Repository navigation
fix: 🐛 Fix stacked usage chart caption overflow - #1319
Conversation
Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Evaline Ju <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe 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. ChangesStacked chart layout
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Suggested reviewers: Merge Risk: ⚪ Minimal · up to 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)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
clawgenti
left a comment
There was a problem hiding this comment.
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 overflowstarts 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
mrsabath
left a comment
There was a problem hiding this comment.
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.
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