fix: recap pagination broken for large lists#419
Conversation
Documents 5 confirmed bugs in finops-formatting.ts that affect user-facing output: negative bytes, NaN, fractional bytes, whitespace-only queries, and truncation exceeding maxLen. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> https://claude.ai/code/session_01AfyN3rkDU7fn9G5SpZSM77
`formatBytes`: - Guard `NaN`/`Infinity` with `Number.isFinite()` → returns "0 B" - Use `Math.abs()` for log calculation to handle negative byte deltas - Clamp unit index with `Math.max(0, Math.min(...))` to prevent `units[-1]` (fractional bytes) and overflow beyond PB `truncateQuery`: - Check post-trim result for empty string → return "(empty)" - Guard `maxLen <= 0` to prevent `slice(0, negative)` leaking content - Guard `maxLen < 4` to hard-truncate without ellipsis Tests updated from documenting bugs to asserting correct behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review.
Tip: disable this comment in your organization's Code Review settings.
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (8)
✨ 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 |
- Add `offset`/`limit` params to `Recap.listTraces()`, return `{ items, total }`
- Add `--offset` CLI option with pagination-aware footer
- Remove hardcoded `slice(0, 50)` cap in TUI dialog (replaced with limit: 200)
- Sanitize inputs: clamp negative/NaN/Infinity/float to safe integers
- Fix empty-page message: show "offset past end" instead of "No recaps found"
- Include `--limit` in next-page hint when non-default
Closes #418
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- TUI sidebar: "Trace" heading → "Recap", /trace hint → /recap - TUI error message: "Trace not found" → "Recap not found" Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>



What does this PR do?
Fixes recap list pagination which was broken when there are many recaps:
listTraces()now supports{ offset, limit }pagination, returns{ items, total }--offsetoption with pagination-aware footer ("Showing 1-20 of 150")slice(0, 50)cap (replaced with limit: 200)--limitwhen non-defaultType of change
Issue for this PR
Closes #418
How did you verify your code works?
Checklist
Test Results (40 pagination tests — all pass)
Adversarial categories (26 tests):
Happy-path pagination (8 tests):
Key Changes
tracing.tslistTraces()→{ items, total }withoffset/limit+ input sanitizationtrace.ts--offsetCLI option, pagination footer, empty-page fixdialog-trace-list.tsxslice(0,50)cap →limit: 200via pagination APItracing-pagination-adversarial.test.tstracing-persistence.test.ts🤖 Generated with Claude Code