feat(mobile): 在任务菜单展示配额与用量摘要 - #3979
Conversation
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
| Filename | Overview |
|---|---|
| apps/mobile/src/session/readSessionMenuAccountUsage.ts | 新增多来源账号用量投影,但模型专属 Codex 桶会替代而非补充通用配额桶。 |
| apps/mobile/src/session/useSessionMenuUsage.ts | 新增按设备、任务和运行配置划分的读取、轮询、失败保留及迟到结果隔离。 |
| apps/mobile/src/session/SessionUsageSummary.tsx | 新增摘要与明细卡片;展示层支持多个配额窗口,但依赖读取层提供完整窗口集合。 |
| apps/mobile/src/session/SessionMenuSheet.tsx | 将新摘要卡接入一级菜单和任务信息详情,并统一刷新入口。 |
| apps/mobile/src/device-link/mobileMakerTransport.ts | 在移动传输层登记并调用已有的会话估值远程查询。 |
| packages/maker-shared/src/deviceLinkContract.ts | 将已有历史估值查询加入移动端允许调用的共享通道集合。 |
Sequence Diagram
sequenceDiagram
participant U as 手机任务菜单
participant H as useSessionMenuUsage
participant T as Device Link
participant D as 桌面端
participant DB as 本地数据库
U->>H: 打开菜单
par 读取账号配额
H->>T: getCodexRateLimits / getAccountUsage
T->>D: 远程调用
D-->>T: 配额桶或账号快照
T-->>H: 账号用量
and 读取任务估值
H->>T: getSessionEstimatedValue(sessionId)
T->>D: 历史估值查询
D->>DB: 汇总估算轮次
DB-->>D: 估值金额
D-->>H: 任务估值
end
H-->>U: 展示配额、价值/费用和上下文
loop 菜单可见期间每 30 秒
H->>T: 重新读取
end
Prompt To Fix All With AI
### Issue 1
apps/mobile/src/session/readSessionMenuAccountUsage.ts:160-167
**隐藏整体配额**
当账号同时存在通用配额桶和当前模型的专属配额桶时,`selectCodexUsageForModel` 只返回一个桶,后续也只读取该桶的窗口。例如通用周限额已经耗尽、Spark 专属限额仍剩 80% 时,菜单只会展示后者,让用户误以为任务仍可继续。这里需要同时保留通用桶和匹配当前模型的专属桶;现有组件测试虽然覆盖了两类窗口的展示,但没有经过这条实际读取路径。
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "feat(mobile): 在任务菜单展示配额与用量摘要" | Re-trigger Greptile
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0892ddf9d1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4638250eb0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c4cc4ea2af
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: abecd1df41
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe64245c08
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
|
命中 UI 路径(apps/mobile/app/sessions/[sessionId].tsx / apps/mobile/src/device-link/mobileMakerTransport.ts / apps/mobile/src/session/SessionMenuSheet.tsx 等)但 description 未附界面效果证据——建议补充改动后效果:截图/录屏,或改动后界面的 HTML 页面(```html 代码块、.html 附件或在线预览链接),便于确认界面符合 DESIGN.md 设计规范 |
MagicLizi
left a comment
There was a problem hiding this comment.
代码重审通过:任务菜单配额/用量只走已有 local-db 通道,未知渠道不会编造 OpenAI/Gateway。当前 head 没有 P0/P1。
|
合了。手机任务菜单终于能看见配额和用量,还不会拿错账号的数。 |
这次改了什么
摘要
手机任务菜单打开后即可查看账号配额、任务价值/费用和上下文占用。摘要卡片统一作为「任务信息」入口,点击整卡进入详情,箭头位于整卡右侧居中,移除下方重复入口。
配额和任务价值复用现有远程查询。Codex 优先读取官方控制面,旧工作端按既有规则回退账号快照;同时保留通用配额和当前模型专属配额,专属行注明模型名称。ChatGPT bridge 仅在来源明确为 OpenAI 时读取 web 槽;明确的 Gateway 来源读取周期和今日用量;Pi/Claude Code 来源未解析时保持未知,不套用 Gateway 或 OpenAI web 账号。估算价值与实际费用分开呈现,不合并不同币种。
变更类型
feat新功能fix缺陷修复refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
UI 变化
docs/design-rules/DESIGN.md§2 Color Palette & Roles、§3 Typography Rules、§4 Cards & Containers、§5 Spacing System。复用 Light/Dark 的 sheet 语义颜色、字体与间距 token;整卡最小点击高度 44,箭头为装饰元素,无障碍名称为「任务信息」。怎么验证的
自动验证
相关检查通过。测试覆盖官方接口与旧快照回退、账号变化禁止旧数据兜底、模型桶选择、web/CLI 配额隔离、Gateway 币种、数据缺失、请求迟到、任务切换和断线保留。共享包没有独立 typecheck script,该步骤按命令约定跳过。
账号生命周期定向测试 8/8 通过;上下文归属与菜单入口测试 12/12 通过,覆盖运行配置切换、A→B→A 迟到回包、刷新失败与关闭,以及详情关闭后重开一级菜单不触发引擎读取。本次重跑根
pnpm test:unit:related与 mobile typecheck 均通过。覆盖通用/模型配额同时呈现、未知来源、显式 OpenAI/Gateway、来源切换与迟到响应,以及未初始化上下文窗口回退、旧字段别名和实时零值优先。早期双桶修复的相关门禁曾遇到未改动的 Pi 集成用例超时及紧随其后的断言失败;干净主干
47ef43edd定向复核两项通过,完整相关门禁重跑一次后通过。未修改 Pi 源码或测试。新增文件通过 Prettier 检查;10 份修改过的存量文件存在整文件格式提示,逐一核对主干
47ef43edd也有相同问题,本 PR 保持周边格式,未做整文件重排。手工验证
最终接口复用版本尚未完成手工验证,不将组件测试等同于 Light/Dark 实机目检。
未执行的验证
最终版本未重跑 iOS Simulator、Android 和真实远程配额端到端测试。目标分支为
dash/mobile-task-usage-summary;未取得最终版本的 Metro 归属和 build label 证据。风险
风险分类
影响与回滚
来源与上下文的不变量
账号读取只使用工作端下发的有效选择;未解析的来源不推断为 OpenAI web 或 Gateway。来源判据集中在
readSessionMenuAccountUsage;账号状态由既有useSessionMenuUsageeffect 写入,按设备/任务/运行配置隔离。上下文优先使用有效的实时计数;窗口必须有限且大于 0,未初始化值回退到详情快照的既有字段;计数允许真实 0。来源交错测试覆盖 OpenAI 请求未完成 → 未明确来源 → Gateway → 旧 OpenAI 响应返回 → 未明确来源;上下文测试覆盖未初始化 → 有效详情 → 实时零值。没有新增工作端接口或重试。
上下文快照归属收敛
上下文快照只属于当前设备、任务和运行配置,旧窗口不得与新运行配置的计数混算。缓存从页面收拢到菜单的
useSessionMenuContextUsage:同一个 effect 负责详情读取、loading、成功/失败和取消;移除页面缓存及/context命令对菜单缓存的旁路写入。命令卡片仍使用自己的原始查询结果。与账号摘要复用已有 scope 判据,账号控制和重置流程保持现状。这次收敛移除了跨入口共享缓存的责任混用,没有加入缓存基础设施、重试调度或新远程接口。交错测试同时覆盖迟到成功和失败,并保留现有未初始化窗口、旧字段别名及实时零值测试。
配额刷新不变量
父级继续拥有 Codex 控制快照和原有重置流程;摘要账号状态仍只有原读取 effect 写入。重置或控制刷新返回新快照时,摘要立即重读并使旧读取失效,不能等待轮询后才更新。
codexRateLimitsprop 更新,触发同一个 effect 重新读取测试覆盖“耗尽快照 → 旧读取挂起 → 重置后快照 → 新读取完成 → 旧读取迟到”,以及关闭期间变化、重新打开与相同快照不重复读取。未修改重置确认、幂等键或错误处理,没有新增状态或刷新调度器。
提交前检查
git commit -s)