Skip to content

Commit 85e80d4

Browse files
fix(shared): a custom project default model stays selected when listed as hidden
Clients never hide custom models, even when their slug is in hiddenModels, so the resolver exempts them too. AI-assisted; verified with the tests and tools listed above.
1 parent 3ed86b5 commit 85e80d4

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

‎packages/shared/src/projectSettings.test.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,18 @@ describe("resolveProjectSettings", () => {
121121

122122
// regression: #17556 a hidden project default silently became the catalog's first model
123123
it.each([
124-
["hidden", ["gpt-5.6-terra", "gpt-5.6-sol"], "gpt-6.1-sol", "environment"],
125-
["visible", ["gpt-5.6-terra"], "gpt-5.6-sol", "project"],
124+
["hidden", ["gpt-5.6-terra", "gpt-5.6-sol"], [], "gpt-6.1-sol", "environment"],
125+
["visible", ["gpt-5.6-terra"], [], "gpt-5.6-sol", "project"],
126+
["custom", ["gpt-5.6-sol"], ["gpt-5.6-sol"], "gpt-5.6-sol", "project"],
126127
] as const)(
127128
"resolves a %s project default model against the environment default",
128-
(_visibility, hiddenModels, expectedModel, expectedSource) => {
129+
(_visibility, hiddenModels, customModels, expectedModel, expectedSource) => {
129130
const codex = ProviderInstanceId.make("codex");
130131
const settings = applyServerSettingsPatch(DEFAULT_SERVER_SETTINGS, {
131132
defaultModelSelection: createModelSelection(codex, "gpt-6.1-sol"),
133+
providerInstances: {
134+
[codex]: { driver: ProviderDriverKind.make("codex"), config: { customModels } },
135+
},
132136
providerModelPreferences: { [codex]: { hiddenModels, modelOrder: [] } },
133137
projectSettingsOverrides: {
134138
[projectId]: { defaultModelSelection: createModelSelection(codex, "gpt-5.6-sol") },

‎packages/shared/src/projectSettings.ts‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
type ThreadEnvMode,
1515
type WorktreeCleanupRules,
1616
} from "@t3tools/contracts";
17+
import { readCustomModelEntries } from "./model.ts";
1718
import { normalizeProjectPathForComparison } from "./path.ts";
1819
import { fallbackTextGenerationModelSelection } from "./serverSettings.ts";
1920

@@ -150,14 +151,18 @@ function resolveProjectOverrides(
150151
}
151152
// Clients resolve a hidden model to the catalog's first visible one, so a
152153
// hidden project default would silently pick a model nobody chose.
153-
if (
154-
key === "defaultModelSelection" &&
155-
value !== null &&
156-
settings.providerModelPreferences?.[
157-
(value as ModelSelection).instanceId
158-
]?.hiddenModels.includes((value as ModelSelection).model)
159-
) {
160-
continue;
154+
// Custom models stay visible even when listed as hidden, as in the clients.
155+
if (key === "defaultModelSelection" && value !== null) {
156+
const { instanceId, model } = value as ModelSelection;
157+
const config = settings.providerInstances[instanceId]?.config as
158+
| { customModels?: unknown }
159+
| undefined;
160+
if (
161+
settings.providerModelPreferences?.[instanceId]?.hiddenModels.includes(model) &&
162+
!readCustomModelEntries(config?.customModels).some((entry) => entry.slug === model)
163+
) {
164+
continue;
165+
}
161166
}
162167
effective[key] = value;
163168
sources[key] = "project";

0 commit comments

Comments
 (0)