Repository navigation
fix(chatbot): drop the CLI default model from the chat model picker - #1000
Robert0622 wants to merge 12 commits into
Conversation
The chat model picker listed 「CLI 默认模型」 (default) first, so a new conversation without a remembered model started on it. Chat now starts on the remembered model, else the first listed one, and no longer offers the CLI default for CodeBuddy or for the catalog of a CLI without a key. A conversation saved on default moves to that model when opened, edited or regenerated. default stays listed only when CodeBuddy has no other model, or when the shared key is limited to it. The backend catalog and the classic pickers are unchanged.
Robert0622
left a comment
There was a problem hiding this comment.
默认模型选择会随请求变化。 b48effff 的 24 个聊天 hook 测试及模型目录既有用例均通过。我另外固定了两个同环境账号的缓存目录,清空显式默认配置,连续读取 256 次,实际选择为 model-a 222 次、model-b 34 次。该分支与 main@6a331fb5 另有 17 个冲突文件,包括模型目录和聊天选择器。
Robert0622
left a comment
There was a problem hiding this comment.
复审通过 · 1fd41104
真实 iOA CodeBuddy CLI 和模型 HTTP 接口返回 36 个可用模型。另一个账号的测试缓存中存在不同模型时,连续解析 256 次均选中当前账号列表的第一项,未出现其他账号的模型。也复测了没有缓存时的两个独立账号、已保存的个人模型、共享 Key、使用 Runner 登录的旧定时任务及其离线切换,以及报告模型与用量记录。最终提交上,聊天前端 453 项测试通过。使用真实 MySQL 和 Chromium 验证未配置 Key 时点击发送保留草稿、无会话写入,并能直接打开个人凭证配置。公开浏览器套件运行的 23 项均通过。
已核对本提交的差异和 GitHub 检查,当前没有发现阻塞合并的问题。
crispinhu27
left a comment
There was a problem hiding this comment.
初审 #1000(head 1fd4110,merge-base 5fadefc)。
审查范围:全部 67 个变更文件。后端:assistant_models.go(cliModelEntry 去 environment 字段、cachedCLIModels 改为按账号 key 查询)、engines/executor_models/catalog/assistant.go/domain/preview.go 等约 20 个文件;前端:chatbot/src/useChat.js、web/app/assistant-models.js 及 5 个 JS 文件;对应测试文件全部读取。
验证:internal/domain 测试通过;TestAssistantModelPickerOmitsCodeBuddyCLIDefault、TestCodeBuddyModelDiscoveryPerEnvironment、TestCodeBuddyImplicitModelStaysWithItsAccount(256 次迭代,两账号各自固定选第一个模型)、TestScheduledRunModel*、TestClarifyAllowedModel*、TestSOPReport*、TestNotification*、TestScheduleJobUsesSaversDefaultRunnerLogin 全部通过;chatbot hooks.test.jsx(52 个测试,含 PR 新增的 2 个用例)通过。baseline 对比确认新断言仅出现在 head。CI 全部通过。
核心改动正确性:sha256(environment + apiKey) 缓存 key 完全消除了同环境不同账号的顺序不确定性,解决了作者在 PR 中指出的 P2 问题。ChosenModel 兼容处理了所有 clarify/schedule/SOP report/Bot/preview build/runner login 路径。未发现确认问题。以上不代表代码没有其他缺陷。
crispinhu27
left a comment
There was a problem hiding this comment.
复审结论:APPROVE(head 9dcb98aa,base main@42541ef)
本次变化:两个合并提交,PR 自身代码没有变化。净 diff 仍是 67 个文件,+432/−298,和上次批准的 1fd4110 相同。
798f129(合入main@edc27c0)CHANGELOG.md:主线新增的 4 条 designer 条目保留,本 PR 的条目放在后面。web/i18n-en.js:逐 key 对比,合并结果相对 main 只少"CLI 默认模型"(本 PR 本来就要删它),主线新增的 13 个 key(designer、MCP 接入引导等)都在。- 其他文件都是自动合并。主线新增的代码没有引用本 PR 改过签名或语义的符号。
- 新的
SopDesigner直接读/api/assistant/models。目录里已经没有default,designer 的模型选择器会落到第一个模型,记住的旧default也会回落到第一个模型,和本 PR 的意图一致。
9dcb98a(合入main@42541ef,含 #1080):--remerge-diff只在web/app/sync-schedule.js的fillScheduleJobForm有一处冲突。解决后同时保留了本 PR 的assistantModel=job.assistantModel||firstModel()和主线的timeoutMinutes回填。主线在 sync-schedule.js 的其余 3 处timeoutMinutes改动和index.html里的新输入框都在。
已执行的验证(隔离沙箱用户和隔离数据库,合成数据,不接触任何凭据)
- chatbot 的
npm ci && npm test && npm run build:465 项全部通过(base 463 项,多出的 2 项是本 PR 新增)。两次合并都没有改chatbot/。 - webtest:在
798f129上全量 219/219 通过;在9dcb98a上相关子集 40/40 通过,包括 sync-schedule、platform-admin、orchestrate-ai/build、sop-sandbox-selection、module-logic。 - Go:
go build ./...和go vet通过;domain、repo、web 测试通过。internal/httpapi只有两个浏览器环境用例失败,base 上同样失败。TestScheduledNativeUsageReproduction/codex_two_calls偶发失败,-count=30时 head 7 次、base42541ef4 次、edc27c07 次,属于主线已有的不稳定用例。 - 运行验证(用本 head 构建的服务连隔离 MariaDB):
/api/assistant/models没有 key 时返回{"default":"","models":[]};配置了合成 key 和模型后,default取第一个模型,列表里没有default项。- 定时任务:
assistantModel为空、timeoutMinutes=75可以保存;"default"加 241 返回 400「执行超时必须为 1–240 分钟」;"default"加 30 能保存,模型被清空、超时为 30;指定模型不填超时时,保留该模型,超时默认 30。
- GitHub 检查:core、browser、platform-required、e2e-required 等 16 项全部通过。
历史问题:上一轮没有阻塞问题。作者自己提的 P2(cachedCLIModels 跨账号顺序)的回归用例 TestCodeBuddyImplicitModelStaysWithItsAccount 仍然通过。
What changed
Follow-up to #978. #978 stopped forcing the chat model back to the default, but the AI 对话 model picker still listed 「CLI 默认模型」 (
default) first. A user with nothing remembered therefore still started on it.Chat now drops the CLI default from its model list:
GET /api/assistant/models): thedefaultentry is filtered out in the chatbot. A new conversation starts on the remembered model, else on the first listed one.GET /api/assistant/models?executor=codexand others): theCLI defaultentry is dropped the same way.default: when opened, edited or regenerated, they move to the remembered or first listed model, like a new conversation. An old remembereddefaultin localStorage falls back to the first listed model, as any retired model does.defaultstays listed only when CodeBuddy has no other model to offer (for example a guest before discovery has run), or when the administrator limited the shared key to it, so chat keeps working in those cases.The filtering lives in the chatbot (
chatModelListandsessionModelinchatbot/src/useChat.js).GET /api/assistant/modelsand the backend are unchanged on purpose. The classic role, scheduler, clarification and SOP preview pickers read the same catalog, and theredefaultmeans "follow the operator's default". Roles, schedules and executors pinned todefaultkeep working, and the backend still acceptsdefaultfrom older clients.Scope
Compatibility
No API, schema or migration change. Only the chatbot model picker changes. Related: #876 (open) normalizes
<cli>:defaultto an unset model on the backend. It does not conflict with this change: chat no longer sendsdefaultfor those CLIs once their list has loaded.Validation
New tests in
chatbot/tests/hooks.test.jsx:chatModelListdropsdefault. It keepsdefaultwhen CodeBuddy offers nothing else, or when the shared key allows it.defaultopens and regenerates on the first listed model.The updated tests now expect the first real model for a new chat and for the Codex catalog.
Not run: Go tests (no Go change),
local/scripts.bash scripts/scan-secrets.shcould not run in this sandbox: extracting gitleaks failed withCannot change ownership ... Operation not permitted.Safety