Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
# Harness Desktop and Web
Harness Desktop is the native Flutter client for browsing Harness machines and
interacting with their terminal-backed agents. **macOS is the primary supported and tested
experience.** Linux builds exist, with feature parity still in progress; Windows support is
planned and its runner is unexercised. Embedded harness viewers currently require macOS.
The browser target uses this same Flutter package and `lib/main.dart`: workspace,
tabs, pickers, settings, state, and the patched xterm renderer are shared. Browser
support is available as a public preview at
[harness.autonomous.ai](https://harness.autonomous.ai); there is no separate web UI
to keep in sync.
## Web development
Use Flutter ≥ 3.47 / Dart ≥ 3.13. From `desktop/`:
```bash
flutter pub get
flutter run -d chrome --web-port=3000
flutter build web --release --no-wasm-dry-run --no-web-resources-cdn
python3 scripts/serve-web.py --port 3000 # optional local release preview
flutter test --platform=chrome --dart-define=HARNESS_TEST=true \
test/web test/browser_login_test.dart test/observer_codec_test.dart \
test/wire_counter_test.dart test/password_stretch_test.dart \
test/terminal_binary_test.dart test/e2ee/strict_down_test.dart
```
Deploy `build/web/` at the root of a dedicated HTTPS origin. The host must serve
`index.html` for `/auth/callback`; `_redirects` and `_headers` cover hosts that
support those files. For other hosts, configure the equivalent SPA fallback and
revalidation of unversioned app files. Do not cache OAuth callbacks. The app uses
JavaScript/CanvasKit; WebAssembly app compilation is not validated yet.
The entry page inlines Flutter's generated bootstrap to start the app without
an extra loader request. Keep entry pages and release metadata `no-store`.
Serve static JavaScript, CanvasKit, fonts, and images with ETags and
`Cache-Control: public, max-age=0, must-revalidate`: browsers reuse unchanged
bytes while checking for every deployment. Do not use `no-store` for these
assets or long-lived immutable caching with their unversioned filenames.
The existing backend handles browser OAuth. Local previews on `127.0.0.1`,
`localhost`, or `[::1]` use its existing loopback authorization endpoint, returning
to the registered `/callback` path on the preview's own port without a server
configuration change.
For a hosted web app, add the exact origin to the backend's `WEB_URL` or
comma-separated `WEB_ORIGINS`, and register that origin's `/auth/callback` with SSO.
Any `SSO_REDIRECT_URI` override must point to that same hosted callback. Tests use a
synthetic authorization service. An alternate backend can be selected with
`--dart-define=HARNESS_API_URL=https://your-backend.example` on run/build.
Use `--dart-define=HARNESS_ANALYTICS_DISABLED=true` for isolated previews.
### Production release
The Flutter source remains in this package. The existing website deployment in
`autonomous-ai/autonomous-code` serves its compiled files under `/harness-web/`,
with `/` and `/auth/callback` opening the Flutter app. It also serves the desktop
downloads and installer redirects.
Push a `vX.Y.Z_web` tag on a tested commit to run **Release web bundle**. CI builds
with Flutter 3.47.2 and publishes the archive, SHA-256, and
`harness-web-release.json` as GitHub release assets. Copy that manifest into the
website's `apps/web/harness-web-release.json`, verify the website build, and use
its existing `scripts/release-web.sh` release procedure. Its build checks the
archive's checksum before including it in the image; ArgoCD deploys that image.
For a local production build, run `bash scripts/build-web-release.sh X.Y.Z`.
`FLUTTER_BIN` can select an SDK installed outside `PATH`. Output is under
`build/web-release/` and `build/web-dist/`; the ordinary local preview is separate.
### Browser behavior
- Authenticated access to existing machines uses the shared viewer services and
encrypted relay. Link a machine from the browser before controlling it.
- Existing account-bound sharing invitations open read-only through the observer
relay, with the owner's identity verified. Public, anonymous session URLs and
published snapshots are the next product layer; they are not implemented here.
- Login, linked machines, preferences, and cached workspace metadata persist in
this origin's local storage across tabs and browser restarts. Only the pending
OAuth transaction is tab-local. Browser locks serialize token refresh and
machine-key writes; signing out or changing accounts reloads other open tabs.
**Sign out** clears authentication while keeping this browser's machine links.
Clearing site data removes both; private browsing retains them only for that
private session. Existing tab credentials migrate on the next reload.
- **Download app** sits at the top right of sign-in and workspace screens, opening
the existing macOS/Linux download page in a separate tab. Browser sign-in uses
a full-page fleet diagram and prominent CTA, sharing the native login actions
and their waiting, cancellation, and recovery states.
- Workspace shortcuts use **Option/Alt** in the browser: Alt-P finds agents,
Alt-N starts an agent, Alt-M opens machines, and Alt-T opens a Harness tab.
Machine connection commands and link requests use that same `@` picker,
with connection and setup forms inside its preview pane.
Text editing and terminal
Control keys keep their usual behavior. The shared shortcut sheet and welcome
hints show the active bindings.
- Agent processes and files stay on their host machines. Local provisioning,
desktop updates, device pairing, local usage ledgers, keyboard config files,
native file previews/image clipboard, and embedded native webviews remain
desktop capabilities. Remote terminals and streamed image viewers reuse the
shared UI. Closing the browser does not stop a running agent.
Keep product changes in the existing shared screens and state. Add platform
adapters only for browser/native capabilities, following the conditional stores,
login adapter, and runtime capability checks already in `lib/`.
## Development
For workspace dialog work, follow the
[terminal dialog design system](design/terminal-dialogs.md): fixed cells, plain
text, and one-line selection, using Cmd-N and Cmd-O as references.
Install a compatible Flutter SDK, then run the project from this directory
(`desktop/` in the monorepo):
```bash
cd desktop
flutter pub get
flutter test
flutter run -d macos # or: flutter run -d linux
```
Useful validation commands:
```bash
dart analyze
flutter build macos --debug
flutter build macos --release
flutter build linux --release # must run on an Ubuntu host — no cross-compiling
```
The terminal core is vendored at `third_party/xterm`. Do not replace it with an
upstream package upgrade without preserving the local rendering and IME fixes.
## Harness manager
The terminal icon to the left of Harness Store opens a compact list across your
machines. Each harness shows its agent and name, followed by its machine, project,
branch, and last activity (`5m`, `1h`, `2d`). Search matches names, machines,
projects, branches, and pending questions. Filter All, Needs input, Running, or
Paused; sort by recently active, name, machine, or project.
Needs input replaces the separate bell. A red count badge at the terminal icon’s
top-right corner appears only when harnesses need input. An amber help action
opens the waiting harness; its question appears on a third line in the Needs input
view. The same view opens with **⌘⇧I**. Questions update live and stale actions
cannot redirect you after a question is answered or replaced elsewhere.
Select a row to reveal its existing pane or resume and open saved work. The
separate play button resumes in the background. Pause/play remains at the right;
normal states need no redundant labels.
Pause uses the CLI's existing stop operation, keeping the saved conversation and
project on its machine. Pause/resume controls are enabled for saved Claude and
Codex conversations; other engines remain openable with a tooltip explaining
that exact resume is unavailable. The CLI confirms termination of the exact process
and pane before publishing the paused state, preserving other panes in the same
tmux session. A failed inventory refresh keeps confirmed paused work visible,
and pending operations survive closing the manager.
Closing a pane only hides its view: a curved Genie animation draws it into
Harnesses while the process continues. A bounded GPU snapshot animates while the
live terminal stays mounted at its original size. macOS Reduce Motion skips it.
Offline and shared harnesses expose their state without offering process controls.
Errors remain beside the affected row, and an uncertain resume checks its original
receipt rather than starting the process twice.
## Open media from agent output
Hold **⌘ and click** on macOS, or **Ctrl and click** on Linux, to open an
image/video path in the OS default app. HTTP(S) links open in the default browser.
Hover over a recognized path to see the shortcut and full target. Normal clicks,
text selection, copy/paste and terminal mouse input keep their existing behavior.
Local previews support absolute paths, `~/...` and `file://...` URLs, including
spaces, Unicode, visible Markdown links and terminal soft wraps. The file must
already exist. Relative paths need a full path because CLI agent frames do not
currently include the working directory.
For a remote agent, the same shortcut downloads the file over the existing E2EE
connection and opens the completed local copy in the OS viewer. The remote
machine must run a CLI advertising `mediaPreview`; older CLIs show update guidance.
Remote relative paths resolve inside that agent's working folder; absolute paths,
`~/...`, and `file://...` resolve on the remote machine, including artifacts in `/tmp`.
The pane shows download progress and Cancel. Closing/changing panes cancels the
download. An interrupted transfer or a file changed during transfer is never opened.
Previews are limited to 512 MiB per file and downloaded in bounded chunks. Copies
live in `~/.harness/desktop-app/media-previews`; before each download, inactive
copies older than 24 hours or over the 1 GiB cache budget are pruned. Cache names
are unique, so matching paths on different machines cannot overwrite one another.
This reads visible terminal text, not hidden OSC 8 hyperlink targets.
The optional A/B smoke test uses isolated identities, two loopback WebSockets,
the CLI's real E2EE handshake/media reader and ffmpeg-generated PNG/MP4 fixtures:
```bash
REMOTE_MEDIA_CLI_ROOT=../openharness/cli flutter test test/remote_media_smoke_test.dart
```
Install the companion CLI's npm dependencies first; ffmpeg must be on PATH.
The smoke test does not use a real account or remote machine. It verifies the OS
launch URI; playback in the native viewer is a separate manual check.
## Viewers on linked machines
Open a harness on a linked machine and its viewer appears beside the terminal. The local CLI
forwards it through the existing encrypted machine connection, including interactive controls,
streaming updates and WebSockets. Both computers need a forwarding-capable Harness CLI. An older
remote CLI shows update guidance in the viewer pane; reconnect after updating it.
The local viewer endpoint is private to the machine connection and closes on disconnect or
revocation. This feature uses your existing machine access; it does not create a public share link.
Embedded viewers remain macOS-only. See the
[remote viewer plan](../docs/plans/2026-09-17-004-remote-viewers.md) for compatibility and tests.
## Local Codex profiles
New Agent → Codex discovers local profiles when the Harness CLI advertises
`supportsCodexHome`. The picker appears only when there are at least two distinct
profile folders; **Default** does not count as another profile. A single profile
is selected automatically, while no profiles keeps the normal launch. Linking
and refreshing remain available in both cases.
Discovery combines `CODEX_HOME` from the app environment, homes
observed on this computer's Codex agents, Codex-named folders in home/XDG config
with an existing `auth.json` or `config.toml` (including `.codex2` and
`.codex_work`), and directories explicitly linked before. An empty default
directory does not create a second profile.
It also reads literal `CODEX_HOME` declarations in bash/zsh/fish startup files,
aliases, functions, sourced files, and executable shell wrappers in local bin/PATH
directories. Shortcut names do not have to contain "codex". `$HOME`, `${HOME}`,
tilde and simple directory variables are supported; symlinks are deduplicated.
Discovery never executes shell configuration or shortcuts and never reads Codex
credentials. Shell scanning stops after 3 seconds, 256 small scripts, or four
levels of script references. Computed paths, unsupported shell syntax and profiles outside
these sources can be added with **Link a profile folder…**. Choose the actual
`CODEX_HOME` directory, not the shortcut executable or a named configuration
preset. Only linked paths are saved. **Refresh profiles** rescans without changing
the current choice; new local agent homes also update an open picker.
The selected directory supplies that agent’s Codex login, configuration, hooks,
history and model cache, and stays attached across restarts. The terminal header
shows its folder name and exposes the full path in a tooltip. **Default** keeps
the machine’s normal launch behavior. This picker applies to local agents using
Codex’s own account; remote machines use their existing flow.
The rail’s Codex usage panel still reports the default `~/.codex` profile.
This requires the companion CLI support for `agent_create.codexHome`. Older CLIs
show update guidance and keep default launches available; Desktop refuses an
explicit profile when support is missing rather than silently using another login.
## Local and production terminal E2E
The terminal E2E scripts exercise this desktop client together with source
checkouts of the Harness backend and CLI. The CLI is this repo's own `cli/`;
the backend is a sibling `autonomous-code` checkout. Their default layout is:
```text
.../autonomous-ai/
autonomous-code/
openharness/
cli/
backend/
desktop/ <- this app
```
Set `AUTONOMOUS_CODE_ROOT` when the backend checkout is elsewhere and
`HARNESS_REPO_ROOT` when the Harness CLI checkout is elsewhere (it defaults to
this repo's root, i.e. `desktop/..`).
```bash
bash scripts/start-terminal-local-manual.sh
bash scripts/test-terminal-local-e2e.sh
PROD_TERMINAL_E2E=1 ... bash scripts/test-terminal-prod-e2e.sh
```
The production script deliberately requires release, deployment, machine, and
commit evidence before it sends terminal traffic to production.
## Autonomous device pairing
Settings → Devices discovers Autonomous devices on the same network using the
CLI's `_autonomous._tcp` discovery, reusing the device's existing advertisement. Start pairing on the Autonomous
device to generate its code, select that device in Desktop, and enter the code.
The Mac connects directly to the selected device without backend routing or a
manually entered IP address. The device needs no backend credentials; Harness’s
existing Mac login/start requirements remain unchanged.
The pairing form is one shared settings row: device picker with an adjacent refresh
icon, code field and Pair button. The form aligns with the title at the top; a
visible note explains that closing Desktop leaves the connection running.
Desktop uses `harness autonomous-device discover --json` to populate the picker.
The CLI resolves the selected discovery ID to its host and port. Pairing runs
`harness autonomous-device pair --code-stdin --device <discoveryId> --json` through
`HarnessCliRunner`; the code travels through stdin only, never argv or logs.
Code normalization matches the original Harness pairing implementation, including
Crockford aliases and separators. The original PAKE handshake authenticates the
connection. Changing or losing the selected discovery identity clears entered
code, and a code mismatch remains visible through background refreshes. A mismatch
consumes the device pairing window: generate a new code before retrying. Rate
limits require waiting five minutes before another attempt. Desktop allows the
pair command fifty seconds to finish, beyond the CLI’s bounded handshake deadline.
`status` and `list` report direct connections and saved device identities.
Revocation requires confirmation and targets the complete saved fingerprint.
Closing Desktop leaves the CLI daemon running. Discovery and status refresh every sixty seconds, including when no device is
paired. Use Refresh to discover a newly started device immediately. Pasted codes
may include separators, for example `ABC-123`. Older CLIs show `harness update`
guidance. Widget tests inject a fake CLI, and the `kUnderTest` gate prevents real
processes and background polling.
## Releases
The application self-updates from the Harness desktop metadata manifest in the
public GCS release bucket. Release commands stay in this repository:
```bash
make upload-desktop # macOS
make upload-desktop-linux # Linux (ARM64 or x64) — must run on the matching Ubuntu build host
make upload-desktop-linux ARCH=arm64
make upload-desktop-linux ARCH=amd64 # amd64 is the x64 artifact
make upload-node-runtime ARGS="22.23.2"
```
See [RELEASE.md](RELEASE.md) for signing, notarization, versioning, managed
Node runtime publishing, safe test releases, and rollback behavior.
Pairing failures use the original Harness manager's validation and attempt limits.
If the device code expires, start pairing again on the Autonomous device.
## App focus and device voice routing
The selected terminal pane is the source of agent focus for the CLI's paired-device
voice mode and the OS Monitor Pairing page. Desktop announces `app_focus` with its
`agentId` through the existing local CLI WebSocket, and reasserts the selected pane
after reconnect. Opening an unrelated terminal or changing which macOS/Linux
window is frontmost does not select another voice agent. Closing the selected pane
announces the replacement pane; closing the last pane or selecting a machine-only
pane sends `app_focus` with `agentId: null`. Switching machines clears the previous
connection's focus before announcing the new target. This requires the CLI version
that publishes app focus to paired devices; there is no separate voice-agent picker
in Desktop.
### Đồng bộ agent đang focus và giọng nói từ device
Pane terminal đang được chọn là nguồn focus cho voice mode của device đã pair và
trang Monitor Pairing của OS. Desktop gửi `app_focus` kèm `agentId` qua WebSocket
local CLI hiện có, và gửi lại pane đang chọn sau khi kết nối lại. Mở terminal khác
ở nền hoặc đổi cửa sổ macOS/Linux ở phía trước không chọn lại voice agent. Đóng
pane đang chọn sẽ thông báo pane thay thế; đóng pane cuối hoặc chọn pane chỉ có
machine sẽ gửi `app_focus` với `agentId: null`. Khi đổi machine, Desktop xóa focus
trên kết nối trước rồi thông báo target mới. Cần phiên bản CLI có hỗ trợ chia sẻ
app focus cho device đã pair; Desktop không có bộ chọn voice agent riêng.
710fbeaaeThis file is pinned to the selected release. Download the original to open it in your design tool.