diff --git a/gui/src/components/mainInput/Lump/LumpToolbar/PendingToolCallToolbar.tsx b/gui/src/components/mainInput/Lump/LumpToolbar/PendingToolCallToolbar.tsx index c67b32fff..72421c7d1 100644 --- a/gui/src/components/mainInput/Lump/LumpToolbar/PendingToolCallToolbar.tsx +++ b/gui/src/components/mainInput/Lump/LumpToolbar/PendingToolCallToolbar.tsx @@ -1,6 +1,6 @@ import styled from "styled-components"; import { useAppDispatch, useAppSelector } from "../../../../redux/hooks"; -import { selectCurrentToolCall } from "../../../../redux/selectors/selectCurrentToolCall"; +import { selectCurrentToolCallsByStatus } from "../../../../redux/selectors/selectCurrentToolCall"; import { cancelToolCall } from "../../../../redux/slices/sessionSlice"; import { callToolById } from "../../../../redux/thunks/callToolById"; import { @@ -28,45 +28,63 @@ const StopButton = styled.div` export function PendingToolCallToolbar() { const dispatch = useAppDispatch(); const jetbrains = isJetBrains(); - const currentToolCall = useAppSelector(selectCurrentToolCall); + const pendingToolCalls = useAppSelector((state) => + selectCurrentToolCallsByStatus(state, "generated") + ); + + if (pendingToolCalls.length === 0) { + return null; + } + + const handleAccept = (toolCallId: string) => { + dispatch(callToolById({ toolCallId })); + }; + + const handleReject = (toolCallId: string) => { + dispatch(cancelToolCall({ toolCallId })); + }; return (
- Pending tool call + + {pendingToolCalls.length === 1 + ? "Pending tool call" + : `${pendingToolCalls.length} pending tool calls` + } +
-
- { - dispatch( - cancelToolCall({ - toolCallId: currentToolCall.toolCallId, - }), - ); - } - : undefined - } - data-testid="reject-tool-call-button" - > - {/* JetBrains overrides cmd+backspace, so we have to use another shortcut */} - {jetbrains ? getAltKeyLabel() : getMetaKeyLabel()} ⌫ Cancel - - - currentToolCall && dispatch( - callToolById({ toolCallId: currentToolCall.toolCallId }) - ) - } - data-testid="accept-tool-call-button" - > - {getMetaKeyLabel()} ⏎ Continue - +
+ {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 + +
+
+ ))}
);