fix(quickadd): return focus to the previous app when the ⌘' popover hides #16

Merged
eblume merged 1 commit from feature/quickadd-focus-return into main 2026-06-08 20:22:13 -07:00
Owner

Problem

The global ⌘' quick-add popover (heph-quickadd) is a borderless, transparent, always-on-top macOS accessory window. It hides via winit's ViewportCommand::Visible(false), which orders the window out visually but leaves heph-quickadd the active application. As a result, after creating a task (or pressing Esc / toggling off):

  • keyboard focus never returns to the app the user was in, and
  • the now-invisible always-on-top overlay can keep intercepting clicks where it used to sit.

Fix

Hide at the application level via NSApplication.hide:, which fully orders our windows out and activates the next app in line — exactly the previously focused app. On re-show, unhide: clears the app-level hidden flag before the existing viewport Focus command makes the field key again.

  • New macOS-only helpers app_yield_focus() (in hide()) and app_take_focus() (in show()); both are no-ops off macOS.
  • Backed by objc2 / objc2-app-kit, pinned to the 0.6 / 0.3 line global-hotkey already pulls in — cargo unifies to one copy, no net-new crate versions.

Testing

  • cargo build -p heph-quickadd + cargo clippy -p heph-quickadd clean
  • Manual (macOS, owner): ⌘' from another app → type a task → Enter; focus should snap back to that app and clicks should land normally where the popover was. Repeat with Esc and with ⌘'-toggle-off. Confirm re-opening with ⌘' still steals focus to the field.

🤖 Generated with Claude Code

## Problem The global ⌘' quick-add popover (`heph-quickadd`) is a borderless, transparent, always-on-top macOS *accessory* window. It hides via winit's `ViewportCommand::Visible(false)`, which orders the window out visually but leaves `heph-quickadd` the **active application**. As a result, after creating a task (or pressing Esc / toggling off): - keyboard focus never returns to the app the user was in, and - the now-invisible always-on-top overlay can keep **intercepting clicks** where it used to sit. ## Fix Hide at the *application* level via `NSApplication.hide:`, which fully orders our windows out **and** activates the next app in line — exactly the previously focused app. On re-show, `unhide:` clears the app-level hidden flag before the existing viewport `Focus` command makes the field key again. - New macOS-only helpers `app_yield_focus()` (in `hide()`) and `app_take_focus()` (in `show()`); both are no-ops off macOS. - Backed by `objc2` / `objc2-app-kit`, pinned to the `0.6` / `0.3` line `global-hotkey` already pulls in — cargo unifies to one copy, no net-new crate versions. ## Testing - [x] `cargo build -p heph-quickadd` + `cargo clippy -p heph-quickadd` clean - [ ] **Manual (macOS, owner):** ⌘' from another app → type a task → Enter; focus should snap back to that app and clicks should land normally where the popover was. Repeat with Esc and with ⌘'-toggle-off. Confirm re-opening with ⌘' still steals focus to the field. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(quickadd): return focus to the previous app when the popover hides
All checks were successful
Build / validate (pull_request) Successful in 5m52s
470ef1de0e
The global ⌘' quick-add overlay is a borderless, transparent, always-on-top
accessory window that winit hides with `Visible(false)`. That orders the window
out visually but leaves heph-quickadd the *active* application — so after a
capture (or Esc / toggle) keyboard focus never returns to the app the user was
in, and the lingering overlay can keep intercepting clicks where it used to sit.

Hide at the application level instead via `NSApplication.hide:`, which fully
orders our windows out and activates the next app in line (the previously
focused one). On re-show, `unhide:` clears that hidden flag before the existing
viewport `Focus` command makes the field key again. Both are macOS-only no-ops
elsewhere, wired through new `app_yield_focus`/`app_take_focus` helpers backed by
objc2 / objc2-app-kit (unified to the 0.6/0.3 line global-hotkey already pulls).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
eblume merged commit 17dab0e281 into main 2026-06-08 20:22:13 -07:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
eblume/hephaestus!16
No description provided.