Skip to content

fix: stabilize model selection across session boundaries#298

Open
Autumn-Whisper wants to merge 1 commit intoop7418:mainfrom
Autumn-Whisper:fix/model-selection-stability
Open

fix: stabilize model selection across session boundaries#298
Autumn-Whisper wants to merge 1 commit intoop7418:mainfrom
Autumn-Whisper:fix/model-selection-stability

Conversation

@Autumn-Whisper
Copy link

Summary

  • NewChatPage: 从 localStorage 读取初始 model/provider,而非硬编码 'sonnet'/'',确保新聊天继承用户上次的选择
  • ChatView + NewChatPage: 模型切换时同步写入 localStorage,确保跨会话一致性
  • useProviderModels: 新增 loaded 标志,区分"尚未加载"和"Provider 无模型"
  • MessageInput: 自动纠正逻辑仅在模型列表加载完成后执行,防止异步窗口期内模型被错误重置

Root Cause

模型选择状态在 3 个入口(NewChatPage、ChatView、ChatListPanel)之间缺乏统一的 localStorage 同步机制,加上 useProviderModels 异步加载期间自动纠正逻辑过早触发,导致用户选择的模型被意外重置。

Test plan

  • 切换模型后新建聊天,确认模型不会跳回 Sonnet
  • 在现有会话中切换模型,然后从侧边栏新建聊天,确认模型一致
  • 快速切换 Provider,确认模型不会在加载过程中闪烁/重置
  • npm run test 通过(419 tests pass)

🤖 Generated with Claude Code

- NewChatPage: read initial model/provider from localStorage instead of
  hardcoded 'sonnet'/'' so new chats inherit the last selection
- ChatView: persist model changes to localStorage in handleProviderModelChange
  so mid-session switches carry over to new chats
- NewChatPage: persist model changes to localStorage in onProviderModelChange
- MessageInput: gate auto-correction effect on modelsLoaded flag to prevent
  premature model reset while provider models are still being fetched
- useProviderModels: add loaded flag to distinguish "not fetched yet" from
  "provider has no models"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 16, 2026

@Autumn-Whisper is attempting to deploy a commit to the op7418's projects Team on Vercel.

A member of the Team first needs to authorize it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant