Skip to content

fix: add pagination support for recap trace list#596

Open
VJ-yadav wants to merge 2 commits intoAltimateAI:mainfrom
VJ-yadav:fix/recap-pagination
Open

fix: add pagination support for recap trace list#596
VJ-yadav wants to merge 2 commits intoAltimateAI:mainfrom
VJ-yadav:fix/recap-pagination

Conversation

@VJ-yadav
Copy link
Copy Markdown

@VJ-yadav VJ-yadav commented Mar 30, 2026

Summary

Fixes #418 — recap pagination broken for large lists.

  • TUI dialog: removed hardcoded .slice(0, 50) cap so all traces are accessible via the dialog's built-in scrolling
  • CLI --offset option: added --offset flag to trace list command, enabling navigation past the first page
  • listTracesPaginated(): added paginated variant of listTraces() that returns { traces, total, offset, limit } metadata, used by the CLI handler
  • Pagination footer: CLI output now shows "Showing X-Y of N" with a next-page hint when more results exist
  • Empty page clarity: offset-past-end now says "No traces on this page (offset N past end of M traces)" instead of the misleading "No traces found"

Test Plan

  • altimate-code trace list — shows first 20 traces with "Showing 1-20 of N" footer
  • altimate-code trace list --limit 5 — shows 5 traces with next-page hint
  • altimate-code trace list --offset 5 --limit 5 — shows traces 6-10
  • altimate-code trace list --offset 9999 — shows "offset past end" message, not "No traces found"
  • altimate-code trace list with 0 traces — shows "No traces found" with setup hint
  • TUI trace dialog — can scroll through all traces (no 50-item cap)
  • altimate-code trace view <bad-id> — fallback list shows pagination metadata

Checklist

Summary by CodeRabbit

  • New Features
    • Added pagination support for trace listing with configurable offset and limit parameters
    • Trace list output now displays pagination metadata ("Showing X–Y of total") and next page guidance when more results exist
    • Added --offset option to trace commands for navigating paginated results
    • Trace list dialog now displays all available traces without truncation

- Add `listTracesPaginated()` method to Trace class returning page of
  traces with total count, offset, and limit metadata
- Add `--offset` CLI option to `trace list` command for navigating
  past the first page of results
- Wire CLI handler to use `listTracesPaginated()` instead of manual
  array slicing
- Remove hardcoded `.slice(0, 50)` cap in TUI dialog so all traces
  are accessible via built-in scrolling
- Show "Showing X-Y of N" pagination footer with next-page hint
- Distinguish empty results (no traces exist) from offset-past-end
  (offset exceeds total count) with clear messaging

Closes AltimateAI#418

Co-Authored-By: Vijay Yadav <vijay@studentsucceed.com>
Copy link
Copy Markdown

@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 pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions
Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

These changes add pagination support to the trace listing feature. A new listTracesPaginated method provides offset/limit parameters with defaults, the CLI command gains --offset support and pagination display, and the TUI dialog removes its hardcoded 50-item limit.

Changes

Cohort / File(s) Summary
Core Pagination Support
packages/opencode/src/altimate/observability/tracing.ts
Added listTracesPaginated() static method that wraps listTraces() with pagination parameters (offset defaults to 0, limit defaults to 20 and clamps to minimum 1), returning paginated results with total count and normalized offset/limit.
CLI Pagination Integration
packages/opencode/src/cli/cmd/trace.ts
Updated listTraces() function to accept pagination metadata object instead of flat array; now distinguishes between "no traces available" and "no traces on this page"; added pagination footer display ("Showing X–Y of total") and next-page command hint; added --offset numeric CLI option; trace list command now calls listTracesPaginated() with offset/limit parameters.
TUI Display Limit Removal
packages/opencode/src/cli/cmd/tui/component/dialog-trace-list.tsx
Removed hardcoded items.slice(0, 50) limit; trace list dialog now renders all provided items instead of truncating to first 50.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Pagination hops with grace,
No more fifty-item space!
Offset, limit, totals shown—
Through the traces, we have flown!
Now each page finds its sweet place.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding pagination support for the recap trace list, which is the primary objective of this PR.
Linked Issues check ✅ Passed All four coding objectives from issue #418 are addressed: TUI dialog cap removed, CLI --offset added, listTracesPaginated() API created, and empty-page messaging improved with pagination footer.
Out of Scope Changes check ✅ Passed All changes are within scope of issue #418: modifications to tracing.ts, trace CLI command, and TUI dialog are all directly related to implementing pagination support.
Description check ✅ Passed The pull request description is comprehensive and well-structured, covering the summary of changes, a detailed test plan with specific scenarios, and a complete checklist.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/opencode/src/altimate/observability/tracing.ts`:
- Around line 999-1005: The returned pagination metadata may include NaN,
fractional or infinite values for offset/limit; update the logic that computes
offset and limit in tracing.ts to first coerce inputs to finite integers (use
Number.isFinite and Math.trunc), fall back to the existing defaults (0 for
offset, 20 for limit), then clamp with Math.max(0, offset) and Math.max(1,
limit) before using them for slice and returning them in the response (refer to
the offset and limit variables used in this block).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b341b9b3-16f3-4876-977b-f1b4c8a4f3fd

📥 Commits

Reviewing files that changed from the base of the PR and between 99270e5 and 28bd42b.

📒 Files selected for processing (3)
  • packages/opencode/src/altimate/observability/tracing.ts
  • packages/opencode/src/cli/cmd/trace.ts
  • packages/opencode/src/cli/cmd/tui/component/dialog-trace-list.tsx

Coerce offset/limit to finite integers via Number.isFinite and
Math.trunc before using them for slice and returning in metadata.
Prevents NaN, fractional, or infinite values from producing invalid
display ranges.

Co-Authored-By: Vijay Yadav <vijay@studentsucceed.com>
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

1 participant