Update PendingToolCallToolbar for parallel tool calls

- Changed from selectCurrentToolCall to selectCurrentToolCallsByStatus
- Show individual UI for each tool call requiring approval
- Display dynamic text: "1 pending tool call" vs "X pending tool calls"
- Individual approve/reject buttons for each tool call
- Added test IDs with toolCallId for specific tool testing
- Used only Tailwind classes, no styled components
- Returns null when no pending tool calls exist

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Patrick Erichsen 2025-07-08 13:19:49 -07:00
parent aa50f54999
commit e3d6d166b4

View file

@ -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 (
<Container>
<div className="text-description flex flex-row items-center pb-0.5 pr-1 text-xs">
<span className="hidden sm:flex">Pending tool call</span>
<span className="hidden sm:flex">
{pendingToolCalls.length === 1
? "Pending tool call"
: `${pendingToolCalls.length} pending tool calls`
}
</span>
</div>
<div className="flex gap-2 pb-0.5">
<StopButton
className="text-description"
onClick={
currentToolCall
? () => {
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
</StopButton>
<EnterButton
isPrimary={true}
className="text-description"
onClick={() =>
currentToolCall && dispatch(
callToolById({ toolCallId: currentToolCall.toolCallId })
)
}
data-testid="accept-tool-call-button"
>
{getMetaKeyLabel()} ⏎ Continue
</EnterButton>
<div className="flex flex-col gap-2 pb-0.5 w-full">
{pendingToolCalls.map((toolCall) => (
<div
key={toolCall.toolCallId}
className="flex items-center gap-2 p-2 border border-input rounded bg-input"
>
<span className="text-foreground font-medium text-sm flex-1">
{toolCall.toolCall.function.name}
</span>
<div className="flex gap-2">
<StopButton
className="text-description text-xs cursor-pointer px-2 py-1"
onClick={() => handleReject(toolCall.toolCallId)}
data-testid={`reject-tool-call-button-${toolCall.toolCallId}`}
>
{jetbrains ? getAltKeyLabel() : getMetaKeyLabel()} ⌫ Cancel
</StopButton>
<EnterButton
isPrimary={true}
className="text-description text-xs"
onClick={() => handleAccept(toolCall.toolCallId)}
data-testid={`accept-tool-call-button-${toolCall.toolCallId}`}
>
{getMetaKeyLabel()} ⏎ Continue
</EnterButton>
</div>
</div>
))}
</div>
</Container>
);