Port upstream 0.65.0: scan claude-swap session homes in Claude cost (stacked on #610) - #670
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
|
Reviewed by Codex gpt-6-luna (xhigh); verified and validated by Claude Thermo-nuclear review of #670 (claude-swap session homes in the Claude cost scan). Findings:
|
|
Follow-up: all three findings above are fixed and pushed. Nothing left open. The change is backend only (no user-visible UI change), so no CUA pass was needed. Commands run (Rust 1.98.0, E-cores): |
….0-claude-swap-cost-homes
Accept an empty label after the slot number (upstream splits with omittingEmptySubsequences: false), translate both CostUsageScannerClaudeSwapTests cases with their token and cost assertions and the two-minute rescan, and cover shared-history de-duplication through a junction, which needs no symlink privilege.
|
Lane A review: fixes at 2808b1b Reviewed the whole diff against the base (#610 at 15f1091) and against upstream v0.65.0 ( What changed on the branch:
Checked and unchanged: base root first, then swap homes sorted by path; missing roots omitted; discovery failures counted so a partial history is not reported as a complete zero; only Validation at 2808b1b (toolchain 1.98.0,
UI proof: not needed. The change is backend only (cost scan roots); the cost totals it feeds are rendered by existing surfaces. |
Summary
The Claude local cost scan now also reads claude-swap session homes, so Usage & Spend totals include Claude usage written while a swapped session was active. Roots are
<home>/.claude-swap-backup/sessions/<N>-<label>/projects(immediate children ofsessions,<N>a positive integer,projectsa directory, sorted by path). They are added beside the existing profile root, including whenCLAUDE_CONFIG_DIRis set (the literal profile root is kept).seende-duplication set, so a row copied between homes counts once. Totals are aggregate only; there is no per-account attribution.has_cost_usage_sources, the summary scan, the chart snapshot and both daily-history scans (cost and tokens) use the same resolver.finalize_claude_summarycoverage is true when any root exists.The resolver lives in a new
rust/src/cost_scanner/claude_roots.rs(pure function overCLAUDE_CONFIG_DIRand the home directory) instead of growingcost_scanner.rs, which was already over 1000 lines.Upstream reference
v0.65.0):Sources/CodexBarCore/Providers/Claude/ClaudeConfigPaths.swift(costProjectsRoots),Tests/CodexBarTests/CostUsageScannerClaudeSwapTests.swift,CostUsageScanner+Claude.swift,SettingsStore+TokenCost.swift, docs/claude.md "Source roots".Ported / Deferred
Ported: the legacy
~/.claude-swap-backuproot (the only root claude-swap uses on Windows and macOS).Deferred / not needed:
$XDG_DATA_HOME/claude-swap/sessions): Windows-only build.~/.config/claude/projectsand Claude Desktop project roots beside~/.claude/projectswhenCLAUDE_CONFIG_DIRis unset. The local scanner keeps its existing single-root fallback (~/.claude/projects, else~/.config/claude/projects); that is unrelated to this item.Validation
Toolchain
cargo +1.98.0, slot-6 target dir, E-core wrappers.cargo fmt --all: cleancargo clippy --workspace --all-targets -- -D warnings: passcargo test -p codexbar cost_scanner: 126 passed, 0 failedcargo test -p codexbar claude_: 93 passed, 0 failed (includes 7claude_rootsresolver tests and the end-to-endclaude_swap_homes_are_scanned_once_beside_a_literal_config_dir)cargo test -p codexbar(full): 2235 passed, 0 failed, 1 ignored (pre-existing)Fixtures are synthetic re-creations of the upstream cases: two homes with one row each, a copied row in both, a symlink to shared history (skipped only if the OS refuses to create it), a dangling profile directory, a literal
CLAUDE_CONFIG_DIRplus swap homes, and non-numeric /0-foodirectories ignored.Affected areas
rust/src/cost_scanner)UI proof
Not applicable. Totals change; the dashboard and tray consume the same summary.