fix: add pagination support for recap trace list#596
fix: add pagination support for recap trace list#596VJ-yadav wants to merge 2 commits intoAltimateAI:mainfrom
Conversation
- 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>
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
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. |
📝 WalkthroughWalkthroughThese changes add pagination support to the trace listing feature. A new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
packages/opencode/src/altimate/observability/tracing.tspackages/opencode/src/cli/cmd/trace.tspackages/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>
Summary
Fixes #418 — recap pagination broken for large lists.
.slice(0, 50)cap so all traces are accessible via the dialog's built-in scrolling--offsetoption: added--offsetflag totrace listcommand, enabling navigation past the first pagelistTracesPaginated(): added paginated variant oflistTraces()that returns{ traces, total, offset, limit }metadata, used by the CLI handlerTest Plan
altimate-code trace list— shows first 20 traces with "Showing 1-20 of N" footeraltimate-code trace list --limit 5— shows 5 traces with next-page hintaltimate-code trace list --offset 5 --limit 5— shows traces 6-10altimate-code trace list --offset 9999— shows "offset past end" message, not "No traces found"altimate-code trace listwith 0 traces — shows "No traces found" with setup hintaltimate-code trace view <bad-id>— fallback list shows pagination metadataChecklist
listTracesPaginatedclamps offset/limit to safe valuesSummary by CodeRabbit
--offsetoption to trace commands for navigating paginated results