Skip to content

Commit 572302b

Browse files
mpstatonclaude
andcommitted
fix(workspace): heal browser/server active-workspace split-brain on every load
The server's active workspace is in-memory per process, so every stack restart silently resets it to the alphabetical default while the browser keeps its localStorage pick. loadWorkspaces only re-asserted the pick to the server when the BROWSER's own value changed — a persisted pick that still exists was kept locally without ever telling the server, leaving the shell showing one tenant while domain services scoped to another (surfaced today by the didi sign-in reloads and a stack restart: browser said reach-edu, every backend said humain-vc). Now the browser re-asserts whenever the server disagrees, making the operator's persisted pick authoritative and converging the whole stack on every page load. Workspace package typecheck clean. Files changed: - packages/workspace/src/state.svelte.ts Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent ebf1339 commit 572302b

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

packages/workspace/src/state.svelte.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,16 @@ class AugmentItWorkspace {
126126
const resolved = persistedExists
127127
? persisted
128128
: result.active_client_id ?? result.workspaces[0]?.client_id ?? null;
129+
// Re-assert whenever the SERVER disagrees, not just when the browser's
130+
// own pick changed. The server's active is in-memory per process, so
131+
// every stack restart silently resets it to the alphabetical default
132+
// while the browser keeps its persisted pick — without this, the two
133+
// split-brain (browser shows one tenant, domain services scope to
134+
// another) until the operator manually re-picks in the switcher.
135+
if (resolved && resolved !== result.active_client_id) {
136+
await this.invoke('workspace.activate', { client_id: resolved });
137+
}
129138
if (resolved !== persisted) {
130-
// Tell the server about our pick so its process-wide fallback
131-
// matches what the browser will send on chat turns.
132-
if (resolved) await this.invoke('workspace.activate', { client_id: resolved });
133139
this.setActiveClientId(resolved);
134140
}
135141
this.workspaces_status = 'ready';

0 commit comments

Comments
 (0)