Persist last selected model when opening new threads#1056
Persist last selected model when opening new threads#1056WeldFire wants to merge 1 commit intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can use oxc to improve the quality of JavaScript and TypeScript code reviews.Add a configuration file to your project to customize how CodeRabbit runs oxc. |
- Track `lastSelectedModel` and `lastSelectedProvider` globally in `composerDraftStore` - Update `setModel`/`setProvider` to write these globals on explicit non-null selection - Pre-populate new thread drafts with the last selected model/provider in `useHandleNewThread`Persist last selected model when opening a new thread
|
Just spent 10 minutes writing this feature request lol. nice work what do you think about add a setting in the model card for setting the default model when creating new chats. With a drop down containing "last used" and a list of providers/models |
Thank you! And that's an interesting idea! The repos owners desire to keep changes as small and targeted as possible. If this PR gets approved and merged, then I can work on creating this setting with a more targeted change. |
What Changed
When a user selects a model in any thread and then opens a new thread, the new thread now pre-populates with that last selected model instead of resetting to the project/global default.
lastSelectedModelandlastSelectedProvideras persisted global fields incomposerDraftStoresetModelandsetProvidernow write these globals whenever a non-null value is explicitly selecteduseHandleNewThreadreads these globals and pre-populates fresh thread drafts before navigatingExisting threads are unaffected as the new values are only written to freshly generated thread IDs that have no prior draft state. Started threads have their model locked via
lockedProvider/sessionProviderinChatViewregardless.Why
Model selection was scoped to individual thread drafts (
draftsByThreadId[threadId].model). When a new thread was created its draft started withmodel: null, causingselectedModelinChatViewto fall back toactiveProject.model ?? getDefaultModel()silently discarding the user's recent choice. This fix introduces a lightweight "sticky last selection" that survives navigation and page reloads via localStorage, without requiring a new user-facing setting.UI Changes
No UI changes. The model picker component is unchanged, it just displays the pre-populated value on new threads.
Demo
GPT-5.4again (behavior unchanged)GPT-5.2and a prompt is sent (behavior unchanged)GPT-5.2selected automatically (new behavior)GPT-5.4is unchanged (behavior unchanged)Checklist
Note
Persist last selected model and provider when opening a new thread
lastSelectedModelandlastSelectedProviderfields to the composer draft store, persisted alongside thread drafts.setModelorsetProvideris called with a non-null value, the store records it as the last selection; null values leave the persisted selection unchanged.useHandleNewThread, newly created threads are initialized with the last non-null model and provider from the store.normalizeModelSlugandnormalizeProviderKindbefore being merged into live state.Macroscope summarized 2813e5a.