Skip to content

Commit ef56e48

Browse files
fix(web): trait changes on another model keep the sticky model's traits
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 8525000 commit ef56e48

2 files changed

Lines changed: 47 additions & 8 deletions

File tree

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,38 @@ describe("composerDraftStore per-model sticky options", () => {
16731673
);
16741674
});
16751675

1676+
it("keeps the sticky model's own traits when traits change on another shown model", () => {
1677+
const store = useComposerDraftStore.getState();
1678+
store.setStickyModelSelection(
1679+
modelSelection(CODEX_DRIVER, "gpt-5.3-codex", { reasoningEffort: "xhigh" }),
1680+
);
1681+
1682+
store.setProviderModelOptions(
1683+
threadRef,
1684+
CODEX_DRIVER,
1685+
toSelections({ reasoningEffort: "low" }),
1686+
{ instanceId: CODEX_INSTANCE, model: "gpt-5.4", persistSticky: true },
1687+
);
1688+
expect(useComposerDraftStore.getState().stickyModelSelectionByProvider[CODEX_INSTANCE]).toEqual(
1689+
modelSelection(CODEX_DRIVER, "gpt-5.3-codex", { reasoningEffort: "xhigh" }),
1690+
);
1691+
expect(
1692+
useComposerDraftStore.getState().stickyOptionsByModelByProvider[CODEX_INSTANCE]?.["gpt-5.4"],
1693+
).toEqual(toSelections({ reasoningEffort: "low" }));
1694+
1695+
store.setProviderModelOptions(threadRef, CODEX_DRIVER, null, {
1696+
instanceId: CODEX_INSTANCE,
1697+
model: "gpt-5.4",
1698+
persistSticky: true,
1699+
});
1700+
1701+
const state = useComposerDraftStore.getState();
1702+
expect(state.stickyModelSelectionByProvider[CODEX_INSTANCE]).toEqual(
1703+
modelSelection(CODEX_DRIVER, "gpt-5.3-codex", { reasoningEffort: "xhigh" }),
1704+
);
1705+
expect(state.stickyOptionsByModelByProvider[CODEX_INSTANCE]?.["gpt-5.4"]).toBeUndefined();
1706+
});
1707+
16761708
it("seeds per-model memory from a persisted sticky selection on upgrade", () => {
16771709
const persistApi = useComposerDraftStore.persist as unknown as {
16781710
getOptions: () => {

‎apps/web/src/composerDraftStore.ts‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3077,22 +3077,29 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
30773077
createModelSelection(instanceKey, fallbackModel);
30783078
const rememberedModel =
30793079
normalizeModelSlug(options?.model, normalizedProvider) ?? stickyBase.model;
3080+
// Traits for another shown model belong in per-model memory only;
3081+
// the sticky selection keeps its own model's traits.
3082+
const appliesToSticky = rememberedModel === stickyBase.model;
30803083
if (providerOpts) {
3081-
nextStickyMap[instanceKey] = createModelSelection(
3082-
instanceKey,
3083-
stickyBase.model,
3084-
providerOpts,
3085-
);
3084+
if (appliesToSticky) {
3085+
nextStickyMap[instanceKey] = createModelSelection(
3086+
instanceKey,
3087+
stickyBase.model,
3088+
providerOpts,
3089+
);
3090+
}
30863091
nextOptionsByModel = {
30873092
...state.stickyOptionsByModelByProvider,
30883093
[instanceKey]: {
30893094
...state.stickyOptionsByModelByProvider[instanceKey],
30903095
[rememberedModel]: providerOpts,
30913096
},
30923097
};
3093-
} else if ((stickyBase.options?.length ?? 0) > 0) {
3094-
const { options: _, ...rest } = stickyBase;
3095-
nextStickyMap[instanceKey] = rest as ModelSelection;
3098+
} else {
3099+
if (appliesToSticky && (stickyBase.options?.length ?? 0) > 0) {
3100+
const { options: _, ...rest } = stickyBase;
3101+
nextStickyMap[instanceKey] = rest as ModelSelection;
3102+
}
30963103
const rememberedByModel = {
30973104
...state.stickyOptionsByModelByProvider[instanceKey],
30983105
};

0 commit comments

Comments
 (0)