Skip to content

fix(server): Snap Shot images keep their captured-window details when saved inline - #33271

Closed
saphid wants to merge 2 commits into
pingdotgg:mainfrom
saphid:fix/attachment-boundaries-20261109
Closed

saphid wants to merge 2 commits into
pingdotgg:mainfrom
saphid:fix/attachment-boundaries-20261109

Conversation

@saphid

@saphid saphid commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A Snap Shot image saved through assets.persistChatAttachments loses its captured-window details (app name, window title, accessibility text). The agent's prompt then has no "captured-window data" block for that image, and the message no longer shows the Snap Shot details.

The RPC's input and result types both carry the optional source, but the handler builds each saved record without it. The original Snap Shot change (#8103) kept source in the V1 normalizer; the V2 rewrite (#2829) dropped it.

On current main, the web queued-message edit sends newly added images as data URLs through this RPC. One way to hit it: take a Snap Shot, stash the draft, edit a queued message, restore the stash into the edit composer, and save. A web send that starts before the server config arrives also uses this path. Normal sends use pending uploads, which already keep source.

Change

Move the existing inline persistence operation into the AttachmentUpload Effect service and preserve optional source when constructing a saved attachment. The RPC handler delegates to that service. This addresses the Macroscope service-boundary review.

Two service-level cases cover attachments with and without capture metadata and verify the persisted image bytes. Existing validation, IDs, errors, and concurrency are preserved.

Scope and approval

This is a very small, focused fix for an obvious bug, so there is no prior issue: the RPC contract accepts and returns source, the server dropped it, and V1 kept it. The final change touches AttachmentUpload.ts, its test, and the thin RPC handler in ws.ts.

Overlap search (open and closed PRs and issues): "persistChatAttachments", "snap shot", "SnapShotSource persist", "queued edit snap shot", "captured-window context". The closest is #32742 (Claude adapter MIME casing), which is a different defect in a different file.

Verification

  • Failing-first RPC validation: main drops source (expected undefined to deeply equal …); the same assertion passes with this repair.
  • Focused attachment/RPC suites: 41 tests passed. Final CI=true vp run check:changed: format, lint, knip, GraphQL, three affected package typechecks, and 43 tests passed in Boat.
  • Earlier runtime transcript through the real RPC and provider prompt builder showed that the saved metadata restores the untrusted captured-window JSON block. The final service move preserves the persistence logic, with the metadata copy as its only behavioral change.
  • Fresh read-only independent review: Claude Opus 5.5/high via T3, task 91bed2be-c9dc-4cb9-ba5e-5dee14fbd747, completed with no actionable findings on staged tree e01bb864854cc1ac0c83c88d1b34ea40689a72f6. Reviewer inspected the source and verification logs; it did not rerun tests.
  • Merged main at c00a373491d20ebcef901b81170abfb9f5f757fe; the resulting candidate also merges cleanly with 4f555c746ce3e762deb4a145bb87d8c7f8634aab.
  • Not checked: queued-edit/stash restore in a real desktop client, or a web send before server config arrives. This PR remains a draft pending that client verification.

Original implementation by saphid with Claude Opus 5.5; recovery and service extraction with GPT-6.1 Sol/high in T3 Code.

… saved inline

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@saphid
saphid marked this pull request as draft November 9, 2026 09:27
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 9, 2026
Comment thread apps/server/src/ws.ts Outdated
name: attachment.name,
mimeType: attachment.mimeType,
sizeBytes: attachment.sizeBytes,
...(attachment.source ? { source: attachment.source } : {}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Preserving Snap Shot metadata broadens the attachment-persistence behavior implemented in this transport module. Could you move this persistence operation into the existing AttachmentUpload service and preserve source there, leaving the RPC handler to call the service and translate errors? Existing inline persistence is legacy, but new behavior should be added at the service boundary.

Posted via Macroscope — Effect Service Conventions

@macroscopeapp

macroscopeapp Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 73856bd

Macroscope's review found this PR approvable — Inline Snap Shot attachments now retain their existing captured-window metadata, matching the normal upload path. Image validation and file persistence remain unchanged, with no new capture or access behavior.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The attachment persistence function now accepts an optional SnapShot source for each image attachment. It includes a truthy source in the persisted record. A new RPC test checks that the response preserves the source.

Changes: Attachment source persistence

Layer / File(s) Summary
Preserve attachment source during persistence
apps/server/src/ws.ts, apps/server/src/ws.test.ts
The attachment input accepts an optional SnapShotSource. Persistence copies a truthy source into the record. An RPC test checks that the successful response includes the source.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge, t3dotgg

Merge Risk: Minimal · up to 73856

Snap Shot details are preserved through the inspected saved-message path. The untested desktop queued-edit and stash flow does not establish a merge-blocking issue.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the server-side fix: Snap Shot images keep their captured-window details when saved inline. This matches the main change, which copies the optional source field in persistChatAttachmen…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description covers the problem (Snap Shot captured-window details dropped by assets.persistChatAttachments), the change (moving persistence into the AttachmentUpload service and preserving optiona…
Full details: Title check

Explanation

The title names the server-side fix: Snap Shot images keep their captured-window details when saved inline. This matches the main change, which copies the optional source field in persistChatAttachments. The title follows a conventional commit format with the fix(server) scope. It is concise and specific.

Full details: Description check

Explanation

The description covers the problem (Snap Shot captured-window details dropped by assets.persistChatAttachments), the change (moving persistence into the AttachmentUpload service and preserving optional source), scope (small obvious bug, no prior issue needed, with rationale), and verification (failing-first RPC test, focused suites, check:changed run, runtime transcript, and unchecked items). It follows the template's section structure. Minor gaps: the template's title format is not evident, and the author notes that the queued-edit flow was not checked in a real client. The description is largely complete.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c73b38b and 73856bd.

Files selected for processing: 2

  • apps/server/src/ws.test.ts
  • apps/server/src/ws.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Merge current main and move inline attachment persistence into AttachmentUpload, preserving optional capture source metadata. Focused checks pass: 43 tests, affected typechecks, format, lint, knip and GraphQL.
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:XS 0-9 changed lines (additions + deletions). labels Nov 12, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

This has been a draft with no activity for more than three days, so it is being closed: the open pull requests are kept to work that is ready to be looked at.

Nothing is lost, the branch stays. When the work is ready, open a new pull request for it; this one will not be reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants