@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
tsx 60 lines 1.86 KB
Raw
1 import { m } from "../i18n/messages";
2 import { thrownErrorMessage } from "@t3tools/client-runtime/errors";
3 import {
4 AuthOrchestrationOperateScope,
5 type EditorId,
6 type EnvironmentId,
7 } from "@t3tools/contracts";
8 import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
9 import { T, useGT, Var } from "gt-react";
10
11 import { useOpenInPreferredEditor } from "../editorPreferences";
12 import { useEnvironmentScope } from "../state/session";
13 import { Button } from "./ui/button";
14 import { stackedThreadToast, toastManager } from "./ui/toast";
15
16 export function KeybindingsConfigWarning({
17 message,
18 environmentId,
19 configPath,
20 availableEditors,
21 }: {
22 message: string;
23 environmentId: EnvironmentId | null;
24 configPath: string | null;
25 availableEditors: readonly EditorId[];
26 }) {
27 const gt = useGT();
28 const canOpenEditor = useEnvironmentScope(environmentId, AuthOrchestrationOperateScope);
29 const openInEditor = useOpenInPreferredEditor(environmentId, availableEditors);
30
31 return (
32 <>
33 {message}
34 <span className="mt-2 flex justify-end">
35 <Button
36 size="xs"
37 variant="outline"
38 disabled={!canOpenEditor || !configPath || availableEditors.length === 0}
39 onClick={async () => {
40 if (!configPath) return;
41 const result = await openInEditor(configPath);
42 if (result._tag === "Success") return;
43 const error = squashAtomCommandFailure(result);
44 toastManager.add(
45 stackedThreadToast({
46 type: "error",
47 title: gt("Unable to open keybindings file"),
48 description: thrownErrorMessage(error, m) ?? gt("Unknown error opening file."),
49 }),
50 );
51 }}
52 >
53 <T>
54 Open <Var>keybindings.json</Var>
55 </T>
56 </Button>
57 </span>
58 </>
59 );
60 }