Repository navigation
fix(usage): order app filter chips like the sidebar apps - #10006
Merged
Merged
Conversation
2 tasks done
jimpablo
force-pushed
the
fix/usage-app-filter-order
branch
from
November 26, 2026 05:33
3807fe4 to
ba0a5af
Compare
Owner
|
已合并,感谢您的贡献!用量页的应用筛选直接复用侧栏的排序,两边顺序终于一致了,修复了 #10005。 |
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.
Human Note / 本人说明
平时在用量统计页切不同应用的统计时,发现顶部应用筛选栏的图标顺序和左侧栏对不上:没拖过顺序时 Antigravity、Oh My Pi、WorkBuddy、CodeBuddy 的位置就不一致,在「应用」页拖过顺序之后用量统计这边也不会跟着变。照着
AuthCenterPanel刚改完的同款写法,让UsageDashboard的筛选栏复用orderAppIds(settings?.appOrder),把KNOWN_APP_TYPES对齐回APP_IDS默认顺序,并把筛选列表键加进useSlidingIndicator防止顺序变化后滑块停在旧位置,同时补齐了对应的单测。Summary / 概述
1. 用量统计应用筛选栏跟随侧栏顺序(
src/components/usage/UsageDashboard.tsx)AuthCenterPanel(18883626)的同款写法,在filterApps中通过orderAppIds(settings?.appOrder)计算各应用在侧栏中的位置并排序:appOrder时保持与APP_IDS/ 侧栏一致的默认顺序;appOrder后同步跟随该顺序(未知 ID 与新增应用由orderAppIds统一处理);claude筛选按钮的["claude", "claude-desktop"]仅按当前可见项计算位置(隐藏项不会把另一项钉死在旧位置;两者都显示时取更靠前的位置);useSlidingIndicator的依赖值更新为`${appType}:${filterApps.join(",")}`,避免settings异步加载或appOrder/visibleApps变化导致按钮重排但appType不变时,选中滑块(SegmentThumb)停留在旧的offsetLeft。2. 对齐
KNOWN_APP_TYPES默认顺序(src/types/usage.ts)AppType与KNOWN_APP_TYPES调整为与APP_SPECS/APP_IDS一致的默认顺序(修正omp、codebuddy的位置漂移),同步修正用量设置抽屉中「覆盖应用列表」的展示顺序。3. 单元测试(
tests/types/usage.test.ts、tests/components/UsageDashboard.test.tsx)tests/types/usage.test.ts:新增KNOWN_APP_TYPES与APP_IDS默认顺序一致性的回归校验,防止后续新增应用再次漂移。tests/components/UsageDashboard.test.tsx:新增默认顺序(含settings加载前全量与加载后筛选子集)、自定义appOrder(含未知 ID 及隐藏claude-desktop)、仅显示claude-desktop、同时显示claude与claude-desktop、隐藏且选中claude的回退位置、无可见统计应用时仅保留「全部」,以及appOrder首次加载与挂载后刷新重排时的滑块位置重算共 7 个单元测试。Related Issue / 关联 Issue
Fixes #10005
Screenshots / 截图
Claude Code → Codex → Grok Build → OpenCode → Antigravity → Oh My Pi → WorkBuddy → CodeBuddy,但用量统计筛选栏为Claude Code → Codex → Grok Build → OpenCode → Oh My Pi → CodeBuddy → Antigravity → WorkBuddy,且不跟随「应用」页拖拽排序appOrder下均与侧栏顺序完全一致;claude-desktop折叠与滑块位置同步正确Checklist / 检查清单
pnpm typecheckpasses / 通过 TypeScript 类型检查pnpm format:checkpasses / 通过代码格式检查(同时通过pnpm knip、pnpm test:unit348/348 全部 4559 项及pnpm build:renderer)cargo clippypasses (if Rust code changed) / 通过 Clippy 检查(N/A — 本 PR 仅修改前端 TypeScript 与测试)