fix(web): attach preview annotation screenshots in the desktop app #6242
main fromrefs/pull/6242/head·opened View on GitHubPreview annotations never attached their screenshot in the desktop app. The crop was captured fine, but converting it into a composer attachment used fetch() on a data: URL, and the desktop renderer's CSP allows data: for img-src and font-src but not for connect-src — the directive that governs fetch. The call was blocked and swallowed by an empty catch, so the image was silently dropped.
The prompt still told the agent "The attached screenshot is the annotated preview crop", because that sentence is built from annotation.screenshot rather than from the attachment that actually landed. The agent was told to look at an image it never received.
Draw annotations made it visible, since strokes carry no element context and the image is the whole payload. Select and region picks were losing their screenshots too, but still read well from their <element_context> text.
Decode the crop with the existing dataUrlToFile helper instead of fetching it, and clear screenshot when the attachment does not survive so a failed conversion stops the prompt from promising an image.
Before#
The annotation arrives as metadata only, and the agent says so.

After#
The crop is attached and the agent can read it.

Verification:
vp test run apps/web/src/lib/previewAnnotation.test.ts apps/web/src/lib/imageCompression.test.ts apps/web/src/components/preview/PreviewView.test.tsx(28 tests)vp run --filter @t3tools/web typecheck- targeted
vp lintandvp fmtfor changed files - Verified in the desktop app, before and after, as above
Model: Claude Opus 5 | Harness: Claude Code in T3 Code
Note
Medium Risk Changes how preview annotation images are converted and attached to the composer/agent prompt, which can affect what the agent receives. Scoped bug fix with focused tests, but regressions would silently drop or misadvertise screenshots.
Overview
Fixes desktop preview annotation screenshots never reaching the composer. Conversion previously fetched a data: URL, which the desktop CSP blocks via connect-src, so the image was silently dropped while the prompt still claimed a screenshot was attached.
previewAnnotationScreenshotFile now decodes the crop in place with dataUrlToFile instead of fetching. If conversion fails or returns null, PreviewView clears screenshot on the annotation so the prompt no longer advertises an image the agent never received.
Note
Fix preview annotation screenshot attachment in the desktop app#
- Replaces the async fetch-based screenshot conversion in
previewAnnotationScreenshotFilewith a synchronous base64 decode usingdataUrlToFile, avoiding a network fetch against the data URL. - Returns
nullfor missing or non-base64 screenshots instead of attempting a fetch. - When conversion fails or yields no file, the annotation's
screenshotfield is cleared before being added and sent, rather than sending stale screenshot data. - Exports
dataUrlToFilefromimageCompression.tsso it can be used bypreviewAnnotation.ts.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Approvability#
Verdict: Approved 751def6
This is a straightforward bug fix addressing CSP restrictions that prevented screenshot attachments in the desktop app. The change is well-scoped, includes proper test coverage, and the defensive handling (clearing screenshot on failure) is sensible.
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).juliusmarminge closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
0e6f3944-38be-40a8-87e1-894ef4aa8adcYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
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.
❤️ Share