Skip to content

Commit 8002b76

Browse files
fix(web): sidebar drops a deleted project's filter with the local environment disabled
Desktops with Local disabled never discover a primary environment, so project snapshot readiness waited for one forever and the sidebar kept a saved filter for a deleted project. Readiness now expects a primary only when the client can have one, the same rule as #26099. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 15fe283 commit 8002b76

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

‎apps/web/src/localEnvironment.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export function isLocalEnvironmentDisabled(): boolean {
2-
return window.desktopBridge?.getLocalEnvironmentEnabled() === false;
2+
return (
3+
typeof window !== "undefined" && window.desktopBridge?.getLocalEnvironmentEnabled() === false
4+
);
35
}

‎apps/web/src/state/shell.test.ts‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { EMPTY_SHELL_STATE, type EnvironmentShellState } from "@t3tools/client-r
77
import { EnvironmentId } from "@t3tools/contracts";
88
import * as Option from "effect/Option";
99
import { Atom, AtomRegistry } from "effect/reactivity";
10-
import { describe, expect, it } from "vite-plus/test";
10+
import { describe, expect, it, vi } from "vite-plus/test";
1111

12-
import { createAllEnvironmentProjectSnapshotsReadyAtom } from "./shell";
12+
import { createAllEnvironmentProjectSnapshotsReadyAtom, expectsPrimaryEnvironment } from "./shell";
1313

1414
const LOCAL = EnvironmentId.make("local");
1515
const REMOTE = EnvironmentId.make("remote");
@@ -135,3 +135,16 @@ describe("project snapshot readiness", () => {
135135
registry.dispose();
136136
});
137137
});
138+
139+
it("expects a primary environment only on desktops with the local environment enabled", () => {
140+
const desktop = (enabled: boolean) => {
141+
vi.stubGlobal("window", { desktopBridge: { getLocalEnvironmentEnabled: () => enabled } });
142+
try {
143+
return expectsPrimaryEnvironment();
144+
} finally {
145+
vi.unstubAllGlobals();
146+
}
147+
};
148+
expect(desktop(true)).toBe(true);
149+
expect(desktop(false)).toBe(false);
150+
});

‎apps/web/src/state/shell.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { AsyncResult, Atom } from "effect/reactivity";
2121
import { environmentCatalog } from "../connection/catalog";
2222
import { connectionAtomRuntime } from "../connection/runtime";
2323
import { isHostedStaticApp } from "../hostedPairing";
24+
import { isLocalEnvironmentDisabled } from "../localEnvironment";
2425

2526
export const shellEnvironment = createShellEnvironmentAtoms(connectionAtomRuntime);
2627
export const environmentShell = createEnvironmentShellAtoms(connectionAtomRuntime);
@@ -123,9 +124,14 @@ export const allEnvironmentProjectSnapshotsReadyAtom =
123124
createAllEnvironmentProjectSnapshotsReadyAtom({
124125
catalogValueAtom: environmentCatalog.catalogValueAtom,
125126
shellStateValueAtom: environmentShell.stateValueAtom,
126-
requiresPrimaryEnvironment: !isHostedStaticApp(),
127+
requiresPrimaryEnvironment: expectsPrimaryEnvironment(),
127128
});
128129

130+
/** Hosted clients and desktops with the local environment disabled never discover a primary. */
131+
export function expectsPrimaryEnvironment(): boolean {
132+
return !isHostedStaticApp() && !isLocalEnvironmentDisabled();
133+
}
134+
129135
export const allReachableShellsLiveAtom = Atom.make((get) => {
130136
const catalog = get(environmentCatalog.catalogValueAtom);
131137
if (!catalogIsComplete(catalog, !isHostedStaticApp())) return false;

0 commit comments

Comments
 (0)