Skip to content

fix: area picker click-drag regression and screenshot editor window lifecycle#1950

Open
shashank-sn wants to merge 2 commits into
CapSoftware:mainfrom
shashank-sn:fix/area-picker-mic-audio-window-instant-audio-bugs
Open

fix: area picker click-drag regression and screenshot editor window lifecycle#1950
shashank-sn wants to merge 2 commits into
CapSoftware:mainfrom
shashank-sn:fix/area-picker-mic-audio-window-instant-audio-bugs

Conversation

@shashank-sn

@shashank-sn shashank-sn commented Jun 29, 2026

Copy link
Copy Markdown

Summary

Fixes two high-impact desktop bugs reported by the community:

  1. 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 setPointerCapture has established, immediately killing the drag session. Defers the check with queueMicrotask so capture completes first.

  2. 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-editor route was missing the AUTO_SHOW_WINDOW: false flag that /editor already 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.tsxqueueMicrotask in blur handler
  • apps/desktop/src/app.tsxAUTO_SHOW_WINDOW: false on /screenshot-editor route

Verification

Both fixes follow existing patterns. The queueMicrotask approach is safe because finish() 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:

  • Adds AUTO_SHOW_WINDOW: false to the /screenshot-editor route.
  • Defers the Cropper blur-time pointer-capture check with queueMicrotask.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The screenshot editor is still shown by its current window open and re-show paths.
  • The Cropper drag cleanup remains guarded against duplicate teardown.

Important Files Changed

Filename Overview
apps/desktop/src/app.tsx Adds screenshot-editor route metadata to suppress the app-level auto-show path.
apps/desktop/src/components/Cropper.tsx Defers Cropper blur handling so pointer capture can settle before ending the drag session.

Reviews (1): Last reviewed commit: "fix: prevent area picker from immediatel..." | Re-trigger Greptile

Context used:

  • Context used - CLAUDE.md (source)
  • Context used - AGENTS.md (source)

shashank-sn and others added 2 commits June 29, 2026 07:26
…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 thread apps/desktop/src/components/Cropper.tsx
Comment thread apps/desktop/src/components/Cropper.tsx
Comment thread apps/desktop/src/components/Cropper.tsx Outdated
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();
});
},
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
});
},

@shashank-sn shashank-sn force-pushed the fix/area-picker-mic-audio-window-instant-audio-bugs branch from 95c396a to 9be96b9 Compare June 29, 2026 02:44

@shashank-sn shashank-sn left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed all review comments:

  • queueMicrotask in blur handler: The code compiles cleanly with a single blur handler — no duplicate lines or stray syntax. queueMicrotask is standard API in all environments Cap targets (WebKit on macOS, Chromium on Windows/Linux). The Promise.resolve() suggestion is equivalent and unnecessary.

All other comments are false positives — the diff is two single-function hunks, correctly formatted.

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.

1 participant