From 4f3116d28a777c120d3764329506be8491cfe3d9 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Tue, 2 Jun 2026 19:49:58 +0800 Subject: [PATCH] Unify workspace service URLs (#1288) * Unify workspace service proxying * Clean up service proxy review issues --- docs/development.md | 4 +- docs/service-proxy.md | 58 +- .../src/utils/workspace-script-links.test.ts | 123 +- .../app/src/utils/workspace-script-links.ts | 26 +- packages/protocol/src/messages.ts | 2 + .../protocol/src/messages.workspaces.test.ts | 48 + .../server/src/server/bootstrap.smoke.test.ts | 251 ++++ packages/server/src/server/bootstrap.ts | 428 +++---- .../server/src/server/config-relay.test.ts | 33 +- packages/server/src/server/config.ts | 35 +- .../server/src/server/persisted-config.ts | 3 + .../src/server/script-health-monitor.test.ts | 22 +- .../src/server/script-health-monitor.ts | 22 +- .../server/src/server/script-proxy.test.ts | 484 +------- packages/server/src/server/script-proxy.ts | 360 +----- .../script-route-branch-handler.test.ts | 149 ++- .../src/server/script-route-branch-handler.ts | 72 +- .../server/script-status-projection.test.ts | 104 +- .../src/server/script-status-projection.ts | 199 +-- .../server/src/server/service-proxy.test.ts | 295 +++++ packages/server/src/server/service-proxy.ts | 1082 +++++++++++++++++ packages/server/src/server/session.test.ts | 6 +- packages/server/src/server/session.ts | 24 +- .../session.workspace-git-watch.test.ts | 28 +- .../src/server/test-utils/paseo-daemon.ts | 2 + .../src/server/test-utils/session-stubs.ts | 8 +- .../server/src/server/websocket-server.ts | 14 +- .../src/server/workspace-service-env.test.ts | 35 +- .../src/server/workspace-service-env.ts | 22 +- .../server/worktree-bootstrap.posix.test.ts | 22 +- .../src/server/worktree-bootstrap.test.ts | 108 +- .../server/src/server/worktree-bootstrap.ts | 41 +- .../src/server/worktree-session.test.ts | 4 +- .../server/src/server/worktree-session.ts | 4 +- .../server/src/utils/script-hostname.test.ts | 14 +- packages/server/src/utils/script-hostname.ts | 57 +- .../public/schemas/paseo.config.v1.json | 3 + public-docs/worktrees.md | 10 +- 38 files changed, 2664 insertions(+), 1538 deletions(-) create mode 100644 packages/server/src/server/service-proxy.test.ts create mode 100644 packages/server/src/server/service-proxy.ts diff --git a/docs/development.md b/docs/development.md index c76e87b61..982d80996 100644 --- a/docs/development.md +++ b/docs/development.md @@ -158,12 +158,14 @@ Every `scripts` entry with `"type": "service"` receives these environment variab | Variable | Value | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -| `PASEO_SERVICE__URL` | Proxied daemon URL for a declared peer service. Prefer this for peer discovery; it survives peer restarts. | +| `PASEO_SERVICE__URL` | Proxied URL for a declared peer service. Prefer this for peer discovery; it survives peer restarts. | | `PASEO_SERVICE__PORT` | Raw ephemeral port for a declared peer service. Use only as a bypass escape hatch; it can go stale if that peer restarts. | | `PASEO_URL` | Self alias for `PASEO_SERVICE__URL`. | | `PASEO_PORT` | Self alias for `PASEO_SERVICE__PORT`. | | `HOST` | Bind host for the service process. | +Service proxy hostnames use the double-dash shape: `web--feature-auth--project.localhost` or, on the default branch, `web--project.localhost`. Optional public aliases use the same leftmost label under the configured public base host. + `` is normalized from the script name by uppercasing it, replacing each run of non-`A-Z0-9` characters with `_`, and trimming leading or trailing `_`. For example, `app-server` and `app.server` both normalize to `APP_SERVER`; that collision fails at spawn time with an actionable error. `PORT` is not injected by default. If a framework requires `PORT`, set it in the command: diff --git a/docs/service-proxy.md b/docs/service-proxy.md index 822a4c3e5..6e11f3e99 100644 --- a/docs/service-proxy.md +++ b/docs/service-proxy.md @@ -1,6 +1,6 @@ # Service Proxy -Paseo can proxy HTTP traffic to services running inside your workspaces and expose them at stable, publicly-accessible URLs. This lets you open a running dev server from your phone or share it with a teammate without any tunneling tools. +Paseo proxies HTTP traffic to services running inside your workspaces. Localhost service URLs are always enabled; optional public aliases and a separate service-only listener can be layered on through config. ## How it works @@ -9,22 +9,22 @@ When a `paseo.json` script of `"type": "service"` starts, Paseo assigns it a loc The generated hostname is built from the script name, branch, and project: ``` -