| 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 { GeneratingIndicator } from "./GeneratingIndicator"; |
| 7 | |
| 8 | export const IsApplyingToolbar = () => { |
| 9 | const ideMessenger = useContext(IdeMessengerContext); |
| 10 | const dispatch = useAppDispatch(); |
| 11 | const jetbrains = window.location.protocol === "jb-api:"; |
| 12 | |
| 13 | return ( |
| 14 | <div className="flex w-full items-center justify-between"> |
| 15 | <GeneratingIndicator text="Applying" testId={"notch-applying-text"} /> |
| 16 | <div |
| 17 | data-testid="notch-applying-cancel-button" |
| 18 | className="text-description text-2xs cursor-pointer p-0.5 pr-1 hover:brightness-125" |
| 19 | onClick={() => { |
| 20 | // Note that this will NOT stop generation but once apply is cancelled will show the Generating/cancel option |
| 21 | // Apply is prioritized because it can be more catastrophic |
| 22 | // Intentional to be more WYSIWYG for now |
| 23 | // Keyboard shortcut is handled in chat |
| 24 | void dispatch(cancelStream()); |
| 25 | ideMessenger.post("rejectDiff", {}); |
| 26 | }} |
| 27 | > |
| 28 | {/* JetBrains overrides cmd+backspace, so we have to use another shortcut */} |
| 29 | {jetbrains ? getAltKeyLabel() : getMetaKeyLabel()} ⌫ Cancel |
| 30 | </div> |
| 31 | </div> |
| 32 | ); |
| 33 | }; |