Open History to see the last commit
1import { appAtomRegistry, subscribeAtomChanges } from "../rpc/atomRegistry";
2import { primaryEnvironmentIdAtom } from "../state/primaryEnvironment";
3import { primaryServerConfigAtom, primaryServerConfigEventAtom } from "../state/server";
4import { KeybindingsConfigWarning } from "./KeybindingsConfigWarning";
5import { createKeybindingsUpdateToastController } from "./KeybindingsUpdateToast.logic";
6import { stackedThreadToast, toastManager } from "./ui/toast";
7
8export function startKeybindingsUpdateToasts(): () => void {
9 const controller = createKeybindingsUpdateToastController({});
10 return subscribeAtomChanges(primaryServerConfigEventAtom, (event) => {
11 const decision = controller.handle(event);
12 if (!decision) return;
13
14 if (decision._tag === "Success") return;
15
16 const serverConfig = appAtomRegistry.get(primaryServerConfigAtom);
17 toastManager.add(
18 stackedThreadToast({
19 type: "warning",
20 title: "Invalid keybindings configuration",
21 description: (
22 <KeybindingsConfigWarning
23 message={decision.message}
24 environmentId={appAtomRegistry.get(primaryEnvironmentIdAtom)}
25 configPath={serverConfig?.keybindingsConfigPath ?? null}
26 availableEditors={serverConfig?.availableEditors ?? []}
27 />
28 ),
29 }),
30 );
31 });
32}