fix(cli): stabilize statusline preset ordering#4634
Conversation
Add direct coverage for exported statusline preset helper behavior requested during PR review. Constraint: Address PR QwenLM#4634 review feedback for direct exported helper tests. Rejected: Relying on existing integration coverage | Direct tests were requested for exported helper contracts. Confidence: high Scope-risk: narrow Directive: Keep preset item ordering and reasoning formatting contracts directly covered when these helpers change. Tested: cd packages/cli && npx vitest run src/ui/statusLinePresets.test.ts; cd packages/cli && npx vitest run src/ui/statusLinePresets.test.ts src/ui/components/StatusLineDialog.test.tsx src/ui/hooks/useStatusLine.test.ts; cd packages/cli && npx eslint src/ui/statusLinePresets.ts src/ui/statusLinePresets.test.ts; git diff --check Not-tested: Full repository test suite.
Verification Report — PR #4634Tested locally on: macOS Darwin 25.4.0 / Node.js v22.17.0 Test Results
Test Breakdown
SummaryAll test plan items pass cleanly on macOS (first macOS verification for this PR, which was previously only tested on Windows). The preset normalization, dialog save ordering, preview output, and hook integration are all covered by the 82 tests. Verified by wenshao |
wenshao
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅ The statusline preset ordering changes are clean — well-structured refactoring with thorough test coverage (82 tests pass). The previously noted gap around direct unit tests for orderStatusLinePresetItems and formatModelWithReasoning has been addressed. — qwen3.7-max via Qwen Code /review
|
@shenyankm 建议合理 👍 右侧 footer 的上下文显示( 动手前有两个约束想先同步一下:
所以我倾向于一个条件隐藏的方案,而不是直接删:仅当 statusline 已经包含 context 项( 方向 OK 的话,另开一个 issue/PR 单独跟进就行,不动已经合并的 #4634。 |
收到! |


What this PR does
This PR makes built-in
/statuslinepreset items behave as a visible item set instead of using MultiSelect insertion order as the display order. Preset items are normalized and rendered using a fixed priority order, so manually written settings, saved dialog settings, preview output, and footer rendering stay consistent.It also updates the model-related preset behavior so
model-with-reasoningremains first,model-onlyappears immediately after it, and both model entries can be displayed together when selected. The preset order is adjusted to keep model information first, followed by high-frequency runtime information such as Git branch, context remaining, and session token totals.Why it's needed
Before this change, disabling a statusline preset item and enabling it again caused the item to reappear at the end of the statusline. That made the statusline order unstable and harder to scan during normal use.
Using a fixed internal priority makes the preset configuration easier to reason about:
itemsnow represents which preset entries are visible, while display order is controlled by the built-in preset order. This preserves existing settings compatibility while improving the interactive/statuslineexperience.Reviewer Test Plan
How to verify
Open
/statusline, disable a selected preset item such ascontext-remaining, enable it again, and save. The saved preset items should return to the fixed priority order instead of appending the toggled item to the end.Select both
model-with-reasoningandmodel-only. The rendered statusline should show the model-with-reasoning entry first and the plain model entry second, for exampleqwen3-code-plus high | qwen3-code-pluswhen reasoning effort is configured.Use a manually written preset config with items in a scrambled order. The preview and rendered statusline should still display items in the built-in priority order.
Local verification:
Evidence (Before & After)
Before: toggling an existing preset item off and back on could move it to the end because the saved order followed MultiSelect insertion order.
After: toggled preset items are saved and rendered in the fixed priority order. Targeted tests cover normalization, dialog saving, preview ordering, footer rendering, and hook integration.
Tested on
Environment (optional)
Windows PowerShell. Targeted Vitest tests, ESLint for touched files, and
git diff --checkpass locally.cd packages/cli && npm run typecheckis currently blocked by an existing missing@qwen-code/channel-feishumodule/type dependency, unrelated to this statusline change.Risk & Scope
itemswill now see the built-in priority order instead. This matches the intended behavior that presetitemscontrols visibility, not custom ordering.modelremains supported; only the UI label is shown asmodel-only.Linked Issues
Closes #4633
中文说明
What this PR does
此 PR 将内置
/statusline预设项改为“可见项集合”语义,不再使用 MultiSelect 的插入顺序作为显示顺序。预设项会通过固定优先级进行归一化和渲染,因此手写 settings、弹窗保存、预览输出和 footer 实际渲染会保持一致。同时,此 PR 调整了模型相关预设项行为:
model-with-reasoning保持第一位,model-only紧随其后,并且当两者都被选中时可以同时显示。预设顺序也被调整为模型信息优先,然后显示 Git 分支、上下文剩余、会话 token 总量等高频运行信息。Why it's needed
在此改动前,用户在 statusline 预设里关闭某个已选项后再重新开启,该项可能会被追加到末尾。这会让 statusline 顺序不稳定,正常使用时更难快速扫描。
使用固定内置优先级后,预设配置更容易理解:
items表示哪些预设项可见,而显示顺序由内置预设顺序控制。这样既保持现有 settings 兼容性,也改善了交互式/statusline的使用体验。Reviewer Test Plan
How to verify
打开
/statusline,关闭一个已选预设项,例如context-remaining,再重新开启并保存。保存后的 preset items 应回到固定优先级顺序,而不是把刚切换的项目追加到末尾。同时选择
model-with-reasoning和model-only。渲染出的 statusline 应先显示带 reasoning 的模型项,再显示纯模型项,例如 reasoning effort 已配置时显示qwen3-code-plus high | qwen3-code-plus。手写一个乱序的 preset config。预览和实际渲染出的 statusline 仍应按照内置优先级显示。
本地验证:
Evidence (Before & After)
Before:关闭某个已有预设项再重新开启时,该项可能移动到末尾,因为保存顺序跟随 MultiSelect 插入顺序。
After:被切换的预设项会按照固定优先级保存和渲染。目标测试覆盖了归一化、弹窗保存、预览顺序、footer 渲染和 hook 集成路径。
Tested on
Environment (optional)
Windows PowerShell。本地已通过目标 Vitest、相关文件 ESLint 和
git diff --check。cd packages/cli && npm run typecheck当前受既有@qwen-code/channel-feishu模块/类型依赖缺失影响,和本次 statusline 改动无关。Risk & Scope
items中的自定义顺序,现在会看到内置优先级顺序。这符合本次预期语义:presetitems控制是否显示,而不是自定义排序。model保持兼容;仅 UI label 显示为model-only。Linked Issues
Closes #4633