Persist first sticky model snapshot from provider options

- Keep sticky selection in sync when provider options change
- Add regression test for creating the initial sticky snapshot
This commit is contained in:
Julius Marminge committed 2026-03-24 12:08:58 -07:00
1 parent 8cad01a57b
commit 71ff626e3e
2 files changed
+22 -3

No files matched your search

+21
View File
@@ -738,6 +738,27 @@ describe("composerDraftStore modelSelection", () => {
);
});
it("creates the first sticky snapshot from provider option changes", () => {
const store = useComposerDraftStore.getState();
store.setModelSelection(threadId, modelSelection("codex", "gpt-5.4"));
store.setProviderModelOptions(
threadId,
"codex",
{
fastMode: true,
},
{ persistSticky: true },
);
expect(useComposerDraftStore.getState().stickyModelSelection).toEqual(
modelSelection("codex", "gpt-5.4", {
fastMode: true,
}),
);
});
it("updates only the draft when sticky persistence is disabled", () => {
const store = useComposerDraftStore.getState();
+1 -3
View File
@@ -1327,9 +1327,7 @@ export const useComposerDraftStore = create<ComposerDraftStoreState>()(
...(nextOptions ? { options: nextOptions } : {}),
};
const nextStickyModelSelection =
options?.persistSticky === true &&
state.stickyModelSelection?.provider === normalizedProvider &&
nextModelSelection !== null
options?.persistSticky === true && nextModelSelection !== null
? nextModelSelection
: state.stickyModelSelection;