fix(web): keep screenshots when attaching preview annotations - #58
Conversation
The element picker captured its crop in Electron, then dropped it in the renderer: the conversion fetched the data URL, and the desktop Content Security Policy only allows http, https, ws, and wss connections, so every attach ended with "The annotation was kept without the screenshot". Decode the data URL locally with the existing dataUrlToFile helper and remove the now-redundant conversion timeout. Failed decodes still keep the annotation without promising an attached image. Ported from upstream pingdotgg#10374. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
@coderabbitai review Please review this four-file port of upstream pingdotgg#10374 at head 8d2412e. The renderer converted the annotation crop with fetch(dataUrl), which the desktop CSP connect-src refuses, so every picked element lost its screenshot. The change decodes the data URL locally with the existing dataUrlToFile helper and updates the tests to match. |
|
✅ Action performedReview finished.
|
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe screenshot capture helper now decodes embedded image data synchronously. It returns explicit statuses for missing, invalid, and valid screenshots. Preview handling and tests now use the synchronous API. ChangesPreview screenshot capture
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The preview flow accepts the producer’s PNG data URLs and all current consumers use the synchronous capture result correctly. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Problem
Picking an element in the browser preview always ends with "Could not capture the picked element. The annotation was kept without the screenshot." Electron captures the crop fine and hands it to the renderer as a data URL. The renderer then converts it with a fetch of that data URL, and the desktop Content Security Policy only allows http, https, ws, and wss connections, so the fetch is refused and the crop is dropped every time. The preview webview always renders in the local desktop app, so this hits SSH-hosted environments the same as local ones.
Fix
Port of upstream pingdotgg#10374 (tracked upstream in pingdotgg#10366 and pingdotgg#11867; the upstream PR is currently conflicting and unmerged). Decode the data URL locally with the existing
dataUrlToFilehelper instead of fetching it, and drop the conversion timeout that only existed to bound the fetch. Invalid data URLs still resolve to a dropped crop with the same toast.Focused tests (previewAnnotation, PreviewView) pass and the web typecheck passes. Not verified in a running desktop build.
Written by Claude Fable 5.1 through Claude Code in T3 Code.
🤖 Generated with Claude Code
Summary by CodeRabbit