Skip to content

Fix overlay stuck visible on rapid Fn presses - #43

Merged
initcore0 merged 1 commit into
mainfrom
fix/overlay-rapid-toggle
Jun 23, 2026
Merged

Fix overlay stuck visible on rapid Fn presses#43
initcore0 merged 1 commit into
mainfrom
fix/overlay-rapid-toggle

Conversation

@initcore0

Copy link
Copy Markdown
Owner

Repro: pressing Fn rapidly leaves the recording overlay on screen.

Cause: OverlayWindowController.hide()'s fade-out completion tears the panel down. If a new show() arrives mid-fade (rapid toggle), it reuses the panel, then the stale completion destroys the panel the new session is showing — desyncing panel from the screen and from overlayIsVisible, so the next hide no-ops while a window stays up.

Fix: a generation counter; the fade-out teardown only runs if no show()/hide() happened after it started. show() also no longer hard-resets alpha (only a fresh panel starts at 0), so a reused mid-fade panel animates smoothly back up.

Animation/timing code can't be unit-tested without a window server; verified by build + reasoning. swift test 92/92.

🤖 Generated with Claude Code

Repro: pressing Fn rapidly leaves the recording overlay on screen.

Cause: OverlayWindowController.hide() starts a 0.14s fade-out whose completion
handler tears the panel down (orderOut + nil contentViewController + panel = nil).
If a new show() arrives during that fade (rapid toggle), it reuses the still-
present panel — then the OLD fade-out completion fires and destroys the panel the
new session is showing, desyncing `panel` from what's on screen and from
AppState.overlayIsVisible, so the next hideOverlayNow() no-ops (panel already nil)
while a window stays visible.

Fix: a generation counter bumped on every show()/hide(). The fade-out completion
only tears down if its generation is still current; a show()/hide() that arrives
after cancels the teardown. show() no longer hard-resets alpha to 0 (only a
freshly-created panel starts at 0), so a reused mid-fade panel animates back up
from its current alpha instead of flashing.

Animation/timing code (NSAnimationContext) can't be unit-tested without a window
server; verified by build + reasoning. swift test 92/92; builds clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@initcore0
initcore0 merged commit b335255 into main Jun 23, 2026
3 checks passed
@initcore0
initcore0 deleted the fix/overlay-rapid-toggle branch June 23, 2026 19:49
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