feat(web): show settings scope as a sentence at the top of the page (#13139)

Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Julius MarmingeandClaude Opus 5.5 authored and GitHub committed 2026-09-22 23:46:27 +00:00
1 parent bed0b4cdad
commit 242816af80
11 files changed
+383 -346

No files matched your search

@@ -129,97 +129,151 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
updateSettings({ 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 (
<SettingsSection
id={
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}
<SettingsRow
serverScoped
settingKeys={["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}
<SettingsRow
serverScoped
settingKeys={["worktreeSubmodules"]}
@@ -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>
<SettingsRow
title="Name"
@@ -480,6 +489,7 @@ function ProjectDetail({
}
/>
</SettingsSection>
<ProjectDefaultsSettings category="project" />
<ProjectActionsSettings />
{hasMultipleCheckouts ? checkoutChoices : null}
<SettingsSection title="Danger">
@@ -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.
@@ -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 };
@@ -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>
);
}
@@ -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>
);
}
@@ -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(),
@@ -23,6 +23,7 @@ import { WorkspacePageContainer, type WorkspacePageWidth } from "../WorkspacePag
import { 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>
+3
View File
@@ -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",
},
},
},
+16 -25
View File
@@ -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">
<RestoreDeviceDefaultsButton
+4 -3
View File
@@ -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, always
show and ignore the selection. Everything else is stored on a server. Choose one environment to