Skip to content

Commit 00fc14b

Browse files
only21milclaude
andcommitted
fix(web): composer draft options override only their own provider
A draft that held options for any provider hid the thread's and project's stored options for every provider, so switching providers in the composer dropped the stored effort and other options of the thread's own provider. Draft options now win only for their own instance, and the stored options fill the rest. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 564b2f9 commit 00fc14b

2 files changed

Lines changed: 57 additions & 12 deletions

File tree

‎apps/web/src/composerDraftStore.ts‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,24 +1163,26 @@ export function deriveEffectiveComposerModelState(input: {
11631163
activeSelection.model,
11641164
))
11651165
: baseModel;
1166-
// Options come from the first of the draft, thread and project that has any. Their selections
1167-
// stay with them, so a fallback instance can check which model the options belong to.
1168-
const optionSelections =
1166+
// Draft options win for their own instance; the thread's, else the project's, fill the rest.
1167+
// Each source keeps its selections so a fallback instance can check which model they belong to.
1168+
const optionsFrom = (optionSelections: Partial<Record<string, ModelSelection>> | null) =>
1169+
withFallbackInstanceOptions({
1170+
...input,
1171+
modelOptions: modelSelectionByProviderToOptions(optionSelections),
1172+
optionSelections,
1173+
selectedModel,
1174+
});
1175+
const draftOptions = optionsFrom(input.draft?.modelSelectionByProvider ?? null);
1176+
const storedOptions = optionsFrom(
11691177
[
1170-
input.draft?.modelSelectionByProvider,
11711178
selectionsByInstance(input.threadModelSelection),
11721179
selectionsByInstance(input.projectModelSelection),
1173-
].find((selections) => modelSelectionByProviderToOptions(selections) !== null) ?? null;
1174-
const modelOptions = modelSelectionByProviderToOptions(optionSelections);
1180+
].find((selections) => modelSelectionByProviderToOptions(selections) !== null) ?? null,
1181+
);
11751182

11761183
return {
11771184
selectedModel,
1178-
modelOptions: withFallbackInstanceOptions({
1179-
...input,
1180-
modelOptions,
1181-
optionSelections,
1182-
selectedModel,
1183-
}),
1185+
modelOptions: draftOptions || storedOptions ? { ...storedOptions, ...draftOptions } : null,
11841186
};
11851187
}
11861188

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,49 @@ describe("instance-scoped model selection", () => {
752752
).toEqual(createModelSelection(instanceId, "openai/gpt-5.5"));
753753
});
754754

755+
it("keeps a thread's stored options while the draft holds options for another provider", () => {
756+
const codex = ProviderInstanceId.make("codex");
757+
const claude = ProviderInstanceId.make("claudeAgent");
758+
const providers = [
759+
provider({ instanceId: "codex", models: ["gpt-5.5"] }),
760+
provider({
761+
provider: ProviderDriverKind.make("claudeAgent"),
762+
instanceId: "claudeAgent",
763+
models: ["claude-opus-5-5"],
764+
}),
765+
];
766+
const stored = createModelSelection(codex, "gpt-5.5", [
767+
{ id: "reasoningEffort", value: "high" },
768+
{ id: "fastMode", value: true },
769+
]);
770+
const claudePick = createModelSelection(claude, "claude-opus-5-5", [
771+
{ id: "effort", value: "max" },
772+
]);
773+
const optionsFor = (codexDraft: ReturnType<typeof createModelSelection>) =>
774+
deriveEffectiveComposerModelState({
775+
draft: {
776+
activeProvider: codex,
777+
modelSelectionByProvider: { [claude]: claudePick, [codex]: codexDraft },
778+
},
779+
providers,
780+
selectedProvider: ProviderDriverKind.make("codex"),
781+
selectedInstanceId: codex,
782+
threadModelSelection: stored,
783+
projectModelSelection: null,
784+
settings: DEFAULT_UNIFIED_SETTINGS,
785+
}).modelOptions;
786+
787+
expect(optionsFor(createModelSelection(codex, "gpt-5.5"))).toEqual({
788+
[claude]: claudePick.options,
789+
[codex]: stored.options,
790+
});
791+
const fastOff = createModelSelection(codex, "gpt-5.5", [
792+
{ id: "reasoningEffort", value: "high" },
793+
{ id: "fastMode", value: false },
794+
]);
795+
expect(optionsFor(fastOff)?.[codex]).toEqual(fastOff.options);
796+
});
797+
755798
it("keeps the default instance's draft model off a custom instance of the same driver", () => {
756799
const driver = ProviderDriverKind.make("opencode");
757800
const defaultInstanceId = ProviderInstanceId.make("opencode");

0 commit comments

Comments
 (0)