Skip to content

Commit cf3d53d

Browse files
grimmerkclaude
andcommitted
fix: use setActivationPolicy instead of dock.hide/show
Replace app.dock.hide()/show() with app.setActivationPolicy(): - Normal mode: 'regular' (dock icon + running dot + App Switcher) - Menu bar mode: 'accessory' (no dock icon, same as LSUIElement) setActivationPolicy is the official macOS API for this, cleaner than dock.hide() which has known Electron bugs. LSUIElement=true kept in Info.plist to prevent dock icon flash on app launch. Caveat: switching to 'accessory' hides all windows — re-show with 100ms delay after policy change. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 20908f9 commit cf3d53d

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/main.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,9 +1032,11 @@ const trayToggleEvtHandler = async () => {
10321032

10331033
// Load app mode setting early (before window creation)
10341034
appMode = ((await settings.get('app-mode')) as 'normal' | 'menubar') || 'normal';
1035-
if (appMode === 'menubar') {
1036-
app.dock.hide();
1035+
if (appMode === 'normal') {
1036+
app.setActivationPolicy('regular');
10371037
}
1038+
// LSUIElement=true in Info.plist starts as accessory (no dock icon).
1039+
// 'regular' adds dock icon + running dot + App Switcher.
10381040

10391041
// Auto-update: check for updates via update.electronjs.org (non-MAS only)
10401042
if (!isMAS()) {
@@ -1972,9 +1974,14 @@ ipcMain.on('set-app-mode', async (_event, mode: string) => {
19721974
await settings.set('app-mode', newMode);
19731975
appMode = newMode;
19741976
if (newMode === 'menubar') {
1975-
app.dock.hide();
1977+
app.setActivationPolicy('accessory');
1978+
// accessory mode hides all windows — re-show after short delay
1979+
const win = getSwitcherWindow();
1980+
if (win) {
1981+
setTimeout(() => { win.show(); win.focus(); }, 100);
1982+
}
19761983
} else {
1977-
await app.dock.show();
1984+
app.setActivationPolicy('regular');
19781985
}
19791986
// Notify renderer to update drag region
19801987
const window = getSwitcherWindow();
@@ -2131,4 +2138,4 @@ ipcMain.handle('detect-active-ide-projects', async () => {
21312138
return Array.from(folderNames);
21322139
});
21332140

2134-
// app.dock.hide() moved to async init block (after settings loaded)
2141+
// Dock visibility managed via app.setActivationPolicy() (see set-app-mode handler)

0 commit comments

Comments
 (0)