agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

Dashboard's path-based mux URL hits a 404: '/ao-terminal-mux' has no upgrade handler

Open thapecroth opened this issue 6 months ago • 2 comments

Summary

packages/web/src/providers/MuxProvider.tsx:56-79 constructs wss://hostname/ao-terminal-mux for the dashboard's mux WebSocket whenever the dashboard is served on a standard port (HTTPS 443, HTTP 80, or empty loc.port):

function buildMuxWsUrl(runtimeConfig) {
  // …
  // Port-less or standard ports: use path-based routing (reverse proxy expected)
  if (loc.port === "" || loc.port === "443" || loc.port === "80") {
    return `${protocol}//${loc.hostname}/ao-terminal-mux`;
  }
  // …
}

This is the path-based-routing branch — intended for deployments fronted by a reverse proxy with a public hostname. But nothing on the server side recognizes that path. direct-terminal-ws.ts:67 only matches pathname === "/mux" for upgrades, and Next.js (which receives the request on PORT) doesn't handle WS upgrades at all — the request falls through to its catch-all 404 page.

Result: every reverse-proxied HTTPS deployment that lets the dashboard's auto-detection take effect breaks. Terminal panes hang at "Connecting…" forever. The operator has to either:

  • Configure their proxy to do path rewriting (/ao-terminal-mux → /mux), which many proxies can't do (cloudflared notably) or require migrating off a managed config to do
  • Or expose DIRECT_TERMINAL_PORT through the proxy on a separate subdomain/port and set TERMINAL_WS_PATH

Both are operationally annoying and undiscoverable — the standard-port branch silently assumes proxy capabilities that may not exist.

Repro

  1. Deploy AO behind any HTTPS reverse proxy with a single hostname → PORT mapping (e.g. cloudflared tunnel run with ingress: [{hostname, service: http://localhost:8094}]).
  2. Open the dashboard, spawn an orchestrator, click the session.
  3. Browser DevTools → Network → filter WS → see the /ao-terminal-mux upgrade get HTTP 404 from Next.js (x-nextjs-prerender: 1 on the response).
  4. Terminal pane stays at "Connecting…".

Proposed (minimal)

Have direct-terminal-ws.ts accept /ao-terminal-mux as an alias for /mux. Then path-capable proxies (cloudflared, nginx, Caddy) just route /ao-terminal-mux → DIRECT_TERMINAL_PORT with no rewrite, and the existing dashboard JS works as-is. One-line change in the upgrade allow-list.

For proxies that can't even do path-based routing to a second port, see issue addressed in #1757's third commit (AO_PATH_BASED_MUX opt-in).

PR addressing this: #1757 (commit 279f2caf)

thapecroth avatar May 10 '26 22:05 thapecroth

@prod-blip new issue from a non-collaborator.

OrcInc avatar May 12 '26 17:05 OrcInc

Hi @thapecroth , thanks for filing this, it is really detailed and useful. I'm a contributor on AO and trying to get a sense of how it's working for folks using it in real workflows. Would love to hear a bit more about your experience and happy to hop on a quick 15-min call if that's easier. Here’s my calendly link https://calendly.com/atulpandey-iift1618/30min

Also, the contributors meet on Discord every day at 10pm IST: https://discord.gg/6KgeUjbe — drop in if you're around, good place to see what's being worked on and shape direction directly.

prod-blip avatar May 14 '26 06:05 prod-blip