TypeScript
feat(web): show settings scope as a sentence at the top of the page (#13139)
Julius Marminge242816af805b
diff --git a/apps/web/src/components/settings/ProjectDefaultsSettings.tsx b/apps/web/src/components/settings/ProjectDefaultsSettings.tsxindex fe757693385..c39b8cb3c5b 100644--- a/apps/web/src/components/settings/ProjectDefaultsSettings.tsx+++ b/apps/web/src/components/settings/ProjectDefaultsSettings.tsx@@ -129,97 +129,151 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSettingupdateSettings({ defaultModelSelection: value });};+ const modelRow = (+ <SettingsRow+ serverScoped+ settingKeys={["defaultModelSelection"]}+ mixed={mixedModel}+ id="default-model"+ title="Model"+ description={+ isProjectScope+ ? "Model for new threads in this project."+ : "Default model for new threads. Projects can override it."+ }+ status={+ unavailable || mixedModel || modelSource === "project"+ ? undefined+ : settings.defaultModelSelection === null+ ? "Automatic"+ : undefined+ }+ resetAction={+ settings.defaultModelSelection !== null ? (+ <SettingResetButton label="default model" onClick={() => setModel(null)} />+ ) : null+ }+ control={+ selection && activeEntry ? (+ <div className="flex min-w-0 flex-wrap items-center justify-end gap-1.5">+ <ProviderModelPicker+ activeInstanceId={selection.instanceId}+ model={selection.model}+ lockedProvider={null}+ instanceEntries={entries}+ modelOptionsByInstance={modelOptions}+ triggerVariant="outline"+ triggerClassName={SETTINGS_PICKER_TRIGGER_CLASSNAME}+ {...(mixedModel ? { triggerLabel: "Mixed" } : {})}+ getModelDisabledReason={modelDisabledReason}+ onOpenProviderSetup={(instanceId) => {+ if (representative)+ void navigate({+ to: "/settings/providers",+ search: { environmentId: representative.environmentId, instanceId },+ });+ }}+ onInstanceModelChange={(instanceId, model) =>+ setModel(createModelSelection(instanceId, model))+ }+ />+ {!mixedModel ? (+ <TraitsPicker+ provider={activeEntry.driverKind}+ models={activeEntry.models}+ model={selection.model}+ prompt=""+ onPromptChange={() => {}}+ modelOptions={selection.options ?? []}+ allowPromptInjectedEffort={false}+ planModeEnabled={settings.planModeEnabled}+ triggerVariant="outline"+ triggerClassName={SETTINGS_PICKER_TRIGGER_CLASSNAME}+ onModelOptionsChange={(options) =>+ setModel(createModelSelection(selection.instanceId, selection.model, options))+ }+ />+ ) : null}+ </div>+ ) : (+ <span className="text-sm text-muted-foreground">No providers available</span>+ )+ }+ />+ );+ const workspaceRow = (+ <SettingsRow+ serverScoped+ settingKeys={["defaultThreadEnvMode"]}+ mixed={mixedWorkspace}+ id={searchableSetting("new-threads").id}+ title="Workspace"+ description={+ isProjectScope+ ? "Where new threads in this project start."+ : "Where new threads start. Projects and their t3.json can override it."+ }+ resetAction={+ !isProjectScope && settings.defaultThreadEnvMode !== null ? (+ <SettingResetButton+ label="default workspace"+ onClick={() => updateSettings({ defaultThreadEnvMode: null })}+ />+ ) : null+ }+ control={+ <Select+ value={mixedWorkspace ? null : (effective?.defaultThreadEnvMode ?? null)}+ onValueChange={(value) => {+ if (value === "local" || value === "worktree")+ updateSettings({ defaultThreadEnvMode: value });+ }}+ >+ <SelectTrigger size="sm" aria-label="Default workspace">+ <SelectValue>+ {(value: string | null) =>+ value === "local" || value === "worktree"+ ? resolveEnvModeLabel(value)+ : unavailable+ ? "Unavailable"+ : "Mixed"+ }+ </SelectValue>+ </SelectTrigger>+ <SelectPopup align="end" alignItemWithTrigger={false}>+ <SelectItem value="local">{resolveEnvModeLabel("local")}</SelectItem>+ <SelectItem value="worktree">{resolveEnvModeLabel("worktree")}</SelectItem>+ </SelectPopup>+ </Select>+ }+ />+ );+return (<SettingsSectionid={- category === "general"+ category === "general" || category === "project"? "project-defaults": category === "integrations"? "browser-access": "source-control-defaults"}title={- category === "general"+ category === "general" || category === "project"? "New threads": category === "integrations"? "Browser": "Repositories"}>- {category === "general" ? (+ {category === "project" ? (<>- <SettingsRow- serverScoped- settingKeys={["defaultModelSelection"]}- mixed={mixedModel}- id="default-model"- title="Model"- description={- isProjectScope- ? "Model for new threads in this project."- : "Default model for new threads. Projects can override it."- }- status={- unavailable || mixedModel || modelSource === "project"- ? undefined- : settings.defaultModelSelection === null- ? "Automatic"- : undefined- }- resetAction={- settings.defaultModelSelection !== null ? (- <SettingResetButton label="default model" onClick={() => setModel(null)} />- ) : null- }- control={- selection && activeEntry ? (- <div className="flex min-w-0 flex-wrap items-center justify-end gap-1.5">- <ProviderModelPicker- activeInstanceId={selection.instanceId}- model={selection.model}- lockedProvider={null}- instanceEntries={entries}- modelOptionsByInstance={modelOptions}- triggerVariant="outline"- triggerClassName={SETTINGS_PICKER_TRIGGER_CLASSNAME}- {...(mixedModel ? { triggerLabel: "Mixed" } : {})}- getModelDisabledReason={modelDisabledReason}- onOpenProviderSetup={(instanceId) => {- if (representative)- void navigate({- to: "/settings/providers",- search: { environmentId: representative.environmentId, instanceId },- });- }}- onInstanceModelChange={(instanceId, model) =>- setModel(createModelSelection(instanceId, model))- }- />- {!mixedModel ? (- <TraitsPicker- provider={activeEntry.driverKind}- models={activeEntry.models}- model={selection.model}- prompt=""- onPromptChange={() => {}}- modelOptions={selection.options ?? []}- allowPromptInjectedEffort={false}- planModeEnabled={settings.planModeEnabled}- triggerVariant="outline"- triggerClassName={SETTINGS_PICKER_TRIGGER_CLASSNAME}- onModelOptionsChange={(options) =>- setModel(- createModelSelection(selection.instanceId, selection.model, options),- )- }- />- ) : null}- </div>- ) : (- <span className="text-sm text-muted-foreground">No providers available</span>- )- }- />+ {modelRow}+ {workspaceRow}+ </>+ ) : category === "general" ? (+ <>+ {modelRow}<SettingsRowserverScopedsettingKeys={["defaultRuntimeMode"]}@@ -281,51 +335,7 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting</Select>}/>- <SettingsRow- serverScoped- settingKeys={["defaultThreadEnvMode"]}- mixed={mixedWorkspace}- id={searchableSetting("new-threads").id}- title="Workspace"- description={- isProjectScope- ? "Where new threads in this project start."- : "Where new threads start. Projects and their t3.json can override it."- }- resetAction={- !isProjectScope && settings.defaultThreadEnvMode !== null ? (- <SettingResetButton- label="default workspace"- onClick={() => updateSettings({ defaultThreadEnvMode: null })}- />- ) : null- }- control={- <Select- value={mixedWorkspace ? null : (effective?.defaultThreadEnvMode ?? null)}- onValueChange={(value) => {- if (value === "local" || value === "worktree")- updateSettings({ defaultThreadEnvMode: value });- }}- >- <SelectTrigger size="sm" aria-label="Default workspace">- <SelectValue>- {(value: string | null) =>- value === "local" || value === "worktree"- ? resolveEnvModeLabel(value)- : unavailable- ? "Unavailable"- : "Mixed"- }- </SelectValue>- </SelectTrigger>- <SelectPopup align="end" alignItemWithTrigger={false}>- <SelectItem value="local">{resolveEnvModeLabel("local")}</SelectItem>- <SelectItem value="worktree">{resolveEnvModeLabel("worktree")}</SelectItem>- </SelectPopup>- </Select>- }- />+ {workspaceRow}<SettingsRowserverScopedsettingKeys={["worktreeSubmodules"]}diff --git a/apps/web/src/components/settings/ProjectSettingsPanel.tsx b/apps/web/src/components/settings/ProjectSettingsPanel.tsxindex c31edf0f7e3..8e5edec0f48 100644--- a/apps/web/src/components/settings/ProjectSettingsPanel.tsx+++ b/apps/web/src/components/settings/ProjectSettingsPanel.tsx@@ -10,7 +10,7 @@ import { AsyncResult } from "effect/unstable/reactivity";import { type EnvironmentId, type ProjectIconOverride } from "@t3tools/contracts";import { useLocation, useNavigate } from "@tanstack/react-router";import * as Cause from "effect/Cause";-import { Trash2Icon } from "lucide-react";+import { InfoIcon, Trash2Icon } from "lucide-react";import { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";import { useComposerDraftStore } from "../../composerDraftStore";@@ -25,6 +25,7 @@ import { useThreadShells } from "../../state/entities";import { projectEnvironment } from "../../state/projects";import { useAtomCommand } from "../../state/use-atom-command";import { ProjectFavicon } from "../ProjectFavicon";+import { Alert, AlertDescription } from "../ui/alert";import { Button } from "../ui/button";import { Input } from "../ui/input";import { stackedThreadToast, toastManager } from "../ui/toast";@@ -39,6 +40,7 @@ import {ProjectFaviconPickerDialog,} from "./ProjectFaviconPickerDialog";import { ProjectActionsSettings } from "./ProjectActionsSettings";+import { ProjectDefaultsSettings } from "./ProjectDefaultsSettings";import { projectGroupTitleNeedsUpdate } from "./ProjectSettingsPanel.logic";import { useSettingsProjectGroups } from "./useSettingsProjectGroups";@@ -52,7 +54,8 @@ function memberKey(member: { environmentId: string; id: string }): string {return `${member.environmentId}:${member.id}`;}-export type ProjectSettingsCategory = "general" | "integrations" | "source-control";+/** `project` is the Projects page shortcut: the new-thread defaults people change most. */+export type ProjectSettingsCategory = "general" | "integrations" | "source-control" | "project";export function ProjectSettingsPanel({projectKey,@@ -406,6 +409,12 @@ function ProjectDetail({return (<><SettingsPageContainer className="gap-6">+ <Alert variant="info">+ <InfoIcon aria-hidden />+ <AlertDescription>+ Can't find a setting? Keep this project picked above and hop to any other settings page.+ </AlertDescription>+ </Alert><SettingsSection id="project-overview" title="Project" hideTitle><SettingsRowtitle="Name"@@ -480,6 +489,7 @@ function ProjectDetail({}/></SettingsSection>+ <ProjectDefaultsSettings category="project" /><ProjectActionsSettings />{hasMultipleCheckouts ? checkoutChoices : null}<SettingsSection title="Danger">diff --git a/apps/web/src/components/settings/ProjectsSettings.tsx b/apps/web/src/components/settings/ProjectsSettings.tsxindex 995b1119117..397662c5f70 100644--- a/apps/web/src/components/settings/ProjectsSettings.tsx+++ b/apps/web/src/components/settings/ProjectsSettings.tsx@@ -3,6 +3,7 @@ import { EnvironmentId } from "@t3tools/contracts";import { ProjectSettingsPanel } from "./ProjectSettingsPanel";import { useSettingsScope } from "./SettingsScopeContext";import { SettingsScopeNotice } from "./SettingsScopeNotice";+import { SettingsPageContainer } from "./settingsLayout";/** Project identity and checkout management for the selected project. */export function ProjectsSettings() {@@ -22,7 +23,9 @@ export function ProjectsSettings() {checkoutKey={value.checkout ?? null}/>) : scope.kind === "unavailable" ? (- <p className="p-8 text-sm text-muted-foreground">{scope.message}</p>+ <SettingsPageContainer>+ <p className="text-sm text-muted-foreground">{scope.message}</p>+ </SettingsPageContainer>) : (<SettingsScopeNotice target="project">Choose a project to manage its name, icon, checkouts and actions.diff --git a/apps/web/src/components/settings/ProviderSettingsPanel.environment.test.tsx b/apps/web/src/components/settings/ProviderSettingsPanel.environment.test.tsxindex 90d84d1c1ef..2d5d5d75171 100644--- a/apps/web/src/components/settings/ProviderSettingsPanel.environment.test.tsx+++ b/apps/web/src/components/settings/ProviderSettingsPanel.environment.test.tsx@@ -58,6 +58,7 @@ vi.mock("./settingsLayout", async (importOriginal) => {};});+vi.mock("./SettingsScopeSentence", () => ({ SettingsScopeSentence: () => null }));vi.mock("react/compiler-runtime", async () => {const { reactHookHarness } = await import("../../test/reactHookHarness");return { c: reactHookHarness.useMemoCache };diff --git a/apps/web/src/components/settings/SettingsBreadcrumb.tsx b/apps/web/src/components/settings/SettingsBreadcrumb.tsxindex 29555c33782..c4e019d6fcf 100644--- a/apps/web/src/components/settings/SettingsBreadcrumb.tsx+++ b/apps/web/src/components/settings/SettingsBreadcrumb.tsx@@ -1,37 +1,9 @@-import { resolveEnvironmentMachineKind } from "@t3tools/contracts";-import { LayersIcon } from "lucide-react";-import type { ReactNode } from "react";--import type { SidebarProjectSnapshot } from "../../sidebarProjectGrouping";-import type { EnvironmentPresentation } from "../../state/environments";-import { EnvironmentMachineIcon } from "../EnvironmentMachineIcon";-import { ProjectFavicon } from "../ProjectFavicon";-import { InlineButton } from "../ui/button";-import {- Menu,- MenuPopup,- MenuRadioGroup,- MenuRadioItem,- MenuRadioItemIndicator,- MenuSeparator,- MenuTrigger,-} from "../ui/menu";import {WorkspaceBreadcrumb,WorkspaceBreadcrumbItem,WorkspaceBreadcrumbSeparator,} from "../WorkspaceBreadcrumb";import { SETTINGS_SECTION_LABELS } from "./settingsSearch";-import { resolveSettingsScope, type SettingsScopeSearch } from "./settingsScope";-import {- ALL_ENVIRONMENTS_VALUE,- ALL_PROJECTS_VALUE,- environmentAxisValue,- projectAxisValue,- selectEnvironmentAxis,- selectProjectAxis,- settingsScopeEnvironmentLabel,-} from "./settingsScopeAxis";const SETTINGS_BREADCRUMB_LABELS: Readonly<Record<string, string>> = {...SETTINGS_SECTION_LABELS,@@ -44,27 +16,11 @@ function settingsBreadcrumbLabel(pathname: string): string | null {return SETTINGS_BREADCRUMB_LABELS[normalizedPathname] ?? null;}-export interface SettingsScopeBreadcrumbProps {- readonly value: SettingsScopeSearch;- readonly groups: readonly SidebarProjectSnapshot[];- readonly environments: readonly EnvironmentPresentation[];- readonly onChange: (next: SettingsScopeSearch) => void;-}-/**- * `Settings / Section / Environment / Project`. The last two crumbs are the- * targets a change applies to and read like the usage page's filter: muted at- * "all", foreground once narrowed. A project is the same project on every- * environment, so the environment crumb alone decides where a project- * override is written.+ * `Settings / Section`. The scope a change applies to lives at the top of the+ * page content, see `SettingsScopeSentence`.*/-export function SettingsBreadcrumb({- pathname,- scope,-}: {- pathname: string;- scope?: SettingsScopeBreadcrumbProps | undefined;-}) {+export function SettingsBreadcrumb({ pathname }: { pathname: string }) {const sectionLabel = settingsBreadcrumbLabel(pathname);return (@@ -78,154 +34,6 @@ export function SettingsBreadcrumb({<WorkspaceBreadcrumbItem current className="truncate">{sectionLabel ?? "Settings"}</WorkspaceBreadcrumbItem>- {scope ? (- <>- <WorkspaceBreadcrumbSeparator />- <WorkspaceBreadcrumbItem className="min-w-0 shrink">- <EnvironmentScopeMenu {...scope} />- </WorkspaceBreadcrumbItem>- <WorkspaceBreadcrumbSeparator />- <WorkspaceBreadcrumbItem className="min-w-0 shrink">- <ProjectScopeMenu {...scope} />- </WorkspaceBreadcrumbItem>- </>- ) : null}</WorkspaceBreadcrumb>);}--function ScopeMenu({- ariaLabel,- icon,- label,- narrowed,- children,-}: {- ariaLabel: string;- icon: ReactNode;- label: string;- narrowed: boolean;- children: ReactNode;-}) {- return (- <Menu>- <MenuTrigger- aria-label={ariaLabel}- render={<InlineButton tone={narrowed ? "default" : "muted"} />}- className="min-w-0 max-w-56 gap-1.5"- >- {icon}- <span className="min-w-0 truncate">{label}</span>- </MenuTrigger>- <MenuPopup align="start">{children}</MenuPopup>- </Menu>- );-}--function EnvironmentScopeMenu({- value,- groups,- environments,- onChange,-}: SettingsScopeBreadcrumbProps) {- const resolved = resolveSettingsScope(value, groups, environments);- const environmentValue = environmentAxisValue(- value,- resolved.kind === "checkout" ? resolved.environmentId : null,- );- const selected = environments.find(- (environment) => environment.environmentId === environmentValue,- );- return (- <ScopeMenu- ariaLabel="Environment scope"- narrowed={environmentValue !== ALL_ENVIRONMENTS_VALUE}- icon={- selected ? (- <EnvironmentMachineIcon- aria-hidden- kind={resolveEnvironmentMachineKind(selected.serverConfig)}- className="size-3.5 shrink-0"- />- ) : null- }- label={- selected- ? settingsScopeEnvironmentLabel(selected, environments)- : environmentValue !== ALL_ENVIRONMENTS_VALUE- ? "Unavailable environment"- : "All environments"- }- >- <MenuRadioGroup- value={environmentValue}- onValueChange={(next) => {- if (typeof next === "string") onChange(selectEnvironmentAxis(value, next));- }}- >- <MenuRadioItem value={ALL_ENVIRONMENTS_VALUE}>- <span className="flex min-w-0 items-center gap-2">- <LayersIcon aria-hidden className="size-3.5" />- <span className="min-w-0 flex-1 truncate">All environments</span>- <MenuRadioItemIndicator />- </span>- </MenuRadioItem>- <MenuSeparator />- {environments.map((environment) => (- <MenuRadioItem key={environment.environmentId} value={environment.environmentId}>- <span className="flex min-w-0 items-center gap-2">- <EnvironmentMachineIcon- aria-hidden- kind={resolveEnvironmentMachineKind(environment.serverConfig)}- className="size-3.5"- />- <span className="min-w-0 flex-1 truncate">- {settingsScopeEnvironmentLabel(environment, environments)}- </span>- {environment.connection.phase === "connected" ? null : (- <span className="shrink-0 text-xs text-muted-foreground">Offline</span>- )}- <MenuRadioItemIndicator />- </span>- </MenuRadioItem>- ))}- </MenuRadioGroup>- </ScopeMenu>- );-}--function ProjectScopeMenu({ value, groups, onChange }: SettingsScopeBreadcrumbProps) {- const selected = groups.find((group) => group.projectKey === value.project);- return (- <ScopeMenu- ariaLabel="Project scope"- narrowed={value.project !== undefined}- icon={selected ? <ProjectFavicon project={selected} className="size-3.5 shrink-0" /> : null}- label={selected?.displayName ?? (value.project ? "Unavailable project" : "All projects")}- >- <MenuRadioGroup- value={projectAxisValue(value)}- onValueChange={(next) => {- if (typeof next === "string") onChange(selectProjectAxis(value, next));- }}- >- <MenuRadioItem value={ALL_PROJECTS_VALUE}>- <span className="flex min-w-0 items-center gap-2">- <span className="min-w-0 flex-1 truncate">All projects</span>- <MenuRadioItemIndicator />- </span>- </MenuRadioItem>- <MenuSeparator />- {groups.map((group) => (- <MenuRadioItem key={group.projectKey} value={group.projectKey}>- <span className="flex min-w-0 items-center gap-2">- <ProjectFavicon project={group} className="size-3.5" />- <span className="min-w-0 flex-1 truncate">{group.displayName}</span>- <MenuRadioItemIndicator />- </span>- </MenuRadioItem>- ))}- </MenuRadioGroup>- </ScopeMenu>- );-}diff --git a/apps/web/src/components/settings/SettingsScopeSentence.tsx b/apps/web/src/components/settings/SettingsScopeSentence.tsxnew file mode 100644index 00000000000..5341b72e73e--- /dev/null+++ b/apps/web/src/components/settings/SettingsScopeSentence.tsx@@ -0,0 +1,207 @@+import { resolveEnvironmentMachineKind } from "@t3tools/contracts";+import { useLocation } from "@tanstack/react-router";+import { ChevronDownIcon, LayersIcon } from "lucide-react";+import type { ReactNode } from "react";++import type { SidebarProjectSnapshot } from "../../sidebarProjectGrouping";+import { useEnvironments, type EnvironmentPresentation } from "../../state/environments";+import { EnvironmentMachineIcon } from "../EnvironmentMachineIcon";+import { ProjectFavicon } from "../ProjectFavicon";+import { InlineButton } from "../ui/button";+import {+ Menu,+ MenuPopup,+ MenuRadioGroup,+ MenuRadioItem,+ MenuRadioItemIndicator,+ MenuSeparator,+ MenuTrigger,+} from "../ui/menu";+import { useOptionalSettingsScope } from "./SettingsScopeContext";+import { resolveSettingsScope, type SettingsScopeSearch } from "./settingsScope";+import {+ ALL_ENVIRONMENTS_VALUE,+ ALL_PROJECTS_VALUE,+ environmentAxisValue,+ projectAxisValue,+ selectEnvironmentAxis,+ selectProjectAxis,+ settingsScopeEnvironmentLabel,+} from "./settingsScopeAxis";++/** Pages whose every row is saved on this client; they have no scope to pick. */+export const SETTINGS_DEVICE_ONLY_PATHS: ReadonlySet<string> = new Set([+ "/settings/appearance",+ "/settings/snap-shot",+ "/settings/connections",+]);++interface SettingsScopeMenuProps {+ readonly value: SettingsScopeSearch;+ readonly groups: readonly SidebarProjectSnapshot[];+ readonly environments: readonly EnvironmentPresentation[];+ readonly onChange: (next: SettingsScopeSearch) => void;+}++/**+ * "Applying settings for <project> across <environment>" at the top of a settings+ * page. The two pickers are the targets a change is written to. A project is+ * the same project on every environment, so the environment alone decides+ * where a project override is written.+ */+export function SettingsScopeSentence() {+ const scope = useOptionalSettingsScope();+ const pathname = useLocation({ select: (location) => location.pathname });+ const { environments } = useEnvironments();+ if (scope === null || SETTINGS_DEVICE_ONLY_PATHS.has(pathname)) return null;+ const props: SettingsScopeMenuProps = {+ value: scope.search,+ groups: scope.groups,+ environments,+ onChange: scope.selectScope,+ };+ return (+ <p className="flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 px-3 text-base text-muted-foreground sm:px-4">+ {/* Each connective stays with its picker so a wrap never strands "on". */}+ <span className="flex min-w-0 items-center gap-1.5">+ <span className="shrink-0">Applying settings for</span>+ <ProjectScopeMenu {...props} />+ </span>+ <span className="flex min-w-0 items-center gap-1.5">+ <span className="shrink-0">+ {/* A legacy checkout link names one environment without `machine`. */}+ {scope.search.machine || scope.scope.kind === "checkout" ? "on" : "across"}+ </span>+ <EnvironmentScopeMenu {...props} />+ </span>+ </p>+ );+}++function ScopeMenu({+ ariaLabel,+ icon,+ label,+ children,+}: {+ ariaLabel: string;+ icon: ReactNode;+ label: string;+ children: ReactNode;+}) {+ return (+ <Menu>+ <MenuTrigger+ aria-label={`${ariaLabel}: ${label}`}+ render={<InlineButton tone="picker" />}+ className="min-w-0 max-w-72"+ >+ {icon}+ <span className="min-w-0 truncate">{label}</span>+ <ChevronDownIcon aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />+ </MenuTrigger>+ <MenuPopup align="start">{children}</MenuPopup>+ </Menu>+ );+}++function EnvironmentScopeMenu({ value, groups, environments, onChange }: SettingsScopeMenuProps) {+ const resolved = resolveSettingsScope(value, groups, environments);+ const environmentValue = environmentAxisValue(+ value,+ resolved.kind === "checkout" ? resolved.environmentId : null,+ );+ const selected = environments.find(+ (environment) => environment.environmentId === environmentValue,+ );+ return (+ <ScopeMenu+ ariaLabel="Environment scope"+ icon={+ selected ? (+ <EnvironmentMachineIcon+ aria-hidden+ kind={resolveEnvironmentMachineKind(selected.serverConfig)}+ className="size-3.5 shrink-0"+ />+ ) : null+ }+ label={+ selected+ ? settingsScopeEnvironmentLabel(selected, environments)+ : environmentValue !== ALL_ENVIRONMENTS_VALUE+ ? "Unavailable environment"+ : "All environments"+ }+ >+ <MenuRadioGroup+ value={environmentValue}+ onValueChange={(next) => {+ if (typeof next === "string") onChange(selectEnvironmentAxis(value, next));+ }}+ >+ <MenuRadioItem value={ALL_ENVIRONMENTS_VALUE}>+ <span className="flex min-w-0 items-center gap-2">+ <LayersIcon aria-hidden className="size-3.5" />+ <span className="min-w-0 flex-1 truncate">All environments</span>+ <MenuRadioItemIndicator />+ </span>+ </MenuRadioItem>+ <MenuSeparator />+ {environments.map((environment) => (+ <MenuRadioItem key={environment.environmentId} value={environment.environmentId}>+ <span className="flex min-w-0 items-center gap-2">+ <EnvironmentMachineIcon+ aria-hidden+ kind={resolveEnvironmentMachineKind(environment.serverConfig)}+ className="size-3.5"+ />+ <span className="min-w-0 flex-1 truncate">+ {settingsScopeEnvironmentLabel(environment, environments)}+ </span>+ {environment.connection.phase === "connected" ? null : (+ <span className="shrink-0 text-xs text-muted-foreground">Offline</span>+ )}+ <MenuRadioItemIndicator />+ </span>+ </MenuRadioItem>+ ))}+ </MenuRadioGroup>+ </ScopeMenu>+ );+}++function ProjectScopeMenu({ value, groups, onChange }: SettingsScopeMenuProps) {+ const selected = groups.find((group) => group.projectKey === value.project);+ return (+ <ScopeMenu+ ariaLabel="Project scope"+ icon={selected ? <ProjectFavicon project={selected} className="size-3.5 shrink-0" /> : null}+ label={selected?.displayName ?? (value.project ? "Unavailable project" : "All projects")}+ >+ <MenuRadioGroup+ value={projectAxisValue(value)}+ onValueChange={(next) => {+ if (typeof next === "string") onChange(selectProjectAxis(value, next));+ }}+ >+ <MenuRadioItem value={ALL_PROJECTS_VALUE}>+ <span className="flex min-w-0 items-center gap-2">+ <span className="min-w-0 flex-1 truncate">All projects</span>+ <MenuRadioItemIndicator />+ </span>+ </MenuRadioItem>+ <MenuSeparator />+ {groups.map((group) => (+ <MenuRadioItem key={group.projectKey} value={group.projectKey}>+ <span className="flex min-w-0 items-center gap-2">+ <ProjectFavicon project={group} className="size-3.5" />+ <span className="min-w-0 flex-1 truncate">{group.displayName}</span>+ <MenuRadioItemIndicator />+ </span>+ </MenuRadioItem>+ ))}+ </MenuRadioGroup>+ </ScopeMenu>+ );+}diff --git a/apps/web/src/components/settings/SnapShotSettings.test.tsx b/apps/web/src/components/settings/SnapShotSettings.test.tsxindex 584c224493d..b8f5bed9979 100644--- a/apps/web/src/components/settings/SnapShotSettings.test.tsx+++ b/apps/web/src/components/settings/SnapShotSettings.test.tsx@@ -27,6 +27,7 @@ vi.mock("react/compiler-runtime", async () => {vi.mock("@effect/atom-react", () => ({ useAtomValue: () => [] }));vi.mock("../../state/server", () => ({ primaryServerKeybindingsAtom: {} }));vi.mock("./SettingsScopeContext", () => ({ useOptionalSettingsScope: () => null }));+vi.mock("./SettingsScopeSentence", () => ({ SettingsScopeSentence: () => null }));const bridge = vi.hoisted(() => ({getSnapShotState: vi.fn<() => Promise<DesktopSnapShotState>>(),setSnapShotShortcutSuppressed: vi.fn(),diff --git a/apps/web/src/components/settings/settingsLayout.tsx b/apps/web/src/components/settings/settingsLayout.tsxindex c204fb9d6b6..7f2a56f3312 100644--- a/apps/web/src/components/settings/settingsLayout.tsx+++ b/apps/web/src/components/settings/settingsLayout.tsx@@ -23,6 +23,7 @@ import { WorkspacePageContainer, type WorkspacePageWidth } from "../WorkspacePagimport { Button } from "../ui/button";import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";import { useOptionalSettingsScope } from "./SettingsScopeContext";+import { SettingsScopeSentence } from "./SettingsScopeSentence";import {isProjectScopedSettingKey,listProjectOverrides,@@ -545,6 +546,7 @@ export function SettingsPageContainer({data-settings-page-scroll><WorkspacePageContainer width={width} className={cn("gap-8", className)}>+ <SettingsScopeSentence />{children}</WorkspacePageContainer></div>diff --git a/apps/web/src/components/ui/button.tsx b/apps/web/src/components/ui/button.tsxindex ef373e49f14..f2775a82ffd 100644--- a/apps/web/src/components/ui/button.tsx+++ b/apps/web/src/components/ui/button.tsx@@ -106,6 +106,9 @@ const inlineButtonVariants = cva(default: "text-foreground",muted: "text-muted-foreground hover:text-foreground",destructive: "text-destructive/80 hover:text-destructive",+ /** Opens a menu from inside a sentence; the dotted underline marks it as a choice. */+ picker:+ "gap-1.5 text-foreground underline decoration-foreground/30 decoration-dotted decoration-from-font underline-offset-4 hover:decoration-foreground hover:decoration-solid data-popup-open:decoration-foreground data-popup-open:decoration-solid",},},},diff --git a/apps/web/src/routes/settings.tsx b/apps/web/src/routes/settings.tsxindex e95895926d4..5fc6d63f20f 100644--- a/apps/web/src/routes/settings.tsx+++ b/apps/web/src/routes/settings.tsx@@ -19,9 +19,10 @@ import {SettingsScopeProvider,useSettingsScope,} from "../components/settings/SettingsScopeContext";-import { useSettingsProjectGroups } from "../components/settings/useSettingsProjectGroups";import { useEnvironments } from "../state/environments";import { SettingsScopeNotice } from "../components/settings/SettingsScopeNotice";+import { SETTINGS_DEVICE_ONLY_PATHS } from "../components/settings/SettingsScopeSentence";+import { SettingsPageContainer } from "../components/settings/settingsLayout";import {retainSettingsScope,validateSettingsRouteSearch,@@ -47,13 +48,6 @@ function RestoreDeviceDefaultsButton({ onRestored }: { onRestored: () => void }));}-/** Pages whose every row is saved on this client; the scope selects are hidden there. */-const DEVICE_ONLY_PATHS = new Set([- "/settings/appearance",- "/settings/snap-shot",- "/settings/connections",-]);-function SettingsScopeBoundary({ pathname, children }: { pathname: string; children: ReactNode }) {const { scope, connectedEnvironments } = useSettingsScope();const { environments } = useEnvironments();@@ -99,16 +93,23 @@ function SettingsScopeBoundary({ pathname, children }: { pathname: string; child}// Device-local pages ignore the scope entirely; the project page follows// remembered members while a grouping change replaces its URL key.- if (DEVICE_ONLY_PATHS.has(pathname) || pathname === "/settings/projects") {+ if (SETTINGS_DEVICE_ONLY_PATHS.has(pathname) || pathname === "/settings/projects") {return children;}+ // Keep the scope sentence on screen so the selection can be changed back.if (scope.kind === "unavailable")- return <p className="p-8 text-sm text-muted-foreground">{scope.message}</p>;+ return (+ <SettingsPageContainer>+ <p className="text-sm text-muted-foreground">{scope.message}</p>+ </SettingsPageContainer>+ );if (scope.kind === "environment" && connectedEnvironments.length === 0) {return (- <p className="p-8 text-sm text-muted-foreground">- Reconnect {scope.label} to change its settings.- </p>+ <SettingsPageContainer>+ <p className="text-sm text-muted-foreground">+ Reconnect {scope.label} to change its settings.+ </p>+ </SettingsPageContainer>);}return children;@@ -118,11 +119,8 @@ function SettingsContentLayout() {const location = useLocation();const navigate = useNavigate();const canGoBack = useCanGoBack();- const { search, selectScope } = useSettingsScope();- const groups = useSettingsProjectGroups();- const { environments } = useEnvironments();+ const { search } = useSettingsScope();const [restoreSignal, setRestoreSignal] = useState(0);- const showScope = !DEVICE_ONLY_PATHS.has(location.pathname);const navigateBackWithinApp = useCallback(() => {if (canGoBack) {window.history.back();@@ -157,14 +155,7 @@ function SettingsContentLayout() {<div className="flex min-h-0 min-w-0 flex-1 flex-col bg-background text-foreground"><WorkspacePageHeader electron={isElectron}><div className="flex w-full items-center gap-3">- <SettingsBreadcrumb- pathname={location.pathname}- scope={- showScope- ? { value: search, groups, environments, onChange: selectScope }- : undefined- }- />+ <SettingsBreadcrumb pathname={location.pathname} />{location.pathname === "/settings/general" ? (<div className="ms-auto flex shrink-0 items-center"><RestoreDeviceDefaultsButtondiff --git a/docs/user/project-settings.md b/docs/user/project-settings.mdindex b5ad7c6514d..fe3d96ba472 100644--- a/docs/user/project-settings.md+++ b/docs/user/project-settings.md@@ -1,8 +1,9 @@# Settings and project overrides-On web and desktop, the Settings breadcrumb ends with the environment and project a change applies to. They start-at **All environments** and **All projects** and stay selected as you move between categories or-search for a setting.+On web and desktop, the "Applying settings for …" sentence at the top of Settings pages picks+the project and environment a change applies to. Pages that only hold device preferences, such as+Appearance, don't show it. They start at **All projects** and **All environments**+and stay selected as you move between categories or search for a setting.Preferences saved on this device, such as appearance, confirmations and browser profiles, alwaysshow and ignore the selection. Everything else is stored on a server. Choose one environment to