Skip to content

Commit 242816a

Browse files
feat(web): show settings scope as a sentence at the top of the page (#13139)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent bed0b4c commit 242816a

11 files changed

Lines changed: 383 additions & 346 deletions

‎apps/web/src/components/settings/ProjectDefaultsSettings.tsx‎

Lines changed: 130 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -129,97 +129,151 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
129129
updateSettings({ defaultModelSelection: value });
130130
};
131131

132+
const modelRow = (
133+
<SettingsRow
134+
serverScoped
135+
settingKeys={["defaultModelSelection"]}
136+
mixed={mixedModel}
137+
id="default-model"
138+
title="Model"
139+
description={
140+
isProjectScope
141+
? "Model for new threads in this project."
142+
: "Default model for new threads. Projects can override it."
143+
}
144+
status={
145+
unavailable || mixedModel || modelSource === "project"
146+
? undefined
147+
: settings.defaultModelSelection === null
148+
? "Automatic"
149+
: undefined
150+
}
151+
resetAction={
152+
settings.defaultModelSelection !== null ? (
153+
<SettingResetButton label="default model" onClick={() => setModel(null)} />
154+
) : null
155+
}
156+
control={
157+
selection && activeEntry ? (
158+
<div className="flex min-w-0 flex-wrap items-center justify-end gap-1.5">
159+
<ProviderModelPicker
160+
activeInstanceId={selection.instanceId}
161+
model={selection.model}
162+
lockedProvider={null}
163+
instanceEntries={entries}
164+
modelOptionsByInstance={modelOptions}
165+
triggerVariant="outline"
166+
triggerClassName={SETTINGS_PICKER_TRIGGER_CLASSNAME}
167+
{...(mixedModel ? { triggerLabel: "Mixed" } : {})}
168+
getModelDisabledReason={modelDisabledReason}
169+
onOpenProviderSetup={(instanceId) => {
170+
if (representative)
171+
void navigate({
172+
to: "/settings/providers",
173+
search: { environmentId: representative.environmentId, instanceId },
174+
});
175+
}}
176+
onInstanceModelChange={(instanceId, model) =>
177+
setModel(createModelSelection(instanceId, model))
178+
}
179+
/>
180+
{!mixedModel ? (
181+
<TraitsPicker
182+
provider={activeEntry.driverKind}
183+
models={activeEntry.models}
184+
model={selection.model}
185+
prompt=""
186+
onPromptChange={() => {}}
187+
modelOptions={selection.options ?? []}
188+
allowPromptInjectedEffort={false}
189+
planModeEnabled={settings.planModeEnabled}
190+
triggerVariant="outline"
191+
triggerClassName={SETTINGS_PICKER_TRIGGER_CLASSNAME}
192+
onModelOptionsChange={(options) =>
193+
setModel(createModelSelection(selection.instanceId, selection.model, options))
194+
}
195+
/>
196+
) : null}
197+
</div>
198+
) : (
199+
<span className="text-sm text-muted-foreground">No providers available</span>
200+
)
201+
}
202+
/>
203+
);
204+
const workspaceRow = (
205+
<SettingsRow
206+
serverScoped
207+
settingKeys={["defaultThreadEnvMode"]}
208+
mixed={mixedWorkspace}
209+
id={searchableSetting("new-threads").id}
210+
title="Workspace"
211+
description={
212+
isProjectScope
213+
? "Where new threads in this project start."
214+
: "Where new threads start. Projects and their t3.json can override it."
215+
}
216+
resetAction={
217+
!isProjectScope && settings.defaultThreadEnvMode !== null ? (
218+
<SettingResetButton
219+
label="default workspace"
220+
onClick={() => updateSettings({ defaultThreadEnvMode: null })}
221+
/>
222+
) : null
223+
}
224+
control={
225+
<Select
226+
value={mixedWorkspace ? null : (effective?.defaultThreadEnvMode ?? null)}
227+
onValueChange={(value) => {
228+
if (value === "local" || value === "worktree")
229+
updateSettings({ defaultThreadEnvMode: value });
230+
}}
231+
>
232+
<SelectTrigger size="sm" aria-label="Default workspace">
233+
<SelectValue>
234+
{(value: string | null) =>
235+
value === "local" || value === "worktree"
236+
? resolveEnvModeLabel(value)
237+
: unavailable
238+
? "Unavailable"
239+
: "Mixed"
240+
}
241+
</SelectValue>
242+
</SelectTrigger>
243+
<SelectPopup align="end" alignItemWithTrigger={false}>
244+
<SelectItem value="local">{resolveEnvModeLabel("local")}</SelectItem>
245+
<SelectItem value="worktree">{resolveEnvModeLabel("worktree")}</SelectItem>
246+
</SelectPopup>
247+
</Select>
248+
}
249+
/>
250+
);
251+
132252
return (
133253
<SettingsSection
134254
id={
135-
category === "general"
255+
category === "general" || category === "project"
136256
? "project-defaults"
137257
: category === "integrations"
138258
? "browser-access"
139259
: "source-control-defaults"
140260
}
141261
title={
142-
category === "general"
262+
category === "general" || category === "project"
143263
? "New threads"
144264
: category === "integrations"
145265
? "Browser"
146266
: "Repositories"
147267
}
148268
>
149-
{category === "general" ? (
269+
{category === "project" ? (
150270
<>
151-
<SettingsRow
152-
serverScoped
153-
settingKeys={["defaultModelSelection"]}
154-
mixed={mixedModel}
155-
id="default-model"
156-
title="Model"
157-
description={
158-
isProjectScope
159-
? "Model for new threads in this project."
160-
: "Default model for new threads. Projects can override it."
161-
}
162-
status={
163-
unavailable || mixedModel || modelSource === "project"
164-
? undefined
165-
: settings.defaultModelSelection === null
166-
? "Automatic"
167-
: undefined
168-
}
169-
resetAction={
170-
settings.defaultModelSelection !== null ? (
171-
<SettingResetButton label="default model" onClick={() => setModel(null)} />
172-
) : null
173-
}
174-
control={
175-
selection && activeEntry ? (
176-
<div className="flex min-w-0 flex-wrap items-center justify-end gap-1.5">
177-
<ProviderModelPicker
178-
activeInstanceId={selection.instanceId}
179-
model={selection.model}
180-
lockedProvider={null}
181-
instanceEntries={entries}
182-
modelOptionsByInstance={modelOptions}
183-
triggerVariant="outline"
184-
triggerClassName={SETTINGS_PICKER_TRIGGER_CLASSNAME}
185-
{...(mixedModel ? { triggerLabel: "Mixed" } : {})}
186-
getModelDisabledReason={modelDisabledReason}
187-
onOpenProviderSetup={(instanceId) => {
188-
if (representative)
189-
void navigate({
190-
to: "/settings/providers",
191-
search: { environmentId: representative.environmentId, instanceId },
192-
});
193-
}}
194-
onInstanceModelChange={(instanceId, model) =>
195-
setModel(createModelSelection(instanceId, model))
196-
}
197-
/>
198-
{!mixedModel ? (
199-
<TraitsPicker
200-
provider={activeEntry.driverKind}
201-
models={activeEntry.models}
202-
model={selection.model}
203-
prompt=""
204-
onPromptChange={() => {}}
205-
modelOptions={selection.options ?? []}
206-
allowPromptInjectedEffort={false}
207-
planModeEnabled={settings.planModeEnabled}
208-
triggerVariant="outline"
209-
triggerClassName={SETTINGS_PICKER_TRIGGER_CLASSNAME}
210-
onModelOptionsChange={(options) =>
211-
setModel(
212-
createModelSelection(selection.instanceId, selection.model, options),
213-
)
214-
}
215-
/>
216-
) : null}
217-
</div>
218-
) : (
219-
<span className="text-sm text-muted-foreground">No providers available</span>
220-
)
221-
}
222-
/>
271+
{modelRow}
272+
{workspaceRow}
273+
</>
274+
) : category === "general" ? (
275+
<>
276+
{modelRow}
223277
<SettingsRow
224278
serverScoped
225279
settingKeys={["defaultRuntimeMode"]}
@@ -281,51 +335,7 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
281335
</Select>
282336
}
283337
/>
284-
<SettingsRow
285-
serverScoped
286-
settingKeys={["defaultThreadEnvMode"]}
287-
mixed={mixedWorkspace}
288-
id={searchableSetting("new-threads").id}
289-
title="Workspace"
290-
description={
291-
isProjectScope
292-
? "Where new threads in this project start."
293-
: "Where new threads start. Projects and their t3.json can override it."
294-
}
295-
resetAction={
296-
!isProjectScope && settings.defaultThreadEnvMode !== null ? (
297-
<SettingResetButton
298-
label="default workspace"
299-
onClick={() => updateSettings({ defaultThreadEnvMode: null })}
300-
/>
301-
) : null
302-
}
303-
control={
304-
<Select
305-
value={mixedWorkspace ? null : (effective?.defaultThreadEnvMode ?? null)}
306-
onValueChange={(value) => {
307-
if (value === "local" || value === "worktree")
308-
updateSettings({ defaultThreadEnvMode: value });
309-
}}
310-
>
311-
<SelectTrigger size="sm" aria-label="Default workspace">
312-
<SelectValue>
313-
{(value: string | null) =>
314-
value === "local" || value === "worktree"
315-
? resolveEnvModeLabel(value)
316-
: unavailable
317-
? "Unavailable"
318-
: "Mixed"
319-
}
320-
</SelectValue>
321-
</SelectTrigger>
322-
<SelectPopup align="end" alignItemWithTrigger={false}>
323-
<SelectItem value="local">{resolveEnvModeLabel("local")}</SelectItem>
324-
<SelectItem value="worktree">{resolveEnvModeLabel("worktree")}</SelectItem>
325-
</SelectPopup>
326-
</Select>
327-
}
328-
/>
338+
{workspaceRow}
329339
<SettingsRow
330340
serverScoped
331341
settingKeys={["worktreeSubmodules"]}

‎apps/web/src/components/settings/ProjectSettingsPanel.tsx‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { AsyncResult } from "effect/unstable/reactivity";
1010
import { type EnvironmentId, type ProjectIconOverride } from "@t3tools/contracts";
1111
import { useLocation, useNavigate } from "@tanstack/react-router";
1212
import * as Cause from "effect/Cause";
13-
import { Trash2Icon } from "lucide-react";
13+
import { InfoIcon, Trash2Icon } from "lucide-react";
1414
import { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";
1515

1616
import { useComposerDraftStore } from "../../composerDraftStore";
@@ -25,6 +25,7 @@ import { useThreadShells } from "../../state/entities";
2525
import { projectEnvironment } from "../../state/projects";
2626
import { useAtomCommand } from "../../state/use-atom-command";
2727
import { ProjectFavicon } from "../ProjectFavicon";
28+
import { Alert, AlertDescription } from "../ui/alert";
2829
import { Button } from "../ui/button";
2930
import { Input } from "../ui/input";
3031
import { stackedThreadToast, toastManager } from "../ui/toast";
@@ -39,6 +40,7 @@ import {
3940
ProjectFaviconPickerDialog,
4041
} from "./ProjectFaviconPickerDialog";
4142
import { ProjectActionsSettings } from "./ProjectActionsSettings";
43+
import { ProjectDefaultsSettings } from "./ProjectDefaultsSettings";
4244
import { projectGroupTitleNeedsUpdate } from "./ProjectSettingsPanel.logic";
4345
import { useSettingsProjectGroups } from "./useSettingsProjectGroups";
4446

@@ -52,7 +54,8 @@ function memberKey(member: { environmentId: string; id: string }): string {
5254
return `${member.environmentId}:${member.id}`;
5355
}
5456

55-
export type ProjectSettingsCategory = "general" | "integrations" | "source-control";
57+
/** `project` is the Projects page shortcut: the new-thread defaults people change most. */
58+
export type ProjectSettingsCategory = "general" | "integrations" | "source-control" | "project";
5659

5760
export function ProjectSettingsPanel({
5861
projectKey,
@@ -406,6 +409,12 @@ function ProjectDetail({
406409
return (
407410
<>
408411
<SettingsPageContainer className="gap-6">
412+
<Alert variant="info">
413+
<InfoIcon aria-hidden />
414+
<AlertDescription>
415+
Can't find a setting? Keep this project picked above and hop to any other settings page.
416+
</AlertDescription>
417+
</Alert>
409418
<SettingsSection id="project-overview" title="Project" hideTitle>
410419
<SettingsRow
411420
title="Name"
@@ -480,6 +489,7 @@ function ProjectDetail({
480489
}
481490
/>
482491
</SettingsSection>
492+
<ProjectDefaultsSettings category="project" />
483493
<ProjectActionsSettings />
484494
{hasMultipleCheckouts ? checkoutChoices : null}
485495
<SettingsSection title="Danger">

‎apps/web/src/components/settings/ProjectsSettings.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { EnvironmentId } from "@t3tools/contracts";
33
import { ProjectSettingsPanel } from "./ProjectSettingsPanel";
44
import { useSettingsScope } from "./SettingsScopeContext";
55
import { SettingsScopeNotice } from "./SettingsScopeNotice";
6+
import { SettingsPageContainer } from "./settingsLayout";
67

78
/** Project identity and checkout management for the selected project. */
89
export function ProjectsSettings() {
@@ -22,7 +23,9 @@ export function ProjectsSettings() {
2223
checkoutKey={value.checkout ?? null}
2324
/>
2425
) : scope.kind === "unavailable" ? (
25-
<p className="p-8 text-sm text-muted-foreground">{scope.message}</p>
26+
<SettingsPageContainer>
27+
<p className="text-sm text-muted-foreground">{scope.message}</p>
28+
</SettingsPageContainer>
2629
) : (
2730
<SettingsScopeNotice target="project">
2831
Choose a project to manage its name, icon, checkouts and actions.

‎apps/web/src/components/settings/ProviderSettingsPanel.environment.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ vi.mock("./settingsLayout", async (importOriginal) => {
5858
};
5959
});
6060

61+
vi.mock("./SettingsScopeSentence", () => ({ SettingsScopeSentence: () => null }));
6162
vi.mock("react/compiler-runtime", async () => {
6263
const { reactHookHarness } = await import("../../test/reactHookHarness");
6364
return { c: reactHookHarness.useMemoCache };

0 commit comments

Comments
 (0)