|
| 1 | +export type DesktopMenuPlatform = "macos" | "windows" |
| 2 | + |
| 3 | +export type DesktopMenuAction = |
| 4 | + | "app.checkForUpdates" |
| 5 | + | "app.relaunch" |
| 6 | + | "app.exportLogs" |
| 7 | + | "edit.undo" |
| 8 | + | "edit.redo" |
| 9 | + | "edit.cut" |
| 10 | + | "edit.copy" |
| 11 | + | "edit.paste" |
| 12 | + | "edit.delete" |
| 13 | + | "edit.selectAll" |
| 14 | + | "view.reload" |
| 15 | + | "view.toggleDevTools" |
| 16 | + | "view.resetZoom" |
| 17 | + | "view.zoomIn" |
| 18 | + | "view.zoomOut" |
| 19 | + | "view.toggleFullscreen" |
| 20 | + | "window.new" |
| 21 | + | "window.close" |
| 22 | + | "window.minimize" |
| 23 | + | "window.toggleMaximize" |
| 24 | + |
| 25 | +export type DesktopMenuRole = |
| 26 | + | "about" |
| 27 | + | "close" |
| 28 | + | "copy" |
| 29 | + | "cut" |
| 30 | + | "hide" |
| 31 | + | "hideOthers" |
| 32 | + | "paste" |
| 33 | + | "quit" |
| 34 | + | "redo" |
| 35 | + | "reload" |
| 36 | + | "resetZoom" |
| 37 | + | "selectAll" |
| 38 | + | "toggleDevTools" |
| 39 | + | "togglefullscreen" |
| 40 | + | "undo" |
| 41 | + | "unhide" |
| 42 | + | "windowMenu" |
| 43 | + | "zoomIn" |
| 44 | + | "zoomOut" |
| 45 | + |
| 46 | +export type DesktopMenuItem = { |
| 47 | + type: "item" |
| 48 | + label?: string |
| 49 | + command?: string |
| 50 | + action?: DesktopMenuAction |
| 51 | + role?: DesktopMenuRole |
| 52 | + href?: string |
| 53 | + accelerator?: Partial<Record<DesktopMenuPlatform, string>> |
| 54 | + enabled?: "updater" |
| 55 | + platforms?: DesktopMenuPlatform[] |
| 56 | +} |
| 57 | + |
| 58 | +export type DesktopMenuSeparator = { |
| 59 | + type: "separator" |
| 60 | + platforms?: DesktopMenuPlatform[] |
| 61 | +} |
| 62 | + |
| 63 | +export type DesktopMenuEntry = DesktopMenuItem | DesktopMenuSeparator |
| 64 | + |
| 65 | +export type DesktopMenu = { |
| 66 | + id: string |
| 67 | + label: string |
| 68 | + role?: DesktopMenuRole |
| 69 | + items?: DesktopMenuEntry[] |
| 70 | + platforms?: DesktopMenuPlatform[] |
| 71 | +} |
| 72 | + |
| 73 | +export const DESKTOP_MENU: DesktopMenu[] = [ |
| 74 | + { |
| 75 | + id: "app", |
| 76 | + label: "OpenCode", |
| 77 | + platforms: ["macos"], |
| 78 | + items: [ |
| 79 | + { type: "item", role: "about" }, |
| 80 | + { type: "item", label: "Check for Updates...", action: "app.checkForUpdates", enabled: "updater" }, |
| 81 | + { type: "item", label: "Settings", command: "settings.open", accelerator: { macos: "Cmd+," } }, |
| 82 | + { type: "item", label: "Reload Webview", action: "view.reload" }, |
| 83 | + { type: "item", label: "Restart", action: "app.relaunch" }, |
| 84 | + { type: "item", label: "Export Logs...", action: "app.exportLogs" }, |
| 85 | + { type: "separator" }, |
| 86 | + { type: "item", role: "hide" }, |
| 87 | + { type: "item", role: "hideOthers" }, |
| 88 | + { type: "item", role: "unhide" }, |
| 89 | + { type: "separator" }, |
| 90 | + { type: "item", role: "quit" }, |
| 91 | + ], |
| 92 | + }, |
| 93 | + { |
| 94 | + id: "file", |
| 95 | + label: "File", |
| 96 | + items: [ |
| 97 | + { |
| 98 | + type: "item", |
| 99 | + label: "New Session", |
| 100 | + command: "session.new", |
| 101 | + accelerator: { macos: "Shift+Cmd+S" }, |
| 102 | + }, |
| 103 | + { type: "item", label: "Open Project...", command: "project.open", accelerator: { macos: "Cmd+O" } }, |
| 104 | + { |
| 105 | + type: "item", |
| 106 | + label: "Settings", |
| 107 | + command: "settings.open", |
| 108 | + accelerator: { windows: "Ctrl+," }, |
| 109 | + platforms: ["windows"], |
| 110 | + }, |
| 111 | + { |
| 112 | + type: "item", |
| 113 | + label: "New Window", |
| 114 | + action: "window.new", |
| 115 | + accelerator: { macos: "Cmd+Shift+N", windows: "Ctrl+Shift+N" }, |
| 116 | + }, |
| 117 | + { type: "separator" }, |
| 118 | + { type: "item", label: "Close Window", action: "window.close", role: "close" }, |
| 119 | + ], |
| 120 | + }, |
| 121 | + { |
| 122 | + id: "edit", |
| 123 | + label: "Edit", |
| 124 | + items: [ |
| 125 | + { type: "item", label: "Undo", action: "edit.undo", role: "undo", accelerator: { windows: "Ctrl+Z" } }, |
| 126 | + { type: "item", label: "Redo", action: "edit.redo", role: "redo", accelerator: { windows: "Ctrl+Y" } }, |
| 127 | + { type: "separator" }, |
| 128 | + { type: "item", label: "Cut", action: "edit.cut", role: "cut", accelerator: { windows: "Ctrl+X" } }, |
| 129 | + { type: "item", label: "Copy", action: "edit.copy", role: "copy", accelerator: { windows: "Ctrl+C" } }, |
| 130 | + { type: "item", label: "Paste", action: "edit.paste", role: "paste", accelerator: { windows: "Ctrl+V" } }, |
| 131 | + { type: "item", label: "Delete", action: "edit.delete" }, |
| 132 | + { |
| 133 | + type: "item", |
| 134 | + label: "Select All", |
| 135 | + action: "edit.selectAll", |
| 136 | + role: "selectAll", |
| 137 | + accelerator: { windows: "Ctrl+A" }, |
| 138 | + }, |
| 139 | + ], |
| 140 | + }, |
| 141 | + { |
| 142 | + id: "view", |
| 143 | + label: "View", |
| 144 | + items: [ |
| 145 | + { type: "item", label: "Toggle Sidebar", command: "sidebar.toggle", accelerator: { macos: "Cmd+B" } }, |
| 146 | + { type: "item", label: "Toggle Terminal", command: "terminal.toggle", accelerator: { macos: "Ctrl+`" } }, |
| 147 | + { type: "item", label: "Toggle File Tree", command: "fileTree.toggle" }, |
| 148 | + { type: "separator" }, |
| 149 | + { type: "item", label: "Reload", action: "view.reload", role: "reload" }, |
| 150 | + { type: "item", label: "Toggle Developer Tools", action: "view.toggleDevTools", role: "toggleDevTools" }, |
| 151 | + { type: "separator" }, |
| 152 | + { |
| 153 | + type: "item", |
| 154 | + label: "Actual Size", |
| 155 | + action: "view.resetZoom", |
| 156 | + role: "resetZoom", |
| 157 | + accelerator: { windows: "Ctrl+0" }, |
| 158 | + }, |
| 159 | + { type: "item", label: "Zoom In", action: "view.zoomIn", role: "zoomIn", accelerator: { windows: "Ctrl++" } }, |
| 160 | + { type: "item", label: "Zoom Out", action: "view.zoomOut", role: "zoomOut", accelerator: { windows: "Ctrl+-" } }, |
| 161 | + { type: "separator" }, |
| 162 | + { type: "item", label: "Toggle Full Screen", action: "view.toggleFullscreen", role: "togglefullscreen" }, |
| 163 | + ], |
| 164 | + }, |
| 165 | + { |
| 166 | + id: "go", |
| 167 | + label: "Go", |
| 168 | + items: [ |
| 169 | + { type: "item", label: "Back", command: "common.goBack", accelerator: { macos: "Cmd+[" } }, |
| 170 | + { type: "item", label: "Forward", command: "common.goForward", accelerator: { macos: "Cmd+]" } }, |
| 171 | + { type: "separator" }, |
| 172 | + { type: "item", label: "Previous Session", command: "session.previous", accelerator: { macos: "Option+Up" } }, |
| 173 | + { type: "item", label: "Next Session", command: "session.next", accelerator: { macos: "Option+Down" } }, |
| 174 | + { type: "separator" }, |
| 175 | + { |
| 176 | + type: "item", |
| 177 | + label: "Previous Project", |
| 178 | + command: "project.previous", |
| 179 | + accelerator: { macos: "Cmd+Option+Up" }, |
| 180 | + }, |
| 181 | + { |
| 182 | + type: "item", |
| 183 | + label: "Next Project", |
| 184 | + command: "project.next", |
| 185 | + accelerator: { macos: "Cmd+Option+Down" }, |
| 186 | + }, |
| 187 | + ], |
| 188 | + }, |
| 189 | + { |
| 190 | + id: "window", |
| 191 | + label: "Window", |
| 192 | + role: "windowMenu", |
| 193 | + items: [ |
| 194 | + { type: "item", label: "Minimize", action: "window.minimize" }, |
| 195 | + { type: "item", label: "Maximize", action: "window.toggleMaximize" }, |
| 196 | + { type: "separator" }, |
| 197 | + { type: "item", label: "Close Window", action: "window.close" }, |
| 198 | + ], |
| 199 | + }, |
| 200 | + { |
| 201 | + id: "help", |
| 202 | + label: "Help", |
| 203 | + items: [ |
| 204 | + { type: "item", label: "OpenCode Documentation", href: "https://opencode.ai/docs" }, |
| 205 | + { type: "item", label: "Support Forum", href: "https://discord.com/invite/opencode" }, |
| 206 | + { type: "item", label: "Export Logs...", action: "app.exportLogs" }, |
| 207 | + { type: "separator" }, |
| 208 | + { type: "item", label: "Share Feedback", href: "https://github.com/anomalyco/opencode/issues/new?template=feature_request.yml" }, |
| 209 | + { type: "item", label: "Report a Bug", href: "https://github.com/anomalyco/opencode/issues/new?template=bug_report.yml" }, |
| 210 | + ], |
| 211 | + }, |
| 212 | +] |
| 213 | + |
| 214 | +export function desktopMenuVisible(item: { platforms?: DesktopMenuPlatform[] }, platform: DesktopMenuPlatform) { |
| 215 | + return !item.platforms || item.platforms.includes(platform) |
| 216 | +} |
0 commit comments