Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): attach preview annotation screenshots in the desktop app #6242

Closedglauberorg(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/6242/headopened View on GitHub

Preview 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.

Before

After

The crop is attached and the agent can read it.

After

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 lint and vp fmt for 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.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 751def618c5e43e374753d606453fe569143a56c. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Fix preview annotation screenshot attachment in the desktop app

  • Replaces the async fetch-based screenshot conversion in previewAnnotationScreenshotFile with a synchronous base64 decode using dataUrlToFile, avoiding a network fetch against the data URL.
  • Returns null for missing or non-base64 screenshots instead of attempting a fetch.
  • When conversion fails or yields no file, the annotation's screenshot field is cleared before being added and sent, rather than sending stale screenshot data.
  • Exports dataUrlToFile from imageCompression.ts so it can be used by previewAnnotation.ts.
Macroscope summarized 751def6.
    1. Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 0e6f3944-38be-40a8-87e1-894ef4aa8adc

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      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
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. 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).
    4. Superseded by #12636, which already fixed #12265 and merged. Closing this PR as leftover hygiene.

    5. juliusmarminge closed this

Sign in to join this conversation.