Skip to content

fix: 🐛 Fix stacked usage chart caption overflow - #1319

Merged
evaline-ju merged 1 commit into
rossoctl:mainfrom
evaline-ju:usage-pane-2
Oct 7, 2026
Merged

evaline-ju merged 1 commit into
rossoctl:mainfrom
evaline-ju:usage-pane-2

Conversation

@evaline-ju

@evaline-ju evaline-ju commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

In the usage pane's stacked chart, long series labels (model names like claude-3-5-sonnet-20241022) wrap the legend to a second line on narrow terminals. The chart's height reservation didn't account for that wrap, so the unit caption was drawn even when there was no room for it, pushing the bottom row off the terminal and scrolling the top of agentop away. The caption's budget check now measures the legend's actual rendered height instead of its one-line minimum. When the legend wraps, the caption is dropped; when it fits, the caption is kept.

Assisted-By: Claude (Anthropic AI) [email protected]

Related issue(s)

Fixes #1083

Summary by CodeRabbit

  • Bug Fixes
    • Improved stacked chart layout with long legends. Axis captions now appear at the appropriate height based on the wrapped legend, helping prevent cramped or overflowing displays at narrower widths.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Evaline Ju <[email protected]>
@evaline-ju
evaline-ju requested a review from a team as a code owner October 7, 2026 17:05
@evaline-ju evaline-ju changed the title 🐛 Fix stacked usage chart caption overflow fix: 🐛 Fix stacked usage chart caption overflow Oct 7, 2026
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a88d3e9d-a1c9-43be-a148-848a7755e77e
📥 Commits

Reviewing files that changed from the base of the PR and between 9de6574 and 5106837.

📒 Files selected for processing (3)
  • cmd/agentop/tui/layout_fit_test.go
  • cmd/agentop/tui/usage_render.go
  • cmd/agentop/tui/usage_stacked.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The stacked chart now bases its axis-caption height gate and output capacity on the rendered legend’s line count. New tests cover wrapped model-name legends at multiple widths and frame budgets.

Changes

Stacked chart layout

Layer / File(s) Summary
Caption budget and wrapped-legend tests
cmd/agentop/tui/usage_stacked.go, cmd/agentop/tui/usage_render.go, cmd/agentop/tui/layout_fit_test.go
renderStackedBarsIn renders the legend before deciding whether to show the axis caption. The caption gate and output capacity use the legend’s actual line count. Tests cover three- and five-model legends, multiple widths, and frame budgets.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: huang195

Merge Risk: ⚪ Minimal · up to 51068

The chart accounts for wrapped legends when deciding whether the caption fits. No actionable issue remains before normal merge checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #1083 requires the stacked-chart caption gate to account for wrapped legend lines and requires automated coverage for long model labels. renderStackedBarsIn now renders the legend before the c…
Out of Scope Changes check ✅ Passed The changes are limited to the stacked usage renderer, its height comment, and focused layout tests. Each change supports issue #1083 by handling wrapped legends or verifying caption and row-budget be…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: fixing caption overflow in the stacked usage chart. The fix: prefix and bug emoji add minor noise but do not reduce clarity.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@evaline-ju evaline-ju added the ready-for-ai-review Request automated AI code review from clawgenti label Oct 7, 2026

@clawgenti clawgenti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The fix is correct: rendering the legend before the caption gate lets axisCaptionIn see the wrapped legend's real height, and the new table-driven test pins the wrap arithmetic across widths and budgets. All CI green, DCO signed, no security concerns.

  • nit: commit subject :bug: Fix stacked usage chart caption overflow starts with an emoji rather than a conventional prefix (e.g. Fix:) — advisory per repo commit conventions; the PR title itself passes the verifier.

Reviewed by clawgenti using the github-pr-review skill

@evaline-ju evaline-ju added ready-for-human-review AI review passed, ready for human reviewer and removed ready-for-ai-review Request automated AI code review from clawgenti labels Oct 7, 2026

@mrsabath mrsabath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The fix is exact: hoisting the legend render above the caption gate gives axisCaptionIn the wrapped legend's real line count, so frameFloor = barChartFloor + 1 + len(legend) matches the emitted rows, and the caption appears only when the budget covers it — height >= frameFloor+1 — never one row past the pane. The old stackedChartFloor stays as the documented minimum and the test-side lower bound, which is the right home for it now that the gate is dynamic.

Verified the new test discriminates: at the pinned budgets (16 for three wrapped names, 17 for five) the pre-fix gate emitted the caption and overran by one row, so this fails on the old code rather than only passing on the new. The wrap-count fixtures match renderLegendIn's cost model, and renderLegendIn is pure over its inputs, so hoisting the call ahead of the plot loop is order-safe.

CI green, DCO signed, closes #1083.

@evaline-ju
evaline-ju merged commit 3ffff10 into rossoctl:main Oct 7, 2026
30 checks passed
@evaline-ju
evaline-ju deleted the usage-pane-2 branch November 3, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human-review AI review passed, ready for human reviewer

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Fix: Usage pane caption overflows the terminal when the stacked legend wraps

3 participants