The best way to control Claude Code, Codex and more from any computer or phone
fix(web): project settings no longer dead-ends on environments without the project (#18692)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Samuel Soeller committed
Oct 20, 2026 at 07:08 UTC
acf7043b72a5641c05943a91226067e84a9d0650
4 files changed
+164
-11
apps/web/src/components/settings/ProjectSettingsPanel.browser.test.tsx
+125
-4
@@ -6,6 +6,7 @@ import type {
6
import {
7
AuthOrchestrationOperateScope,
8
AuthSettingsWriteScope,
9
+ DEFAULT_SERVER_SETTINGS,
10
EnvironmentId,
11
ProjectId,
12
ProviderInstanceId,
@@ -26,7 +27,7 @@ import { AsyncResult, Atom } from "effect/reactivity";
27
import { act } from "react";
28
import { createRoot, type Root } from "react-dom/client";
29
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
29
-import { userEvent } from "vite-plus/test/browser";
30
+import { page, userEvent } from "vite-plus/test/browser";
31
32
import type { Project } from "../../types";
33
@@ -105,7 +106,7 @@ vi.mock(import("~/lib/composerDraftUploads"), async (original) => ({
106
...(await original()),
107
releaseProjectDraftUploads: state.releaseUploads,
108
}));
108
-// Sections with their own data sources and tests; this file covers project permissions.
109
+// These sections have separate data sources and their own tests.
110
vi.mock(import("./ProjectDefaultsSettings"), async (original) => ({
111
...(await original()),
112
ProjectDefaultsSettings: (() => null) as never,
@@ -115,11 +116,18 @@ vi.mock(import("./ProjectActionsSettings"), async (original) => ({
116
ProjectActionsSettings: (() => null) as never,
117
}));
118
119
+vi.mock(import("../files/projectFilesQueryState"), async (original) => ({
120
+ ...(await original()),
121
+ getProjectFileQueryAtom: () => missingProjectFile,
122
+}));
123
+
124
import { useComposerDraftStore } from "../../composerDraftStore";
125
import { appAtomRegistry } from "../../rpc/atomRegistry";
126
import { buildSidebarProjectSnapshots } from "../../sidebarProjectGrouping";
127
import { ProjectSettingsPanel } from "./ProjectSettingsPanel";
122
-import type { SettingsScopeSearch } from "./settingsScope";
128
+import { ProjectsSettings } from "./ProjectsSettings";
129
+import { SettingsScopeProvider } from "./SettingsScopeContext";
130
+import { validateSettingsScopeSearch, type SettingsScopeSearch } from "./settingsScope";
131
import { retainSettingsScope, validateSettingsRouteSearch } from "./settingsScopeNavigation";
132
133
const primaryId = EnvironmentId.make("primary");
@@ -129,7 +137,11 @@ const environments = [primaryId, remoteId].map((environmentId) => ({
137
environmentId,
138
label: environmentId,
139
connection: { phase: "connected" },
132
- serverConfig: { keybindings: DEFAULT_RESOLVED_KEYBINDINGS },
140
+ serverConfig: {
141
+ keybindings: DEFAULT_RESOLVED_KEYBINDINGS,
142
+ settings: DEFAULT_SERVER_SETTINGS,
143
+ environment: { platform: { machine: "server" } },
144
+ },
145
}));
146
const session = (scopes: ReadonlyArray<AuthEnvironmentScope>): AuthSessionState => ({
147
authenticated: true,
@@ -142,6 +154,7 @@ const session = (scopes: ReadonlyArray<AuthEnvironmentScope>): AuthSessionState
154
},
155
});
156
const writable = () => AsyncResult.success(session([AuthOrchestrationOperateScope]));
157
+const missingProjectFile = Atom.make(AsyncResult.initial<never, never>());
158
159
function deferred<T>() {
160
let resolve!: (value: T) => void;
@@ -253,6 +266,38 @@ async function mountPanel(search: Omit<SettingsScopeSearch, "project"> = {}) {
266
return router;
267
}
268
269
+async function mountSettings(search: SettingsScopeSearch) {
270
+ const searchParams = new URLSearchParams(
271
+ Object.entries(search).flatMap(([key, value]) => (value === undefined ? [] : [[key, value]])),
272
+ );
273
+ const route = createRootRoute({
274
+ validateSearch: validateSettingsScopeSearch,
275
+ component: () => (
276
+ <SettingsScopeProvider
277
+ search={route.useSearch()}
278
+ onChange={(next) => void router.navigate({ to: "/settings/projects", search: () => next })}
279
+ >
280
+ <ProjectsSettings />
281
+ </SettingsScopeProvider>
282
+ ),
283
+ });
284
+ const router = createRouter({
285
+ routeTree: route,
286
+ history: createMemoryHistory({
287
+ initialEntries: [`/settings/projects?${searchParams.toString()}`],
288
+ }),
289
+ });
290
+ await router.load();
291
+ await act(async () =>
292
+ root.render(
293
+ <RegistryContext.Provider value={appAtomRegistry}>
294
+ <RouterProvider router={router} />
295
+ </RegistryContext.Provider>,
296
+ ),
297
+ );
298
+ return router;
299
+}
300
+
301
const nameInput = () => container.querySelector<HTMLInputElement>('[aria-label="Project name"]')!;
302
const removeCheckout = (root: string) =>
303
container.querySelector<HTMLButtonElement>(`[aria-label="Remove checkout ${root}"]`)!;
@@ -385,6 +430,82 @@ describe("project settings permissions", () => {
430
);
431
});
432
433
+describe("project settings scope", () => {
434
+ it("offers project checkout environments while keeping unselected and unknown projects recoverable", async () => {
435
+ state.projects = state.projects.filter((project) => project.environmentId === primaryId);
436
+ const key = projectKey();
437
+ const router = await mountSettings({});
438
+ const environmentMenu = () => page.getByRole("button", { name: /^Environment scope:/ });
439
+ const primaryOption = () => page.getByRole("menuitemradio", { name: /^primary/ });
440
+ const remoteOption = () => page.getByRole("menuitemradio", { name: /^remote/ });
441
+
442
+ await act(async () => userEvent.click(environmentMenu()));
443
+ await expect.element(primaryOption()).toBeVisible();
444
+ await expect.element(remoteOption()).toBeVisible();
445
+ await act(async () => userEvent.keyboard("{Escape}"));
446
+
447
+ await act(async () =>
448
+ router.navigate({ to: "/settings/projects", search: () => ({ project: key }) }),
449
+ );
450
+ await expect.element(page.getByRole("textbox", { name: "Project name" })).toBeVisible();
451
+ await act(async () => userEvent.click(environmentMenu()));
452
+ await expect.element(primaryOption()).toBeVisible();
453
+ await expect.element(remoteOption()).not.toBeInTheDocument();
454
+ await act(async () => userEvent.keyboard("{Escape}"));
455
+
456
+ await act(async () =>
457
+ router.navigate({ to: "/settings/projects", search: () => ({ project: "removed-project" }) }),
458
+ );
459
+ await act(async () => userEvent.click(environmentMenu()));
460
+ await expect.element(primaryOption()).toBeVisible();
461
+ await expect.element(remoteOption()).toBeVisible();
462
+ await act(async () => userEvent.click(remoteOption()));
463
+ await vi.waitFor(() =>
464
+ expect(router.state.location.search).toEqual({
465
+ project: "removed-project",
466
+ machine: remoteId,
467
+ }),
468
+ );
469
+ });
470
+
471
+ it.each([
472
+ [undefined, "This project has no checkout on this environment."],
473
+ [
474
+ "removed-checkout",
475
+ "This checkout is no longer available in the selected project and environment.",
476
+ ],
477
+ ])("recovers a stale environment link with checkout %s", async (checkout, message) => {
478
+ state.projects = state.projects.filter((project) => project.environmentId === primaryId);
479
+ const key = projectKey();
480
+ const router = await mountSettings({
481
+ project: key,
482
+ machine: remoteId,
483
+ ...(checkout ? { checkout } : {}),
484
+ });
485
+
486
+ await expect.element(page.getByText(message, { exact: true })).toBeVisible();
487
+ await expect.element(page.getByRole("button", { name: /^Project scope:/ })).toBeVisible();
488
+ await expect
489
+ .element(page.getByRole("button", { name: "Environment scope: remote" }))
490
+ .toBeVisible();
491
+ await act(async () =>
492
+ userEvent.click(page.getByRole("button", { name: "Show all environments" })),
493
+ );
494
+
495
+ await expect
496
+ .element(page.getByRole("textbox", { name: "Project name" }))
497
+ .toHaveValue("Shared repo");
498
+ expect(router.state.location.search).toEqual({ project: key });
499
+ await expect
500
+ .element(page.getByRole("button", { name: "Environment scope: All environments" }))
501
+ .toBeVisible();
502
+ await expect.element(page.getByText(message, { exact: true })).not.toBeInTheDocument();
503
+ await expect
504
+ .element(page.getByRole("button", { name: "Remove project", exact: true }))
505
+ .toBeEnabled();
506
+ });
507
+});
508
+
509
it("returns to the project overview after removal, clearing the selection but keeping the environment", async () => {
510
state.projects = [state.projects[1]!];
511
const router = await mountPanel({ machine: remoteId, checkout: "remote:/work/remote" });
apps/web/src/components/settings/ProjectSettingsPanel.tsx
+5
-1
@@ -15,7 +15,7 @@ import { type EnvironmentId, type ProjectIconOverride } from "@t3tools/contracts
15
import { useLocation, useNavigate } from "@tanstack/react-router";
16
import * as Cause from "effect/Cause";
17
import { InfoIcon, Trash2Icon } from "lucide-react";
18
-import { lazy, Suspense, useEffect, useRef, useState } from "react";
18
+import { lazy, Suspense, useEffect, useRef, useState, type ReactNode } from "react";
19
20
import { useComposerDraftStore } from "../../composerDraftStore";
21
import { releaseProjectDraftUploads } from "../../lib/composerDraftUploads";
@@ -65,10 +65,12 @@ export function ProjectSettingsPanel({
65
projectKey,
66
environmentId = null,
67
checkoutKey = null,
68
+ unavailable,
69
}: {
70
projectKey: string;
71
environmentId?: EnvironmentId | null;
72
checkoutKey?: string | null;
73
+ unavailable?: ReactNode;
74
}) {
75
const groups = useSettingsProjectGroups();
76
const navigate = useNavigate({ from: "/settings" });
@@ -126,6 +128,8 @@ export function ProjectSettingsPanel({
128
}
129
}, [groups, navigate, pathname, projectKey, members.length, environmentId, checkoutKey]);
130
131
+ if ((!selected || members.length === 0) && unavailable != null) return unavailable;
132
+
133
if (!selected) {
134
return (
135
<div className="flex flex-1 items-center justify-center p-8 text-sm text-muted-foreground">
apps/web/src/components/settings/ProjectsSettings.tsx
+26
-5
@@ -1,12 +1,34 @@
1
import { EnvironmentId } from "@t3tools/contracts";
2
+import { LayersIcon } from "lucide-react";
3
4
+import { Button } from "../ui/button";
5
import { ProjectSettingsPanel } from "./ProjectSettingsPanel";
6
import { useSettingsScope } from "./SettingsScopeContext";
7
import { SettingsScopeNotice } from "./SettingsScopeNotice";
8
import { SettingsPageContainer } from "./settingsLayout";
9
+import { ALL_ENVIRONMENTS_VALUE, selectEnvironmentAxis } from "./settingsScopeAxis";
10
11
export function ProjectsSettings() {
9
- const { search: value, scope } = useSettingsScope();
12
+ const { search: value, scope, selectScope } = useSettingsScope();
13
+ const unavailable =
14
+ scope.kind === "unavailable" ? (
15
+ <SettingsPageContainer>
16
+ <div className="flex flex-col items-start gap-3">
17
+ <p className="text-sm text-muted-foreground">{scope.message}</p>
18
+ {value.machine || value.checkout ? (
19
+ <Button
20
+ variant="outline"
21
+ size="xs"
22
+ onClick={() => selectScope(selectEnvironmentAxis(value, ALL_ENVIRONMENTS_VALUE))}
23
+ >
24
+ <LayersIcon />
25
+ Show all environments
26
+ </Button>
27
+ ) : null}
28
+ </div>
29
+ </SettingsPageContainer>
30
+ ) : null;
31
+ // Keep the panel mounted so it can follow members when regrouping changes the project key.
32
const projectScope =
33
scope.kind === "project" ||
34
scope.kind === "checkout" ||
@@ -19,11 +41,10 @@ export function ProjectsSettings() {
41
projectKey={value.project}
42
environmentId={value.machine ? EnvironmentId.make(value.machine) : null}
43
checkoutKey={value.checkout ?? null}
44
+ unavailable={unavailable}
45
/>
23
- ) : scope.kind === "unavailable" ? (
24
- <SettingsPageContainer>
25
- <p className="text-sm text-muted-foreground">{scope.message}</p>
26
- </SettingsPageContainer>
46
+ ) : unavailable ? (
47
+ unavailable
48
) : (
49
<SettingsScopeNotice target="project">
50
Choose a project to manage its name, icon, checkouts and actions.
apps/web/src/components/settings/SettingsScopeSentence.tsx
+8
-1
@@ -230,6 +230,13 @@ function EnvironmentScopeMenu({
230
const selected = environments.find(
231
(environment) => environment.environmentId === environmentValue,
232
);
233
+ const project = groups.find((group) => group.projectKey === value.project);
234
+ const memberEnvironmentIds = project
235
+ ? new Set(project.memberProjects.map((member) => member.environmentId))
236
+ : null;
237
+ const options = memberEnvironmentIds
238
+ ? environments.filter((environment) => memberEnvironmentIds.has(environment.environmentId))
239
+ : environments;
240
return (
241
<ScopeMenu
242
ariaLabel="Environment scope"
@@ -263,7 +270,7 @@ function EnvironmentScopeMenu({
270
icon: <LayersIcon aria-hidden className="size-3.5 shrink-0" />,
271
}
272
}
266
- options={environments.map((environment) => {
273
+ options={options.map((environment) => {
274
const { primary, secondary } = settingsScopeEnvironmentLabels(environment, environments);
275
return {
276
value: environment.environmentId,