From 7cb78fe20935d32045b4d319bf508eedd5d782fb Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Jul 2025 13:11:43 -0700 Subject: [PATCH] Rename callCurrentTool to callToolById for clarity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Renamed function from callCurrentTool to callToolById to better reflect its purpose - Updated function signature to accept toolCallId parameter for parallel tool execution - Renamed file from callCurrentTool.ts to callToolById.ts - Updated all import paths and call sites across codebase - Verified TypeScript compilation passes - All utility function tests still pass (21/21) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../mainInput/Lump/LumpToolbar/LumpToolbar.tsx | 6 ++++-- .../Lump/LumpToolbar/PendingToolCallToolbar.tsx | 8 ++++++-- .../{callCurrentTool.ts => callToolById.ts} | 15 +++++++++------ gui/src/redux/thunks/streamNormalInput.ts | 6 ++++-- 4 files changed, 23 insertions(+), 12 deletions(-) rename gui/src/redux/thunks/{callCurrentTool.ts => callToolById.ts} (92%) diff --git a/gui/src/components/mainInput/Lump/LumpToolbar/LumpToolbar.tsx b/gui/src/components/mainInput/Lump/LumpToolbar/LumpToolbar.tsx index 466887a3e..6f04c18db 100644 --- a/gui/src/components/mainInput/Lump/LumpToolbar/LumpToolbar.tsx +++ b/gui/src/components/mainInput/Lump/LumpToolbar/LumpToolbar.tsx @@ -4,7 +4,7 @@ import { IdeMessengerContext } from "../../../../context/IdeMessenger"; import { useAppDispatch, useAppSelector } from "../../../../redux/hooks"; import { selectCurrentToolCall } from "../../../../redux/selectors/selectCurrentToolCall"; import { cancelToolCall } from "../../../../redux/slices/sessionSlice"; -import { callCurrentTool } from "../../../../redux/thunks/callCurrentTool"; +import { callToolById } from "../../../../redux/thunks/callToolById"; import { logToolUsage } from "../../../../redux/util"; import { isJetBrains } from "../../../../util"; import { BlockSettingsTopToolbar } from "./BlockSettingsTopToolbar"; @@ -48,7 +48,9 @@ export function LumpToolbar() { if (metaKey && event.key === "Enter") { event.preventDefault(); event.stopPropagation(); - void dispatch(callCurrentTool()); + void dispatch( + callToolById({ toolCallId: toolCallState.toolCallId }) + ); } else if ((jetbrains ? altKey : metaKey) && event.key === "Backspace") { event.preventDefault(); event.stopPropagation(); diff --git a/gui/src/components/mainInput/Lump/LumpToolbar/PendingToolCallToolbar.tsx b/gui/src/components/mainInput/Lump/LumpToolbar/PendingToolCallToolbar.tsx index 3cb6acc2d..c67b32fff 100644 --- a/gui/src/components/mainInput/Lump/LumpToolbar/PendingToolCallToolbar.tsx +++ b/gui/src/components/mainInput/Lump/LumpToolbar/PendingToolCallToolbar.tsx @@ -2,7 +2,7 @@ import styled from "styled-components"; import { useAppDispatch, useAppSelector } from "../../../../redux/hooks"; import { selectCurrentToolCall } from "../../../../redux/selectors/selectCurrentToolCall"; import { cancelToolCall } from "../../../../redux/slices/sessionSlice"; -import { callCurrentTool } from "../../../../redux/thunks/callCurrentTool"; +import { callToolById } from "../../../../redux/thunks/callToolById"; import { getAltKeyLabel, getFontSize, @@ -58,7 +58,11 @@ export function PendingToolCallToolbar() { dispatch(callCurrentTool())} + onClick={() => + currentToolCall && dispatch( + callToolById({ toolCallId: currentToolCall.toolCallId }) + ) + } data-testid="accept-tool-call-button" > {getMetaKeyLabel()} ⏎ Continue diff --git a/gui/src/redux/thunks/callCurrentTool.ts b/gui/src/redux/thunks/callToolById.ts similarity index 92% rename from gui/src/redux/thunks/callCurrentTool.ts rename to gui/src/redux/thunks/callToolById.ts index cedebe4f9..67646527a 100644 --- a/gui/src/redux/thunks/callCurrentTool.ts +++ b/gui/src/redux/thunks/callToolById.ts @@ -3,7 +3,7 @@ import { ContextItem } from "core"; import { CLIENT_TOOLS_IMPLS } from "core/tools/builtIn"; import posthog from "posthog-js"; import { callClientTool } from "../../util/clientTools/callClientTool"; -import { selectCurrentToolCall } from "../selectors/selectCurrentToolCall"; +import { findToolCall } from "../util"; import { selectSelectedChatModel } from "../slices/configSlice"; import { acceptToolCall, @@ -15,12 +15,17 @@ import { ThunkApiType } from "../store"; import { logToolUsage } from "../util"; import { streamResponseAfterToolCall } from "./streamResponseAfterToolCall"; -export const callCurrentTool = createAsyncThunk( +export const callToolById = createAsyncThunk< + void, + { toolCallId: string }, + ThunkApiType +>( "chat/callTool", - async (_, { dispatch, extra, getState }) => { + async ({ toolCallId }, { dispatch, extra, getState }) => { const state = getState(); - const toolCallState = selectCurrentToolCall(state); + const toolCallState = findToolCall(state.session.history, toolCallId); if (!toolCallState) { + console.warn(`Tool call with ID ${toolCallId} not found`); return; } @@ -34,8 +39,6 @@ export const callCurrentTool = createAsyncThunk( throw new Error("No model selected"); } - const { toolCallId } = toolCallState; - dispatch( setToolCallCalling({ toolCallId, diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index ab86aa85c..3648ee1ba 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -19,7 +19,7 @@ import { constructMessages, getBaseSystemMessage, } from "../util/constructMessages"; -import { callCurrentTool } from "./callCurrentTool"; +import { callToolById } from "./callToolById"; export const streamNormalInput = createAsyncThunk< void, @@ -160,7 +160,9 @@ export const streamNormalInput = createAsyncThunk< toolSettings[toolCallState.toolCall.function.name] === "allowedWithoutPermission" ) { - const response = await dispatch(callCurrentTool()); + const response = await dispatch( + callToolById({ toolCallId: toolCallState.toolCallId }) + ); unwrapResult(response); } }