---
lastModified: 2026-12-02
---

# Portals & Desktop

Portals are authenticated URLs that expose web servers running inside an orb, so you can open a
dev server or preview app straight from the thread's **Portal** tab. Threads on your own
machines can share portals too, except on Windows for now; see
[Portals on Your Runner](/docs/cli/runners#portals-on-your-runner).

![An Amp thread with its Portal tab open beside it](https://static.ampcode.com/docs/portals.png)

You can navigate in portals just like in browser. And you can also annotate what you see and send
your comments directly to the agent:

<!-- prettier-ignore -->
<video controls autoplay muted loop playsinline width="1440" height="830" src="https://static.ampcode.com/docs/portal-review-comments.mp4" type="video/mp4"></video>

The easiest way to get started is to ask Amp:

```prompt
Start the dev server and give me a portal link.
```

Screencast (Orbs from Zero, episode 2): [Review Your App Through Portals](/docs/using-amp/screencasts/orbs/portals-in-orbs). Open the dev server in a portal, comment on the page itself to send the agent changes, and check the result live.

## Put Each Responsibility in the Right File

| File                  | Purpose                                                                                     |
| --------------------- | ------------------------------------------------------------------------------------------- |
| `.agents/setup`       | Prepare a new orb by installing dependencies, generating files, and checking required tools |
| `.agents/resume`      | Perform optional, quick authentication or repair work after activation and each wake        |
| `.amp/services.yaml`  | Declare long-running services and their portal links                                        |
| `.amp/portals/*.json` | Store generated portal links for the current orb and thread                                 |

Use `.agents/setup` for work a fresh orb needs before an agent starts. Make the script executable
and safe to run more than once:

```bash
#!/usr/bin/env bash
set -euo pipefail

npm ci
```

```bash
chmod +x .agents/setup
```

Do not start a development server or run `amp orb services ensure` from `.agents/setup`. Setup
prepares the environment. `.amp/services.yaml` owns the lifecycle of long-running services.

Most repositories do not need `.agents/resume` for portals. Add it only for quick, idempotent
repair work that Amp cannot supervise as a service, such as reconnecting a tunnel. Amp starts this
hook after initial orb activation and whenever the orb wakes. Amp waits for up to 10 seconds before
it lets the agent continue. Do not install dependencies or restart declared portal services in
this hook.

Read [Customizing Orbs](/docs/orbs/customizing) for complete setup and resume examples and their log
locations.

Amp generates `.amp/portals/*.json` when it ensures a service. Edit `.amp/services.yaml`, not the
generated file, when you want to change a declared service or its links. Ignore generated portal
state in Git:

```text
.amp/portals/
```

## Define Services

Commit `.amp/services.yaml` so every orb knows how to run the repository's development services:

```yaml
services:
  web:
    command: pnpm dev -- --host 0.0.0.0 --port "$PORT"
    cwd: app
    health: /healthz
    env:
      API_MODE: development
    review: true
    portal:
      url: /
      title: App
      description: Use the seeded development account.
    portals:
      - url: /admin
        title: Admin
        description: Open the administration tools.
```

The file needs a nonempty top-level `services` mapping. Service names can contain lowercase letters,
numbers, and hyphens. A name must start with a letter or number and can have up to 32 characters.

Each service supports these fields:

| Field       | Purpose                                                                                                      |
| ----------- | ------------------------------------------------------------------------------------------------------------ |
| `command`   | Required shell command. It runs through a login shell. A service with a portal must listen on `$PORT`.       |
| `cwd`       | Working directory relative to the repository root. It defaults to the repository root.                       |
| `port`      | Fixed local port from 1 to 65535. Omit it to let Amp choose a free port that stays the same across restarts. |
| `env`       | String environment variables for the command. Values can refer to another service's public URL.              |
| `health`    | HTTP path Amp requests after the port opens. HTTP 2xx and 3xx mean ready.                                    |
| `portal`    | Primary portal link. Use `true` for `/` with the service name, or provide link details.                      |
| `portals`   | More portal links for the same service. Each entry needs `url` and `title`.                                  |
| `review`    | Whether Amp injects the review widget. It defaults to `true`.                                                |
| `platforms` | Optional nonempty list of `linux` or `darwin` (macOS). Omit it to run on all platforms.                      |

Services without `platforms` run on all platforms. Use `platforms: [linux]` for a Linux-only service
or `platforms: [darwin]` for a macOS-only service. Amp skips services that exclude the executor's
operating system and does not show their declared portal links. If no services match, ensure
succeeds without starting anything. Services referenced through `env` must also match the
executor's platform. An explicit empty list is invalid.

```yaml
services:
  simulator:
    platforms: [darwin]
    command: ./scripts/serve-ios-simulator
    portal: true
```

A portal `url` can be a path that starts with `/` or an absolute HTTP or HTTPS URL. A primary
`portal` mapping defaults to `/` and the service name when you omit `url` or `title`.

Amp manages `PORT`, `PUBLIC_URL`, and `AMP_THREAD_ID`, so you cannot set them inside `env`. Every
service receives `PORT` and `AMP_THREAD_ID`. A service with at least one portal link also receives
`PUBLIC_URL`.

`$AMP_USER_EMAIL` is the only placeholder supported in a portal entry. Amp replaces it in the
`url`, `title`, and `description`. It URL-encodes the value when it appears in `url`.

## Start Declared Services

Run every declared service from the repository root:

```bash
amp orb services ensure
```

Ensure reads `.amp/services.yaml`, checks each service, starts anything missing, and waits for
readiness. It then writes the Portal tab state and prints the exact portal URLs. The Portal tab also
runs ensure when you open a declared portal that has not started yet.

Use the printed URL. Do not use a raw localhost URL, construct a portal hostname, or save one in
configuration. When an application needs its public origin, read `PUBLIC_URL` at runtime.

For scripts that need structured service status, run:

```bash
amp orb services ensure --json
```

## Add Health Checks

Without `health`, Amp considers a service ready when its port accepts a connection. Set `health`
when the application needs more time after opening the port:

```yaml
services:
  web:
    command: pnpm dev -- --host 0.0.0.0 --port "$PORT"
    health: /healthz
    portal: true
```

Amp sends a GET request to the path. HTTP 2xx and 3xx responses pass the check. A configured portal
URL can exist even when readiness fails, so the URL alone does not prove that the app responded.

## Connect Declared Services

One service can use another service's final public URL through an `env` reference:

```yaml
services:
  api:
    command: go run ./cmd/api
    env:
      FRONTEND_URL: ${services.web.publicURL}
  web:
    command: pnpm dev -- --host 0.0.0.0 --port "$PORT"
    portal: true
```

Amp starts the referenced service first and replaces the reference with its final URL. The
referenced service must have a portal. References to missing services and dependency cycles are
rejected.

For separate frontend and API services, expose the frontend and route API requests through the
frontend development server's proxy. Browser requests between two portal hosts are not supported
because CORS preflight requests do not carry portal authentication.

Use a folder to group related links while leaving other links at the top level:

```yaml
services:
  web:
    command: pnpm dev
    portal: true
    portals:
      - folder: Marketing site
        links:
          - url: /home
            title: Homepage
          - url: /pricing
            title: Pricing
      - url: /storybook
        title: Storybook
```

`amp orb services ensure` also writes the Portal tab's links to `.amp/portals/*.json`. To add
custom links, write a separate manifest by hand. Service-generated manifests are an implementation
detail, so edit `.amp/services.yaml` instead of editing them. Get each custom URL from
`amp orb portal 3000` (pass the local port) instead of hardcoding the domain format:

```json
{
	"links": [
		{
			"label": "App",
			"url": "https://t-…-p3000.onamp.dev",
			"note": "Use the seeded test account."
		},
		{
			"folder": "Admin",
			"links": [
				{ "label": "Users", "url": "https://t-…-p3000.onamp.dev/admin/users" },
				{ "label": "Settings", "url": "https://t-…-p3000.onamp.dev/admin/settings" }
			]
		}
	]
}
```

A link's optional `note` is shown as an info popover next to it. A folder can contain links one
level deep, and each folder name must be unique within a service. The Portal tab shows the folder
as a menu and keeps other links at the top level.

## Manage Services

Use these commands to inspect and control supervised services:

```bash
amp orb service list
amp orb service status web
amp orb service logs web
amp orb service restart web
amp orb service stop web
```

Restart a declared service after changing its command, dependencies, or source when the development
server does not reload that change itself. Restart reads the latest `.amp/services.yaml` and keeps
the service's port and portal configuration.

Do not use `nohup`, `setsid`, a background `&`, or tmux to keep a portal server alive. Processes
started that way can be stopped when Amp updates or the orb resumes. Use a supervised service.

## Start a One-Off Service

Use `amp orb service start` for a service needed only in the current thread:

```bash
amp orb service start app \
  --command 'npm run preview -- --host 0.0.0.0 --port "$PORT"' \
  --portal \
  --title 'App' \
  --description 'Use the seeded development account.'
```

The outer quotes keep the shell from expanding `$PORT` before Amp supplies it. You can also pass
`--cwd` or `--port`. With `--portal`, Amp waits for the listener, detects HTTP or HTTPS, writes
`.amp/portals/<name>.json`, and prints the URL.

Amp waits up to 60 seconds for that port, so a hardcoded wrong port causes a long wait followed by
`NOT RESPONDING` and exit status 1. The reported port is the app's internal port. The `p<number>` in
the public URL may differ because it identifies Amp's Portal proxy. A manifest and URL may still be
printed after a readiness failure. They mean the link was configured, not that the app responded.
Check `amp orb service logs <name>`.

The start command rejects a name already declared in `.amp/services.yaml`. Use ensure or restart
for declared services. If a one-off service will be useful in future orbs, move its configuration
into `.amp/services.yaml`.

`amp orb portal <port> --title 'App'` is a lower-level command for a server that is already
listening. It creates or prints a portal URL and registers it in the Portal tab. Add `--description`
when people need setup or usage notes. It does not start or supervise the server. Prefer declared
services for repository development servers.

## Choose a Portal Hostname

Portal URLs are generated subdomains of `onamp.dev` by default. To give one portal a specific
hostname, run `amp orb portal <port> --hostname <hostname>` with a managed hostname like
`<name>--<namespace>.onamp.dev` or a hostname on a custom domain from your personal or workspace
**Domains** settings page. Add the domain there, create the DNS records shown, and wait until
the domain is Active. The hostname applies only to that port. Outside the orb, such as in
[Puck](/docs/puck), the agent uses the `manage_amp` tool with topic `portals` and operation
`set-hostname`; inside the orb, the command above also updates the portal's manifest.

To make one of your domains the default for portals, select **Make Default for Portals** on an
active domain on your personal or workspace **Domains** page. New portal links then use
subdomains of that domain, such as `t-<thread>-p<port>.portal.example.com`, so your people only
need to trust links on your own domain. A workspace default applies to the workspace's projects.
A personal default applies to your personal projects and to your threads outside any project.
Existing URLs keep working.

A project can also choose its own default portal domain under **Portals** on its **Orb** settings
page, from the active domains of the project's owner. Without a choice, the project follows its
owner's default portal domain. An agent can change it with the `manage_amp` tool (topic
`projects`, operation `update`, `default_portal_domain`). Portal links under a domain the project
no longer uses stop working, unless it is the owner's default.

## Reuse a Custom Hostname

A custom hostname stays assigned when you archive its thread. To move it to a portal in another
thread, run this command inside the new thread's orb:

```bash
amp orb portal <port> --hostname <hostname> --take-over
```

Amp moves the hostname from the other thread portal to the current portal. You can take over only a
hostname that the new thread can use. Without `--take-over`, Amp reports that the hostname is
already in use.

To keep serving the app at the same hostname without an orb, move it to an app on a
[box](/docs/boxes#custom-domains) with `amp boxes deploy --domain <hostname> --take-over`. A portal
cannot take a hostname back from a box app.

## Review and Comment

Open the portal from the thread's **Portal** tab. The floating review button lets you select an
element and send a comment to the thread. Amp receives your comment with the selected text and page
location. It also receives the source location when the app can provide one. When the portal is
open in its own browser tab, the arrow button next to the review button opens the thread.

To start a comment from the keyboard, press <kbd>Cmd</kbd>+<kbd>Shift</kbd>+<kbd>.</kbd> on macOS
or <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>.</kbd> on other systems, then click an element. Press the
same keys or <kbd>Esc</kbd> to cancel. <kbd>Cmd</kbd>+<kbd>.</kbd> (<kbd>Ctrl</kbd>+<kbd>.</kbd>)
hides or shows the review button.

Portal comments work well for visual fixes because you can point at the exact part of the running
app instead of describing its location. To use the same widget on your deployed website, see
[Feedback Widget](/docs/feedback-widget).

The review widget is enabled by default. Disable it for every page in one service with:

```yaml
services:
  web:
    command: pnpm dev -- --host 0.0.0.0 --port "$PORT"
    review: false
    portal: true
```

Disable it for one response with this header:

```text
x-amp-review-widget: off
```

<details>
<summary><strong>Vite Reconnects Across Amp Deploys (Agent Instructions)</strong></summary>

Portal WebSockets pass through Amp's servers. Each Amp deploy replaces those servers and closes
every open portal WebSocket. Vite reloads the page whenever its HMR socket closes, so without help
an open Vite portal would reload on every Amp deploy and lose unsaved form input.

To avoid that, Amp injects a short inline script with the review widget, before the page's first
`<script>` tag. It wraps
`window.WebSocket` and changes only sockets opened with Vite's `vite-hmr` subprotocol. A server
that is shutting down closes those sockets with close code `4012` and the reason
`amp-portal-restart`, and the script opens a new connection without telling the page. Every other
close still reaches Vite, so restarting the dev server still reloads the page. Other sockets are
not changed.

The script does not run when the review widget is off for the page, or when the page's
Content-Security-Policy blocks inline scripts. Then Vite reloads the page during Amp deploys. Such
a page can load the same script from Amp in development, with a plain `<script>` tag (no `async`
or `defer`) in `<head>` before its other scripts:

```html
<script src="https://ampcode.com/api/app-kit/v1/portal-websocket-restart.js"></script>
```

It does nothing outside a portal, and nothing when Amp's injected copy already ran. To add it only
while Vite serves the app, use a plugin in `vite.config.ts`:

```ts
plugins: [
	{
		name: 'amp-portal-websocket-restart',
		apply: 'serve',
		transformIndexHtml: () => [
			{
				tag: 'script',
				attrs: { src: 'https://ampcode.com/api/app-kit/v1/portal-websocket-restart.js' },
				injectTo: 'head-prepend',
			},
		],
	},
],
```

If the page has a Content-Security-Policy, let its development policy load the script:

- A policy that lists allowed hosts: add `https://ampcode.com` to `script-src` (or to
  `default-src` when it has no `script-src`) where the dev server sets the policy, such as Vite's
  `server.headers` or a `<meta http-equiv="Content-Security-Policy">` tag.
- A policy with nonces or `'strict-dynamic'`: give the tag the page's nonce. Browsers ignore host
  lists under `'strict-dynamic'`. Vite adds the nonce to every `<script>` tag, this one included,
  when `html.cspNonce` is set.

Production needs neither the tag nor the policy change.

To opt out, set this before the page opens its Vite socket, for example in an inline script in
`index.html`:

```html
<script>
	window.ampPortalWebSocketRestart = false
</script>
```

If a portal page reloads by itself, open the browser console. `[vite] server connection lost`
followed by a reload means Vite's socket closed. A reload during an Amp deploy means the script did
not run on that page.

</details>

## Link Back to Amp

Use `target="_amp"` on a link to let a person leave the Portal pane and open an Amp page in the
containing Amp app:

```html
<a href="https://ampcode.com/threads/T-..." target="_amp">Open the thread in Amp</a>
```

## Handle Development Sign-In

### Vite

When Amp starts a portaled service, it sets `__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS` to the Portal
domain, such as `.onamp.dev`. Vite 6.1 and later add that domain to `server.allowedHosts`, so most
projects do not need any Vite configuration for Portals.

If the project's Vite config overrides this behavior and blocks the Portal hostname, allow all
hosts only inside an orb:

```js
export default defineConfig({
	server: {
		allowedHosts: process.env.AMP_ORB ? true : undefined,
	},
})
```

Keep the existing configuration and plugins when adding this setting. Do not allow every host
outside an orb.

### Laravel

Start Laravel from `.amp/services.yaml`, where `$PUBLIC_URL` is available. Assign it at runtime;
never save a generated portal hostname:

```yaml
services:
  web:
    command: >-
      php artisan optimize:clear &&
      APP_URL="$PUBLIC_URL" ASSET_URL="$PUBLIC_URL"
      php artisan serve --host=0.0.0.0 --port="$PORT"
    portal: true
```

Amp supplies the public Portal `Host` and standard forwarded HTTPS headers. Use Laravel's normal
trusted-proxy handling; do not inspect provider-specific headers or replace `Request::capture()`.
Clear Laravel configuration and any full-response cache before listening whenever the public
origin changes.

### Dev Magic Link Authentication

OAuth, email links, and password managers make repeated development sign-in difficult for both
agents and reviewers. Add a development-only route such as:

```text
GET /__dev/log-me-in/<email>?returnTo=<path>
```

The route should find the user with the given email address, or create the user if absent. Create a
session and set the application's normal session cookie, using the same cookie name and options as
the real sign-in flow. Redirect to a relative path on the same origin. Reject absolute and
protocol-relative return URLs to prevent open redirects. If `returnTo` is missing or not safe,
redirect to `/`. Return 404 outside local development by checking both the framework development
flag and that `NODE_ENV` is not `production`. Do not include the route in production builds.

Put an example URL and test account in `AGENTS.md` so agents can discover them. A request made with
`curl` does not sign in the browser, so open the URL in the browser session used for testing.

You can make the development login the primary portal link without hardcoding an email:

```yaml
services:
  web:
    command: pnpm dev -- --host 0.0.0.0 --port "$PORT"
    portal:
      url: /__dev/log-me-in/$AMP_USER_EMAIL?returnTo=/
      title: App
      description: Sign in as $AMP_USER_EMAIL.
```

Screencast (Orbs from Zero, episode 3): [Add a Dev Sign-In for Agents](/docs/using-amp/screencasts/orbs/add-a-dev-sign-in). Give agents and portal viewers a development sign-in route so nobody types a password in an orb again.

### Native Apps, Devices, and Other Servers

Before a portal reaches your application, it requires an Amp sign-in of its own. A browser
completes it with a redirect, but native apps, mobile simulators and devices, other servers, and
scripts cannot.

A portal URL is a public HTTPS address, so these clients can reach it from anywhere, including a
simulator on another machine or a phone in a cloud device farm. To test a mobile app against the
services in an orb, build or launch the app with portal URLs as its server addresses instead of
`localhost`. Each service gets its own portal hostname, which it reads from `$PUBLIC_URL`, and
other services can read it from [`${services.<name>.publicURL}`](#connect-declared-services).

Sign these clients in to the portal with a single-use sign-in link:

```bash
amp portal login-url https://t-...-p3000.onamp.dev/
```

The command runs in the orb or on any machine where the `amp` CLI is signed in, and applies the
same access check as the browser sign-in. It prints a link that works once and expires after
about 60 seconds, so create it immediately before the client opens it. Opening the link sets the
portal's session cookie and redirects to the portal page. The session lasts up to 12 hours and
covers only that portal's hostname, so create one link per portal the client uses.

Open the link in the same client that makes the later requests, such as the device's browser, the
first page an app's web view loads, or an HTTP client that keeps cookies. An app whose native
networking code does not share cookies with its web view must load the link with that networking
code too. For example, with `curl`:

```bash
curl -c cookies.txt -L "$(amp portal login-url "$PORTAL_URL")"
curl -b cookies.txt "$PORTAL_URL/api/health"
```

When you cannot control the first request a client makes, as on some device farms,
[make the portal public](#access-and-lifecycle) for a limited time instead.

To skip portals and their sign-in entirely, connect the client to the orb's network instead.
With [Tailscale](/docs/orbs/customizing#use-tailscale), the orb joins your tailnet, and
simulators, phones, and servers on the same tailnet reach its ports directly. A device farm's own
tunnel agent, such as BrowserStack Local, can also run in the orb so the farm's devices reach the
orb's local ports.

## Access and Lifecycle

Portal access is separate from application authentication. By default, only people who can view
the thread can access its portals. A multiplayer participant can use the portal for as long as
their access to that thread remains active.

To share a portal with anyone, open **Portal Options** (the **⋯** button in the portal toolbar),
open **Access**, and under **Make Public For** choose 1 hour, 3 hours, 1 day, or 7 days. Anyone with
the link can open the portal during that time without signing in to Amp. Public access applies only
to that port. The public link does not grant access to the thread or its review tools.

While a portal is public, **Access** shows when public access ends. Open it to choose a new duration
under **Keep Public For** or to select **End Public Access**. **Access** is unavailable, and its
tooltip says why, when the thread runs on a [self-hosted orb](/docs/orbs/self-hosted#public-portals)
whose provider has **Public Portals** turned off or when the workspace turns off **Allow Sharing
Outside the Workspace**.

You can also ask the agent to make a portal public or private. It uses the `manage_amp` tool with
topic `portals` and operation `set-public-access`, and asks you to approve in a dialog before a
portal becomes public or stays public longer. The `amp` CLI cannot change portal access, but
`amp orb portal list` shows which of a thread's portals are public and until when (the agent uses
operation `list`).

Amp sets `X-Amp-Authenticated` on requests sent through the external portal proxy. The header includes the following tokens, separated by commas:

- `amp-user=yes|no` says whether the visitor is a registered Amp user. The user may be outside the
  workspace.
- `workspace-member=yes|no` says whether the user belongs to the workspace that owns the thread.
- `collaborator=yes|no` is `yes` for the thread creator. For a multiplayer thread, it is also `yes`
  for anyone who can currently contribute to the thread, except contributors who must use a
  passkey for web and app interaction.

The possible values are:

- Unauthenticated visitor: `amp-user=no, workspace-member=no, collaborator=no`
- Amp user outside the workspace: `amp-user=yes, workspace-member=no, collaborator=no`
- Creator of a personal thread: `amp-user=yes, workspace-member=no, collaborator=yes`
- Workspace member: `amp-user=yes, workspace-member=yes,
  collaborator=no`
- Workspace member for a portal of a multiplayer thread who can currently contribute: `amp-user=yes, workspace-member=yes,
  collaborator=yes`

In most cases, you'll just want to check for string-includes `workspace-member=yes` to perform access control.

Amp also sends these user identification headers when the user is a workspace member or collaborator:

```text
X-Amp-User-ID: user_abcd1234
X-Amp-User-Display-Name: Ada Lovelace
X-Amp-User-Email: ada@example.com
X-Amp-User-URL: https://ampcode.com/@ada
```

Amp sends visible ASCII values unchanged. If one of these values contains other characters, Amp
percent-encodes the full value as UTF-8. Use `decodeURIComponent` to recover the original value.

Do not add `access` to `.amp/services.yaml`. The current format does not support it. Amp manages
portal access separately from the service definition.

Opening a portal wakes a paused orb. The orb resumes billing while the request and services are
active, then automatically pauses again when idle. Archiving the thread also pauses its orb. A dev
server page left open in a browser tab does not wake its orb again by itself.

<details>
<summary><strong>Which Portal Requests Wake a Paused Orb (Agent Instructions)</strong></summary>

Every portal request keeps a running orb awake, and almost every request wakes a paused one. The
exceptions are requests that a dev server's live reload client makes by itself after the orb
pauses. Without them, a dev server page left open in a browser tab would wake the orb every time
it paused.

These requests do not wake a paused orb:

- WebSocket connections, such as Vite's and Next.js's HMR sockets.
- A page load within 5 seconds after a WebSocket to the same portal failed because the orb was
  asleep. Next.js reloads the page right after its HMR socket fails to reconnect too many times
  in a row, and this rule keeps that reload from waking the orb. Vite does not reload until its ping socket connects, so a failed Vite ping
  does not count.
- Vite's HTTP ping (`Accept: text/x-vite-ping`, sent by older Vite versions) and the Next.js 12
  `/_next/webpack-hmr` event stream.
- The polls of Amp's own **Orb is asleep** page.

When one of these requests reaches a paused orb, a page load gets the **Orb is asleep** page and
other requests get a JSON error with the `x-amp-portal-error: sandbox-not-found` header. Select
**Wake Orb** on that page to wake the orb. The page checks every 5 seconds for 10 minutes, and
again whenever someone switches back to its tab, and reloads by itself once the orb is back.

If a person opens or reloads the portal within 5 seconds after a tab's live reload socket failed,
they also get the **Orb is asleep** page and need to select **Wake Orb**.

If an orb keeps waking while nobody uses it, look for a page that polls the portal with `fetch`, a
page that reloads itself on a timer, or an outside service that calls the portal URL. These still
wake the orb.

</details>

Inside the owning orb, requests to the thread's portal URL go directly to the local service. This
means browser automation, `curl`, Node.js, and Python can use `PUBLIC_URL` without a second portal
sign-in. This bypasses only Amp's portal authentication. It does not bypass authentication in the
application itself, and it does not test the external viewer sign-in flow. The app receives the
same public `Host` and standard forwarded HTTPS headers as through the external portal path.

Portals carry WebSocket connections, such as a dev server's live reload. Each WebSocket passes
through one Amp server, and Amp replaces its servers when it deploys, often several times an hour.
The connection then closes without a close frame, so clients report code 1006, and they must
reconnect. Do not use a portal for a connection that must stay open, such as a database tunnel.
To connect an orb privately to a box or another machine you control, use
[Tailscale](/docs/orbs/customizing#use-tailscale) instead.

## Troubleshooting

If a portal fails, rerun ensure first. This repairs a missing supervised service without starting
a duplicate:

```bash
amp orb services ensure
```

If the service does not become ready, inspect its status and logs:

```bash
amp orb service status <name>
amp orb service logs <name>
```

Check these common causes:

- The command listens on a hardcoded port instead of `$PORT`.
- The process exits after starting a child server.
- The configured health path returns an error or never becomes ready.
- The development server rejects the generated portal hostname.
- The app expects its own login, but the browser opened only the portal URL.

A printed portal URL means Amp configured the public route. It does not prove that the service
passed its readiness check. After fixing the command or configuration, run
`amp orb service restart <name>` and open the exact URL printed by Amp.

### Safari Asks to Allow Access

Some Safari versions, including Safari 18.5 through 26.1, block the sign-in cookie of a portal
shown inside Amp. In those versions, the **Portal** tab and portal previews in the thread show
**Allow this portal to open in Amp** instead of the portal:

1. Select **Allow Access**.
2. The first time, Safari opens a small window from the portal. Select **Continue** there.
3. Select **Allow Access** again, then **Allow** when Safari asks whether the portal can use
   cookies and website data.

After that, each new portal needs one **Allow Access** click, without a prompt. After you quit
Safari, each portal needs that click once more. If Safari still refuses, select
**Open in New Tab** to use the portal outside Amp. Newer Safari versions and other browsers open
portals inside Amp without these steps.

## Desktop

Open the **Desktop** tab in an orb thread to use a high-resolution, interactive Linux desktop
environment running in the orb. Runner threads can have a Desktop tab too; see
[See and Control the Runner's Desktop](/docs/cli/runners#see-and-control-the-runners-desktop).

Amp knows how to use the Desktop, so you can ask it to do things there while you watch.

This is useful when you want to verify Amp's work on Linux and Chrome extension development tasks,
or when working with file formats that need to be opened in native applications.
You can also try computer use in the orb desktop, but this is early and unsupported. You'll hear
from us when we think orb computer use is really good.

Orbs can build Android apps but cannot run the Android emulator, because they have no hardware
virtualization. To run an Android app, use a
[runner](/docs/cli/runners#see-and-control-the-runners-desktop) with an emulator or a connected
Android device.

You can set a Desktop resume script in Project Settings, or add `.agents/desktop/resume` to the
repository to share the script with everyone who uses the project.

When you ask Amp to do something on a website for you, such as filling out a form or completing a
purchase, it drives this same Chrome window. Open the Desktop tab at any time to watch, and use the
window yourself when Amp asks you to take over, for example to sign in or solve a CAPTCHA. Amp
records the run and reports what it did with screenshots.

To browse from your own connection on sites that block cloud IPs,
[share your network](/docs/cli/runners#share-your-network).

You can click any of the other apps in the dock to open them; hover an icon to see its name. Amp installs an app the
first time you open it, so the first launch can take longer.

Read the [Desktop announcement](/news/desktop) for more examples.

### Customizing the Environment

Orbs run Debian, so you can use `apt-get` to install graphical apps. See
[Installing Software](/docs/orbs/customizing#installing-software) for an example and guidance on
making the installation available in future orbs.

### Launch Behavior

Add a Desktop resume script in the Orb section of Project Settings to replace the default Chrome
window with your own startup script. You can also add `.agents/desktop/resume` to your repository. The
repository script takes priority over the Project setting.

To set the project script from the CLI, pass a file when you create or update the project:

```bash
amp projects create acme/widgets --desktop-resume-script-file ./desktop-resume.sh
amp projects update acme/widgets --desktop-resume-script-file ./desktop-resume.sh
```

Amp runs the selected script from the repository root each time the Desktop session starts, so your
script should check whether the application is already running to avoid opening it again.

Commands and child processes that you start from the script keep running after the script exits.
Run an app in the background if the script should continue or exit while the app remains open.

```bash
#!/usr/bin/env bash
set -euo pipefail

sudo -n /opt/amp-desktop/install-app blender
if ! command -v libreoffice >/dev/null; then
  sudo apt-get update
  sudo apt-get install -y libreoffice
fi

if ! pgrep -x blender >/dev/null; then
  blender &
fi
if ! pgrep -x soffice.bin >/dev/null; then
  libreoffice &
fi
```

If you are testing changes to the script while Desktop is already running, run
`sudo systemctl restart amp-desktop` after each change.

### Built-in Apps

Amp can install and configure commonly used Desktop apps. Run
`sudo -n /opt/amp-desktop/install-app <name>` with one of these names:

- `chrome` for Google Chrome
- `firefox` for Firefox
- `code` for Visual Studio Code
- `blender` for Blender
- `terminal` for the Foot terminal
