-
Notifications
You must be signed in to change notification settings - Fork 2.1k
#1777: minimal implementation. #1848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -816,6 +816,9 @@ export default function ChatView(props: ChatViewProps) { | |
| const attachmentPreviewHandoffTimeoutByMessageIdRef = useRef<Record<string, number>>({}); | ||
| const sendInFlightRef = useRef(false); | ||
| const dragDepthRef = useRef(0); | ||
| const inputHistoryRef = useRef<string[]>([]); | ||
| const historyIdxRef = useRef(-1); | ||
| const historyDraftRef = useRef(''); | ||
| const terminalOpenByThreadRef = useRef<Record<string, boolean>>({}); | ||
| const setMessagesScrollContainerRef = useCallback((element: HTMLDivElement | null) => { | ||
| messagesScrollRef.current = element; | ||
|
|
@@ -2509,6 +2512,14 @@ export default function ChatView(props: ChatViewProps) { | |
| composerTerminalContextsRef.current = composerTerminalContexts; | ||
| }, [composerTerminalContexts]); | ||
|
|
||
| useEffect(() => { | ||
| inputHistoryRef.current = (activeThread?.messages ?? []) | ||
| .filter((m) => m.role === 'user' && m.text.trim()) | ||
| .map((m) => m.text.trim()) | ||
| .reverse(); | ||
| historyIdxRef.current = -1; | ||
| }, [activeThread?.id]); // eslint-disable-line react-hooks/exhaustive-deps | ||
|
|
||
| useEffect(() => { | ||
| if (!activeThread?.id) return; | ||
| if (activeThread.messages.length === 0) { | ||
|
|
@@ -3178,6 +3189,7 @@ export default function ChatView(props: ChatViewProps) { | |
| description: toastCopy.description, | ||
| }); | ||
| } | ||
| if (promptForSend.trim()) { inputHistoryRef.current.unshift(promptForSend.trim()); historyIdxRef.current = -1; } | ||
| promptRef.current = ""; | ||
| clearComposerDraftContent(scopeThreadRef(activeThread.environmentId, threadIdForSend)); | ||
| setComposerHighlightedItemId(null); | ||
|
|
@@ -4066,6 +4078,18 @@ export default function ChatView(props: ChatViewProps) { | |
| } | ||
| } | ||
|
|
||
| if (key === 'ArrowUp' && inputHistoryRef.current.length > 0 && !promptRef.current.includes('\n')) { | ||
| if (historyIdxRef.current === -1) historyDraftRef.current = promptRef.current; | ||
| historyIdxRef.current = Math.min(historyIdxRef.current + 1, inputHistoryRef.current.length - 1); | ||
| setPrompt(inputHistoryRef.current[historyIdxRef.current]!); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. History navigation doesn't synchronously update promptRefHigh Severity The composer's new history navigation updates the prompt state but not Reviewed by Cursor Bugbot for commit 375ee94. Configure here.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this does not happen during testing. |
||
| return true; | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| } | ||
| if (key === 'ArrowDown' && historyIdxRef.current >= 0) { | ||
| const next = historyIdxRef.current - 1; | ||
| historyIdxRef.current = next; | ||
| setPrompt(next >= 0 ? inputHistoryRef.current[next]! : historyDraftRef.current); | ||
| return true; | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| } | ||
| if (key === "Enter" && !event.shiftKey) { | ||
| void onSend(); | ||
| return true; | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.