Skip to content

feat(dashboard): Open long transcripts at the read position - #2635

Merged
BYK merged 24 commits into
mainfrom
feat/dashboard-open-at-read-position
Nov 4, 2026
Merged

BYK merged 24 commits into
mainfrom
feat/dashboard-open-at-read-position

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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.

Opens at the read position Newer page loads on scroll

API

  • GET /api/conversations/:id/events takes after=<cursor> and around=<cursor> as well as before=<cursor>. An after page holds the earliest events after the cursor. An around page ends half of its events with the cursor event, and the rest follow it. Both have a nextCursor when newer events follow. An around page also has a previousCursor when older events come before it.
  • Conversation detail has an unreadCursor when the viewer's read position is older than events. 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=true also returns the around page of unreadCursor as unreadPage. 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)

  • When the fetched detail has an 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.
  • The app shell owns the open Conversation's data and passes it to the page. It fetches once at the start of each visit, also when the cached copy is fresh, and only that fetch asks for unreadPage. Polls do not ask. If detail comes without the page, an around request reads it.
  • A cached transcript stays on screen, with no marker, no earlier-page loads, and no read reports, until this visit's fetch tells where to open and the unread page is there.
  • Newer pages load when the reader scrolls near the end, the same way as earlier pages. The latest page joins only after they reach it, so the transcript has no gap. Until then, the transcript ends with "Show newer messages", no thinking row, and sends wait in the queue.
  • Jump to latest, a send, or the mobile keyboard skips the newer pages. The transcript shows the latest page at once, and earlier pages load above it. A poll that skips past the newer pages does the same, so the transcript never drops the skipped events.
  • Earlier pages load on scroll from the read position, not from the latest page.
  • Two loads of the same page share one request. Each visit starts again from the page around the read position, so newer pages from an earlier visit do not come back.
  • A linked event, Turn, or memory outside the loaded pages loads one page at a time toward it.
  • Without a cursor, with the "Latest message" preference, or when the first page fails, nothing changes.

Server cost

  • Detail polls: no new query. The read position now reads in parallel with the other detail reads, not after them.
  • Open far behind: one request, also on a direct load. Detail reads the around page (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 separate around request.
  • Each newer page costs the same as an earlier page, and only loads when the reader reaches it. A reader who opens far behind and does not scroll reads one page more than today, in the same request. A reader who reads to the end reads the same pages as today, but from the other direction. Jump to latest reads no newer pages.

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 /events request. 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 no unreadPage, so they cover the separate around request.

Detail mocks in the other e2e specs now match the detail URL with a query string. The archive queries moved to conversationArchive.ts, so queries.ts stays under the file length limit.

Still open in #2568

  • Scrolling to the end still mounts every row from the read position to the latest. The next step caps the mounted range and adds a virtual list. TanStack maxPages on 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.
  • Linked events, Turns, and memories should open from the server with the page around them, not by a page-by-page search. That needs no new table: see the review thread.

Refs #2568

via @BYK.

--

View Session in Sentry

@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 4, 2026 10:12pm UTC

Request Review

@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.

Stale Bugbot comment from a previous run.

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

2 screenshot changes — 2 changed · 0 added · 0 removed

Review screenshots in Frameshift

Conversation Attachment · Desktop
Conversation Attachment · Desktop
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed

@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.

Stale Bugbot comment from a previous run.

@blacksmith-sh

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.

@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.

Stale Bugbot comment from a previous run.

@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.

Stale Bugbot comment from a previous run.

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

@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.

Stale Bugbot comment from a previous run.

…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.

@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.

Stale Bugbot comment from a previous run.

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]>
sentry-junior Bot and others added 2 commits November 4, 2026 20:23
…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]>
@blacksmith-sh

This comment has been minimized.

@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.

Stale Bugbot comment from a previous run.

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

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

merge conflicts

@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.

Stale Bugbot comment from a previous run.

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]>

@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.

There are 2 total unresolved issues (including 1 from previous review).

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 b0d9a57. Configure here.

Comment on lines +340 to +343
// 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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't we have a table of linked events at conversation level and not calculate this everytime??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 its turn_started event, and the existing junior_conversation_events_type_idx (conversation_id, type, seq) index finds it by reading only that Conversation's turn_started rows.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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]>
@sentry-junior

sentry-junior Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Answering your question in the first review, which I left without a reply: yes. 7160ca8 added around=<cursor>. The page ends half of its events with the cursor event, and the rest follow it, so the read events show above the "New" marker. Since 07a96c3, detail can also return that page as unreadPage (?unreadPage=true), so a reader far behind opens with one request.

@BYK
BYK enabled auto-merge (squash) November 4, 2026 22:19
@BYK
BYK merged commit 16db21b into main Nov 4, 2026
44 checks passed
@BYK
BYK deleted the feat/dashboard-open-at-read-position branch November 4, 2026 22:20
BYK added a commit that referenced this pull request Nov 5, 2026
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:

![Event
link](https://junior-prod.sentry.dev/public/artifacts/4001c111-5982-4d54-b9e3-2613f76e93c1.png)

Memory chosen in details, opened at its capture:

![Memory jump
desktop](https://junior-prod.sentry.dev/public/artifacts/d5e3e999-5061-4f7a-a031-407dbb0144b3.png)

<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]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 5d7cab39 Deployed Nov 4, 2026 by vercel[bot]
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.

2 participants