Skip to content

Commit 1d77552

Browse files
committed
fix(web): do not let kind-keyed draft options outrank sticky
When the selected instance already has a draft entry without options, skip legacy kind-key option fallback so sticky/thread options can apply — matching the model path which only falls back when the instance entry is missing.
1 parent cb97299 commit 1d77552

2 files changed

Lines changed: 59 additions & 1 deletion

File tree

‎apps/web/src/composerDraftStore.test.ts‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,58 @@ describe("composerDraftStore modelSelection", () => {
12621262
expect(derived.modelOptions?.[String(CODEX_INSTANCE)]).toBeUndefined();
12631263
});
12641264

1265+
it("does not let kind-keyed draft options outrank sticky when instance entry has no options", () => {
1266+
// Selected custom Codex instance has a model-only draft entry; kind-keyed
1267+
// codex draft holds high effort. Sticky for the custom instance is low —
1268+
// sticky must win (same rule as the model path: legacy only when entry missing).
1269+
const derived = deriveEffectiveComposerModelState({
1270+
draft: {
1271+
modelSelectionByProvider: {
1272+
[CODEX_SECONDARY_INSTANCE]: modelSelection(CODEX_DRIVER, "gpt-5.4"),
1273+
[CODEX_INSTANCE]: modelSelection(CODEX_DRIVER, "gpt-5.3-codex", {
1274+
reasoningEffort: "high",
1275+
}),
1276+
},
1277+
activeProvider: null,
1278+
},
1279+
providers: [
1280+
{
1281+
instanceId: CODEX_SECONDARY_INSTANCE,
1282+
driver: CODEX_DRIVER,
1283+
enabled: true,
1284+
isAvailable: true,
1285+
models: [
1286+
{
1287+
slug: "gpt-5.4",
1288+
name: "GPT-5.4",
1289+
isCustom: false,
1290+
capabilities: { optionDescriptors: [] },
1291+
},
1292+
],
1293+
} as never,
1294+
],
1295+
selectedProvider: CODEX_DRIVER,
1296+
selectedInstanceId: CODEX_SECONDARY_INSTANCE,
1297+
threadModelSelection: null,
1298+
projectModelSelection: null,
1299+
stickyModelSelectionByProvider: {
1300+
[CODEX_SECONDARY_INSTANCE]: modelSelection(CODEX_DRIVER, "gpt-5.4", {
1301+
reasoningEffort: "low",
1302+
}),
1303+
},
1304+
settings: {
1305+
providers: {
1306+
codex: { customModels: [] },
1307+
},
1308+
providerInstances: {},
1309+
models: {},
1310+
} as never,
1311+
});
1312+
expect(derived.modelOptions?.[String(CODEX_SECONDARY_INSTANCE)]).toEqual(
1313+
toSelections({ reasoningEffort: "low" }),
1314+
);
1315+
});
1316+
12651317
it("uses sticky options only and keeps thread model when draft is empty", () => {
12661318
const derived = deriveEffectiveComposerModelState({
12671319
draft: {

‎apps/web/src/composerDraftStore.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,13 +1042,19 @@ export function deriveEffectiveComposerModelState(input: {
10421042
// must not short-circuit sticky/thread/project for the current selection.
10431043
// Sticky (and legacy kind-keyed draft hits) are re-keyed under
10441044
// stickyInstanceKey so custom instances resolve options.
1045+
//
1046+
// Mirror the model path: only fall back to the kind-keyed draft when the
1047+
// selected instance has *no* draft entry. An entry that exists without
1048+
// options must not pull sibling/kind options ahead of sticky.
10451049
const legacyProviderKey = ProviderInstanceId.make(input.selectedProvider);
1050+
const hasInstanceDraftEntry =
1051+
input.draft?.modelSelectionByProvider?.[stickyInstanceKey] !== undefined;
10461052
const draftOptionsAtInstance = optionsForInstance(
10471053
input.draft?.modelSelectionByProvider,
10481054
stickyInstanceKey,
10491055
);
10501056
const legacyDraftOptions =
1051-
String(stickyInstanceKey) !== String(legacyProviderKey)
1057+
!hasInstanceDraftEntry && String(stickyInstanceKey) !== String(legacyProviderKey)
10521058
? optionsForInstance(input.draft?.modelSelectionByProvider, legacyProviderKey)?.[
10531059
String(legacyProviderKey)
10541060
]

0 commit comments

Comments
 (0)