The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 00:30 UTC
fix(web): settings shows the model a hidden default falls back to (#13479)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
ValeraZSD committed
Oct 20, 2026 at 00:40 UTC
e3e89f4b2ec21020f380fdba4a79207e3d5fcd56
3 files changed
+95
-2
apps/web/src/components/settings/ProjectDefaultsSettings.tsx
+11
-2
@@ -9,7 +9,10 @@ import { resolveProjectSettings } from "@t3tools/shared/projectSettings";
9
import { useNavigate } from "@tanstack/react-router";
10
11
import { mergeEnvironmentSettings } from "../../hooks/useSettings";
12
-import { getCustomModelOptionsByInstance } from "../../modelSelection";
12
+import {
13
+ getCustomModelOptionsByInstance,
14
+ resolveEffectiveDefaultModelSelection,
15
+} from "../../modelSelection";
16
import {
17
applyProviderInstanceSettings,
18
deriveProviderInstanceEntries,
@@ -61,7 +64,13 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
64
(representative?.serverConfig
65
? providersByEnvironment.get(representative.environmentId)
66
: undefined) ?? EMPTY_SERVER_PROVIDERS;
64
- const selection = resolveDefaultProviderModelSelection(providers, settings.defaultModelSelection);
67
+ const storedSelection = resolveDefaultProviderModelSelection(
68
+ providers,
69
+ settings.defaultModelSelection,
70
+ );
71
+ const selection = storedSelection
72
+ ? resolveEffectiveDefaultModelSelection(settings, providers, storedSelection)
73
+ : null;
74
const entries = sortProviderInstanceEntries(
75
applyProviderInstanceSettings(
76
deriveProviderInstanceEntries(providers),
apps/web/src/modelSelection.test.ts
+68
@@ -16,6 +16,7 @@ import {
16
getAppModelOptionsForInstance,
17
resolveAppModelSelectionForInstance,
18
resolveAppModelSelectionState,
19
+ resolveEffectiveDefaultModelSelection,
20
} from "./modelSelection";
21
22
function provider(input: {
@@ -953,3 +954,70 @@ describe("resolveAppModelSelectionState with the opencode plan agent", () => {
954
);
955
});
956
});
957
+
958
+describe("default model settings and new-thread composer parity", () => {
959
+ it.each([
960
+ ["hidden", "claudeAgent", "claude-opus-5", "claude-opus-5-5", "medium"],
961
+ ["visible", "claudeAgent", "claude-opus-5", "claude-opus-5", "max"],
962
+ ["unavailable", "opencode", "openrouter/kimi-k3", "openrouter/kimi-k3", null],
963
+ ] as const)(
964
+ "resolves the %s default and its traits",
965
+ (visibility, kind, model, expectedModel, effort) => {
966
+ const driver = ProviderDriverKind.make(kind);
967
+ const instanceId = ProviderInstanceId.make(`${kind}_work`);
968
+ const snapshot = provider({ provider: driver, instanceId });
969
+ const models: ServerProvider["models"] = ["claude-opus-5-5", "claude-opus-5"].map(
970
+ (slug, index) => ({
971
+ slug,
972
+ name: slug,
973
+ isCustom: false,
974
+ capabilities: {
975
+ optionDescriptors: [
976
+ {
977
+ id: "effort",
978
+ label: "Effort",
979
+ type: "select",
980
+ options: (index === 0 ? ["medium", "high"] : ["high", "max"]).map(
981
+ (id, optionIndex) => ({ id, label: id, isDefault: optionIndex === 0 }),
982
+ ),
983
+ },
984
+ ],
985
+ },
986
+ }),
987
+ );
988
+ const providers = [{ ...snapshot, models }];
989
+ const stored = createModelSelection(instanceId, model, [{ id: "effort", value: "max" }]);
990
+ const settings: UnifiedSettings = {
991
+ ...settingsWithProviderInstances(),
992
+ providerModelPreferences: {
993
+ [instanceId]: { hiddenModels: visibility === "hidden" ? [model] : [], modelOrder: [] },
994
+ },
995
+ };
996
+ // ChatView builds the local draft with the project default as its thread selection.
997
+ const composer = deriveEffectiveComposerModelState({
998
+ draft: null,
999
+ providers,
1000
+ selectedProvider: driver,
1001
+ selectedInstanceId: instanceId,
1002
+ threadModelSelection: stored,
1003
+ projectModelSelection: stored,
1004
+ settings,
1005
+ });
1006
+ const effective = resolveEffectiveDefaultModelSelection(settings, providers, stored);
1007
+ const traits = (model: string, modelOptions: typeof stored.options) =>
1008
+ getComposerProviderState({
1009
+ provider: driver,
1010
+ model,
1011
+ models,
1012
+ modelOptions,
1013
+ planModeEnabled: settings.planModeEnabled,
1014
+ });
1015
+ const composerTraits = traits(composer.selectedModel, composer.modelOptions?.[instanceId]);
1016
+
1017
+ expect(composer.selectedModel).toBe(expectedModel);
1018
+ expect(traits(effective.model, effective.options)).toEqual(composerTraits);
1019
+ expect(effective).toEqual({ ...stored, model: composer.selectedModel });
1020
+ expect(composerTraits.promptEffort).toBe(effort);
1021
+ },
1022
+ );
1023
+});
apps/web/src/modelSelection.ts
+16
@@ -281,6 +281,22 @@ export function resolveAppModelSelectionForInstance(
281
return options.find((option) => option.isDefault)?.slug ?? options[0]?.slug ?? null;
282
}
283
284
+// New drafts carry the stored selection; capabilities resolve its raw options later.
285
+export function resolveEffectiveDefaultModelSelection(
286
+ settings: UnifiedSettings,
287
+ providers: ReadonlyArray<ServerProvider>,
288
+ selection: ModelSelection,
289
+): ModelSelection {
290
+ const model = resolveAppModelSelectionForInstance(
291
+ selection.instanceId,
292
+ settings,
293
+ providers,
294
+ selection.model,
295
+ { preserveUnavailableSelection: true },
296
+ );
297
+ return model === null || model === selection.model ? selection : { ...selection, model };
298
+}
299
+
300
export function getCustomModelOptionsByInstance(
301
settings: UnifiedSettings,
302
providers: ReadonlyArray<ServerProvider>,