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, 09:30 UTC
fix(web): PR links at launch open the PR view with the local environment disabled (#26099)
NotAnNvidiaFan committed
Oct 31, 2026 at 21:34 UTC
cbd43b63d20955418e4c956531aac02dee5fd12f
4 files changed
+36
-7
apps/web/src/components/desktop/DesktopWebLinkCoordinator.browser.test.tsx
+14
-2
@@ -329,9 +329,21 @@ it("pairs with Local environment disabled, where there is no primary environment
329
);
330
});
331
332
-it("does not hold a PR link for project discovery that never settles with Local environment disabled", async () => {
332
+it("holds a launch PR link with Local environment disabled until discovery settles", async () => {
333
setup();
334
state.localEnvironmentDisabled = true;
335
await using _coordinator = await mount(pullRequestUrl);
336
- await vi.waitFor(() => expect(state.openScratchProject).toHaveBeenCalledOnce());
336
+ expect(state.navigate).not.toHaveBeenCalled();
337
+ expect(state.openScratchProject).not.toHaveBeenCalled();
338
+
339
+ state.projects = [project];
340
+ const navigated = new Promise<void>((resolve) => {
341
+ state.navigate.mockImplementationOnce(async () => resolve());
342
+ });
343
+ await act(async () => {
344
+ appAtomRegistry.set(discoverySettled, true);
345
+ await navigated;
346
+ });
347
+ expect(state.navigate).toHaveBeenCalledExactlyOnceWith(pullRequestView);
348
+ expect(state.openScratchProject).not.toHaveBeenCalled();
349
});
apps/web/src/components/desktop/DesktopWebLinkCoordinator.tsx
-2
@@ -237,10 +237,8 @@ export function DesktopWebLinkCoordinator() {
237
// A connected server publishes its config before its project snapshot, so a source control
238
// link delivered at launch would miss its project and fall through to the browser. Hold
239
// those links until discovery settles; an ordinary link never waits for it.
240
- // Discovery never settles without the local environment, so those links do not wait.
240
const hold =
241
openPullRequestsInApp &&
243
- !localEnvironmentDisabled &&
242
(sourceControlClients.parseChangeRequestUrl(url) !== null ||
243
sourceControlClients.parseCommitUrl(url) !== null)
244
? projectsSettled()
apps/web/src/state/shell.test.ts
+15
-2
@@ -7,9 +7,9 @@ import { EMPTY_SHELL_STATE, type EnvironmentShellState } from "@t3tools/client-r
7
import { EnvironmentId } from "@t3tools/contracts";
8
import * as Option from "effect/Option";
9
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";
11
12
-import { createAllEnvironmentProjectSnapshotsReadyAtom } from "./shell";
12
+import { createAllEnvironmentProjectSnapshotsReadyAtom, expectsPrimaryEnvironment } from "./shell";
13
14
const LOCAL = EnvironmentId.make("local");
15
const REMOTE = EnvironmentId.make("remote");
@@ -135,3 +135,16 @@ describe("project snapshot readiness", () => {
135
registry.dispose();
136
});
137
});
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
+7
-1
@@ -21,6 +21,7 @@ import { AsyncResult, Atom } from "effect/reactivity";
21
import { environmentCatalog } from "../connection/catalog";
22
import { connectionAtomRuntime } from "../connection/runtime";
23
import { isHostedStaticApp } from "../hostedPairing";
24
+import { isLocalEnvironmentDisabled } from "../localEnvironment";
25
26
export const shellEnvironment = createShellEnvironmentAtoms(connectionAtomRuntime);
27
export const environmentShell = createEnvironmentShellAtoms(connectionAtomRuntime);
@@ -126,9 +127,14 @@ export const allEnvironmentProjectSnapshotsReadyAtom =
127
requiresPrimaryEnvironment: !isHostedStaticApp(),
128
});
129
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
+
135
export const allReachableShellsLiveAtom = Atom.make((get) => {
136
const catalog = get(environmentCatalog.catalogValueAtom);
131
- if (!catalogIsComplete(catalog, !isHostedStaticApp())) return false;
137
+ if (!catalogIsComplete(catalog, expectsPrimaryEnvironment())) return false;
138
for (const environmentId of enabledEnvironmentIds(catalog)) {
139
const shell = get(environmentShell.stateValueAtom(environmentId));
140
if (shell.status === "live" && Option.isSome(shell.snapshot)) continue;