fix(tui): follow active gateway port#73338
Conversation
|
Implemented the #42461 fix in Local verification:
@codex review |
Greptile SummaryThis PR fixes a bug where Confidence Score: 5/5This PR is safe to merge — the logic is correct, precedence rules are preserved, and the new seam is well-tested. No P0 or P1 findings. The implementation correctly handles all stated precedence rules (explicit --url wins, remote mode wins, unknown/dead lock owners return undefined). The port probe and process-cmdline liveness checks are correctly composed. Tests cover the happy path, the cmdline-mismatch staleness case, the --url override, and the remote-mode bypass. No files require special attention. Reviews (1): Last reviewed commit: "fix(tui): follow active gateway port" | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 11a3eb9b6a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Pushed Changes since the first pass:
Local verification:
@codex review |
|
Codex review: needs changes before merge. Reviewed July 6, 2026, 12:18 AM ET / 04:18 UTC. Summary PR surface: Source +45, Tests +108, Docs +3. Total +156 across 8 files. Reproducibility: yes. Source inspection of the PR head shows a malformed non-empty Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Keep the lock-backed approach, but make TUI suppress the active-lock fallback only when the explicit env port parses as a valid Gateway port, with regression coverage for malformed and out-of-range env values. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection of the PR head shows a malformed non-empty Is this the best way to solve the issue? No. The lock-backed owner-boundary fix is the right direction, but the current implementation is incomplete until it uses parsed env-port semantics before suppressing the active Gateway lock fallback. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 37f96bde4d90. Label changesLabel justifications:
Evidence reviewedPR surface: Source +45, Tests +108, Docs +3. Total +156 across 8 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (2 earlier review cycles) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ba1903819f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
ba19038 to
749091d
Compare
|
Rebased on latest main and addressed the Codex lock-owner review. Updates:
Local verification:
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Pushed another rebase-stabilization commit: What changed:
Verification:
@codex review |
173282c to
fe5e768
Compare
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Rebased on upstream Post-rebase verification:
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
fe5e768 to
a478889
Compare
|
Heads up: this PR needs to be updated against current |
7699175 to
a7df7bf
Compare
a7df7bf to
95057f5
Compare
95057f5 to
4f4b048
Compare
|
Maintainer rewrite pushed as The PR now keeps the active custom port in the Gateway-owned lock, verifies the live lock owner before using it, and makes the TUI consume that port only as a local fallback. Explicit Proof on Blacksmith Testbox
Exact-head land-ready update: 6a1a9bb is the clean current-main-plus-reviewed-patch head. Hosted CI run https://github.com/openclaw/openclaw/actions/runs/28767171420 passed at that exact SHA. The rebase changed ancestry only; the tested diff and Testbox/browser/PTY proof above are unchanged. Known proof gaps: none. |
a28abeb to
c936787
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c936787ba6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const hasExplicitGatewayTarget = Boolean( | ||
| urlOverride || | ||
| env.OPENCLAW_GATEWAY_URL?.trim() || | ||
| env.OPENCLAW_GATEWAY_PORT?.trim() || |
There was a problem hiding this comment.
Don't let invalid port env suppress active lock
In environments where OPENCLAW_GATEWAY_PORT is present but invalid or out of range, resolveGatewayPort deliberately ignores it and falls back to config/defaults, but this Boolean still treats the raw value as an explicit target and skips readActiveGatewayLockPort(). That means openclaw tui can again connect to the configured/default port instead of a live Gateway started with --port 48789 whenever a stale/malformed port env var is inherited; please use the same parsed-port semantics before suppressing the active-lock lookup.
Useful? React with 👍 / 👎.
c936787 to
d87d063
Compare
Co-authored-by: haishmg <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
|
Merged via squash.
|
Summary
openclaw tuicould still build its default local Gateway URL from config/defaults after a Gateway was started with an explicit runtime--port.--urlmanually or the client triedws://127.0.0.1:18789.--url, remote Gateway config, auth selection, and non-loopback websocket security precedence are preserved.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
--portoverride.48789makes defaultopenclaw tuiconnect tows://127.0.0.1:48789.Regression Test Plan (if applicable)
src/tui/gateway-chat.test.ts,src/infra/gateway-lock.test.ts48789drives default TUI URL resolution while explicit--urland remote config still win.User-visible / Behavior Changes
openclaw tuiwithout--urlnow follows the active local Gateway runtime port recorded by the running Gateway.Diagram (if applicable)
Security Impact (required)
Yes, explain risk + mitigation: N/ARepro + Verification
Environment
Steps
openclaw gateway --port 48789.openclaw tuiwithout--url.Expected
ws://127.0.0.1:48789.Actual
ws://127.0.0.1:18789.Evidence
Human Verification (required)
CI=true OPENCLAW_LOCAL_CHECK=0 npm exec [email protected] -- test src/tui/gateway-chat.test.ts src/infra/gateway-lock.test.tsnpm exec [email protected] -- exec oxfmt --check src/infra/gateway-lock.ts src/infra/gateway-lock.test.ts src/tui/gateway-chat.ts src/tui/gateway-chat.test.ts docs/cli/tui.md docs/gateway/troubleshooting.mdCI=true OPENCLAW_LOCAL_CHECK=0 npm exec [email protected] -- run check:changedReview Conversations
Compatibility / Migration
Risks and Mitigations
--urlremains the override.Maintainer Verification - 2026-05-30
Behavior addressed: default
openclaw tuiGateway resolution follows the active local Gateway lock port when a Gateway is running on a non-default port.Real environment tested: macOS source checkout at
4f4b04875ad, isolated OpenClaw home/state, Gateway auth modenone, loopback Gateway on48789.Exact steps or command run after this patch:
node --import tsx src/entry.ts gateway run --dev --allow-unconfigured --auth none --bind loopback --port 48789 --ws-log compact --verbose node --import tsx --input-type=module # imported src/tui/gateway-chat.ts, called resolveGatewayConnection({}), GatewayChatClient.connect({}), waitForReady(), getGatewayStatus()Evidence after fix:
Observed result after fix: the TUI Gateway client resolved and connected to the custom active Gateway port
48789, then successfully calledstatus.What was not tested: full human keystroke rendering inside the terminal UI; this proof covers the TUI Gateway connection/resolver path and real WebSocket handshake, not terminal paint behavior.
Real behavior proof - Maintainer verification 2026-05-30
Behavior addressed: default
openclaw tuiGateway resolution follows the active local Gateway lock port when a Gateway is running on a non-default port.Real environment tested: macOS source checkout at
4f4b04875ad, isolated OpenClaw home/state, Gateway auth modenone, loopback Gateway on48789.Exact steps or command run after this patch:
node --import tsx src/entry.ts gateway run --dev --allow-unconfigured --auth none --bind loopback --port 48789 --ws-log compact --verbose node --import tsx --input-type=module # imported src/tui/gateway-chat.ts, called resolveGatewayConnection({}), GatewayChatClient.connect({}), waitForReady(), getGatewayStatus()Evidence after fix:
Observed result after fix: the TUI Gateway client resolved and connected to the custom active Gateway port
48789, then successfully calledstatus.What was not tested: full human keystroke rendering inside the terminal UI; this proof covers the TUI Gateway connection/resolver path and real WebSocket handshake, not terminal paint behavior.