diff --git a/core/index.d.ts b/core/index.d.ts index 89342db42..093841349 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -461,7 +461,6 @@ export interface ChatHistoryItem { editorState?: any; modifiers?: InputModifiers; promptLogs?: PromptLog[]; - toolCallState?: ToolCallState; toolCallStates?: ToolCallState[]; // Support for multiple parallel tool calls isGatheringContext?: boolean; reasoning?: Reasoning; diff --git a/core/tools/definitions/lsTool.ts b/core/tools/definitions/lsTool.ts index a0bb96cbb..979f9450b 100644 --- a/core/tools/definitions/lsTool.ts +++ b/core/tools/definitions/lsTool.ts @@ -4,7 +4,7 @@ import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; export const lsTool: Tool = { type: "function", - displayTitle: "LS Tool", + displayTitle: "ls", wouldLikeTo: "list files and folders in {{{ dirPath }}}", isCurrently: "listing files and folders in {{{ dirPath }}}", hasAlready: "listed files and folders in {{{ dirPath }}}", diff --git a/gui/src/components/StepContainer/StepContainer.tsx b/gui/src/components/StepContainer/StepContainer.tsx index 0deab4625..d76e05789 100644 --- a/gui/src/components/StepContainer/StepContainer.tsx +++ b/gui/src/components/StepContainer/StepContainer.tsx @@ -7,6 +7,7 @@ import { vscBackground } from ".."; import { useAppSelector } from "../../redux/hooks"; import { selectUIConfig } from "../../redux/slices/configSlice"; import { deleteMessage } from "../../redux/slices/sessionSlice"; +import { selectCurrentToolCallsByStatus } from "../../redux/selectors/selectCurrentToolCall"; import { getFontSize } from "../../util"; import StyledMarkdownPreview from "../StyledMarkdownPreview"; import Reasoning from "./Reasoning"; @@ -38,10 +39,15 @@ export default function StepContainer(props: StepContainerProps) { ); const uiConfig = useAppSelector(selectUIConfig); + const pendingToolCalls = useAppSelector((state) => + selectCurrentToolCallsByStatus(state, "generated") + ); + const hasPendingToolCalls = pendingToolCalls.length > 0; + const hideActionSpace = historyItemAfterThis?.message.role === "assistant" || historyItemAfterThis?.message.role === "thinking"; - const hideActions = hideActionSpace || (isStreaming && props.isLast); + const hideActions = hideActionSpace || (isStreaming && props.isLast) || hasPendingToolCalls; useEffect(() => { if (!isStreaming) { diff --git a/gui/src/components/mainInput/Lump/LumpToolbar/PendingToolCallToolbar.tsx b/gui/src/components/mainInput/Lump/LumpToolbar/PendingToolCallToolbar.tsx index 72421c7d1..ccbbd06fa 100644 --- a/gui/src/components/mainInput/Lump/LumpToolbar/PendingToolCallToolbar.tsx +++ b/gui/src/components/mainInput/Lump/LumpToolbar/PendingToolCallToolbar.tsx @@ -1,35 +1,15 @@ -import styled from "styled-components"; import { useAppDispatch, useAppSelector } from "../../../../redux/hooks"; import { selectCurrentToolCallsByStatus } from "../../../../redux/selectors/selectCurrentToolCall"; -import { cancelToolCall } from "../../../../redux/slices/sessionSlice"; import { callToolById } from "../../../../redux/thunks/callToolById"; -import { - getAltKeyLabel, - getFontSize, - getMetaKeyLabel, - isJetBrains, -} from "../../../../util"; +import { cancelToolCallById } from "../../../../redux/thunks/cancelToolCallById"; +import { getAltKeyLabel, getMetaKeyLabel, isJetBrains } from "../../../../util"; import { EnterButton } from "../../InputToolbar/EnterButton"; -const Container = styled.div` - display: flex; - justify-content: space-between; - align-items: center; - width: 100%; -`; - -const StopButton = styled.div` - font-size: ${getFontSize() - 3}px; - padding: 2px; - padding-right: 4px; - cursor: pointer; -`; - export function PendingToolCallToolbar() { const dispatch = useAppDispatch(); const jetbrains = isJetBrains(); - const pendingToolCalls = useAppSelector((state) => - selectCurrentToolCallsByStatus(state, "generated") + const pendingToolCalls = useAppSelector((state) => + selectCurrentToolCallsByStatus(state, "generated"), ); if (pendingToolCalls.length === 0) { @@ -37,55 +17,44 @@ export function PendingToolCallToolbar() { } const handleAccept = (toolCallId: string) => { - dispatch(callToolById({ toolCallId })); + void dispatch(callToolById({ toolCallId })); }; const handleReject = (toolCallId: string) => { - dispatch(cancelToolCall({ toolCallId })); + void dispatch(cancelToolCallById({ toolCallId })); }; return ( - -
- - {pendingToolCalls.length === 1 - ? "Pending tool call" - : `${pendingToolCalls.length} pending tool calls` - } - -
+
+ {pendingToolCalls.map((toolCall) => ( +
+ + {toolCall.tool?.displayTitle ?? toolCall.toolCall.function.name} + -
- {pendingToolCalls.map((toolCall) => ( -
- - {toolCall.toolCall.function.name} - - -
- handleReject(toolCall.toolCallId)} - data-testid={`reject-tool-call-button-${toolCall.toolCallId}`} - > - {jetbrains ? getAltKeyLabel() : getMetaKeyLabel()} ⌫ Cancel - - - handleAccept(toolCall.toolCallId)} - data-testid={`accept-tool-call-button-${toolCall.toolCallId}`} - > - {getMetaKeyLabel()} ⏎ Continue - +
+
handleReject(toolCall.toolCallId)} + data-testid={`reject-tool-call-button-${toolCall.toolCallId}`} + > + {jetbrains ? getAltKeyLabel() : getMetaKeyLabel()} ⌫ Cancel
+ + handleAccept(toolCall.toolCallId)} + data-testid={`accept-tool-call-button-${toolCall.toolCallId}`} + > + {getMetaKeyLabel()} ⏎ Continue +
- ))} -
- +
+ ))} +
); } diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 09a3884b7..c48ada330 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -321,13 +321,20 @@ export function Chat() { ) : item.message.role === "tool" ? null : item.message.role === "assistant" && item.message.toolCalls && - item.toolCallState ? ( + item.toolCallStates ? (
{item.message.toolCalls?.map((toolCall, i) => { + // Find the corresponding tool call state for this tool call + const toolCallState = item.toolCallStates?.find( + state => state.toolCallId === toolCall.id + ); + + if (!toolCallState) return null; + return ( diff --git a/gui/src/pages/gui/chat-tests/ParallelToolCalls.test.tsx b/gui/src/pages/gui/chat-tests/ParallelToolCalls.test.tsx index e092e1873..10c16f492 100644 --- a/gui/src/pages/gui/chat-tests/ParallelToolCalls.test.tsx +++ b/gui/src/pages/gui/chat-tests/ParallelToolCalls.test.tsx @@ -2,18 +2,15 @@ import { act } from "@testing-library/react"; import { ChatMessage } from "core"; import { addAndSelectMockLlm } from "../../../util/test/config"; import { renderWithProviders } from "../../../util/test/render"; -import { - getElementByTestId, - getElementByText, - sendInputWithMockedResponse, -} from "../../../util/test/utils"; +import { sendInputWithMockedResponse } from "../../../util/test/utils"; import { Chat } from "../Chat"; describe("Parallel Tool Calls", () => { const PARALLEL_TOOL_CALL_RESPONSE: ChatMessage[] = [ { role: "assistant", - content: "I'll call the get_weather function in parallel for both San Francisco and Monterey, California.", + content: + "I'll call the get_weather function in parallel for both San Francisco and Monterey, California.", toolCalls: [ { id: "toolu_0112JmA95qW6WhAsvkKb7Avp", @@ -56,9 +53,9 @@ describe("Parallel Tool Calls", () => { PARALLEL_TOOL_CALL_RESPONSE, ); - // Wait for the message to be processed + // Wait for the message to be processed await act(async () => { - await new Promise(resolve => setTimeout(resolve, 100)); + await new Promise((resolve) => setTimeout(resolve, 100)); }); // Currently this will fail because we only support one tool call @@ -80,35 +77,44 @@ describe("Parallel Tool Calls", () => { PARALLEL_TOOL_CALL_RESPONSE, ); - // Wait for the message to be processed + // Wait for the message to be processed await act(async () => { - await new Promise(resolve => setTimeout(resolve, 100)); + await new Promise((resolve) => setTimeout(resolve, 100)); }); // Wait for any state updates to complete await act(async () => { - await new Promise(resolve => setTimeout(resolve, 100)); + await new Promise((resolve) => setTimeout(resolve, 100)); }); // Verify multiple tool calls are stored in Redux state const state = store.getState(); const history = state.session.history; - + // Find the assistant message (might not be at index 1 if tool messages were created) - const assistantMessage = history.find(item => - item.message.role === "assistant" && (item.message as any).toolCalls?.length + const assistantMessage = history.find( + (item) => + item.message.role === "assistant" && + (item.message as any).toolCalls?.length, ); - + expect(assistantMessage).toBeDefined(); expect((assistantMessage!.message as any).toolCalls).toHaveLength(2); expect(assistantMessage!.toolCallStates).toHaveLength(2); - + // Verify each tool call has correct ID and function name - expect(assistantMessage!.toolCallStates![0].toolCallId).toBe("toolu_0112JmA95qW6WhAsvkKb7Avp"); - expect(assistantMessage!.toolCallStates![0].toolCall.function.name).toBe("get_weather"); - expect(assistantMessage!.toolCallStates![1].toolCallId).toBe("toolu_01UFK4ZUmbpkeFJGg7mdoT6T"); - expect(assistantMessage!.toolCallStates![1].toolCall.function.name).toBe("get_weather"); - + expect(assistantMessage!.toolCallStates![0].toolCallId).toBe( + "toolu_0112JmA95qW6WhAsvkKb7Avp", + ); + expect(assistantMessage!.toolCallStates![0].toolCall.function.name).toBe( + "get_weather", + ); + expect(assistantMessage!.toolCallStates![1].toolCallId).toBe( + "toolu_01UFK4ZUmbpkeFJGg7mdoT6T", + ); + expect(assistantMessage!.toolCallStates![1].toolCall.function.name).toBe( + "get_weather", + ); }); test("should use utility functions for finding tool calls", async () => { @@ -126,36 +132,285 @@ describe("Parallel Tool Calls", () => { PARALLEL_TOOL_CALL_RESPONSE, ); - // Wait for the message to be processed + // Wait for the message to be processed await act(async () => { - await new Promise(resolve => setTimeout(resolve, 100)); + await new Promise((resolve) => setTimeout(resolve, 100)); }); await act(async () => { - await new Promise(resolve => setTimeout(resolve, 100)); + await new Promise((resolve) => setTimeout(resolve, 100)); }); // Test our utility functions work with the new state const state = store.getState(); - + // Import the utility functions to test them - const { findCurrentToolCalls, hasCurrentToolCalls, findToolCall } = await import("../../../redux/util"); - + const { findCurrentToolCalls, hasCurrentToolCalls, findToolCall } = + await import("../../../redux/util"); + // Test findCurrentToolCalls finds both tool calls const currentToolCalls = findCurrentToolCalls(state.session.history); expect(currentToolCalls).toHaveLength(2); - expect(currentToolCalls[0].toolCallId).toBe("toolu_0112JmA95qW6WhAsvkKb7Avp"); - expect(currentToolCalls[1].toolCallId).toBe("toolu_01UFK4ZUmbpkeFJGg7mdoT6T"); - + expect(currentToolCalls[0].toolCallId).toBe( + "toolu_0112JmA95qW6WhAsvkKb7Avp", + ); + expect(currentToolCalls[1].toolCallId).toBe( + "toolu_01UFK4ZUmbpkeFJGg7mdoT6T", + ); + // Test hasCurrentToolCalls returns true expect(hasCurrentToolCalls(state.session.history)).toBe(true); - + // Test findToolCall can find specific tool calls by ID - const toolCall1 = findToolCall(state.session.history, "toolu_0112JmA95qW6WhAsvkKb7Avp"); - const toolCall2 = findToolCall(state.session.history, "toolu_01UFK4ZUmbpkeFJGg7mdoT6T"); + const toolCall1 = findToolCall( + state.session.history, + "toolu_0112JmA95qW6WhAsvkKb7Avp", + ); + const toolCall2 = findToolCall( + state.session.history, + "toolu_01UFK4ZUmbpkeFJGg7mdoT6T", + ); expect(toolCall1?.toolCall.function.name).toBe("get_weather"); expect(toolCall2?.toolCall.function.name).toBe("get_weather"); expect(toolCall1?.toolCall.function.arguments).toContain("San Francisco"); expect(toolCall2?.toolCall.function.arguments).toContain("Monterey"); }); -}); \ No newline at end of file + + test("should complete streaming but hide ResponseActions when pending tool calls exist", async () => { + const { ideMessenger, store } = await renderWithProviders(); + + await act(async () => { + addAndSelectMockLlm(store, ideMessenger); + }); + + const INPUT = "Read a file using the read_file tool"; + + await sendInputWithMockedResponse( + ideMessenger, + INPUT, + PARALLEL_TOOL_CALL_RESPONSE, + ); + + // Wait for the message to be processed + await act(async () => { + await new Promise((resolve) => setTimeout(resolve, 100)); + }); + + await act(async () => { + await new Promise((resolve) => setTimeout(resolve, 100)); + }); + + // Verify streaming is complete (so tool calls can be shown) + const state = store.getState(); + expect(state.session.isStreaming).toBe(false); + + // Verify we have pending tool calls + const { findCurrentToolCallsByStatus } = await import("../../../redux/util"); + const pendingToolCalls = findCurrentToolCallsByStatus(state.session.history, "generated"); + expect(pendingToolCalls).toHaveLength(2); + + // Note: ResponseActions should be hidden by the hasPendingToolCalls condition in StepContainer + // The individual tool calls should now show with "Continue wants to..." text and accept/reject buttons + }); + + test("should show tool name in pending toolbar instead of generic text", async () => { + const { ideMessenger, store } = await renderWithProviders(); + + await act(async () => { + addAndSelectMockLlm(store, ideMessenger); + }); + + // Test with single tool call to check the specific name display + // Use get_weather which should stay in generated status for this test + const SINGLE_TOOL_CALL_RESPONSE: ChatMessage[] = [ + { + role: "assistant", + content: "I'll check the weather for you.", + toolCalls: [ + { + id: "single-tool-call", + type: "function", + function: { + name: "get_weather", + arguments: JSON.stringify({ + location: "San Francisco, CA", + }), + }, + }, + ], + }, + ]; + + await sendInputWithMockedResponse( + ideMessenger, + "Check weather", + SINGLE_TOOL_CALL_RESPONSE, + ); + + // Wait for processing + await act(async () => { + await new Promise((resolve) => setTimeout(resolve, 100)); + }); + + const state = store.getState(); + const { findCurrentToolCallsByStatus } = await import("../../../redux/util"); + const pendingToolCalls = findCurrentToolCallsByStatus(state.session.history, "generated"); + + // Should have one pending tool call with the correct name + expect(pendingToolCalls).toHaveLength(1); + expect(pendingToolCalls[0].toolCall.function.name).toBe("get_weather"); + }); + + test("should show individual tool call UI with 'Continue wants to...' text", async () => { + const { ideMessenger, store } = await renderWithProviders(); + + await act(async () => { + addAndSelectMockLlm(store, ideMessenger); + }); + + // Test with a tool that requires approval (not auto-executed) + const TOOL_CALL_RESPONSE: ChatMessage[] = [ + { + role: "assistant", + content: "I'll use a tool that requires approval.", + toolCalls: [ + { + id: "approval-required-tool-call", + type: "function", + function: { + name: "unknown_tool_requiring_approval", + arguments: JSON.stringify({ + param: "test.js", + }), + }, + }, + ], + }, + ]; + + await sendInputWithMockedResponse( + ideMessenger, + "Use a tool", + TOOL_CALL_RESPONSE, + ); + + // Wait for processing + await act(async () => { + await new Promise((resolve) => setTimeout(resolve, 100)); + }); + + const state = store.getState(); + + // Verify we have a pending tool call + const { findCurrentToolCallsByStatus } = await import("../../../redux/util"); + const pendingToolCalls = findCurrentToolCallsByStatus(state.session.history, "generated"); + expect(pendingToolCalls).toHaveLength(1); + expect(pendingToolCalls[0].toolCall.function.name).toBe("unknown_tool_requiring_approval"); + + // Verify the individual tool call UI should now show up in the DOM + // Since we fixed Chat.tsx to use toolCallStates instead of toolCallState, + // the ToolCallDiv components should now render + const state2 = store.getState(); + const history = state2.session.history; + + // Find the message with tool calls + const messageWithToolCalls = history.find(item => + item.message.role === "assistant" && item.toolCallStates?.length + ); + + // Verify that both condition parts are met for rendering in Chat.tsx: + // 1. item.message.toolCalls exists + // 2. item.toolCallStates exists + expect((messageWithToolCalls?.message as any).toolCalls).toBeDefined(); + expect(messageWithToolCalls?.toolCallStates).toBeDefined(); + expect(messageWithToolCalls?.toolCallStates).toHaveLength(1); + }); + + test("should show all pending tool calls requiring permissions simultaneously", async () => { + const { ideMessenger, store } = await renderWithProviders(); + + await act(async () => { + addAndSelectMockLlm(store, ideMessenger); + }); + + // Test with multiple tools that require approval + const MULTIPLE_TOOL_CALLS_RESPONSE: ChatMessage[] = [ + { + role: "assistant", + content: "I'll use multiple tools that require approval.", + toolCalls: [ + { + id: "approval-required-tool-call-1", + type: "function", + function: { + name: "write_file", + arguments: JSON.stringify({ + file_path: "test1.js", + content: "console.log('test1');" + }), + }, + }, + { + id: "approval-required-tool-call-2", + type: "function", + function: { + name: "run_terminal_command", + arguments: JSON.stringify({ + command: "npm test" + }), + }, + }, + { + id: "approval-required-tool-call-3", + type: "function", + function: { + name: "edit_file", + arguments: JSON.stringify({ + file_path: "test2.js", + content: "console.log('test2');" + }), + }, + }, + ], + }, + ]; + + await sendInputWithMockedResponse( + ideMessenger, + "Use multiple tools", + MULTIPLE_TOOL_CALLS_RESPONSE, + ); + + // Wait for processing + await act(async () => { + await new Promise((resolve) => setTimeout(resolve, 100)); + }); + + const state = store.getState(); + + // Verify we have multiple pending tool calls + const { findCurrentToolCallsByStatus } = await import("../../../redux/util"); + const pendingToolCalls = findCurrentToolCallsByStatus(state.session.history, "generated"); + expect(pendingToolCalls).toHaveLength(3); + + // Verify all tool calls are in "generated" status (requiring permissions) + expect(pendingToolCalls[0].toolCall.function.name).toBe("write_file"); + expect(pendingToolCalls[0].status).toBe("generated"); + expect(pendingToolCalls[1].toolCall.function.name).toBe("run_terminal_command"); + expect(pendingToolCalls[1].status).toBe("generated"); + expect(pendingToolCalls[2].toolCall.function.name).toBe("edit_file"); + expect(pendingToolCalls[2].status).toBe("generated"); + + // The key test: All pending tool calls should be visible in the toolbar simultaneously + // This verifies that the PendingToolCallToolbar shows all pending tools at once + // rather than prompting for permissions one at a time + + // Verify the PendingToolCallToolbar would show all three tool calls + // by checking that all three are in the "generated" state + const allGeneratedCalls = pendingToolCalls.filter(call => call.status === "generated"); + expect(allGeneratedCalls).toHaveLength(3); + + // This test documents the expected behavior: all pending tool calls should + // be shown simultaneously in the UI, not one at a time + }); +}); diff --git a/gui/src/redux/selectors/selectLastToolCall.ts b/gui/src/redux/selectors/selectLastToolCall.ts index 2c5a0db8d..e85a30490 100644 --- a/gui/src/redux/selectors/selectLastToolCall.ts +++ b/gui/src/redux/selectors/selectLastToolCall.ts @@ -13,6 +13,7 @@ export const selectLastToolCall = createSelector( break; } } - return lastToolCallHistoryItem?.toolCallState ?? null; + // Return the first tool call state from the states array + return lastToolCallHistoryItem?.toolCallStates?.[0] ?? null; }, ); diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 030506b76..023b36c9b 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -19,6 +19,7 @@ import { Session, SessionMetadata, Tool, + ToolCallState, } from "core"; import { NEW_SESSION_TITLE } from "core/util/constants"; import { @@ -414,15 +415,21 @@ export const sessionSlice = createSlice({ message.toolCalls?.length && lastMessage.role === "assistant" ) { - // Handle multiple tool calls in streaming updates + // Handle multiple tool calls in streaming updates - simplified index-based approach const existingToolCallStates = lastItem.toolCallStates || []; - const updatedToolCallStates = message.toolCalls.map((toolCallDelta, index) => { - const existingState = existingToolCallStates[index]; - return addToolCallDeltaToState(toolCallDelta, existingState); - }); + const newToolCallStates: ToolCallState[] = []; + + // Process each incoming tool call delta by index + for (let i = 0; i < message.toolCalls.length; i++) { + const toolCallDelta = message.toolCalls[i]; + const existingState = existingToolCallStates[i]; + const updatedState = addToolCallDeltaToState(toolCallDelta, existingState); + newToolCallStates.push(updatedState); + } + + lastItem.toolCallStates = newToolCallStates; + lastMessage.toolCalls = newToolCallStates.map(state => state.toolCall); - lastItem.toolCallStates = updatedToolCallStates; - lastMessage.toolCalls = updatedToolCallStates.map(state => state.toolCall); } } } @@ -575,6 +582,7 @@ export const sessionSlice = createSlice({ state.history, action.payload.toolCallId, ); + if (toolCallState) { toolCallState.status = "generated"; diff --git a/gui/src/redux/thunks/cancelToolCallById.ts b/gui/src/redux/thunks/cancelToolCallById.ts new file mode 100644 index 000000000..c94e66fe3 --- /dev/null +++ b/gui/src/redux/thunks/cancelToolCallById.ts @@ -0,0 +1,15 @@ +import { createAsyncThunk } from "@reduxjs/toolkit"; +import { RootState } from "../store"; +import { cancelToolCall } from "../slices/sessionSlice"; + +export const cancelToolCallById = createAsyncThunk< + void, + { toolCallId: string }, + { state: RootState } +>("session/cancelToolCallById", async ({ toolCallId }, { dispatch }) => { + // Cancel the specific tool call + dispatch(cancelToolCall({ toolCallId })); + + // Note: We don't need to manage streaming state here since streaming should + // already be complete when tool calls are pending user approval +}); \ No newline at end of file diff --git a/gui/src/redux/thunks/moveTerminalProcessToBackground.ts b/gui/src/redux/thunks/moveTerminalProcessToBackground.ts index c3f0a39d0..062f124fa 100644 --- a/gui/src/redux/thunks/moveTerminalProcessToBackground.ts +++ b/gui/src/redux/thunks/moveTerminalProcessToBackground.ts @@ -6,6 +6,7 @@ import { updateToolCallOutput, } from "../slices/sessionSlice"; import { ThunkApiType } from "../store"; +import { findToolCall } from "../util"; import { streamResponseAfterToolCall } from "./streamResponseAfterToolCall"; /** @@ -22,20 +23,12 @@ export const moveTerminalProcessToBackground = createAsyncThunk< >( "chat/moveTerminalProcessToBackground", async ({ toolCallId }, { dispatch, getState, extra }) => { - // Find the current tool call + // Find the current tool call using utility function const state = getState(); - const toolCalls = state.session.history.filter( - (item) => item.toolCallState?.toolCallId === toolCallId, - ); - - if (toolCalls.length === 0) { - console.error("Could not find tool call with ID:", toolCallId); - return; - } - - const toolCall = toolCalls[0].toolCallState; + const toolCall = findToolCall(state.session.history, toolCallId); + if (!toolCall) { - console.error("Tool call state is missing"); + console.error("Could not find tool call with ID:", toolCallId); return; } diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 004dade9d..c30c5a34a 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -3,7 +3,7 @@ import { LLMFullCompletionOptions } from "core"; import { modelSupportsTools } from "core/llm/autodetect"; import { ToCoreProtocol } from "core/protocol"; import { selectActiveTools } from "../selectors/selectActiveTools"; -import { selectCurrentToolCalls } from "../selectors/selectCurrentToolCall"; +import { selectCurrentToolCall } from "../selectors/selectCurrentToolCall"; import { selectSelectedChatModel } from "../slices/configSlice"; import { abortStream, diff --git a/gui/src/redux/util/constructMessages.test.ts b/gui/src/redux/util/constructMessages.test.ts index b1d808662..cea183491 100644 --- a/gui/src/redux/util/constructMessages.test.ts +++ b/gui/src/redux/util/constructMessages.test.ts @@ -316,7 +316,7 @@ describe("constructMessages", () => { { message: assistantWithToolCall, contextItems: [], - toolCallState: { + toolCallStates: [{ toolCallId: "tool-call-1", toolCall: { id: "tool-call-1", @@ -329,7 +329,7 @@ describe("constructMessages", () => { status: "done", parsedArgs: { query: "test" }, output: [createContextItem("search-result", "Search result content")], - }, + }], }, ]; @@ -370,7 +370,7 @@ describe("constructMessages", () => { { message: assistantWithToolCall, contextItems: [], - toolCallState: { + toolCallStates: [{ toolCallId: "tool-call-1", toolCall: { id: "tool-call-1", @@ -382,7 +382,7 @@ describe("constructMessages", () => { }, status: "canceled", parsedArgs: { query: "test" }, - }, + }], }, ]; @@ -422,7 +422,7 @@ describe("constructMessages", () => { { message: assistantWithToolCall, contextItems: [], - toolCallState: { + toolCallStates: [{ toolCallId: "tool-call-1", toolCall: { id: "tool-call-1", @@ -434,7 +434,7 @@ describe("constructMessages", () => { }, status: "generating", // Not done yet parsedArgs: { query: "test" }, - }, + }], }, ]; @@ -499,7 +499,7 @@ describe("constructMessages", () => { { message: assistantWithMultipleToolCalls, contextItems: [], - toolCallState: { + toolCallStates: [{ toolCallId: "tool-call-1", toolCall: { id: "tool-call-1", @@ -512,7 +512,7 @@ describe("constructMessages", () => { status: "done", parsedArgs: { query: "test" }, output: [createContextItem("search-result", "Search result content")], - }, + }], }, ]; @@ -665,7 +665,7 @@ describe("constructMessages", () => { { message: assistantWithToolCall, contextItems: [], - toolCallState: { + toolCallStates: [{ toolCallId: "tool-call-1", toolCall: { id: "tool-call-1", @@ -678,7 +678,7 @@ describe("constructMessages", () => { status: "done", parsedArgs: { query: "test" }, output: [triggeringToolOutput], - }, + }], }, ]; diff --git a/gui/src/redux/util/constructMessages.ts b/gui/src/redux/util/constructMessages.ts index 0a77c2824..f938600e0 100644 --- a/gui/src/redux/util/constructMessages.ts +++ b/gui/src/redux/util/constructMessages.ts @@ -98,7 +98,7 @@ export function constructMessages( // Find the corresponding tool call state for this specific tool call const toolCallState = item.toolCallStates?.find( state => state.toolCallId === toolCall.id - ) || (item.toolCallState?.toolCallId === toolCall.id ? item.toolCallState : undefined); + ); if (toolCallState?.status === "canceled") { content = CANCELLED_TOOL_CALL_MESSAGE;