diff --git a/ui/desktop/src/main.ts b/ui/desktop/src/main.ts index c13d472d4b4e..da16344af096 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');