fix(cli): fix issue updating a component while rendering a different component (#14319)

This commit is contained in:
Jacob Richman
2025-12-01 17:33:03 -08:00
committed by GitHub
parent 98d7238ed6
commit 1689e9b671
9 changed files with 43 additions and 90 deletions

View File

@@ -83,7 +83,7 @@ export interface InputPromptProps {
isEmbeddedShellFocused?: boolean;
setQueueErrorMessage: (message: string | null) => void;
streamingState: StreamingState;
popAllMessages?: (onPop: (messages: string | undefined) => void) => void;
popAllMessages?: () => string | undefined;
suggestionsPosition?: 'above' | 'below';
setBannerVisible: (visible: boolean) => void;
}
@@ -143,15 +143,6 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
const pasteTimeoutRef = useRef<NodeJS.Timeout | null>(null);
const innerBoxRef = useRef<DOMElement>(null);
const [dirs, setDirs] = useState<readonly string[]>(
config.getWorkspaceContext().getDirectories(),
);
const dirsChanged = config.getWorkspaceContext().getDirectories();
useEffect(() => {
if (dirs.length !== dirsChanged.length) {
setDirs(dirsChanged);
}
}, [dirs.length, dirsChanged]);
const [reverseSearchActive, setReverseSearchActive] = useState(false);
const [commandSearchActive, setCommandSearchActive] = useState(false);
const [textBeforeReverseSearch, setTextBeforeReverseSearch] = useState('');
@@ -165,7 +156,6 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
const completion = useCommandCompletion(
buffer,
dirs,
config.getTargetDir(),
slashCommands,
commandContext,
@@ -310,14 +300,13 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
// Returns true if we should continue with input history navigation
const tryLoadQueuedMessages = useCallback(() => {
if (buffer.text.trim() === '' && popAllMessages) {
popAllMessages((allMessages) => {
if (allMessages) {
buffer.setText(allMessages);
} else {
// No queued messages, proceed with input history
inputHistory.navigateUp();
}
});
const allMessages = popAllMessages();
if (allMessages) {
buffer.setText(allMessages);
} else {
// No queued messages, proceed with input history
inputHistory.navigateUp();
}
return true; // We handled the up arrow key
}
return false;