Skip to content

feat(plugins): Apply annotation and Inbox item changes in one write - #4096

Merged
BYK merged 2 commits into
mainfrom
feat/conversation-changes-batch
Nov 23, 2026
Merged

BYK merged 2 commits into
mainfrom
feat/conversation-changes-batch

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3782.

A plugin could not change Conversation annotations and Inbox items in one transaction. When a pull request merged, the GitHub plugin closed its asks and marked its chips in separate writes, so a failed write left the chip and the ask out of step, and the conversation and inboxItems version tokens moved at different times.

Heartbeat and route contexts now have ctx.conversationChanges.apply(batch). The batch is data:

await ctx.conversationChanges.apply({
  annotations: [{ conversationId, upsert: annotation }],
  inboxItems: [{ conversationId, close: { dedupeKey, reason, status: "done" } }],
});

Core saves the batch in one transaction. Each entry uses the same write as its forConversation call (upsertPluginAnnotation and closePluginInboxItem are now shared by both paths), so it has the same checks. When one entry fails, no entry is saved and the call throws. After the commit, core shows each closed item through ShowInboxItem (Slack cards and push).

The GitHub plugin's ended pull request path (webhook and daily reconcile) now marks the chip of the Conversation that asked for the pull request and closes its next-action item and merge conflict notice in one batch. A failed batch is logged, as the separate writes were before.

Scope

  • Only annotation upserts and Inbox item closes. Code index writes (codeChanges.record), annotation removes, and Inbox item upserts are not in the batch. No current user needs them.
  • A batch has at most 100 entries (MAX_CONVERSATION_CHANGES). Core rejects a larger batch with an error. The GitHub batch has at most 3 entries.
  • Only the Conversation that owns the asks is in the batch. Each other linked Conversation gets its chip in its own write and logs its own failure, as before. A stored id can point to a purged Conversation, and its chip write fails, so batching every chip would let one stale id roll back every chip and ask.
  • Issue close and the merge conflict notice's own upsert and close change only one side, so they stay as they are. The daily reconcile still closes the merge conflict notice before the batch, so a failed close keeps the row open for the next reconcile.

via @BYK.

--

View Session [Sentry]

Add ctx.conversationChanges.apply to heartbeat and route contexts. Core
saves a batch of annotation upserts and Inbox item closes in one
transaction, then shows the closed items. A batch has at most 100
entries.

The GitHub plugin now marks the chips of an ended pull request and
closes its next-action item and merge conflict notice in one batch, from
the webhook and the daily reconcile.

Refs #3782

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot requested a review from BYK November 23, 2026 14:47
@vercel

vercel Bot commented Nov 23, 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 23, 2026 3:01pm UTC

Request Review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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

Review screenshots in Frameshift

Automation Run Details Light · Mobile
Automation Run Details Light · Mobile
Changed
Conversation Title · Desktop
Conversation Title · Desktop
Changed
Conversation Unsent Answers · Desktop
Conversation Unsent Answers · Desktop
Changed
Inbox Palette Pages · Desktop
Inbox Palette Pages · Desktop
Changed
Lead Home · Mobile
Lead Home · Mobile
Changed
System Cache Health Stale · Desktop
System Cache Health Stale · Desktop
Changed

A stale linked Conversation id made the chip upsert fail and rolled back
every chip and ask of an ended pull request. Batch only the chip of the
Conversation that owns the asks with their closes. Each other linked
Conversation gets its chip in its own write, so a stale id breaks only its
own chip.
@BYK
BYK enabled auto-merge (squash) November 23, 2026 15:03

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c4f0f63. Configure here.

@BYK
BYK merged commit f001d97 into main Nov 23, 2026
58 checks passed
@BYK
BYK deleted the feat/conversation-changes-batch branch November 23, 2026 15:14
BYK added a commit that referenced this pull request Nov 23, 2026
Follow-up to #4096.

When a pull request merged or closed, `applyGitHubPullRequestOutcome`
read the Conversation that owns its asks after it wrote the outcome row.
If that read failed, the error was only logged. Every linked chip then
turned `merged` or `closed` while the asks stayed open. Because the row
was already recorded, neither a redelivery nor the daily reconcile tried
again.

Now the owner lookup runs before the row is written, and its error is
not caught. It reaches the webhook or reconcile boundary like any other
unexpected failure. The row stays open, so the next delivery or
reconcile applies the whole outcome once: the row, the code index, the
opener's chip with its asks, and the other chips. Nothing was written
before the failure, so the retry does not apply anything twice.

A failed chip or Inbox item write is still logged and does not stop the
work after it, as before.

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

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

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A2186cef324c460e37246608055bd8216)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A2186cef324c460e37246608055bd8216/?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

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

Apply annotation and review item changes in one write

1 participant