# Add a System Tray Icon to a Tauri App

Yes. An agent turns on Tauri's tray-icon feature, adds a tray with a menu that shows, hides and quits the app, builds it in its sandbox and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-tray-icon/tauri/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent clones the repository into its own cloud sandbox and reads how the desktop side is put together. In a Tauri 2 app like Uninen/tauri-vue-template, `src-tauri/Cargo.toml` depends on `tauri = { version = "2", features = [] }` with no optional features, plus `tauri-plugin-shell` and `tauri-plugin-prevent-default`; `src-tauri/tauri.conf.json` declares one 800 by 600 window titled `tauri-app`, the identifier `com.tauri-app.my` and a bundle icon list that already includes `icons/32x32.png`, `icons/128x128.png`, `icons/icon.icns` and `icons/icon.ico`; and `src-tauri/src/lib.rs` builds the app with a `setup` hook that opens devtools in debug builds, registers the two plugins and exposes one `greet` command. There is no `src-tauri/capabilities/` directory and nothing about a tray anywhere, so the agent knows it is adding the feature from scratch rather than extending one.

It makes the smallest Rust change that gives the app a tray. In `Cargo.toml` it adds `tray-icon` to the `tauri` crate's feature list, because the tray types are compiled out without it. In `lib.rs` it extends the `setup` closure: it builds a `Menu` with `MenuItem` entries for Show, Hide and Quit through `tauri::menu`, then a `TrayIconBuilder` from `tauri::tray` that takes the app's default window icon from the bundle list, sets a tooltip with the product name, attaches the menu, turns off `show_menu_on_left_click` so a left click can act on the window, and wires `on_menu_event` to show and focus the main window, hide it, or exit, and `on_tray_icon_event` so a left click brings the window back. It also adds an `on_window_event` handler that intercepts `CloseRequested` on the main window, calls `prevent_close` and hides the window instead, so closing the window sends the app to the tray and Quit in the tray menu is the way out. Every id the handlers compare against is a named constant, not a string typed twice.

Platform details go in with the code rather than in a follow-up. On macOS the agent sets the icon as a template so it renders as a monochrome glyph in the menu bar and reads correctly in light and dark mode, and it notes in the pull request that `ActivationPolicy::Accessory` would also hide the Dock icon if the maintainers want a menu-bar-only app. On Linux the tray needs the `libayatana-appindicator3-dev` package at build time, so the agent adds it to the `apt-get install` line in `.github/workflows/test-build.yml` and `release.yml` next to the webkit2gtk packages the template already installs, and says so in the description. The Vue frontend under `src/` is left alone: the tray is a native menu and needs no `@tauri-apps/api` call or Pinia state.

Before opening anything it proves the change compiles. It installs the Linux build dependencies in its sandbox, runs `cargo check --manifest-path src-tauri/Cargo.toml`, the same command the repository's `pnpm check` script wraps, then `cargo build --manifest-path src-tauri/Cargo.toml` so the tray and menu code paths are linked and not just type-checked, and `cargo clippy` on the crate to catch an unused import or a handler that ignores a `Result`. It runs `pnpm test` once as well, since `vitest` is the existing frontend check, to show nothing on the web side moved. The command output is pasted into the pull request description.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add a system tray icon to this Tauri 2 app. Read src-tauri/Cargo.toml, src-tauri/tauri.conf.json, src-tauri/src/lib.rs, src-tauri/src/main.rs, package.json and the workflows under .github/workflows first, and confirm there is no tray, menu or capabilities configuration today. Enable the tray-icon feature on the tauri crate. In lib.rs, build a tray with a menu of Show, Hide and Quit using the app's default window icon, make a left click on the tray show and focus the main window, mark the icon as a template on macOS, and make closing the main window hide it to the tray instead of exiting, with Quit as the only exit. Add the Linux appindicator build dependency to every workflow that installs webkit2gtk. Do not change the frontend. In your sandbox install the Linux build dependencies, run cargo check, cargo build and cargo clippy on src-tauri, run pnpm test, and open a pull request whose description lists the files changed, the platform notes for macOS, Windows and Linux, and the command output.",
  "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

