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

main
ts 63 lines 2.02 KB
Raw
1 import { msg } from "gt-react-native";
2
3 import type { StatusTone } from "../../components/StatusPill";
4 import { m, type MessageResolver } from "../../i18n/messages";
5 import type { RemoteClientConnectionState } from "../../lib/connection";
6
7 export function connectionTone(
8 state: RemoteClientConnectionState,
9 awaitingApproval?: boolean,
10 resolve: MessageResolver = m,
11 ): StatusTone {
12 if (state === "reconnecting" && awaitingApproval) {
13 return {
14 label: resolve(msg("Waiting for approval")),
15 pillClassName: "bg-update",
16 textClassName: "text-update-foreground",
17 };
18 }
19 switch (state) {
20 case "connected":
21 return {
22 label: resolve(msg("Connected", { $context: "connection status" })),
23 pillClassName: "bg-adaptive-emerald-500-a12-a16",
24 textClassName: "text-adaptive-emerald-700-300",
25 };
26 case "reconnecting":
27 return {
28 label: resolve(msg("Reconnecting", { $context: "connection status" })),
29 pillClassName: "bg-warning",
30 textClassName: "text-warning-foreground",
31 };
32 case "connecting":
33 return {
34 label: resolve(msg("Connecting", { $context: "connection status" })),
35 pillClassName: "bg-update",
36 textClassName: "text-update-foreground",
37 };
38 case "unsupported":
39 return {
40 label: resolve(msg("Client not supported")),
41 pillClassName: "bg-subtle",
42 textClassName: "text-foreground-secondary",
43 };
44 case "error":
45 return {
46 label: resolve(msg("Connection failed")),
47 pillClassName: "bg-danger",
48 textClassName: "text-danger-foreground",
49 };
50 case "offline":
51 return {
52 label: resolve(msg("Offline", { $context: "connection status" })),
53 pillClassName: "bg-danger",
54 textClassName: "text-danger-foreground",
55 };
56 case "available":
57 return {
58 label: resolve(msg("Available", { $context: "connection status" })),
59 pillClassName: "bg-subtle",
60 textClassName: "text-foreground-secondary",
61 };
62 }
63 }