Skip to content

fix(desktop): don't close picker webview before window screenshot - #2071

Merged
richiemcilroy merged 1 commit into
mainfrom
codex/fix-window-screenshot-picker
Aug 3, 2026
Merged

fix(desktop): don't close picker webview before window screenshot#2071
richiemcilroy merged 1 commit into
mainfrom
codex/fix-window-screenshot-picker

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Aug 3, 2026

Copy link
Copy Markdown
Member

Closes #2046.

Problem

On Windows, taking a screenshot of a specific window silently never happened: no file written, no error, no log. The window variant's onRecordingStart called closeTargetSelectOverlays() while options.mode === "screenshot". On Windows that command closes the overlay webviews (to release the DirectComposition surface) rather than hiding them, and takeScreenshot is invoked from that same webview immediately afterwards, so the webview was destroyed before the IPC call was dispatched.

Fix

  • Keep the picker webview alive until the screenshot request is dispatched (remove the premature close from the window-variant screenshot branch), matching the display-target flow that already works.
  • Close the overlays after both successful and failed captures (move the post-capture close into a finally).
  • Keep overlay-cleanup failures from masking the original screenshot error (.catch(console.error)).

Verification

  • The window variant already hides overlays via the frontend win.hide() plus the backend hide_overlay() + 150 ms settle inside take_screenshot, identical to the display flow, so this change does not extend the time a hidden overlay could be captured.
  • All closeTargetSelectOverlays / takeScreenshot call sites audited: recording modes and the area-screenshot path are untouched.
  • Scoped biome check passes.

Known pre-existing gaps, out of scope: on failure the toast renders in an already-hidden webview, and the area-screenshot path only closes overlays on success. Worth a follow-up issue.

Greptile Summary

This PR corrects the desktop window-screenshot lifecycle by keeping the picker webview alive until screenshot IPC is dispatched.

  • Removes premature overlay closure from the window-target screenshot callback.
  • Moves overlay cleanup into finally so it runs after successful and failed captures.
  • Prevents cleanup errors from replacing the original screenshot failure.

Confidence Score: 5/5

The PR appears safe to merge because screenshot dispatch now completes before overlay destruction while cleanup still runs on both success and failure.

The selected target is preserved before dismissal, overlays are hidden before capture by both frontend and backend paths, and post-capture cleanup errors are contained without masking screenshot failures.

Important Files Changed

Filename Overview
apps/desktop/src/routes/target-select-overlay.tsx Defers picker-overlay closure until after screenshot capture and makes cleanup failure-safe; no actionable changed-code defect was identified.

Reviews (1): Last reviewed commit: "fix(desktop): don't close picker webview..." | Re-trigger Greptile

Context used:

Keep the window screenshot picker alive until takeScreenshot is dispatched on Windows. Close target-selection overlays on every capture outcome without allowing cleanup failures to mask the original error.
@cursor

cursor Bot commented Aug 3, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@richiemcilroy
richiemcilroy merged commit 80f2e27 into main Aug 3, 2026
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug/windows]: window screenshots silently never happen

2 participants