All jobs

Add a Native Menu to a Tauri App

Yes. An agent builds a native application menu for your Tauri 2 app in Rust, wires its items to the Vue frontend, checks it compiles on Linux and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads the Rust side first, because that is where a Tauri 2 menu lives. In an app laid out like Uninen/tauri-vue-template, src-tauri/src/lib.rs has one greet command and a run() that builds tauri::Builder::default(), opens the devtools in setup on debug builds, registers tauri_plugin_shell and tauri_plugin_prevent_default, and calls generate_context!. Cargo.lock resolves tauri to 2.10.3, tauri.conf.json declares one window named main at 800 by 600 with a CSP, and there is no src-tauri/capabilities directory. The frontend is Vue 3.5 with Pinia and Tailwind 4, built by Vite 8; src/components/GreetComponent.vue calls invoke('greet') from @tauri-apps/api/core, and src/store.ts keeps the name. .github/workflows/test.yml runs pnpm test (Vitest 4) on Ubuntu, and release.yml installs libwebkit2gtk-4.1-dev, libappindicator3-dev, librsvg2-dev and patchelf before tauri-action builds for macOS, Ubuntu 24.04 and Windows.

The menu is built in setup with tauri::menu. The agent uses SubmenuBuilder and MenuBuilder rather than hand-assembling items: an app submenu first, because on macOS the first submenu becomes the application menu and top-level items outside a submenu are ignored, holding PredefinedMenuItem::about, a separator and PredefinedMenuItem::quit; an Edit submenu with the predefined undo, redo, cut, copy, paste and select_all, which is what makes Cmd+C and Cmd+V work in the greet form's input on macOS, where a webview without an Edit menu gets no edit shortcuts; a Greet submenu with one MenuItem::with_id(app, "greet", "Greet…", true, Some("CmdOrCtrl+G")); and a Help submenu with a repository item. app.set_menu(menu)? attaches it, and on Windows and Linux it renders inside the window.

Events come back through app.on_menu_event, which matches on event.id().0. The repository item opens the template's GitHub URL through tauri-plugin-opener, app.opener().open_url(url, None::<&str>) via tauri_plugin_opener::OpenerExt; the tauri-plugin-shell already in Cargo.toml has an open too, but it is marked deprecated since 2.1.0 in favour of the opener plugin, and clippy would say so, so the agent adds the opener crate and its opener:default permission rather than ship a warning. The greet item emits a menu:greet event to the main window with app.emit, and src/App.vue subscribes with listen from @tauri-apps/api/event and focuses the input. The frontend can listen only when a capability allows it, so the agent adds src-tauri/capabilities/default.json for the main window with core:event:default and opener:default, the directory the template never needed while its only IPC was an app command, which needs no permission.

In its sandbox the agent installs the four Ubuntu packages release.yml names and runs the repository's own pnpm check, which is cargo check --manifest-path src-tauri/Cargo.toml, plus cargo clippy for the new module, then pnpm build so vue-tsc sees the new import, and pnpm test. A Vitest test for the listener uses mockIPC from @tauri-apps/api/mocks, which the API package ships for exactly this, so the frontend half is covered without a window. The menu's own behaviour on macOS cannot be seen from Linux, and the pull request says so rather than claiming it.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Add a native application menu to this Tauri 2 app. Read src-tauri/Cargo.toml, src-tauri/src/lib.rs, src-tauri/src/main.rs, src-tauri/tauri.conf.json, package.json, vite.config.ts, src/App.vue, src/components/GreetComponent.vue, src/store.ts and .github/workflows/release.yml and test.yml first. Build the menu in setup with tauri::menu: an app submenu first with About and Quit so macOS gets its application menu, an Edit submenu with the predefined undo, redo, cut, copy, paste and select all items, a Greet item with a CmdOrCtrl+G accelerator that emits an event the Vue app listens for to focus the greet input, and a Help item that opens the repository URL through tauri-plugin-opener, since the shell plugin's open is deprecated. Handle events with on_menu_event. Add a capability file for the main window granting core:event:default, since the frontend needs it to listen, and the opener permission. Install the Linux build dependencies the release workflow lists, run pnpm check, cargo clippy, pnpm build and pnpm test, add a Vitest test for the listener using @tauri-apps/api/mocks, and open a pull request that quotes the output and says what could not be exercised on Linux.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

