# The desktop application

> Run the editor in its own window on Windows: build it, start it, use the menu and the native file picker.

Source: https://stuarty.com/docs/guide/desktop/

**Warning:**
The desktop application is new. A release lists an installer for Windows 11, a disk image for macOS and a package for Debian and Ubuntu, none signed with a paid certificate (see [Installation](/docs/installation)); you can also build it from source. It has been run by hand on Windows 11 only; macOS and Linux are built and their files are checked in CI, but the window has not been run there, so this page does not describe them.

## You will learn

- what the desktop application is and what it adds to `stuarty serve`;
- how to build and start it on Windows;
- what the menu, the file picker and full screen do.

## The idea

The desktop application is a small shell around the same program. It starts `stuarty serve` on a free port of `127.0.0.1`, waits until the server is up, and opens the editor in one native window. It has no editing logic of its own: the window shows the same editor you get in a browser, over the same [workspace](/docs/workspace), protected by your local [account](/docs/account).

Closing the window, choosing Quit, or a crash of the shell stops the server it started. The window cannot leave its own server: if a page ends at another address, the shell sends the window back to the editor.

## Quick start

You need Go, Bun and, on Windows 11, nothing else (WebView2 ships with the system). From the repository root:

```bash
cd web && bun install --frozen-lockfile && bun run build && cd ..
go build -o dist/stuarty.exe ./web/cmd/app
cd desktop/shell/app && go build -ldflags "-H windowsgui" -o ../../../dist/stuarty-desktop.exe .
```

Put the two files in one folder and set `STUARTY_HOME` to a development folder (a dev build refuses the default `~/.stuarty` workspace with `E_INVALID_STATE` unless built with `-ldflags "-H windowsgui -X main.version=<release>"`), then start `stuarty-desktop.exe`. To use a server program in another place, start it as `stuarty-desktop -binary <path to stuarty>`. The first start can take tens of seconds while the window component starts; later starts are faster.

The workspace is `~/.stuarty` for release builds, or the folder in `STUARTY_HOME` if you set it before you start the application. You can also run the same server with `stuarty serve` and open it in a browser with `stuarty open`: once you sign in with your local [account](/docs/account), both the desktop window and the browser session have full person privileges (see [Approvals](/docs/guide/approvals)).

## Automate the window

To drive the window from a tool such as Playwright or a Chrome DevTools client, start the application with `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS` set to the flags you want, for example `--remote-debugging-port=9223` (Windows). The application reads the variable at start and passes the flags to the window component. Then connect to `http://127.0.0.1:9223/json/list`. Choose a port that is free; the port opens a few seconds after the window appears. The flag does not show in the command line of the `msedgewebview2` process, so check the port, not the command line. `WEBVIEW2_USER_DATA_FOLDER` names the browser profile folder; without it each workspace has its own, in `webview` inside the workspace. This is for tests and debugging only: the debugging port gives full control of the editor to any program on the machine.

## The menu, the file picker and full screen

| Menu | Entry | What it does |
| --- | --- | --- |
| File | Open workspace folder | opens the workspace folder in the file manager |
| File | Quit | stops the server and closes the window |
| View | Reload | reloads the editor |
| View | Toggle full screen | full screen on and off; the key is `F11` |
| Help | About | shows the version |

In a browser you paste a file path to import media. In the desktop window the editor shows **Choose files**, which opens the native file dialog and imports the files you pick. Dropping files on the window imports them in the same way. The editor sends only the paths to the server, which copies the files into the workspace, so nothing is uploaded anywhere.

## Updates

The application can look for a newer version, and only with your consent. The first time you start it, it asks **Check for updates automatically?** with **Yes** selected; nothing connects before you answer. With Yes it checks at start-up and every 24 hours; with No, or with **Help**, **Check for updates automatically** cleared, it opens no connection at all, and **Help**, **Check for updates** makes one check for that action. A check is one HTTPS request for a signed file, `feed.json`, on the GitHub Pages site of the project; the installer it offers is downloaded from the same address, and the application checks its SHA-256 and its signature before it runs it. A file that does not match is refused and the application keeps running. On Windows the installer is started for you and the application quits; on macOS and Linux the application shows the release page instead. A build made without the signing key built in (for example one you compiled yourself) has no update check and says so in the menu. What the request carries and how to turn it off are on [Desktop updates and how to turn them off](/docs/self-hosting/desktop-updates); how the feed is signed is on [Verify a release](/docs/self-hosting/verify-a-release).

**Warning:**
The site moved to `https://stuarty.com` in v0.21.0, and the feed moved with it (`https://stuarty.com/updates/feed.json`). The update address is built into each application, and the update client follows no redirect. Applications up to v0.20.0 still ask the old address (`alexgalhardo.github.io/stuarty`), so they will not find v0.21.0 or later. Download the installer of the latest release from the [release page](https://github.com/AlexGalhardo/stuarty/releases) and install it once. From v0.21.0 on, updates work again as described above.

## Keep running in the background

A post you schedule goes out only while Stuarty is running. On Windows you can let the application stay running behind an icon in the notification area after you close the window, so a scheduled post still goes out. It is off until you turn it on: the first time you schedule a post in the desktop window, a dialog explains the choice and asks once, and **Settings**, **Background** changes it later.

- **Keep running in the background.** Closing the window while at least one post is scheduled hides it instead of quitting, and the icon shows that Stuarty is still there. With nothing scheduled, or with the option off, closing the window quits as before. The icon's menu has **Open Stuarty**, **Pause publishing** and **Quit**; **Quit** says how many scheduled posts will wait until Stuarty runs again.
- **Start when I sign in.** Starts Stuarty hidden when you sign in to Windows, only for your user and with no administrator rights. Turning the option off, or uninstalling Stuarty, removes it. Nothing is registered unless you turn it on.
- **The limits.** A post goes out only if the computer is on and you are signed in: Stuarty does not wake the computer and is not a system service. A post whose time passed while Stuarty was not running is never sent on its own; it waits for your decision on the calendar. Starting Stuarty a second time shows the window that is already running instead of opening another one.

The background mode opens no connection of its own: only the connections you set up are used, as before. On macOS and Linux the same settings exist and are not verified.

## Common mistakes

- The build is not signed with a paid certificate, so Windows SmartScreen warns before the first run. See [Installation](/docs/installation) for the steps on Windows and macOS.
- Every page answers with an error: the front end was not built. Run `bun run build` in `web/` before `go build`.
- A second copy of the program on the same workspace: the workspace is locked and the second one cannot start. See [the workspace is locked](/docs/troubleshooting/workspace-locked) This includes a `stuarty serve` that is already running on the workspace: the window says so, with the process and the address. Open that server with `stuarty open`, stop it, or give the application another folder in `STUARTY_HOME`.
- Looking for macOS or Linux builds: they are not verified, so nothing here is promised for them.

## Next steps

- [Installation](/docs/installation)
- [Desktop updates and how to turn them off](/docs/self-hosting/desktop-updates)
- [Verify a release](/docs/self-hosting/verify-a-release)
- [Run the binary](/docs/self-hosting/binary)
