fix: target the live server port for server-backed CLI commands - #264
Conversation
`webmux serve` walks to a free port when 5111 is taken (e.g. a service installed on 5112), but server-backed CLI commands (oneshot, linear, send) hardcoded the 5111 default and never consulted the instance registry — so they tried to connect to a port nothing was listening on and failed. In-process commands (add, list, open, ...) were unaffected, which is why `webmux add` worked while `webmux oneshot` did not. Resolve the port from the live instance registry by matching the current project's dir when --port/PORT isn't set, falling back to the sole live instance, then the 5111 default. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Claude finished @rubenfiszel's task in 4m 12s —— View job Code Review: PR #264 — fix: target the live server port for server-backed CLI commandsThis is a clean, well-scoped fix for a real bug. The pure-function + I/O-wrapper split, the comprehensive test for ✅ Strengths
🟡 Minor observations
Verification notes
SummaryLGTM. The minor items above (especially the
|
|
Claude finished @rubenfiszel's task in 2m 59s —— View job Code Review — PR #264
Overall: clean fix with good pure/IO separation and solid coverage of the project-matching logic. The fallback chain ( Findings🟡 Worktree cwd does not match the registered
|
Summary
Follow-up to #263. That PR fixed the error message when the webmux server is unreachable, but the underlying cause of
webmux oneshot --linear=<TEAM>failing withUnable to connect...was a port mismatch: the server was running on 5112 (awebmux serve --port 5112service) while the CLI hardcoded the 5111 default.webmux servewalks to a free port when 5111 is taken, but server-backed CLI commands (oneshot,linear,send) only ever used--port/PORT/5111 and never consulted the instance registry — so they connected to a dead port. In-process commands (add,list,open, ...) talk to tmux/git/fs directly, which is whywebmux addworked whilewebmux oneshotdidn't.This resolves the live instance's port from the registry by matching the current project dir when
--port/PORTisn't set.Changes
bin/src/instance-port.ts(new):selectInstancePort(pure) +resolveLiveServerPort(I/O) resolve the port of the live webmux instance serving the current project, falling back to the sole live instance, then the default.bin/src/webmux.ts: when--port/PORTisn't set, resolve the live server port before dispatching CLI commands;--debuglogs the resolved source.serveis unaffected. Updated--porthelp text.bin/src/instance-port.test.ts: project match, subdir match, preference over other instances, sole/default fallbacks, and a sibling-prefix guard.Test plan
bun test bin/src/instance-port.test.tspasseswebmux serve --port 5112running for the current project,webmux oneshot --prompt 'x' --linear=TEAM(no--port) connects to 5112 instead of failing on 5111webmux --debug oneshot ...logsresolved port 5112 from live instance (project)webmux --port 5111 ...still forces 5111 (explicit port wins)Generated with Claude Code