Skip to content

fix: recap pagination broken for large lists#419

Closed
anandgupta42 wants to merge 9 commits intomainfrom
claude/test-finops-formatting-01AfyN3rkDU7fn9G5SpZSM77
Closed

fix: recap pagination broken for large lists#419
anandgupta42 wants to merge 9 commits intomainfrom
claude/test-finops-formatting-01AfyN3rkDU7fn9G5SpZSM77

Conversation

@anandgupta42
Copy link
Contributor

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 }
  • CLI gets --offset option with pagination-aware footer ("Showing 1-20 of 150")
  • TUI dialog removed hardcoded slice(0, 50) cap (replaced with limit: 200)
  • Input sanitization: NaN, Infinity, negatives, floats all handled safely
  • Empty page shows "offset past end" instead of misleading "No recaps found"
  • Next-page hint preserves custom --limit when non-default

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Issue for this PR

Closes #418

How did you verify your code works?

  • 383 tests pass across 14 tracing test files (0 failures)
  • 26 new adversarial tests covering: boundary values, NaN/Infinity/floats, sort stability, corrupted files, concurrent mutations (TOCTOU), non-JSON files, startedAt edge cases
  • 8 new happy-path pagination tests covering: offset, limit, offset+limit, backward compat
  • Typecheck passes
  • 6-model consensus code review (Claude + GPT 5.2 Codex + Gemini 3.1 Pro + Kimi K2.5 + MiniMax M2.5 + GLM-5)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • New and existing unit tests pass locally with my changes

Test Results (40 pagination tests — all pass)

Adversarial categories (26 tests):

  • Boundary values (offset=0/limit=0, negative, MAX_SAFE_INTEGER, offset=total)
  • Non-integer/special values (NaN, Infinity, -Infinity, floats)
  • Sort stability (identical timestamps across pages)
  • Corrupted files (excluded from total, all corrupted, non-TraceFile JSON)
  • Non-JSON files (ignored by readdir filter)
  • startedAt edge cases (far future/past, sort order across pages)
  • Concurrent mutations (file deleted/added between page requests)
  • Minimal cases (single trace, empty directory)

Happy-path pagination (8 tests):

  • limit, offset, offset+limit, offset beyond total, full page coverage, backward compat, limit > total, offset-only

Key Changes

File Change
tracing.ts listTraces(){ items, total } with offset/limit + input sanitization
trace.ts --offset CLI option, pagination footer, empty-page fix
dialog-trace-list.tsx Removed slice(0,50) cap → limit: 200 via pagination API
tracing-pagination-adversarial.test.ts 26 new adversarial tests
tracing-persistence.test.ts Updated for new return type + 8 pagination tests

🤖 Generated with Claude Code

claude and others added 3 commits March 23, 2026 01:16
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>
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

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

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.

@coderabbitai
Copy link

coderabbitai bot commented Mar 23, 2026

Warning

Rate limit exceeded

@anandgupta42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 54 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a15659d1-6d4b-48c8-9ac8-f0af5d112618

📥 Commits

Reviewing files that changed from the base of the PR and between 8e11c7f and d4a3fce.

⛔ Files ignored due to path filters (3)
  • docs/assets/pagination-changes.png is excluded by !**/*.png
  • docs/assets/pagination-demo.png is excluded by !**/*.png
  • docs/assets/pagination-tests.png is excluded by !**/*.png
📒 Files selected for processing (8)
  • packages/opencode/src/altimate/observability/tracing.ts
  • packages/opencode/src/cli/cmd/trace.ts
  • packages/opencode/src/cli/cmd/tui/app.tsx
  • packages/opencode/src/cli/cmd/tui/component/dialog-trace-list.tsx
  • packages/opencode/src/cli/cmd/tui/routes/session/sidebar.tsx
  • packages/opencode/test/altimate/tracing-pagination-adversarial.test.ts
  • packages/opencode/test/altimate/tracing-persistence.test.ts
  • packages/opencode/test/altimate/tracing.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/test-finops-formatting-01AfyN3rkDU7fn9G5SpZSM77

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.

anandgupta42 and others added 3 commits March 23, 2026 15:47
- 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>
@anandgupta42
Copy link
Contributor Author

anandgupta42 commented Mar 24, 2026

Screenshots

Pagination in Action (35 recaps across 3 pages)

pagination-demo

Test Results (40 pagination tests — all pass)

pagination-tests

Key Code Changes

pagination-changes

anandgupta42 and others added 3 commits March 23, 2026 17:25
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>
@anandgupta42 anandgupta42 deleted the claude/test-finops-formatting-01AfyN3rkDU7fn9G5SpZSM77 branch March 25, 2026 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: recap pagination broken for large lists

2 participants