Skip to content

Fix keyboard focus when entering session duration - #143

Open
ilya-the-frog wants to merge 2 commits into
krishhgg:mainfrom
ilya-the-frog:fix/duration-input-focus
Open

ilya-the-frog wants to merge 2 commits into
krishhgg:mainfrom
ilya-the-frog:fix/duration-input-focus

Conversation

@ilya-the-frog

@ilya-the-frog ilya-the-frog commented Oct 23, 2026 •

Copy link
Copy Markdown

When the duration pills are open, digits can still reach the previously active app (for example, a search field in Telegram). The pills also stay visible while the Settings/Quit menu is handling input.

Activate Insomnia and make its typing panel key, using the same activation call as SettingsWindow. Remember the previous app and return focus when typing ends, provided Insomnia still owns activation. Losing the key window dismisses the pills without taking focus back; opening the context menu dismisses them before menu tracking begins.

This branch starts from main and contains only the input-focus fix. It is independent of #142 (Login Items attribution).

Validation:

  • Release build passed with warnings treated as errors.
  • Added a regression test for focus-loss dismissal and panel cleanup; updated the panel-style test.
  • CI passed for b6ee899: release builds and Swift tests on macOS 26 and 27, ShellCheck, and workflow lint. Each macOS suite reported 1,273 tests, 10 skipped and 0 failures; the new focus-loss regression passed on both.
  • An isolated AppKit probe compiled the changed KeyCatcherPanel.swift into a disposable accessory app, with a second disposable app as the previous keyboard owner. All three checks passed: the catcher becomes the actual key window while its app is active; closing it returns activation; switching apps fires focus-loss dismissal and leaves the new app active.
  • Updated the specification and real-Mac release checklist.

Not run: physical-keyboard validation of the installed PR head, extension/refused-start paths, context-menu interactions, and multiple displays/Spaces. The isolated probe is not the installed-head real-Mac report required by CONTRIBUTING before merge. The currently installed #142 validation build has not been replaced.

RetriggerView in GreptileConfidence Score: 5/5

The reviewed changes appear safe to merge; the previous Settings-focus issue is fixed and no new actionable issue was found.

Summary

The PR activates Insomnia while users enter a duration and returns focus when typing ends.

  • The duration pills keep keyboard input in Insomnia and return focus when they close.

Reviews (2) · Last reviewed commit: "Keep focus in Insomnia when clicking its..." · Reviewed by Greptile

Comment thread Sources/Insomnia/UI/StatusItemController.swift
@krishhgg

Copy link
Copy Markdown
Owner

Thank you for this. Your head commit b6ee899 is merged unchanged into #145, together with five other menu bar pull requests that change the same files. When #145 merges, GitHub marks this pull request as merged too, with your commits and your authorship.

Please don't push to this branch from now on. A new commit wouldn't be in #145, so this pull request would stay open instead of showing as merged. If you want to change something, comment here and I'll add it to #145.

#145's description lists the conflicts resolved in its merge commits and the two maintainer fixes after them.

🤖 Generated with Claude Code

krishhgg added a commit that referenced this pull request Oct 24, 2026
Integration branch integration/menu-controls at ce8ba6f, built and
installed with install.sh --app in a macOS 27.0.1 VM: hold-to-end,
End session in the menu, the Time left row, the countdown toggle,
End time with a time zone change, typing into the pills (#143), and
displays asleep. Pill-click sheets for ce8ba6f, main e242782, e537b3a,
091e413 and 25e6f15. Scripts in scripts/.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
krishhgg added a commit that referenced this pull request Oct 24, 2026
On macOS 27 a press on the status item deactivates Insomnia while the
button is still down. The catcher panel from #143 then resigns key, and
its focus-lost handler collapsed the pills about 1 ms after the press,
before the pill's tap (on release) could focus it. So a pill click closed
the pills, and #93's fix for the same click was lost in the merge.

Focus lost with the pointer on the item now waits for the release: a
pill takes focus back through focus(_:), and if the catcher is still not
key 0.2 s after the release the pills close, so typing never goes to
another app while they show. Focus lost anywhere else collapses at once,
as before.

Checked in a macOS 27.0.1 VM: Minutes and Days clicks keep the pills
open, typed digits land in them and start or extend the session, and a
click elsewhere, Cmd-Tab, Escape, an eye click and a drag off a pill
still close them. The hold-to-end checks still pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
krishhgg added a commit that referenced this pull request Oct 24, 2026
P1 and P2 pill clicks, X1 to X15, hold-to-end (part A) and the #143
typing checks (part F) against 732de03, plus X11 against the first fix
(ce8ba6f with fix145.diff) as a control.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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