Elffuss BraidHub

kikocis/continue public

0cdb3e901c09 · 2.0 KiBRawPermalink
1import styled from "styled-components";
2import { useAppDispatch, useAppSelector } from "../../../../redux/hooks";
3import { selectCurrentToolCall } from "../../../../redux/selectors/selectCurrentToolCall";
4import { cancelToolCall } from "../../../../redux/slices/sessionSlice";
5import { callCurrentTool } from "../../../../redux/thunks/callCurrentTool";
6import {
7 getAltKeyLabel,
8 getFontSize,
9 getMetaKeyLabel,
10 isJetBrains,
11} from "../../../../util";
12import { EnterButton } from "../../InputToolbar/EnterButton";
13
14const Container = styled.div`
15 display: flex;
16 justify-content: space-between;
17 align-items: center;
18 width: 100%;
19`;
20
21const StopButton = styled.div`
22 font-size: ${getFontSize() - 3}px;
23 padding: 2px;
24 padding-right: 4px;
25 cursor: pointer;
26`;
27
28export function PendingToolCallToolbar() {
29 const dispatch = useAppDispatch();
30 const jetbrains = isJetBrains();
31 const currentToolCall = useAppSelector(selectCurrentToolCall);
32
33 return (
34 <Container>
35 <div className="text-description flex flex-row items-center pb-0.5 pr-1 text-xs">
36 <span className="hidden sm:flex">Pending tool call</span>
37 </div>
38
39 <div className="flex gap-2 pb-0.5">
40 <StopButton
41 className="text-description"
42 onClick={
43 currentToolCall
44 ? () => {
45 dispatch(
46 cancelToolCall({
47 toolCallId: currentToolCall.toolCallId,
48 }),
49 );
50 }
51 : undefined
52 }
53 data-testid="reject-tool-call-button"
54 >
55 {/* JetBrains overrides cmd+backspace, so we have to use another shortcut */}
56 {jetbrains ? getAltKeyLabel() : getMetaKeyLabel()} ⌫ Cancel
57 </StopButton>
58 <EnterButton
59 isPrimary={true}
60 className="text-description"
61 onClick={() => dispatch(callCurrentTool())}
62 data-testid="accept-tool-call-button"
63 >
64 {getMetaKeyLabel()} ⏎ Continue
65 </EnterButton>
66 </div>
67 </Container>
68 );
69}