fix(panel): hand focus to the source app on every open-editor path - #148
Merged
Conversation
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.
Problem
"Open editor" (
O/ Enter on a stop event) sometimes leaves you looking at StackNudge instead of jumping to the source app. It worked intermittently, which read as flaky.Cause
actOnSelectedonly hid the panel when the acted-on event was the last one in the list:Any time other events remained,
AppActivator.activatewas dispatched with the panel still up and StackNudge still active. The panel is.floating,hidesOnDeactivate = false,.canJoinAllSpaces, andpanelDidResignKey's auto-hide is gated behind!panelPinned(pin defaults on), so nothing else pulled it down — the source app never came forward. Events have no TTL, so a non-empty list is the common case.The three sibling focus paths all hide first:
focusSelectedSession(hidePanel()), the banner-click handler (NSApp.hide+ settle), andopenConfig(orderOut). Only the events-tab path didn't.Fix
actOnSelected: split the removal concern from the hide concern. Every path that hands focus to the source app (editor jump or approval keystroke) nowhidePanel()s unconditionally, then settles 0.15s beforeAppActivator.activateso our deactivation lands before the target is raised. Blocking-permissionOstill keeps the event in the store (so it can be resolved later) but now hides too. Pure FIFO-approve keeps the panel up while other prompts remain (triage), closing only when the list empties — it doesn't jump anywhere.focusSelectedSession: added the same 0.15s settle after its existinghidePanel().AppActivator: the sixNSAppleScriptcalls swallowed their error dicts. They now route throughlogScriptError, which prints to stderr underSTACKNUDGE_PANEL_DEBUG(no-op otherwise). A missing Automation grant — wiped on every ad-hoc rebuild, and reset dozens of times in local logs — makes these calls silently no-op, which is a plausible second contributor; this makes the next occurrence diagnosable instead of invisible.Verification
swiftc -typecheckpanel+shared: exit 0 (only pre-existing deprecation warnings)../build.sh: exit 0.make reload: injected 2+ events, pressedOon a non-last event — panel now hides and the source window comes forward. Previously it stayed up.