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