-
Notifications
You must be signed in to change notification settings - Fork 1.5k
#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
base: main
Are you sure you want to change the base?
Changes from all commits
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,19 @@ export default function ChatView(props: ChatViewProps) { | |
| } | ||
| } | ||
|
|
||
| const cur = composerEditorRef.current?.readSnapshot()?.cursor ?? 0; | ||
| if (key === 'ArrowUp' && inputHistoryRef.current.length > 0 && !promptRef.current.slice(0, cur).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.
Show resolved
Hide resolved
|
||
| } | ||
| if (key === 'ArrowDown' && historyIdxRef.current >= 0 && !promptRef.current.slice(cur).includes('\n')) { | ||
| 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.
Show resolved
Hide resolved
|
||
| } | ||
| if (key === "Enter" && !event.shiftKey) { | ||
| void onSend(); | ||
| return true; | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
History index not reset on early-return send paths
Low Severity
The plan-follow-up path and standalone-slash-command path both clear the prompt and return early from
onSend, never reaching thehistoryIdxRef.current = -1reset at line 3192. If the user was navigating history before triggering either path,historyIdxRefremains positive, so a subsequent ArrowDown would unexpectedly restore a history entry instead of behaving as normal cursor movement.Additional Locations (1)
apps/web/src/components/ChatView.tsx#L3089-L3097Reviewed by Cursor Bugbot for commit 069183c. Configure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cant produce any buggy interactions with slash commands.