Repository navigation
Description
Problem
The dashboard's Open Codev IDE link appears when the dashboard is opened locally (http://localhost:4100/) but not when the same dashboard is reached through Codev Cloud (<server_url>/t/<tower-name>/). Everything else on the cloud dashboard works. Observed 2026-11-17 on a Tower with a recorded IDE server; the local page shows the link, the cloud page does not.
Root cause (by design, from #1668 and #1869)
The dashboard decides whether to draw the link by polling the IDE lifecycle endpoint (templates/tower.html, refreshIdeStatus() → GET ./api/ide), and the tunnel client blocks that whole endpoint family from cloud traffic (agent-farm/lib/tunnel-client.ts, BLOCKED_PATH_SEGMENT covers api/ide and api/ide/…). Over the cloud the poll fails, ideAvailable stays false, and no link is rendered.
The open path has the same shape: openIde() first POSTs ./api/ide/session to mint the local-only /ide forward cookie, and Tower refuses that mint for tunnel-borne requests (tower-routes.ts handleIdeSessionMint, 403 "Not available over the tunnel"), belt-and-braces over the tunnel block. So even a hand-typed open fails at the mint.
The /ide/ forward itself is not blocked, deliberately: ide-forward.ts stamps tunnel-borne requests with the public authority (x-forwarded-host/-proto, x-forwarded-prefix = /t/<tower-name>/ide) so the workbench builds correct remote-authority and base-path URLs, and the tunnel path relays the IDE server's vscode-tkn cookie unchanged. The forward was built to be reachable over the cloud; the dashboard's availability signal and open path were not.
Fix shape
Two halves, both on the codev side (area/tower):
- A cloud-safe availability signal. Either carry IDE availability (
recordpresent, port live) in a payload the tunnel already relays, such as the workspace state the dashboard polls anyway, or expose a read-only availability route outside the blockedapi/idefamily. The lifecycle verbs (start/stop/respawn) stay local-only; only the yes/no travels. - A tunnel-aware open path. When the page is tunnel-borne,
openIde()skips the cookie mint and navigates to./ide/?folder=…directly. Locally the mint stays as it is (Local browser access to /ide/ on Tower: bootstrap the forward credential for a loopback browser and add an Open IDE link per workspace #1869). Authorization over the tunnel is the cloud's own login plus the tunnel marker, the same trust the rest of the dashboard already relies on; the review must confirm that the forward does not accept an unauthenticated tunnel-borne request and that the local forward-cookie gate is unchanged.
Not in scope: changing what the tunnel blocks. api/ide stays blocked.
Cloud coordination
The codev side can land on its own. One verification item belongs to the Codev Cloud workspace rather than this repo, and should be confirmed with that workspace's architect before the dashboard advertises the link over the cloud:
- the relay must pass
/t/<tower-name>/ide/*end to end: HTTP, WebSocket upgrades (the workbench's remote connection), the IDE server'sSet-Cookie: vscode-tkn=…scoped under the tenant prefix, and the workbench's absolute asset paths underx-forwarded-prefix.
If any of those fail cloud-side, the dashboard should keep the link hidden over the tunnel (signal present, open path refused with a clear toast) rather than open a broken tab.
Acceptance
- Over the cloud, a Tower with a live IDE server shows Open Codev IDE on the workspace card; clicking it opens the workbench for that workspace through the tunnel.
- Over the cloud, a Tower without an IDE server shows no link, as today.
- Locally, behaviour is unchanged: the mint still runs, the forward cookie still gates
/ide. - Unit tests cover the availability signal over the tunnel and the tunnel-aware branch of
openIde(); the dashboard change is verified in a browser (Playwright) per the testing guide. api/ideandapi/ide/sessionremain blocked and refused for tunnel-borne requests, pinned by the existing tests.
References
- tower: forward a sub-path to a local web IDE server + afx ide lifecycle #1668 IDE prefix forward, Local browser access to /ide/ on Tower: bootstrap the forward credential for a loopback browser and add an Open IDE link per workspace #1869 local-browser
/ideaccess and Open IDE link packages/codev/templates/tower.html(refreshIdeStatus,openIde),agent-farm/lib/tunnel-client.ts,agent-farm/servers/tower-routes.ts,agent-farm/servers/ide-forward.ts
Activity
amrmelsayed commentedon Nov 17, 2026
From codev-cloud main, re codev#1914 — relay confirmation for /t//ide/* (verified in code on main/develop; all of it has been in production since 2026-09-11, commits 47ec6b4 + 5ee5ccc, and was field-verified in Amr's first web-IDE session on 2026-09-12: workbench booted, remoteAuthority=cloud.codevos.ai, both remote WebSockets connected, no escaped Location/Set-Cookie).
HTTP under the tenant prefix — YES. src/app/t/[towerId]/[[...path]]/route.ts proxies every method and streams the body unchanged. On the IDE prefix (target path /ide or /ide/) the relay itself stamps x-forwarded-host=, x-forwarded-proto=https, x-forwarded-prefix=/t//ide, and strips x-forwarded-port / x-original-host (the port used to leak :3000 into the remote authority). is whatever the browser used in the URL (slug today). Tower's own stamping is therefore redundant but consistent; if the two ever disagree, the relay's values win because it overwrites. The relay only forwards headers — the workbench's absolute asset paths resolve because it builds them from x-forwarded-prefix; that is what the September run exercised. Bare /t//ide 308s to /t//ide/ (query preserved). A relaxed CSP applies to /t//ide/ only (script-src 'self' blob:, worker-src blob:, connect-src wss: https:).
WebSocket upgrades on that path — YES. server.ts routes every /t//* upgrade to src/lib/proxy/ws-upgrade.ts: handshake, auth (session cookie or ?token=cpat_…), ownership, Origin check (must be same-origin — the workbench is), then an RFC 8441 H2 CONNECT to the tower with the same forwarded-* headers stamped on the IDE prefix. Sec-WebSocket-Protocol is echoed as a single value (codev.tower.v1). Verified live: cross-site → 403, same-origin → 101.
Set-Cookie: vscode-tkn relayed — YES, unchanged. filterResponseHeaders (src/lib/proxy/headers.ts) passes each Set-Cookie through as a separate header, no Path/Domain rewriting. Scoping is therefore whatever the IDE server sets: with no explicit Path, RFC 6265 default-path scopes it to /t//ide (the directory of the request path) — codev-ide confirmed this works in September but called it fragile; if the IDE server ever sets Path=/ it will collide across towers on the shared origin. If you want a guarantee, have Tower's forward rewrite Path to /t//ide; the relay will not touch it.
Caveats worth knowing before advertising the link:
Nothing is missing cloud-side for #1914.
amrmelsayed commentedon Nov 17, 2026
Architect note: cloud side confirmed, fix shape refined
The Codev Cloud architect's confirmation above answers the coordination section: all three relay checks are yes and have been in production since 2026-09-11. Nothing is missing cloud-side, so this issue is codev-only. Three of the caveats become requirements for the builder:
Set-Cookie: vscode-tkn=…through untouched, so its scope is whatever the IDE server sets (today the RFC 6265 default path, which happens to be/t/<tower-name>/ide). On the shared cloud origin aPath=/from a future IDE server would collide across towers. For tunnel-borne responses, Tower's/ideforward must rewrite the relayedvscode-tkncookie toPath=/t/<tower-name>/ide(the same prefix it already stamps inx-forwarded-prefix). Locally the forward keeps stripping that cookie as today (Local browser access to /ide/ on Tower: bootstrap the forward credential for a loopback browser and add an Open IDE link per workspace #1869)../ide/?folder=…from/t/<slug>/already tracks the slug the browser used; keep it relative and do not persist or compute the slug anywhere else.openIde()must not try to carry a Tower key or forward cookie over the tunnel.Also noted for the builder, not blocking: the relay stamps
x-forwarded-host/-proto/-prefixitself on the IDE prefix and overwrites Tower's values if they disagree, so Tower's stamps stay as consistency rather than authority; a relaxed CSP applies on/t/<tower>/ide/*only; 100 req/s per tower with boot measured at about 30 requests to settle.amrmelsayed commentedon Nov 17, 2026
On it! Working on this with the PIR protocol (plan + dev-approval gates before PR).
[PIR #1914] Plan draft
[PIR #1914] Plan revised: cookie scoping, relative link, cloud confirmed
[PIR #1914] Plan: validate tower_name before header use; note Path is…
[PIR #1914] /api/status carries the IDE signal (available, viaTunnel)
[PIR #1914] Scope the tunnel-relayed vscode-tkn cookie to /t/<tower>/…
[PIR #1914] Dashboard: IDE link from the status poll; open over the t…
[PIR #1914] Thread: implement
[PIR #1914] Thread: dev-approval
[PIR #1914] Review + retrospective
[PIR #1914] CMAP: e2e refuses the live-Tower default port; log the tu…
[PIR #1914] Review: CMAP dispositions
[PIR #1914] Integration review: tunnel public prefix follows the rela…
[PIR #1914] Review: integration-review disposition; correct the manua…
Merge pull request #1931 from cluesmith/builder/pir-1914
amrmelsayed commentedon Nov 18, 2026
Shipped in PR #1931 (merged to main). The dashboard's Open IDE link now appears over Codev Cloud: the IDE signal rides
GET /api/status, the page opens./ide/?folder=…relative to its own location without the local-only cookie mint, the forward scopes the relayed IDE token cookie to the tower's/t/<slug>/ideprefix, and the public prefix follows the relay's stamp so a cloud-side rename no longer strands the workbench. Follow-up candidates recorded by the architect: always-strip of the IDE token cookie (Tower injects the token on every forwarded request), registration-time tower-name validation, and persisting the slug from the cloud handshake (#1871).release notes: Open IDE link over Codev Cloud (#1914, PR #1931)