From 8d564a3e5c77d283994119eca82881f8c37a4a4d Mon Sep 17 00:00:00 2001 From: Charlie J Date: Wed, 7 Oct 2026 18:06:29 +0100 Subject: [PATCH] fix(mobile): hide threads from switched-off environments (#16886) --- .../src/state/threadShell.test.ts | 24 +++++++++++++++++++ .../client-runtime/src/state/threadShell.ts | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/client-runtime/src/state/threadShell.test.ts b/packages/client-runtime/src/state/threadShell.test.ts index 74c93edc3a9aad18151a588cd70e2e8d0720aae3..d3653d30035d78603e05ff914a9e87672600e04b 100644 --- a/packages/client-runtime/src/state/threadShell.test.ts +++ b/packages/client-runtime/src/state/threadShell.test.ts @@ -103,6 +103,30 @@ describe("v2 thread shell lists", () => { registry.dispose(); }); + it("leaves switched-off environments out of navigation", () => { + const { registry, threads, catalogValueAtom } = makeHarness([ + environmentId, + remoteEnvironmentId, + ]); + const dispose = registry.mount(threads.navigationThreadShellsAtom); + const environmentsOf = () => + new Set(registry.get(threads.navigationThreadShellsAtom).map((t) => t.environmentId)); + expect(environmentsOf()).toEqual(new Set([environmentId, remoteEnvironmentId])); + + const setRemoteEnabled = (enabled: boolean) => { + const catalog = registry.get(catalogValueAtom); + const entries = new Map(catalog.entries); + entries.set(remoteEnvironmentId, { ...entries.get(remoteEnvironmentId)!, enabled }); + registry.set(catalogValueAtom, { ...catalog, entries }); + }; + setRemoteEnabled(false); + expect(environmentsOf()).toEqual(new Set([environmentId])); + setRemoteEnabled(true); + expect(environmentsOf()).toEqual(new Set([environmentId, remoteEnvironmentId])); + dispose(); + registry.dispose(); + }); + it("shares point and list values without retaining an atom for every listed thread", () => { const harness = makeHarness(); const snapshot = { diff --git a/packages/client-runtime/src/state/threadShell.ts b/packages/client-runtime/src/state/threadShell.ts index a59fbb2375d359063f57fb562a01f1e7bea74a45..bc6d444f471affc0068febdd09bf56d475fa45fe 100644 --- a/packages/client-runtime/src/state/threadShell.ts +++ b/packages/client-runtime/src/state/threadShell.ts @@ -202,7 +202,7 @@ export function createEnvironmentThreadShellAtoms(input: { let previousNavigationShells: ReadonlyArray = []; const navigationThreadShellsAtom = Atom.make((get) => { const next: EnvironmentThreadShell[] = []; - for (const environmentId of get(input.catalogValueAtom).entries.keys()) { + for (const environmentId of enabledEnvironmentIds(get(input.catalogValueAtom))) { for (const thread of get(environmentThreadsAtom(environmentId))) { if (thread.archivedAt !== null || thread.lineage.relationshipToParent === "subagent") continue; -- 2.54.0