Skip to content

Commit 25e456b

Browse files
grimmerkclaude
andcommitted
fix: address review — banner timeout, dock await, startup timing, shortcut resume
- Clear banner timeout before scheduling new one (cubic P2) - Await app.dock.show() (cubic P2) - Delay showSwitcherWindow to after bootstrap (CodeRabbit) - Resume paused shortcut when switching settings tabs (CodeRabbit) - Use actual shortcut key in mode switch banner (CodeRabbit) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent aa5d8a0 commit 25e456b

3 files changed

Lines changed: 28 additions & 14 deletions

File tree

src/main.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,9 +1081,10 @@ const trayToggleEvtHandler = async () => {
10811081
}
10821082

10831083
switcherWindow = createSwitcherWindow();
1084-
// Normal mode: show window immediately on startup
1084+
// Normal mode: show window after bootstrap (server must be ready for API calls)
10851085
if (appMode === 'normal') {
1086-
showSwitcherWindow();
1086+
// Delay show to ensure bootstrap() has completed (runs earlier in this block)
1087+
setTimeout(() => showSwitcherWindow(), 100);
10871088
}
10881089
if (isDebug) {
10891090
console.log('when ready');
@@ -1973,7 +1974,7 @@ ipcMain.on('set-app-mode', async (_event, mode: string) => {
19731974
if (newMode === 'menubar') {
19741975
app.dock.hide();
19751976
} else {
1976-
app.dock.show();
1977+
await app.dock.show();
19771978
}
19781979
// Notify renderer to update drag region
19791980
const window = getSwitcherWindow();

src/popup.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,15 @@ const PopupDefaultExample = ({
327327
{(['general', 'sessions', 'shortcuts'] as const).map((tab) => (
328328
<button
329329
key={tab}
330-
onClick={() => setSettingsTab(tab)}
330+
onClick={() => {
331+
// Resume any paused shortcut when switching away from Shortcuts tab
332+
if (editingShortcut) {
333+
window.electronAPI.resumeShortcut(editingShortcut);
334+
setEditingShortcut(null);
335+
setShortcutError('');
336+
}
337+
setSettingsTab(tab);
338+
}}
331339
style={{
332340
padding: '6px 12px',
333341
fontSize: '12px',

src/switcher-ui.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ function SwitcherApp() {
363363
const [currentAppMode, setCurrentAppMode] = useState('menubar');
364364
const [modeBanner, setModeBanner] = useState<string | null>(null);
365365
const [quickSwitcherShortcut, setQuickSwitcherShortcut] = useState('');
366+
const bannerTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
366367

367368
const updateWorkingPathUIAndList = async (path: string) => {
368369
setWorkingFolderPath(path);
@@ -674,40 +675,44 @@ function SwitcherApp() {
674675
// Load shortcut for display
675676
window.electronAPI.getShortcuts().then((s: any) => {
676677
if (s?.quickSwitcher) {
677-
// Convert Electron accelerator to display format
678678
const display = s.quickSwitcher
679679
.replace('Command', 'Cmd')
680680
.replace('Control', 'Ctrl')
681681
.replace(/\+/g, '+');
682682
setQuickSwitcherShortcut(display);
683+
shortcutDisplay = display;
683684
}
684685
});
685686

687+
const showBanner = (msg: string, durationMs = 5000) => {
688+
if (bannerTimeoutRef.current) clearTimeout(bannerTimeoutRef.current);
689+
setModeBanner(msg);
690+
bannerTimeoutRef.current = setTimeout(() => setModeBanner(null), durationMs);
691+
};
692+
686693
// Listen for app mode changes to enable/disable drag
694+
let shortcutDisplay = ''; // will be set by getShortcuts
687695
window.electronAPI.getAppMode().then((mode: string) => {
688696
const m = mode || 'normal';
689697
setCurrentAppMode(m);
690-
// Show banner on first launch for new users
691698
if (m === 'normal') {
692-
setModeBanner('Normal App mode — drag to reposition. Switch to Menu Bar mode in Settings.');
693-
setTimeout(() => setModeBanner(null), 6000);
699+
showBanner('Normal App mode — drag to reposition. Switch to Menu Bar mode in Settings.', 6000);
694700
}
695701
});
696702
window.electronAPI.onShortcutsUpdated((_event: any, s: any) => {
697703
if (s?.quickSwitcher) {
698-
const display = s.quickSwitcher.replace('Command', 'Cmd').replace('Control', 'Ctrl').replace(/\+/g, '+');
699-
setQuickSwitcherShortcut(display);
704+
shortcutDisplay = s.quickSwitcher.replace('Command', 'Cmd').replace('Control', 'Ctrl').replace(/\+/g, '+');
705+
setQuickSwitcherShortcut(shortcutDisplay);
700706
}
701707
});
702708
window.electronAPI.onAppModeChanged((_event: any, mode: string) => {
703709
setCurrentAppMode(mode);
704-
// Show banner on mode change
710+
const key = shortcutDisplay || 'Cmd+Ctrl+R';
705711
if (mode === 'normal') {
706-
setModeBanner('Switched to Normal App mode — window stays visible and is draggable.');
712+
showBanner('Switched to Normal App mode — window stays visible and is draggable.');
707713
} else {
708-
setModeBanner('Switched to Menu Bar mode — window auto-hides. Use Cmd+Ctrl+R to toggle.');
714+
showBanner(`Switched to Menu Bar mode — window auto-hides. Use ${key} to toggle.`);
709715
}
710-
setTimeout(() => setModeBanner(null), 5000);
711716
});
712717

713718
window.electronAPI.onCheckTerminalAndHide(() => {

0 commit comments

Comments
 (0)