Repository navigation
Add live token stopwatch and versioning - #2
Merged
Merged
Conversation
There was a problem hiding this comment.
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/photkeys and mouse interaction. - Implements a local
LiveUsageReaderthat discovers and incrementally consumestoken_countJSONL records from$CODEX_HOME/sessions, plus accompanying tests. - Establishes semantic versioning via
internal/versionand 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 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 |
Owner
Author
Comment on lines
+115
to
+116
| } else if err := r.discover(ctx, now, forceFullDiscovery || now.Sub(r.lastFullDiscovery) >= fullDiscoveryEvery); err != nil { | ||
| return LiveUsageSnapshot{}, err |
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
g/photkeystoken_counttelemetry from local Codex rollout JSONL files and measures deltas across locally active sessionsv0.1.0with-vand--version, tagged-build detection, and a linker-overridable source fallbackWhy
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 ./...-v,--version, and linker-overridden version output