Skip to content

Persist last selected model when opening new threads#1056

Open
WeldFire wants to merge 1 commit intopingdotgg:mainfrom
WeldFire:main
Open

Persist last selected model when opening new threads#1056
WeldFire wants to merge 1 commit intopingdotgg:mainfrom
WeldFire:main

Conversation

@WeldFire
Copy link
Contributor

@WeldFire WeldFire commented Mar 14, 2026

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.

  • Added lastSelectedModel and lastSelectedProvider as persisted global fields in composerDraftStore
  • setModel and setProvider now write these globals whenever a non-null value is explicitly selected
  • useHandleNewThread reads these globals and pre-populates fresh thread drafts before navigating

Existing 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/sessionProvider in ChatView regardless.

Why

Model selection was scoped to individual thread drafts (draftsByThreadId[threadId].model). When a new thread was created its draft started with model: null, causing selectedModel in ChatView to fall back to activeProject.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

  • This demo shows GPT-5.4 selected initially
  • A second thread is opened showing GPT-5.4 again (behavior unchanged)
  • The second thread chat model is changed to GPT-5.2 and a prompt is sent (behavior unchanged)
  • A new third thread is opened and shows GPT-5.2 selected automatically (new behavior)
  • The original thread is opened showing that GPT-5.4 is unchanged (behavior unchanged)

t3code_persistant_model_selection

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Persist last selected model and provider when opening a new thread

  • Adds lastSelectedModel and lastSelectedProvider fields to the composer draft store, persisted alongside thread drafts.
  • When setModel or setProvider is called with a non-null value, the store records it as the last selection; null values leave the persisted selection unchanged.
  • In useHandleNewThread, newly created threads are initialized with the last non-null model and provider from the store.
  • On rehydration, persisted values are normalized via normalizeModelSlug and normalizeProviderKind before being merged into live state.

Macroscope summarized 2813e5a.

@coderabbitai
Copy link

coderabbitai bot commented Mar 14, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b2465da1-3f2c-4f87-a51f-21a0092ba639

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

@github-actions github-actions bot added size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 14, 2026
- 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
@WeldFire WeldFire changed the title Persist last selected model when opening a new thread Persist last selected model when opening new threads Mar 14, 2026
@ianjamesburke
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants