Repository navigation
Description
User trigger: in thread A's Browser pane, click Add screenshot. Switch to thread B before the image save resolves. A's screenshot appears in B's composer and can be sent as context for B.
Reproduced at 9fc8645: mounted the real ThreadView and Composer with the existing DOM harness. A's preview.screenshot returned immediately; onSaveAttachmentImage was deferred. Switched detail A -> null (loading) -> B, then resolved the save to an image attachment named A screenshot.png. Asserted B had no attachment before resolution and then rendered the Remove A screenshot.png chip afterward. The assertion script exited 0 with no React console errors. This is a simulated-transport mounted check, not a native screenshot or live-data experiment.
Cause:
- ThreadView Browser callback awaits onSaveAttachmentImage, then writes setIncomingAttachments([att]) without an originating thread/session identity.
- Thread switch reset clears the state once but cannot guard later promise completions.
- Composer consumes incomingAttachments into the current thread's otherwise correctly scoped attachment map.
- captureAppSnap writes the same unowned state after awaiting window capture. That sibling path is source-confirmed, not separately reproduced.
- BrowserPane.onScreenshot also has an earlier async capture boundary. Guarding only the child cannot cover a parent save already in flight.
Smallest scope: give the shared async attachment handoff an originating thread and request generation. Preserve the result with the originating thread's draft, or explicitly reject a stale capture without inserting it into another draft. Cover both capture and save boundaries and the app-window sibling using existing attachment state. Do not rely only on clearing incomingAttachments on selection change.
Acceptance:
- Deferred screenshot/save across A -> B and A -> loading -> B cannot put A's image in B.
- A -> B -> A and pane close/reopen do not revive cancelled requests.
- Capture success, save failure and late rejection leave the correct draft/attachments intact and report errors in the owning context.
- Normal same-thread screenshot attaches once; preserve existing unsent text and attachments.
- Include a mounted ThreadView/Composer regression with the actual save callback, not only a BrowserPane unit test.
- Validate the source-confirmed app-window capture sibling against the same ownership contract.
Dedup: #1193 proposes live DOM context selection and mentions origin binding for that new feature. This fixes the existing screenshot handoff. #460 adds image markup; #1182 is terminal ownership. No matching existing screenshot thread-switch issue was found.
Activity
currentbits commentedon Sep 10, 2026
Async screenshot/app-window attachments now carry originating thread + request generation. Deferred save across A→B and A→loading→B cannot put A's image in B; A→B→A and pane close/reopen do not revive cancelled requests. Same-thread screenshot still attaches once. Mounted ThreadView/Composer tests cover the actual save callback and captureAppSnap.