Skip to content

Add live token stopwatch and versioning - #2

Merged
merefield merged 1 commit into
mainfrom
agent/add-stopwatch-and-versioning
Aug 11, 2026
Merged

merefield merged 1 commit into
mainfrom
agent/add-stopwatch-and-versioning

Conversation

@merefield

Copy link
Copy Markdown
Owner

What changed

  • adds a responsive Stopwatch presentation with clickable Go and Stop controls and g/p hotkeys
  • reads cumulative token_count telemetry from local Codex rollout JSONL files and measures deltas across locally active sessions
  • renders a scrolling, automatically scaled 30-second vertical block-bar chart
  • adds a red recording lamp that pulses between muted and highlighted red
  • forces full local-session discovery on Stop, tolerates individual unreadable rollouts, expires inactive session counts, and preserves the newest activity timestamp
  • documents the local-only scope, privacy behavior, platform considerations, controls, and troubleshooting
  • establishes semantic versioning at v0.1.0 with -v and --version, tagged-build detection, and a linker-overridable source fallback

Why

The account activity summary is delayed and does not provide a useful live interval counter. Codex already persists the token telemetry underlying its live token-usage events in local rollout files, so Codexometer can establish a baseline and report newly observed local usage without invoking a model or converting raw tokens into misleading quota percentages.

User impact

Users can switch to Stopwatch, press Go, work across one or more local Codex sessions, and press Stop for a fresh aggregate token reading. The graph provides a compact visual history without assuming a token ceiling. Existing quota presentations and authentication behavior are unchanged.

Validation

  • go test -race -cover ./...
  • go vet ./...
  • local Linux build
  • cross-builds for Linux, macOS, and Windows on amd64 and arm64
  • verified -v, --version, and linker-overridden version output

@merefield
merefield marked this pull request as ready for review August 11, 2026 12:30
@merefield
merefield requested a lite review from Copilot August 11, 2026 12:30
@merefield
merefield merged commit 8bef7fd into main Aug 11, 2026
7 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new “Stopwatch” view that reports live local token-usage deltas by tailing Codex rollout JSONL telemetry, and introduces a semantic-versioning system with -v/--version support and build-tag/linker override behavior.

Changes:

  • Adds a Stopwatch UI layout (readout + Go/Stop controls + 30s auto-scaling bar chart) with g/p hotkeys and mouse interaction.
  • Implements a local LiveUsageReader that discovers and incrementally consumes token_count JSONL records from $CODEX_HOME/sessions, plus accompanying tests.
  • Establishes semantic versioning via internal/version and updates CLI/version output + client metadata, along with README documentation.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Documents Stopwatch behavior, privacy scope, controls, troubleshooting, and versioning.
main.go Adds -v/--version, wires internal/version, and configures optional local live-usage reader.
main_test.go Updates version flag tests and asserts demo mode provides live token usage.
internal/version/version.go Introduces Current() with build-info tag detection and linker-overridable fallback.
internal/version/version_test.go Tests fallback behavior for source builds.
internal/ui/view.go Routes rendering to Stopwatch layout when styleStopwatch is selected.
internal/ui/view_test.go Adjusts view assertions for Stopwatch vs quota styles.
internal/ui/theme.go Adds the Stopwatch meter style name/ID.
internal/ui/stopwatch.go Implements Stopwatch rendering, formatting helpers, and hit-testing.
internal/ui/stopwatch_test.go Adds comprehensive UI/state lifecycle tests for Stopwatch behavior.
internal/ui/model.go Adds stopwatch state machine, tick sampling, live-usage fetch plumbing, and hotkeys.
internal/ui/meters.go Excludes Stopwatch from meter-grid rendering path.
internal/ui/meters_test.go Updates meter-style loops to exclude Stopwatch where appropriate.
internal/codex/types.go Removes legacy Version variable.
internal/codex/live_usage.go Adds local rollout discovery + incremental JSONL consumption for token usage.
internal/codex/live_usage_test.go Adds tests covering baselining, discovery modes, resets, cancellation, and parsing.
internal/codex/client.go Adds optional local live-usage fetch methods and updates clientInfo version reporting.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/ui/stopwatch.go
Comment on lines +266 to +269
footer := m.renderFooter(contentWidth, colors)
reservedHeight += lipgloss.Height(footer)
area := m.renderStopwatchArea(contentWidth, max(contentHeight-reservedHeight, 1), colors)
localX, localY := x-2, y-originY

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Follow-up PR #3 extracts pure dashboard/Stopwatch geometry and reuses it for both rendering and hit-testing, so mouse motion no longer renders the full view or Stopwatch graph: #3

Comment on lines +115 to +116
} else if err := r.discover(ctx, now, forceFullDiscovery || now.Sub(r.lastFullDiscovery) >= fullDiscoveryEvery); err != nil {
return LiveUsageSnapshot{}, err

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Follow-up PR #3 keeps one-second consumption for known rollout cursors, throttles recent-session discovery to five seconds and full-tree discovery to five minutes, and retains forced full discovery on Stop: #3

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.

2 participants