Skip to content

perf(api): Paginate conversation event history#1017

Open
sentry-junior[bot] wants to merge 21 commits into
mainfrom
perf/dashboard-transcript-deltas
Open

perf(api): Paginate conversation event history#1017
sentry-junior[bot] wants to merge 21 commits into
mainfrom
perf/dashboard-transcript-deltas

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Conversation transcripts now use bounded, cursor-based REST resources instead
of repeatedly loading the complete event history:

  • GET /api/conversations/:id returns mutable metadata, the latest bounded
    event page, and cursors for both paging directions.
  • GET /api/conversations/:id/events?before=… returns one older history page.
  • GET /api/conversations/:id/updates?cursor=… returns one forward page through
    a stable high-water mark, with hasMore when another page remains.

Cursors are signed, opaque, direction-specific, and conversation-bound. SQL
reads scan bounded canonical rows while projecting only reporting events, and
subagent pairing remains correct across page boundaries. Each resource
re-evaluates transcript retention and participant access so expired and private
histories keep the existing privacy contract.

The dashboard stores detail, backward history, and forward updates as separate
TanStack Query resources and derives one ordered transcript from their immutable
responses. Earlier pages load on demand, active conversations poll only for
forward deltas, and Markdown export drains remaining history without writing
into another resource's cache. The long mock transcript exercises the same REST
flow, including active polling, end-of-history behavior, and complete export.

Requested by David Cramer via Junior.

--

View Junior Session

@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview Jul 24, 2026 11:57pm

Request Review

Comment thread packages/junior-dashboard/src/client/api.ts Outdated
Comment thread packages/junior-dashboard/src/client/conversation-state.ts Outdated
Comment thread packages/junior-dashboard/src/client/api.ts Outdated
Comment thread packages/junior-dashboard/src/client/api.ts
Comment thread packages/junior-dashboard/src/client/api.ts Outdated
Comment thread packages/junior-dashboard/src/client/conversation-state.ts Outdated
Comment thread packages/junior-dashboard/src/client/conversation-state.ts Outdated
sentry-junior Bot and others added 7 commits July 24, 2026 15:03
Co-Authored-By: David Cramer <david@sentry.io>
Co-Authored-By: David Cramer <david@sentry.io>
Serve bounded backward history pages and stable forward update pages through signed REST cursors. Update the dashboard to merge both directions without gaps, preserve redaction, and expose older transcript history on demand.
Cancel in-flight polling before merging older history so stale responses cannot replace newly loaded pages. Refresh per-model usage through the updates resource and merge it into the active transcript cache.
Merge fresh detail snapshots into the expanded transcript cache so focus refetches, remounts, and invalidations do not discard earlier pages.
dcramer added 4 commits July 24, 2026 15:03
Keep conversation state transitions framework-free and pass the active QueryClient from React Query hooks into cache operations.
Treat optional summary fields in the updates response as replacement data so archive and location state cannot remain stale in cached detail.
Load all older REST event pages before copying Markdown and merge them without overwriting newer live state. Only show event-derived totals once the transcript is complete.
Comment thread packages/junior-dashboard/src/client/conversation-state.ts Outdated
Refresh the REST detail anchor after an invalid history cursor, update only the paging cursor in the live cache, and continue the requested page read.
Comment thread packages/junior-dashboard/src/client/api.ts Outdated
Keep an absent previousCursor absent when forward-update recovery refreshes detail, while still replacing stale cursors for partially loaded histories.
Comment thread packages/junior-dashboard/src/client/conversation-state.ts Outdated
Comment thread packages/junior-dashboard/src/client/api.ts
Adopt restricted history snapshots over cached available events, and ignore late page responses after another request has completed the transcript.
Comment thread packages/junior-dashboard/src/client/conversation-state.ts Outdated
Deduplicate and sort merged event pages by canonical sequence so cursor recovery cannot leave overlapping transcript windows out of order.
Comment thread packages/junior-dashboard/src/client/api.ts Outdated
Comment thread packages/junior-dashboard/src/client/api.ts Outdated
Comment thread packages/junior-dashboard/src/client/api.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7dcd256. Configure here.

"history",
detail.data?.previousCursor,
detail.data?.eventHistory.status,
],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Detail refresh orphans loaded history

Medium Severity

The history infinite query keys on detail.previousCursor. After the conversation grows, a detail refetch (archive invalidation or cursor recovery) issues a new previousCursor for a shifted latest window, which creates a new empty history query and drops already-loaded older pages. The UI then shows only the new detail slice and can re-offer Load earlier events even after history was complete.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7dcd256. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant