Skip to content

Commit 1a614a2

Browse files
committed
fix: command palette navigation and reduce window height
- Fix navigation listener by moving from NavigationHandler to App component - Use Events.On from @wailsio/runtime for proper event handling - Reduce command palette window height to 80% (480px -> 384px) - Adjust CSS heights for results area and list to match new window size
1 parent 6e0892d commit 1a614a2

3 files changed

Lines changed: 49 additions & 30 deletions

File tree

frontend/src/App.jsx

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,69 @@
11
import React, { useState, useEffect, useCallback } from 'react';
22
import { Routes, Route, Navigate, useNavigate } from 'react-router-dom';
33
import { Events } from '@wailsio/runtime';
4+
45
import { Sidebar } from './components/Sidebar';
56
import { TitleBar } from './components/TitleBar';
67
import { SettingsModal } from './components/SettingsModal';
78
import ToolRouter from './ToolRouter';
89
import './App.css';
910

10-
// NavigationHandler listens for navigate events from command palette
11-
function NavigationHandler() {
11+
function App() {
1212
const navigate = useNavigate();
13+
const [isSidebarOpen, setIsSidebarOpen] = useState(true);
14+
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
15+
const [themeMode, setThemeMode] = useState(() => {
16+
return localStorage.getItem('themeMode') || 'dark';
17+
});
18+
19+
const toggleSidebar = () => setIsSidebarOpen(!isSidebarOpen);
20+
const openSettings = () => setIsSettingsOpen(true);
21+
const closeSettings = () => setIsSettingsOpen(false);
1322

23+
// Handle navigation events from command palette
1424
useEffect(() => {
15-
console.log('[App] Setting up navigation event listener...');
25+
console.log('[App] Setting up navigation listener for command palette...');
26+
27+
const handleNavigation = (data) => {
28+
console.log('[App] Received navigate:to event:', data);
29+
30+
// In Wails V3, data might be the path string OR an event object with path in data
31+
let path = '';
32+
if (typeof data === 'string') {
33+
path = data;
34+
} else if (data && typeof data === 'object') {
35+
if (data.data) {
36+
path = typeof data.data === 'string' ? data.data : data.data[0];
37+
} else if (data.path) {
38+
path = data.path;
39+
}
40+
}
1641

17-
// Listen for navigation events from command palette (via Go backend)
18-
const unsubscribe = Events.On('navigate:to', (path) => {
19-
console.log('[App] Received navigate:to event:', path);
2042
if (path) {
43+
console.log('[App] Navigating to path:', path);
2144
navigate(path);
45+
} else {
46+
console.warn('[App] Received empty/invalid path via navigate:to:', data);
2247
}
23-
});
48+
};
49+
50+
let unsubscribe = null;
51+
try {
52+
unsubscribe = Events.On('navigate:to', (event) => {
53+
handleNavigation(event);
54+
});
55+
console.log('[App] Navigation listener registered successfully');
56+
} catch (err) {
57+
console.error('[App] Failed to register navigation listener:', err);
58+
}
2459

2560
return () => {
26-
console.log('[App] Cleaning up navigation event listener');
61+
console.log('[App] Cleaning up navigation listener');
2762
if (unsubscribe) unsubscribe();
2863
};
2964
}, [navigate]);
3065

31-
return null;
32-
}
33-
34-
function App() {
35-
const [isSidebarOpen, setIsSidebarOpen] = useState(true);
36-
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
37-
const [themeMode, setThemeMode] = useState(() => {
38-
return localStorage.getItem('themeMode') || 'dark';
39-
});
40-
41-
const toggleSidebar = () => setIsSidebarOpen(!isSidebarOpen);
42-
const openSettings = () => setIsSettingsOpen(true);
43-
const closeSettings = () => setIsSettingsOpen(false);
44-
45-
// Global spotlight shortcut is Cmd+Shift+Space (handled by Go backend)
46-
66+
// Handle theme changes
4767
useEffect(() => {
4868
localStorage.setItem('themeMode', themeMode);
4969
if (themeMode === 'dark') {
@@ -90,7 +110,6 @@ function App() {
90110
<Route path="/tool/:toolId/*" element={<ToolRouter />} />
91111
<Route path="*" element={<Navigate to="/tool/text-converter" replace />} />
92112
</Routes>
93-
<NavigationHandler />
94113
</main>
95114
</div>
96115

frontend/src/components/CommandPalette.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
}
6060

6161
.command-palette-results {
62-
height: 332px; /* Reduced to ~80% of original (416 * 0.8) */
62+
height: 264px; /* Results area: 80% of original (332 * 0.8) */
6363
overflow: hidden;
6464
background: #18181b;
6565
}
@@ -73,7 +73,7 @@
7373

7474
.command-palette-list {
7575
overflow-y: auto;
76-
max-height: 320px; /* Reduced to match results height */
76+
max-height: 252px; /* 80% of original (320 * 0.8) */
7777
}
7878

7979
.command-palette-item {

main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ func main() {
160160
spotlightWindow := app.Window.NewWithOptions(application.WebviewWindowOptions{
161161
Title: "Spotlight",
162162
Width: 640,
163-
Height: 480,
164-
MinHeight: 480,
165-
MaxHeight: 480,
163+
Height: 384,
164+
MinHeight: 384,
165+
MaxHeight: 384,
166166
Frameless: true,
167167
Hidden: true,
168168
BackgroundColour: application.RGBA{Red: 22, Green: 22, Blue: 22, Alpha: 255},

0 commit comments

Comments
 (0)