Skip to content

fix: preserve Quick Access previews after save and drag races - #367

Merged
lzhgus merged 1 commit into
lzhgus:mainfrom
sivyrn:fix/quick-access-preview-reliability
Oct 20, 2026
Merged

lzhgus merged 1 commit into
lzhgus:mainfrom
sivyrn:fix/quick-access-preview-reliability

Conversation

@sivyrn

@sivyrn sivyrn commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • XcodeGen generation and full App test suite passed: 216 tests, English/US.
  • Regressions cover large/panoramic/portrait thumbnails, original-image preservation, save failure followed by successful retry, late drag completion, entrance interruption, eviction, and reopening.
  • The save-failure string includes all 10 non-English locales (11 languages including source English).
  • git diff --check passed.

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.

@sivyrn
sivyrn marked this pull request as ready for review October 19, 2026 08:40

@lzhgus lzhgus left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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
lzhgus merged commit 56d36a4 into lzhgus:main Oct 20, 2026
2 checks passed
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>
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.

2 participants