| 1 | import styled from "styled-components"; |
| 2 | import { useAppDispatch, useAppSelector } from "../../../../redux/hooks"; |
| 3 | import { selectCurrentToolCall } from "../../../../redux/selectors/selectCurrentToolCall"; |
| 4 | import { cancelToolCall } from "../../../../redux/slices/sessionSlice"; |
| 5 | import { callCurrentTool } from "../../../../redux/thunks/callCurrentTool"; |
| 6 | import { |
| 7 | getAltKeyLabel, |
| 8 | getFontSize, |
| 9 | getMetaKeyLabel, |
| 10 | isJetBrains, |
| 11 | } from "../../../../util"; |
| 12 | import { EnterButton } from "../../InputToolbar/EnterButton"; |
| 13 | |
| 14 | const Container = styled.div` |
| 15 | display: flex; |
| 16 | justify-content: space-between; |
| 17 | align-items: center; |
| 18 | width: 100%; |
| 19 | `; |
| 20 | |
| 21 | const StopButton = styled.div` |
| 22 | font-size: ${getFontSize() - 3}px; |
| 23 | padding: 2px; |
| 24 | padding-right: 4px; |
| 25 | cursor: pointer; |
| 26 | `; |
| 27 | |
| 28 | export 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 | } |