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 22, 20:45 UTC
fix(mobile): keep home brand visible during secondary retries (#21388)
maria committed
Oct 21, 2026 at 00:02 UTC
327f3fc72cee0a51079f40980373f5e87fbd497d
6 files changed
+96
-5
apps/mobile/src/features/home/workspace-connection-status.test.ts
+66
-1
@@ -9,6 +9,7 @@ function workspaceState(overrides: Partial<WorkspaceState> = {}): WorkspaceState
9
hasConnections: true,
10
hasLoadedShellSnapshot: true,
11
hasPendingShellSnapshot: false,
12
+ hasSyncingConnectedEnvironment: false,
13
hasReadyEnvironment: true,
14
hasConnectingEnvironment: false,
15
connectingEnvironments: [],
@@ -25,6 +26,66 @@ describe("workspace connection status", () => {
26
expect(workspaceConnectionStatusPresentation(workspaceState())).toBeNull();
27
});
28
29
+ it.each([
30
+ ["connecting", null],
31
+ ["reconnecting", null],
32
+ ["connecting", "Could not reach sleeping laptop"],
33
+ ["reconnecting", "Could not reach sleeping laptop"],
34
+ ["error", "Could not reach sleeping laptop"],
35
+ ] as const)(
36
+ "keeps the brand while a secondary environment is %s (%s)",
37
+ (connectionState, connectionError) => {
38
+ const state = workspaceState({
39
+ hasConnectingEnvironment: connectionState !== "error",
40
+ hasPendingShellSnapshot: true,
41
+ connectionError,
42
+ connectingEnvironments:
43
+ connectionState === "error"
44
+ ? []
45
+ : [
46
+ {
47
+ environmentId: "environment-2" as never,
48
+ environmentLabel: "Sleeping laptop",
49
+ displayUrl: "",
50
+ isRelayManaged: false,
51
+ isEnabled: true,
52
+ connectionState,
53
+ connectionError,
54
+ connectionErrorTraceId: null,
55
+ },
56
+ ],
57
+ });
58
+
59
+ expect(workspaceConnectionStatusPresentation(state)).toBeNull();
60
+ },
61
+ );
62
+
63
+ it("shows connected shell catch-up even while a secondary environment is unreachable", () => {
64
+ const state = workspaceState({
65
+ hasSyncingConnectedEnvironment: true,
66
+ hasPendingShellSnapshot: true,
67
+ hasConnectingEnvironment: true,
68
+ connectionError: "Could not reach sleeping laptop",
69
+ connectingEnvironments: [
70
+ {
71
+ environmentId: "environment-2" as never,
72
+ environmentLabel: "Sleeping laptop",
73
+ displayUrl: "",
74
+ isRelayManaged: false,
75
+ isEnabled: true,
76
+ connectionState: "reconnecting",
77
+ connectionError: "Could not reach sleeping laptop",
78
+ connectionErrorTraceId: null,
79
+ },
80
+ ],
81
+ });
82
+
83
+ expect(workspaceConnectionStatusPresentation(state)).toEqual({
84
+ label: "Syncing threads...",
85
+ showsProgress: true,
86
+ });
87
+ });
88
+
89
it("surfaces offline snapshots", () => {
90
const state = workspaceState({ networkStatus: "offline", hasReadyEnvironment: false });
91
@@ -72,7 +133,10 @@ describe("workspace connection status", () => {
133
});
134
135
it("shows shell catch-up while cached threads remain visible", () => {
75
- const state = workspaceState({ hasPendingShellSnapshot: true });
136
+ const state = workspaceState({
137
+ hasPendingShellSnapshot: true,
138
+ hasSyncingConnectedEnvironment: true,
139
+ });
140
141
expect(workspaceConnectionStatusPresentation(state)).toEqual({
142
label: "Syncing threads...",
@@ -84,6 +148,7 @@ describe("workspace connection status", () => {
148
const state = workspaceState({
149
hasLoadedShellSnapshot: false,
150
hasPendingShellSnapshot: true,
151
+ hasSyncingConnectedEnvironment: true,
152
});
153
154
expect(workspaceConnectionStatusPresentation(state)).toEqual({
apps/mobile/src/features/home/workspace-connection-status.ts
+6
-2
@@ -6,8 +6,9 @@ export interface WorkspaceConnectionStatusPresentation {
6
}
7
8
function shouldShowWorkspaceConnectionStatus(state: WorkspaceState): boolean {
9
+ if (state.networkStatus === "offline") return true;
10
+ if (state.hasReadyEnvironment) return state.hasSyncingConnectedEnvironment;
11
return (
10
- state.networkStatus === "offline" ||
12
state.connectionError !== null ||
13
state.hasConnectingEnvironment ||
14
state.hasPendingShellSnapshot ||
@@ -17,6 +18,9 @@ function shouldShowWorkspaceConnectionStatus(state: WorkspaceState): boolean {
18
19
function workspaceConnectionStatusLabel(state: WorkspaceState): string {
20
if (state.networkStatus === "offline") return "You are offline";
21
+ if (state.hasReadyEnvironment && state.hasSyncingConnectedEnvironment) {
22
+ return state.hasLoadedShellSnapshot ? "Syncing threads..." : "Loading threads...";
23
+ }
24
if (state.connectingEnvironments.length === 1) {
25
return `Reconnecting to ${state.connectingEnvironments[0]!.environmentLabel}`;
26
}
@@ -38,7 +42,7 @@ export function workspaceConnectionStatusPresentation(
42
label: workspaceConnectionStatusLabel(state),
43
showsProgress:
44
state.networkStatus !== "offline" &&
41
- state.connectionError === null &&
45
+ (state.hasReadyEnvironment || state.connectionError === null) &&
46
(state.connectingEnvironments.length > 0 || state.hasPendingShellSnapshot),
47
};
48
}
apps/mobile/src/state/workspace-connection-atoms.test.ts
+1
@@ -62,6 +62,7 @@ describe("workspace connection subscriptions", () => {
62
networkStatus: get(h.network),
63
environments: [projectWorkspaceEnvironment(ID, get(h.source)!)],
64
shellSummary: get(shell),
65
+ hasSyncingConnectedEnvironment: false,
66
}),
67
);
68
const initial = h.registry.get(h.stateAtom);
apps/mobile/src/state/workspace.ts
+15
-2
@@ -1,7 +1,8 @@
1
import { useAtomValue } from "@effect/atom-react";
2
import { useMemo } from "react";
3
+import { Atom } from "effect/reactivity";
4
4
-import { environmentShellSummaryAtom } from "./shell";
5
+import { environmentShell, environmentShellSummaryAtom } from "./shell";
6
import { projectWorkspaceState } from "./workspaceModel";
7
import { environmentCatalog } from "../connection/catalog";
8
import { environmentPresentations } from "./presentation";
@@ -13,6 +14,16 @@ export const workspaceConnections = createWorkspaceConnectionAtoms({
14
presentationAtom: environmentPresentations.presentationAtom,
15
});
16
17
+// A disconnected environment's retries also leave its shell synchronizing.
18
+const hasSyncingConnectedEnvironmentAtom = Atom.make((get) =>
19
+ get(workspaceConnections.environmentsAtom).some(
20
+ (environment) =>
21
+ environment.isEnabled &&
22
+ environment.connectionState === "connected" &&
23
+ get(environmentShell.stateValueAtom(environment.environmentId)).status === "synchronizing",
24
+ ),
25
+).pipe(Atom.withLabel("mobile:has-syncing-connected-environment"));
26
+
27
export function useWorkspaceEnvironments() {
28
return useAtomValue(workspaceConnections.environmentsAtom);
29
}
@@ -30,6 +41,7 @@ export function useWorkspaceState() {
41
const networkStatus = useAtomValue(environmentCatalog.networkStatusValueAtom);
42
const projectedEnvironments = useWorkspaceEnvironments();
43
const shellSummary = useAtomValue(environmentShellSummaryAtom);
44
+ const hasSyncingConnectedEnvironment = useAtomValue(hasSyncingConnectedEnvironmentAtom);
45
const state = useMemo(
46
() =>
47
projectWorkspaceState({
@@ -37,8 +49,9 @@ export function useWorkspaceState() {
49
networkStatus,
50
environments: projectedEnvironments,
51
shellSummary,
52
+ hasSyncingConnectedEnvironment,
53
}),
41
- [isReady, networkStatus, projectedEnvironments, shellSummary],
54
+ [isReady, networkStatus, projectedEnvironments, shellSummary, hasSyncingConnectedEnvironment],
55
);
56
57
return {
apps/mobile/src/state/workspaceModel.test.ts
+5
@@ -77,6 +77,7 @@ describe("mobile workspace projection", () => {
77
networkStatus: "offline",
78
environments,
79
shellSummary: EMPTY_SHELL_SUMMARY,
80
+ hasSyncingConnectedEnvironment: false,
81
});
82
83
expect(state.connectionState).toBe("offline");
@@ -94,12 +95,14 @@ describe("mobile workspace projection", () => {
95
networkStatus: "online",
96
environments,
97
shellSummary: EMPTY_SHELL_SUMMARY,
98
+ hasSyncingConnectedEnvironment: true,
99
});
100
101
expect(state.connectingEnvironments).toHaveLength(1);
102
expect(state.connectingEnvironments[0]?.connectionState).toBe("reconnecting");
103
expect(state.hasConnectingEnvironment).toBe(true);
104
expect(state.hasReadyEnvironment).toBe(true);
105
+ expect(state.hasSyncingConnectedEnvironment).toBe(true);
106
});
107
108
it("keeps retained snapshots visible while reconnecting without claiming readiness", () => {
@@ -109,10 +112,12 @@ describe("mobile workspace projection", () => {
112
networkStatus: "online",
113
environments,
114
shellSummary: CACHED_SHELL_SUMMARY,
115
+ hasSyncingConnectedEnvironment: false,
116
});
117
118
expect(state.hasLoadedShellSnapshot).toBe(true);
119
expect(state.hasPendingShellSnapshot).toBe(true);
120
+ expect(state.hasSyncingConnectedEnvironment).toBe(false);
121
expect(state.hasReadyEnvironment).toBe(false);
122
expect(state.connectionState).toBe("reconnecting");
123
});
apps/mobile/src/state/workspaceModel.ts
+3
@@ -25,6 +25,7 @@ export interface WorkspaceConnectionState {
25
export interface WorkspaceState extends WorkspaceConnectionState {
26
readonly hasLoadedShellSnapshot: boolean;
27
readonly hasPendingShellSnapshot: boolean;
28
+ readonly hasSyncingConnectedEnvironment: boolean;
29
readonly shellSnapshotError: string | null;
30
}
31
@@ -92,11 +93,13 @@ export function projectWorkspaceState(input: {
93
readonly networkStatus: NetworkStatus;
94
readonly environments: ReadonlyArray<WorkspaceEnvironment>;
95
readonly shellSummary: EnvironmentShellSummary;
96
+ readonly hasSyncingConnectedEnvironment: boolean;
97
}): WorkspaceState {
98
return {
99
...projectWorkspaceConnectionState(input),
100
hasLoadedShellSnapshot: input.shellSummary.hasSnapshot,
101
hasPendingShellSnapshot: input.shellSummary.hasSynchronizingShell,
102
+ hasSyncingConnectedEnvironment: input.hasSyncingConnectedEnvironment,
103
shellSnapshotError: input.shellSummary.firstError,
104
};
105
}