Skip to content

Commit 2828f28

Browse files
fix(web): composer follows an optionless thread instead of the settings default (pingdotgg#16546)
Co-authored-by: Julius Marminge <[email protected]>
1 parent 54a5c51 commit 2828f28

2 files changed

Lines changed: 74 additions & 4 deletions

File tree

‎apps/web/src/composerDraftStore.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,13 +1165,12 @@ export function deriveEffectiveComposerModelState(input: {
11651165
activeSelection.model,
11661166
))
11671167
: baseModel;
1168-
// Options come from the first of the draft, thread and project that has any. Their selections
1169-
// stay with them, so a fallback instance can check which model the options belong to.
1168+
// Draft options win; otherwise an existing thread's options, even none, outrank the project's.
1169+
// Selections stay with them, so a fallback instance can check which model the options belong to.
11701170
const optionSelections =
11711171
[
11721172
input.draft?.modelSelectionByProvider,
1173-
selectionsByInstance(input.threadModelSelection),
1174-
selectionsByInstance(input.projectModelSelection),
1173+
selectionsByInstance(input.threadModelSelection ?? input.projectModelSelection),
11751174
].find((selections) => modelSelectionByProviderToOptions(selections) !== null) ?? null;
11761175
const modelOptions = modelSelectionByProviderToOptions(optionSelections);
11771176

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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,77 @@ describe("instance-scoped model selection", () => {
712712
).toEqual(saved);
713713
});
714714

715+
describe("composer model option precedence", () => {
716+
const instanceId = ProviderInstanceId.make("claudeAgent");
717+
const driver = ProviderDriverKind.make("claudeAgent");
718+
const base = provider({ provider: driver, instanceId, models: ["claude-opus-5-5"] });
719+
const providers = [
720+
{
721+
...base,
722+
models: base.models.map((model) => ({
723+
...model,
724+
capabilities: {
725+
optionDescriptors: [
726+
{
727+
id: "effort",
728+
label: "Effort",
729+
type: "select" as const,
730+
options: [
731+
{ id: "medium", label: "Medium", isDefault: true },
732+
{ id: "high", label: "High" },
733+
],
734+
currentValue: "medium",
735+
},
736+
],
737+
},
738+
})),
739+
},
740+
];
741+
const settingsDefault = createModelSelection(instanceId, "claude-opus-5-5", [
742+
{ id: "effort", value: "high" },
743+
]);
744+
const dispatchedSelection = (
745+
threadModelSelection: ReturnType<typeof createModelSelection> | null,
746+
) => {
747+
const state = deriveEffectiveComposerModelState({
748+
draft: null,
749+
providers,
750+
selectedProvider: driver,
751+
selectedInstanceId: instanceId,
752+
threadModelSelection,
753+
projectModelSelection: settingsDefault,
754+
settings: settingsWithProviderInstances(),
755+
});
756+
const dispatch = getComposerProviderState({
757+
provider: driver,
758+
model: state.selectedModel,
759+
models: providers[0]!.models,
760+
modelOptions: state.modelOptions?.[instanceId],
761+
});
762+
return createModelSelection(
763+
instanceId,
764+
state.selectedModel,
765+
dispatch.modelOptionsForDispatch,
766+
);
767+
};
768+
769+
it("does not inherit settings options for an optionless existing thread", () => {
770+
const threadSelection = createModelSelection(instanceId, "claude-opus-5-5");
771+
expect(dispatchedSelection(threadSelection)).toEqual(threadSelection);
772+
});
773+
774+
it("keeps the options it was saved with", () => {
775+
const threadSelection = createModelSelection(instanceId, "claude-opus-5-5", [
776+
{ id: "effort", value: "medium" },
777+
]);
778+
expect(dispatchedSelection(threadSelection)).toEqual(threadSelection);
779+
});
780+
781+
it("leaves the settings default's options in place before a thread exists", () => {
782+
expect(dispatchedSelection(null)).toEqual(settingsDefault);
783+
});
784+
});
785+
715786
it("keeps a custom-instance draft model while dropping unsupported options", () => {
716787
const instanceId = ProviderInstanceId.make("claude_openrouter");
717788
const driver = ProviderDriverKind.make("claudeAgent");

0 commit comments

Comments
 (0)