All jobs

Add Dark Mode to a Tauri App

Yes. An agent adds a light theme to your Tauri 2 + Vue app's Tailwind 4 styles, follows the OS theme via Tauri's window API, adds a persisted toggle, 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 front end and the Tauri side before it touches a colour. In an app laid out like Uninen/tauri-vue-template, package.json runs Vue 3.5 with Vite, Pinia, @tauri-apps/api 2.10, Tailwind 4 through @tailwindcss/vite, Vitest 4 and vue-tsc, with unplugin-auto-import making ref, computed and useStore available without imports. src/assets/main.css imports Tailwind, declares fonts in @theme, and then hard-codes one palette: html is text-gray-200 bg-gray-800, .btn and input are gray-700 on gray-800, links are text-sky-500. There is no dark: variant anywhere, so the app is dark-only rather than dark-aware. src/store.ts is a Pinia store named main with debug, version, isInitialized and name; App.vue and GreetComponent.vue use those classes. src-tauri/tauri.conf.json declares one window, main, 800 by 600, with no theme key, and there is no src-tauri/capabilities directory. vitest.config.ts includes tests/unit/**/*.test.ts with tests/setup/testglobals.ts installing a testing Pinia, and sets no DOM environment. .github/workflows/test.yml runs pnpm test on Node 24 with pnpm 10.

The CSS change makes the palette two-sided. Tailwind 4 applies dark: by prefers-color-scheme unless told otherwise, so the agent adds @custom-variant dark (&:where(.dark, .dark *)); after the import, the documented way to drive dark mode from a class, and rewrites each rule as a pair: html becomes bg-white text-gray-900 dark:bg-gray-800 dark:text-gray-200, .btn and input get light defaults with the current grays under dark:, and html gains color-scheme: light with .dark { color-scheme: dark } so scrollbars and native controls match. Nothing in the existing dark look changes; it is now the dark: half of every rule.

The source of truth for the theme is a useTheme composable with a preference of system, light or dark kept in localStorage under theme, which is the pattern Tailwind's documentation gives for a three-way toggle. When the preference is system, the composable asks Tauri rather than the browser: getCurrentWindow().theme() returns Promise<Theme | null> with Theme being 'light' | 'dark', and onThemeChanged(({ payload }) => ...) fires when the OS switches; the unlisten function it returns is called on unmount. When the window API is not present (in Vitest, or in a plain browser tab) it falls back to matchMedia('(prefers-color-scheme: dark)'). The effective theme is applied by toggling dark on document.documentElement, and a short inline script in index.html sets that class before the first paint so a dark window does not flash white. Because the template has no capability files, the agent adds src-tauri/capabilities/default.json for the main window with core:window:default, which covers the theme getter, and core:event:default for the listener. setTheme, which would make the native title bar follow the toggle, needs core:window:allow-set-theme, which the API reference says is not in the default set; the agent adds it only if the prompt asks for that.

A ThemeToggle.vue cycles the three states with icons from the mdi set the project already loads through @egoist/tailwindcss-icons (i-mdi-monitor, i-mdi-weather-sunny, i-mdi-weather-night), placed in App.vue next to the heading. Tests go under tests/unit: the function that resolves a preference and an OS theme into an effective theme is pure and runs in the default Node environment; the test that checks the class on document.documentElement adds happy-dom as a devDependency and declares @vitest-environment happy-dom at the top of its file, with @tauri-apps/api/window mocked through vi.mock. pnpm test, pnpm build (which runs vue-tsc) and pnpm check (cargo check in src-tauri) pass before the pull request opens.

Start it with one API call

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

{
  "agent": "claude",
  "input": "Add dark mode with a light theme and a toggle to this Tauri 2 + Vue 3 app. Read package.json, vite.config.ts, vitest.config.ts, src/assets/main.css, src/App.vue, src/components/GreetComponent.vue, src/store.ts, index.html, src-tauri/tauri.conf.json, src-tauri/src/lib.rs and the tests folder first. In main.css add @custom-variant dark (&:where(.dark, .dark *)) and turn every hard-coded gray rule into a light default with the current colours under dark:, and set color-scheme on html and .dark. Add a useTheme composable with a system, light or dark preference persisted in localStorage under theme; when the preference is system read the window theme with getCurrentWindow().theme() and subscribe with onThemeChanged, falling back to matchMedia when the Tauri API is absent; apply the result as a dark class on the html element and add an inline script in index.html that sets the class before first paint. Add src-tauri/capabilities/default.json for the main window with core:window:default and core:event:default. Add a ThemeToggle component using the mdi icons already configured and place it in App.vue. Write Vitest tests for the pure resolver and, with happy-dom and a per-file environment comment, for the class on the html element, mocking @tauri-apps/api/window. Run pnpm test, pnpm build and pnpm check, then open a pull request that shows both themes and lists the capability added.",
  "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 changes src/assets/main.css, src/App.vue and index.html, adds src/composables/useTheme.ts, src/components/ThemeToggle.vue, src-tauri/capabilities/default.json and two test files under tests/unit, and adds happy-dom to package.json with the lockfile change. Its description shows the app in both themes, lists the capability permissions it granted and the one it did not, and quotes the Vitest output.

A reviewer runs pnpm tauri dev, switches the OS appearance and watches the window follow, then picks a fixed preference and restarts the app to see it persist. They read the CSS diff rule by rule to confirm the dark half is the old look unchanged, and read default.json to confirm the window got only the permissions the feature needs. Whether the native title bar should follow the toggle, which needs the extra permission and setTheme, is the one decision left open.

The unit tests cover the resolver and the class application; the OS-level behaviour is checked by hand because there is no driver for the native theme in CI.

Run it on every Linear issue labelled design

An automation on the Project with a linear trigger on linear.issue.labeled and the label design starts one run per visual change. The trigger adds the issue after the prompt and fills in no placeholder, so the prompt tells the agent to read the change from the issue and to express new colours as light and dark: pairs in main.css, keeping the composable as the single place the theme is decided.

A studio with several Tauri apps built from the same template sends this body once per repository from its own server, each POST /o/{org}/sessions naming that repository in resources and a request_id that is a UUID v5 of the repository name, so a retried call returns the run already started. Each run reads its own main.css and converts the palette it finds.

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

Why run it on Rush?

Dark mode in a desktop app touches three layers that are hard to check together on one machine: the stylesheet, the preference and the OS signal that Tauri exposes through a permission. The agent works through all three in its own sandbox, builds the front end with vue-tsc, runs cargo check against the capability it added, and keeps every command with the pull request.

A reviewer reads a CSS diff, one composable and one JSON capability instead of a changelog, and sees both themes before opening the branch. The same request runs across every app built from the template at once.

Frequently asked questions

Why not just use prefers-color-scheme?

That is the fallback, and it is what Tailwind's dark: does with no configuration. The class-based variant is there so the toggle can force a theme regardless of the OS, and the Tauri window API is preferred for the system case because it reports the theme the window actually has.

Why does the app need a capabilities file now?

The template ships none, and its only call into Tauri is the app's own greet command, which needs no permission. Reading the window theme and listening for changes are core commands, so the agent adds capabilities/default.json granting core:window:default and core:event:default to the main window and nothing else.

Will the window chrome change too?

Not by default. setTheme can make the native title bar follow the toggle on Windows, and on Linux and macOS the theme is app-wide, but it needs core:window:allow-set-theme, which is outside the default set. The pull request names the permission and leaves the call out unless asked.

Does the existing dark look change?

No. Every current colour becomes the dark: side of its rule, and the new light side is the addition. A user whose OS is dark sees the same app.

How are the tests run without a window?

The resolver is a pure function and runs under Vitest's default Node environment. The test that checks the dark class uses happy-dom through a per-file @vitest-environment comment and mocks @tauri-apps/api/window, since the project's Vitest config sets no DOM environment.

More Tauri jobs

The same job on other stacks

Keep reading