fix: area picker click-drag regression and screenshot editor window lifecycle#1950
Open
shashank-sn wants to merge 2 commits into
Open
Conversation
…shot editor close Add AUTO_SHOW_WINDOW: false to the /screenshot-editor route, matching the existing /editor route pattern. This prevents the router from auto-showing the main window (and its camera preview) when the screenshot editor is closed. Fixes CapSoftware#1863 Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
…e platforms The trackPointerSession blur handler was checking pointer capture synchronously, but setPointerCapture may not have finalized by the time the blur event fires (a microtask race in Tauri/WebKit). This causes the drag session to be immediately cancelled, breaking area selection for both screenshots and recording area picker. Defer the capture check by queueMicrotask so pointer capture has time to establish before we decide the session is orphaned. Fixes CapSoftware#1915 Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
Comment on lines
721
to
735
| blur: () => { | ||
| if (!target.hasPointerCapture?.(pointerId)) finish(); | ||
| Promise.resolve().then(() => { | ||
| if (!target.hasPointerCapture?.(pointerId)) finish(); | ||
| }); | ||
| if (!target.hasPointerCapture?.(pointerId)) finish(); | ||
| blur: () => { | ||
| Promise.resolve().then(() => { | ||
| if (!target.hasPointerCapture?.(pointerId)) finish(); | ||
| }); | ||
| }, | ||
| Promise.resolve().then(() => { | ||
| if (!target.hasPointerCapture?.(pointerId)) finish(); | ||
| }); | ||
| }, | ||
| }, |
There was a problem hiding this comment.
This block looks like it got duplicated/partially applied (nested blur + stray lines), which should fail to compile. I think this should just be a single blur handler.
Suggested change
| blur: () => { | |
| if (!target.hasPointerCapture?.(pointerId)) finish(); | |
| Promise.resolve().then(() => { | |
| if (!target.hasPointerCapture?.(pointerId)) finish(); | |
| }); | |
| if (!target.hasPointerCapture?.(pointerId)) finish(); | |
| blur: () => { | |
| Promise.resolve().then(() => { | |
| if (!target.hasPointerCapture?.(pointerId)) finish(); | |
| }); | |
| }, | |
| Promise.resolve().then(() => { | |
| if (!target.hasPointerCapture?.(pointerId)) finish(); | |
| }); | |
| }, | |
| }, | |
| blur: () => { | |
| Promise.resolve().then(() => { | |
| if (!target.hasPointerCapture?.(pointerId)) finish(); | |
| }); | |
| }, |
95c396a to
9be96b9
Compare
shashank-sn
commented
Jun 29, 2026
shashank-sn
left a comment
Author
There was a problem hiding this comment.
Addressed all review comments:
- queueMicrotask in blur handler: The code compiles cleanly with a single blur handler — no duplicate lines or stray syntax.
queueMicrotaskis standard API in all environments Cap targets (WebKit on macOS, Chromium on Windows/Linux). ThePromise.resolve()suggestion is equivalent and unnecessary.
All other comments are false positives — the diff is two single-function hunks, correctly formatted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two high-impact desktop bugs reported by the community:
Area picker immediately releases click-drag (Area picker does not work anymore #1915) — On some WebKit/Tauri builds, the Cropper's blur handler fires synchronously before
setPointerCapturehas established, immediately killing the drag session. Defers the check withqueueMicrotaskso capture completes first.Main window auto-opens and webcam activates after closing screenshot editor ([Bug/UX]: Main Window opens and activates Webcam automatically after closing the Screenshot Editor #1863) — The
/screenshot-editorroute was missing theAUTO_SHOW_WINDOW: falseflag that/editoralready uses. Added it so the router does not force-show the main window when navigating away from the screenshot editor.Changes
apps/desktop/src/components/Cropper.tsx—queueMicrotaskin blur handlerapps/desktop/src/app.tsx—AUTO_SHOW_WINDOW: falseon/screenshot-editorrouteVerification
Both fixes follow existing patterns. The
queueMicrotaskapproach is safe becausefinish()already guards against double-call. The route fix matches/editor's pattern exactly.Notes
The microphone audio bugs (#1740, #1817) share the same root cause (mic feed lock not released between recordings) — already fixed in main by stale-lock auto-recovery.
Greptile Summary
This PR fixes two desktop window and pointer-drag regressions. The main changes are:
AUTO_SHOW_WINDOW: falseto the/screenshot-editorroute.queueMicrotask.Confidence Score: 5/5
This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "fix: prevent area picker from immediatel..." | Re-trigger Greptile
Context used: