Skip to content

fix(connection): copied browser SSH forward uses the local port on both sides - #1556

Merged
bkudiess merged 2 commits into
openclaw:mainfrom
SebTardif:fix/f074-browser-remote-port
Oct 20, 2026
Merged

bkudiess merged 2 commits into
openclaw:mainfrom
SebTardif:fix/f074-browser-remote-port

Conversation

@SebTardif

@SebTardif SebTardif commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: the copied browser SSH forward uses the local port on both sides when the tunnel has no browser-proxy remote endpoint.

User Impact

The diagnostics browser-setup copy now forwards the local browser port to the remote gateway port plus 2. A local gateway port of 19000 and a remote port of 18789 produces -L 19002:127.0.0.1:18791 instead of -L 19002:127.0.0.1:19002. An explicit browser remote port is unchanged; a missing remote gateway port leaves a placeholder. The current-head Diagnostics Copy clipboard is below.

Why This Change Was Made

The managed tunnel forwards local gateway port + 2 to remote gateway port + 2. The command-center repair copy already used that remote port. The diagnostics copy now uses the same rule, and it leaves a placeholder when the remote gateway port is missing.

Evidence

On 2026-10-07, isolated tray pid 34868 ran the Debug build of head 9459dfe651f2c6f394a85398ebcc44dd652433cf from wt-wn-1556. The exe timestamp was 2026-10-07 08:03:53 UTC and the worktree was clean at that commit. The isolated gateway record used ws://127.0.0.1:19000, SSH user oc, host gateway.example, local port 19000, and remote port 18789. The tray log, after its own redaction, recorded:

SSH tunnel started: <ip>:19000 -> <ip>:18789 via <email>:22
SSH tunnel browser proxy forward started: <ip>:19002 -> <ip>:18791 via <email>:22
[SSH] ssh: Could not resolve hostname gateway.example: No such host is known.
Copied browser setup guidance from deep link

The copy line is from 2026-10-07 05:50:49 local. A second launch of the same exe, with the same isolated data directory, forwarded openclaw://browser-setup into that process. That is the Diagnostics Copy action. The clipboard read back:

OpenClaw browser proxy setup
Expected local browser-control endpoint: http://<host>:19002/

If the Gateway and browser are on this Windows machine:
1. Ensure the upstream browser plugin is enabled in the Gateway config.
2. Verify the browser control plane:
   openclaw browser --browser-profile openclaw doctor
   openclaw browser --browser-profile openclaw start
   openclaw browser --browser-profile openclaw tabs

If the browser is on this Windows machine but the Gateway is remote:
1. Run a browser-capable OpenClaw node host on this machine:
   openclaw node run --host <ip> --port 19000
2. Or install it as a user service:
   openclaw node install --host <ip> --port 19000
   openclaw node start
3. Keep nodeHost.browserProxy.enabled=[REDACTED], and configure nodeHost.browserProxy.allowProfiles only if you want to restrict profile access.

Gateway policy and auth checks:
- The Gateway allowlist must permit browser.proxy for this node.
- Browser-control auth must match the saved Gateway token/password in Settings.
- Do not paste QR bootstrap tokens into the normal Gateway Token field.

SSH tunnel mode:
- Prefer the tray-managed SSH tunnel with Browser proxy bridge enabled; it forwards local-port+2 to remote-port+2 automatically.
- Manual forward shape: ssh -N -L 19002:<ip>:18791 <email>

The product sanitizer replaced the loopback address, the user@host, and the enabled=true literal. The remote side of the forward is 18791, remote gateway port 18789 plus 2. It is not 19002 on both sides. The isolated gateway token was not in the clipboard. No live SSH session was established.

The Diagnostics page was open. Copy specific diagnostic text was expanded, and Copy browser setup guidance was enabled. The automation host could not call that card's Invoke pattern (InvalidCastException), and a coordinate tap did not show the Copied infobar. The clipboard above is from the deep-link Diagnostics Copy, which calls the same CopyBrowserSetupGuidance method as that card.

Previously reported formatter-only before/after evidence

The contributor's original body reported a direct BuildBrowserSetupGuidance call with browser port 19002, SSH mode, local 127.0.0.1:19000, remote 127.0.0.1:18789, user oc, host gateway.example, and no browser-proxy remote endpoint. This is not output captured from the live Diagnostics Copy action.

Before, on base 5abfabb38e121cc169bd42574740a7e9518ad2e4:

- Manual forward shape: ssh -N -L 19002:127.0.0.1:19002 [email protected]

After, on 9459dfe651f2c6f394a85398ebcc44dd652433cf (empty retrigger of 3e0be3afdb8f423e19afec92da874cfaf7c61dd6):

- Manual forward shape: ssh -N -L 19002:127.0.0.1:18791 [email protected]

The current-head focused tests independently passed the asymmetric-port, explicit-browser-endpoint, and missing-remote-port cases.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required proof pools

  • windows-winui-interactive: isolated Debug tray on head 9459dfe651f2c6f394a85398ebcc44dd652433cf opened Diagnostics and the Diagnostics Copy action wrote the clipboard above. The maintainer-scheduled freeze run was not executed.

