Repository navigation
fix: preserve Quick Access previews after save and drag races - #367
Merged
Merged
Conversation
sivyrn
marked this pull request as ready for review
October 19, 2026 08:40
lzhgus
approved these changes
Oct 20, 2026
lzhgus
left a comment
Owner
There was a problem hiding this comment.
Thanks @sivyrn, this is a nice one! I tested it in a Debug build: the Quick Access thumbnail stays sharp with the bounded texture; with an unwritable export folder, Save keeps the card open and shows the error, and retrying after fixing the folder saves and closes the card. The full App suite (224 tests) passes too. Merging. 🙏
One small note, not caused by this PR: the toast sizes itself from the character count, so "Failed to save screenshot" gets cut off. I'll fix the toast sizing separately.
lzhgus
pushed a commit
that referenced
this pull request
Oct 20, 2026
## Problem and behavior After automatic-language OCR hits a persistent `TextRecognition.CRImageReaderError` and the existing fresh-process helper succeeds, subsequent captures currently retry the same broken in-process Vision path. Remember that confirmed recovery for the app lifetime and route later automatic-language requests directly to the helper. Successful primary requests, unrelated errors, failed helpers, and cancelled requests do not enable this routing. Explicit-language requests still try the primary recognizer. Cancellation is checked before routing and after helper completion, including when the helper route is already remembered. ## Scope Only `OCRProcessFallback.swift` and the new `OCRFallbackRoutingTests.swift` differ from main. Startup/prewarming, OCRKit, shortcut recording, the capture cursor, and Quick Access animations retain main's behavior. No helper is launched at app startup by this change. The other independent fixes are in #365 (translation sessions), #366 (image scaling), and #367 (Quick Access). ## Reproduction and validation The targeted failure is the process-local Vision failure described by the existing helper implementation from #338: accurate automatic-language OCR fails with `TextRecognition.CRImageReaderError` in the current process while the same request succeeds in a fresh helper. Repeated requests in that affected process are the case this router avoids. Current live probe: on macOS 27.2 (26B5112a), three consecutive `VNRecognizeTextRequest` calls in one process, using the same generated English/Chinese image, `.accurate`, automatic language detection, and language correction, all completed without that engine error. The historical OS fault was **not reproduced on this run**, and this PR makes no startup or first-request performance claim. The deterministic regression tests inject that specific error followed by helper success and assert that three requests use the primary once and the helper three times. Separate tests cover successful primary calls, explicit languages, unrelated errors, helper failure, cancellation during primary/helper work, and cancellation after the helper route is remembered. Tests live in their own file, with explicitly `@Sendable` closures to address the older-Xcode CI diagnostic. Local validation (Apple Silicon, Xcode 27, English/US): - XcodeGen generation and full App test suite: 219 tests passed, including all 8 routing tests and the real executable-helper integration test. - `git diff --check` passed. Ready for review of the OS-specific routing policy. GitHub Actions and GitGuardian passed on commit `28310cb`. The live reproduction limitation described above remains unchanged.
lzhgus
added a commit
that referenced
this pull request
Oct 20, 2026
Noticed while testing #367: the new "Failed to save screenshot" toast showed as "Failed to save screensh…". - The toast guessed its width from `message.count * 8`, and `NSHostingView` then resized the panel to the content's ideal size, which was narrower than the rendered text. The text was truncated, and the capsule was left-aligned in the panel rather than centered. - Now the panel is sized from the hosting view's `fittingSize` and centered on that. The content uses `fixedSize()`, and has a 12 pt margin so the shadow isn't clipped. Tested in the Debug app with an unwritable export folder: the full message shows, the capsule and shadow are intact, and the toast is centered on the screen. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01CEFcqadVpnqXceY8Ke7Szp Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Quick Access could close after a failed save, and a late drag callback could restore a preview that was already closing. Keep the preview available for retry after a failed save and show a localized error; ignore drag, hover, restack, and timer callbacks once closing starts. Bound the centered display thumbnail while retaining the original capture for actions and the drag image.
This is the Quick Access split requested in #357. It preserves main's entrance, close, and eviction animations, native shortcut recorder, capture reticle, and newly added Save As action. It is independent of the ImageUtilities PR.
Validation on Apple Silicon / Xcode 27:
git diff --checkpassed.Ready for review. Manual multi-display/drag visual verification and screenshots remain pending; the automated validation above does not cover those manual checks. GitHub Actions and GitGuardian passed on commit
3ef1eaf.