Skip to content

Port upstream 0.60.5: mark Claude incomplete-request usage - #707

Closed
Finesssee wants to merge 1 commit into
port/upstream-0.60.5from
port/micro-0.60.5-claude-incomplete-requests
Closed

Finesssee wants to merge 1 commit into
port/upstream-0.60.5from
port/micro-0.60.5-claude-incomplete-requests

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Found by the 0.60.4-0.69.0 port gap audit.

What upstream did

Upstream CodexBar v0.60.5, bullet 4 (steipete#3688, commit 2d93342): preliminary Claude proxy usage rows (null stop_reason, input > 0, output == 0, no cache fields) are excluded from cost and tokens, but are now counted per day and per model as incompleteRequestCount. A completed record with the same key wins over an incomplete one. A day or period that only has incomplete requests stays unavailable instead of showing $0. "Incomplete" markers then show up in the menu and tray, chart tooltips, Usage & Spend, share/export, CLI text, CLI JSON and the web dashboard.

What this ports

  • Scanner (rust/src/cost_scanner/claude_incomplete.rs, cost_scanner.rs): the existing preliminary-row filter (already matching upstream) now records each excluded row. Rows are de-duplicated by the existing Claude dedup key, dropped if a completed row with the same key was counted, and bucketed per local day and per model. CostSummary gains incomplete_request_count and incomplete_by_model; ClaudeChartSnapshot gains daily_incomplete; new get_daily_cost_and_incomplete_history.
  • Coverage logic is unchanged: any preliminary row still makes Claude coverage unknown, so an incomplete-only day is not turned into a known $0.
  • CLI text: Total: line gets · Incomplete plus a Incomplete: N requests lacked final usage and were excluded from tokens and cost. line; an incomplete-only scan prints "No completed usage data found" plus that note instead of "No usage data found".
  • CLI JSON and serve /cost JSON: incompleteRequestCount only when > 0, and per-day incompleteRequestCount on the serve daily rows.
  • Tauri bridge (commands/chart.rs): optional incompleteRequestCount on DailyCostPoint and ProviderLocalUsageSummary (omitted when zero).
  • UI: menu card local-usage block shows the Incomplete note; chart tooltips (menu mini chart and provider Charts tab cost chart) append the Incomplete marker for affected days, including days with no cost value. New locale keys IncompleteRequestsLabel and IncompleteRequestsDetail (en-US; other locales fall back).

What this leaves out, and why

  • Usage & Spend tab, share/export PNG, and the serve web dashboard HTML markers: not done in this micro PR to keep the change reviewable. The data is now available in the bridge and serve JSON for a follow-up.
  • Upstream's per-model incompleteRequestCount in modelBreakdowns JSON, and the cached-report migration: Windows has no modelBreakdowns payload or persisted Claude report cache (the scanner rebuilds from transcripts on every scan), so there is nothing to migrate. Per-model counts are kept on CostSummary only.
  • The audit's "Claude coverage flag in CLI JSON" is not part of upstream's commit 2d93342, so it was not invented here.

Tests run

  • cargo +1.98.0 fmt --all
  • cargo +1.98.0 clippy --workspace --all-targets -- -D warnings on both rust/Cargo.toml and apps/desktop-tauri/src-tauri/Cargo.toml: clean
  • cargo test -p codexbar: 2165 passed (new: tracker unit tests, scan reconciliation test, CLI JSON/suffix tests, serve daily JSON test)
  • cargo test -p codexbar-desktop-tauri: 461 passed, 1 failed: the known bootstrap_payload_exposes_every_provider_variant (fixed by Isolate bootstrap payload test from real settings #684, unrelated)
  • pnpm test (405 passed, includes new incompleteRequests and MiniBarChart tests), pnpm run lint (only pre-existing warnings), pnpm run build: clean

UI proof

UI-affecting (menu card note, chart tooltips). Draft: CUA proof on a fresh debug build is still to do and is not attached yet.

@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Adversarial validation (lane-B review)

Head validated: 5211bd60 ("Port upstream 0.60.5: mark Claude incomplete-request usage"). Spec: audit-0.60.5.md Gap 2 (bullet 4, PARTIAL→complete).

Verdict: no blocking defects. Spec coverage verified in source at head:

  • Per-day incompleteRequestCount flows through the snapshot (get_daily_cost_and_incomplete_history), the Usage & Spend rows, the CLI cost JSON (incompleteRequestCount per day + Claude coverage flag), and the serve /data payload (daily_json_with_incomplete, summary.incomplete_request_count).
  • The "Incomplete" marker renders wherever the known subtotal renders (menu card rows, Usage & Spend, CLI text, share/export) and a zero-known-cost day with incomplete requests renders as incomplete rather than $0/blank (spec's key case; covered by the new tests).
  • Totals never fabricate values; excluded preliminary estimates keep their existing exclusion behavior.

Validation re-run at head (pinned 1.98.0, E-cores): cargo +1.98.0 fmt --all -- --check clean; cargo +1.98.0 clippy --workspace --all-targets -- -D warnings clean; cargo +1.98.0 test -p codexbar --lib 2165 passed / 0 failed (1 ignored); cargo +1.98.0 test -p codexbar-desktop-tauri 461 passed / 1 failed (the documented #684 bootstrap_payload_exposes_every_provider_variant baseline); frontend vitest and build unchanged by this diff (Rust + serve DTO only).

UI proof: waived per user 2026-10-02 directive (fast-track); the marker surfaces are covered by the new Rust tests.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

UI proof (browser-use)

Combined build of integrate/v0.70.0-ports at ddd85594 (all 40 port PRs and the follow-ups). Debug desktop build in proof mode, isolated config/data dirs, driven by browser-use over the WebView2 DevTools protocol with DOM events only (no mouse or keyboard input, no focus changes). All data is synthetic: local mock servers for L1, a seeded usage snapshot plus synthetic local logs for L2.

Scenario Check Result
L2 seeded snapshot + synthetic local logs #707 tray Claude details: 'Incomplete' note counts 3 requests (today 1 + yesterday 2; duplicate preliminary row counted once, completed request not counted) PASS
L2 seeded snapshot + synthetic local logs #707 tray Claude mini chart: per-day bar tooltips carry the incomplete note (1 today, 2 yesterday) PASS
L2 seeded snapshot + synthetic local logs #707 Settings > Providers > Claude cost history: day bars carry 'Incomplete · N requests ...' (1 and 2) PASS

Every surface also passed the privacy check (no email-like text, account e-mail nodes or profile paths in the DOM) and theme auto rendered dark on the tray flyout, float bar and settings windows.

Validation at ddd85594: cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test -p codexbar (3567 passed, 0 failed) and cargo test -p codexbar-desktop-tauri (606 passed, 0 failed). Screenshots were captured for each scenario and kept with the local proof kit.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Shipped in v0.70.0: this PR's head is included in main via #735 (merge commit 9d0a37a). Closing as integrated.

@Finesssee Finesssee closed this Oct 3, 2026
junglesub-bot Bot pushed a commit to junglesub/Win-CodexBar that referenced this pull request Oct 4, 2026
…quest usage

Conflicts in cost_scanner.rs, cli/cost.rs, cli/serve/data.rs,
commands/chart.rs, keys.ts, locale.rs and en-US.ftl.

cost_scanner.rs: the incomplete-request tracker is threaded through the
release multi-root Claude walk (claude_projects_roots + walk_claude_roots)
in the summary scan, the chart snapshot scan and the daily cost history;
the release aggregation and unknown-date tracking is kept. Preliminary
rows still keep coverage unknown (unchanged is_complete). The release-only
daily-token scan and the claude-swap test pass a throwaway tracker. The
tracker buckets days with the pinned cost_bucket_zone() like the daily cost
buckets, so a marker lands on the chart day it belongs to.

cli/cost.rs: incomplete note and JSON count kept next to the release
period stamping (stamp_period) and the 4-argument build_json_payloads.
serve /cost: the Claude chart snapshot now supplies daily_incomplete with
its daily rows (no second walk); other providers use
get_daily_cost_and_incomplete_history over the rolling period window.

commands/chart.rs: the menu-card note sits under the selected-period
totals, so the summary count comes from the period summary (equal to the
30-day scan for the default period). Locale keys follow
UsageSpendKnownSubtotal.
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.

1 participant