Validation

Current-head local results, September 30, with $env:OPENCLAW_REPO_ROOT=(Get-Location).Path in this isolated worktree. This copy pass did not change source and did not rerun the suites.

  • .\build.ps1: passed, exit 0; Shared, CLI, WinNode CLI, SetupEngine, and WinUI built.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: passed, 4169 passed, 33 skipped, 0 failed (4202 discovered).
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: passed, 3347 passed, 0 skipped, 0 failed.
  • Fresh-worktree safeguard: both complete suites first ran without --no-restore, restoring and executing nonzero tests; the required --no-restore commands above were then rerun with the same counts.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore --filter 'FullyQualifiedName~CommandCenterBrowserSetupGuidanceTests|FullyQualifiedName~DiagnosticsPageContractTests|FullyQualifiedName~CommandCenterTunnel|FullyQualifiedName~CommandCenterTopology|FullyQualifiedName~CommandCenterPort|FullyQualifiedName~BrowserControl': passed, 44 passed, 0 skipped, 0 failed.
  • dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --filter 'FullyQualifiedName~SshTunnel|FullyQualifiedName~BrowserProxy|FullyQualifiedName~GatewayTopology': passed, 65 passed, 0 skipped, 0 failed.
  • Exact-head GitHub Build and Test run: CI Gate, fast validation, Tray/setup/integration, and UI/functional/accessibility checks were green when inspected. Classified unrelated jobs were skipped, not claimed as locally executed.
  • Rubber-duck: no blocking finding; noted non-blocking gaps in composite endpoint fixture shape and mismatch-guard coverage. Production composite endpoint parsing and the managed remote-port-plus-2 invariant were independently checked. No source change was needed.

Real Behavior Proof

  • Environment tested: local native Windows x64, Debug WinUI build, isolated tray data directory. Gateway URL ws://127.0.0.1:19000. SSH local port 19000, remote port 18789, user oc, host gateway.example. Node mode, MCP, hotkeys, notifications, and managed-local auto-repair were off. The installed gateway on port 18789 was not the target.
  • PR head or commit tested: 9459dfe651f2c6f394a85398ebcc44dd652433cf. Tray pid 34868.
  • Exact steps or command run: started OpenClaw.Tray.WinUI.exe with openclaw://hub/debug. The Diagnostics page opened. Expanded Copy specific diagnostic text. A second process with the same isolated data directory forwarded openclaw://browser-setup. The tray log recorded Copied browser setup guidance from deep link. The clipboard was then read.
  • Evidence after fix: the copied manual forward is ssh -N -L 19002:<ip>:18791 <email>. The node command in the same clipboard uses port 19000. The tray log for that process recorded remote gateway port 18789 and remote browser port 18791. ssh exited 255 because gateway.example does not resolve.
  • Screenshot or artifact links verified? (No)
  • Not verified or blocked: the on-screen card's Invoke pattern was not called, and the coordinate tap did not show the Copied infobar. No live SSH session. The explicit remote browser endpoint and the missing-remote-port placeholder remain covered by the formatter tests, not by this clipboard.

Security Impact

  • New permissions or capabilities? (No)
  • Secrets or tokens handling changed? (No)
  • New or changed network calls? (No)
  • Command or tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any answer is Yes, explain the risk and mitigation: The app still does not run the copied command. Only the remote port in the text changed.

Compatibility and Migration

  • Backward compatible? (Yes)
  • Config or environment changes? (No)
  • Migration needed? (No)
  • If yes, list the exact upgrade steps: Existing tunnels are unchanged. The copied line's remote port changes when the browser-proxy remote endpoint is missing and the remote gateway port is known. No setting file changes.

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

There are no inline review threads. This update records the current-head Diagnostics Copy clipboard that revision 5 asked for.

The diagnostics setup text reused the local browser port as the remote
port when the tunnel had no browser-proxy remote endpoint. A local
gateway port of 19000 and a remote port of 18789 copied
-L 19002:127.0.0.1:19002. The line now uses remote gateway port + 2,
matching the managed tunnel and the command-center repair copy.

The same inputs now copy -L 19002:127.0.0.1:18791. An explicit browser
remote port is kept. A missing remote gateway port stays a placeholder.

Signed-off-by: Sebastien Tardif <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 30, 2026
@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed October 7, 2026, 8:59 AM ET / 12:59 UTC (Revision 6).

ClawSweeper review

What this changes

The PR corrects copied browser SSH forwarding guidance to use the remote gateway port plus two when no explicit browser endpoint is available, and adds three regression tests.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on current main and is ready for normal landing review. The new current-head clipboard evidence resolves the prior proof request, with no blocking findings.

Priority: P2
Reviewed head: 9459dfe651f2c6f394a85398ebcc44dd652433cf

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with production clipboard output, regression coverage, and successful exact-head CI is ready for normal landing review.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Current-head native Windows output exercises the production deep-link clipboard service and changed guidance formatter with asymmetric gateway ports, producing 19002 to 18791 after SSH failure clears the explicit browser endpoint. This satisfies the previous clipboard-output request; the uninvoked card and absent live SSH session do not undermine the changed text behavior. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Current-head native Windows output exercises the production deep-link clipboard service and changed guidance formatter with asymmetric gateway ports, producing 19002 to 18791 after SSH failure clears the explicit browser endpoint. This satisfies the previous clipboard-output request; the uninvoked card and absent live SSH session do not undermine the changed text behavior. No stored-data contract changes.
Evidence reviewed 8 items Pinned introduced change: The introduced delta changes only the browser SSH hint formatter and adds three tests. Remote port resolution preserves explicit endpoints, bounds derived ports, and leaves a placeholder when derivation is unsafe.
Still necessary on main: Fetched main still falls back to the local browser port when the explicit remote endpoint is absent.
Latest release remains affected: The same local-port fallback exists in v2026.9.4; this is not an already-shipped fix.
Findings None None.
Security None None.

How this fits together

Windows Companion builds browser setup guidance from the active gateway and SSH tunnel diagnostics. Diagnostics copy actions format and sanitize that state before placing instructions on the clipboard.

flowchart TD
 A[Active gateway settings] --> C[Tunnel diagnostics]
 B[Live SSH tunnel state] --> C
 C --> D[Browser setup guidance]
 D --> E{Explicit remote browser port?}
 E -->|Yes| F[Use explicit port]
 E -->|No| G[Derive remote gateway port plus two]
 F --> H[Sanitized clipboard instructions]
 G --> H
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test LOC production +23/-2, tests +60/-0 The bounded production growth implements safe remote-port derivation and is accompanied by three focused regression cases.

Technical review

Best possible solution:

Keep copied diagnostics guidance consistent with the managed tunnel's remote-port mapping while preserving explicit endpoints and safe placeholders.

Do we have a high-confidence way to reproduce the issue?

Yes, source establishes the defect: local gateway port 19000, remote port 18789, and no explicit browser endpoint cause current main to copy remote port 19002 instead of 18791. Reviewer did not execute a failing runtime reproduction.

Is this the best way to solve the issue?

Yes, this bounded formatter repair follows the existing managed-tunnel mapping and preserves explicit endpoints; no broader connection change is needed.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 94006b3672a0.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. Current-head native Windows output exercises the production deep-link clipboard service and changed guidance formatter with asymmetric gateway ports, producing 19002 to 18791 after SSH failure clears the explicit browser endpoint. This satisfies the previous clipboard-output request; the uninvoked card and absent live SSH session do not undermine the changed text behavior. No stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Current-head native Windows output exercises the production deep-link clipboard service and changed guidance formatter with asymmetric gateway ports, producing 19002 to 18791 after SSH failure clears the explicit browser endpoint. This satisfies the previous clipboard-output request; the uninvoked card and absent live SSH session do not undermine the changed text behavior. No stored-data contract changes.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This repairs incorrect copied setup guidance for asymmetric SSH ports with a limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Current-head native Windows output exercises the production deep-link clipboard service and changed guidance formatter with asymmetric gateway ports, producing 19002 to 18791 after SSH failure clears the explicit browser endpoint. This satisfies the previous clipboard-output request; the uninvoked card and absent live SSH session do not undermine the changed text behavior. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. Current-head native Windows output exercises the production deep-link clipboard service and changed guidance formatter with asymmetric gateway ports, producing 19002 to 18791 after SSH failure clears the explicit browser endpoint. This satisfies the previous clipboard-output request; the uninvoked card and absent live SSH session do not undermine the changed text behavior. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • RBrid: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Sebastien Tardif: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-09-30T15:13:35.937Z sha 3e0be3a :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-30T15:30:19.595Z sha 9459dfe :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-30T17:27:12.809Z sha 9459dfe :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-30T17:53:01.721Z sha 9459dfe :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-07T03:46:18.596Z sha 9459dfe :: needs real behavior proof before merge. :: none

Tray UI tests aborted after 5 minutes of inactivity during MarkdownRendererCoalesceTests and ThemeResolveColorFallbackTests. The browser SSH line is unchanged.

Signed-off-by: Sebastien Tardif <[email protected]>
@shanselman shanselman added status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. and removed status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. labels Sep 30, 2026
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 7, 2026
@karkarl

karkarl commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Global triage: HOLD_FOR_AUTHOR. Take confidence 20%; recommendation confidence 98%; effort small; risk high.

Reviewed exact head 9459dfe651f2. GitHub currently reports CLEAN with 31 passing, 1 failing, and 0 pending checks. proof label is sufficient. Durable automated signal: Codex review: needs maintainer review before merge..

Author: investigate the 1 failing check(s), establish whether each failure is branch-owned, and publish a green exact-head CI Gate before reconsideration.

This is a triage classification, not a merge action. No branch changes were made.

@bkudiess
bkudiess merged commit 69276a1 into openclaw:main Oct 20, 2026
31 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants