From 71ff626e3e8e936504066d8eca34a14ae13a9dea Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 24 Mar 2026 12:08:58 -0700 Subject: [PATCH] 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 --- apps/web/src/composerDraftStore.test.ts | 21 +++++++++++++++++++++ apps/web/src/composerDraftStore.ts | 4 +--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/apps/web/src/composerDraftStore.test.ts b/apps/web/src/composerDraftStore.test.ts index d1c0ac1f59..68925a8988 100644 --- a/apps/web/src/composerDraftStore.test.ts +++ b/apps/web/src/composerDraftStore.test.ts @@ -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(); diff --git a/apps/web/src/composerDraftStore.ts b/apps/web/src/composerDraftStore.ts index d70dcda619..587129fa08 100644 --- a/apps/web/src/composerDraftStore.ts +++ b/apps/web/src/composerDraftStore.ts @@ -1327,9 +1327,7 @@ export const useComposerDraftStore = create()( ...(nextOptions ? { options: nextOptions } : {}), }; const nextStickyModelSelection = - options?.persistSticky === true && - state.stickyModelSelection?.provider === normalizedProvider && - nextModelSelection !== null + options?.persistSticky === true && nextModelSelection !== null ? nextModelSelection : state.stickyModelSelection;