Skip to content

Draft: Add filtered token usage views - #1

Draft
vincepr wants to merge 1 commit into
mainfrom
draft/token-usage-views
Draft

Draft: Add filtered token usage views#1
vincepr wants to merge 1 commit into
mainfrom
draft/token-usage-views

Conversation

@vincepr

@vincepr vincepr commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

Explores token accounting as alternate views over the sessions already discovered and filtered by sfind. This is a preserved draft, not merge-ready work.

Changes

  • Adds normalized per-session, per-model token usage for Codex, OpenCode, and Claude Code.
  • Reads OpenCode recorded costs while leaving unavailable Codex and Claude costs unknown.
  • Adds an internal cost-provider boundary for later pricing implementations.
  • Cycles Tab through Continue, Fork, Usage, and Graph modes.
  • Aggregates the Usage view over sessions matching the current text, date, and provider filters.
  • Adds a graph approximation that assigns each session lifetime usage to its last-activity timestamp.
  • Splits selected date ranges into width-aware minute, hour, day, and longer intervals.
  • Stacks model usage with stable colors and groups the long tail into Other.
  • Adds provider parsing, aggregation, mode, interval, and model-grouping regression tests.

Verification

  • cargo test passed after the latest graph implementation.
  • git diff --check main...HEAD passes.
  • The full required fmt check, Clippy, and documentation suite was run before the final graph refactor, but has not been rerun against this exact snapshot.

Risks/Notes

Remaining work before this should be considered mergeable:

  • Run cargo fmt -- --check, cargo test, cargo clippy --all-targets --all-features -- -D warnings, and cargo doc --no-deps against the final snapshot.
  • Update the README wording for sub-day intervals, stacked model colors, and Other grouping.
  • Manually validate the TUI with real Codex, OpenCode, and Claude data on narrow and wide terminals.
  • Review stacked-bar rounding, legends on low-height terminals, interval labels, and empty buckets.
  • Reassess whether the graph approximation is useful enough: it assigns full session totals to last activity and is not true event-level history.
  • Review Codex fork/replay behavior because copied usage history can inflate per-session aggregate totals.
  • Decide whether to keep this implementation or use it only as reference for a smaller redesign.

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