Changesets · Branches · Tags · Compare
| Changeset | e46c9aad1fc244e6aab0620e5f1db1f99fa70202da67dd10b76ce1c250ffb89e |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-09-24 13:23 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-09-24 13:23 -07:00 |
| Parents | 36b51df0a775 |
3 files changed
modified gui/src/components/mainInput/Lump/LumpToolbar/LumpToolbar.tsx +13 −2
| @@ -12,6 +12,7 @@ | ||
| 12 | 12 | import { cancelStream } from "../../../../redux/thunks/cancelStream"; |
| 13 | 13 | import { logToolUsage } from "../../../../redux/util"; |
| 14 | 14 | import { isJetBrains } from "../../../../util"; |
| 15 | +import { useMainEditor } from "../../TipTapEditor"; | |
| 15 | 16 | import { BlockSettingsTopToolbar } from "./BlockSettingsTopToolbar"; |
| 16 | 17 | import { EditOutcomeToolbar } from "./EditOutcomeToolbar"; |
| 17 | 18 | import { EditToolbar } from "./EditToolbar"; |
| @@ -64,6 +65,7 @@ | ||
| 64 | 65 | (state) => state.status === "done", |
| 65 | 66 | ); |
| 66 | 67 | const isApplying = applyStates.some((state) => state.status === "streaming"); |
| 68 | + const editor = useMainEditor(); | |
| 67 | 69 | |
| 68 | 70 | // Get ALL running terminal commands |
| 69 | 71 | const runningToolCalls = useAppSelector((state) => |
| @@ -140,7 +142,10 @@ | ||
| 140 | 142 | // Stop running terminal commands |
| 141 | 143 | void handleStopAction(); |
| 142 | 144 | } else if (firstPendingToolCall) { |
| 143 | - // Cancel pending tool call | |
| 145 | + // Cancel pending tool call. If last call, focus editor | |
| 146 | + if (pendingToolCalls.length === 1) { | |
| 147 | + editor.mainEditor?.commands.focus(); | |
| 148 | + } | |
| 144 | 149 | void dispatch( |
| 145 | 150 | cancelToolCall({ |
| 146 | 151 | toolCallId: firstPendingToolCall.toolCallId, |
| @@ -155,7 +160,13 @@ | ||
| 155 | 160 | return () => { |
| 156 | 161 | document.removeEventListener("keydown", handleToolCallKeyboardShortcuts); |
| 157 | 162 | }; |
| 158 | - }, [firstPendingToolCall, hasRunningTerminalCommand, runningTerminalCalls]); | |
| 163 | + }, [ | |
| 164 | + firstPendingToolCall, | |
| 165 | + pendingToolCalls, | |
| 166 | + editor, | |
| 167 | + hasRunningTerminalCommand, | |
| 168 | + runningTerminalCalls, | |
| 169 | + ]); | |
| 159 | 170 | |
| 160 | 171 | if (isApplying) { |
| 161 | 172 | return <IsApplyingToolbar />; |
modified gui/src/components/mainInput/Lump/LumpToolbar/PendingToolCallToolbar.tsx +6 −0
| @@ -4,6 +4,7 @@ | ||
| 4 | 4 | import { cancelToolCallThunk } from "../../../../redux/thunks/cancelToolCall"; |
| 5 | 5 | import { getAltKeyLabel, getMetaKeyLabel, isJetBrains } from "../../../../util"; |
| 6 | 6 | import { Button } from "../../../ui"; |
| 7 | +import { useMainEditor } from "../../TipTapEditor"; | |
| 7 | 8 | |
| 8 | 9 | export const generateToolCallButtonTestId = ( |
| 9 | 10 | action: "accept" | "reject", |
| @@ -16,6 +17,7 @@ | ||
| 16 | 17 | const dispatch = useAppDispatch(); |
| 17 | 18 | const jetbrains = isJetBrains(); |
| 18 | 19 | const pendingToolCalls = useAppSelector(selectPendingToolCalls); |
| 20 | + const editor = useMainEditor(); | |
| 19 | 21 | |
| 20 | 22 | if (pendingToolCalls.length === 0) { |
| 21 | 23 | return null; |
| @@ -26,6 +28,10 @@ | ||
| 26 | 28 | }; |
| 27 | 29 | |
| 28 | 30 | const handleReject = (toolCallId: string) => { |
| 31 | + // put cursor in editor after last rejection | |
| 32 | + if (pendingToolCalls.length === 1) { | |
| 33 | + editor.mainEditor?.commands.focus(); | |
| 34 | + } | |
| 29 | 35 | void dispatch(cancelToolCallThunk({ toolCallId })); |
| 30 | 36 | }; |
| 31 | 37 |
modified gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx +16 −18
| @@ -185,24 +185,22 @@ | ||
| 185 | 185 | const statusIcon = useMemo(() => { |
| 186 | 186 | const status = toolCallState?.status; |
| 187 | 187 | if (status) { |
| 188 | - if (status === "canceled" || status === "errored" || status === "done") { | |
| 189 | - return ( | |
| 190 | - <div | |
| 191 | - className={`mr-1 h-4 w-4 flex-shrink-0 ${toolCallState.output ? "cursor-pointer" : ""}`} | |
| 192 | - onClick={(e) => { | |
| 193 | - if (toolCallState.output) { | |
| 194 | - e.stopPropagation(); | |
| 195 | - ideMessenger.post("showVirtualFile", { | |
| 196 | - name: "Edit output", | |
| 197 | - content: renderContextItems(toolCallState.output), | |
| 198 | - }); | |
| 199 | - } | |
| 200 | - }} | |
| 201 | - > | |
| 202 | - {getStatusIcon(toolCallState.status)} | |
| 203 | - </div> | |
| 204 | - ); | |
| 205 | - } | |
| 188 | + return ( | |
| 189 | + <div | |
| 190 | + className={`mr-1 h-4 w-4 flex-shrink-0 ${toolCallState.output ? "cursor-pointer" : ""}`} | |
| 191 | + onClick={(e) => { | |
| 192 | + if (toolCallState.output) { | |
| 193 | + e.stopPropagation(); | |
| 194 | + ideMessenger.post("showVirtualFile", { | |
| 195 | + name: "Edit output", | |
| 196 | + content: renderContextItems(toolCallState.output), | |
| 197 | + }); | |
| 198 | + } | |
| 199 | + }} | |
| 200 | + > | |
| 201 | + {getStatusIcon(status)} | |
| 202 | + </div> | |
| 203 | + ); | |
| 206 | 204 | } |
| 207 | 205 | }, [toolCallState?.status, toolCallState?.output]); |
| 208 | 206 |