# Desktop app

Atlas Desktop is a native app (Tauri 2 + Svelte 5) for macOS (Apple silicon), Windows 10/11 (x64, one click with `Atlas-Setup.exe`) and Linux (x86_64). The GPU terminal is macOS only, agent test instances (with stills, recording, Lab and the mirror) run on macOS and Linux, and the built-in capture of your own windows is macOS only; on Windows and Linux terminals use xterm.js. It lists every atlas project in a sidebar and lets you start and stop each stack. It shows services live, streams and searches logs, runs actions, and edits `atlas.yaml` with validation.

It is a client of the same runners as the CLI: **Start** runs `atlas dev --detach`, and **Stop** is `atlas down`. The app, an attached TUI and an AI agent (through [MCP](https://atlas.codeatlas.com.br/docs/mcp.md)) all see and control the same live state. Quitting or closing the app never stops a stack.

Contents: [Getting around](#getting-around) · [Install](#install) · [Updates](#updates) · [Architecture](#architecture) · [Projects and worktrees](#projects-and-worktrees) · [Tabs and panes](#tabs-and-panes) · [Agents](#agents) · [SSH hosts](#ssh-hosts) · [Keyboard](#keyboard) · [Automation](#automation) · [Developing the app](#developing-the-app)

## Getting around

**Spaces.** Every project is a space: it keeps its own worktrees, tabs, panes and docks, and has its own **icon and color**. The color is derived from the project unless you pick one, and tints the selection, the header and focus states, so you always know which project you are in. Pick a space in the sidebar, or move with ⌥⌘← / ⌥⌘→ and ⌃1…⌃9.

**Project icons.** Colors alone get confusing, so each project also shows an icon: your choice, else the repo's own logo, else a monogram (`my-app` → **MA**) on its color. Right-click a project (in the list or the bottom strip), or `⋯` → **Change icon and color…**: _Emoji_ (type or paste any emoji, or pick one), _Icons_ (search the ~1,900 Lucide icons), _Project logo_ (shown when Atlas found one), plus color swatches (the first one, dashed, is the automatic color). **Reset** goes back to automatic. Atlas looks for the logo in `package.json` `icon`, then `public/favicon.svg|png|ico`, `public/icon.*`, `public/logo.*`, `public/apple-touch-icon.png`, `static/favicon.*`, `app/icon.*` (and `src/app/`), `assets/logo.*`, `.github/logo.*`, and `logo.*` / `icon.*` / `favicon.ico` at the root; images over 256 KB are skipped. It is read through the host, so SSH projects get their logo too. The choice is saved per project in `~/.atlas/desktop/projects.json` (`identity`). The icon appears in the sidebar and its bottom strip, the header breadcrumb, the project panel, the jump palette, the Files header and the tray popover.

**Sidebars.** The left sidebar shows the **active project** (icon, name, live status dot that breathes while its stack runs, `up/total` services) and its worktrees; a project with a single checkout is just its own row (clicking it opens `main`, no redundant child). **Other projects** is collapsed by default (pinned first); each shows its icon, status and service count, with a chevron to expand worktrees only when it has more than one. Filtering opens the list and shows every match. At the bottom, a strip of project icons switches space (active one ringed, tooltip with the name and ⌃N). Hide the sidebar with ⌃⌘S. The right sidebar (⌘R) holds agent history and listening ports; hide it for a calmer view. Hidden sidebars can be peeked without losing your layout. A project's panel (stack health, services and their live CPU and memory) is the first thing a space shows.

**Peeking a hidden sidebar.** Move the pointer to the window edge (left for spaces, right for the context sidebar; the last 12 px count as the edge, since the outermost pixels are window padding and the OS resize band) and it slides in over the content: after ~60 ms, or at once if you flick into the edge. Pushing the pointer against the very edge counts as staying there: the page reports it as leaving the window, which neither cancels the open nor closes an open panel. A press, a drag or a modal dialog cancels the dwell, and the next move at the edge starts a new one. It stays while the pointer is on it (with a 24 px margin), slides out 250 ms after you leave, and ⎋ dismisses it. A menu or dialog opened from it keeps it open.

**The right panel** (Agents / Ports) opens three ways: peeking from the right edge, the header button, and ⌘R (Ctrl+R elsewhere), the last two toggling it pinned beside the panes (the pin button in the panel does the same). It reads fresh data each time it comes on screen and reads nothing while hidden. **Agents:** the agents running in this worktree come first (state: needs you, working, done or idle; what each last said or was asked; how long ago; click to bring its terminal forward), then the history of past sessions with ages (Resume, Resume in native chat, Copy command, Reveal), filtered by search and by scope (Worktree, Project, All). With no sessions it says what the panel is for and offers New agent session with its shortcut. **Ports:** every port the worktree's terminals listen on (on an SSH host, every listening port there), named after the `atlas.yaml` service that declares it, plus the declared port of each running service that no terminal owns (`atlas dev` starts services outside the terminals); a click opens it in Atlas's browser tab, the arrow in the system browser (remote ports go through an `ssh -L` forward first). With none it says where ports come from.

**Trackpad gestures.** Two-finger swipes work like Arc and never take over scrolling: a gesture only starts when it is clearly horizontal (15 pt of travel, at least twice the vertical) over a swipeable area, and a vertical scroll, a resting finger's jitter or a wheel mouse never starts one.

| Swipe…       | Over                               | Does                                                                                                                                                                                              |
| ------------ | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| left / right | the sidebar                        | next / previous space. The content follows your fingers 1:1 and the next space slides in beside it; past half a page, or with a quick flick, it commits, otherwise it springs back                |
| left / right | the tab strip or the tab's content | next / previous tab, the same way                                                                                                                                                                 |
| right / left | the content, where nothing scrolls | Back / Forward through visited worktrees and tabs (⌘[ / ⌘]), with an arrow chip that fills as you drag                                                                                            |

The release is decided the instant your fingers lift (not after a quiet gap), the page settles in about 0.3 s with no overshoot, and the momentum tail after it is swallowed, so one swipe is one switch, never two. Swiping at the first or last space only stretches like a rubber band. A new swipe during a settle continues from where the page is. With _Reduce motion_ on, nothing animates and the switch is instant. Pinch (ctrl + wheel) is never treated as a swipe.

**Search and jump.**

| Want to…                              | Press     |
| ------------------------------------- | --------- |
| Go to a worktree, terminal or command | ⌘K        |
| Open a file in this worktree          | ⌘P        |
| Run any command (and see its key)     | ⌘⇧P       |
| Open a symbol in the current editor   | ⌘⇧O       |
| See every shortcut                    | ⌘/ or `?` |

**First run.** With no projects, Atlas shows a welcome in three short beats (projects become spaces, terminals and agents per worktree, one key to go anywhere) and one action: **Add your first project**. **Or find projects on this machine** scans the usual folders. **Skip for now** closes it; it does not come back once you add a project or skip.

**The tour.** After your first project, a guided tour spotlights the sidebar, spaces, header breadcrumb, the project panel, a service card, the right-sidebar toggle and the jump palette. → or Enter next, ← back, Esc skip. Steps whose part of the screen is not visible are skipped. Run it again from ⌘⇧P → _Take the tour_ or Settings → _Help & onboarding_.

**Getting started checklist.** A small card in the bottom-right corner tracks six first steps: add a project, start the stack, open a terminal (⌘T), run an agent (⌘⇧A), try the command palette (⌘⇧P), search a file (⌘P). Items tick themselves when you do the thing, whichever way you did it. Collapse it with its header (or Esc), dismiss it with ✕ (it also leaves by itself when done). The corner is one column shared with toasts and suggestions: errors and toasts come first (newest nearest the corner, three at most, the rest under **+N more**), the checklist folds to its header while one is showing and opens again after (if you had it open), and a suggestion (enable an agent's hooks, use your Ghostty theme, "Updated to…") waits for a calm corner, one at a time. In a narrow window the column is a full-width bottom sheet. _Show getting started checklist_ in ⌘⇧P, or Settings → _Help & onboarding_, brings it back; _Start over_ resets the tour and the checklist.

**Help.** ⌘/ (or `?` outside a text field) opens a searchable cheat sheet generated from the live keymap, so it shows your own remaps. State is saved under `onboarding` in `~/.atlas/desktop/settings.json`.

## Install

```sh
atlas desktop
```

The first run downloads the `Atlas.app` that matches your CLI version from the public GitHub release (with `curl`, checksum verified), installs it into `/Applications`, and opens it. Later runs just open it. You can also download `Atlas-<version>-aarch64-apple-darwin.dmg` from the release by hand.

Requirements:

- macOS 13+ on Apple silicon, Linux x86_64 (glibc 2.35+, WebKitGTK 4.1), or Windows 10 (1809+) / 11 on x64 (WebView2). On Linux and Windows terminals use xterm.js rather than the native GPU terminal, and the built-in capture of your own windows is macOS only. Agent test instances run on macOS and on Linux (own headless sway and D-Bus; stills through `grim`, recording through `grim` and `ffmpeg`, Lab and the mirror); see [Linux and Windows gaps](https://atlas.codeatlas.com.br/docs/contributing.md). The window has one title row drawn by the app on every OS: macOS keeps its traffic lights and menu bar at the top of the screen; Windows and Linux have no native title bar or menu bar (every menu command is in the palette) and the app draws minimize, maximize and close, except on a Linux tiling window manager (Hyprland, Sway, i3, niri…, from `XDG_CURRENT_DESKTOP`), where the window manager owns the window and Atlas draws none. Known limit: with no native frame, tauri-runtime-wry keeps a 5 px resize band along every window edge, also on a tiling window manager (GTK never reports a tiled window as maximized, and a non-resizable window would make sway and Hyprland float it), so a click in the outermost 5 px of the window starts a resize instead of reaching the page. Windows specifics (cmd.exe for `atlas.yaml` commands, ConPTY, no live host upgrade): [Installation › Windows](https://atlas.codeatlas.com.br/docs/installation.md#windows).
- The atlas CLI. The app looks for it at `$ATLAS_BIN`, then `~/.atlas/bin/atlas`, then (Windows) the `atlas.exe` its installer put next to the app, then `atlas` on `PATH`.
- `curl` (preinstalled on macOS). No GitHub login is needed: releases are public.
- Optional: `gh`, logged in (`gh auth login`), for the pull-request tab and checks.

### Shell environment

Opened from Finder or the Dock on macOS, or from a menu entry on Linux, the app gets the session's bare environment (`PATH=/usr/bin:/bin:…`), so `bun` (`~/.bun/bin`), `node` and anything from Homebrew, nvm, mise or asdf would be missing (`exit 127: sh: 1: bun: not found`). At launch Atlas reads the environment of your shell in the background and starts every service, `pre_command`, action, terminal and agent, plus `git`, `gh` and updates, with it, exactly as your terminal would. Commands themselves still run through `sh -c`. The runner (`atlas dev`) and the terminal host (`atlas hostd`) do the same when started from a terminal or by the app, so all of them see one `PATH`.

- Which shell: the one chosen in **Settings → Integrations → Shell & links → Shell for your projects**, else `$SHELL`, else your account's login shell from the user database (`chsh`), else `/bin/zsh` (`/bin/sh` where zsh is missing). Any shell works (zsh, bash, fish, nushell, ksh, dash, tcsh…): Atlas runs it as an interactive login shell and only asks it to run `/usr/bin/env -0`, trying `-l -i -c`, then `-l -c`, then `-c`; anything your rc files print around the result is ignored.
- Settings lists shells from `/etc/shells`, accepts any path, shows which flags worked, how long it took, the resulting `PATH`, and whether `bun`, `node`, `docker`, `gh`… are found. **Reload** re-reads it after you edit your rc files.
- A shell that fails or takes over 6 s is reported there, and Atlas falls back to the inherited `PATH` with the usual user bin directories that exist prepended (`~/.bun/bin`, `~/.cargo/bin`, `~/.local/bin`, mise and asdf shims, the newest nvm node).
- When a `pre_command` (the stack setup) exits 127, the setup panel and `.logs/setup.log` name the missing binary, the `PATH` Atlas used and what to do: put the directory on `PATH` in your shell's rc file (`~/.bashrc`, `~/.zshrc`, `~/.config/fish/config.fish`) or pick the right shell in Settings → Integrations → Shell & links, then restart.
- Projects already running keep the environment they started with: stop and start them after a change.
- The choice is saved in `~/.atlas/desktop/settings.json` (`{"shell": "/opt/homebrew/bin/fish"}`).

## Updates

The CLI and the app are released together with the same version, and they update together:

- **From the terminal:** `atlas update` updates the CLI, then brings an installed `Atlas.app` to the same version.
- **From the app:** the app checks on launch, when you return to it (at most every 6 hours) and every 6 hours while open; turn this off in Settings → General → Updates → _Check automatically_. When a newer release exists a calm **Update to X.Y.Z** pill with a soft glow appears in the sidebar footer, and you get one native notification per version (through the same switch as agent notifications, Settings → Notifications & sounds). Clicking the pill, or ⌘K → _What's new_, opens the **What's new** sheet.
- **What's new sheet:** the release notes (each version's `CHANGELOG.md` section, read from the public repository without the GitHub API) of every version between the one you run and the latest. Each version has a header (version, date, an _Alpha_/_Beta_/_RC_ badge for a pre-release, *Latest*/*Installed*/*New*) and the footer names the channel of the release shown and the one you follow. The sheet hides a pre-release section once its stable release is in range (the stable section is the complete summary), the changelog's one-line summary and its changes in cards by kind, each change a bold title plus its text (long ones fold behind *More*). The intro, the titles and the texts are the changelog's inline markdown rendered (`**bold**`, `` `code` ``, links: never the raw markers); the "Updated to X" card shows the same text as plain words. With several versions a sticky index follows the scroll, versions fold, and `j`/`k` move between them. **Update to X and relaunch** (with the download size) runs `atlas update` and shows _Download → Verify → Install CLI → Update app → Terminal host → Relaunch_ with a progress bar for the download (the raw output is under _Details_), then **Relaunch Atlas**; a failure shows the reason inline with **Try again**. **Remind me later** only closes the sheet (the pill stays); **Skip this version** hides the pill and the notification until a newer version ships (stored under `updates` in `settings.json`, with `notified` and `lastSeen`), and Settings → General → Updates offers *Stop skipping*.
- **Update channel:** Settings → General → Updates → **Update channel** has three cards, _Stable_, _Beta_ and _Alpha_ (the default while Atlas is in alpha: a profile without `~/.atlas/update-channel` follows it) (see [Versioning and release channels](https://atlas.codeatlas.com.br/docs/versioning.md#channels)). Each shows its promise, a risk badge, how often it ships, who it is for and what it offers **right now** ("Offers 1.4.0-beta.2", "Nothing newer than what you run", "Offers 1.3.0, older than yours"); _Following_ marks the one you use and _Installed_ the one the running build was cut for. While Atlas is in alpha a note above the cards says that every channel, Stable included, can still have rough edges. Picking a card opens an inline confirmation with what the switch means; only **Follow …** saves it. The choice is the one word in `~/.atlas/update-channel` that the CLI shares (`atlas update channel`), never a second copy in `settings.json`; if `ATLAS_UPDATE_CHANNEL` is set in the app's environment the cards are disabled and say so. Offline, the cards still render from their copy and **Retry** looks again. Switching never installs anything older: when the chosen channel only offers a build older than yours the panel adds a separate **Install X now (downgrade)** button (it runs `atlas update --downgrade --yes`, and warns that settings or data written by the newer build may not be readable), and automatic checks, the pill and the notification only ever react to a strictly newer release.
- **After an update:** the first launch of the new version shows a one-time _Updated to X_ card with **See what's new**, opening the same sheet for that version.
- **Commands:** ⌘K → _Check for updates_ (checks now and says what it found, or opens the sheet) and _What's new_. Settings → General → Updates shows both versions, when it last checked, **Check now**, the **Update channel** cards, the auto-check switch and a link to the full changelog.
- **Repair:** **Reinstall app** in the sheet, or `atlas desktop --install --latest`.
- **Terminal host:** `atlas update` ends with a _Terminal host_ step (`@@atlas phase terminal-host`): the running `atlas hostd` is compared with the new version and handed over live (no terminal is lost), restarted silently when no terminal runs, or, when terminals run and features such as language servers would stay off, you are asked first (`Restart now and end N terminals? [y/N]`). It never ends a terminal without your yes; if you decline or run without a TTY, it prints what is stale and the command to fix it. See [`atlas hostd`](#keeping-the-terminal-host-current).

### Keeping the terminal host current

The terminal host outlives the app and `atlas update`, so it can be older than the CLI. Three commands report and fix that (all take `--dir`, default `~/.atlas` or `$ATLAS_HOSTD_DIR`):

- `atlas hostd --check`: one human report (`Terminal host 0.6.2 (pid 812, up 40h, 2 terminals) is older than Atlas 1.2.1; language features … off until it restarts.`) with the running terminals (folder and command) and the exact fix commands. Exit `0` current, `3` stale, `1` not running. `--status` still prints the raw `info` JSON.
- `atlas hostd --reconcile [--choice ask|idle|later]`: acts on it. A host that can hand over (`upgrade` capability) is replaced live and verified (new version, no terminal lost); one that cannot is restarted when no terminal runs; otherwise it asks (`ask`), waits (`idle`) or leaves it (`later`). Exit `0` also when it is not running.
- `atlas hostd --restart`: explicit consent: stop it (ending its terminals), start a fresh one from this binary and verify it.

An idle host does not linger forever: with **no running terminal, no connected client and no paired phone for 10 minutes** (`ATLAS_HOSTD_IDLE_SECS` overrides, in seconds) it exits and removes its socket and pid file, and it also exits if its own directory disappears. A running terminal always keeps it alive, and so does a paired Atlas Mobile phone (not revoked), even while the phone is away: it only ever dials a host that is already there. The app starts a host when it needs one, and remote hosts are started again by the app on every connect, so an exited one comes back current.

### How an update stays safe

`atlas update` (the app runs the same command) verifies the SHA-256 of every download (the CLI tarball and the app tarball) and refuses an asset without a checksum. It takes `~/.atlas/.update.lock` (`flock`, released by the kernel if the process dies), so a second update from another terminal or window stops with a clear message. The CLI is replaced in place after a backup of the previous one (`~/.atlas/bin/.atlas.prev`); if the app then cannot be brought to the same version the CLI is restored and the error says so, so the two never sit on different versions in silence. With `ATLAS_UPDATE_PROGRESS=1` the CLI prints `@@atlas phase|bytes|rollback|host|managed …` lines next to its normal output (`managed homebrew|package` means the CLI exited 0 but installed nothing because Homebrew or a system package manager owns this Atlas: the app shows how to update it instead of "Atlas is up to date"); the app turns them into the step list and the progress bar, and an older CLI without them still advances the steps from its plain text.

The app is replaced the same way on every OS: the previous app stays until the new one is verified, and an update that fails or is killed never leaves you without Atlas Desktop. **macOS:** the new bundle is built next to `Atlas.app` (`.Atlas.app.new`), the old one moves to `.Atlas.app.old`, the new one takes its place and only then is the old one deleted. If the process dies between the two renames, the next `atlas`/`atlas desktop` run puts `.Atlas.app.old` back before doing anything else. **Linux:** the previous AppImage is kept as `~/.local/bin/.atlas-desktop.prev` until the new one is in place and its version recorded, and put back when either fails. **Windows:** the install folder (`%LOCALAPPDATA%\Atlas`) moves aside to `Atlas.prev` before the installer runs; if the installer fails, leaves no `atlas-desktop.exe`, or leaves a version other than the wanted one (the `DisplayVersion` it registers), the folder is restored. A running Atlas on Windows keeps the folder locked, so the update stops before touching it and asks you to close the app. Staging files and folders are removed on every path, including a full disk. When the app is a symlink to a dev build (`atlas link --desktop`) and the CLI is not linked, `atlas update` leaves the app alone and prints one line saying so.

## Architecture

Terminals live in **`atlas hostd`**, a per-user daemon (`~/.atlas/hostd.sock`, token `~/.atlas/hostd.token`) that the app starts on launch. It owns PTYs, one-shot `exec`, file access and scrollback, so terminals and agents keep running when the app quits, crashes or updates; reopening restores the tabs with their scrollback. The same daemon runs on SSH hosts.

### Reporting a problem

When the terminal host cannot be reached, one toast (with a count if it repeats) offers **Restart terminal host** and **Report**. Restarting ends the terminals it hosts (their tabs stay; use Restart on each) and works even when the host does not answer: the app ends the daemon named in `hostd.pid`, only if that process is an `atlas hostd`, and starts a clean one. **Report** opens the error screen with a diagnostics block built by the backend (`host_diagnostics`): versions of the app, the installed CLI and the running host, the OS, the last 40 lines of `hostd.log` and of `~/.atlas/desktop/app.log` (Rust panics, host incidents), and the newest crash report (`atlas_core::crash`, message and location only). **Copy details** and **Copy as Markdown** carry it; **Report issue** opens the bug form with its fields prefilled. Secrets (tokens, passwords, API keys, URL credentials) and home directories are redacted in the backend and again before anything is copied or sent. For the host's own state from a shell, `atlas hostd --check` is the doctor.

**Updating the host without losing terminals.** The daemon outlives app updates, so after one it is older than the app. On connect the app compares the daemon's `info` (`version`, `proto`, `caps`) with its own version and acts:

- the daemon supports `upgrade` (protocol 2+): **live takeover**. The new `atlas hostd --takeover` receives every pty master fd (`SCM_RIGHTS` over a unix socket) plus the session state and the pid-file lock, binds the socket, confirms, and the old process exits. Programs keep running (they never notice); scrollback keeps appending to the same files; the app reconnects and reattaches, GPU terminals open their raw streams, and a _Terminal host updated_ toast appears. If the successor fails before confirming, the old daemon takes its ptys back and keeps serving. `atlas hostd --upgrade` does the same from a shell with the binary you run.
- an older (protocol 1) daemon cannot hand over. With no running terminal the app restarts it silently; with running terminals and features missing the app asks once per session in a _Restart the terminal host?_ dialog listing them: **Restart now**, **Restart when idle** (also when you quit with nothing running) or **Later**. The _Terminal host needs a restart_ chip in the sidebar footer and the _Terminal host_ row in Settings → General → Updates stay until it is current (terminals use xterm.js meanwhile). It also updates by itself the next time the app starts with nothing running. Handing over from protocol 1 to 2 is the one update that needs this restart; later ones are live.
- pipe-mode sessions (`omp --mode rpc-ui`) have no pty master to pass and end with the old daemon.
- one update is one handoff. A daemon at the app's version **or newer** is current: an app older than the installed CLI (the app has not restarted yet after `atlas update`) never replaces a host that is already ahead of it. Concurrent `upgrade` calls (`atlas update` and the app at the same moment) are serialized by the daemon: the first moves the terminals, a later one gets `handed_off: 0` and just reconnects.
- the outage toast only stays while the host is really unreachable: a failure shorter than 3 seconds (the moment of a live handoff) shows nothing, and `host://reconnected` or a successful terminal list dismisses a toast and the pane notice _Terminal host not reachable_.
- exit codes of programs adopted by a takeover come from kqueue (`NOTE_EXITSTATUS`) on macOS, registered at adoption; where that is unavailable the exit is still detected but its code is reported as unknown.

### Startup

The main window is created from `tauri.conf.json` (`create: false`) in `setup`, hidden, before anything else so WebKit's web process spawns while the rest of the shell initializes. `boot.rs` owns the rest:

- **Pre-paint theme.** The theme engine (`lib/stores/theme.svelte.ts`) stays the single source of truth; whenever it applies a theme it saves the resulting CSS variables, scheme and name through `theme_cache_write` to `~/.atlas/desktop/theme-cache.json`. At launch Rust reads that file before the webview exists, injects it as an initialization script (variables, `.dark`, `color-scheme`, the kit's `ca-scheme` in `localStorage`) and sets the native window appearance, so the first style computation already has your theme. Without a cache (first run, or the file was deleted) the previous defaults apply for that one launch.
- **Show gate.** `app_ready` (sent by `lib/shell/ready.svelte.ts` once the real theme, the project list and the workspace are in) shows the window; a 1 s deadline shows it anyway so a broken frontend never leaves it hidden. window-state restores size, position and maximized while it is hidden (it no longer shows the window itself).
- **Theme files** come from `themes_user_read` (plain disk reads of `~/.atlas/themes` and the legacy dir), not through hostd, so the theme never waits for the terminal host.
- **Bundle.** Heavy views (editor, loose-file editor, diff, chat thread, browser tab, PR, panel, logs, config, terminal pane) load through `components/Lazy.svelte`; Settings, What's new and the new-worktree / PR dialogs through `LazyOpen.svelte` on first open. The shell reaches CodeMirror only through the `ops` slots in `lib/symbols.ts`, installed by `lib/outline.ts` when the first editor loads; do not import `@codemirror/*`, `yaml`, `marked`, `prettier` or `echarts` from startup modules (`routes/(app)/+layout.svelte`, `lib/shell/*`, `lib/stores/*`). The language-server bookkeeping the shell does reach (`lsp/client.svelte.ts`, `lsp/history.ts`) is the CodeMirror-free half: `lsp/convert.ts` (positions over a structural `LineDoc`, URIs, WorkspaceEdit planning) and `lsp/navigation.ts`; the CodeMirror halves are `lsp/changes.ts` and `lsp/navigationCm.ts`, and the editor hands its `ChangeBuffer` to `LspDoc`. The crew chat thread (`CrewmateView`) is a `Lazy` with an empty same-size box while it loads, because replies are markdown with every language pack. `bun run bundle` (part of `bun run check` and CI) builds the app and checks what a start loads (the static closure of the entry chunks and the main route) against `apps/desktop/bundle-budget.json`: gzip JS and CSS may not exceed the budget, none of those packages may be reachable except the violations listed in `known` (each with its reason), and both only shrink (`bun run bundle -- --ratchet` lowers them). xterm.js stays out of startup, stylesheet included. `known` is empty today: keep it that way. Messages tree-shake: `m` (`lib/i18n/m.ts`) is a namespace of one export per message, so each lands in the chunk of the screens that call `m.key()` and the startup does not grow with the catalog; keep call sites static (no `m[variable]`, no passing `m` around) and `bun run bundle` prints how many compiled messages startup holds.
- **Measuring.** `ATLAS_BOOT_TRACE=/tmp/boot.txt <app binary>` appends `<ms since process start> <mark>` lines (Rust marks plus `js:` marks from `lib/boot.ts`); unset, every mark is a no-op.

## Projects and worktrees

Projects (main checkouts) are stored in `~/.atlas/desktop/projects.json`. Add them with **Add project…**, the search button (scans `~/Projetos`, `~/Projects`, `~/code`, `~/dev`), or the first-run scan.

Each project groups its **git worktrees** in the sidebar. **New worktree** (⌘N, or `+` on the project) asks for a name (blank = random), an agent and an optional first prompt; a GitHub PR or issue URL works as the name. Advanced: branch name and base ref. Atlas then:

1. creates `~/.atlas/worktrees/<repo>/<name>` on branch `<git user>/<name>` from `origin/<default>` (`git worktree add`), records the base (`branch.<b>.base`) and sets `push.autoSetupRemote`;
2. applies `worktree.shared`, **seeds** the heavy directories (`node_modules`, `target`) from the main checkout by copy-on-write clone so the install and build are incremental (`worktree.seed`; skipped, never copied, where the file system cannot clone), and runs `worktree.setup` from `atlas.yaml` in a "Setup" terminal ([configuration](https://atlas.codeatlas.com.br/docs/configuration.md#worktree));
3. gives the worktree a **port offset** (100, 200, …) so its stack runs next to the main checkout's (`ATLAS_PORT_OFFSET`).

Deleting a worktree stops its stack, runs `worktree.archive`, removes the checkout and deletes the branch unless it is unmerged (then it is kept, and a toast says so). Settings → Workspaces sets the worktree folder and branch name prefix, and **Clean up** lists worktrees with size, last commit and git state. Worktrees created outside Atlas are imported.

Sidebar: glyph = agent state (spinner working, `?` needs you, ✓ done, • idle), **bold** = unread, chips for PR and port offset. ⌘-click selects several; ⌘⇧⌫ deletes the selection or the row under the pointer. **Agents** is a feed of agent events, **Dashboard** a board of agents by state.

### Plain folders

A folder is a **project** when it has a `.git`, an `atlas.yaml` or a recognised manifest (`package.json`, `Cargo.toml`, `go.mod`, `pyproject.toml`, a compose file, `Gemfile`, `pom.xml`, `build.gradle`, `composer.json`, `deno.json`, `pubspec.yaml`, `Package.swift`, `mix.exs`, `CMakeLists.txt`). Anything else, such as `~/Downloads`, is a **plain folder**, and Atlas does not pretend it is a project: the header says **Folder** instead of the health pill, and there is no **Auto-detected** chip, no **Save as atlas.yaml**, no **Start**, no Activity or Machine buttons, no Panel, Logs or Config tab, no **New worktree**, and the Changes panel says "Not a git repository". What stays is the explorer, the editor, search, terminals and agents.

**Use as project** (in the header and its menu) gives the folder the full project UI from then on. It writes nothing to the folder: the choice is a flag on the sidebar entry (`project` in `~/.atlas/desktop/projects.json`). A linked worktree and an SSH checkout are always projects. The test is the folder's own markers, so a folder that gains a `.git` turns into a project on the next refresh.

### Open any file with Atlas

Atlas is offered wherever the OS offers "Open With", for text and source files and for folders, and it **never becomes the default**: your own editor, browser or file manager keeps that job.

| OS | Where it shows up | How it is registered | Make it the default | Remove it |
| --- | --- | --- | --- | --- |
| macOS | Open With for text, Markdown, source, script, JSON, XML, YAML and any other file (`public.data`), and for folders (`public.folder`) | `CFBundleDocumentTypes` written from `bundle.fileAssociations`, every type `LSHandlerRank` `Alternate`, with the app | Finder → Get Info → Open with → Atlas → Change All… | Drag Atlas to the Trash |
| Windows | Explorer's Open with list for about 60 text and source extensions (`.md`, `.txt`, `.json`, `.rs`, `.ts`, `.py`…), and **Open with Atlas** on a folder and on a folder's background | The installer writes per-user keys under `HKCU\Software\Classes` (`Applications\Atlas.exe\SupportedTypes`, an `OpenWithProgids` value per extension, `Directory\shell\AtlasDesktop`, `Directory\Background\shell\AtlasDesktop`); no extension key and no default value is written | Settings → Apps → Default apps, or Open with → Choose another app → Always | Uninstalling Atlas removes every key and value |
| Linux | The file manager's Open With for `text/*`, Markdown, JSON, YAML, XML, shell, source types and `inode/directory` | `MimeType=` and `Exec=… %F` in the `.desktop` file of the deb, rpm, AppImage and Arch package (one template, `packaging/linux/atlas.desktop`) | `xdg-mime default atlas.desktop text/markdown` (or the file manager's Properties → Open With → Set as default) | Remove the package |

`atlas <path>` does the same from a terminal. Every route ends in the same queue: macOS hands the app a `file://` URL per item (`application:openURLs`), Windows and Linux pass the paths as arguments. A second "Open With" while Atlas runs is forwarded by the single-instance guard to the running window (a relative path is made absolute against the second launch's folder), so it opens there instead of in a second process; macOS keeps one instance per app on its own. Several selected files open one after another.

### Opening a single file

A text file (not an image, PDF or media file) with **no project above it** (no `.git`, `atlas.yaml` or manifest in its folder or any parent) and not inside a folder you already added opens in the **light editor**, in the main area, and **registers nothing**: no sidebar project, no worktree, no services, no git status, no language server, no hostd. It is the project editor's own CodeMirror session (autosave after 0.5 s, ⌘S to save now, `.editorconfig`, the large-file tiers) with a line and column footer. The file is read and written by the app process itself (`loose_stat`, `loose_read`, `loose_write` in `loose_fs.rs`: one IPC call each, the write goes to a temp file and is renamed over the original, keeping its permissions), so opening does not wait for hostd, which a cold start may still be spawning. The only thing the page asks for first is `path_locate` (is there a project above it), which reads the folder markers and the project list and writes nothing. Nothing watches the file, so a change made by another program shows up when you save (the editor compares the disk with what it last read and asks, it never overwrites). Files you open this way are one collapsible **Files** group under Dashboard in the sidebar, newest first, the latest five shown and **Show all (N)** for the rest; each row closes with its **x** or a middle click, and closing a file in the editor's own strip removes its row. Nothing is saved: closing Atlas forgets them all.

A Markdown file also gets a bar over the editor: **Bold**, **Italic**, **Heading** (cycles plain, H1, H2, H3), **Bulleted list**, **Numbered list**, **Link**, and **Preview** (the rendered file, **Edit source** to come back). Each button toggles, works on every selection range and is one undo step. **Open folder** adds the file's folder to the sidebar (a plain folder, so still no services) and continues there in the full editor; **Open as project** also promotes it.

A file inside a project, or inside a folder you added, opens in that project as before (`atlas src/main.rs` opens the project, then the file). Images, PDFs and media have no light viewer, so a loose one opens inside its folder (plain-folder mode). Quick Open (⌘P) in a plain folder walks the folder (`.gitignore` honoured; `node_modules`, `target`, `build`, `dist`, caches and dot folders other than `.github`, `.vscode`, `.atlas`, `.husky` skipped; at most 20,000 files and 2 seconds), off the UI thread, and caches the list until the file watcher reports a change under the folder. Time to first paint of a loose file is recorded as the `loose:first-paint` performance measure, from the moment the editor mounts (`atlas desktop debug eval 'return performance.getEntriesByName("loose:first-paint").map(e => e.duration)'` in an agent instance).

## Tabs and panes

Each worktree has its own tab groups and splits (⌘\\ right, ⌘⇧\\ down; drag a tab to a pane edge to split). Tab kinds: terminal, agent, editor, changes (diff), browser, pull request, panel, logs, config. Layout is saved in `~/.atlas/desktop/workspace.json`.

| Tab                   | What it does                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Terminal              | xterm.js on a hostd PTY. ⌘F search; links open in the Atlas browser (⌘-click: system browser); dropping a file pastes its path. Local terminals are drawn natively on the GPU by default ([GPU terminal](https://atlas.codeatlas.com.br/docs/terminal.md)); Settings → Terminal → **Fast terminal (GPU)** switches back to xterm.js. SSH-host terminals always use xterm.js.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| Agent                 | an agent CLI in a terminal (omp, Claude Code, Codex). Its state comes from hooks (see below). **New omp chat** opens omp's native chat instead (`omp --mode rpc-ui`): streaming transcript, tool cards, `ask`/confirm cards, `/` commands, `@` files, image attachments, thinking level, Stop (Esc), Compact.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| Editor / viewers      | CodeMirror for text (autosave 500 ms after you stop typing; ⌥Z wrap). Other formats open in a viewer by extension: **images** (png, jpg, gif, webp, avif, bmp, ico, svg) on a checkerboard, fit to view, ⌘+ / ⌘− / ⌘0 or pinch / ⌘-wheel to zoom, drag to pan, double-click toggles 100%, pixel-crisp past 200%, info bar with size and format, copy image; **SVG** also has an _Edit source_ toggle; **PDF** rendered with pdf.js: continuous pages, pinch and ⌘+/⌘− zoom, fit width/page, page thumbnails and outline, ⌘F search; **video / audio** (mp4, mov, webm, mp3, wav, ogg, m4a) in native players; **Markdown** preview ⌘⇧M (syntax-colored code, tables, task lists, images relative to the file). Media loads in 8 MB chunks up to 200 MB; text opens up to 2 MB. Larger text and binary files show their size, **Open externally** / **Reveal in Finder**, and a hex dump of the first 4 KB. |
| Changes               | diff vs the branch base, unstaged or staged; stage/unstage per file or hunk; comment a line and **Send to agent**. Source control writes the commit message for you with **Generate** (⌥⌘G, `git::GenerateCommitMessage`) from the staged diff using the agent picked in Settings → Git; secrets are never sent. The **branch** in the title bar (or ⌥⌘B, `git::Branch`) opens the branch switcher: fuzzy over local and remote branches, create from HEAD, jump to the worktree that owns a branch, **Stash and switch** on a dirty tree. In a folder that is not a git repository, Changes and Source control say so and offer **Initialize repository** (`git init`) instead of stage, commit and diff actions. A failed git command reaches you as one sentence (_This repository has no remote_, _This branch has not been pushed yet_…) with git's own output behind **Details**, never git's usage text (`src/lib/gitErrors.ts`). |
| Browser               | an embedded webview over the pane. **Design Mode** picks an element and sends its selector, HTML, computed styles and a screenshot to an agent (secrets in URLs and attributes are redacted).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| Pull request          | `gh pr view`: timeline, comments, checks (failed log, **Fix broken checks** sends it to the agent), merge, ready. The tab first says where the worktree is on its way to a pull request (`src/lib/repoState.ts`, derived from `git remote -v`, `rev-parse HEAD`, the shared git status feed, `gh auth status` and `gh pr view`; nothing polls beyond the existing 60 s refresh): not a repository (**Initialize repository**), no commits yet, no remote (**Add a remote**), a remote that is not on GitHub, GitHub CLI not installed (**Install GitHub CLI**) or not signed in (**Sign in to GitHub**, `gh auth login` in a terminal), on the default branch (**Create branch**), branch not pushed (**Push branch**, `git push --set-upstream`), and only then **Create pull request**. With a PR it shows the title, state, review state, checks summary and a link to GitHub. |
| Panel / Logs / Config | the stack views: the [project panel](#project-panel) (health, live charts, service cards, setup), [logs](#logs), the `atlas.yaml` editor with live validation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

### Project panel

Every worktree opens on its **Panel** (the old Services tab; the tab kind is still `services`, so saved layouts keep working). The window header carries the project's health pill (**All healthy**, **N starting**, **N failed**, **Stopped**) and, at the right, in this order: notifications bell (an empty inbox says what lands there, agents waiting for you, finished tasks and updates, and links to Settings → Notifications & sounds), the dock toggles, **Activity**, **Actions ▾**, the `…` menu and **Start** / **Stop** (with the profile menu when the project has profiles). The Panel itself shows the project name in the space's accent color, uptime, mode and version, branch, the service ports and the root path.

- **Setup strip** (top of the Panel, only when the project has a dependency step: `pre_command` or an auto-detected installer; hidden otherwise): `Setup  bun install ⓘ · ran 1h ago · ok` with **Run again** and **View output**. While it runs the strip turns amber and tails the live output; if it fails it turns red, shows the reason and a **Retry** button with the last lines of output (**Full output** shows all 200). The ⓘ tooltip says when it runs: `always` = before every start, `lockfile` = when the lockfile changes (or `node_modules` is missing).
- **Actions** (header **Actions** menu): every `actions:` entry of `atlas.yaml`, grouped like the TUI help (ungrouped first), with its bare key. Destructive ones (those with `confirm:`) are marked with a warning icon and ask first; disabled ones say why in their tooltip (stack stopped, already running, interactive session). While an action runs the button shows a spinner and its label, with progress in the operation strip; when it finishes a small chip (or a toast, for a project you are not looking at) reports the result. The same actions stay in the command palette (⌘⇧P) and on their bare keys.
- **Action output** (click the running indicator on the Actions button, **View output** at the bottom of the Actions menu or on the result chip, or ⌘⇧P → _Show action output_, unbound by default): a drawer on the right that keeps the output of the last 10 action runs of the project (up to 5000 lines each). The list shows newest first with a status dot (running / finished / failed), start time and duration; the selected run shows its output with ANSI colors, follows the end while it runs (scroll up to stop following), and offers **Copy** (plain text) and **Run again**. `path:line[:col]` references open in the editor and URLs in the preview browser (⇧ for the system browser). Opening the app mid-run shows what the runner kept: the last 500 lines of each recent run, with a note when earlier lines were dropped (the full output is always in `.logs/action-<slug>.log`); a runner older than this feature simply has no replay.
- **Activity** (header button with an unread count, or ⌘⇧P → _Show activity_): a drawer on the right with the stack's events grouped by time (_Just now_, _5 min ago_, _Today 19:00_…). Bursts collapse into one row (`server restarted 3×` instead of a stopped / starting / running row each), dots are colored by state, and **All / Errors / Restarts / Actions** filter the list. Click a row to open that service's logs at that moment.
- **Machine** (header gauge button, or ⌘⇧P → _Show machine load and agents_): a drawer on the right answering "why is this machine slow, and what is each agent running?". **Load and memory** are two gauges (5-minute load over the cores, memory in use) with a line where the heavy-job gates hold a job back (`0.75 × cores` load, 20% free memory by default); a gauge turns red past its line and the heading names the gate that is holding. **Heavy jobs** is the machine-wide queue (`atlas run --heavy`): holders, waiters and their ETA. **Agents and terminals** lists every running terminal, agents first, with its state (working, waiting, blocked, done), what the agent was asked, and the CPU and memory of its whole process tree. **Services by memory** shows the eight heaviest services of every running project with the memory trend and budget note (leak suspected, over `memory_warn`, rising +N MB/min). **Heavy run history** lists the last runs of each label with average, max and last duration, and a `N% slower` / `N% faster` note when the last run left a 10% band around the earlier average. **Task cache** shows the cache of `atlas run --cache` (see [cli.md](https://atlas.codeatlas.com.br/docs/cli.md#task-cache-atlas-run---cache-atlas-cache)): the hit rate (hits over hits plus misses, `–` before the first run), the time saved in total and over the last 7 days (the original duration of every run a hit skipped), the size against the `cache.max_bytes` cap (the bar turns red from 90%, where eviction of the least recently used entries starts), the five projects that saved the most time, and **Clear cache**, which asks first and then runs the same code as `atlas cache clear` (`cache_clear`). **Orphans and disk** shows the session-hygiene report (orphaned processes, disk per project, what a fix frees) and reads "Not available in this version" where that command is absent. Everything comes from one command, `machine_report`, refreshed every 3 s only while the drawer is open and the window visible.

- **KPI row**: services running of total, restarts in the last hour, error lines in the last 5 minutes, memory and CPU of the whole stack. Tiles turn amber or red when something needs a look.
- **Service cards**, failed and starting first. Each card has the state ring (a soft halo pulses while it runs), the port (click to open or copy the URL), CPU and memory sparklines of the last ~2 minutes, the last log line, a restart badge, `depends_on` chips and, on hover or focus, **Restart**, **Stop** / **Start**, **Logs** and **Terminal** (opened in the service's `dir`). A failed card shows its reason and **View logs**, which opens Logs filtered to that service. Under the memory sparkline a [memory](https://atlas.codeatlas.com.br/docs/configuration.md#memory) line appears only when there is something to say, in amber (red over `max_memory`): a suspected leak (`leak suspected: +660 MB over 11 reloads`), the budget overrun (`Over memory_warn`) or a rising trend (`Rising +42 MB/min`). A service over its `memory_warn` is `degraded`, its banner says `using 2.1 GB, over memory_warn 1.5 GB`, and a suspected leak is added under the banner.
- **Resources**: stacked-area charts for memory and CPU across the heaviest services, and an error-rate bar chart over the last 5 minutes. **Health over time** is a per-service timeline of running / starting / failed bands for the last 10 minutes; click a lane for its logs.
- **Keyboard**: arrows, Home and End move across cards, Enter opens the service's logs, **R** restarts a running service after a confirmation. Cards scale from one column in narrow panes to as many as fit, and 20+ services scroll.
- **Empty states**: with the stack stopped, a card says what **Start** will launch; a project without services links to `atlas.yaml`.

History is sampled in the app (one sample per service every 3 s, 10 minutes kept; log throughput and errors come from the logs ring by reading only the lines appended since the last tick), so charts fill from the moment the app sees the stack and cost a handful of numbers per service. Charts follow the theme through the kit's chart tokens and refresh at most once a second.

### Logs

The Logs tab keeps the last 50k lines per project and stays at frame rate under bursts: the app side batches service output (one message per ~16 ms, at most 2000 lines, lines over 16 KiB are cut), the view is filtered incrementally (only new lines are tested; a filter change re-scans in idle slices, so typing never blocks) and only the visible rows are parsed and rendered. Service chips show an error count; `restarted` rules separate runs.

- **Find** (⌘F, or `/` with the log focused): literal or regex (`.*`), match case (`Aa`), `n/N` counter, Enter / ⇧Enter (or ⌘G / ⌘⇧G) next / previous with wrap; every match is highlighted, the current one stronger. **Filter** toggles hiding lines that do not match. Esc clears.
- **Time range** (clock chip in the toolbar, next to Find): **Last 1 / 5 / 15 / 60 min**, **Since restart** (of the selected service; of the whole stack on All, using the `restarted` rules), **Since stack start** (the oldest line held) or a **custom** clock range of today: `14:05` (from) or `14:05–14:20` (`-`, `–`, `—` or `..` separate; both ends inclusive; an invalid time is explained under the field). An active range shows its label on the chip; ✕ clears it. It composes with the service chips, the level filter and Find/Filter, and the line counts, the error/warning totals and the **N new lines** pill all follow it. `Last N` windows slide: once a second the lines that aged out are dropped from the front of the view without rescanning the ring, so an idle window empties by itself. Changing the range re-filters once, in idle slices like any other filter change. Opening logs at a moment from the Activity drawer clears a range that would hide that moment (with a toast).
- **Levels**: `all levels / warn+ / error+`; buttons and `e` / `w` (⇧ or `E` / `W` for previous) jump to the next error / warning.
- **Links**: ⌘-click a `http(s)` URL or an OSC 8 hyperlink to open it in the embedded browser (⇧⌘-click: system browser); ⌘-click `path:line[:col]` to open the file at that line in an editor tab. Relative paths resolve against the service's `dir`, then the worktree; paths outside it are refused.
- **Colors** follow the active theme's terminal palette (16/256/truecolor, bold, dim, italic, underline styles and color, strike, inverse).
- Keys with the log focused: `j`/`k`/arrows, Space/PageUp/PageDown, `g`/`G` top/bottom, `f` follow, `t` timestamps. Wrap and timestamps have toolbar toggles; scrolling up pauses follow and shows a **N new lines ↓** pill.
- **Copy** copies the filtered view (selection copy gives plain text only); **Copy for AI** copies the last 300 filtered lines with a header describing the filter.

Docks: three toggle buttons in the worktree header (left, bottom, right) show which docks are open and their shortcut on hover. Drag a dock's edge to resize it (arrow keys nudge, double-click resets); sizes are remembered. Left dock: Explorer (⌘⇧E, git-colored, highlights the open file, live; arrows/←/→/Home/End/Enter navigate, F2 or _Rename_ and _New file_ edit in place, the locate button reveals the active file), Search (⌘⇧F: project-wide, below) or Source control (⌃⇧G: stage, commit, generate message with AI, push/pull, conflicts, create PR); it sits on the side chosen by `project_panel.dock`. Right dock (⌘R): agent session history with search and Resume, listening ports. Bottom dock (⌘J): a terminal tab group.

**Search in project (⌘⇧F).** Type to search every file in the worktree (debounced; a newer query cancels the older one). Toggles: match case, whole word, regular expression; _Files to include or skip_ takes globs (`src/**, *.ts`; a bare folder name matches everything under it). Results are grouped by file with the match highlighted; ↑ ↓ move, ← → fold a file, Enter opens the file at the line and column. It runs `rg` through hostd (so it works on SSH hosts too, honoring `.gitignore`) and falls back to `git grep` when `rg` is not installed. At most 2000 matches in 200 files are shown; the status line says when results were cut.

A worktree with no open tabs shows a welcome state with **New terminal**, **Start an agent** and **Open a file**. Destructive questions and name prompts (delete, discard, force push, rename, new file, closing a busy terminal) use in-app dialogs, not browser ones.

## Agents

Agents run in worktree terminals with `ATLAS_HOOK_ENDPOINT` set. omp reports through the `atlas-status` extension that `atlas setup omp --apply` installs; Claude Code and Codex through `atlas hook` (`atlas setup claude-code|codex --apply`). Events go to a loopback server in `atlas hostd` (`~/.atlas/desktop/hook-endpoint.env`, new token per daemon run), which keeps agent state while the window is closed and pushes it to the app and to [Atlas Mobile](https://atlas.codeatlas.com.br/docs/mobile.md). When a turn ends or the agent needs you while you look elsewhere, Atlas marks the worktree unread, adds it to the bell inbox, shows a notification and updates the Dock badge. After an app restart, omp's state is recovered from its terminal title. Settings → Agents: default agent, permissions (manual / auto-approve), extra args, custom agents, quick commands. Settings → Notifications & sounds: notifications and sounds. Settings → Integrations: shell, where links open, agent hooks, SSH hosts, Mobile.

## SSH hosts

Settings → Integrations → SSH hosts adds a host from `~/.ssh/config`. Atlas uploads `atlas` if `~/.atlas/remote/atlas-<arch>-<os>` exists and the host lacks it, starts `atlas hostd` there and keeps an `ssh` tunnel (`-L` to its socket). Add a remote project by path; its worktrees, terminals, editor, diff and agents then run on the host. The right panel's **Ports** tab lists the host's listening ports; opening one (a click, or the arrow for the system browser) first sets up an `ssh -L` forward to a local port, and there is no separate forward button. Not yet for remote checkouts: the Services/Logs/Config views and Design Mode.

## Keyboard

Defaults follow macOS, Zed and browser conventions. Every shortcut is a named command: ⌘⇧P lists them with their keys (the last five you ran come first), and tooltips on buttons show the current key. Change them in **Settings → Keyboard shortcuts**: search a command, click its key, press the new one (⎋ cancels; ⌘, ⌃ or ⌥ is required). A key already used moves to the command you pick. ✕ unbinds, **Reset all** restores the defaults. The same thing by hand in `~/.atlas/desktop/settings.json`, Zed syntax, `null` unbinds:

```json
{ "keymap": { "cmd-j": null, "cmd-shift-j": "workspace::ToggleBottomDock" } }
```

**On Windows and Linux** the table below reads with Ctrl for ⌘ (the Windows/Super key belongs to the system) and Alt for ⌥; labels in the app say so (`Ctrl+Shift+P`). The keymap file keeps the `cmd-…` spelling on every platform. Where a chord differs by OS, [Differences by OS](#differences-by-os) lists it. In a focused terminal a plain Ctrl+letter goes to the shell (^C, ^R, ^W, ^B …), and so do Ctrl+[ (Esc in vim) and Alt+←/→ (word motion); Ctrl+Shift chords, Ctrl with a digit, Tab, PgUp/PgDn or punctuation, and Ctrl+Q still reach the app. Ctrl+C copies when text is selected and Ctrl+V pastes. A Ctrl+Alt chord that types a character (AltGr on Windows: `ś`, `²`, `@`) stays text. There is no native menu bar there (it is macOS only, and no native accelerator is bound off macOS, so a key can never fire twice): the app window handles every key, and the palette (⌘⇧P reads `Ctrl+Shift+P`), tooltips and the keyboard-shortcuts sheet show the same labels from the one keymap.

| Keys                      | Action                                                                                                                       |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| ⌘⇧P                       | command palette                                                                                                              |
| ⌘K                        | jump palette: recent terminals and worktrees, commands, "Create worktree <query>"; Shift-Enter opens beside. In a focused terminal ⌘K clears the screen and scrollback instead (Ghostty's `clear_screen`); the palette is still on ⌘⇧P and the Go menu |
| ⌘P / ⌘⇧O                  | go to file / go to symbol in the open editor                                                                                 |
| ⌘⇧F                       | search in project                                                                                                            |
| ⌘B / ⌘J / ⌥⌘Y             | left dock / bottom dock (terminals) / all docks (Windows/Linux: Ctrl+B is the sidebar, the left dock is Alt+Shift+B)         |
| ⌘⇧E / ⌃⇧G / ⌃\` / ⌘?      | project panel / git panel / terminal panel (focus) / agents                                                                  |
| ⇧Esc                      | zoom the focused pane (palette: centered layout)                                                                             |
| ⌘+ / ⌘− / ⌘0              | zoom the whole layout in / out / back to 100% (Ctrl instead of ⌘ outside macOS; steps from 50% to 300%, saved; View menu, Settings → Appearance → Zoom). In a focused GPU terminal ⌘+ ⌘− ⌘0 change that terminal's font size instead |
| ⌃⌘1…⌃⌘6                   | recent worktrees                                                                                                             |
| ⌘S / ⌥⌘S                  | save the focused editor (atlas.yaml: review the diff, then save) / save every open editor; files also autosave after 0.5 s    |
| ⌃⌘S                       | hide / pin the sidebar (hidden: move the pointer to the left edge to peek)                                                   |
| ⌘R                        | right sidebar: pinned beside the panes, or hidden and revealed from the right edge (also the button in the header)           |
| ⌘[ / ⌘]                   | back / forward through the worktrees and tabs you visited                                                                    |
| ⌥⌘← / ⌥⌘→ , ⌃1…⌃9         | previous / next space, space by position (a space is a repo; each has its own color)                                         |
| ⌘/                        | shortcuts cheat sheet                                                                                                        |
| ⌘N                        | new worktree                                                                                                                 |
| ⌘T / ⌘⇧A / ⌃⇧\`           | new terminal / new agent session / new terminal (VS Code's key, with a terminal focused too)                                 |
| ⌘W / ⌥⌘W / ⇧⌘W            | close tab (asks when a process is running) / close other tabs / close tab. "Close all tabs in the pane" has no key: palette, tab menu and menu bar |
| ⌘⇧T                       | reopen the last closed tab (editors, diffs, browser, logs, config and PRs return in place; terminals restart)                |
| ⌘1…⌘8 / ⌘9                | tab 1 to 8 by position in the focused pane / last tab                                                                        |
| ⌘⇧] / ⌘⇧[                 | next / previous tab (Windows/Linux also Ctrl+PgDn / Ctrl+PgUp)                                                               |
| ⌃Tab / ⌃⇧Tab              | recent tab / older tab: a switcher lists tabs by last use while ⌃ is held, releasing ⌃ opens the highlighted one (⎋ cancels) |
| ⌘\\ / ⌘⇧\\                | split right / down                                                                                                           |
| ⌘,                        | settings                                                                                                                     |
| ⌘⇧D                       | changes (in a focused terminal: split down, see [terminal keys](https://atlas.codeatlas.com.br/docs/terminal.md#keyboard))                                       |
| ⌘L / ⌘E / ⌘⇧R             | logs / config / restart focused service                                                                                      |
| `open_key` / action `key` | same bare keys as the TUI                                                                                                    |

**The Panel tab is pinned.** It is always the first tab of the first pane, shown as a compact icon with no close button. ⌘W on it only says so and moves to the next tab; middle-click, close other tabs and close all tabs skip it; it cannot be dragged out, split or moved to another pane or the bottom dock; it is recreated when a worktree opens without one.

**App menu.** Atlas has a real macOS menu (Atlas, File, Edit, View, Go, Window, Help). Edit carries Undo/Redo/Cut/Copy/Paste/Select All. Cut, Copy and Paste are the standard macOS items. Undo (⌘Z), Redo (⇧⌘Z) and Select All (⌘A) are Atlas items that act on whatever has focus: the editor's own history and selection in an editor, `execCommand` in a text field, the terminal's selection (⌘A) in a GPU terminal (undo and redo do nothing there and never reach the shell). The standard AppKit items would send `undo:` to the web view, which knows nothing about CodeMirror's history. These three keys are fixed and cannot be remapped. On macOS the menu owns the keys of the commands it lists (File, Go, View and Settings), shows your current binding, follows remaps in Settings → Keyboard shortcuts, and works with focus in a terminal, an editor or the embedded browser. Keys that are not menu items (⌃Tab, ⇧Esc, ⌃1…⌃9, ⌘1…⌘9, ⌘[ ⌘]) are handled by the app window. With focus inside an embedded browser page (a separate native view that never delivers keys to the app window), every ⌘, ⌃ or ⌥ chord bound in your keymap still runs its command: ⌘1…⌘9, ⌃Tab, ⇧⌘[ ⇧⌘], ⌃⌘1…⌃⌘6 and your remaps. The app pushes the bound strokes to the native side, which takes only those from the page; typing, unbound keys and the page's own ⌘C ⌘V ⌘X ⌘Z ⌘A stay with the page. On Windows the same holds through WebView2's accelerator-key event (Ctrl+1…9, Ctrl+Tab, Ctrl+PgUp/PgDn, Ctrl+Shift+T/W, Alt+1…9 …), and the page keeps Ctrl+F, F5, Ctrl+C and Ctrl+V; on Linux (WebKitGTK) the embedded page still takes every key while it has focus. There is no _Close Window_ item: ⌘W closes a tab, never the window.

### Differences by OS

| Action | macOS | Windows / Linux | Why |
| ------ | ----- | --------------- | --- |
| New terminal | ⌘T, ⌃⇧\` | Ctrl+T (not in a terminal), **Ctrl+Shift+T** (everywhere, a focused terminal included), Ctrl+Shift+\` | Windows Terminal / GNOME Terminal use Ctrl+Shift+T; Chrome and VS Code use Ctrl+T and Ctrl+Shift+\` |
| Close tab | ⌘W, ⇧⌘W | Ctrl+W (not in a terminal: it is the shell's delete-word), **Ctrl+Shift+W** (everywhere) | Ctrl+Shift+W no longer closes every tab; "Close all tabs in the pane" is palette / menu only |
| Reopen closed tab | ⇧⌘T | **Alt+Shift+T** | Ctrl+Shift+T is new terminal there; ⌘ never reaches a shell, so macOS keeps ⇧⌘T |
| Next / previous tab | ⇧⌘] / ⇧⌘[ | Ctrl+Shift+] / [, **Ctrl+PgDn / Ctrl+PgUp** | Chrome, VS Code and GNOME Terminal; ⌘PgDn is the GPU terminal's scroll on macOS |
| Toggle sidebar | ⌃⌘S | **Ctrl+B** (VS Code) | the left dock (⌘B on macOS) moved to **Alt+Shift+B** |
| Quit | ⌘Q (menu) | **Ctrl+Q**, from a terminal too; same quit as the tray's Quit | Alt+F4 still hides the window to the tray |
| Full screen | ⌃⌘F (View menu) | **F11** | |
| Go back / forward | ⌘[ / ⌘] | Ctrl+[ / Ctrl+] (a focused terminal keeps Ctrl+[ for the shell) | |
| Jump history | ⌃- / ⌃⇧- | Alt+← / Alt+→ (a focused terminal keeps them for word motion) | Ctrl+- is zoom out |
| Spaces / recent worktrees | ⌃1…⌃9 / ⌃⌘1…⌃⌘6 | Alt+1…9 / Alt+Shift+1…6 | Ctrl+digit is tab by position |

On Windows the webview's own browser keys are off for the app window and the tray popover (F5 and Ctrl+R never reload Atlas, Ctrl+F, Ctrl+P and F12 open no Edge UI); the page still receives every key. The embedded browser's tabs keep theirs.

The palettes highlight the characters your query matched and show their keys (Enter select, ⇧Enter open beside, Esc close).

Spaces and sidebars: every repo is a space with its own accent color (derived from its id), shown with its icon in a strip at the bottom of the sidebar and tinting the active space. Switching animates the content in the direction you moved; a two-finger horizontal swipe over the sidebar switches too. ⌃⌘S hides the sidebar so the content fills the window; moving the pointer to the left edge (about 8 px, after a short pause) slides it in as a floating panel, and it slides out when the pointer leaves (⎋ closes it). The right sidebar works the same from the right edge. The header breadcrumb `Space › worktree › tab` is clickable, and ⌘[ / ⌘] walk your visit history.

Settings has thirteen sections in three groups (twelve off macOS, where **Capture** is hidden). **Atlas**: **General** (updates, update channel, display language), **Appearance**, **Notifications & sounds**, **Capture**, **Keyboard shortcuts** and **Help & onboarding**. **Work**: **Workspaces**, **Editor**, **Terminal**, **Git** and **Agents**. **Connect**: **Integrations** (tabs **Shell & links**, **Agent hooks**, **SSH hosts** and **Mobile**) and **Atlas Crew**. The search box at the top finds any setting by what it does ("font", "clipboard", "branch") and jumps to it; the full map is in [Desktop settings](https://atlas.codeatlas.com.br/docs/desktop-settings.md#where-things-are-in-settings). **Appearance** is one page: a picker of theme cards with Atlas Dark/Light (Tokyo Night based) as the default, next to Dracula/Alucard and One Dark/Light, a separate **Terminal theme**, import from Ghostty, iTerm, VS Code, Alacritty and Base16, from a zip or folder of themes (or drop Zed theme JSON into `~/.atlas/themes/`), export and **Accent color**; then zoom, interface font and size, the file panel (side, icons, indent) and the active-pane border and dimming. **Editor** has two tabs: **Editor** (code font, size, line spacing, editing and display options, with a live sample) and **Languages** (language servers). **Terminal** has **Fast terminal (GPU)** (macOS), the terminal host restart, font, size, ligatures, minimum contrast, cursor shape and blinking, padding, scrollback and whether programs may copy to your clipboard (_Ask each time_ / _Always allow_ / _Never_). Appearance changes apply immediately; terminal changes apply to terminals opened afterwards. The values are saved in `~/.atlas/desktop/settings.json` (`buffer_font_*`, `ui_font_*`, `terminal.*`, `project_panel.*`, `active_pane_modifiers`); the **Advanced: edit settings.json** link in Settings → Editor opens it in an editor tab.

## Automation

With the app open, `atlas wt`, `atlas term`, `atlas browser` and `atlas file` drive it through `~/.atlas/desktop.sock` ([CLI](https://atlas.codeatlas.com.br/docs/cli.md#atlas-wt)); the `atlas-desktop` skill teaches agents to use them.

## Tray icon

Clicking the menu-bar icon (macOS) or the notification-area icon (Windows) opens a small popover next to it (a borderless, always-on-top window with rounded corners), the way a system utility would. It is painted on the active theme's ground and surface ladder (Atlas Dark's blue, Atlas Light's paper, any imported theme), never on the wallpaper's brightness. It closes on ⎋, when you click elsewhere, or when you click the icon again. Right-click the icon for a menu: **Open Atlas**, **Show Agent Dock** / **Hide Agent Dock**, a **Capture** submenu (each capture action with its key) and **Quit Atlas** (**Exit** on Windows).

**On Linux** the tray is a StatusNotifier/AppIndicator item (`libayatana-appindicator`), and desktops deliver **no click events** for it: only its menu works. So there is no popover there; the menu opens on any click and has **Show or Hide Atlas**, **Show Agent Dock** / **Hide Agent Dock** and **Quit**. Quit exits the app (closing the window only hides it, as everywhere). The icon is white, because hosts draw the PNG as is and panels are dark by default (the black glyph is the macOS template, which the system tints). Needs a tray host: KDE Plasma, XFCE, Cinnamon, MATE and most panels have one; **stock GNOME does not** and needs the [AppIndicator extension](https://extensions.gnome.org/extension/615/appindicator-support/). Atlas asks the session bus (`org.kde.StatusNotifierWatcher`) when you close the window: with a host it hides to the tray, without one it **quits** instead of hiding an app you could not reach again. On Wayland the icon is created only once a host is on the bus (at start or later: a GNOME extension enabled mid-session, a panel that starts late); creating it earlier made `libayatana-appindicator` fall back to a GTK status icon that Wayland does not have, and GTK printed `Gtk-CRITICAL gtk_widget_get_scale_factor` on every start (#426). X11 keeps that fallback (the legacy XEmbed tray).

What it shows, top to bottom:

- **Header**: the Atlas mark (drawn from `assets/logo.svg`, like every other copy of the brand), one status line and four quick actions. The line lists, most urgent first, _N need you_, _N failed_ (failed services across every project), _N working_ (agents) and _N up_ (running projects), or _All quiet_; the least urgent parts are dropped when it would not fit. Its dot is red when a service failed, amber when an agent needs you and green otherwise, and pulses slowly while something is unhealthy (not with reduced motion). The quick actions are **New agent**, **Agent dock** (shows or hides the dock; it appears once the app has answered), **Settings** and **Open Atlas**.
- **Needs you**: agents that are waiting or blocked. A row names where it runs (project and worktree) and the agent, says what it last said or asked, and ends in **Approval** or **Reply**; a click jumps to its tab.
- **Recommendation** (only when it adds something the cards do not say): _Atlas X is available_ → **Update**, else a terminal host that needs a restart → **Review** (opens the restart dialog). A failed service is already named, with its actions, on its card.
- **Working**: agents that are working, with what each is doing; a click jumps to its tab.
- **Running**: one card per running project, failed first, then starting, then healthy (ties by name): the project's icon, accent color and branch, one segment per service (red for a failed one) and a line that **names what is wrong** (_redis, api +2 failed_, _1 starting_, _All 10 services up_). A click opens the project. **Stop** appears on hover or keyboard focus; a failed stack also offers **Restart failed services** (restarts exactly the failed ones, through the same `service_cmd` as the Panel, not the whole stack) and **Logs** (opens Logs on the first failed one).
- **Projects**: every project grouped by repo, with its worktrees nested and named by branch, running first; **Start** (or **Stop**) appears on hover or keyboard focus. **Stopped (n)** is collapsed until you open it or search. The search field (_Find a project or branch_) appears from 8 projects.
- **Footer** (only with a terminal host version or on a dev build): a **Dev** chip on a dev build and `host <version> · N terminals`, marked _outdated_ when the host needs a restart; a click opens the restart dialog.

Anything that opens something brings the main window forward and runs there, through the same stores as a click in the app. When the window is not focused, a service failure, a runner alert or an agent that needs you still shows a native notification.

How it works: the popover is a second webview (`/tray`, label `tray`) created once, right after the main window first shows, and only hidden afterwards (never on Linux, where nothing can open it: the launch would pay a page load and a web process for a window nobody sees). It has no stores of its own, so runners are subscribed once, by the main window. The main window builds a snapshot of projects, agents, terminals and updates (at most once a second, and the popover only receives it while visible), `tray.rs` caches it so the popover paints at once when shown, and clicks come back as `tray://action` to the main window. Start and Stop call the same `stack_start` / `stack_stop` commands as the sidebar. The popover is born in the app's cached theme (`boot::window_boot`, the same recipe as the main window, so it never starts on the kit's defaults) and follows the theme chosen in the app. It sizes itself to its content (up to 560 px and never taller than the room the screen leaves below the icon, `tray::room`); beyond that the list scrolls inside it while the header and footer stay put. Layout, top to bottom: one status line (agents needing you, failed services, agents working, stacks running) with quick actions (new agent, agent dock on/off, settings, open Atlas); **Needs you** (agents waiting or blocked, longest-blocked first; a click jumps to the tab); **Working** agents with their last message; **Running** stacks with a segment per service and Stop / Restart failed / Logs on hover; **Projects** grouped by repo with worktrees nested and named by branch (two on the same branch add their folder), running first, then recents; **Stopped (n)** collapsed (a search opens it; the field appears from 8 projects). The terminal host version is a small footer. Keyboard: ↑ ↓ Home End move through the buttons and rows, Enter activates, ⎋ clears the search and then closes. It is positioned from the icon's rectangle and kept inside the screen it is on, including a second monitor.

## Agent dock

A small pill that floats above every other app and Space (and over fullscreen apps) and sends text to the agents Atlas already runs, with the Atlas window closed. On macOS it is on while Atlas runs; on Windows and Linux it is off until you turn it on (Ctrl+Alt+D, the dock item in the tray menu, or Settings → Agents → Agent dock). Settings → Agents → Agent dock also rebinds its hotkey.

- **Pill**: the agent it would message (`api · omp`), a dot that is green while any agent works, the hotkey, and a badge with the number of agents that need you. Drag it anywhere; it comes back to the bottom centre of the display under the cursor if the monitor it was on is gone.
- **Composer** (the hotkey, default ⌃⌥Space, or a click on the pill; the hotkey again or ⎋ closes it): type, Enter (or ⌘/Ctrl+Enter) sends, Shift+Enter is a newline. Who gets it, first rule that applies: the **To** menu; an **@mention** (`@api`, `@feat-login`, `@claude`: matches the tab's project, worktree or agent kind, and is removed from the text); the agent you last sent to from the dock; the most recently active agent. When an @mention matches several tabs the dock **asks** (number keys pick); it never guesses between them. With no agent running it says so and offers **Open Atlas**; it does not start one.
- **Reply**: after a send the pill grows into a preview of the agent's last message (the last six lines, from its status hooks; it updates as the agent reports) with **Open in Atlas**, and goes back to the pill eight seconds after the agent is done.
- **Needs you**: an agent that is waiting or blocked raises a card with what it said and **Open in Atlas**, even if you never opened the dock. If you are typing, the card waits until the composer closes. Approving or denying from the card is not there yet: the keystroke for each agent's permission prompt has to be verified per agent and version first.

The dock never takes focus from the app you are in: on macOS its window is a non-activating `NSPanel` (`dock_mac.rs`: the window's class becomes a runtime `NSPanel` subclass, style `NonactivatingPanel`, status level, `canJoinAllSpaces | fullScreenAuxiliary | stationary | ignoresCycle`), and it only becomes the key window while the composer is open. Elsewhere it is a plain always-on-top window without a taskbar entry. The hotkey is a system chord (`tauri-plugin-global-shortcut`: Carbon `RegisterEventHotKey` on macOS), so it needs no Accessibility permission; it must include ⌘, ⌃ or ⌥ and is refused otherwise, and a key another app already owns is reported in Settings and keeps the previous one.

How it works: like the tray, the dock is a second webview (`/dock`, label `dock`) that owns no stores. Its window is built at startup only while the pill is on (macOS by default); with the pill off (the default on Windows and Linux) there is no window and no web process until something shows it (Settings → Agents, the hide key, the summon key, a capture sent to an agent), which builds it off the event loop and shows it once its page has painted (`dock_ready`). The hide key stays registered either way. The main window publishes the agent terminals it knows (`dockFeed.svelte.ts` → `dock_publish`: tab, pty, agent, project, worktree, state, last message; omp chat tabs are left out, they take input through their protocol), `dock.rs` caches them and forwards `dock://snapshot`. Delivery does not go through any webview: `dock_send` looks the pty up in the cached snapshot and `agent/send.rs` writes the bracketed paste and Enter to hostd itself, serialized per terminal. `agents.send` in the app calls the same code (`agent_send`), so there is one implementation. The state machine and target resolution are pure (`lib/dock.ts`, `dock.test.ts`); Rust reads the snapshot's JSON from the same fixture the producer test pins (`__fixtures__/dock-snapshot.json`).

Agent instances (`desktop:agent`): the dock window is built but never shown by itself, owns no global hotkey and never becomes key. `dock_show` (call it from `atlas desktop debug eval 'return await window.__TAURI_INTERNALS__.invoke("dock_show")'`) shows it on the instance's virtual display through `agent_display::park_and_show` and the watchdog, like the main window; the `atlas desktop debug shot` and `capture` commands target the main window, so capture the dock by sending `{"cmd":"capture_shot","args":{"window":"dock","out":"/tmp/dock.png"}}` to the instance's `ATLAS_DEBUG_SOCK` (same request the CLI sends, with the window label the CLI does not expose).

Not in this version (the design is in the dock proposal, `dock.rs` keeps one table of hotkey actions for them): voice and push-to-talk, approve/deny from the card, launching an agent from the dock, Windows and Linux panels. Screenshots, recordings and GIFs are the next section.

## Capture

Screenshots, screen recordings and GIFs of **your** screen, from a hotkey, in any app (macOS; other platforms answer "not available yet"). The keys are in Settings → Capture, with presets; the defaults are ⌃⌥ + digit, none of which macOS or ordinary apps use (⇧⌘3/4/5 are macOS's own and are refused; ⇧⌘S is a preset that costs you Save As in the app in front, and the page says so).

| Key | What |
|---|---|
| ⌃⌥3 | The display under the pointer, now |
| ⌃⌥4 | Drag a region (crosshair, live pixel size, a 15×15 magnifier; Space moves it while you drag, or switches to window mode before you start; the shot is taken the moment you release the mouse; Esc or right click cancels) |
| ⌃⌥5 | Click a window (it highlights under the pointer) |
| ⌃⌥6 | Record a region to mp4 |
| ⌃⌥7 | Record a region to GIF |

**Capture on release** (Settings → Capture → Screenshots, on by default, `still.captureOnRelease`): a drag of at least 4 points commits when the mouse button goes up, with no Return; a smaller one is ignored. Turn it off to keep the selection after the release, adjust it (drag inside to move it, handles to resize, arrows to nudge, Shift/⌥ for 10 points or resize) and confirm with Return or a double click. Window picks, whole-screen picks and a click on a window in Record/GIF/Text act on the click, as before. The setting reaches every display's overlay in its init (`Hud.captureOnRelease`).

Pressing a capture key while the overlay is up toggles it (same key) or switches its mode (another key). While a recording runs only its HUD applies.

**After a capture**: the file goes to the folder (`~/Pictures/Atlas Captures` by default, `Screenshot 2026-10-26 at 14.03.22.png`, a counter when two land in one second), the image is copied to the clipboard (a recording copies the file), the shutter sounds, it is added to the history (last 50 by default) and a **quick card** appears in the corner you chose (default bottom right) of the display under the pointer for six seconds (hover pauses that card, an error holds it). Captures **stack**: the newest card sits nearest the corner and the oldest goes once the stack is full (default 5, up to 8); each card has its own timer, and closing the last one hides the window. The cards never take focus. Their buttons: Copy, Save As, Annotate (screenshots), **Pin** (screenshots), **Text** (screenshots: reads the words in the image), Send to agent, Reveal in Finder, Discard (asks first), and you can drag the thumbnail out as a file. A recording also offers **GIF** with three qualities and a size estimate.

**Pin** opens the screenshot in its own borderless window above every other window, on every Space, without taking the keyboard from the app you are in (`shots/pin.rs`; any number of pins; they are visible in screenshots like any window). Drag the picture to move it; mouse wheel or pinch zooms (from 25% to 400%, around the centre, never larger than the display), `+` / `−` do the same by keys, **Alt + wheel** or `[` / `]` fade it (from 20% to 100%), double click goes back to 100%, **Esc** or the button that appears on hover closes it. A picture larger than 80% of the display opens scaled down to fit. Keys reach a pin after you click it; clicking another window hands the keyboard back.

**Text** shows a card with the first lines it read, **Copy again** and **Send to agent**; a picture with no words says "No text found" and leaves the clipboard alone. Sending a text writes it to a `.txt` in the temp folder and attaches that file like a capture.

**Send to agent** attaches the file to the dock's composer (`dock.rs`: `attach` queues it, `dock://attach` tells the page, `dock_take_attachments` drains the queue, so a capture sent while the dock page was not listening is not lost; a hidden dock is shown). The composer shows a chip with ✕ and appends the absolute path after the text (`@/path` is how omp and Claude Code read an image).

**Recording** ([`shots/record.rs`](../crates/atlas-desktop/src/shots/record.rs), `record_mac.rs`): ScreenCaptureKit with the display filter excluding Atlas's own windows, HEVC in an mp4, 30 fps, the display's pixel scale, the pointer when "Highlight cursor" is on. ScreenCaptureKit cannot pause, so a recording is a list of **segments**: pause ends one, resume starts the next, stop joins them without re-encoding (AVFoundation) and the clock counts only recorded time (the limit is 10 minutes of it). The HUD (`shots-hud`) shows 3-2-1, the timer, Pause, Stop, Cancel; Esc discards, Enter stops, P pauses. A GIF is made from the mp4 with one frame every 1/fps, box-downscaled, one palette for the whole clip (exact when it has up to 255 colours), differenced frames with a transparent "unchanged" index (`shots/gif.rs`).

**Annotate** (`shots-editor`, `shots/editor.rs`): arrow, rectangle, text, highlight, blur/pixelate, crop; **Copy**, **Save a copy**, **Save & Copy**. The edit is written next to the original as `… (edited).png` (editing an edit overwrites the edit) and listed in the history; the page's PNG is validated (base64, PNG signature, size) before it reaches the disk or the clipboard, and only files in the history can be opened or deleted from the card, because the page is a webview and its arguments are untrusted.

**Permission**: Screen Recording, asked on the first capture (never at launch). macOS applies the grant only after Atlas restarts, and the error says so. Nothing is captured in the background.

Windows of capture: overlay (one per display, covers the real screen, never built in an agent instance), the card stack (one window, resized to its cards by `surface::quick_stack_frame`), HUD, editor, and the pins (`shots-pin-<n>`). All go through `shots::surface::show` (the overlay through `runner::order_in`, the same gate) and every later move or resize through `surface::place`, whose rule (`relayout`) never sets a position in an agent instance; they run on the main thread and, in an agent instance (`desktop:agent`), go through the guarded virtual display like the dock (guard test in `agent_display.rs`). All but the editor and the pins are excluded from the picture by window id.

**Capture never activates Atlas.** Every capture window is an `NSPanel` with the non-activating style, built that way before it is ever shown (`surface::build` → `dock_mac::make_panel`, on the main thread). The style alone is not enough: `NSPanel` tells the window server (`kCGSPreventsActivationTagBit`) only while it initialises, and these windows start as ordinary Tauri windows, so `make_panel` also sends `_setPreventsActivation:` (the call `NSPanel` makes itself). Without the tag the first mouse-down on the window (the drag of a region) activated Atlas and raised its main window over the app you were capturing. Right before a capture window is ordered in, `dock_mac::ensure_nonactivating` reads the real state back (`Activation`: class, style, tag; the decision is `Activation::safe`, unit-tested) and converts again if it is not safe; a window that still is not safe is not shown at all. The overlay, HUDs and pins get Esc, Space and their keys through `dock_mac::overlay_keys`, which makes the panel key without activating the app (a no-op in agent instances). Nothing in a capture calls `show_main`, `set_focus` or `activate`. To check a build, in a debug build: `atlas desktop debug eval 'return await window.__TAURI_INTERNALS__.invoke("shots_debug_activation")'` answers `{active, frontmost, windows: [{label, panel, nonactivatingStyle, preventsTag, safe}]}` (agent instances run with the `Prohibited` activation policy, so `active` stays false there; the per-window fields are what it proves).

**How fast it is.** Capture opens and finishes from state that is already in memory, so a loaded Mac cannot stretch it:

- The overlay windows are built once and reused (hidden and reset between captures, `shots://overlay-reset`); the hotkey orders them in from CoreGraphics' display list at once and sends each page its session (`shots://overlay-init`, `session` tells one from the next), then freezes every display in parallel with the overlay excluded by window id, and sends the init again with the windows a pick can snap to.
- A region or a whole-screen pick is **cut from that frozen frame in memory** (`freeze.rs`): the pixels saved are the ones you saw when you let go, never a new capture taken after the overlay has gone. A fast release that beats the freeze waits for it on the worker; "capture previous area", the full-screen key, a window pick and the self-timer capture live (`runner::live_still`).
- The PNG is encoded once; the file, the clipboard and the card's thumbnail come from it, the card appears before the sound and the history write.
- Only the threads you wait on run at the interactive scheduler class (`mac::Qos`): the one that shows the overlay and freezes (one helper per display), the one that cuts, encodes and writes the still, and the clipboard helper. Recording, GIF encoding, text recognition, history and the settings write run at the default class (QoS is per thread and not inherited, tested). A hotkey while a capture's pixels are still being cut waits those few milliseconds, because a new session would replace the frames being read.
- `ATLAS_SHOTS_PERF=1` prints every stage (`overlay.visible`, `overlay.freeze`, `release.file`, `finish.thumb`, `release.card`, `capture-to-card`, ...); a debug build also answers `shots_perf` with p50 and max per stage.

Contract with the pages (Rust serializes camelCase; tests serialize the real values): `shots_*` commands listed in `main.rs` (`lib/shots/commands.test.ts` fails when a page calls one that is not registered, or a registered one nobody calls), events `shots://quick-stack`, `shots://record`, `shots://overlay-init`, `shots://overlay-reset`, `shots://overlay-mode`, `shots://gif-progress`, `dock://attach`. State machines are pure (`shots/session.rs`, `lib/shots/*.ts`).

Agent instances own no global hotkey, so in a debug build start a capture with `atlas desktop debug eval 'return await window.__TAURI_INTERNALS__.invoke("shots_debug_start", {mode: "fullscreen"})'` (`region`, `window`, `record` and `gif` need the overlay, which an agent instance never builds).

## UI kit workarounds

Atlas Desktop runs on `@codeatlasdev/ui` (4.6.0). When the kit has a defect that cannot wait for a release, Atlas fixes it once, in one central place for every screen (never per dialog or per bar), documents it in the code with the kit file it works around and the condition for removing it, and lists it here. A workaround that the kit has fixed is deleted, not left behind.

| Workaround | Where | Kit behaviour | Remove when |
| --- | --- | --- | --- |
| **A closing modal stops blocking the page** (#501). | `apps/desktop/src/lib/shell/closingLayers.ts` and `.closing-scrim` in `app.css`, started in `shell/session.svelte.ts`; guarded by `closingLayers.test.ts`. | `Dialog`, `AlertDialog`, `Drawer`, `Sheet` and `CommandPalette` are native `<dialog>`s opened with `showModal()`; closing flips `data-state="closed"` but keeps the dialog modal (page inert, scrim live) until the 150 ms exit animation ends (`primitives/presence.svelte.js`, `primitives/layer.js`), so a click on a button behind it right after an outside dismissal is lost. As soon as a `dialog.ca-overlay` turns `closed` (a microtask later, before any input event), the workaround calls `close()` then `show()` on it: the dialog leaves the top layer and is no longer modal, so the page answers the very next press, while the kit's exit animation keeps playing in place. The dialog is made `inert` for that time (presses and the kit's focus trap find nothing in it), its `::backdrop` (which only exists for modal dialogs) is replaced by a fixed `.closing-scrim` element with the kit's scrim colour and `ca-overlay-out` fade (no blur: Atlas's `--ca-scrim-blur` is `none`), so **the fade still plays, panel and scrim**. Opening the dialog again during the exit makes it modal again; a control focused during the exit keeps focus when the kit removes the layer and restores the opener; an animation that never ends (a spinner) is cancelled, because the kit waits for it forever. | The kit releases the modal when it starts closing ([ui#1334](https://github.com/codeatlasdev/ui/issues/1334)). The control test in `closingLayers.test.ts` ("without the workaround ... is dropped") then goes red: delete the module, its call in `session.svelte.ts`, the `.closing-scrim` and `[popover]` rules in `app.css` and this row. |
| **A closing menu, popover or tooltip takes no presses** (#501). | `[popover][data-state="closed"] { pointer-events: none }` at the end of `apps/desktop/src/app.css`. | A floating layer stays in the page for its exit fade and keeps catching presses over its own box. It does not make the page inert, so the fade keeps playing and the presses pass through. | Same kit fix (ui#1334). |
| **One box for every status bar item** (#504). | `apps/desktop/src/lib/editor/StatusItem.svelte`, used by `StatusBar.svelte` and `lsp/LspStatus.svelte`; guarded by `editor/statusBaseline.test.ts`. | The kit's reset has `button { font: inherit }`, which resets `line-height`, and a `<button>` centres its text while a `<span>` does not, so a compact row that mixes text and action items draws them at different heights (WebKit: 3.25 px). `StatusItem` is a `<span>` or a `<button>` with one height, padding, font and a `line-height` equal to the height written after `font`. A new status item uses it; nothing in the bar draws its own box. | The kit ships an item primitive that keeps both element types on one baseline ([ui#1335](https://github.com/codeatlasdev/ui/issues/1335)); switch `StatusItem` to it and keep the test. |

The tests run the real kit. happy-dom has no layout, top layer or hit-testing, so they model the browser rule they need (a modal blocks the page; a closing overlay has one running 150 ms animation) and the status test recomputes each item's line box from the compiled CSS; the same two scenarios were also measured in WebKit through Playwright (click 0, 16, 30, 80, 150 ms after a dismissal, panel and scrim opacity sampled mid-exit; text top of each status item).

## Developing the app

| Goal                                                                        | Command                                                           |
| --------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| Hot reload (Vite + Tauri shell; Rust changes rebuild)                       | `atlas desktop --dev` (or `bun run desktop:dev` at the repo root) |
| Make the real `Atlas.app` (Dock, Spotlight, `atlas desktop`) run your build | `atlas link --desktop` (debug bundle; rerun to rebuild)           |
| Back to the release CLI and app                                             | `atlas unlink`                                                    |
| Release bundle + dmg locally                                                | `bun run desktop:build` → `target/release/bundle/`                |
| Debug `.app` only (agents, Studio capture; never builds a DMG)             | `bun run desktop:build:app` → `target/debug/bundle/macos/`        |
| Typecheck the frontend                                                      | `bun run desktop:check` (also part of `bun run check`)            |

While linked (or running `cargo tauri dev`), the app shows a thin amber line across the top of the window and a small **Dev** chip next to the version in Settings and in the menu-bar popover. Hovering the top edge tells you that updates are paused and that `atlas unlink` resumes them. Both the app and `atlas update` refuse to install over your build, and no update pill or notification appears. Settings → General has an **Unlink dev build** button and copyable rebuild commands.

### Native views

The GPU terminal and every browser tab are native views: an `NSView` that a DOM element (the _slot_) stands in for. They sit **below** the main webview, and the page is transparent exactly over each slot, so a view shows through it and everything the page draws over a slot (menus, dialogs, a modal's scrim, shadows, backdrop blur) is ordinary DOM painted above the view in the same compositor commit: there is nothing to keep in step with it, and no overlay ever needs a hole, a mask or a veil. Measured against a mask design (native view above the page, holes cut for overlays), the stacking produced 0 inconsistent frames in 60 open/close transitions where the mask produced one in 30-40% of them.

Everything the views share lives in one core, `apps/desktop/src/lib/native/`, and a kind of native view is only an **adapter**. A new kind (a video player, a map) registers once and gets every behaviour below for free; a bug fixed in the core is fixed for all of them.

What the core does for every kind:

- **One serialized chain.** `open → place → release` run strictly in order per view, coalesced (one run waits behind the running one) and measured when each call _runs_, never with a stale rect. `dispose` releases after whatever is in flight (a release outside the chain used to land before an in-flight open and leave an owner-less view over every other space); after it nothing opens or shows the view again.
- **The ground and the hole** (`ground.ts`). Three grounds paint under a slot and carry a hole at the native view's box: `.window-ground` (the chrome colour, one, fixed), each space layer's `.ground` (card colour and space tint, so a hole travels with its layer and a parked neighbour's is right the moment it slides in) and the slot element's own fill (a terminal's padding colour paints around the view, not under it). The holes are `clip-path`s, written **in the same task as the sync** (a `ResizeObserver` callback, a Svelte effect), never a frame later, and an unchanged write does nothing. A hole **closes at once** when the view is hidden, parked, replaced or disposed (the page covers the slot that very frame) and **opens only once the view has been placed shown**, so a slot never shows window material while a view is still on its way. The engine is on only while `html.ground-holes` is set (macOS: `startGround`, from the shell); on Linux and Windows the grounds stay opaque and child views stay above the page as before.
- **Overlays are the page's.** Nothing in the core measures, cuts or tracks them. Only the **input** needs to know: the page is on top, so AppKit's hit test always lands on it. The **hit map** (`hit.ts`) publishes the rects the page paints over a slot and owns input in (open menus, listboxes, tooltips and dialogs, the edge peek, anything marked `data-native-cover`, and a modal's whole window) through `natives_hit`. It is measured when an overlay opens, closes or is placed (a kit floating layer is placed a frame late, so a change is re-measured for three frames; the rect is the overlay's _final_ box, its entry transform taken out), sent only when the set changed, and arrives before the first frame that shows the new state. Nothing runs per frame at rest.
- **The router** (`natives/router.rs`, carried out by `natives/mac.rs`). One local `NSEvent` monitor decides every mouse event: over an _interactive_ view's slot (a browser page) and outside every hit-map rect it belongs to the native view (the event goes to it; a press makes it first responder and is reported as `native://pointerdown`, `nativeClicks.ts`, so the page's outside-press logic closes menus and popovers); elsewhere AppKit delivers it to the page. A press **pins** its owner until the button is up (a drag begun in the page that crosses a dialog stays the page's, one begun in a browser stays the browser's), a scroll follows the point, and a move is never taken from the page (hover panels must see the pointer leave) but the view under it is told too. A GPU terminal is not interactive: its input is DOM events on its slot, which the page keeps. Keys follow the first responder, independent of stacking.
- **The underlay** (`natives_ground`). An opaque view in the card colour under every native view, which is what a hole shows for the frame before a view has landed (just shown, resized or moved), so it is never the window material. The page sends the colour whenever the theme changes.
- **The loading strip** (`loading.ts`, `indicator.ts`). The core reserves a 2 px strip above the view (the rect the adapter's `open`/`place` receive starts 2 px below the slot's top, and the hole starts there too) and draws one indicator in it, so the bar can never be covered by, or bleed into, the native view or the DOM chrome. Adapters only report: `surface.loading.start() / progress() / finish() / fail()`. The bar fades in after 150 ms (a fast load never flashes) and out on finish; a load with no event for 15 s stalls (`onStall`, which the browser turns into its error screen). Any `start`, `progress` or `finish` re-arms that timer, so a slow page that keeps reporting is never marked failed. A slow `open` is a load too.
- **Swipes park.** A tab swipe marks every pane it moves with `data-swiping`; a native view cannot follow a CSS transform and no IPC runs per frame, so the surface parks a view inside such a pane (hole closed, view hidden) and puts it back when the mark lifts (`watchSlot` re-syncs once each way).
- **The registry and reconciler** (`surface.ts`). Every surface is registered by kind and id; `reconcileNatives` (after every space commit, gesture rest and window focus) hands each kind's orphans (views nobody mounted owns) to the kind's handler and re-syncs the owned ones. Nothing is reconciled before the workspace has loaded.

The contract, in full (`NativeAdapter` in `native/surface.ts`):

```ts
const surface = createNativeSurface({
  kind: "player", id: tab.id,
  slot: () => area,                      // the DOM element the view stands in for
  visible: () => active,                 // does the owner want it on screen?
  open: (rect, shown) => invoke("player_open", { tab: id, ...rect, visible: shown }),
  place: (rect, shown) => invoke("player_bounds", { tab: id, ...rect, visible: shown }),
  release: () => invoke("player_close", { tab: id }),   // close it, or park it if the tab may be re-parented
  // optional: extraHidden, rect (padding), canOpen, gone, onError, reload, onStall/stallMs
});
const off = watchSlot(area, surface.sync);   // on mount; `off(); surface.dispose()` on destroy
registerNativeKind({ kind: "player", list: () => invoke("player_list"), orphan: (id) => invoke("player_close", { tab: id }) });
```

On the Rust side the kind calls `natives::register("player", tab, view_ptr, interactive)` when it creates its view (again when it swaps the `NSView` for another), puts it below the page with `natives::lower_below_page(view_ptr)` once it joined the window, and calls `natives::unregister("player", tab)` when it destroys it. `interactive` says whether the view takes mouse input itself (a browser page does, so the router hands it the events over its slot; a terminal does not). The registry and the router (`natives/`) find views by `(kind, tab)` and know no kind by name; the router's decisions are a pure function with a table of tests, no AppKit.

The terminal (`components/terminal/nativeView.ts`, which adds colours, prefs and reload) and the browser (`browserSync.ts`: parked instead of closed on release, opened only once it has a URL) are the two adapters. `native/surface.test.ts` registers a fake third kind and proves it gets the chain, the hole, park, loading strip, reconciler and dispose ordering with no code of its own.

### Debugging a running build

Debug builds (`desktop:dev` and `atlas link --desktop`) keep WebKit's context menu, so right-click → **Inspect Element** opens Web Inspector. They also run a bridge (`~/.atlas/desktop-debug.sock`, or `$ATLAS_DEBUG_SOCK`) that a terminal or an AI agent can use without touching the mouse or keyboard. Release builds do not contain the bridge or the menu.

#### Agent instances: `bun run desktop:agent`

An agent that wants to look at the app must never open a window on your desktop. `atlas desktop --agent` (or `bun run desktop:agent`, which also builds the debug bundle the first time) starts an isolated instance and prints the socket to use:

```bash
bun run desktop:agent -- --name a1 [--scratch]
# atlas-agent ready name=a1 pid=123 ATLAS_DEBUG_SOCK=/private/tmp/atlas-agent-a1/debug.sock
export ATLAS_DEBUG_SOCK=/private/tmp/atlas-agent-a1/debug.sock
atlas desktop debug state
bun run desktop:agent -- --stop --name a1      # or --stop for all of them
```

Each instance has its own `HOME`, `ATLAS_HOSTD_DIR` and bridge socket under `/tmp/atlas-agent-<name>/`, so agents run side by side and never touch your app, hostd or `~/.atlas`. `--scratch` copies only the files of `~/.atlas/desktop` (settings, theme, layout) into its `HOME`, never your project registry, tokens or sockets. The instance has no Dock icon or tray, never takes focus, and its window is placed on a private 2x `CGVirtualDisplay` that is not one of your monitors; the page there runs at the full 60 rAF/s because the display is never occluded. The display is retina (DPR 2); `ATLAS_AGENT_SCALE=1 bun run desktop:agent` gives a standard 1x display, to check what a non-retina user sees. Before showing the window the app reads its real frame back from AppKit and refuses unless it lies entirely on that display.

```bash
atlas desktop debug info                          # pid, URL, visible, window id, agent, socket
atlas desktop debug state                         # projects + service states, worktrees, selection
atlas desktop debug logs [--level csp|error|warn] [--since N]   # console, uncaught errors, CSP violations
atlas desktop debug eval 'document.title'         # expression, or a body with `return`; awaits promises
atlas desktop debug shot x.png [--selector css | --rect x,y,w,h | --full | --window]
atlas desktop debug record x.mov --seconds 5 | --until '[data-testid="welcome-up"]' [--fps 30]
atlas desktop debug wait '.ready' [--timeout ms] | wait 'window.__atlas.ws.loaded' --expr
atlas desktop debug click 'button.go' | type 'input' 'text' [--delay ms]
atlas desktop debug resize 1100 720                # main window, logical px (320..5120); prints the page view size
atlas desktop debug a11y [selector]               # roles, names, nesting; unnamed controls are flagged
atlas desktop debug perf --seconds 3              # rAF/s, p50/p95/max frame ms, long tasks
```

`shot` is a `WKWebView` snapshot: no permission, retina, works with the window unfocused. `--selector` picks the first match that is visible and on screen. `click` and `type` are DOM events inside the webview, never OS input. Logs are captured from before the page's own scripts run, so load-time errors and CSP violations show up. `desktop:dev` also prints them to the terminal as `[webview <level>] …`.

#### Gesture engine, bench and recordings

The gesture system is one engine with one source of truth, in Rust, fed by the raw `NSEvent` scroll stream:

- `crates/atlas-desktop/src/swipe_engine.rs`: pure physics and decisions (claim gate, 1:1 tracking, rubber band, release decision from the lift velocity, critically damped spring, programmatic `go`). Every decision carries a generation (`seq`) so a consumer applies each commit exactly once.
- `swipe_mac.rs`: the `NSEvent` monitor (the only place an event becomes a `Sample`), zone hit-testing, the display-rate clock (`swipe_clock.rs`, `NSView.displayLink`), the recorder and the replay entry.
- Frontend: `shell/pager.ts` (space layers), `shell/tabPager.ts` (tab panes), `shell/nativeSwipe.ts` (events and zones). The pager draws every engine frame itself, as GPU transforms of the live layers: there is no snapshot of the UI anywhere. A non-current layer is on screen only while a gesture keeps it (`spacePager.kept`); debug builds check that after every commit and rest (`shell/layerInvariant.ts`, `[layers]` console error). Why the native snapshot stage was removed: [postmortems/ghost-frames.md](https://github.com/codeatlasdev/atlas/blob/main/docs/postmortems/ghost-frames.md).

**Native views and zones.** Terminals and browser tabs are native views above the webview: a CSS transform cannot move them and no IPC runs per frame, so the tab pager marks every pane it moves with `data-swiping` for the generation. the native-view core (`lib/native/surface.ts`, see [Native views](#native-views)) parks a view whose slot is inside such a pane, and `watchSlot` re-syncs it once when the mark is lifted on `rest` (committed or cancelled), at the pane's untransformed rect. The engine hit-tests only the zones the page last pushed, and `rectOf` skips `[inert]`: the collapsed sidebar's `space` zone exists only while its peek is open, so `EdgePeek` re-pushes the zones when it opens, closes and finishes sliding.

**What a space switch must not do inside a page.** The pager moves transforms; everything under a layer has to sit still while it does. Four things broke that and are guarded by tests: (1) a space's hidden tabs were mounted only while it was current, so leaving a space unmounted them and coming back mounted them all in one pass (`panes/tabMount.ts`: a tab that was mounted stays mounted, the fill-in only adds); (2) `DiffView` reloaded (`git diff`, reset and rewrite of every row) whenever its parent rebuilt the `<Lazy props>` object, which a switch does through `focused` (its load now keys on one value-compared string); (3) the kit's blur tiers are glass unless `html[data-style]` selects a style, and `app.html`'s own pre-hydration script never did (`data-style="solid"`, guarded by `kitBlurRoles.test.ts`); (4) the role flip itself restyled every node of the two layers it swapped (#121): the layer root carried `inert` and `pointer-events: none`, and both inherit, so a change on the root makes Chromium recompute the style of the whole subtree (57 ms per layer of 23k nodes, a 286 ms stall with a 400-line diff in each of five spaces; bisected: pinning every declaration of the `near` rule inline gave 0 ms, unpinning only `pointer-events` gave 56 ms, and `inert` costs the same on a wrapper). `SpaceLayer.svelte` lets the role drive only `transform`, `will-change`, `contain: layout paint` and `aria-hidden` (none inherits, 0 ms), and `parkedLayer.ts` keeps a resting neighbour out of reach without a style flip: focus that lands in it is bounced back (and the scroll the browser did to reveal it undone), and `rectOf` drops its swipe zones. Never put `inert`, `pointer-events`, `visibility`, `contain: style` or any inherited property on a layer root or a wrapper that a switch flips (`layerRoleFlip.test.ts`); `bun scripts/pager-restyle-probe.ts` mounts the real `SpaceLayer` with three 23k-node layers in a real Chromium, flips the roles and exits 1 when the flip restyles more than 200 elements (`--layer <file>` judges another version of the component). To see what a switch really does, count the `git_diff` calls and DOM mutations under `.pager` during one `button.space` click through `debug eval` (a `MutationObserver` on `.pager`, `fetch` wrapped for the IPC names): a healthy switch changes role attributes on two layer roots and issues no content IPC.

AppKit's `trackSwipeEvent` is deliberately not used: its `gestureAmount` is a fixed `scrollingDeltaX / 1000` whatever the view size (a half-page drag is a 500 pt reach) and its settle is opaque.

**Who owns a sideways gesture (Safari's back swipe).** Content that scrolls horizontally (an editor with a long line, a diff, a table, a code block) keeps a gesture that lands on it while it can still go the way the fingers go; the swipe only takes a gesture that starts with the content at its edge in that direction or on a surface that does not scroll. The page measures it (`scrollerRects` in `nativeSwipe.ts`: every scroller's rect plus `left`/`right`, the directions it can still scroll; terminals and `data-gesture="own"` keep both; an editor that wraps its lines and a tab that is not shown, `visibility: hidden` under the active one, are not scrollers) and pushes it with the zones, again 100 ms after any sideways wheel, `scrollLeft` change or edit. The engine (`Scroll` in `swipe_engine.rs`) asks once, when the fingers land, and the answer holds to the lift: a scroller that reaches its edge mid-gesture never hands the gesture over, and its momentum tail stays the page's. A gesture the content took marks the scrollers under the pointer as "both ways" until the next measurement, so a quick scroll back is not given to a swipe on a stale edge. It applies to every zone (tab group, sidebar, Back/Forward).

**The page always settles.** Fingers that land during a settle only take the page over if they claim: until then the spring keeps running and ends in `rest`, however the new gesture goes (a scroll the content owns, a vertical scroll, a resting finger). A new touch on a gesture whose lift was lost ends that gesture first; a silent finger is released after 400 ms; `swipe_abandon` (window blur, page hidden) cancels fingers still counted as down; and both pagers (`pager.ts`, `tabPager.ts`) let go of their pose by themselves when no frame arrives for `PAGER_WATCHDOG_MS` (2 s).

**Tests.** `cargo test -p atlas-desktop swipe` runs the engine against the trace suite (`apps/desktop/src/lib/shell/__fixtures__/traces/*.json`, synthesized from the trackpad physics by `bun scripts/gesture-fixtures.ts`, plus any `recorded-*.json`; a trace with `expect.scroller` starts over a horizontal scroller with those edges, and the bench puts one under the aimed pointer for its replay). `bun test --conditions browser src/lib/shell src/lib/debug` (in `apps/desktop`) covers the pagers, the layer invariant, the measured scroller edges and the bench's assessment rules.

**Bench.** Against a real agent instance (never your window, never OS input):

```bash
bun run desktop:agent -- --name gesture --scratch       # prints ATLAS_DEBUG_SOCK=…
ATLAS_DEBUG_SOCK=/private/tmp/atlas-agent-gesture/debug.sock bun scripts/gesture-bench.ts [--only name,name] [--repeat N] [--hz 60] [--json out.json]
```

It replays every trace into the engine through the same entry point real events use and holds the app to the budget: exactly the expected page (never two steps, never a bounce to the wrong one), tracking monotonic toward the target, settle 250-350 ms with no overshoot, no frame gap over 1.2 frames + 3 ms, no main-thread stall over 20 ms, zero forced layouts, natives parked and restored together, a consistent end state (one current layer, no leftover transform, no parked layer in view). It seeds its own spaces (five tiny repos registered through `projects_add`), aims every trace at the zone it is meant for by reading the zone table the engine actually hit-tests (`swipe_zones_now`), prints a table and exits 1 on any violation.

Timing on a shared machine: the bench first records 3 s of the page doing nothing (the **idle floor**: frame-gap p95 and the worst stall) and judges the timing rules against the larger of the budget and 1.5x that floor; a trace that fails only on timing is retried (`--retries`, default 4) and reports its best attempt. Deterministic rules (wrong page, double commit, forced layouts, settle time, overshoot, end state) are never relaxed or retried. The agent's virtual display is 60 Hz: the engine ticks at the display's refresh, so frame-time claims for 120 Hz need a bench run on a ProMotion panel (`--hz 120`).

`bun scripts/gesture-baseline.ts` measures the one thing every build shares, the programmatic space switch (what a click on the space strip or ⌃⇥ does), by injecting the same probe through `debug eval`, so it also runs against a bundle built from an old commit (`ATLAS_BIN=<that tree>/target/debug/atlas`).

What replay cannot cover: the `NSEvent` → `Sample` conversion (`sample_of` in `swipe_mac.rs`) and the OS delivering real events to the monitor. Measured with a standalone probe: a scroll `NSEvent` built from a `CGEvent` (`scrollWheelEventScrollPhase`, `IsContinuous`, point deltas) carries the right phases and deltas, but `-[NSWindow sendEvent:]` and `-[NSApplication postEvent:atStart:]` delivered none of a synthetic stream to a view in a background window, and calling `scrollWheel:` on the view directly started `trackSwipeEvent` with only its first callback (it reads the rest from the real event queue). So replay feeds the engine at `on_sample`, one step after the conversion, and the conversion stays verified by recordings.

**Recording your own swipes.** In a debug build of your app (`bun run desktop:dev`, or `atlas link --desktop`), run the command and swipe on the trackpad while it records:

```bash
atlas desktop debug gesture-record /tmp/my-swipe.json --seconds 8
```

The file is the raw event stream (timestamps, phases, deltas, pointer) with what the engine did with each event. Set `expect` in it (`zone`, `steps`: `1` next, `-1` previous, `0` stay, `untouched`) and keep it as `apps/desktop/src/lib/shell/__fixtures__/traces/recorded-<name>.json`: the Rust suite and the bench pick it up. `atlas desktop debug gesture-replay <trace.json>` feeds one into the running app in-process.

#### Flicker sweep

`gesture-bench` and `selection-bench` measure the main thread; a flicker is something the compositor *showed*, so the sweep judges pixels. It drives every surface of a real agent instance (never your window, never OS input) while the in-app recorder films it at 60 fps, then exits 1 on any flicker:

```bash
bun scripts/flicker-sweep.ts [--only settings,terminal] [--out /tmp/flicker-sweep] [--keep] [--list]
bun scripts/flicker-sweep.ts --judge /tmp/x.mov [--surface name]      # judge one recording, no app
```

It starts its own instance (`--name sweep`, scratch HOME, three throwaway repos under `/tmp/flicker-sweep-fixtures`: a stack with a crash-looping service, an action and an uncommitted diff, plus two neighbour spaces) and stops it at the end. One recording per surface, so a finding names its surface: boot (idle baseline), sidebar select, space switch, Panel (cards filling in, failed service), action toast and output drawer, Logs, Changes, Settings (every section), dialogs, menus and tooltips, space switches by click and by replayed trackpad gesture, window hide/restore, palette, error toast, terminal open/close, window resize with a live terminal, browser tab, tab swaps (`--list` prints them; `scripts/flicker-sweep-surfaces.ts` is the one place to add one). `atlas desktop debug resize W H` resizes the window mid-recording; `atlas desktop debug hide [--restore]` hides an agent instance's window and shows it again through the guarded placement.

**Ghost frames.** Surfaces that call `mark()` after a transition (dialogs, space switches, restore, tabs) are also ghost-judged (`ghostFrames`): the mark is taken in the page once the pager is at rest and every animation finished, and each of the 6 frames shown from 50 ms after it must match that transition's settled picture (the last frame within 1 s, before the next mark) on fewer than `minCells` cells by `delta`. A frame that does not showed an older picture: a ghost. The verdict prints `ghost frames: N` per surface and fails on any; a `[layers]` error from the page fails the sweep too. Background: [postmortems/ghost-frames.md](https://github.com/codeatlasdev/atlas/blob/main/docs/postmortems/ghost-frames.md).

A recording is decoded with its own presentation times (ScreenCaptureKit is variable frame rate: no `fps=` resample) into a 24 x 15 luminance grid per frame (`lib/debug/flickerSweep.ts`, unit-tested; flashing reuses `studio/src/lint` `flashWindows`). It fails on a **blip** (a region that differs from the frame before and the frame after while those two agree: the picture left its state for 1-2 frames and came back; ramps, one-way changes and states held 3+ frames are motion, not flicker), a **blank** frame (black or a cleared flat surface between frames with content) and BT.1702 **flashing**. A surface that recorded fewer than 3 frames fails too: a recording that never started is not a pass. The report (`report.md`, `report.json`) lists every surface with its frame count and, per finding, the timestamp and PNG crops of the frames around it.

Needs Screen Recording permission. It is heavy: run it alone, with the load average under 4, like the benches. Run it before a release; `bun test scripts` covers the detector and the script's exit codes without an app.

#### Capture and record (agents)

The app records and screenshots its own windows without focusing or driving the desktop (ScreenCaptureKit inside the app; every build, local only):

```bash
atlas desktop capture shot /tmp/x.png [--mode window|snapshot] [--size WxH]
atlas desktop capture start /tmp/x.mov [--fps 24|30|60] [--size WxH] [--cursor]   # then: atlas desktop capture stop
atlas desktop record --script tour.json --out /tmp/rec     # video.mov + timeline.json + shots/
bun studio run studio/recipes/tour.ts                      # recipe -> cached clip + timeline + shots
```

`snapshot` renders the page only (no permission, works occluded); `window` includes the native chrome and needs Screen Recording. Measured on macOS 26 with the user's windows covering the dev window 100 %: WebKit marks the page hidden (0 rAF/s) because AppKit clears the window's occlusion bit; none of the WebKit preferences or `_setWindowOcclusionDetectionEnabled:` changes that, only `-[NSWindow _setOcclusionStateIsVisible:]` does (30 rAF/s). `capture start` applies it for the recording and restores the real bit on stop. A window that is not key renders at 30 Hz, so the video container runs at the requested fps while page content is 30 fps; `start` reports this as `page_fps_cap`. macOS draws a "being shared" pill into the title bar of a captured window; no `SCStreamConfiguration` setting removes it (`sharingType = none` makes the frames black), so the standard window buttons are hidden for the recording.

Agent instances (`ATLAS_AGENT=1`, debug builds only) have no Dock icon or tray, never take focus, and park their window on a private `CGVirtualDisplay` (2x, placed right of the user's displays, destroyed with the process). Verified: creating it leaves the user's display bounds, main display, menu bar and Spaces unchanged. `ATLAS_DEBUG_SOCK=<absolute path>` selects another instance's bridge socket.

The code lives in two places: the backend is in `crates/atlas-desktop`, which reuses `atlas-tui`'s `config`, `control`, `status` and `runner`, and the frontend is in `apps/desktop` (SvelteKit SPA, `@codeatlasdev/ui`). Installs and updates always go through the CLI (`atlas update`, `atlas desktop --install`), so the terminal and the app share one download-and-replace path.
