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