feat: use NSPanel for macOS spotlight window - #161
Open
vuon9 wants to merge 8 commits into
Open
Conversation
- Upgrade wails v3 beta.6 -> master (beta.11 pseudo-version) for MacWindowClassPanel support (wailsapp/wails#6008) - Spotlight window now uses an NSPanel with NonActivating, FloatingPanel and BecomesKeyOnlyIfNeeded, so showing/focusing it no longer activates the app or steals focus from the active application - Drop the 100ms async-hide workaround for macOS reverting focus to the previously active app; non-activating panels make it unnecessary Entire-Checkpoint: 960b22501128
- Spotlight window height now follows the visible result count: the frontend emits spotlight:resize with the computed height and the backend resizes the NSPanel (SetSize + Center). Removed the fixed 384px MinHeight/MaxHeight cap (MinHeight 100, JS caps at 600) - Fix Escape not closing the palette: frontend emitted command-palette:close but the backend listens for spotlight:close (event name mismatch, pre-existing) - Fix opened-event mismatch: frontend now listens for spotlight:opened which the service emits - Results area no longer has a hardcoded 264px height; list scrolls within the window (max-height: calc(100vh - 49px))
Replace Center() after resize with a fixed position: horizontally centered, top edge at 15% of screen height, so the panel grows downward like macOS Spotlight instead of re-centering. Also position the panel once at startup instead of relying on WindowCentered.
- Draggable via the Wails runtime --wails-draggable: drag CSS hook on the panel container (input, clear button and result items stay no-drag) - Persist the panel position to settings on WindowDidMove (debounced 200ms) - On open, restore the last position; fall back to the default top position only on first run - Resize no longer repositions the panel, so the user's placement is kept
The whole panel used to be a drag region, which made it unclear where dragging works. Now only the search icon is draggable (grab cursor) and everything else stays interactive.
The lucide search icon is an <svg> containing <circle>/<line> children. Those SVG children report clientWidth/clientHeight of 0, so the Wails runtime draggable check (offsetX < clientWidth) failed whenever the click landed on a child element, making drag work only sometimes. Route pointer events to the svg root with pointer-events: none on children.
…NSPanel support WebviewPanel (NSPanel) does not implement handleLeftMouseDown/leftMouseEvent, so the Wails runtime's --wails-draggable path would fail (and could crash on startDrag). Replace it with a JS-tracked drag: mousedown on the search icon records screen coords, mousemove emits spotlight:drag with the delta, and the backend moves the panel with SetPosition. Position is saved on drag end.
- Drop unused SpotlightService.IsVisible() and Close() (no callers) - Drop unlistened spotlight:closed emit - Drop spotlight:theme:toggle handler (nothing emits it) - Drop app:quit handler (nothing emits it) - Update spotlight tests to only assert no-panic behaviour
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.
Summary
MacWindowClassPanelsupport (Add macOS NSPanel window support wailsapp/wails#6008, merged 2026-08-21)NonActivating,FloatingPanelandBecomesKeyOnlyIfNeededpreferences: showing or focusing the launcher no longer activates DevToolbox or steals focus from the active app (Spotlight/Raycast behaviour)Test Plan
go build ./...passes (macOS)go vet ./...passesgo test ./internal/... ./service/...all passNotes
N/A