diff --git a/ui/desktop/src/ChatWindow.tsx b/ui/desktop/src/ChatWindow.tsx index 5adea015..d0ac5f9c 100644 --- a/ui/desktop/src/ChatWindow.tsx +++ b/ui/desktop/src/ChatWindow.tsx @@ -213,13 +213,18 @@ function ChatContent({ } export default function ChatWindow() { + // Shared function to create a chat window + const openNewChatWindow = () => { + window.electron.createChatWindow(); + }; + // Add keyboard shortcut handler useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { // Check for Command+N (Mac) or Control+N (Windows/Linux) if ((event.metaKey || event.ctrlKey) && event.key === 'n') { event.preventDefault(); // Prevent default browser behavior - window.electron.createChatWindow(); + openNewChatWindow(); } }; diff --git a/ui/desktop/src/main.ts b/ui/desktop/src/main.ts index cdd8b012..9db583c5 100644 --- a/ui/desktop/src/main.ts +++ b/ui/desktop/src/main.ts @@ -1,6 +1,6 @@ import 'dotenv/config'; import { loadZshEnv } from './utils/loadEnv'; -import { app, BrowserWindow, Tray, Menu, globalShortcut, ipcMain, Notification } from 'electron'; +import { app, BrowserWindow, Tray, Menu, globalShortcut, ipcMain, Notification, MenuItem } from 'electron'; import path from 'node:path'; import { findAvailablePort, startGoosed } from './goosed'; import started from "electron-squirrel-startup"; @@ -208,6 +208,23 @@ app.whenReady().then(async () => { // Show launcher input on key combo globalShortcut.register('Control+Alt+Command+G', createLauncher); + // Preserve existing menu and add new items + const menu = Menu.getApplicationMenu(); + const fileMenu = menu?.items.find(item => item.label === 'File'); + + // Add 'New Chat Window' to File menu + if (fileMenu && fileMenu.submenu) { + fileMenu.submenu.append(new MenuItem({ + label: 'New Chat Window', + accelerator: 'CmdOrCtrl+N', + click() { + ipcMain.emit('create-chat-window'); + }, + })); + } + + Menu.setApplicationMenu(menu); + app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) { createChat(app); @@ -266,4 +283,5 @@ app.on('window-all-closed', () => { if (process.platform !== 'darwin') { app.quit(); } -}); \ No newline at end of file +}); +