Elffuss BraidHub

kikocis/continue public

b804d5856fb5 · 24.3 KiBRawPermalink
1/* eslint-disable max-lines */
2import { type AssistantConfig } from "@continuedev/sdk";
3import { Box, Text, useApp, useInput } from "ink";
4import React, { useCallback, useState } from "react";
5
6import { getAllSlashCommands } from "../commands/commands.js";
7import { useServices } from "../hooks/useService.js";
8import type { PermissionMode } from "../permissions/types.js";
9import type { FileIndexServiceState } from "../services/FileIndexService.js";
10import { SERVICE_NAMES, serviceContainer } from "../services/index.js";
11import { modeService } from "../services/ModeService.js";
12import { messageQueue } from "../stream/messageQueue.js";
13import { InputHistory } from "../util/inputHistory.js";
14
15import { FileSearchUI } from "./FileSearchUI.js";
16import { useClipboardMonitor } from "./hooks/useClipboardMonitor.js";
17import {
18 handleControlKeys,
19 updateTextBufferState,
20} from "./hooks/useUserInput.js";
21import { SlashCommandUI } from "./SlashCommandUI.js";
22import { TextBuffer } from "./TextBuffer.js";
23
24// Small presentational helpers to reduce cyclomatic complexity in UserInput
25const InterruptedBanner: React.FC<{ wasInterrupted: boolean }> = ({
26 wasInterrupted,
27}) => {
28 if (!wasInterrupted) return null;
29 return (
30 <Box paddingX={1} marginBottom={0}>
31 <Text color="yellow">Interrupted by user - Press enter to continue</Text>
32 </Box>
33 );
34};
35
36const SlashCommandsMaybe: React.FC<{
37 show: boolean;
38 inputMode: boolean;
39 hideNormalUI: boolean;
40 isRemoteMode: boolean;
41 assistant?: AssistantConfig;
42 filter: string;
43 selectedIndex: number;
44}> = ({
45 show,
46 inputMode,
47 hideNormalUI,
48 isRemoteMode,
49 assistant,
50 filter,
51 selectedIndex,
52}) => {
53 if (!show || !inputMode || hideNormalUI || !(isRemoteMode || assistant))
54 return null;
55 return (
56 <SlashCommandUI
57 assistant={assistant}
58 filter={filter}
59 selectedIndex={selectedIndex}
60 isRemoteMode={isRemoteMode}
61 />
62 );
63};
64
65const FileSearchMaybe: React.FC<{
66 show: boolean;
67 inputMode: boolean;
68 hideNormalUI: boolean;
69 isRemoteMode: boolean;
70 filter: string;
71 selectedIndex: number;
72 onSelect: (path: string) => void | Promise<void>;
73 onFilesUpdated: (files: Array<{ path: string; displayName: string }>) => void;
74}> = ({
75 show,
76 inputMode,
77 hideNormalUI,
78 isRemoteMode,
79 filter,
80 selectedIndex,
81 onSelect,
82 onFilesUpdated,
83}) => {
84 if (!show || !inputMode || hideNormalUI || isRemoteMode) return null;
85 return (
86 <FileSearchUI
87 filter={filter}
88 selectedIndex={selectedIndex}
89 onSelect={onSelect}
90 onFilesUpdated={onFilesUpdated}
91 />
92 );
93};
94
95interface UserInputProps {
96 onSubmit: (message: string, imageMap?: Map<string, Buffer>) => void;
97 isWaitingForResponse: boolean;
98 inputMode: boolean;
99 onInterrupt?: () => void;
100 assistant?: AssistantConfig;
101 wasInterrupted?: boolean;
102 onFileAttached?: (filePath: string, content: string) => void;
103 disabled?: boolean;
104 placeholder?: string;
105 hideNormalUI?: boolean;
106 isRemoteMode?: boolean;
107 onImageInClipboardChange?: (hasImage: boolean) => void;
108}
109
110const UserInput: React.FC<UserInputProps> = ({
111 onSubmit,
112 isWaitingForResponse,
113 inputMode,
114 onInterrupt,
115 assistant,
116 wasInterrupted = false,
117 onFileAttached,
118 disabled = false,
119 placeholder,
120 hideNormalUI = false,
121 isRemoteMode = false,
122 onImageInClipboardChange,
123}) => {
124 const [textBuffer] = useState(() => new TextBuffer());
125 const [inputHistory] = useState(() => new InputHistory());
126
127 // Stable callback for TextBuffer state changes to prevent race conditions
128 const onStateChange = useCallback(() => {
129 setInputText(textBuffer.text);
130 setCursorPosition(textBuffer.cursor);
131 }, [textBuffer]);
132
133 // Set up callback for when TextBuffer state changes (e.g., rapid input finalized)
134 React.useEffect(() => {
135 textBuffer.setStateChangeCallback(onStateChange);
136
137 // Cleanup on unmount: clear any pending timers
138 return () => {
139 textBuffer.clear();
140 };
141 }, [textBuffer, onStateChange]);
142 const [inputText, setInputText] = useState("");
143 const [cursorPosition, setCursorPosition] = useState(0);
144 const [showSlashCommands, setShowSlashCommands] = useState(false);
145
146 // Clear input function for Ctrl+C
147 const clearInput = useCallback(() => {
148 textBuffer.clear();
149 setInputText("");
150 setCursorPosition(0);
151 setShowSlashCommands(false);
152 setShowFileSearch(false);
153 setShowBashMode(false);
154 inputHistory.resetNavigation();
155 }, [textBuffer]);
156
157 const [slashCommandFilter, setSlashCommandFilter] = useState("");
158 const [selectedCommandIndex, setSelectedCommandIndex] = useState(0);
159 const [showBashMode, setShowBashMode] = useState(false);
160 const [showFileSearch, setShowFileSearch] = useState(false);
161 const [fileSearchFilter, setFileSearchFilter] = useState("");
162 const [selectedFileIndex, setSelectedFileIndex] = useState(0);
163 const [currentFiles, setCurrentFiles] = useState<
164 Array<{ path: string; displayName: string }>
165 >([]);
166 const { exit } = useApp();
167
168 // Get file index service
169 const { services } = useServices<{
170 fileIndex: FileIndexServiceState;
171 }>(["fileIndex"]);
172
173 const getSlashCommands = () => {
174 if (assistant || isRemoteMode) {
175 return getAllSlashCommands(assistant || ({} as AssistantConfig), {
176 isRemoteMode,
177 });
178 }
179
180 // Fallback - basic commands without assistant
181 return [
182 { name: "help", description: "Show help message" },
183 { name: "clear", description: "Clear the chat history" },
184 { name: "exit", description: "Exit the chat" },
185 ];
186 };
187
188 // Cycle through permission modes
189 const cycleModes = async () => {
190 const modes: PermissionMode[] = ["normal", "plan", "auto"];
191 const currentMode = modeService.getCurrentMode();
192 const currentIndex = modes.indexOf(currentMode);
193 const nextIndex = (currentIndex + 1) % modes.length;
194 const nextMode = modes[nextIndex];
195
196 modeService.switchMode(nextMode);
197
198 // Update the service container with the new tool permissions state
199 // Since TOOL_PERMISSIONS was registered with registerValue(), we need to
200 // update its value directly rather than reloading from a factory
201 const updatedState = modeService.getToolPermissionService().getState();
202 serviceContainer.set(SERVICE_NAMES.TOOL_PERMISSIONS, updatedState);
203
204 // Show a brief indicator of the mode change
205 // This will be reflected in the ModeIndicator component
206 return nextMode;
207 };
208
209 // Update shell mode state based on input
210 const updateBashModeState = (text: string) => {
211 const trimmed = text.trimStart();
212 const isBash = trimmed.startsWith("!");
213 setShowBashMode(isBash);
214 if (isBash) {
215 // Disable other helpers while in shell mode
216 setShowSlashCommands(false);
217 setShowFileSearch(false);
218 }
219 };
220
221 // Update slash command UI state based on input
222 const updateSlashCommandState = (text: string, cursor: number) => {
223 // Only show slash commands if slash is the very first character
224 if (!text.trimStart().startsWith("/")) {
225 setShowSlashCommands(false);
226 return;
227 }
228
229 // When using slash commands, disable file search
230 setShowFileSearch(false);
231
232 const trimmedText = text.trimStart();
233 const beforeCursor = trimmedText.slice(
234 0,
235 cursor - (text.length - trimmedText.length),
236 );
237
238 // Only show if cursor is after the slash and before any whitespace
239 if (beforeCursor.length === 0 || !beforeCursor.startsWith("/")) {
240 setShowSlashCommands(false);
241 return;
242 }
243
244 // Get the complete slash command, not just the part before cursor
245 const afterSlash = trimmedText.slice(1).split(/[\s\n]/)[0];
246
247 // We're in a slash command context - check if it's a complete command
248 const allCommands = getSlashCommands();
249 const exactMatch = allCommands.find((cmd) => cmd.name === afterSlash);
250
251 // Hide selector if we have an exact match and there's a space after cursor
252 if (exactMatch) {
253 const restOfText = text.slice(cursor);
254 // Only hide if there's a space or newline immediately after cursor
255 const shouldHide =
256 restOfText.startsWith(" ") || restOfText.startsWith("\n");
257 if (shouldHide) {
258 setShowSlashCommands(false);
259 return;
260 }
261 }
262
263 // Check if there are any matching commands
264 const filteredCommands = allCommands.filter((cmd) =>
265 cmd.name.toLowerCase().includes(afterSlash.toLowerCase()),
266 );
267
268 // If no commands match, hide the dropdown to allow normal Enter behavior
269 if (filteredCommands.length === 0) {
270 setShowSlashCommands(false);
271 return;
272 }
273
274 // Show selector for partial matches
275 setShowSlashCommands(true);
276 setSlashCommandFilter(afterSlash);
277 setSelectedCommandIndex(0);
278 setShowFileSearch(false);
279 };
280
281 // Update file search UI state based on input
282 const updateFileSearchState = (text: string, cursor: number) => {
283 // Don't show file search in remote mode
284 if (isRemoteMode) {
285 setShowFileSearch(false);
286 return;
287 }
288
289 // Disable file search if we're in shell mode or slash command mode
290 const trimmed = text.trimStart();
291 if (trimmed.startsWith("!") || trimmed.startsWith("/")) {
292 setShowFileSearch(false);
293 return;
294 }
295
296 // Check if we're in a file search context
297 const beforeCursor = text.slice(0, cursor);
298 const lastAtIndex = beforeCursor.lastIndexOf("@");
299
300 if (lastAtIndex === -1) {
301 setShowFileSearch(false);
302 } else {
303 // Check if there's any whitespace between the last @ and cursor
304 const afterAt = beforeCursor.slice(lastAtIndex + 1);
305
306 if (afterAt.includes(" ") || afterAt.includes("\n")) {
307 setShowFileSearch(false);
308 } else {
309 // We're in a file search context - check if there are matching files
310 const fileIndexService = services.fileIndex;
311 if (fileIndexService) {
312 const filteredFiles = fileIndexService.files.filter((file) => {
313 if (afterAt.length === 0) {
314 return true;
315 }
316 const lowerFilter = afterAt.toLowerCase();
317 return (
318 file.displayName.toLowerCase().includes(lowerFilter) ||
319 file.path.toLowerCase().includes(lowerFilter)
320 );
321 });
322
323 // If no files match, hide the dropdown to allow normal Enter behavior
324 if (filteredFiles.length === 0 && afterAt.length > 0) {
325 setShowFileSearch(false);
326 return;
327 }
328 }
329
330 setShowFileSearch(true);
331 setFileSearchFilter(afterAt);
332 setSelectedFileIndex(0);
333 setShowSlashCommands(false);
334 setShowBashMode(false);
335 }
336 }
337 };
338
339 // Get filtered commands for navigation - using the same sorting logic as SlashCommandUI
340 const getFilteredCommands = () => {
341 const allCommands = getSlashCommands();
342 return allCommands
343 .filter((cmd) =>
344 cmd.name.toLowerCase().includes(slashCommandFilter.toLowerCase()),
345 )
346 .sort((a, b) => {
347 const aStartsWith = a.name
348 .toLowerCase()
349 .startsWith(slashCommandFilter.toLowerCase());
350 const bStartsWith = b.name
351 .toLowerCase()
352 .startsWith(slashCommandFilter.toLowerCase());
353
354 if (aStartsWith && !bStartsWith) return -1;
355 if (!aStartsWith && bStartsWith) return 1;
356
357 return a.name.localeCompare(b.name);
358 });
359 };
360
361 // Handle slash command selection
362 const selectSlashCommand = (commandName: string) => {
363 const beforeCursor = inputText.slice(0, cursorPosition);
364 const lastSlashIndex = beforeCursor.lastIndexOf("/");
365
366 if (lastSlashIndex !== -1) {
367 const beforeSlash = inputText.slice(0, lastSlashIndex);
368 const afterCursor = inputText.slice(cursorPosition);
369
370 // Replace the partial command with the full command
371 const newText = beforeSlash + "/" + commandName + " " + afterCursor;
372 const newCursorPos = lastSlashIndex + 1 + commandName.length + 1;
373
374 textBuffer.setText(newText);
375 textBuffer.setCursor(newCursorPos);
376 setInputText(newText);
377 setCursorPosition(newCursorPos);
378 setShowSlashCommands(false);
379 setShowBashMode(false);
380 }
381 };
382
383 // Handle file selection
384 const selectFile = async (filePath: string) => {
385 const beforeCursor = inputText.slice(0, cursorPosition);
386 const lastAtIndex = beforeCursor.lastIndexOf("@");
387
388 if (lastAtIndex !== -1) {
389 const beforeAt = inputText.slice(0, lastAtIndex);
390 const afterCursor = inputText.slice(cursorPosition);
391
392 // Replace the partial file reference with the full file path
393 const newText = beforeAt + "@" + filePath + " " + afterCursor;
394 const newCursorPos = lastAtIndex + 1 + filePath.length + 1;
395
396 textBuffer.setText(newText);
397 textBuffer.setCursor(newCursorPos);
398 setInputText(newText);
399 setCursorPosition(newCursorPos);
400 setShowFileSearch(false);
401
402 // Read the file content and notify parent component
403 if (onFileAttached) {
404 try {
405 const fs = await import("fs/promises");
406 const path = await import("path");
407 const absolutePath = path.resolve(filePath);
408 const content = await fs.readFile(absolutePath, "utf-8");
409 onFileAttached(absolutePath, content);
410 } catch (error) {
411 console.error(`Error reading file ${filePath}:`, error);
412 }
413 }
414 }
415 };
416
417 const handleSlashCommandNavigation = (key: any): boolean => {
418 const filteredCommands = getFilteredCommands();
419
420 if (key.upArrow) {
421 setSelectedCommandIndex((prev) =>
422 prev > 0 ? prev - 1 : filteredCommands.length - 1,
423 );
424 return true;
425 }
426
427 if (key.downArrow) {
428 setSelectedCommandIndex((prev) =>
429 prev < filteredCommands.length - 1 ? prev + 1 : 0,
430 );
431 return true;
432 }
433
434 if ((key.return && !key.shift) || key.tab) {
435 if (filteredCommands.length > 0) {
436 selectSlashCommand(filteredCommands[selectedCommandIndex].name);
437 }
438 return true;
439 }
440
441 return false;
442 };
443
444 const handleFileSearchNavigation = (key: any): boolean => {
445 if (key.upArrow) {
446 setSelectedFileIndex((prev) =>
447 prev > 0 ? prev - 1 : Math.max(0, Math.min(currentFiles.length - 1, 9)),
448 );
449 return true;
450 }
451
452 if (key.downArrow) {
453 setSelectedFileIndex((prev) =>
454 prev < Math.min(currentFiles.length - 1, 9) ? prev + 1 : 0,
455 );
456 return true;
457 }
458
459 if ((key.return && !key.shift) || key.tab) {
460 if (currentFiles.length > 0 && selectedFileIndex < currentFiles.length) {
461 selectFile(currentFiles[selectedFileIndex].path);
462 }
463 return true;
464 }
465
466 return false;
467 };
468
469 const handleHistoryNavigation = (key: any): boolean => {
470 if (!showSlashCommands && !showFileSearch) {
471 if (key.upArrow) {
472 const historyEntry = inputHistory.navigateUp(inputText);
473 if (historyEntry !== null) {
474 textBuffer.setText(historyEntry);
475 textBuffer.setCursor(historyEntry.length);
476 setInputText(historyEntry);
477 setCursorPosition(historyEntry.length);
478 }
479 return true;
480 }
481
482 if (key.downArrow) {
483 const historyEntry = inputHistory.navigateDown();
484 if (historyEntry !== null) {
485 textBuffer.setText(historyEntry);
486 textBuffer.setCursor(historyEntry.length);
487 setInputText(historyEntry);
488 setCursorPosition(historyEntry.length);
489 }
490 return true;
491 }
492 }
493 return false;
494 };
495
496 const handleEnterKey = (key: any): boolean => {
497 if (key.return && !key.shift) {
498 // Check for backslash continuation
499 const beforeCursor = textBuffer.text.slice(0, cursorPosition);
500 const trimmedBeforeCursor = beforeCursor.trimEnd();
501
502 if (trimmedBeforeCursor.endsWith("\\")) {
503 // Handle backslash continuation: remove the trailing "\" and add newline
504 const beforeBackslash = trimmedBeforeCursor.slice(0, -1);
505 const afterCursor = textBuffer.text.slice(cursorPosition);
506 const newText = beforeBackslash + "\n" + afterCursor;
507 const newCursorPos = beforeBackslash.length + 1;
508
509 textBuffer.setText(newText);
510 textBuffer.setCursor(newCursorPos);
511 setInputText(newText);
512 setCursorPosition(newCursorPos);
513 updateSlashCommandState(newText, newCursorPos);
514 updateFileSearchState(newText, newCursorPos);
515 return true;
516 }
517
518 // Normal Enter behavior - submit if there's content
519 if (textBuffer.text.trim() || wasInterrupted) {
520 // Get images before expanding paste blocks
521 const imageMap = textBuffer.getAllImages();
522
523 // Expand all paste blocks before submitting
524 textBuffer.expandAllPasteBlocks();
525 const submittedText = textBuffer.text.trim();
526
527 if (isWaitingForResponse) {
528 // Process message later when LLM has responded
529 void messageQueue.enqueueMessage(
530 submittedText,
531 imageMap,
532 inputHistory,
533 );
534 } else {
535 // Submit with images
536 inputHistory.addEntry(submittedText);
537 onSubmit(submittedText, imageMap);
538 }
539
540 textBuffer.clear();
541 setInputText("");
542 setCursorPosition(0);
543 setShowSlashCommands(false);
544 setShowBashMode(false);
545 }
546 return true;
547 }
548 return false;
549 };
550
551 const handleNewLine = (input: string, key: any): boolean => {
552 if (input === "\r" || input === "\\\r") {
553 const handled = textBuffer.handleInput("\n", key);
554 if (handled) {
555 const newText = textBuffer.text;
556 const newCursor = textBuffer.cursor;
557 setInputText(newText);
558 setCursorPosition(newCursor);
559 updateSlashCommandState(newText, newCursor);
560 updateFileSearchState(newText, newCursor);
561 }
562 return true;
563 }
564 return false;
565 };
566
567 const handleEscapeKey = (key: any): boolean => {
568 if (!key.escape) return false;
569
570 // If only "!" is present, clear shell mode
571 if (inputMode && showBashMode && inputText.trim() === "!") {
572 textBuffer.clear();
573 setInputText("");
574 setCursorPosition(0);
575 setShowBashMode(false);
576 return true;
577 }
578
579 // Handle escape key to interrupt streaming
580 if (isWaitingForResponse && onInterrupt) {
581 onInterrupt();
582 return true;
583 }
584
585 // Handle escape key to close slash command UI
586 if (showSlashCommands && inputMode) {
587 setShowSlashCommands(false);
588 return true;
589 }
590
591 // Handle escape key to close file search UI
592 if (showFileSearch && inputMode) {
593 setShowFileSearch(false);
594 return true;
595 }
596
597 return false;
598 };
599
600 // Handle text buffer updates for async operations like image pasting
601 const handleTextBufferUpdate = () => {
602 const newText = textBuffer.text;
603 const newCursor = textBuffer.cursor;
604 setInputText(newText);
605 setCursorPosition(newCursor);
606 updateSlashCommandState(newText, newCursor);
607 updateFileSearchState(newText, newCursor);
608 updateBashModeState(newText);
609 inputHistory.resetNavigation();
610 };
611
612 // State for showing image paste hint
613 const [_hasImageInClipboard, _setHasImageInClipboard] = useState(false);
614
615 // Monitor clipboard for images and show helpful hints
616 const { checkNow: _checkClipboardNow } = useClipboardMonitor({
617 onImageStatusChange: (hasImage) => {
618 _setHasImageInClipboard(hasImage);
619 // Also notify parent component
620 if (onImageInClipboardChange) {
621 onImageInClipboardChange(hasImage);
622 }
623 },
624 enabled: !disabled && inputMode,
625 pollInterval: 2000,
626 });
627
628 useInput((input, key) => {
629 // Don't handle any input when disabled
630 if (disabled) {
631 return;
632 }
633
634 // Handle control keys
635 if (
636 handleControlKeys({
637 input,
638 key,
639 exit,
640 showSlashCommands,
641 showFileSearch,
642 cycleModes,
643 clearInput,
644 textBuffer,
645 onTextBufferUpdate: handleTextBufferUpdate,
646 })
647 ) {
648 return;
649 }
650
651 // Handle escape key variations
652 if (handleEscapeKey(key)) {
653 return;
654 }
655
656 // Handle slash command navigation
657 if (showSlashCommands) {
658 if (handleSlashCommandNavigation(key)) {
659 return;
660 }
661 }
662
663 // Handle file search navigation
664 if (showFileSearch) {
665 if (handleFileSearchNavigation(key)) {
666 return;
667 }
668 }
669
670 // Handle input history navigation
671 if (handleHistoryNavigation(key)) {
672 return;
673 }
674
675 // Handle Enter key
676 if (handleEnterKey(key)) {
677 return;
678 }
679
680 // Handle Shift+Enter (new line)
681 if (handleNewLine(input, key)) {
682 return;
683 }
684
685 // Let TextBuffer handle the input
686 const handled = textBuffer.handleInput(input, key);
687
688 // Update React state to trigger re-render
689 updateTextBufferState({
690 handled,
691 textBuffer,
692 setInputText,
693 setCursorPosition,
694 updateSlashCommandState,
695 updateFileSearchState,
696 updateBashModeState,
697 inputHistory,
698 });
699 });
700
701 const renderInputText = () => {
702 const placeholderText = isRemoteMode
703 ? "Ask anything, / for slash commands, ! for shell mode"
704 : placeholder ||
705 "Ask anything, @ for context, / for slash commands, ! for shell mode";
706 if (inputText.length === 0) {
707 return (
708 <>
709 {(inputMode || isWaitingForResponse) && (
710 <Text italic color="gray">
711 ▋{placeholderText}
712 </Text>
713 )}
714 {!inputMode && !isWaitingForResponse && (
715 <Text italic color="gray">
716 {placeholderText}
717 </Text>
718 )}
719 </>
720 );
721 }
722
723 if (inputMode || isWaitingForResponse) {
724 // Handle multi-line text with cursor
725 const lines = inputText.split("\n");
726 let charCount = 0;
727 let cursorLine = 0;
728 let cursorCol = 0;
729
730 // Find which line and column the cursor is on
731 for (let i = 0; i < lines.length; i++) {
732 if (cursorPosition <= charCount + lines[i].length) {
733 cursorLine = i;
734 cursorCol = cursorPosition - charCount;
735 break;
736 }
737 charCount += lines[i].length + 1; // +1 for the newline character
738 }
739
740 // Handle cursor at the very end
741 if (cursorPosition >= inputText.length) {
742 cursorLine = lines.length - 1;
743 cursorCol = lines[cursorLine].length;
744 }
745
746 return (
747 <Box flexDirection="column">
748 {lines.map((line, lineIndex) => {
749 if (lineIndex === cursorLine) {
750 // Line with cursor
751 const beforeCursor = line.slice(0, cursorCol);
752 const atCursor = line.slice(cursorCol, cursorCol + 1);
753 const afterCursor = line.slice(cursorCol + 1);
754
755 return (
756 <Text key={lineIndex}>
757 {beforeCursor}
758 <Text inverse>{atCursor || " "}</Text>
759 {afterCursor}
760 </Text>
761 );
762 } else {
763 // Regular line - ensure empty lines still render
764 return <Text key={lineIndex}>{line || " "}</Text>;
765 }
766 })}
767 </Box>
768 );
769 } else {
770 // Not in input mode, just display the text
771 return (
772 <Box flexDirection="column">
773 {inputText.split("\n").map((line, index) => (
774 <Text key={index}>{line || " "}</Text>
775 ))}
776 </Box>
777 );
778 }
779 };
780
781 // Don't render anything when disabled
782 if (disabled) {
783 return null;
784 }
785
786 return (
787 <Box flexDirection="column">
788 <InterruptedBanner wasInterrupted={!!wasInterrupted} />
789
790 {/* Input box */}
791 <Box
792 borderStyle="round"
793 borderTop={true}
794 paddingX={1}
795 borderColor={showBashMode ? "yellow" : isRemoteMode ? "cyan" : "gray"}
796 >
797 <Text
798 color={showBashMode ? "yellow" : isRemoteMode ? "cyan" : "blue"}
799 bold
800 >
801 {showBashMode ? "$ " : isRemoteMode ? "◉ " : "● "}
802 </Text>
803 {renderInputText()}
804 </Box>
805
806 <SlashCommandsMaybe
807 show={showSlashCommands}
808 inputMode={inputMode}
809 hideNormalUI={!!hideNormalUI}
810 isRemoteMode={!!isRemoteMode}
811 assistant={assistant}
812 filter={slashCommandFilter}
813 selectedIndex={selectedCommandIndex}
814 />
815
816 <FileSearchMaybe
817 show={showFileSearch}
818 inputMode={inputMode}
819 hideNormalUI={!!hideNormalUI}
820 isRemoteMode={!!isRemoteMode}
821 filter={fileSearchFilter}
822 selectedIndex={selectedFileIndex}
823 onSelect={selectFile}
824 onFilesUpdated={setCurrentFiles}
825 />
826 </Box>
827 );
828};
829
830export { UserInput };