feat(webview): open localhost links through a proxied web tab from another device

An agent prints `http://localhost:5173/` (a dev server, a preview it just
served) and the user taps it on a phone. That address only exists on the
Codeman box, so the link was a guaranteed connection error from any other
device — while the web-tab proxy fetches from the server, where it works.

A loopback link (`localhost`, `*.localhost`, 127/8, 0.0.0.0, ::1) activated
in the terminal or clicked in the Response Viewer now opens as a proxied
web tab whenever the Codeman page itself is not on that box. A saved
proxied dashboard on the same origin is reused, with the link's own path,
query and fragment opened inside it (a mounted frame is navigated, not torn
down, so its state survives); otherwise one is saved under its host:port,
sandboxed like any other web tab, so it is in the Run dropdown next time.

Only loopback is routed this way. A LAN or tailnet address may well be
reachable from the device (a VPN, the same Wi-Fi) and a direct open is the
cheaper, richer path, so those keep opening in a new browser tab; on the
box itself every link opens directly. The terminal link provider and the
viewer's click handler consult one hook and fall through to their existing
behaviour when it declines.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01McLWqCWBuQYGuPMScb4Aou
This commit is contained in:
shenlvkang-collab
2026-09-10 12:48:47 +08:00
co-authored by Claude Fable 5.1
parent 5b667264b4
commit d9eeb039db
6 changed files with 405 additions and 4 deletions
+14
View File
@@ -0,0 +1,14 @@
---
"aicodeman": minor
---
feat(webview): open `localhost` links from the terminal and the Response Viewer through a proxied web tab
An agent prints `http://localhost:5173/` and the user taps it on a phone: that address
only exists on the Codeman box, so the link was a guaranteed connection error from any
other device. A loopback link (`localhost`, `*.localhost`, 127/8, 0.0.0.0, ::1) clicked in
the terminal or in the Response Viewer now opens as a proxied web tab whenever the
Codeman page itself is not on that box — reusing a saved proxied dashboard on the same
origin (with the link's own path opened inside it) or saving one under its host:port.
LAN and tailnet addresses, which the device may reach directly, keep opening in a new
browser tab, and on the box itself every link opens directly.