Skip to content

Session reachability: always surface the review URL, and keep the port stable across plan resubmissions #1134

Open

Description

@backnotprop

Two small gaps make a running Plannotator session hard to reach. Both were reported separately (#601, #589) and both are still current on main. This issue supersedes both.

1. The URL is only printed when the browser fails. handleServerReady (packages/server/shared-handlers.ts:209-228) writes the session URL to stderr only when the session is remote, when the Codex desktop host is detected, or when openBrowser() fails. On the common local path where the browser opens fine, nothing is printed, so there is no way to recover the URL if the tab is closed, if you are on a second machine, or if you want to hand it to another tool.

2. The port changes on every resubmission. getServerPortConfiguration (packages/server/remote.ts) returns port 0 for local sessions, so each deny, revise, resubmit cycle spawns a new process on a new random port. Anyone pointing a secondary tool or a bookmark at the session has to be re-told the port every round. PLANNOTATOR_PORT is the only workaround today, and #1042's bounded ranges do not address it (a range still picks a different free port each start).

Acceptance criteria

  • The session URL is written to stderr on every session start, including local sessions where the browser opened successfully.
  • Within one plan review cycle (same project and plan slug), a resubmitted plan reuses the previous session's port when it is still free, without requiring PLANNOTATOR_PORT.
  • plannotator sessions continues to list and reopen these sessions unchanged.

Out of scope: the portless / stable-hostname idea from #601. That is a much larger proxy story; open it separately if wanted.

Related: #899 (big-picture session tracker), #1042 (bounded port ranges, merged).

Activity

  1. added
    enhancement
    on Jul 27, 2026
  2. technicalpickles commented on Aug 3, 2026

    @technicalpickles
    Contributor

    Ran into both halves of this and figured the usage data might be worth adding, since it's all still current on main (0935cf08).

    I went back through my Claude Code transcripts and found 16 sessions where I'd used plannotator annotate. Across those, the agent burned 21 lsof calls hunting for the bound port, 8 polling loops grepping its own background output for anything matching https?://, 6 pkill -9 -f plannotator calls, and 4 curl probes against 127.0.0.1:$port to work out which document a given server was actually serving. Meanwhile I'm typing "i need a url", then "ill need the url", then eventually "you need to give me a URL for it."

    None of that was the agent flailing. There was genuinely no URL anywhere for it to read.

    Confirming criterion 1 is still unmet: handleServerReady (packages/server/shared-handlers.ts:209-231) writes a URL on exactly three paths, isRemote, isCodexDesktopHost(), and !opened. A local session where the browser opened fine gets silence, and that's the common case.

    One thing that might shorten the fix: the side channel already exists. PLANNOTATOR_READY_FILE appends {url, isRemote, port} the moment the server binds, and apps/amp-plugin/plannotator.ts:543 sets it. apps/hook/ never does, so Claude Code is the one host that can't see a URL that's already being published. Wiring it there gets you most of criterion 1 for the Claude Code path without touching the stderr behavior at all. I'd still want the stderr line for people not going through a plugin, though.

    Criterion 2 is what the pkill calls were about. A stale server holding the previous document, with no way to tell from the outside which one it had, so kill-and-relaunch was the only reliable move. #636 is circling the same thing from the tab side.

    Happy to take a swing at this if it's unclaimed.

  3. backnotprop commented on Aug 3, 2026

    @backnotprop
    OwnerAuthor

    This is exactly the kind of usage data that turns a "nice to have" into a priority, thank you for pulling the transcripts. Twenty-one lsof calls and six pkill -9 invocations to find a URL the server already knows is a clear verdict on the current behavior.

    It is unclaimed and it is yours if you want it. Your read of the shortest path matches ours:

    1. Wire PLANNOTATOR_READY_FILE in apps/hook/ the way apps/amp-plugin/plannotator.ts already does, which closes most of criterion 1 for Claude Code without touching stderr behavior.
    2. Add the unconditional stderr URL line in handleServerReady for people not going through a plugin. Keep it one line and stable in format, since agents will grep it.

    Two repo rules worth knowing before you start: server changes must land in both runtimes (packages/server/ for Bun and apps/pi-extension/server/ for the Node mirror; shared logic goes in packages/shared/ and gets vendored via vendor.sh), and criterion 2 (stable port across resubmissions) has some subtlety around abandoned-session cleanup, so feel free to split it into a second PR if it grows. Happy to review as soon as something is up.

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