Repository navigation
feat(terminal): forward loopback links clicked in SSH terminals - #3664
Merged
bobleer merged 2 commits intoNov 2, 2026
Merged
Conversation
Ctrl/Cmd+clicking an http(s) loopback link with an explicit port in a remote SSH terminal now reuses or starts a local port forward for that remote port and opens the rewritten local URL. Forward failures, local Docker/WSL targets, and Peer Device Mode show an explicit warning with an 'open anyway' action instead of silently opening the local URL. Fixes openBitFun#2285
- Open links unchanged for WSL and local Docker targets instead of calling the SSH forward backend. - Always rewrite to the forward's bound address so localhost cannot resolve to a local IPv6 server. - Match forwards by exact remote host (plus localhost/127.0.0.1), so 127.x and ::1 links reuse or create the right forward. - Treat a lost start race as reuse and keep the original start error when the fallback re-list fails. - Warn on port-less loopback links and strip a trailing host dot. - Restart an idle forward that recorded an error instead of reusing it. - Add Terminal onLinkActivate wiring test; keep terminal.json formatting.
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
When you Ctrl/Cmd+click a loopback link (
127.x.y.z,localhost,*.localhost,0.0.0.0,[::1], with an explicit port) in a remote SSH terminal, the remote port is now forwarded and the forwarded local URL opens, the same way VS Code does it.Fixes #2285
Type and Areas
Type: Feature
Areas: web UI (terminal, ssh-remote), locales
Motivation / Impact
Previously, clicking
http://127.0.0.1:5173printed by a dev server on an SSH host opened the local URL. You reached whatever was listening on your own machine, or nothing.Now:
loopbackLink.ts(pure, no IO): detects loopback http(s) links. A trailing host dot such aslocalhost.is stripped. The link is rewritten to the forward's bound address (always127.0.0.1unless the forward binds elsewhere), keeping the path, query and hash.localhostis not kept, because the browser could try::1first and reach a local server on the same port.openTerminalLink.ts, for a terminal with aconnectionId:wslorcontainer.local): the link opens unchanged and the backend is not called. WSL2 forwards localhost by default, and these targets have no SSH channel.localhostand127.0.0.1count as the same host, so a[::1]link never reuses a127.0.0.1forward and a127.1.2.3link finds its own forward.lastErroris stopped and started again, keeping its local port, LAN exposure and label. Starting again reconnects the SSH session if needed.sshApi.startPortForward, asking for the same local port first; the backend picks another if it is taken. A toast shows the mapping, then the rewritten URL opens.Terminal.tsxgets an optionalonLinkActivateprop. All calls go through the existing API adapters, not Tauri directly.Verification
pnpm --dir src/web-ui run test:run src/features/ssh-remote src/tools/terminal: 22 files, 218 tests passed.loopbackLink.test.tsopenTerminalLink.test.ts: local passthrough, WSL/Docker passthrough, exact-host reuse,127.xreuse,[::1]versus127.0.0.1, restarting a forward with an error, create, failure without opening locally, lost race reported as reuse, original error kept when the re-list fails, port-less notice, peer mode.Terminal.linkActivation.test.tsx: component-level check thatonLinkActivateis called and the external fallback still works.tsc --noEmitinsrc/web-ui: passed. The ts-rssrc/generated/apitypes were copied from an existing local generation, not regenerated.pnpm run i18n:audit: passed, 0 warnings.Remote scenarios: only unit and component tests with mocked APIs were run. There was no live SSH, WSL, Docker or Peer Device Mode run. Remote control (mobile/IM) has no terminal link surface and is not affected.
Reviewer Notes
Checklist