Skip to content

fix(cli): always show context usage bar in status panel#242

Merged
xinhuagu merged 1 commit into
mainfrom
fix/context-usage-always-visible
Mar 13, 2026
Merged

fix(cli): always show context usage bar in status panel#242
xinhuagu merged 1 commit into
mainfrom
fix/context-usage-always-visible

Conversation

@xinhuagu

@xinhuagu xinhuagu commented Mar 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Context usage bar (14/200K (0%)) disappeared from status panel because the condition required latestInputTokens > 0
  • Before first turn or when tokens are 0, the bar was hidden — user loses visibility into context window capacity
  • Removed the latestInputTokens > 0 guard so the bar always shows when context window size is known

One-line fix: ctxWindow > 0 && latestInputTokens > 0ctxWindow > 0

Test plan

  • All CLI tests pass
  • Manual: start fresh session, verify 0/200K (0%) shows immediately

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced terminal REPL status display to reliably show token usage information whenever a context window is available, with more robust percentage calculations.

… is known

The condition `ctxWindow > 0 && latestInputTokens > 0` hid the context
usage bar before the first turn and whenever tokens were 0. Show it
whenever the context window size is known so the user always sees
remaining capacity.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@greptile-apps greptile-apps Bot 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.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai

coderabbitai Bot commented Mar 13, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: aca21ac3-467f-4abd-98fe-55e26cb858d3

📥 Commits

Reviewing files that changed from the base of the PR and between e805e6d and cd9773d.

📒 Files selected for processing (1)
  • aceclaw-cli/src/main/java/dev/aceclaw/cli/TerminalRepl.java

📝 Walkthrough

Walkthrough

The condition for rendering token usage information in the status string is modified to display whenever the context window is non-zero, rather than requiring both context window and latest input tokens to be positive. The percentage calculation is explicitly guarded against division by zero.

Changes

Cohort / File(s) Summary
Token Usage Display Logic
aceclaw-cli/src/main/java/dev/aceclaw/cli/TerminalRepl.java
Modified buildStatusString method to render token usage when context window is non-zero, independent of latest input token count. Added explicit ternary guard for percentage calculation to safely handle zero latest input tokens.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: making the context usage bar always visible in the status panel by adjusting the display condition.
Block Major Correctness And Security Risks ✅ Passed PR safely displays context usage bar before first turn by removing latestInputTokens check while maintaining division-by-zero protection.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/context-usage-always-visible
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@xinhuagu xinhuagu merged commit fdbc09f into main Mar 13, 2026
3 of 4 checks passed
@xinhuagu xinhuagu deleted the fix/context-usage-always-visible branch March 13, 2026 23:18
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