feat(ui): preview port menu, terminal auto-start, and project actions tabs

This commit is contained in:
Chris Scott committed 2026-10-04 01:34:57 -04:00
1 parent cf9fa61118
commit 62e36eb3b2
31 files changed
+1332 -489

No files matched your search

+13 -5
View File
@@ -6,11 +6,13 @@ The Preview panel lists the loopback ports that are currently listening, then pr
## Port List
Open **Preview** from the desktop sidebar tool list or the **More** drawer, including in the Assistant workspace. The panel lists every listening loopback port on the host, with its port number and process command. On Linux hosts (including the Docker image) it also shows each process's working directory, and ports inside the selected repository or workspace directory are badged **this repo** and sorted first. On macOS the working directory is not available, so no port is badged. Other platforms list no ports.
Open **Preview** from the desktop sidebar tool list or the **More** drawer, including in the Assistant workspace. The port menu at the start of the toolbar lists every listening loopback port on the host as `:PORT command`, with the process's working directory underneath. Type in the menu to filter by port, command or directory. Working directories are read on Linux hosts (including the Docker image) and macOS; ports whose process runs inside the selected repository or workspace directory are grouped under **This repo** at the top, and the rest under **Other ports**. Other platforms list no ports.
Until a port is selected, the panel body lists the dev servers of this repo so one click opens the preview, and counts the other listening ports. When nothing is listening, it points to the Terminal and Actions to start a dev server.
The list excludes reserved ports — the Manager port (`PORT`, default 5003), the OpenCode server port (default 5551) and the preview gateway port itself — and only includes ports at or above 1024. Any other listening loopback port can be previewed; there is no per-port allow-list. This grants nothing an authenticated user does not already have, because the [Terminal](terminal.md) can reach the same ports.
While the port list is shown it refreshes every 2 seconds. It stops refreshing while a preview is open.
Until a preview is open, the port list refreshes every 2 seconds. While a preview is open it refreshes only when you open the port menu.
Selecting a port creates a preview session and renders the target in an iframe on the gateway origin. The iframe keeps that origin (`allow-same-origin`) so dev servers can use cookies and storage; isolation from the Manager comes from the separate origin, not from an opaque sandbox. Selecting a different port starts a new session for it.
@@ -44,16 +46,17 @@ A browser can hold one preview target per gateway origin at a time: the `ocm_pre
A preview can be opened from more than one place:
- **Port list** — select a port in the panel.
- **Port menu** — pick a port in the toolbar, or a dev server listed in the panel body.
- **Terminal links** — clicking a local dev URL (`http://localhost:PORT`, `127.0.0.1`, `0.0.0.0`, or `[::1]`) printed in a terminal opens the Preview panel at that port and path instead of a new browser tab. External links still open in a new tab.
- **Project actions** — an action's resolved URL opens in the Preview panel when **Auto-open URL** is enabled.
## Toolbar
- **Port** — the port menu described in [Port List](#port-list). Press Escape to close the menu without closing the panel.
- **Path** — enter a path and press **Go** (or Enter) to start a session for that path.
- **Reload** — remounts the iframe.
- **Open in new tab** — creates a fresh session and opens its start URL in a new tab with `noopener`. Start tokens are single-use, so this always mints a new one.
- **Viewport** — switch between Mobile (390 px), Tablet (820 px), and Full width.
- **Viewport** — switch between Mobile (390 px), Tablet (820 px), and Full width. Hidden on small screens, where the panel is already phone-width.
## Behind HTTPS or a Reverse Proxy
@@ -62,7 +65,12 @@ By default the panel builds the gateway origin as `${location.protocol}//${locat
- **Mixed content** — an `https://` page cannot embed an `http://` preview.
- **Third-party cookies** — the `ocm_preview` cookie is blocked in a cross-site iframe.
Set `PREVIEW_PUBLIC_URL` to a same-site HTTPS origin that proxies the preview gateway, for example `https://preview.example.com`. Do not add it to `AUTH_TRUSTED_ORIGINS` (see [Isolation level](#isolation-level)). The panel then builds preview URLs from that origin instead. As a fallback, **Open in new tab** opens the preview as a top-level page, where the session cookie is first-party.
Set `PREVIEW_PUBLIC_URL` to a same-site HTTPS origin that proxies the preview gateway, for example `https://preview.example.com`. Do not add it to `AUTH_TRUSTED_ORIGINS` (see [Isolation level](#isolation-level)). The panel then builds preview URLs from that origin instead, however the Manager itself was opened. As a fallback, **Open in new tab** opens the preview as a top-level page, where the session cookie is first-party.
!!! warning "Turn off caching for the preview origin"
The gateway passes the dev server's cache headers through unchanged, and every port shares the one preview origin. A CDN or caching proxy in front of the gateway can therefore serve stale files, mix files between projects, and serve cached files without the preview login. Bypass caching for the preview hostname.
For a complete setup through a Cloudflare Tunnel, including the cache rule and Cloudflare Access, see [Cloudflare Tunnel](../configuration/cloudflare-tunnel.md).
## Related
+4 -4
View File
@@ -81,7 +81,7 @@ Project actions are not available in the Assistant workspace.
## Moving Actions and Setup Commands
The Project Actions dialog moves items between personal settings and the repository file:
The Project Actions dialog moves items between personal settings and the repository file from each row's **⋯** menu:
- **Move to repository** writes the item into `.ocm/project.json` and removes it from personal settings. Because the user authored it, the file is trusted automatically.
- **Move to my settings** removes the item from `.ocm/project.json` (deleting the file if it becomes empty) and stores it in personal settings.
@@ -93,10 +93,10 @@ Moves are transactional: if the file write or the settings update fails, the fil
Commands in `.ocm/project.json` run on your machine, so the Manager does not run them until you trust the file:
- Trust covers everything in the file that can run or open: each action's `id`, `name`, `command`, `url` and `autoOpenUrl` (including actions hidden because a personal action has the same `id`), plus every setup command. Changing any of these resets trust; changing an icon does not.
- Both trust prompts — **Trust these commands** in the dialog and **Trust and run** in the header menu — list every action and setup command that trusting covers, not only the one you clicked.
- Both trust prompts — **Review** in the dialog and **Trust and run** in the header menu — list every action and setup command that trusting covers, not only the one you clicked.
- Trusting requires echoing the exact hash of the content shown, so a file cannot be swapped between review and trust.
- Untrusted repository commands never run — not from the header menu, and not as worktree setup commands.
- The dialog shows the untrusted commands and a **Trust these commands** button. Attempting to run an untrusted action prompts for trust first.
- The dialog shows a banner above its tabs while the file is untrusted. **Review** lists the untrusted commands, and **Trust these commands** confirms. Attempting to run an untrusted action prompts for trust first.
- Moving an item into the file auto-trusts it, because the user authored it.
## Worktree Setup Commands
@@ -105,7 +105,7 @@ Setup commands run once after a new working directory is created — Manager wor
- `$ROOT_PROJECT_PATH` is available in the environment and points at the repository's main checkout.
- Personal setup commands always run. Repository setup commands are skipped while the file is untrusted; the skipped result is reported.
- Setup commands are configured in the **Worktree setup** section of the Project Actions dialog.
- Setup commands are configured in the **Worktree setup** tab of the Project Actions dialog. Edits are saved together with **Save setup**, which is enabled once there are unsaved changes.
## Related
+1 -1
View File
@@ -9,7 +9,7 @@ Open the terminal from either surface:
- **Desktop sidebar** — click **Terminal** in the tool list for a repository or session.
- **More drawer** — on mobile or from the overflow menu, open **More** and select **Terminal**.
The terminal panel opens as a dialog. If no terminal exists for the selected directory yet, the panel starts one automatically.
The terminal panel opens as a dialog. If nothing is running in the selected directory, opening the panel starts a shell automatically; exited terminals do not count. Opening a specific terminal — such as a project action or worktree setup — shows that terminal instead and starts nothing extra.
Terminals are scoped to the selected repository or OpenCode workspace directory. A terminal opened from a repo runs in that repo's path; a terminal opened from a session runs in the session's working directory. Switching directories shows that directory's terminals.