| 1 | import { useContext } from "react"; |
| 2 | import { IdeMessengerContext } from "../../../../context/IdeMessenger"; |
| 3 | import { useAppDispatch } from "../../../../redux/hooks"; |
| 4 | import { cancelStream } from "../../../../redux/thunks/cancelStream"; |
| 5 | import { getAltKeyLabel, getMetaKeyLabel } from "../../../../util"; |
| 6 | import { Container, StopButton } from "./components"; |
| 7 | import { GeneratingIndicator } from "./GeneratingIndicator"; |
| 8 | |
| 9 | export const IsApplyingToolbar = () => { |
| 10 | const ideMessenger = useContext(IdeMessengerContext); |
| 11 | const dispatch = useAppDispatch(); |
| 12 | const jetbrains = window.location.protocol === "jb-api:"; |
| 13 | |
| 14 | return ( |
| 15 | <Container> |
| 16 | <GeneratingIndicator text="Applying" testId={"notch-applying-text"} /> |
| 17 | <StopButton |
| 18 | data-testid="notch-applying-cancel-button" |
| 19 | className="text-description" |
| 20 | onClick={() => { |
| 21 | // Note that this will NOT stop generation but once apply is cancelled will show the Generating/cancel option |
| 22 | // Apply is prioritized because it can be more catastrophic |
| 23 | // Intentional to be more WYSIWYG for now |
| 24 | // Keyboard shortcut is handled in chat |
| 25 | void dispatch(cancelStream()); |
| 26 | ideMessenger.post("rejectDiff", {}); |
| 27 | }} |
| 28 | > |
| 29 | {/* JetBrains overrides cmd+backspace, so we have to use another shortcut */} |
| 30 | {jetbrains ? getAltKeyLabel() : getMetaKeyLabel()} ⌫ Cancel |
| 31 | </StopButton> |
| 32 | </Container> |
| 33 | ); |
| 34 | }; |