From 29983a096986ac94196b67da3a37d4c907ed8713 Mon Sep 17 00:00:00 2001 From: Vuong <3168632+vuon9@users.noreply.github.com> Date: Fri, 21 Aug 2026 15:15:26 +0700 Subject: [PATCH 1/8] feat: use NSPanel for macOS spotlight window - 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 --- go.mod | 2 +- go.sum | 4 ++-- main.go | 24 ++++++++++++++---------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index dc41ffc..fde2dc1 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/pelletier/go-toml/v2 v2.4.3 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e github.com/stretchr/testify v1.11.1 - github.com/wailsapp/wails/v3 v3.0.0-beta.6 + github.com/wailsapp/wails/v3 v3.0.0-beta.11.0.20260821044253-44df631f198a golang.design/x/hotkey v0.6.1 golang.org/x/crypto v0.54.0 golang.org/x/net v0.57.0 diff --git a/go.sum b/go.sum index 6d97061..89a2cc1 100644 --- a/go.sum +++ b/go.sum @@ -125,8 +125,8 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY= github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4= -github.com/wailsapp/wails/v3 v3.0.0-beta.6 h1:k9FHF/T39EyTZNCHweRrLt1c6dwV3R3A+r1oCNiPB8I= -github.com/wailsapp/wails/v3 v3.0.0-beta.6/go.mod h1:A/OaL1mXOnwWynTJv4rZU89Wbk5q3rtq3C3qkx4rRN0= +github.com/wailsapp/wails/v3 v3.0.0-beta.11.0.20260821044253-44df631f198a h1:oyvZVI2ubfK7jV7Q5sbaHsFPoEg3qPLiAeUA4HWoCgA= +github.com/wailsapp/wails/v3 v3.0.0-beta.11.0.20260821044253-44df631f198a/go.mod h1:zKZYhB3WjrN5LhJWbnOAVMN0Xf8qTozbw2nf5micKl4= go.mongodb.org/mongo-driver/v2 v2.5.0 h1:yXUhImUjjAInNcpTcAlPHiT7bIXhshCTL3jVBkF3xaE= go.mongodb.org/mongo-driver/v2 v2.5.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0= go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= diff --git a/main.go b/main.go index 0a00a67..af43742 100644 --- a/main.go +++ b/main.go @@ -149,8 +149,9 @@ func main() { windowControls.SetWindow(mainWindow) // Create spotlight window with special behaviors - // Note: MacWindowLevelFloating and ActivationPolicyAccessory may require - // platform-specific code. CollectionBehaviors provide most spotlight functionality. + // NSPanel-backed window: non-activating (does not steal focus or activation + // from the previously active app) and floating, so it behaves like a real + // Spotlight/Raycast launcher overlay instead of a regular NSWindow. spotlightWindow := app.Window.NewWithOptions(application.WebviewWindowOptions{ Title: "Spotlight", Width: 640, @@ -165,8 +166,14 @@ func main() { // Prevent resizing DisableResize: true, Mac: application.MacWindow{ - // Float above other windows - WindowLevel: application.MacWindowLevelFloating, + // Use a dedicated NSPanel so showing or focusing the launcher does + // not activate DevToolbox or steal focus from the active app. + WindowClass: application.MacWindowClassPanel, + PanelPreferences: application.MacPanelPreferences{ + NonActivating: true, + FloatingPanel: true, + BecomesKeyOnlyIfNeeded: true, + }, // Hidden title bar for clean look TitleBar: application.MacTitleBar{ AppearsTransparent: true, @@ -217,12 +224,9 @@ func main() { mainWindow.Show() mainWindow.Focus() - // Hide spotlight window asynchronously to prevent macOS from reverting focus - // to the previously active non-DevToolbox app - go func() { - time.Sleep(100 * time.Millisecond) - spotlightWindow.Hide() - }() + // Hide the panel. Non-activating NSPanels never took over app activation, + // so hiding immediately cannot make macOS revert focus to another app. + spotlightWindow.Hide() // Tell the frontend to navigate mainWindow.EmitEvent("navigate:to", path) From 6ce44768dd02012e0870396e5b314c628f1639b8 Mon Sep 17 00:00:00 2001 From: Vuong <3168632+vuon9@users.noreply.github.com> Date: Fri, 21 Aug 2026 15:22:33 +0700 Subject: [PATCH 2/8] fix: flexible spotlight height and Escape-to-close - 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)) --- frontend/src/components/CommandPalette.css | 4 ++-- frontend/src/components/CommandPalette.jsx | 20 +++++++++++++++--- main.go | 24 ++++++++++++++++++++-- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/CommandPalette.css b/frontend/src/components/CommandPalette.css index 8df5128..5bd8aca 100644 --- a/frontend/src/components/CommandPalette.css +++ b/frontend/src/components/CommandPalette.css @@ -59,7 +59,7 @@ } .command-palette-results { - height: 264px; /* Results area: 80% of original (332 * 0.8) */ + height: auto; /* Grows with the window; the JS backend drives window height */ overflow: hidden; background: #18181b; } @@ -73,7 +73,7 @@ .command-palette-list { overflow-y: auto; - max-height: 252px; /* 80% of original (320 * 0.8) */ + max-height: calc(100vh - 49px); /* Scroll within the window; 49px = search box */ } .command-palette-item { diff --git a/frontend/src/components/CommandPalette.jsx b/frontend/src/components/CommandPalette.jsx index be4fc3e..d1a3a37 100644 --- a/frontend/src/components/CommandPalette.jsx +++ b/frontend/src/components/CommandPalette.jsx @@ -251,7 +251,7 @@ export function CommandPalette() { // Listen for command palette opened event useEffect(() => { - const unsubscribe = window.runtime?.EventsOn?.('command-palette:opened', () => { + const unsubscribe = window.runtime?.EventsOn?.('spotlight:opened', () => { setSearchQuery(''); setSelectedIndex(0); setTimeout(() => inputRef.current?.focus(), 100); @@ -261,6 +261,20 @@ export function CommandPalette() { }; }, []); + // Resize the spotlight window to fit the visible results (Spotlight-like + // dynamic height). The backend listens for spotlight:resize and resizes + // the NSPanel while keeping it centered. + useEffect(() => { + const itemCount = commands.length; + const shown = Math.min(itemCount, 12); + const height = Math.max(100, Math.min(600, 49 + shown * 37 + 2)); + try { + Events.Emit('spotlight:resize', height); + } catch (err) { + console.error('Failed to emit spotlight:resize', err); + } + }, [commands.length]); + // Save recent command const saveRecentCommand = useCallback((commandId) => { setRecentCommands((prev) => { @@ -323,9 +337,9 @@ export function CommandPalette() { e.preventDefault(); console.log('[CommandPalette] Escape pressed, closing...'); try { - Events.Emit('command-palette:close'); + Events.Emit('spotlight:close'); } catch (err) { - console.error('Failed to emit command-palette:close', err); + console.error('Failed to emit spotlight:close', err); } } }, diff --git a/main.go b/main.go index af43742..7c91ec3 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( "os" "path/filepath" "runtime" + "strconv" "strings" "time" @@ -156,8 +157,7 @@ func main() { Title: "Spotlight", Width: 640, Height: 384, - MinHeight: 384, - MaxHeight: 384, + MinHeight: 100, Frameless: true, Hidden: true, BackgroundColour: application.RGBA{Red: 22, Green: 22, Blue: 22, Alpha: 255}, @@ -238,6 +238,26 @@ func main() { spotlightWindow.Hide() }) + // Resize spotlight window to fit content (height driven by the frontend, + // which knows how many results are visible). Keeps the panel centered. + app.Event.On("spotlight:resize", func(event *application.CustomEvent) { + var h float64 + switch v := event.Data.(type) { + case float64: + h = v + case int: + h = float64(v) + case string: + if parsed, err := strconv.ParseFloat(v, 64); err == nil { + h = parsed + } + } + if h > 0 { + spotlightWindow.SetSize(640, int(h)) + spotlightWindow.Center() + } + }) + // Proxy these events to the main window app.Event.On("spotlight:theme:toggle", func(_ *application.CustomEvent) { log.Printf("[Spotlight] Relaying theme:toggle to main window") From 5b80a23bf1ab97bcfa3583d7be654d5a132cc2ab Mon Sep 17 00:00:00 2001 From: Vuong <3168632+vuon9@users.noreply.github.com> Date: Fri, 21 Aug 2026 15:27:41 +0700 Subject: [PATCH 3/8] fix: keep spotlight top edge fixed while resizing 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. --- main.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 7c91ec3..ab2c92e 100644 --- a/main.go +++ b/main.go @@ -161,8 +161,6 @@ func main() { Frameless: true, Hidden: true, BackgroundColour: application.RGBA{Red: 22, Green: 22, Blue: 22, Alpha: 255}, - // Center the window - InitialPosition: application.WindowCentered, // Prevent resizing DisableResize: true, Mac: application.MacWindow{ @@ -186,6 +184,10 @@ func main() { // Set the window in spotlight service spotlightService.SetWindow(spotlightWindow) + // Position the panel once so the first show appears at the right place + // before the frontend drives resizes. + positionSpotlight(spotlightWindow) + // Handle spotlight window close - hide instead of close spotlightWindow.OnWindowEvent(events.Common.WindowClosing, func(event *application.WindowEvent) { event.Cancel() @@ -254,7 +256,7 @@ func main() { } if h > 0 { spotlightWindow.SetSize(640, int(h)) - spotlightWindow.Center() + positionSpotlight(spotlightWindow) } }) @@ -320,6 +322,20 @@ func main() { } } +// positionSpotlight keeps the spotlight panel horizontally centered while its +// top edge stays at a fixed height below the top of the screen, so resizing +// makes it grow downward instead of re-centering (macOS Spotlight behaviour). +func positionSpotlight(w *application.WebviewWindow) { + screen, err := w.GetScreen() + if err != nil || screen == nil { + w.Center() + return + } + x := screen.Bounds.X + (screen.Bounds.Width-640)/2 + y := screen.Bounds.Y + int(float64(screen.Bounds.Height)*0.15) + w.SetPosition(x, y) +} + func GinMiddleware(ginEngine *gin.Engine) application.Middleware { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { From 85df5f64084d66baf248b2316c16b6d21a3efd4f Mon Sep 17 00:00:00 2001 From: Vuong <3168632+vuon9@users.noreply.github.com> Date: Fri, 21 Aug 2026 15:32:58 +0700 Subject: [PATCH 4/8] feat: make spotlight draggable and remember its position - 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 --- frontend/src/components/CommandPalette.css | 6 +++++ internal/settings/settings.go | 24 +++++++++++++++++++ main.go | 27 ++++++++++++++++++---- 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/CommandPalette.css b/frontend/src/components/CommandPalette.css index 5bd8aca..7432ed7 100644 --- a/frontend/src/components/CommandPalette.css +++ b/frontend/src/components/CommandPalette.css @@ -8,6 +8,9 @@ border-radius: 0; box-shadow: none; overflow: hidden; + /* Wails runtime: mousedown + move on a --wails-draggable: drag element + starts a native window drag, so the panel can be moved around. */ + --wails-draggable: drag; } .command-palette-search-box { @@ -35,6 +38,7 @@ system-ui, -apple-system, sans-serif; + --wails-draggable: no-drag; } .command-palette-input::placeholder { @@ -52,6 +56,7 @@ justify-content: center; border-radius: 4px; transition: background-color 0.15s ease; + --wails-draggable: no-drag; } .command-palette-clear-btn:hover { @@ -84,6 +89,7 @@ cursor: pointer; transition: background-color 0.15s ease; border-bottom: none; + --wails-draggable: no-drag; } .command-palette-item:hover, diff --git a/internal/settings/settings.go b/internal/settings/settings.go index 04dd779..a47469b 100644 --- a/internal/settings/settings.go +++ b/internal/settings/settings.go @@ -10,6 +10,10 @@ import ( // Settings holds the application settings type Settings struct { CloseMinimizesToTray bool `json:"closeMinimizesToTray"` + // SpotlightX/SpotlightY remember the last position of the spotlight + // panel. nil means the user has never moved it. + SpotlightX *int `json:"spotlightX,omitempty"` + SpotlightY *int `json:"spotlightY,omitempty"` } // Manager handles settings persistence @@ -88,3 +92,23 @@ func (m *Manager) ToggleCloseMinimizesToTray() error { return m.Save() } + +// GetSpotlightPosition returns the last remembered spotlight position. +// The bool is false when the user has never moved the panel. +func (m *Manager) GetSpotlightPosition() (int, int, bool) { + m.mu.RLock() + defer m.mu.RUnlock() + if m.settings.SpotlightX == nil || m.settings.SpotlightY == nil { + return 0, 0, false + } + return *m.settings.SpotlightX, *m.settings.SpotlightY, true +} + +// SetSpotlightPosition remembers the spotlight panel position +func (m *Manager) SetSpotlightPosition(x, y int) error { + m.mu.Lock() + m.settings.SpotlightX = &x + m.settings.SpotlightY = &y + m.mu.Unlock() + return m.Save() +} diff --git a/main.go b/main.go index ab2c92e..942ea67 100644 --- a/main.go +++ b/main.go @@ -184,9 +184,29 @@ func main() { // Set the window in spotlight service spotlightService.SetWindow(spotlightWindow) - // Position the panel once so the first show appears at the right place - // before the frontend drives resizes. - positionSpotlight(spotlightWindow) + // Position the panel: stick to the last position the user dragged it to, + // or fall back to the default position on first run. + if x, y, ok := settingsManager.GetSpotlightPosition(); ok { + spotlightWindow.SetPosition(x, y) + } else { + positionSpotlight(spotlightWindow) + } + + // Remember the panel position whenever it moves (e.g. user drags it), so + // the next open sticks to the latest position. Debounced at 200ms to avoid + // writing settings on every mousemove during a drag. + var lastSpotlightSave time.Time + spotlightWindow.OnWindowEvent(events.Common.WindowDidMove, func(event *application.WindowEvent) { + now := time.Now() + if now.Sub(lastSpotlightSave) < 200*time.Millisecond { + return + } + lastSpotlightSave = now + x, y := spotlightWindow.Position() + if err := settingsManager.SetSpotlightPosition(x, y); err != nil { + log.Printf("[Spotlight] Failed to save position: %v", err) + } + }) // Handle spotlight window close - hide instead of close spotlightWindow.OnWindowEvent(events.Common.WindowClosing, func(event *application.WindowEvent) { @@ -256,7 +276,6 @@ func main() { } if h > 0 { spotlightWindow.SetSize(640, int(h)) - positionSpotlight(spotlightWindow) } }) From 4d1ead57dbb84a52b585c2d24f137a147a961f26 Mon Sep 17 00:00:00 2001 From: Vuong <3168632+vuon9@users.noreply.github.com> Date: Fri, 21 Aug 2026 15:46:13 +0700 Subject: [PATCH 5/8] feat: restrict spotlight drag to the search icon handle 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. --- frontend/src/components/CommandPalette.css | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/CommandPalette.css b/frontend/src/components/CommandPalette.css index 7432ed7..08e25cf 100644 --- a/frontend/src/components/CommandPalette.css +++ b/frontend/src/components/CommandPalette.css @@ -8,9 +8,6 @@ border-radius: 0; box-shadow: none; overflow: hidden; - /* Wails runtime: mousedown + move on a --wails-draggable: drag element - starts a native window drag, so the panel can be moved around. */ - --wails-draggable: drag; } .command-palette-search-box { @@ -24,6 +21,15 @@ .command-palette-search-icon { color: #71717a; flex-shrink: 0; + /* Wails runtime: mousedown + move on a --wails-draggable: drag element + starts a native window drag. The search icon is the explicit drag + handle, with a grab cursor so it's discoverable. */ + --wails-draggable: drag; + cursor: grab; +} + +.command-palette-search-icon:active { + cursor: grabbing; } .command-palette-input { From 2fe82f444ce0c79d426acb6490761e92027572a2 Mon Sep 17 00:00:00 2001 From: Vuong <3168632+vuon9@users.noreply.github.com> Date: Fri, 21 Aug 2026 15:47:31 +0700 Subject: [PATCH 6/8] fix: make spotlight drag handle work consistently on SVG icons The lucide search icon is an containing / 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. --- frontend/src/components/CommandPalette.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontend/src/components/CommandPalette.css b/frontend/src/components/CommandPalette.css index 08e25cf..fe7a615 100644 --- a/frontend/src/components/CommandPalette.css +++ b/frontend/src/components/CommandPalette.css @@ -28,6 +28,13 @@ cursor: grab; } +/* SVG child elements (circle/line) have zero clientWidth/clientHeight, which + makes the runtime's draggable check fail when the click lands on them. + Route all pointer events to the svg root so drag works consistently. */ +.command-palette-search-icon * { + pointer-events: none; +} + .command-palette-search-icon:active { cursor: grabbing; } From 40829cccb0574ce68f9e16a33751545449ce726e Mon Sep 17 00:00:00 2001 From: Vuong <3168632+vuon9@users.noreply.github.com> Date: Fri, 21 Aug 2026 15:52:34 +0700 Subject: [PATCH 7/8] fix: implement spotlight drag manually since Wails native drag lacks 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. --- frontend/src/components/CommandPalette.css | 15 +++---- frontend/src/components/CommandPalette.jsx | 49 +++++++++++++++++++++- main.go | 23 ++++++++++ 3 files changed, 77 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/CommandPalette.css b/frontend/src/components/CommandPalette.css index fe7a615..c8e493a 100644 --- a/frontend/src/components/CommandPalette.css +++ b/frontend/src/components/CommandPalette.css @@ -21,16 +21,16 @@ .command-palette-search-icon { color: #71717a; flex-shrink: 0; - /* Wails runtime: mousedown + move on a --wails-draggable: drag element - starts a native window drag. The search icon is the explicit drag - handle, with a grab cursor so it's discoverable. */ - --wails-draggable: drag; + /* Explicit drag handle for the panel. Wails native window drag does not + support NSPanel yet, so dragging is implemented in JS (mousedown/move + -> spotlight:drag events) and applied via SetPosition on the backend. + The grab cursor makes the handle discoverable. */ cursor: grab; } /* SVG child elements (circle/line) have zero clientWidth/clientHeight, which - makes the runtime's draggable check fail when the click lands on them. - Route all pointer events to the svg root so drag works consistently. */ + breaks offset-based hit checks. Route all pointer events to the svg root + so the drag handle behaves consistently. */ .command-palette-search-icon * { pointer-events: none; } @@ -51,7 +51,6 @@ system-ui, -apple-system, sans-serif; - --wails-draggable: no-drag; } .command-palette-input::placeholder { @@ -69,7 +68,6 @@ justify-content: center; border-radius: 4px; transition: background-color 0.15s ease; - --wails-draggable: no-drag; } .command-palette-clear-btn:hover { @@ -102,7 +100,6 @@ cursor: pointer; transition: background-color 0.15s ease; border-bottom: none; - --wails-draggable: no-drag; } .command-palette-item:hover, diff --git a/frontend/src/components/CommandPalette.jsx b/frontend/src/components/CommandPalette.jsx index d1a3a37..b1ef2f5 100644 --- a/frontend/src/components/CommandPalette.jsx +++ b/frontend/src/components/CommandPalette.jsx @@ -212,6 +212,49 @@ export function CommandPalette() { }); const inputRef = useRef(null); const listRef = useRef(null); + const dragRef = useRef(null); // { startX, startY } in screen coords + + // Custom panel dragging: Wails native window drag doesn't support NSPanel, + // so we track the pointer in JS and let the backend move the window. + const handleDragMouseDown = useCallback((e) => { + if (e.button !== 0) return; + dragRef.current = { startX: e.screenX, startY: e.screenY }; + try { + Events.Emit('spotlight:drag:start'); + } catch (err) { + console.error('Failed to emit spotlight:drag:start', err); + } + }, []); + + useEffect(() => { + const onMouseMove = (e) => { + if (!dragRef.current) return; + const { startX, startY } = dragRef.current; + try { + Events.Emit('spotlight:drag', { + dx: e.screenX - startX, + dy: e.screenY - startY, + }); + } catch (err) { + console.error('Failed to emit spotlight:drag', err); + } + }; + const onMouseUp = () => { + if (!dragRef.current) return; + dragRef.current = null; + try { + Events.Emit('spotlight:drag:end'); + } catch (err) { + console.error('Failed to emit spotlight:drag:end', err); + } + }; + window.addEventListener('mousemove', onMouseMove); + window.addEventListener('mouseup', onMouseUp); + return () => { + window.removeEventListener('mousemove', onMouseMove); + window.removeEventListener('mouseup', onMouseUp); + }; + }, []); // Calculate fuzzy match score const fuzzyScore = (target, query) => { @@ -357,7 +400,11 @@ export function CommandPalette() { return (
- + Date: Fri, 21 Aug 2026 16:34:57 +0700 Subject: [PATCH 8/8] chore: remove dead spotlight code - 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 --- main.go | 12 ------------ service/spotlight.go | 15 --------------- service/spotlight_test.go | 13 ------------- 3 files changed, 40 deletions(-) diff --git a/main.go b/main.go index c2678fb..eb0233a 100644 --- a/main.go +++ b/main.go @@ -212,7 +212,6 @@ func main() { spotlightWindow.OnWindowEvent(events.Common.WindowClosing, func(event *application.WindowEvent) { event.Cancel() spotlightWindow.Hide() - spotlightWindow.EmitEvent("spotlight:closed", "") }) // Listen for spotlight navigation events @@ -302,12 +301,6 @@ func main() { } }) - // Proxy these events to the main window - app.Event.On("spotlight:theme:toggle", func(_ *application.CustomEvent) { - log.Printf("[Spotlight] Relaying theme:toggle to main window") - mainWindow.EmitEvent("theme:toggle", nil) - }) - app.Event.On("window:toggle", func(_ *application.CustomEvent) { log.Printf("[Spotlight] Window toggle requested") if mainWindow.IsVisible() { @@ -318,11 +311,6 @@ func main() { } }) - app.Event.On("app:quit", func(_ *application.CustomEvent) { - log.Printf("[Spotlight] App quit requested via spotlight") - app.Quit() - }) - // Setup system tray systray := app.SystemTray.New() diff --git a/service/spotlight.go b/service/spotlight.go index bc04cd2..3568fa0 100644 --- a/service/spotlight.go +++ b/service/spotlight.go @@ -54,18 +54,3 @@ func (s *SpotlightService) Toggle() { s.Show() } } - -// IsVisible returns whether the spotlight window is visible -func (s *SpotlightService) IsVisible() bool { - if s.window == nil { - return false - } - return s.window.IsVisible() -} - -// Close closes the spotlight window -func (s *SpotlightService) Close() { - if s.window != nil { - s.window.Close() - } -} diff --git a/service/spotlight_test.go b/service/spotlight_test.go index a3bff3b..5946370 100644 --- a/service/spotlight_test.go +++ b/service/spotlight_test.go @@ -21,12 +21,8 @@ func TestSpotlightService_Operations(t *testing.T) { { name: "Toggle with nil window", test: func(t *testing.T, s *SpotlightService) { - // Initially not visible - assert.False(t, s.IsVisible()) - // Toggle should not panic with nil window s.Toggle() - assert.False(t, s.IsVisible()) }, }, { @@ -34,7 +30,6 @@ func TestSpotlightService_Operations(t *testing.T) { test: func(t *testing.T, s *SpotlightService) { // Should not panic with nil window s.Show() - assert.False(t, s.IsVisible()) }, }, { @@ -42,14 +37,6 @@ func TestSpotlightService_Operations(t *testing.T) { test: func(t *testing.T, s *SpotlightService) { // Should not panic with nil window s.Hide() - assert.False(t, s.IsVisible()) - }, - }, - { - name: "IsVisible with nil window", - test: func(t *testing.T, s *SpotlightService) { - // Should return false with nil window - assert.False(t, s.IsVisible()) }, }, }