fix(desktop): restore last confirmed capture area when reopening selector#1872
Open
ManthanNimodiya wants to merge 3 commits into
Open
fix(desktop): restore last confirmed capture area when reopening selector#1872ManthanNimodiya wants to merge 3 commits into
ManthanNimodiya wants to merge 3 commits into
Conversation
…nitialCrop to captureTarget bounds
Contributor
Author
|
@richiemcilroy, have a look when you get chance and lmk for any changes |
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.
Problem
When a user had previously selected a capture area and reopened the area selector, it always started blank, forcing them to redraw their selection every time.
This was reported by multiple users in the community.
The root cause was in
target-select-overlay.tsx:initialAreaBounds(which seeds the Cropper's starting position) was always initialized toundefined, even when an existing area target was already set.Solution
Added an
effectiveInitialBoundsmemo that falls back to the currentcaptureTargetarea bounds when no explicitinitialAreaBoundsis set.Both
initialCropandshouldShowSelectionHintnow use this memo, so:Also fixed
capture-area.tsx(the alternate area selection flow) with the same pattern,activeScreenIdnow handles both"display"and"area"capture target variants.Test Plan
Greptile Summary
This PR restores previously confirmed capture-area bounds when the selector is reopened, fixing a reported UX regression. The fix addresses both selection flows independently:
target-select-overlay.tsxgets aneffectiveInitialBoundsmemo that falls back tooptions.captureTarget.bounds(guarded bytarget.screen === params.displayIdfor multi-display safety), andcapture-area.tsxgets ascreenIdderived from both"display"and"area"variants so that a prior area confirmation no longer silently breaks subsequent saves and pre-loads.target-select-overlay.tsx: neweffectiveInitialBoundsmemo correctly short-circuits to storedcaptureTargetbounds; drives bothshouldShowSelectionHintandinitialCrop.capture-area.tsx:activeScreenIdnow returnstarget.screenfor the"area"variant; a "frozen on first non-null" pattern prevents stale async Tauri-store updates from overwriting the resolved screen ID. Minor gap:initialCropdoesn't fall back torawOptions.captureTarget.bounds, so the first open ofcapture-area.tsxafter an overlay-confirmed area still starts blank.Confidence Score: 4/5
Safe to merge; the fix is scoped to UI initialisation logic and cannot cause data loss or corrupt the saved capture target.
The overlay fix is solid and well-guarded. The capture-area.tsx fix correctly unblocks the previously broken area variant path, but the initialCrop accessor still reads only from state.lastSelectedBounds and doesn't fall back to rawOptions.captureTarget.bounds, leaving a small parity gap with the overlay flow. The redundant reactive dependency in the frozen-signal effect is harmless but worth cleaning up.
apps/desktop/src/routes/capture-area.tsx — the initialCrop fallback logic and the screenId guard effect.
Important Files Changed
Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "fix(desktop): restore last confirmed cap..." | Re-trigger Greptile