The best way to control Claude Code, Codex and more from any computer or phone
fix(web): show mixed automatic defaults across environments (#28005)
James Tatum committed
Oct 31, 2026 at 19:44 UTC
77a728e3a11638e5ff6ca217cc9e73bfaaa870be
3 files changed
+219
-15
apps/web/src/components/settings/ProjectDefaultsSettings.tsx
+36
-13
@@ -7,13 +7,16 @@ import { createModelSelection } from "@t3tools/shared/model";
7
import { resolveProjectSettings } from "@t3tools/shared/projectSettings";
8
import { useNavigate } from "@tanstack/react-router";
9
10
+import { useClientSettings } from "../../hooks/useSettings";
11
import {
12
+ defaultModelSelectionsAreMixed,
13
getCustomModelOptionsByInstance,
14
resolveEffectiveDefaultModelSelection,
15
} from "../../modelSelection";
16
import {
17
providerInstanceEntriesFor,
18
resolveDefaultProviderModelSelection,
19
+ resolveProjectDefaultProviderModelSelection,
20
} from "../../providerInstances";
21
import { useEnvironmentProviders, useEnvironments } from "../../state/environments";
22
import { EMPTY_SERVER_PROVIDERS } from "../../state/server";
@@ -48,8 +51,9 @@ function isWorktreeSubmodules(value: string | null): value is WorktreeSubmodules
51
}
52
53
export function ProjectDefaultsSettings({ category }: { category: ProjectSettingsCategory }) {
51
- const { scope, target, connectedEnvironments } = useSettingsScope();
54
+ const { scope, target, targets, connectedEnvironments } = useSettingsScope();
55
const settings = useScopedSettings();
56
+ const clientSettings = useClientSettings();
57
const updateSettings = useUpdateScopedSettings();
58
const navigate = useNavigate();
59
const { environments } = useEnvironments();
@@ -61,10 +65,10 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
65
(representative?.serverConfig
66
? providersByEnvironment.get(representative.environmentId)
67
: undefined) ?? EMPTY_SERVER_PROVIDERS;
64
- const storedSelection = resolveDefaultProviderModelSelection(
65
- providers,
66
- settings.defaultModelSelection,
67
- );
68
+ const storedSelection =
69
+ settings.defaultModelSelection === null
70
+ ? resolveProjectDefaultProviderModelSelection(providers, settings, target?.projectId ?? null)
71
+ : resolveDefaultProviderModelSelection(providers, settings.defaultModelSelection);
72
const selection = storedSelection
73
? resolveEffectiveDefaultModelSelection(settings, providers, storedSelection)
74
: null;
@@ -76,7 +80,17 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
80
selection?.model,
81
);
82
const activeEntry = entries.find((entry) => entry.instanceId === selection?.instanceId);
79
- const mixedModel = useScopedSettingsMixed(["defaultModelSelection"]);
83
+ const mixedModel = defaultModelSelectionsAreMixed(
84
+ clientSettings,
85
+ targets.map((candidate) => ({
86
+ projectId: candidate.projectId,
87
+ settings: candidate.settings,
88
+ providers: providersByEnvironment.get(candidate.environmentId) ?? EMPTY_SERVER_PROVIDERS,
89
+ })),
90
+ );
91
+ const automaticModel =
92
+ targets.length > 0 &&
93
+ targets.every((candidate) => candidate.settings.defaultModelSelection === null);
94
const mixedFallback = useScopedSettingsMixed(["fallbackModelSelection"]);
95
const fallbackSelection = settings.fallbackModelSelection ?? selection;
96
const fallbackEntry = entries.find((entry) => entry.instanceId === fallbackSelection?.instanceId);
@@ -100,6 +114,9 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
114
: null;
115
116
const modelDisabledReason = useScopedModelDisabledReason(settings, entries);
117
+ const effortDisabledReason = selection
118
+ ? modelDisabledReason(selection.instanceId, selection.model)
119
+ : null;
120
121
const setModel = (value: ModelSelection | null) => {
122
const reason = value ? modelDisabledReason(value.instanceId, value.model) : null;
@@ -120,13 +137,15 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
137
description={
138
isProjectScope
139
? "Model for new threads in this project."
123
- : !unavailable &&
124
- !mixedModel &&
125
- modelSource !== "project" &&
126
- settings.defaultModelSelection === null
140
+ : !unavailable && modelSource !== "project" && automaticModel
141
? "Default model for new threads, selected automatically. Projects can override it."
142
: "Default model for new threads. Projects can override it."
143
}
144
+ status={
145
+ mixedModel
146
+ ? `${automaticModel ? "Automatic defaults differ." : "Defaults differ."} Select one environment or choose a shared model to edit effort.`
147
+ : effortDisabledReason
148
+ }
149
resetAction={
150
settings.defaultModelSelection !== null ? (
151
<SettingResetButton label="default model" onClick={() => setModel(null)} />
@@ -143,7 +162,9 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
162
instanceEntries={entries}
163
modelOptionsByInstance={modelOptions}
164
triggerClassName={SETTINGS_PICKER_TRIGGER_CLASSNAME}
146
- {...(mixedModel ? { triggerLabel: "Mixed" } : {})}
165
+ {...(mixedModel
166
+ ? { triggerLabel: automaticModel ? "Automatic (mixed)" : "Mixed" }
167
+ : {})}
168
getModelDisabledReason={modelDisabledReason}
169
onOpenProviderSetup={(instanceId) => {
170
if (representative)
@@ -156,7 +177,7 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
177
setModel(createModelSelection(instanceId, model))
178
}
179
/>
159
- {!mixedModel ? (
180
+ {!mixedModel && !effortDisabledReason ? (
181
<TraitsPicker
182
provider={activeEntry.driverKind}
183
models={activeEntry.models}
@@ -172,7 +193,9 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
193
) : null}
194
</div>
195
) : (
175
- <span className="text-sm text-muted-foreground">No providers available</span>
196
+ <span className="text-sm text-muted-foreground">
197
+ {mixedModel ? "Mixed" : "No providers available"}
198
+ </span>
199
)
200
}
201
/>
apps/web/src/modelSelection.test.ts
+144
-1
@@ -1,11 +1,17 @@
1
import {
2
ANTIGRAVITY_DEFAULT_MODEL,
3
DEFAULT_TEXT_GENERATION_MODEL,
4
+ DEFAULT_SERVER_SETTINGS,
5
+ ProjectId,
6
ProviderDriverKind,
7
ProviderInstanceId,
8
type ServerProvider,
9
} from "@t3tools/contracts";
8
-import { DEFAULT_UNIFIED_SETTINGS, type UnifiedSettings } from "@t3tools/contracts/settings";
10
+import {
11
+ DEFAULT_CLIENT_SETTINGS,
12
+ DEFAULT_UNIFIED_SETTINGS,
13
+ type UnifiedSettings,
14
+} from "@t3tools/contracts/settings";
15
import { describe, expect, it } from "vite-plus/test";
16
import { createModelSelection } from "@t3tools/shared/model";
17
import { deriveEffectiveComposerModelState } from "./composerDraftStore";
@@ -17,6 +23,7 @@ import {
23
providerInstanceEntriesFor,
24
} from "./providerInstances";
25
import {
26
+ defaultModelSelectionsAreMixed,
27
getAppModelOptionsForInstance,
28
resolveAppModelSelectionForInstance,
29
resolveAppModelSelectionState,
@@ -73,6 +80,142 @@ function settingsWithProviderInstances(): UnifiedSettings {
80
};
81
}
82
83
+describe("scoped default model selections", () => {
84
+ // regression: #27997 equal automatic defaults can resolve to different providers
85
+ it("compares automatic defaults using each environment's models", () => {
86
+ const codex = {
87
+ projectId: null,
88
+ settings: DEFAULT_UNIFIED_SETTINGS,
89
+ providers: [provider({ instanceId: "codex", models: ["gpt-6-astra"] })],
90
+ };
91
+ const claude = {
92
+ projectId: null,
93
+ settings: DEFAULT_UNIFIED_SETTINGS,
94
+ providers: [
95
+ provider({
96
+ instanceId: "claudeAgent",
97
+ provider: ProviderDriverKind.make("claudeAgent"),
98
+ models: ["claude-sonnet-4-6"],
99
+ }),
100
+ ],
101
+ };
102
+
103
+ expect(defaultModelSelectionsAreMixed(DEFAULT_CLIENT_SETTINGS, [codex, claude])).toBe(true);
104
+ expect(defaultModelSelectionsAreMixed(DEFAULT_CLIENT_SETTINGS, [claude, codex])).toBe(true);
105
+ expect(defaultModelSelectionsAreMixed(DEFAULT_CLIENT_SETTINGS, [codex, codex])).toBe(false);
106
+ expect(defaultModelSelectionsAreMixed(DEFAULT_CLIENT_SETTINGS, [claude])).toBe(false);
107
+ expect(defaultModelSelectionsAreMixed(DEFAULT_CLIENT_SETTINGS, [])).toBe(false);
108
+ expect(
109
+ defaultModelSelectionsAreMixed(DEFAULT_CLIENT_SETTINGS, [codex, { ...codex, providers: [] }]),
110
+ ).toBe(true);
111
+ expect(
112
+ defaultModelSelectionsAreMixed(DEFAULT_CLIENT_SETTINGS, [
113
+ codex,
114
+ { ...codex, providers: [provider({ instanceId: "codex", models: ["gpt-6-sol"] })] },
115
+ ]),
116
+ ).toBe(true);
117
+
118
+ const projectId = ProjectId.make("claude-only");
119
+ const project = {
120
+ projectId,
121
+ settings: {
122
+ ...DEFAULT_SERVER_SETTINGS,
123
+ projectSettingsOverrides: {
124
+ [projectId]: {
125
+ providerInstances: { [ProviderInstanceId.make("codex")]: { enabled: false } },
126
+ },
127
+ },
128
+ },
129
+ providers: [...codex.providers, ...claude.providers],
130
+ };
131
+ const remoteProject = { ...claude, projectId: ProjectId.make("remote-project") };
132
+ expect(defaultModelSelectionsAreMixed(DEFAULT_CLIENT_SETTINGS, [project, remoteProject])).toBe(
133
+ false,
134
+ );
135
+ expect(defaultModelSelectionsAreMixed(DEFAULT_CLIENT_SETTINGS, [remoteProject, project])).toBe(
136
+ false,
137
+ );
138
+ expect(
139
+ defaultModelSelectionsAreMixed(DEFAULT_CLIENT_SETTINGS, [
140
+ project,
141
+ { ...project, projectId: ProjectId.make("other-project") },
142
+ ]),
143
+ ).toBe(true);
144
+
145
+ const configured = {
146
+ projectId: null,
147
+ settings: {
148
+ ...DEFAULT_SERVER_SETTINGS,
149
+ providerModelPreferences: {
150
+ [ProviderInstanceId.make("codex")]: {
151
+ hiddenModels: ["gpt-6-astra"],
152
+ modelOrder: [],
153
+ },
154
+ },
155
+ },
156
+ providers: [provider({ instanceId: "codex", models: ["gpt-6-astra", "gpt-6-sol"] })],
157
+ };
158
+ const inherited = { ...configured, settings: DEFAULT_SERVER_SETTINGS };
159
+ expect(defaultModelSelectionsAreMixed(DEFAULT_CLIENT_SETTINGS, [configured, inherited])).toBe(
160
+ true,
161
+ );
162
+ expect(defaultModelSelectionsAreMixed(DEFAULT_CLIENT_SETTINGS, [inherited, configured])).toBe(
163
+ true,
164
+ );
165
+ const clientSettings = {
166
+ ...DEFAULT_CLIENT_SETTINGS,
167
+ providerModelPreferences: configured.settings.providerModelPreferences,
168
+ };
169
+ expect(defaultModelSelectionsAreMixed(clientSettings, [configured, inherited])).toBe(false);
170
+ expect(defaultModelSelectionsAreMixed(clientSettings, [inherited, configured])).toBe(false);
171
+ expect(
172
+ defaultModelSelectionsAreMixed(clientSettings, [
173
+ { ...inherited, settings: { ...DEFAULT_SERVER_SETTINGS, providerModelPreferences: {} } },
174
+ inherited,
175
+ ]),
176
+ ).toBe(true);
177
+ });
178
+
179
+ it("keeps automatic, explicit, and different saved options distinct", () => {
180
+ const providers = [provider({ instanceId: "codex", models: ["gpt-6-astra"] })];
181
+ const selected = {
182
+ projectId: null,
183
+ providers,
184
+ settings: {
185
+ ...DEFAULT_UNIFIED_SETTINGS,
186
+ defaultModelSelection: createModelSelection(
187
+ ProviderInstanceId.make("codex"),
188
+ "gpt-6-astra",
189
+ ),
190
+ },
191
+ };
192
+ expect(
193
+ defaultModelSelectionsAreMixed(DEFAULT_CLIENT_SETTINGS, [selected, { ...selected }]),
194
+ ).toBe(false);
195
+ expect(
196
+ defaultModelSelectionsAreMixed(DEFAULT_CLIENT_SETTINGS, [
197
+ selected,
198
+ { projectId: null, providers, settings: DEFAULT_UNIFIED_SETTINGS },
199
+ ]),
200
+ ).toBe(true);
201
+ expect(
202
+ defaultModelSelectionsAreMixed(DEFAULT_CLIENT_SETTINGS, [
203
+ selected,
204
+ {
205
+ ...selected,
206
+ settings: {
207
+ ...selected.settings,
208
+ defaultModelSelection: {
209
+ ...selected.settings.defaultModelSelection,
210
+ options: [{ id: "reasoningEffort", value: "xhigh" }],
211
+ },
212
+ },
213
+ },
214
+ ]),
215
+ ).toBe(true);
216
+ });
217
+});
218
+
219
describe("instance-scoped model selection", () => {
220
it("keeps custom models on the provider instance that declared them", () => {
221
const providers = [
apps/web/src/modelSelection.ts
+39
-1
@@ -4,9 +4,11 @@ import {
4
DEFAULT_TEXT_GENERATION_MODEL_BY_PROVIDER,
5
defaultInstanceIdForDriver,
6
type ModelSelection,
7
+ type ProjectId,
8
ProviderDriverKind,
9
ProviderInstanceId,
10
type ServerProvider,
11
+ type ServerSettings,
12
} from "@t3tools/contracts";
13
import {
14
type CustomModelDefinition,
@@ -16,8 +18,10 @@ import {
18
resolveSelectableModel,
19
} from "@t3tools/shared/model";
20
import { getComposerProviderState } from "./components/chat/composerProviderState";
19
-import { UnifiedSettings } from "@t3tools/contracts/settings";
21
+import { type ClientSettings, UnifiedSettings } from "@t3tools/contracts/settings";
22
+import { resolveModelPreferences } from "@t3tools/shared/serverSettings";
23
import * as Arr from "effect/Array";
24
+import * as Equal from "effect/Equal";
25
import * as Result from "effect/Result";
26
import {
27
getDefaultServerModel,
@@ -29,6 +33,8 @@ import {
33
type ProviderInstanceEntry,
34
deriveProviderInstanceEntries,
35
NO_PROVIDER_MODEL_SELECTION,
36
+ resolveDefaultProviderModelSelection,
37
+ resolveProjectDefaultProviderModelSelection,
38
} from "./providerInstances";
39
import { sortModelsForProviderInstance } from "./modelOrdering";
40
import { resolveModelShortName } from "@t3tools/client-runtime/provider-clients";
@@ -308,6 +314,38 @@ export function resolveEffectiveDefaultModelSelection(
314
return model === null || model === selection.model ? selection : { ...selection, model };
315
}
316
317
+export function defaultModelSelectionsAreMixed(
318
+ clientSettings: ClientSettings,
319
+ targets: ReadonlyArray<{
320
+ projectId: ProjectId | null;
321
+ settings: ServerSettings;
322
+ providers: ReadonlyArray<ServerProvider>;
323
+ }>,
324
+): boolean {
325
+ const selections = targets.map(({ projectId, settings, providers }) => {
326
+ const stored = settings.defaultModelSelection;
327
+ const selection =
328
+ stored === null
329
+ ? resolveProjectDefaultProviderModelSelection(providers, settings, projectId)
330
+ : resolveDefaultProviderModelSelection(providers, stored);
331
+ return {
332
+ stored,
333
+ effective: selection
334
+ ? resolveEffectiveDefaultModelSelection(
335
+ {
336
+ ...clientSettings,
337
+ ...settings,
338
+ ...resolveModelPreferences(settings, clientSettings),
339
+ },
340
+ providers,
341
+ selection,
342
+ )
343
+ : null,
344
+ };
345
+ });
346
+ return selections.some((selection) => !Equal.equals(selection, selections[0]));
347
+}
348
+
349
export function getCustomModelOptionsByInstance(
350
settings: UnifiedSettings,
351
providers: ReadonlyArray<ServerProvider>,