Skip to content

fix: explain unavailable cost in offload ls - #12

Merged
zhoushoujianwork merged 2 commits into
mainfrom
fix/issue-10
Oct 26, 2026
Merged

zhoushoujianwork merged 2 commits into
mainfrom
fix/issue-10

Conversation

@zhoushoujianwork

Copy link
Copy Markdown
Owner

Fixes #10

改动

  • history.Read: 不再无条件把 cost_is_estimate 置为 true。只有存在成本值时才视为估算。保留真实的 0。无标记的 legacy 0 仍视为不可用(无法与缺失区分)。legacy 非零值保留为估算。
  • 新增仅运行时字段 Record.CostNote(json:"-"),记录成本不可用的原因。JSON 契约不变,cost_usd 仍为 null。
  • offload ls: 有值显示 est. $x,真实 0 显示 est. $0.0000,不可用显示 cost unavailable (原因)。原因包括 Codex 不报告 USD、worker 未上报、legacy 零不明确、记录值无效。
  • README 说明 Codex 只报告 token、不报告 USD 成本,以及各原因的含义。

CI 修复(单独一个 commit)

TestTerminalSettingsSecretIsMasked 在 go test -race 下失败(promptui Cursor/ScreenBuf 竞争,基线 ff0a109 已有)。Secret 改为直接使用 readline 实现掩码回显,并避免在 Enter 之后写屏。测试断言未改动,未关闭 race 检查。

测试

  • 新增基于保存的 runs.jsonl fixture 的测试:available、zero、missing、legacy 非零、legacy 零、codex、invalid。没有调用付费模型。
  • 新增 history 测试,确认 CostNote 不会被序列化。
  • go test -race -count=1 ./... 全部通过。gofmt、go vet 干净。Secret 测试 -race -count=20 稳定通过。
  • 未运行桌面/真机测试。

假设

  • offload show 与摘要行仍使用 unknown 文案,未改动,只在 ls 中加入原因。

promptui.Prompt shares its cursor with readline's listener goroutine, which
fails go test -race. Read the secret with readline directly and keep masked
echo; the test assertions are unchanged.

Refs #10
@zhoushoujianwork
zhoushoujianwork merged commit a2a7775 into main Oct 26, 2026
1 check passed
@zhoushoujianwork
zhoushoujianwork deleted the fix/issue-10 branch October 26, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: offload ls shows unknown cost without explaining availability

1 participant