Repository navigation
feat(api): Page the conversation feed and return dashboard links - #2232
Closed
sentry-junior[bot] wants to merge 1 commit into
Closed
sentry-junior[bot] wants to merge 1 commit into
sentry-junior[bot] wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
dingsdax
marked this pull request as draft
October 26, 2026 18:51
sentry-junior
Bot
force-pushed
the
feat/conversation-list-cursor
branch
from
October 29, 2026 09:54
6317dde to
114bc9d
Compare
thomasjiangcy
added a commit
that referenced
this pull request
Nov 5, 2026
`GET /api/conversations` (the dashboard sidebar) runs p50 688ms / p95 2.3s on the server, and the dashboard polls it every 10s while a listed Conversation is active. In the 40 slowest prod requests over 3 days (all over 2s, up to 17.7s), the slowest DB span was one of two event queries in 34 of them: | Query | Slowest in | Median | Max | | --- | --- | --- | --- | | participants `select distinct on (conversation_id, actor_identity_id) …` | 21 / 40 | 2.5s | 17.4s | | `readLastUserMessageAtByConversation` `max(created_at) … type in (user_message, message)` | 13 / 40 | 1.9s | 6.1s | Example trace: `19019d5f769341a2916e865e93267baa` (5.5s and 3.3s). **Participants.** The old query joined every authored event to identities, conversations, and participants before `DISTINCT ON`. Postgres does not carry an `IN` list across a join, and no index starts with `conversation_id` and covers authored rows. Locally it scanned the non-null part of `junior_conversation_events_actor_identity_idx`, so its cost grows with all human messages in the database, not with the 50 listed Conversations. Now: - A `GROUP BY` subquery finds each author's first `seq`, then joins. - It is served by a new partial index `junior_conversation_events_author_idx (conversation_id, actor_identity_id, seq) WHERE actor_identity_id IS NOT NULL`. Only `message` / `message_updated` rows with an author set this column, so the index is small (13 MB, against 221 MB for the existing actor index, on the fixture below). - The `IN` list is repeated on `junior_conversations`. - The result is the same: the join filters depend only on (Conversation, author), so the first `seq` per pair does not change. `readConversationAuthors` (detail) uses the same rows and gets the same speedup. **Last user message time.** `isConversationPriority` reads `lastUserMessageAt` only for assigned work with a finish time. The list now reads it only for those ids, after `listConversationWork` (about 40ms in prod traces) and still inside the same `Promise.all`. Before, it read and detoasted every `user_message` and `message` payload of all 50 Conversations. **Evidence.** On a local Postgres 17 fixture (40k Conversations, 4.4M events), the exact generated SQL dropped from 80ms / 16.3k buffers to 9ms / 2.6k buffers on a warm cache. That's a relative change only. Prod runs on Neon with cold reads, so I expect a bigger absolute drop there, but that's not measured. **Migration.** `0078` follows the `0062` pattern. For a busy database, first build the index `CONCURRENTLY` outside a transaction. The migration then skips the DDL and checks that the index is valid and ready. **Overlap** - #2713 also adds core migration `0078`, a different partial index on `structured_event` rows, so the indexes don't duplicate. The PR that merges second must renumber its migration to `0079` and regenerate the journal and snapshot. - #2232 / #2234 (cursor paging for this endpoint) change `conversationRows` and the response. This PR changes only the auxiliary reads after the page is chosen, so it composes with paging. Expect a small textual conflict in `list.ts`. **Not in this PR** - The `conversation_subtree` auxiliary-cost aggregate (`readConversationAuxiliaryCostsFromSql`) is the next slowest: median 0.9s, max 4.4s, slowest in 4 / 40. - The 10s list poll (`useConversationsData`) runs on every dashboard page, including open Conversations. Checks: - `vitest run tests/integration/api/conversations/ tests/integration/dashboard-reporting.test.ts` passed (74 tests) - `tsc --noEmit` (junior), oxlint, prettier, `migration-metadata:check`, `file-length:check` - `db:generate` reports no further changes <!-- junior-request-attribution:start --> via @thomasjiangcy. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Aa40c0c19633f683c13aa6acb1ea1ee47 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3Aa40c0c19633f683c13aa6acb1ea1ee47) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Aa40c0c19633f683c13aa6acb1ea1ee47/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Thomas Jiang <[email protected]>
GET /api/conversations accepts a signed cursor and returns nextCursor while more rows remain. The cursor holds the position of the last row and whether it is pinned, so paging stays stable across the pin boundary. Callers send the same filters on each page. Conversation and automation summaries now carry an optional dashboardUrl built by the server, so clients do not rebuild dashboard paths. The MCP mappers read the same field. Refs #2231 Co-Authored-By: johdax <[email protected]> Co-Authored-By: Johannes Daxboeck <[email protected]>
sentry-junior
Bot
force-pushed
the
feat/conversation-list-cursor
branch
from
November 7, 2026 15:13
114bc9d to
d604489
Compare
Contributor
|
16 screenshot changes — 16 changed · 0 added · 0 removed Review screenshots in Frameshift Show 10 more changed screenshots |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2231. Rebased on
main(2026-11-07).Cursor.
GET /api/conversationstakes an optionalcursorand returnsnextCursorwhile more rows remain. The cursor is signed and holds the position of the last row:lastActivityAt,conversationId, and whether the row is pinned. Pins sort first for the viewer's active feed, so the keyset must cross the pin boundary. The cursor holds no filters. Callers send the sameq/statuson each page. An invalid cursor returns400 Invalid conversation cursor.The first page still adds roots that wait on the viewer (
waitingRowsOutsidePage). Those roots can also show on their own later page, so a client that reads every page can see one twice. The CLI in #2234 drops repeated ids. A root with new activity during paging moves above the cursor and later pages skip it.Links. Conversation and Automation summaries return an optional
dashboardUrlfromgetDashboardConversationLink()/getDashboardTaskLink(). It includes the dashboard base path and is missing when the dashboard is off. The MCP mappers now read this field instead of building the link again.No other change to the REST shape. Automations keep
page+total.Tests:
tests/integration/api/conversations/list-paging.test.tscovers paging one row at a time with a tie onlastActivityAt, paging across a pin, the/dashboardbase path indashboardUrl, and the invalid-cursor400.search-automations.test.tsasserts the MCPurl. The paging test is a new file becauselist.test.tsis at the 1,000-line limit.via @dingsdax.
--
View Session [Sentry]