You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Claim a screenshot reply's uploads once when its chat hasn't changed - #49572
When you answer an item with screenshots, Orca reserves those screenshots for the bot's chat when it accepts the reply, then reserved them a second time a moment later when it delivered the reply to the same chat. Now it reserves them once.
Files
Added
Deleted
Net
Test
1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$11
$\color{#cf222e}{\Huge{\mathbf{−}}}$1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$10
Prod
5
$\color{#1a7f37}{\Huge{\mathbf{+}}}$69
$\color{#cf222e}{\Huge{\mathbf{−}}}$7
$\color{#1a7f37}{\Huge{\mathbf{+}}}$62
What Changed
admitBotItemCommentAttachments now returns which chat it claimed the comment's uploads for (claimed: { sessionId, uploadIds }).
The owner-comment RPC records that claim against the open items store after the comment is written (bot-item-comment-admitted-claims.ts, bounded to 64 entries).
sendBotItemMail skips its first claim only when that same store recorded exactly these uploads for the same recipient session. It still checks the recipient is current, and any re-resolved recipient, a reopened store (restart), replayed or older mail, or a profile switch claims as before.
Per reply with N screenshot uploads delivered to an unchanged chat, counted from the source: claim passes 2 → 1; sweep lookups, upload-directory reads and ignored inserts on the shared journal writer 2N → N.
Why
#47967 added a delivery-time claim so a reply follows its chat when the chat is replaced between admission and delivery. That claim is needed for recovery and for a changed recipient, but for the common case it repeats exactly what admission just did. Keying the record on the open items store, rather than process memory, means a reopened store always re-claims, which keeps the restart path from #47967 unchanged.
Linked Issue
Tracked in STA-18522
Visual Proof
N/A: no visual change; the reply is delivered the same way.
Testing
bots-items-answer-attachments.test.ts drives the real reply RPC, attachment store and mail delivery: changed recipient, restart and expired uploads still claim, and it now asserts a reply delivered to the chat admission claimed for is claimed once (fails on revert).
Performance
Removes N sweep lookups, N synchronous upload-directory reads and N ignored inserts per screenshot reply on the shared journal writer. Adds one in-memory set lookup per delivery.
Risk
Level: Low. The riskiest part is skipping a claim that was needed: that would require the admission's claim row to vanish while the same chat stays the current recipient. Claims are only pruned for chats that are gone, and a gone chat fails the existing recipient check, which re-resolves and claims. Plain revert.
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Main-process only; same on every platform. Replies from paired phones go through the same RPC. No saved data changes.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
Admission already claims an owner reply's uploads for the item's chat, and
delivery to that same chat claimed them all again: N sweep lookups, upload
directory reads and ignored inserts on the shared journal writer. Delivery now
skips the claim when the open items store's admission just made it for the same
chat; a changed recipient, a reopened store or older mail still claims.
Fixes STA-18522
No actionable comments were generated in the recent review.
Walkthrough
Attachment admission now returns claim metadata for referenced uploads. A per-store registry retains up to 64 claims, keyed by event ID, session ID, and sorted upload IDs. Owner comment handling records the claim. Mail delivery consumes a matching claim to skip duplicate upload claiming on the first attempt. Retries and attempts without a matching claim still claim uploads. A test checks that delivery to an already-claimed chat does not repeat the claim.
Merge Risk: Minimal · up to 0bf4f
This change avoids claiming screenshot uploads twice when a reply goes to the same chat. Claiming still happens for changed recipients, retries and restarts. No merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title states the main change: uploads from a screenshot reply are claimed once when the target chat is unchanged. The raw summary shows admission records the claim and delivery skips the duplicate…
Description check
The description follows the repository template and covers ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, and the checklist. It explains the me…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title states the main change: uploads from a screenshot reply are claimed once when the target chat is unchanged. The raw summary shows admission records the claim and delivery skips the duplicate claim when the recorded session and upload IDs match, so the title matches the changeset.
Full details: Description check
Explanation
The description follows the repository template and covers ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, and the checklist. It explains the mechanism, the scope of the skip, and the rollback path. The Linked Issue section cites STA-18522 rather than a GitHub issue number, and the 'Fixes #' line is left blank. The Testing section also lists only one automated test file and does not state which platforms were manually tested. The AI Disclosure section is empty. These gaps are non-critical, so the check passes.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
Problem. A screenshot reply to an item claimed its N uploads at admission, then claimed them again when it was delivered to the same chat. That doubled the sweep lookups, upload-directory reads and ignored journal inserts on Electron main.
Change. Delivery skips its first claim only when the open items store recorded exactly these uploads for the same recipient. The record is keyed to the reply, so a changed or replaced chat, a retry, a restart, a profile switch and older mail all still claim; delivery never opens an items store to check.
Verified
CI is green.
bots-items-answer-attachments.test.ts runs the real reply RPC, attachment store, journal and mail delivery through changed-recipient, restart and expired-upload cases. It now asserts that the claim happens once for the admitted chat, and it fails on revert.
Regression audit: SAFE. Correctness review: no P0 or P1.
Perf scan: clean.
Per reply, journal claim work goes from 2N to N.
New in-memory state is at most 64 short keys per items store, held in a WeakMap that is released with the store.
No timers, polls, subscriptions or sync I/O are added.
Deferred (no wrong output)
A record can outlive its mail, for example when another delivery trigger wins the race. It is capped at 64, and skipping it is still correct because the earlier claim is already durable.
When delivery skips, it relies on claimed uploads never being swept, which the sweep guarantees today.
If the profile switches during a delivery pass, the lookup misses and delivery claims again. That is one redundant claim, the same as before this change.
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
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.
ELI5
When you answer an item with screenshots, Orca reserves those screenshots for the bot's chat when it accepts the reply, then reserved them a second time a moment later when it delivered the reply to the same chat. Now it reserves them once.
What Changed
admitBotItemCommentAttachmentsnow returns which chat it claimed the comment's uploads for (claimed: { sessionId, uploadIds }).bot-item-comment-admitted-claims.ts, bounded to 64 entries).sendBotItemMailskips its first claim only when that same store recorded exactly these uploads for the same recipient session. It still checks the recipient is current, and any re-resolved recipient, a reopened store (restart), replayed or older mail, or a profile switch claims as before.Per reply with N screenshot uploads delivered to an unchanged chat, counted from the source: claim passes 2 → 1; sweep lookups, upload-directory reads and ignored inserts on the shared journal writer 2N → N.
Why
#47967 added a delivery-time claim so a reply follows its chat when the chat is replaced between admission and delivery. That claim is needed for recovery and for a changed recipient, but for the common case it repeats exactly what admission just did. Keying the record on the open items store, rather than process memory, means a reopened store always re-claims, which keeps the restart path from #47967 unchanged.
Linked Issue
Tracked in STA-18522
Visual Proof
N/A: no visual change; the reply is delivered the same way.
Testing
bots-items-answer-attachments.test.tsdrives the real reply RPC, attachment store and mail delivery: changed recipient, restart and expired uploads still claim, and it now asserts a reply delivered to the chat admission claimed for is claimed once (fails on revert).Performance
Removes N sweep lookups, N synchronous upload-directory reads and N ignored inserts per screenshot reply on the shared journal writer. Adds one in-memory set lookup per delivery.
Risk
Level: Low. The riskiest part is skipping a claim that was needed: that would require the admission's claim row to vanish while the same chat stays the current recipient. Claims are only pruned for chats that are gone, and a gone chat fails the existing recipient check, which re-resolves and claims. Plain revert.
Review
Agent skill upstream boundary
Notes
Main-process only; same on every platform. Replies from paired phones go through the same RPC. No saved data changes.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)