11import { Menu , MenuItem , PredefinedMenuItem , Submenu } from "@tauri-apps/api/menu"
22import { type as ostype } from "@tauri-apps/plugin-os"
33import { relaunch } from "@tauri-apps/plugin-process"
4+ import { openUrl } from "@tauri-apps/plugin-opener"
45
56import { runUpdater , UPDATER_ENABLED } from "./updater"
67import { installCli } from "./cli"
78import { initI18n , t } from "./i18n"
89import { commands } from "./bindings"
910
10- export async function createMenu ( ) {
11+ export async function createMenu ( trigger : ( id : string ) => void ) {
1112 if ( ostype ( ) !== "macos" ) return
1213
1314 await initI18n ( )
@@ -60,29 +61,27 @@ export async function createMenu() {
6061 } ) ,
6162 ] . filter ( Boolean ) ,
6263 } ) ,
63- // await Submenu.new({
64- // text: "File",
65- // items: [
66- // await MenuItem.new({
67- // enabled: false,
68- // text: "Open Project...",
69- // }),
70- // await PredefinedMenuItem.new({
71- // item: "Separator"
72- // }),
73- // await MenuItem.new({
74- // enabled: false,
75- // text: "New Session",
76- // }),
77- // await PredefinedMenuItem.new({
78- // item: "Separator"
79- // }),
80- // await MenuItem.new({
81- // enabled: false,
82- // text: "Close Project",
83- // })
84- // ]
85- // }),
64+ await Submenu . new ( {
65+ text : "File" ,
66+ items : [
67+ await MenuItem . new ( {
68+ text : "New Session" ,
69+ accelerator : "Shift+Cmd+S" ,
70+ action : ( ) => trigger ( "session.new" ) ,
71+ } ) ,
72+ await MenuItem . new ( {
73+ text : "Open Project..." ,
74+ accelerator : "Cmd+O" ,
75+ action : ( ) => trigger ( "project.open" ) ,
76+ } ) ,
77+ await PredefinedMenuItem . new ( {
78+ item : "Separator" ,
79+ } ) ,
80+ await PredefinedMenuItem . new ( {
81+ item : "CloseWindow" ,
82+ } ) ,
83+ ] ,
84+ } ) ,
8685 await Submenu . new ( {
8786 text : "Edit" ,
8887 items : [
@@ -109,6 +108,83 @@ export async function createMenu() {
109108 } ) ,
110109 ] ,
111110 } ) ,
111+ await Submenu . new ( {
112+ text : "View" ,
113+ items : [
114+ await MenuItem . new ( {
115+ action : ( ) => trigger ( "sidebar.toggle" ) ,
116+ text : "Toggle Sidebar" ,
117+ accelerator : "Cmd+B" ,
118+ } ) ,
119+ await MenuItem . new ( {
120+ action : ( ) => trigger ( "terminal.toggle" ) ,
121+ text : "Toggle Terminal" ,
122+ accelerator : "Ctrl+`" ,
123+ } ) ,
124+ await MenuItem . new ( {
125+ action : ( ) => trigger ( "fileTree.toggle" ) ,
126+ text : "Toggle File Tree" ,
127+ } ) ,
128+ await PredefinedMenuItem . new ( {
129+ item : "Separator" ,
130+ } ) ,
131+ await MenuItem . new ( {
132+ action : ( ) => trigger ( "common.goBack" ) ,
133+ text : "Back" ,
134+ } ) ,
135+ await MenuItem . new ( {
136+ action : ( ) => trigger ( "common.goForward" ) ,
137+ text : "Forward" ,
138+ } ) ,
139+ await PredefinedMenuItem . new ( {
140+ item : "Separator" ,
141+ } ) ,
142+ await MenuItem . new ( {
143+ action : ( ) => trigger ( "session.previous" ) ,
144+ text : "Previous Session" ,
145+ accelerator : "Option+ArrowUp" ,
146+ } ) ,
147+ await MenuItem . new ( {
148+ action : ( ) => trigger ( "session.next" ) ,
149+ text : "Next Session" ,
150+ accelerator : "Option+ArrowDown" ,
151+ } ) ,
152+ await PredefinedMenuItem . new ( {
153+ item : "Separator" ,
154+ } ) ,
155+ ] ,
156+ } ) ,
157+ await Submenu . new ( {
158+ text : "Help" ,
159+ items : [
160+ // missing native macos search
161+ await MenuItem . new ( {
162+ action : ( ) => openUrl ( "https://opencode.ai/docs" ) ,
163+ text : "OpenCode Documentation" ,
164+ } ) ,
165+ await MenuItem . new ( {
166+ action : ( ) => openUrl ( "https://discord.com/invite/opencode" ) ,
167+ text : "Support Forum" ,
168+ } ) ,
169+ await PredefinedMenuItem . new ( {
170+ item : "Separator" ,
171+ } ) ,
172+ // await MenuItem.new({
173+ // text: "Release Notes",
174+ // }),
175+ await PredefinedMenuItem . new ( {
176+ item : "Separator" ,
177+ } ) ,
178+ await MenuItem . new ( {
179+ action : ( ) => openUrl ( "https://github.com/anomalyco/opencode/issues/new?template=feature_request.yml" ) ,
180+ text : "Share Feedback" ,
181+ } ) ,
182+ await MenuItem . new ( {
183+ action : ( ) => openUrl ( "https://github.com/anomalyco/opencode/issues/new?template=bug_report.yml" ) ,
184+ text : "Report a Bug" ,
185+ } ) ,
186+ ] ,
187+ } ) ,
112188 ] ,
113189 } )
114190 menu . setAsAppMenu ( )
0 commit comments