The pull request adds src-tauri/src/menu.rs and src-tauri/capabilities/default.json, changes src-tauri/Cargo.toml (the opener plugin) and src-tauri/src/lib.rs to build the menu in setup and register the event handler, and changes src/App.vue and a test file under tests/ for the listener. Its description quotes cargo check, cargo clippy, vue-tsc and the Vitest summary, lists each menu item with its id and what it does, and states plainly that the macOS application menu and the Windows in-window rendering were not seen in the run.

A reviewer checks the item order (the app submenu first), that the Edit submenu uses predefined items rather than custom handlers, that the capability grants only the event and opener permissions and only to main, and that the accelerator does not collide with one the webview already handles. They then run pnpm tauri dev on a Mac to see the menu bar, which is the one check no sandbox replaces.

The greet command, the devtools behaviour in debug builds and the two existing plugins are untouched, and the release workflow needs no change because the menu is part of the same binary.

Run it on every new app from the template

A team that stamps out desktop apps from one template wants the menu in each of them. A handler on your own server, run when a repository is created from the template, sends this body to POST /o/{org}/sessions with the new repository in resources, and a request_id that is a UUID v5 of the repository's id so a retried call returns the run already started. Each run opens one pull request on that repository, and the key's webhook_url receives run.completed with the result.

For a repository that already has a menu, an automation on the Project with a github trigger on pull_request.opened and pull_request.synchronize can run read-only with a prompt that checks any change under src-tauri/src/menu.rs keeps the app submenu first and keeps the Edit items predefined, and comments when it does not. The trigger adds the event after the prompt; it fills nothing in.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

A Tauri change is a Rust change and a frontend change at once, and compiling the Rust side needs WebKitGTK and three more system packages that most laptops do not have installed. The agent's sandbox installs them, runs cargo check and clippy against the pinned tauri 2.10.3, builds the Vue app with vue-tsc, and keeps the output, so the pull request's claim that it compiles is backed by the run's record.

Menus are also where platform differences hide: the macOS application menu, the edit shortcuts that only predefined items provide, the in-window menu on Linux and Windows. The agent reads the Tauri 2 menu API for the pinned version and writes those constraints into the code and the pull request, and says which of them it could and could not observe.

Frequently asked questions

Why build the menu in Rust rather than with the JavaScript API?

Both work in Tauri 2. The JavaScript Menu.new API holds native resources that must be closed by hand, and it needs core:menu permissions in a capability. Building in setup gives the app one menu from the first frame, needs no menu permission in the frontend, and keeps the event handling next to the commands.

Will Cmd+C and Cmd+V work in the input on macOS?

Only with an Edit menu made of the predefined cut, copy, paste, undo, redo and select_all items, which is why the agent adds one. On macOS the webview's edit shortcuts are routed through the application menu, and a menu without them leaves the greet input unable to paste.

Why does the frontend need a capability file now?

The template calls only its own greet command, and an app's own commands need no permission. Listening for an event is a core API call, which a capability must allow for the window, so the agent adds src-tauri/capabilities/default.json for main with core:event:default and the opener plugin's opener:default, and nothing else.

Does it work with the prevent-default plugin?

Yes. tauri-plugin-prevent-default blocks browser-style shortcuts inside the webview such as reload and the context menu; it does not touch native menu accelerators, which the window handles before the webview sees them.

What about the system tray?

A tray uses the same tauri::menu items attached to a TrayIconBuilder instead of set_menu, and needs the tray-icon feature on the tauri dependency. The agent leaves it out of this pull request because the template has no tray, and the menu module is written so a tray can reuse its items.

More Tauri jobs

More jobs like this: Hand off a long task

Keep reading