feat(webview): open localhost links through a proxied web tab from another device - #401
Open
shenlvkang-collab wants to merge 1 commit into
Open
feat(webview): open localhost links through a proxied web tab from another device#401shenlvkang-collab wants to merge 1 commit into
shenlvkang-collab wants to merge 1 commit into
Conversation
…other 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
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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 (docs/web-tabs.md) fetches from the server, where it works.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.openWebview(id, { path })appends it to the minted/webview/<cap>/prefix; a mounted frame is navigated, not torn down, so its state survives). Otherwise one is saved under itshost:port, sandboxed like any other web tab, so it is in the Run dropdown next time.localhost) every link opens directly.openLinkThroughWebTabIfLoopback(url), returns false when it declines, and both callers fall through to their existing behaviour (window.openin the link provider, the anchor's_blankdefault in the viewer).No server change: the proxy, the egress policy (loopback is explicitly allowed) and the capability model are as shipped.
Docs:
docs/web-tabs.md(new section). Changeset: minor.Test plan
test/webview-loopback-links.test.ts(new, jsdom): loopback spellings vs LAN/tailnet/invalid; page-on-box exemption; reuse of a saved proxied dashboard with a deep path; navigating a mounted frame in place; saving an unknown origin ashost:port; direct-mode dashboards not reused; reachable links left to the caller; both callers consult the hook before their own path.test/webview-menu-rows.test.ts,test/response-viewer-file-links.test.ts,test/response-viewer-external-links.test.ts,test/link-provider-regex.test.ts,test/frontend-public-tooling.test.tsunchanged and green.🤖 Generated with Claude Code
https://claude.ai/code/session_01McLWqCWBuQYGuPMScb4Aou