<!--
  scaffold: workspace-server.md
  bucket: platform-tooling (Bucket 7)
  what belongs here: workspace server operations.
    - Default port (4200).
    - viewer.html for long content.
    - `pa workspace start / stop / status / restart / open`.
    - Supervisor-aware lifecycle (launchd / systemd).
    - Point at packages/core/docs/workspace-operations.md.
-->

# Workspace server

## Purpose

The workspace server hosts `viewer.html` — the PA's canonical surface for long-form content, structured data, tables, and reports. Direct the operator to `http://localhost:<port>/viewer.html?file=path/to/file.md` instead of pasting long output into chat.

## Verbs

| Verb | Purpose |
|---|---|
| `pa workspace start [--port N] [--no-open]` | Start the workspace server. |
| `pa workspace stop` | Stop the server (refuses if supervised — see below). |
| `pa workspace status` | Show server status (supervisor-aware). |
| `pa workspace restart [--port N] [--no-open]` | Restart. Supervisor-aware — launchctl kickstart / systemctl restart. |
| `pa workspace open` | Open the workspace URL in a browser. |

## Default port

`4200`. Configurable via `operator/config/preferences.json:workspacePort`.

<!-- OPERATOR: name your workspace port here if it's not 4200. -->

## Supervisor-aware lifecycle

When the workspace is supervised by launchd (`~/Library/LaunchAgents/com.<paName>.workspace.plist`) or systemd (`~/.config/systemd/user/<paName>-workspace.service`), `stop` is refused and `restart` delegates to the supervisor. This is the in-place version-pickup path after `pnpm update @stravica-ai/digital-operator-pa`. Unit labels follow the scheduler's `com.{agent}.{id}` convention with `id = workspace` and `agent` resolved from `paName` in `operator/config/preferences.json`; pre-0.1.44 installs are still recognised under the legacy `com.dave.workspace` / `dave-workspace.service` name until you run `install-daemon install --migrate` to rename.

## When to use the workspace

- **Long-form content** — anything more than a few paragraphs.
- **Structured data / tables** — anything that renders better in HTML than in a chat line-wrap.
- **Reports** — session reports, dispatch outcomes, project progress trackers.

## Full operations reference

`packages/core/docs/workspace-operations.md`.

## Related

- CLAUDE.md.template Bucket 7 rule 5.
- `packages/core/docs/workspace-operations.md`.
