Skip to content

Count Claude Cowork sessions in cost history - #960

Merged
Finesssee merged 5 commits into
mainfrom
feat/claude-cost-cowork-shards
Oct 21, 2026
Merged

Finesssee merged 5 commits into
mainfrom
feat/claude-cost-cowork-shards

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Summary

Ports upstream CodexBar steipete#3209 (Cowork audit transcripts in Claude cost history) to Windows. Upstream steipete#4598, its 0.79 follow-up steipete#4667, and steipete#4617 are reviewed and not ported: they change a persisted Claude cost cache that Windows does not have.

  • Cowork audit files are cost inputs. Claude Desktop cost discovery admits local-agent-mode-sessions/**/audit.jsonl regular files, beside the Desktop project stores. Symbolic links are never followed. Live-session discovery output is unchanged.
  • Windows Desktop folders. Discovery searches %APPDATA%\Claude and each Microsoft Store (MSIX) package store, reusing the existing msix_store_dirs helper from the browser module.
  • Default history only. Desktop roots are added only when CLAUDE_CONFIG_DIR is unset or blank and no token account is mapped. This mirrors upstream costProjectsRoots.
  • Parser unchanged. Cowork rows go through the existing CLI transcript parser. A response present in both a CLI transcript and a Cowork audit is counted once. result rows, which hold session totals, are never counted.
  • Bounded discovery. A cost discovery pass stops at 16,384 directory entries or 5 seconds. It has its own budget, so it cannot starve live session listing. A stopped walk adds one read failure to the Claude root, so the cost estimate stays unavailable instead of showing a partial total.
  • File roots. A .jsonl root is read directly. Any other file root counts as unreadable.
  • docs/PROVIDERS.md gains a Claude local cost history section.

Windows differences and not ported

Commands run

  • cargo fmt --all -- --check: clean
  • cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings: clean
  • cargo clippy --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml --all-targets -- -D warnings: clean
  • cargo test --manifest-path rust/Cargo.toml: 5093 passed, 0 failed, 2 ignored
  • Focused: cost_scanner:: 243 passed; agent_sessions:: 64 passed; claude_cowork 1 passed (child-process fixtures, default and CLAUDE_CONFIG_DIR cases)
  • cargo test --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml: 755 passed, 0 failed

Test coverage for the change:

  • claude_cowork: Cowork dedupe against CLI transcripts, result rows ignored, chart and daily totals match the summary, a mapped token account excludes Cowork, and a set CLAUDE_CONFIG_DIR excludes Cowork.
  • agent_sessions::tests: cost discovery admits audit files, live discovery stays project-only, and an expired clock or an exhausted entry cap reports incomplete.
  • cost_scanner::claude_roots: merging Desktop roots de-duplicates by resolved path, an incomplete walk is a read failure, and only an unset or blank config dir takes Desktop roots.

No UI proof: no frontend file changed, and the change is backend-only. Discovery of real Desktop folders was not exercised on a machine with a live Cowork install; the tests use temp directories through injected application-data roots.

Factory Agent added 3 commits October 21, 2026 12:29
Cost discovery admits Cowork audit.jsonl files and the Desktop project stores under %APPDATA%\Claude and the MSIX package stores, for the default Claude history only. A mapped token account or a set CLAUDE_CONFIG_DIR leaves them out. An incomplete discovery walk counts as an unreadable root.
Cover audit file dedupe, ignored result rows, chart and daily consistency, the mapped-account and CLAUDE_CONFIG_DIR exclusions, live discovery staying project-only, and incomplete discovery when the clock or the entry cap runs out.
Describe Cowork inclusion, the default-history-only rule, the Desktop discovery budget and the unavailable state after an incomplete walk.
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 25 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: nesszer/Win-CodexBar/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: a6b09bf9-3aaa-44de-8235-bace459c5619
📥 Commits

Reviewing files that changed from the base of the PR and between e26e4d9 and 1a57f27.

📒 Files selected for processing: 11
  • docs/PROVIDERS.md
  • rust/src/agent_sessions.rs
  • rust/src/agent_sessions/claude_desktop.rs
  • rust/src/agent_sessions/pi_family/roots.rs
  • rust/src/agent_sessions/tests.rs
  • rust/src/browser/claude_desktop.rs
  • rust/src/browser/mod.rs
  • rust/src/cost_scanner.rs
  • rust/src/cost_scanner/claude_roots.rs
  • rust/src/cost_scanner/tests.rs
  • rust/src/cost_scanner/tests/claude_cowork.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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
Finesssee merged commit 71c387d into main Oct 21, 2026
3 checks passed
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