What comes back is a pull request touching `src-tauri/Cargo.toml`, `src-tauri/src/lib.rs` and the two workflows that build on Linux, with `Cargo.lock` updated for the feature's transitive crates. The description explains the behaviour in a few lines: a tray icon with Show, Hide and Quit, left click restores the window, close hides to the tray, and a section per platform noting the template icon on macOS, that Windows needs nothing extra, and the appindicator package on Linux.

The run's record holds the `cargo check`, `cargo build`, `cargo clippy` and `pnpm test` output from the sandbox, so a reviewer can see the crate compiled with the new feature on Linux without building it locally. It also holds every file the agent read before deciding there was no existing tray code to merge with.

Before merging, a reviewer runs `pnpm tauri dev` on macOS or Windows, which the sandbox cannot do, checks that the icon appears and that Quit exits cleanly, and decides two product questions the pull request raises but does not settle: whether closing the window should really hide the app for first-time users, and whether to hide the Dock icon on macOS.

## Run it on every Linear issue labelled desktop

A team that tracks desktop work in Linear starts one run per issue from an automation with a `linear` trigger on the `desktop` label, in the Project that holds the Tauri repository. The trigger adds the issue after this prompt, so an issue that asks for a different menu, a tooltip with the version, or a tray-only mode on macOS is what the agent reads, and it fills in no placeholder in the prompt text itself.

Each run checks the app out in its own sandbox, installs the Linux build packages, makes the change and opens its own pull request linking the issue. An automation run has its own `max_runs_per_hour` cap, and a second issue labelled while the first is running simply gets a second sandbox.

## Why run it on Rush?

A tray icon is a small feature with an awkward build story: the `tray-icon` feature pulls in new crates, Linux needs a system package that is not in a stock runner, and most contributors have one operating system in front of them. The agent's sandbox is a clean Linux machine where it installs exactly the packages the workflow will need, which is how the pull request arrives with the CI change already made and a build log to show it worked, rather than a red first run.

The same request runs against every Tauri app an organisation ships, each in its own sandbox with its own `lib.rs` read first, and each pull request keeps the full command record. That is what makes it reviewable: a maintainer reads the diff and the `cargo build` output together and spends their own time on the two product decisions only a person can make.

## Frequently asked questions

### Does the tray need a capabilities file?

No. The tray is built in Rust inside `setup`, and Rust code is not subject to the capability system that governs what the webview may call. A capability file would only be needed if the Vue frontend later wanted to drive the tray through `@tauri-apps/api/tray`, which this change avoids on purpose.

### Which icon does the tray use?

The app's default window icon, which Tauri derives from the `bundle.icon` list in `tauri.conf.json`. On macOS the agent marks it as a template image so the system draws it in the menu bar's current colour; if the maintainers want a dedicated monochrome tray glyph, the pull request names where to add a separate PNG and point the builder at it.

### Why does closing the window hide the app?

Because a tray icon that outlives the window is what users expect from a tray app: the icon stays, the window comes back on click, and Quit in the menu exits. The behaviour is one `on_window_event` handler, so a reviewer who prefers close-to-exit removes about ten lines and keeps the rest.

### Will CI on Linux still pass?

The pull request adds `libayatana-appindicator3-dev` to the `apt-get install` step in every workflow that already installs the webkit2gtk packages, which is the dependency the tray needs to link on Linux. The agent installs the same package in its sandbox before `cargo build`, so the log shows the exact line that worked.

### Does it change the Vue frontend?

No. The menu, icon and click handling are native and live in `src-tauri/src/lib.rs`. `pnpm test` runs unchanged to show the frontend is untouched, and no new dependency is added to `package.json`.

## More Tauri jobs

- [Remember Window Size and Position Between Launches in a Tauri App](https://getrush.ai/run/persist-window-state/tauri/)
- [Update Pinned GitHub Actions in a Tauri Repo](https://getrush.ai/run/update-github-actions/tauri/)
- [Add an Auto-Updater to a Tauri App](https://getrush.ai/run/add-auto-updater/tauri/)

## The same job on other stacks

- [Add a System Tray Icon to an Electron App](https://getrush.ai/run/add-tray-icon/electron/)

## More jobs like this: Turn a Linear label into a PR

- [Add a Tree View to a VS Code Extension](https://getrush.ai/run/add-tree-view/vscode-extension/)
- [Add Two-Factor Authentication to an Express and Mongoose API](https://getrush.ai/run/add-two-factor-auth/mongoose/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
