Skip to content

perf(dashboard): Move the feed token only on what a live Turn shows - #2994

Merged
BYK merged 1 commit into
mainfrom
perf/versions-list-refetch
Nov 9, 2026
Merged

BYK merged 1 commit into
mainfrom
perf/versions-list-refetch

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

After #2922, 35% of /api/versions polls in prod (0.287.0) still refetched the list. With a live Turn open it was 61–74%.

Cause

The feed token hashed each root's last_activity_at. Every Event in a live Turn moves it: turn_started, each assistant_message, tool_execution_started and tool_result, checkpoints, and turn_completed. So each poll during a Turn moved conversations.

I reproduced it locally with a real web Turn (fake model, 20 tool steps 3s apart) and the versions poll every 5s. conversations moved on 13 of 13 polls, and last_activity_at changed each time. Only 2 of those polls had a new Message, 2 a status change, and 1 a title change.

reviewItems never moved during the Turn. It still refetches the list, because waiting Conversations outside the first page join the feed. The new diagnostic will show how often that happens in prod.

Change

What the feed token hashes for each row:

  • Last activity: date_trunc('minute', last_activity_at), for the root and for its nested Threads. Rows show last activity only as a whole-minute age (now, 3m, 5 minutes ago) and, while a Turn runs, a spinner. The token moves at most once a minute during a Turn, and the age is never more than one minute stale.
  • Order: rows are hashed in feed order (pinned first, then last activity), not by id. A reorder still moves the token in the same poll.
  • Preview and participants: the seq of the newest assistant Message and the newest user Message. They are two index walks per row on junior_conversation_events_message_role_idx. Before, last_activity_at stood in for both.
  • Unchanged: title, status, stopped_at, unread, pins, Threads, and annotations are hashed as before. A new reply, status, title, unread state, or pin still shows within one poll.

Diagnostic: when a versions poll moves a token, the browser sends a function span named Refresh changed reads. Its app.dashboard.versions.moved attribute lists the tokens that moved (for example conversations,reviewItems). A poll that moves nothing adds no span. A query recipe is in TELEMETRY.md.

Side effect: while a Turn runs, the list's lastSeenAt can be up to a minute stale. Archive compares lastSeenAt with the stored value, so an archive during a live Turn can return 409 "Conversation received new activity". It already could: before this change, each 5s poll window during a Turn had a new Event. Idle rows are not affected.

Measured (local Postgres 17)

Polls that refetch the list (conversations moved, since reviewItems did not move), on a live Turn of about 65s with a 5s poll:

before after
live Turn, run 1 13/13 (100%) 2/13 (15%)
live Turn, run 2 13/13 (100%) 3/13 (23%)
idle, no writes 0/20 0/20

The polls that still move are the Turn start (status and title), the Turn end (status and the reply), and one minute change. A longer Turn adds about one move per minute plus one per visible Message, so the floor is about 8% of 5s polls. The feed token doesn't depend on the open Conversation, so a live Turn in a row that isn't open gives the same numbers.

Full /api/versions poll p50 (400 polls, median of 3 interleaved runs, 50-row first page):

roots before after
50 6.2ms 7.5ms
500 7.4ms 7.4ms

That is about 1ms more per poll, for the two Message lookups. Each list refetch it avoids costs about 295ms and 24.6 queries in prod.

Tests

  • versions.test.ts:
    • starting a child agent now moves only conversation;
    • a root tool Event in the same minute moves only conversation;
    • one in the next minute also moves conversations;
    • a reply with no change to last activity still moves conversations.
  • Passed: pnpm typecheck, root pnpm lint, tests/integration/api (71 files, 209 tests), dashboard unit tests (59 files, 408 tests).

No visible UI change.

via @BYK.

--

View Session in Sentry

Every Event of a live Turn moves the root's last_activity_at, which the
feed token hashed, so each versions poll during a Turn refetched the
list. Hash the minute that the row shows as an age, the feed order, and
the newest Message of each role instead. Record which tokens a poll
moved on a browser span.

Co-Authored-By: BYK <[email protected]>
@vercel

vercel Bot commented Nov 9, 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 9, 2026 10:18am UTC

Request Review

@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Review screenshots in Frameshift

Conversation Attachment · Desktop
Conversation Attachment · Desktop
Changed
Conversation Attachment · Mobile
Conversation Attachment · Mobile
Changed
Conversation Captured Memories Popover · Desktop
Conversation Captured Memories Popover · Desktop
Changed
Conversation Create Focused · Desktop
Conversation Create Focused · Desktop
Changed
Conversation Details Watched Linked Work · Desktop
Conversation Details Watched Linked Work · Desktop
Changed
Conversation Details Watched Linked Work · Mobile
Conversation Details Watched Linked Work · Mobile
Changed
Show 5 more changed screenshots
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Stop Active · Mobile
Conversation Stop Active · Mobile
Changed
Conversations Sections Collapsed · Desktop
Conversations Sections Collapsed · Desktop
Changed
Memories · Mobile
Memories · Mobile
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed

@BYK
BYK merged commit 21b800d into main Nov 9, 2026
45 checks passed
@BYK
BYK deleted the perf/versions-list-refetch branch November 9, 2026 10:33

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 18ef8c6a Deployed Nov 9, 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.

1 participant