-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add stop thread keybinding command #4308
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 |
|---|---|---|
|
|
@@ -2405,6 +2405,21 @@ function ChatViewContent(props: ChatViewProps) { | |
| [draftId, routeThreadKey, routeThreadRef, serverThread], | ||
| ); | ||
|
|
||
| const onInterrupt = useCallback(async () => { | ||
| if (!activeThread) return; | ||
| const result = await interruptThreadTurn({ | ||
| environmentId, | ||
| input: buildThreadTurnInterruptInput(activeThread), | ||
| }); | ||
| if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) { | ||
| const error = squashAtomCommandFailure(result); | ||
| setThreadError( | ||
| activeThread.id, | ||
| error instanceof Error ? error.message : "Failed to interrupt the current turn.", | ||
| ); | ||
| } | ||
| }, [activeThread, environmentId, interruptThreadTurn, setThreadError]); | ||
|
|
||
| const focusComposer = useCallback(() => { | ||
| composerRef.current?.focusAtEnd(); | ||
| }, [composerRef]); | ||
|
|
@@ -3931,6 +3946,13 @@ function ChatViewContent(props: ChatViewProps) { | |
| return; | ||
| } | ||
|
|
||
| if (command === "thread.stop") { | ||
| event.preventDefault(); | ||
| event.stopPropagation(); | ||
| void onInterrupt(); | ||
|
Comment on lines
+3949
to
+3952
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.
When a custom Useful? React with 👍 / 👎. |
||
| return; | ||
|
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. Stop shortcut ignores running stateMedium Severity The new Reviewed by Cursor Bugbot for commit 7ae0496. Configure here. |
||
| } | ||
|
|
||
| const scriptId = projectScriptIdFromCommand(command); | ||
| if (!scriptId || !activeProject) return; | ||
| const script = activeProject.scripts.find((entry) => entry.id === scriptId); | ||
|
|
@@ -3956,6 +3978,7 @@ function ChatViewContent(props: ChatViewProps) { | |
| splitTerminal, | ||
| splitPanelTerminal, | ||
| keybindings, | ||
| onInterrupt, | ||
| onToggleDiff, | ||
| toggleRightPanel, | ||
| toggleTerminalVisibility, | ||
|
|
@@ -4411,21 +4434,6 @@ function ChatViewContent(props: ChatViewProps) { | |
| } | ||
| }; | ||
|
|
||
| const onInterrupt = async () => { | ||
| if (!activeThread) return; | ||
| const result = await interruptThreadTurn({ | ||
| environmentId, | ||
| input: buildThreadTurnInterruptInput(activeThread), | ||
| }); | ||
| if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) { | ||
| const error = squashAtomCommandFailure(result); | ||
| setThreadError( | ||
| activeThread.id, | ||
| error instanceof Error ? error.message : "Failed to interrupt the current turn.", | ||
| ); | ||
| } | ||
| }; | ||
|
|
||
| const onRespondToApproval = useCallback( | ||
| async (requestId: ApprovalRequestId, decision: ProviderApprovalDecision) => { | ||
| if (!activeThreadId) return; | ||
|
|
||


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.
Held stop key repeats interrupt
Low Severity
The
thread.stopkeydown branch does not ignoreevent.repeat, so holding the bound key can enqueue multipleonInterruptcalls. Other thread-related shortcuts in the sidebar explicitly bail out whenevent.repeatis true.Reviewed by Cursor Bugbot for commit 7ae0496. Configure here.