Skip to content

Every session prints its URL (re-applies #1184) - #1938

Merged
backnotprop merged 1 commit into
mainfrom
session-url-always
Oct 15, 2026
Merged

backnotprop merged 1 commit into
mainfrom
session-url-always

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

This re-applies the design of #1184 by @technicalpickles (Josh Nichols) on current main, with credit: the commit carries his Co-authored-by trailer. #1184 conflicts with main after about 50 later commits to the same files, so the change was rebuilt here rather than rebased. The design, the stable line format and the OpenCode filter work are his; the review feedback from #1184 is folded in. Part of #1134 (criterion 1, the URL). The port half of #1134 is not in this PR.

What changes

Every Bun session now prints one stable line on stderr when it starts, before it launches a browser:

  Plannotator session ready: http://localhost:54321

Two leading spaces, the prefix (SESSION_READY_LINE_PREFIX), then the URL last. Anything else goes on its own line under it, so the URL appears exactly once:

  • remote: Open it on your local machine (forward port N if needed). (or Open it on your device (the URL above). plus the QR for an overridden host)
  • a failed launch: Could not open a browser automatically — open the URL above.

Before, a local session whose browser opened fine printed no URL, so a closed tab left neither the person nor the agent a way back; and because the URL was printed only after the launcher exited, a launcher that never exits hid it (probably #746).

Per host:

Where What
Bun CLI (classic hook, skills, Codex, Gemini, a shell) The ready line on every start. isCodexDesktopHost is gone (the new line covers it).
--tailscale announceTailscaleSession: the ready line once, then the tailnet line and QR.
OpenCode embedded runtime announce: false (its toast or transcript notice already carries the URL, and raw stderr would land in OpenCode's TUI). An OpenCode 2 host without session.synthetic gets the URL through app.log instead, which OPENCODE_PRINT_LOGS=1 shows, as the plugin README promises.
OpenCode CLI bridge The stderr filter already matches the new line; it now also forwards the remote follow-up and the "Could not open a browser" line.
Pi The in-turn "opened" message (sessionOpenedMessage, now its own module) always carries the URL. The after-turn notify runs only for callers without that message (archive, the event API) or after a failed launch. Remote no longer shows the URL twice. This is the one change from #1184, which used the after-turn notify.
Mod, Inbox Unchanged.

stdout is untouched in every mode: --json, --hook and --gate keep it for the decision record.

Things people may notice

  • The remote and failure lines change shape. Anything grepping Plannotator session ready — (with the dash) must match Plannotator session ready instead; the OpenCode filter (old and new plugins) and Amp keep working.
  • In the classic Claude Code hook the line goes to hook stderr, shown only in the transcript or verbose view.
  • Codex desktop gets the new wording.

Tests

  • packages/server/shared-handlers.test.ts: the exact bytes for local, remote and failed launches; the URL once; the line is out before the launch; announce: false prints nothing but still writes the ready file; stdout empty in every branch; the prefix pinned to its literal text.
  • packages/server/tailscale-serve.test.ts: one ready line, above the tailnet line, no browser.
  • apps/hook/server/annotate-cli.test.ts: a real session under --gate --json, --hook and --gate writes the line to stderr and nothing to stdout.
  • apps/opencode-plugin/cli-bridge.test.ts: the filter on the new lines, an old binary's line, and a line built from the server's own constant; server.test.ts: the OpenCode 2 fallback log.
  • apps/pi-extension/plannotator-browser.test.ts: the opened message carries the URL locally and remotely; no second notice when the caller already showed it; the after-turn notice for callers without one (RPC included).
  • Docs: the troubleshooting page.

Ran: bun run typecheck; bun test packages/server apps/hook/server (2198 pass), bun test apps/opencode-plugin (372 pass), bun test in apps/pi-extension (537 pass). Every test opens no browser (NO_BROWSER).

PR B (PLANNOTATOR_BROWSER=none opens nothing) is stacked on this branch.

Every Bun session now writes one stable stderr line on start, before it
launches a browser:

  Plannotator session ready: <url>

Remote forwarding advice and a failed browser launch become follow-up lines
under it, so the URL appears exactly once. A local session whose browser
opened fine used to print nothing (#1134), and a launcher that never exits
hid the URL until it did.

- shared-handlers: SESSION_READY_LINE_PREFIX, an `announce` option, the line
  printed before the launch; isCodexDesktopHost removed (its case is covered).
- --tailscale: announceTailscaleSession prints the ready line once, then the
  tailnet line and QR.
- OpenCode embedded runtime: announce: false (its toast or transcript notice
  carries the URL); an OpenCode 2 host without session.synthetic logs the URL
  instead. The CLI bridge's stderr filter also forwards the remote follow-up
  and the "Could not open a browser" line.
- Pi: the in-turn "opened" message always carries the URL; the after-turn
  notify runs only for the archive and the event API, or after a failed
  launch (remote no longer shows the URL twice).

Re-applies the design of #1184 by @technicalpickles on current main.

Co-authored-by: Josh Nichols <[email protected]>
@backnotprop
backnotprop merged commit b3ff0b9 into main Oct 15, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant