From cb2303107d1348d127e6d5b63b373745d3656694 Mon Sep 17 00:00:00 2001 From: Zane <75694352+zanesq@users.noreply.github.com> Date: Thu, 30 Oct 2025 09:24:24 -0700 Subject: [PATCH] Add menu option for setting window always on top (#5429) --- ui/desktop/src/main.ts | 48 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/ui/desktop/src/main.ts b/ui/desktop/src/main.ts index c13d472d..da16344a 100644 --- a/ui/desktop/src/main.ts +++ b/ui/desktop/src/main.ts @@ -483,9 +483,7 @@ let appConfig = { const windowMap = new Map(); const goosedClients = new Map(); - -// Track power save blockers per window -const windowPowerSaveBlockers = new Map(); // windowId -> blockerId +const windowPowerSaveBlockers = new Map(); const createChat = async ( app: App, @@ -1872,6 +1870,50 @@ async function appMain() { ); } + if (menu) { + let windowMenu = menu.items.find((item) => item.label === 'Window'); + + if (!windowMenu) { + windowMenu = new MenuItem({ + label: 'Window', + submenu: Menu.buildFromTemplate([]), + }); + + const helpMenuIndex = menu.items.findIndex((item) => item.label === 'Help'); + if (helpMenuIndex >= 0) { + menu.items.splice(helpMenuIndex, 0, windowMenu); + } else { + menu.items.push(windowMenu); + } + } + + if (windowMenu.submenu) { + windowMenu.submenu.append( + new MenuItem({ + label: 'Always on Top', + type: 'checkbox', + accelerator: process.platform === 'darwin' ? 'Cmd+Shift+T' : 'Ctrl+Shift+T', + click(menuItem) { + const focusedWindow = BrowserWindow.getFocusedWindow(); + if (focusedWindow) { + const isAlwaysOnTop = menuItem.checked; + + if (process.platform === 'darwin') { + focusedWindow.setAlwaysOnTop(isAlwaysOnTop, 'floating'); + } else { + focusedWindow.setAlwaysOnTop(isAlwaysOnTop); + } + + console.log( + `[Main] Set always-on-top to ${isAlwaysOnTop} for window ${focusedWindow.id}` + ); + } + }, + }) + ); + } + } + // on macOS, the topbar is hidden if (menu && process.platform !== 'darwin') { let helpMenu = menu.items.find((item) => item.label === 'Help');