fix(tui): honor active Gateway runtime port in TUI connection#393
Open
BingqingLyu wants to merge 4 commits into
Open
fix(tui): honor active Gateway runtime port in TUI connection#393BingqingLyu wants to merge 4 commits into
BingqingLyu wants to merge 4 commits into
Conversation
Fixes openclaw#42461 - Apply applyGatewayRuntimePortEnvOverride() before resolving TUI Gateway URL - Ensures TUI connects to the correct port when Gateway runs on custom port - Added port field to gateway lock payload for runtime port discovery
…PID in TUI port override - In acquireGatewayLock, pass lastPayload?.port (existing gateway's port) to resolveGatewayOwnerStatus instead of opts.port (new gateway's port). This prevents incorrectly declaring a live gateway as dead when two gateways target different ports. - In applyGatewayRuntimePortEnvOverride, verify the PID is still alive before applying the port from the lock file. This prevents using a stale lock from a crashed gateway. - Update tests to reflect correct behavior: lock files now include port field, and liveness checks use the lock holder's port. Fixes review feedback from PR openclaw#42496.
Two review fixes for PR openclaw#42496: 1. readLockPayload: validate port range (1-65535) before returning. Prevents ERR_SOCKET_BAD_PORT when a stale/corrupted lock contains an out-of-range port. 2. applyGatewayRuntimePortEnvOverride: also check legacy CLAWDBOT_GATEWAY_PORT env var when deciding whether to apply the lock file port override, preserving backward compatibility. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…non-integer ports
- Guard applyGatewayRuntimePortEnvOverride against PID reuse: when a lock
carries startTime, compare it against the current process start time
read from /proc/{pid}/stat before trusting the runtime-port override.
If the times differ the lock is stale (PID recycled) and is ignored.
- Add Number.isInteger check in readLockPayload so malformed locks with
fractional ports (e.g. 18789.5) are treated as missing, preventing
ERR_SOCKET_BAD_PORT from net.createConnection during owner probes.
- Export readLinuxStartTime so it can be used by paths.ts for the
startTime verification above.
Addresses chatgpt-codex-connector[bot] P2 comments on openclaw#42496.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
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
Fixes openclaw#42461
The TUI connection path now applies the active Gateway runtime port override before resolving the connection target. This ensures that when the Gateway is running on a custom port (e.g., 48789), the TUI automatically connects to that port instead of defaulting to 18789.
Changes
portfield to the gateway lock payload insrc/infra/gateway-lock.tsapplyGatewayRuntimePortEnvOverride()function insrc/config/paths.tsto read the lock file and setOPENCLAW_GATEWAY_PORTenv varapplyGatewayRuntimePortEnvOverride()at the start ofresolveGatewayConnection()insrc/tui/gateway-chat.tsTesting
Fixes openclaw#42461