The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { msg } from "gt-react"; |
| 2 | |
| 3 | import { m } from "../i18n/messages"; |
| 4 | import { appAtomRegistry, subscribeAtomChanges } from "../rpc/atomRegistry"; |
| 5 | import { primaryEnvironmentIdAtom } from "../state/primaryEnvironment"; |
| 6 | import { primaryServerConfigAtom, primaryServerConfigEventAtom } from "../state/server"; |
| 7 | import { KeybindingsConfigWarning } from "./KeybindingsConfigWarning"; |
| 8 | import { createKeybindingsUpdateToastController } from "./KeybindingsUpdateToast.logic"; |
| 9 | import { stackedThreadToast, toastManager } from "./ui/toast"; |
| 10 | |
| 11 | export function startKeybindingsUpdateToasts(): () => void { |
| 12 | const controller = createKeybindingsUpdateToastController({}); |
| 13 | return subscribeAtomChanges(primaryServerConfigEventAtom, (event) => { |
| 14 | const decision = controller.handle(event); |
| 15 | if (!decision) return; |
| 16 | |
| 17 | if (decision._tag === "Success") return; |
| 18 | |
| 19 | const serverConfig = appAtomRegistry.get(primaryServerConfigAtom); |
| 20 | toastManager.add( |
| 21 | stackedThreadToast({ |
| 22 | type: "warning", |
| 23 | title: m(msg("Invalid keybindings configuration")), |
| 24 | description: ( |
| 25 | <KeybindingsConfigWarning |
| 26 | message={decision.message} |
| 27 | environmentId={appAtomRegistry.get(primaryEnvironmentIdAtom)} |
| 28 | configPath={serverConfig?.keybindingsConfigPath ?? null} |
| 29 | availableEditors={serverConfig?.availableEditors ?? []} |
| 30 | /> |
| 31 | ), |
| 32 | }), |
| 33 | ); |
| 34 | }); |
| 35 | } |