Skip to content

ref(api): Page review items with the shared page cursor - #3453

Merged
BYK merged 2 commits into
mainfrom
ref/review-item-page-cursor
Nov 15, 2026
Merged

BYK merged 2 commits into
mainfrom
ref/review-item-page-cursor

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

Follow-up to review feedback on #3439, and stacked on it. The review item cursor of GET /api/review-items now encodes and decodes through the shared page-cursor.ts, like the People code and feed cursors.

  • It keeps its list-binding checks: a cursor pages only the list (Conversation, for, q, sort, status) it came from, and any other cursor answers 400 with Invalid review item cursor., as before.
  • The payload stays version: 2. Only the key order inside the opaque value can change, so cursors held by tabs opened before a deploy still read their next page.
  • Responses do not change. Nothing breaks.

Retarget to main after #3439 merges.

via @BYK.

--

View Session [Sentry]

@sentry-junior
sentry-junior Bot requested a review from BYK November 14, 2026 22:23
@sentry-junior
sentry-junior Bot added this pull request to stack #3454 November 14, 2026 22:24
@vercel

vercel Bot commented Nov 14, 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 15, 2026 1:35am UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 14, 2026
Base automatically changed from feat/api-code-state-counts-people-paging to main November 15, 2026 00:00
BYK added a commit that referenced this pull request Nov 15, 2026
…ng (#3439)

The new dashboard (#3035) needs some new reads from the
Code and People APIs. This PR adds them to `main` before the new UI
ships behind its opt-in. The current UI sends none of the new params, so
it sees no change.

## What changes

- `GET /api/code/repositories/:id` takes an optional
`?state=open|merged|closed`, which lists only the changes in that state.
The response gets `changeCounts` with every change in the repository
counted by state. When there is no `state`, changes keep today's order,
newest `updated_at` first.
- Each code summary (overview, repository, person) gets `idle`: open
changes with no activity for more than `IDLE_CHANGE_DAYS` (7). It is
counted from the rows that the summary already reads, so it adds no
query.
- `GET /api/people/:email/code` takes `?cursor=` and returns
`nextCursor` when a page is full. The cursor is a keyset position on the
list order (open first, longest idle, then latest update, then `id`), so
rows that move or arrive between pages do not shift the next page. A bad
cursor answers 400.
- `src/api/page-cursor.ts` is a shared primitive that encodes and
decodes these opaque base64url JSON cursors against a zod schema. The
conversation feed cursor uses it too. The review item cursor moves onto
it in #3453.
- The state counts are part of the repository lookup (`LEFT JOIN` with
`count(*) FILTER`), so they add no round trip.
- The person scope for code changes now starts from the person's
Conversations, through the actor index, and hash-joins them with the
linked ids. Before, it looked up `EXISTS (unnest → conversation →
identity)` once for each code change in the table. The result is the
same.
- Migration `0110`: `CREATE INDEX CONCURRENTLY
junior_code_changes_repository_state_idx ON junior_code_changes
(repository_id, state, updated_at DESC)`. It runs outside a transaction,
like the existing concurrent index migrations. Before this, no
repository query had an index on `repository_id`.

## Query cost

Measured with `EXPLAIN (ANALYZE, BUFFERS)` on Postgres 17 with 30k code
changes (4.5k in the largest repository), 300 repositories, 200k
Conversations, and 500 users.

| Query | `main` | This PR, no index | This PR, with index |
| --- | --- | --- | --- |
| Repository lookup (now with state counts) | 0.02 ms | 5–9 ms, seq
scan, 744 buffers | 1.6 ms, index-only scan, 36 buffers |
| Repository list, `?state=closed` | — | 5.0 ms, seq scan | 1.3 ms,
index |
| Repository list, no state | 5.9 ms, seq scan | 5.9 ms | 3.5 ms, index
|
| Repository summary window | ~5 ms, seq scan | ~5 ms | 3.7 ms, index |
| Person summary window, heavy user (8.9k Conversations) | 398 ms, 68.7k
buffers | 32 ms, 7.9k buffers | 32 ms |
| Person summary window, light user (200 Conversations) | 399 ms | 17 ms
| 17 ms |
| Person next page (cursor), heavy / light | 740 ms (page 1 on `main`) |
48 / 20 ms | 48 / 20 ms |

Each person page also reads the summary window again (~32 ms for a heavy
user). The keyset page costs the same as the offset page did (38 ms,
10.5k buffers vs 39 ms, 11.8k buffers for a heavy user), because the
person scope, not the skip, dominates.

## Old open tabs

The dashboard parses responses with `.strict()` schemas, which it gets
from this package. A tab that still runs a bundle from before this
deploy rejects the new fields (`changeCounts`, `idle`, `nextCursor`)
until it reloads. Every additive API change on `main` has the same risk.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A8541f171a3af567a3e793732efc8684f -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A8541f171a3af567a3e793732efc8684f)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A8541f171a3af567a3e793732efc8684f/?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]>
The review item cursor now encodes and decodes through page-cursor.ts,
like the People code and feed cursors. It keeps its list-binding checks,
so a cursor still pages only the list it came from. The payload stays
version 2, so cursors in tabs opened before a deploy still read.

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

Copy link
Copy Markdown
Contributor

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

Review screenshots in Frameshift

Automation Run Details · Desktop
Automation Run Details · Desktop
Changed
Automation Skill Editor · Desktop
Automation Skill Editor · Desktop
Changed
Automations Runs Filters · Desktop
Automations Runs Filters · Desktop
Changed
Conversation Attachment · Desktop
Conversation Attachment · Desktop
Changed
Conversation Attachment · Mobile
Conversation Attachment · Mobile
Changed
Conversation Attachment Modal · Desktop
Conversation Attachment Modal · Desktop
Changed
Show 12 more changed screenshots
Conversation Attachment Zoom · Desktop
Conversation Attachment Zoom · Desktop
Changed
Conversation Captured Memories Popover · Desktop
Conversation Captured Memories Popover · Desktop
Changed
Conversation Child Agents · Desktop
Conversation Child Agents · Desktop
Changed
Conversation Details Watched Linked Work · Desktop
Conversation Details Watched Linked Work · Desktop
Changed
Conversation Event Log Virtual · Desktop
Conversation Event Log Virtual · Desktop
Changed
Conversation Event Log Virtual · Mobile
Conversation Event Log Virtual · Mobile
Changed
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Memory List Jump · Mobile
Conversation Memory List Jump · Mobile
Changed
Conversation Question Picks And Text · Desktop
Conversation Question Picks And Text · Desktop
Changed
Conversation Stop Active · Mobile
Conversation Stop Active · Mobile
Changed
Conversation Task Line · Desktop
Conversation Task Line · Desktop
Changed
Conversation Text Attachment · Desktop
Conversation Text Attachment · Desktop
Changed

12 more changed screenshots in Frameshift.

@BYK
BYK merged commit af238e0 into main Nov 15, 2026
46 checks passed
@BYK
BYK deleted the ref/review-item-page-cursor branch November 15, 2026 07:53

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 33316f4f Deployed Nov 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant