feat: 聊天界面模型快速切换下拉框 + 切换提示优化#2
Merged
Merged
Conversation
- 新增模型快速切换下拉选择器(圆角按钮 + 图标箭头) - 下拉框显示模型名称 + 供应商标签,模型>8个自动滚动 - 底部管理模型入口,跳转模型管理页面 - 切换提示改为发送时检测,显示模型已从 A 更改为 B - 新增 ChatMessage.modelSwitchNotification 字段 - 输入框获焦点自动关闭弹窗,修复键盘遮挡问题 - 点击模型只切换不跳转,与模型管理页面完全分离 - 修复 ToolCallUtils 测试在 Windows 上的路径问题
Reviewer's GuideImplements a quick model-switch dropdown in the chat composer, propagates selected model state and available models through the UI layer, adds in-chat model switch notification messages on send, decouples quick switch from the model management screen navigation, improves popup dismissal on input focus, and simplifies tool/image handling including a Windows‑safe path normalization fix. Sequence diagram for quick model switch and notification on sendsequenceDiagram
actor User
participant ComposerView
participant MainChatView
participant MainCoordinator
participant ModelRepository
participant ChatUiStateAssembler
participant ChatMessageListView
%% Quick model switch via dropdown
User->>ComposerView: tap modelSelectorButton
ComposerView->>ComposerView: showModelPopup(anchor)
User->>ComposerView: tap modelOptionRow
ComposerView->>MainChatView: Listener.onModelQuickSwitch(modelId)
MainChatView->>MainCoordinator: onModelQuickSwitch(modelId)
MainCoordinator->>MainCoordinator: isStreaming() check
MainCoordinator->>ModelRepository: setSelectedModelId(modelId)
MainCoordinator->>ChatUiStateAssembler: assemble(...)
ChatUiStateAssembler-->>MainCoordinator: ChatUiState(selectedModelId, availableModels)
MainCoordinator-->>ComposerView: render(ChatUiState)
ComposerView->>ComposerView: updateModelSelector()
%% Notification on send after model change
User->>ComposerView: press send
ComposerView->>MainChatView: Listener.onSend(text, attachments)
MainChatView->>MainCoordinator: onSendMessage(text, attachments)
MainCoordinator->>MainCoordinator: currentModelId = selectedModel.getModelId()
MainCoordinator->>MainCoordinator: [lastMessageModelId != "" && != currentModelId]
MainCoordinator->>MainCoordinator: messages.add(ChatMessage.modelSwitchNotice(...))
MainCoordinator->>MainCoordinator: persistCurrentConversation()
MainCoordinator->>MainCoordinator: lastMessageModelId = currentModelId
MainCoordinator-->>ChatMessageListView: render(messages)
ChatMessageListView->>ChatMessageListView: message.isModelSwitchNotification()
ChatMessageListView->>ChatMessageListView: createModelSwitchNotice(text)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
ChatUiStateclass is getting a large number of telescoping constructors with long parameter lists (especially the new one includingselectedModelIdandavailableModels); consider introducing a builder/factory or a value object for the UI config to improve readability and reduce the chance of parameter-order bugs. - User-visible texts like the model switch notice (
"模型已从 A 更改为 B。") and the "管理模型..." label are currently hard-coded in Java; consider moving them into localized string resources (or a centralized constants/strings helper) to keep presentation copy maintainable and easier to translate.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `ChatUiState` class is getting a large number of telescoping constructors with long parameter lists (especially the new one including `selectedModelId` and `availableModels`); consider introducing a builder/factory or a value object for the UI config to improve readability and reduce the chance of parameter-order bugs.
- User-visible texts like the model switch notice (`"模型已从 A 更改为 B。"`) and the "管理模型..." label are currently hard-coded in Java; consider moving them into localized string resources (or a centralized constants/strings helper) to keep presentation copy maintainable and easier to translate.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动内容
新增功能
修复
涉及文件(共 9 个)
ChatMessage.java— 新增 modelSwitchNotification 字段ChatUiState.java— 新增 availableModels / selectedModelIdChatUiStateAssembler.java— 传递模型列表到 UIMainCoordinator.java— 发送时检测 + onModelQuickSwitchModelController.java— 新增 onModelQuickSwitch 接口MainChatView.java— 回调适配ComposerView.java— 模型选择器 UI + 焦点监听ChatMessageListView.java— 模型切换通知渲染ToolCallUtils.java— 修复 Windows 路径问题构建验证
Summary by Sourcery
Add quick model switching and model change notifications to the chat UI, and refine tool handling and path utilities.
New Features:
Bug Fixes:
Enhancements: