Skip to content

fix: dashboard usage stats flash and disappear (#112) - #115

Merged
nutt-adam merged 1 commit into
mainfrom
fix/dashboard-usage-flash
Mar 22, 2026
Merged

fix: dashboard usage stats flash and disappear (#112)#115
nutt-adam merged 1 commit into
mainfrom
fix/dashboard-usage-flash

Conversation

@nutt-adam

@nutt-adam nutt-adam commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Server-side: /focus endpoint now omits usage from the JSON response unless ?usage=1 is explicitly requested. The fast 2s terminal poll no longer returns usage: { input_tokens: 0, ... } that overwrites real values.
  • Client-side: renderFocusView guards against writing empty usage data (defense-in-depth from earlier fix)
  • Version bump to 0.8.1

Closes #112

Test plan

  • cargo test — 362 tests pass
  • cargo clippy — clean
  • CI checks
  • Visual verification: open dashboard, click agent, confirm usage stats persist between polls

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed dashboard focus sidebar where rapid polling was overwriting token count data. The /focus endpoint no longer returns usage data by default—add ?usage=1 to explicitly request it.

The /focus endpoint now omits `usage` from the response unless ?usage=1
is explicitly requested. Previously, the fast 2s terminal poll returned
usage: { input_tokens: 0, ... } which the client rendered as zeros,
overwriting real values from the slower 30s usage poll.

Server-side: conditionally include usage in focus response
Client-side: guard renderFocusView from writing empty usage (defense-in-depth)

Closes #112

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 22, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e4cc1128-451f-4999-9ae5-8e405b8cdcbd

📥 Commits

Reviewing files that changed from the base of the PR and between 3dee293 and 8fccd6f.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • Cargo.toml
  • src/cli/serve.rs

📝 Walkthrough

Walkthrough

Version 0.8.1 fixes a bug where the /focus endpoint always returned usage statistics, causing real token values to be overwritten with zeros. The fix makes usage data optional in the response, only including it when explicitly requested via the ?usage=1 query parameter.

Changes

Cohort / File(s) Summary
Version Bump
Cargo.toml
Updated crate version from 0.8.0 to 0.8.1.
Changelog Entry
CHANGELOG.md
Added entry documenting the fix: /focus endpoint no longer includes usage by default, only when ?usage=1 is explicitly requested.
Focus Endpoint Logic
src/cli/serve.rs
Modified agent_focus_data to conditionally compute and include usage statistics in the response based on the presence of ?usage=1 query parameter. usage_data is now Some(...) only when requested, and the response JSON conditionally adds the "usage" field only when data is present.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A token count that flashed then died,
Now hides when not requested wide,
Just ask with ?usage=1 please,
And zeros won't spoil the breeze! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the main change: fixing a bug where dashboard usage stats flash and disappear.
Description check ✅ Passed The PR description covers the main changes and includes test results, but the Versioning section is incomplete (checkboxes not fully marked and SemVer choice not explicitly selected).
Linked Issues check ✅ Passed The PR successfully addresses the root cause in issue #112 by modifying the server-side /focus endpoint to omit usage unless ?usage=1 is requested, preventing zero values from overwriting real stats.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the dashboard usage stats issue: version bump, changelog entry, and server-side endpoint modification to conditionally return usage data.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dashboard-usage-flash

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 and usage tips.

Tip

Rust Clippy can be used to improve the quality of Rust code reviews.

Clippy is the official Rust linter. It provides lints to catch common mistakes and improve your Rust code.

To configure Clippy, add a clippy.toml file to your project root.

See Clippy Documentation for more details.

@nutt-adam
nutt-adam merged commit df5d60f into main Mar 22, 2026
11 checks passed
@nutt-adam
nutt-adam deleted the fix/dashboard-usage-flash branch March 22, 2026 19:10
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.

Dashboard focus sidebar: usage tokens flash then show zeros

1 participant