fix(dashboard): page traces with API next_cursor - #414
Conversation
The traces list API cursors on updatedAt and returns next_cursor as
`${updatedAt}.${id}`. Load more was sending created_at, which can skip
or repeat traces.
Fixes #412
Co-Authored-By: Duyet Le <me@duyet.net>
Co-Authored-By: duyetbot <bot@duyet.net>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR updates the dashboard traces hook to use the API-provided Sequence diagram for traces pagination using API next_cursorsequenceDiagram
actor User
participant DashboardTraces
participant useTracesData
participant API
User->>DashboardTraces: selectProject(selectedProjectId)
DashboardTraces->>useTracesData: useTracesData(selectedProjectId)
useTracesData->>useTracesData: setTraces([]), setHasMore(false), setNextCursor(null), setLoading(true)
useTracesData->>API: GET /v1/projects/:id/traces?limit=50
API-->>useTracesData: TracesListResponse(data, has_more, next_cursor)
useTracesData->>useTracesData: setTraces(data), setHasMore(has_more), setNextCursor(next_cursor), setLoading(false)
User->>DashboardTraces: clickLoadMore()
DashboardTraces->>useTracesData: loadMore()
useTracesData->>useTracesData: [loadingMore || !hasMore || !nextCursor] guard
useTracesData->>API: GET /v1/projects/:id/traces?limit=50&cursor=encodeURIComponent(nextCursor)
API-->>useTracesData: TracesListResponse(data, has_more, next_cursor)
useTracesData->>useTracesData: [projectIdRef.current === selectedProjectId]
useTracesData->>useTracesData: setTraces([...prev, ...data]), setHasMore(has_more), setNextCursor(next_cursor), setLoadingMore(false)
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reached
Next review available in: 112 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches📝 Generate docstrings
🧪 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.
Hey - I've left some high level feedback:
- Consider extracting the
TracesListResponsetype to a shared location if other hooks or components consume the same traces API response, to avoid duplication and keep the API contract centralized. - The cursor is passed through
encodeURIComponentin the URL; if yourapiutility already handles query parameter encoding, you might simplify this by delegating encoding there to avoid potential double-encoding or inconsistencies with other calls.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting the `TracesListResponse` type to a shared location if other hooks or components consume the same traces API response, to avoid duplication and keep the API contract centralized.
- The cursor is passed through `encodeURIComponent` in the URL; if your `api` utility already handles query parameter encoding, you might simplify this by delegating encoding there to avoid potential double-encoding or inconsistencies with other calls.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Compare median success duration to the 200ms pad floor instead of a single denied sample, which flakes under CI/workerd load. Co-Authored-By: Duyet Le <me@duyet.net> Co-Authored-By: duyetbot <bot@duyet.net>
|
Sourcery nits noted but left as-is:
CI flake on |
Summary
next_cursorfromGET /v1/projects/:id/tracesand send it on Load morecreated_at, which can skip or repeat traces when the list is ordered byupdatedAtFixes #412
Test plan
updatedAt.idcursor (no skips/repeats)Summary by Sourcery
Use the traces list API’s next_cursor for pagination in the dashboard and reset cursor state when switching projects.
Bug Fixes: