Skip to content

perf(review-items): Batch webhook review item closes and memoize conversation access - #3456

Open
sentry[bot] wants to merge 2 commits into
mainfrom
seer/batch-plugin-review-item-closes
Open

sentry[bot] wants to merge 2 commits into
mainfrom
seer/batch-plugin-review-item-closes

Conversation

@sentry

@sentry sentry Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Every pull request webhook delivery that checked a pull request triggered an N+1 query issue in POST /api/webhooks/github (Sentry issue JUNIOR-XD). In pull-request-action.ts, syncOne made three sequential calls to items.close() (two for legacy item prefixes and one for the merge-conflict notice). Each call to createPluginReviewItems().close() re-fetched the conversation access from the database (readConversationAccessFromSql) and performed an individual SQL select by dedupe_key against junior_review_items, causing 6 database queries per pull request check.

In addition, a recent merge on main left readLinkObjectType referencing .objectType instead of .objectTypes on ObjectLinkType, causing CI typecheck and lint to fail.

Solution

  1. Batch Closes: Added closeMany to PluginReviewItems in @sentry/junior-plugin-api and implemented getOpenReviewItemsByDedupeKeys in chat/review-items/store.ts using inArray to fetch matching open review items in a single query.
  2. Memoize Access: Memoized the per-conversation access lookup in createPluginReviewItems so subsequent review-item operations on the same conversation reuse the access read and avoid repeating the join query.
  3. Use Batched Closes in GitHub Webhook: Refactored syncOne in pull-request-action.ts to collect legacy dedupe keys and any applicable conflict-notice key into a single closeMany call, cutting database queries down to 2.
  4. Fix ObjectLinkType Reference: Updated readLinkObjectType in packages/junior/src/api/objects/resolve.ts to inspect linkType.objectTypes instead of the removed property.

Fixes JUNIOR-XD

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@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 14, 2026 10:54pm UTC

Request Review

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

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

Review screenshots in Frameshift

Automation Run Details · Desktop
Automation Run Details · Desktop
Changed
Automations Runs Filters · Desktop
Automations Runs Filters · 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 · Mobile
Conversation Event Log · Mobile
Changed
Show 8 more changed screenshots
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Memory List Jump · Mobile
Conversation Memory List Jump · Mobile
Changed
Conversation Task Line · Desktop
Conversation Task Line · Desktop
Changed
Conversation Text Attachment · Desktop
Conversation Text Attachment · Desktop
Changed
Memories · Mobile
Memories · Mobile
Changed
Push Notifications Tip · Desktop
Push Notifications Tip · Desktop
Changed
Settings · Desktop
Settings · Desktop
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed

This branch was successfully deployed

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

0 participants