Repository navigation
feat(dashboard): Open long transcripts at the read position - #2635
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
2 screenshot changes — 2 changed · 0 added · 0 removed Review screenshots in Frameshift
|
This comment has been minimized.
This comment has been minimized.
When the read position is older than the latest page, Conversation detail returns an unreadCursor. The events API pages forward with after. The dashboard opens at the read position, loads newer pages in the background until they reach the latest page, and loads earlier pages on scroll from there. Refs #2568
…ned events A cache from a visit that read to the end has no unread cursor. The first fetched detail now supplies it, and the cached transcript stays until the unread pages load. Events that new events push out of the latest page now stay in the transcript, so the latest page does not unjoin after catch-up.
7a59c41 to
268b9b4
Compare
BYK
left a comment
There was a problem hiding this comment.
GET /api/conversations/:id/events takes after= as well as before=. An after page holds the earliest events after the cursor. It has a nextCursor when newer events follow, and a previousCursor when older events come before it.
We should also probably have an "around=" for this?
…t-read-position # Conflicts: # packages/junior-dashboard/src/client/conversations/ConversationPage.tsx
Co-Authored-By: BYK <[email protected]>
…ng rows Read the latest page alone, not the transcript joined with cached earlier pages, and not the deferred copy that lags the fetched read cursor. Withhold inline sends while newer pages load. Memory jumps use the shown history and wait for newer pages before they look back.
The transcript does not end at the latest event until newer pages join, so an inline send has no place there. Keep it in the composer queue.
The app shell started its own detail fetch on a direct load. The page's first fetch joined it and lost ?unreadPage=true, so far-behind readers paid a second, serial around request. The shell now reads the title from the cache without fetching. Co-Authored-By: BYK <[email protected]>
…t-read-position # Conflicts: # packages/junior-dashboard/src/client/conversations/ConversationPage.tsx # packages/junior-dashboard/src/client/conversations/ConversationSidebar.tsx # packages/junior-dashboard/src/client/conversations/ConversationWorkspace.tsx # packages/junior-dashboard/src/client/conversations/conversationArchive.ts # packages/junior-dashboard/src/client/conversations/queries.ts # packages/junior/src/api/conversations/detail.ts # packages/junior/src/api/conversations/routes.ts # packages/junior/src/api/schema.ts Co-Authored-By: BYK <[email protected]> Co-Authored-By: BYK <[email protected]>
This reverts commit d156e15. The page mounts only after the dashboard core data loads, so the shell's early fetch is what runs the detail in parallel with it. Without it, every direct load waits one more round trip for the detail, to save an around request only for far-behind readers. It also made the offline reconnect e2e test flaky. Co-Authored-By: BYK <[email protected]> Co-Authored-By: BYK <[email protected]>
This comment has been minimized.
This comment has been minimized.
Two loads of the same history page now join one request. fetchNextPage cancelled the read in flight and started it again, so a linked-event search and a scroll, or gap reconciliation and auto-load, read the same page twice. The shell's detail fetch now asks for the unread page too. On a direct load the page joins that fetch, so it no longer needs a separate around request. Co-Authored-By: BYK <[email protected]> Co-Authored-By: BYK <[email protected]>
Newer pages stayed cached after a visit. A later visit with the same unread cursor restored them, and the last one could end at an old latest event, which left a gap before the latest page.
…t-read-position # Conflicts: # packages/junior/src/api/schema/conversation.ts
The shell now owns the open Conversation's data, and the page reads it. Before, the page made its own fetch when it mounted. On a direct load the shell's fetch had often ended by then, so the detail and its unread page were read twice. A fetch at the start of each visit replaces refetchOnMount. The shell's hook stays mounted across Conversations, and the 30s default staleTime would skip the reopen fetch. Co-Authored-By: BYK <[email protected]> Co-Authored-By: BYK <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b0d9a57. Configure here.
| // A linked event, Turn, or memory can be outside the loaded pages. Look | ||
| // for it one page at a time, in the direction where it can be. | ||
| const historyRef = useRef(history); | ||
| historyRef.current = history; |
There was a problem hiding this comment.
Shouldn't we have a table of linked events at conversation level and not calculate this everytime??
There was a problem hiding this comment.
Agreed, the client should not hunt for the target one page at a time. That search was already on main for earlier pages; this PR only added the newer direction.
I don't think we need a new table, because each link already resolves to one seq on the server:
- Event links carry their seq.
- Turn and memory links carry a
turnId. A Turn starts at itsturn_startedevent, and the existingjunior_conversation_events_type_idx(conversation_id, type, seq)index finds it by reading only that Conversation'sturn_startedrows.
So the fix: the detail (or the events API) accepts the link target, for example ?event=<seq> or ?turn=<turnId>. It returns the page around it, with a signed cursor, in the same way as unreadPage. The client then opens there through the same around-page path that this PR uses for the read position. No page-by-page search, and no loadToward/nextHistorySearch.
I put the choice between doing this here and in a follow-up on the review desk, because you already approved.
There was a problem hiding this comment.
Done in #2727. Memories in the details pane come from the whole Conversation, so they get their seqs in bulk: the memory list now returns each recall's and capture's seq, with no extra query. Event and Turn links point to one row each, so the events API now takes event=<seq> and turn=<turnId> and returns the page around that row in one request. The client no longer pages toward a link.
… pages A poll can skip more than one latest page after the unread pages join it, or past an unread page with nothing after it. The transcript then joined the new latest events onto older pages and left a gap. Now it switches to the latest page, like jump to latest, and earlier pages load above it. Co-Authored-By: BYK <[email protected]>
|
Answering your question in the first review, which I left without a reply: yes. 7160ca8 added |
Follow-up to #2635, part of #2568. Answers [the linked-events review comment](#2635 (comment)). Before, a link to an event, Turn, or memory outside the loaded rows paged the transcript one page at a time until it found the row. Now the server gives the row position, and the client makes one request. ## Design - **Memories (details pane, whole Conversation):** these come in bulk. Each recall and capture in the memory list now has its event `seq`. The list already reads those events, so this adds no query. A memory jump opens at that seq. - **Event and Turn links (shared URL, review desk):** `GET /api/conversations/:id/events` also takes `event=<seq>` and `turn=<turnId>` and returns the same page that `around` returns for that row. - `event` adds no query. It uses the same seq page read and access checks as `around=<cursor>`. - `turn` adds one lookup on the `(conversation_id, type, seq)` index, over this Conversation's `turn_started` rows. An unknown Turn returns 404 and the dashboard drops the link. - **Client:** if the loaded rows don't hold a link's row, `useHistoryAround` (renamed from `useUnreadHistory`) opens at the page around it, the same way it opens at the read position. Jump to latest clears the link, and a link page that fails is dropped. The page-by-page search (`nextHistorySearch` / `loadToward`) is gone. - **Scroll fix:** a link at open now sets the first scroll position. Before, bottom pinning ran after the event log showed the linked row and scrolled the row out of view. No bulk mapping for event and Turn links. Each one points to one row, and an event link already has its seq in the URL. Only the Memories section shows targets from the whole Conversation, and it gets them in bulk. ## Tests - Integration: `event-list.test.ts` gets "opens the page around a linked event or Turn" (event page, Turn page, unknown Turn 404). The memory REST test covers `seq` and seq order. - E2e (`conversations-read-position.spec.ts`): event and Turn links outside the loaded rows each make one link request, and the row is in the event log viewport. A memory outside the loaded rows opens with one `event` request. - Full dashboard e2e (90/90), dashboard unit tests, `tsc` for `junior`, `junior-memory`, and `junior-dashboard`, oxlint, and `file-length:check` pass. ## Screenshots Event link (`?event=70`) outside the loaded rows:  Memory chosen in details, opened at its capture:  <img alt="Memory jump mobile" src="https://junior-prod.sentry.dev/public/artifacts/5ce366e9-abc8-4452-a31b-7d89523ff277.png" width="320"> ## Next for #2568 Virtualize the event log, then the transcript. `@tanstack/react-virtual` only picks and measures rows; bottom pinning keeps control of `scrollTop`. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:local%3Aweb%3A735c6e48f79c0c925da15893 --> -- [View Session in Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A735c6e48f79c0c925da15893/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]> Co-authored-by: BYK <[email protected]>

First step of #2568: cap how far toward the present the first load goes.
Today a reader whose read position is older than the latest 500 events opens at the latest page. The "New" marker shows at the top of the loaded rows, not at the first unread row, and the reader has to scroll back through every page to get there.
API
GET /api/conversations/:id/eventstakesafter=<cursor>andaround=<cursor>as well asbefore=<cursor>. Anafterpage holds the earliest events after the cursor. Anaroundpage ends half of its events with the cursor event, and the rest follow it. Both have anextCursorwhen newer events follow. Anaroundpage also has apreviousCursorwhen older events come before it.unreadCursorwhen the viewer's read position is older thanevents. It is a normal signed cursor at the read position. It comes from the read position that detail already reads, so detail runs no extra query.GET /api/conversations/:id?unreadPage=truealso returns thearoundpage ofunreadCursorasunreadPage. Without the flag, or without a cursor, detail reads no extra page. If that page read fails, detail still returns without it.Dashboard (new
transcriptUnreadHistory.ts)unreadCursor, and the reader opens at unread (the default), the transcript starts with the page around the read position, so the last read events show above the marker. It opens at the "New" marker as usual.unreadPage. Polls do not ask. If detail comes without the page, anaroundrequest reads it.Server cost
aroundpage (two half pages in parallel) next to its mention lookup. That is one round trip, one conversation read, and one access read fewer than a separatearoundrequest.The read-position journeys moved to
conversations-read-position.spec.ts, because the mobile spec went over the file length limit. The far-behind journey loads the page directly, 120 events behind the latest page. The page opens at the first unread row with the read events above it. Only the first detail request asks for the unread page, and it makes no/eventsrequest. No newer page loads before the reader scrolls, and the latest page waits until the newer pages reach it. The pages before the latest page are never read. A poll that skips more than a page opens the latest page without a gap. The cached-reopen journey checks that the reopen fetch asks for the unread page. The other read-position journeys get nounreadPage, so they cover the separatearoundrequest.Detail mocks in the other e2e specs now match the detail URL with a query string. The archive queries moved to
conversationArchive.ts, soqueries.tsstays under the file length limit.Still open in #2568
maxPageson these queries is a natural fit. This also covers the layout cost that fix(dashboard): Stop transcript jumps while scrolling up on mobile #2634 adds back on phones.Refs #2568
via @BYK.
--
View Session in Sentry