Skip to content

Commit 22a816f

Browse files
authored
🤖 feat: add Settings to macOS menu bar (#813)
Adds a Settings menu item to the macOS application menu (`Cmd+,`) for easier access to the settings modal. Closes #810 _Generated with `mux`_
1 parent 7d668fe commit 22a816f

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

src/browser/App.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,14 @@ function AppInner() {
480480
openSettings,
481481
]);
482482

483+
// Subscribe to menu bar "Open Settings" (macOS Cmd+, from app menu)
484+
useEffect(() => {
485+
const unsubscribe = window.api.menu?.onOpenSettings(() => {
486+
openSettings();
487+
});
488+
return () => unsubscribe?.();
489+
}, [openSettings]);
490+
483491
// Handle workspace fork switch event
484492
useEffect(() => {
485493
const handleForkSwitch = (e: Event) => {

src/common/constants/ipc-constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ export const IPC_CHANNELS = {
5050
// Window channels
5151
WINDOW_SET_TITLE: "window:setTitle",
5252

53+
// Menu channels (main -> renderer)
54+
MENU_OPEN_SETTINGS: "menu:openSettings",
55+
5356
// Debug channels (for testing only)
5457
DEBUG_TRIGGER_STREAM_ERROR: "debug:triggerStreamError",
5558

src/common/types/ipc.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ export interface IPCApi {
377377
install(): void;
378378
onStatus(callback: (status: UpdateStatus) => void): () => void;
379379
};
380+
menu?: {
381+
onOpenSettings(callback: () => void): () => void;
382+
};
380383
server?: {
381384
getLaunchProject(): Promise<string | null>;
382385
};

src/desktop/main.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,16 @@ function createMenu() {
187187
submenu: [
188188
{ role: "about" },
189189
{ type: "separator" },
190+
{
191+
label: "Settings...",
192+
accelerator: "Cmd+,",
193+
click: () => {
194+
if (mainWindow) {
195+
mainWindow.webContents.send(IPC_CHANNELS.MENU_OPEN_SETTINGS);
196+
}
197+
},
198+
},
199+
{ type: "separator" },
190200
{ role: "services", submenu: [] },
191201
{ type: "separator" },
192202
{ role: "hide" },

src/desktop/preload.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@ const api: IPCApi = {
210210
closeWindow: (workspaceId: string) =>
211211
ipcRenderer.invoke(IPC_CHANNELS.TERMINAL_WINDOW_CLOSE, workspaceId),
212212
},
213+
menu: {
214+
onOpenSettings: (callback: () => void) => {
215+
const handler = () => callback();
216+
ipcRenderer.on(IPC_CHANNELS.MENU_OPEN_SETTINGS, handler);
217+
return () => ipcRenderer.removeListener(IPC_CHANNELS.MENU_OPEN_SETTINGS, handler);
218+
},
219+
},
213220
};
214221

215222
// Expose the API along with platform/versions

0 commit comments

Comments
 (0)