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

main
ts 81 lines 2.56 KB
Raw
1 import { describe, expect, it } from "vite-plus/test";
2
3 import type { WorkspaceState } from "../../state/workspaceModel";
4 import { workspaceConnectionStatusPresentation } from "./workspace-connection-status";
5
6 function workspaceState(overrides: Partial<WorkspaceState> = {}): WorkspaceState {
7 return {
8 isLoadingConnections: false,
9 hasConnections: true,
10 hasLoadedShellSnapshot: true,
11 hasPendingShellSnapshot: false,
12 hasSyncingConnectedEnvironment: false,
13 hasReadyEnvironment: true,
14 hasConnectingEnvironment: false,
15 connectingEnvironments: [],
16 connectionState: "connected",
17 connectionError: null,
18 shellSnapshotError: null,
19 networkStatus: "online",
20 ...overrides,
21 };
22 }
23
24 describe("workspace connection status", () => {
25 it.each([
26 ["reconnecting", "Could not reach sleeping laptop"],
27 ["error", "Could not reach sleeping laptop"],
28 ] as const)(
29 "keeps the brand while a secondary environment is %s (%s)",
30 (connectionState, connectionError) => {
31 const state = workspaceState({
32 hasConnectingEnvironment: connectionState !== "error",
33 hasPendingShellSnapshot: true,
34 connectionError,
35 connectingEnvironments:
36 connectionState === "error"
37 ? []
38 : [
39 {
40 environmentId: "environment-2" as never,
41 environmentLabel: "Sleeping laptop",
42 displayUrl: "",
43 isRelayManaged: false,
44 isEnabled: true,
45 connectionState,
46 connectionError,
47 connectionErrorTraceId: null,
48 },
49 ],
50 });
51
52 expect(workspaceConnectionStatusPresentation(state)).toBeNull();
53 },
54 );
55
56 it("shows connected shell catch-up even while a secondary environment is unreachable", () => {
57 const state = workspaceState({
58 hasSyncingConnectedEnvironment: true,
59 hasPendingShellSnapshot: true,
60 hasConnectingEnvironment: true,
61 connectionError: "Could not reach sleeping laptop",
62 connectingEnvironments: [
63 {
64 environmentId: "environment-2" as never,
65 environmentLabel: "Sleeping laptop",
66 displayUrl: "",
67 isRelayManaged: false,
68 isEnabled: true,
69 connectionState: "reconnecting",
70 connectionError: "Could not reach sleeping laptop",
71 connectionErrorTraceId: null,
72 },
73 ],
74 });
75
76 expect(workspaceConnectionStatusPresentation(state)).toEqual({
77 label: "Syncing threads...",
78 showsProgress: true,
79 });
80 });
81 });