Skip to content

dashboard: Open Codev IDE link is hidden over Codev Cloud (availability poll and cookie mint are local-only) #1914

Closed

Description

@amrmelsayed

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):

  1. A cloud-safe availability signal. Either carry IDE availability (record present, 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 blocked api/ide family. The lifecycle verbs (start/stop/respawn) stay local-only; only the yes/no travels.
  2. 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's Set-Cookie: vscode-tkn=… scoped under the tenant prefix, and the workbench's absolute asset paths under x-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/ide and api/ide/session remain blocked and refused for tunnel-borne requests, pinned by the existing tests.

References

Activity

  1. added
    area/tower
    on Nov 17, 2026
  2. amrmelsayed commented on Nov 17, 2026

    @amrmelsayed
    CollaboratorAuthor

    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).

    1. 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:).

    2. 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.

    3. 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:

    • Reaching /t//ide/* over HTTP requires the cloud browser session cookie; a Bearer PAT is still redirected by middleware (codev-cloud#10, open). Since the dashboard is already open through the cloud, the session exists — fine for the link.
    • Rate limit 100 req/s per tower; boot measured at ~12 requests to interactive, ~30 to settle. 30 s HTTP timeout is time-to-headers only.
    • Cloudflare compresses the proxied text/javascript (zstd observed); the relay does not.
    • Tower rename (codev-cloud#17 / PR Rename the protocol name?! #18, gate approved 2026-11-18, merging to develop) will make old slugs 410/404; the link should always be built from the slug Tower holds (auth_ok will carry it).
    • Windows ?folder= FYI: codev-cloud builds no IDE links of its own, so the URI-path defect does not apply here.

    Nothing is missing cloud-side for #1914.

  3. amrmelsayed commented on Nov 17, 2026

    @amrmelsayed
    CollaboratorAuthor

    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:

    1. Cookie scoping is Tower's to guarantee. The relay passes 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 a Path=/ from a future IDE server would collide across towers. For tunnel-borne responses, Tower's /ide forward must rewrite the relayed vscode-tkn cookie to Path=/t/<tower-name>/ide (the same prefix it already stamps in x-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).
    2. Build the link from the page's own location, never a stored slug. Tower renames (cloud-side Expert Review Enforcement #17) will 410/404 old slugs. The dashboard's relative ./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.
    3. The cloud session is the authorization over the tunnel. HTTP on the IDE path requires the cloud browser session cookie (a PAT does not work for HTTP yet, cloud-side Directory Structure - Separate Framework from Project Files #10). The dashboard is already open under that session, so the link works; the tunnel-aware 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/-prefix itself 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.

  4. amrmelsayed commented on Nov 17, 2026

    @amrmelsayed
    CollaboratorAuthor

    On it! Working on this with the PIR protocol (plan + dev-approval gates before PR).

  5. added 14 commits that reference this issue on Nov 17, 2026
  6. amrmelsayed commented on Nov 18, 2026

    @amrmelsayed
    CollaboratorAuthor

    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>/ide prefix, 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/tower

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions