Repository navigation
test(api): Budget the size of conversation feed rows - #3809
Merged
Merged
Conversation
Add expectResponseBudget, which fails when the largest item of a list in a JSON body grows past a budget, and names its biggest fields. A nested list with its own budget is left out of its parent item. Seed a heavy viewer feed with pins, waiting rows outside the page, Threads, a Brief, a long latest message, and annotations at their max lengths. Set each budget to the size measured on main. Co-Authored-By: BYK <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
BYK
approved these changes
Nov 19, 2026
BYK
enabled auto-merge (squash)
November 19, 2026 17:54
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c3edabf. Configure here.
…r max The heavy row now stores 4 KiB of object facts and a 400-char Brief intent, so the row and annotation budgets hold for a legal max payload.
BYK
added a commit
that referenced
this pull request
Nov 19, 2026
`GET /api/conversations` waited on reads that did not depend on each other. On the heavy feed seed from #3809 (`include=links,media`), it ran 23 statements in 7 serial rounds. It now runs 21 statements in 3 rounds. The response stays the same. - **Waiting rows:** the first page read the waiting ids, then the rows for the ids outside the page. Now a third row read in the first round filters by `waitingConversationIdsQuery` as a subquery, and the feed dedupes it in JS against the pins and the page. `listWaitingConversations` and the subquery share one root expression. - **Threads:** `readFeedThreads` waited on access before it read anything. `readFeedThreadRecords` now reads the Thread rows, trees and the first messages of untitled Threads in the main batch, and `nestFeedThreads` applies access afterwards. - **Slack tenants:** `attachActivityPreviewMentions` read each conversation's tenant again. The feed now takes it from the rows it already has, through `conversationSlackTenantId`, which `loadConversationSlackTenantIds` also uses. The detail route keeps its lookup. Mention resolution and sidebar annotations now run together after the batch. | Heavy seed | Statements | Rounds | | --- | --- | --- | | Before | 23 | 7 | | After | 21 | 3 | On the same seed with preview mentions and an untitled Thread, the request goes from 25 statements in 9 rounds to 23 in 5. The `serialRounds` budgets on the feed scenarios go down to match: `list-brief` 3 → 2, `list-answer` 5 → 3, `tree-state` feed 5 → 3. The statement budgets do not change. The heavy viewer's feed in `list-budget.test.ts` now also has an `expectSqlBudget` of 21 statements and 3 serial rounds. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A2c3e432e56cd1bf6d0fbfabed08dc476 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A2c3e432e56cd1bf6d0fbfabed08dc476) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A2c3e432e56cd1bf6d0fbfabed08dc476/?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]>
BYK
added a commit
that referenced
this pull request
Nov 19, 2026
`GET /api/conversations` read some rows twice. On the heavy feed seed from #3809 (`include=links,media`), it ran 23 statements. It now runs 20. The response stays the same. - **Participants:** access read the viewer's participant rows, and the pin marks read the same rows again with `pinned_at is not null`. The feed now reads them once with `readMemberParticipants` and passes the roots to `conversationAccessFromRows`. `readConversationAccessFromSql` is now `readConversationAccessRows` plus that projection, so its other callers do not change. Feed rows are roots, so these roots cover the access check. An actor email feed with no viewer still reads only its pin marks. - **Avatars:** `readConversationParticipants` and `readConversationAuthors` read user photos in a second statement. Both participant reads now join the photo Identities with `hasUserPhoto`. `userAvatarUrlsFromJoinedPhotos` picks the photo, and `readMentionedPeople` uses it too. - **Children:** `listConversationWork` and `readFeedThreads` each read the children of the same roots. The feed reads `readConversationTrees` once and passes it to both. `ConversationTreeNode` now carries `rootConversationId` for the work owners. Other `listConversationWork` callers read the tree themselves. | Heavy seed | Statements | Rounds | | --- | --- | --- | | Before | 23 | 7 | | After | 20 | 7 | The rounds do not change here. #3820 removes them. On the same seed with preview mentions and an untitled Thread, the request goes from 25 statements to 22. The SQL budgets go down to match: `list-brief` 15 → 14 statements, `list-answer` 19/5 → 17/4, `tree-state` feed 20/5 → 17/4 and detail 20 → 19 statements. This PR and #3820 both change `readConversationFeedFromSql`. The one that merges second merges `main` in and keeps both changes. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A2c3e432e56cd1bf6d0fbfabed08dc476 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A2c3e432e56cd1bf6d0fbfabed08dc476) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A2c3e432e56cd1bf6d0fbfabed08dc476/?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]>
22 tasks done
BYK
added a commit
that referenced
this pull request
Nov 22, 2026
`GET /api/conversations` had no cap on the Threads that a row nests or on the waiting rows that the first page adds from outside the page (#3809). Both caps sit well above what real feeds carry, so no row loses data today; they only bound the response. **Threads** (`CONVERSATION_FEED_THREAD_LIMIT = 100` per root, at any depth) - `nestFeedThreads` keeps Threads depth first in activity order, so a kept Thread always has its parent. - A root past the cap carries `omittedThreadCount`. The root's own page still lists every Thread. - The dashboard (sidebar and the new UI's rows) shows a muted "+N more" under the root's Threads once every loaded Thread shows. **Waiting rows** (`CONVERSATION_FEED_WAITING_LIMIT = 50`) - The waiting read skips pins (they already show) and reads `limit + 50 + 1` rows, so it knows whether the cap cut some without another statement. - The newest waiting rows join the first page. When some are cut, the feed sets `waitingRowsTruncated: true`. The rest come on later pages by activity like any other row, so the dashboard does not lose them. Pins are still not paged; this leaves them as they are. ### Screenshots Mock data with `omittedThreadCount: 12` on a root with two Threads. Current dashboard sidebar:  New dashboard Conversations view:  <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A89f267e0ff71aeabd08513df3cdf5741 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A89f267e0ff71aeabd08513df3cdf5741) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A89f267e0ff71aeabd08513df3cdf5741/?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]>
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.

expectSqlBudgetholds the SQL work of hot routes, but nothing holds the size of what they send.GET /api/conversationsrows carry content with no cap, so the body grows with the data.expectResponseBudget(packages/junior/tests/fixtures/response-budget.ts) takes a request and a budget per list path, such asconversationsorconversations.threads, and holds the largest item of each list. A nested list with its own entry is left out of its parent item, so each entry holds only the item's own fields. A failure names the size and the three biggest fields of the item.The feed scenario seeds a heavy viewer: heavy pins, plain rows, and heavy waiting rows older than the page. A heavy row has a full title, Threads, a 32,000-char latest message, a Brief, an open Review item, and annotations with every field at its max length. Each budget is the size on
main:conversations1_959 + 32_069conversations.annotationsconversations.sidebarAnnotationsconversations.participantsconversations.threadsThe body has no total budget: pins and waiting rows are not paged, so the row count has no cap.
policies/performance.mdgets a bullet next to the SQL budget.via @BYK.
--
View Session [Sentry]