Skip to content

[Feature Request] Live app annotation over a port-forwarded session: a fixed port for the live proxy #2109

Closed

Description

@vladmarchuk

Version: Plannotator 0.28.27 (Pi extension; same code path in the CLI). Agent on a remote Linux machine, browser on a Mac (and an iPhone for the second proposal).

Use case: I run Pi with Plannotator on a remote dev machine and review from my laptop. Remote mode is off: everything binds loopback, and an SSH forward of a fixed range (PLANNOTATOR_PORT=19432-19439, plus my app ports) makes http://localhost:19432 on the laptop reach the remote machine. Plans, code review, annotate-last and HTML files all work this way, and Ask this session stays on.

Live app annotation does not. /plannotator-annotate http://localhost:5173 opens the editor, but the frame stays empty (the browser's broken-page icon).

Why: the live proxy binds a port the OS picks (listen(0, "127.0.0.1") in packages/shared/live-proxy-node.ts, port: 0 in packages/server/live-proxy.ts), and the editor frames http://localhost:<that port>/ (buildLiveAppUrl in packages/shared/live-proxy-core.ts). On Linux that port comes from 32768–60999 and changes every session, so it cannot be forwarded ahead of time. The editor at localhost:19432 arrives through the forward; the frame's localhost:<random port> hits the laptop itself.

Repro

  1. Remote machine, remote mode off: PLANNOTATOR_PORT=19432-19439, and any page on python3 -m http.server 5173 --bind 127.0.0.1.
  2. Laptop: ssh -L 19432:127.0.0.1:19432 -L 5173:127.0.0.1:5173 <remote>.
  3. In Pi on the remote: /plannotator-annotate http://localhost:5173, then open http://localhost:19432 on the laptop.

Expected: the app in the frame. Actual: an empty frame. The frame points at http://localhost:41535/ (a random port); the proxy answers there with frame-ancestors http://localhost:19432 http://127.0.0.1:19432.

Proposal

  1. Let the live proxy use a fixed port or range, for example PLANNOTATOR_LIVE_PORT=19440-19447 (same syntax and busy-port fallback as PLANNOTATOR_PORT, Handle remote multi-session port conflicts with port-range fallback #437). The proxy still binds 127.0.0.1, with the same Host and Origin checks and the same frame-ancestors. Remote mode's hard-off (feat(annotate): live local app annotation through a loopback reverse proxy #1352) stays as it is. The user forwards that range next to the editor's, and live annotation works over SSH, VS Code Remote, or any local port forward.
  2. Optional, for forwards that change the host name: when the editor is opened at a host already allowed through PLANNOTATOR_ALLOWED_HOSTS (for example a tailnet name that a user-run forwarder maps to loopback), build the frame URL from location.hostname instead of localhost, and add that origin to the proxy's frame-ancestors and Host check. The proxy still binds loopback; reaching it stays the user's own forward. This is what a phone needs, where localhost can never mean the remote machine. I understand it touches the live proxy's security contract, so (1) alone already solves the SSH-forward case.

I can send a PR for (1) if the shape works for you.

Activity

  1. added
    enhancement
    on Oct 23, 2026
  2. backnotprop commented on Oct 23, 2026

    @backnotprop
    Owner

    Thanks for the detailed report. We reproduced it with a simulated SSH forward and confirmed the fix. Please go ahead with a PR for (1), PLANNOTATOR_LIVE_PORT with the same syntax and busy-port fallback as PLANNOTATOR_PORT, used by both the Bun and Node proxies, still bound to 127.0.0.1 with the same checks. A few things we'd like in it:

    • one clear error line when every port in the range is busy, not a stack trace
    • an env-var row in the docs, noting that the forward must keep the same port number and that SSH sessions need PLANNOTATOR_REMOTE=0
    • the proxy's port printed next to "Live app:"

    We'll hold off on (2).

  3. backnotprop commented on Oct 24, 2026

    @backnotprop
    Owner

    Fixed in #2145.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions