fix(cli): stop a sibling start from persisting its port into config.port - #3232
Conversation
#3188 opened the sibling path: `ocx start --port X` beside a live proxy on the configured port starts a second instance instead of refusing. That instance went through chooseListenPort with X as its hard-pinned preference, so shouldPersistSelectedPort(config.port, X, X) was true and config.port was rewritten to X under the still-running configured-port proxy. Observed: a probe session ran `start --port 10198` a few times against the real home, exited, and left config.port=10198 behind. The next `ocx stop` + `ocx service` read config.port, baked `--port 10198` into the launchd plist, and re-pointed Codex's openai_base_url at 10198 -- the service silently moved off 10100 with no start on 10198 in sight. A sibling is a second instance, not a new home for this config, so it must never persist its port. handleStart now records the sibling decision and passes it into both chooseListenPort call sites (initial pick and the EADDRINUSE re-pick); shouldPersistSelectedPort returns false for it. The ordinary first-start persist and the fallback-port non-persist are unchanged.
|
✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthrough
ChangesSibling port persistence
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change prevents sibling starts from persisting a temporary port into the saved configuration; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
리뷰 · 우선순위 74 / 80이 PR은 #3188이 연 메인테이너 실기에서 재현됐습니다. 프로브로 고침은 작습니다. 테스트도 핵심만 짚습니다. 라인 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
Summary
ocx start --port Xbeside a live proxy on the configured port starts a second instance instead of refusing. That instance goes throughchooseListenPortwithXas its hard-pinned preference, soshouldPersistSelectedPort(config.port, X, X)is true andconfig.portis rewritten toXunder the still-running configured-port proxy.start --port 10198a few times against the real home, exited, and leftconfig.port=10198behind. The nextocx stop+ocx servicereadconfig.port, baked--port 10198into the launchd plist, and re-pointed Codexopenai_base_urlat 10198 — the service silently moved off 10100 with no start on 10198 in sight.handleStartnow records the sibling decision and passes{ sibling: true }into bothchooseListenPortcall sites (initial pick and the EADDRINUSE re-pick);shouldPersistSelectedPortreturns false for it. The ordinary first-start persist and the fallback-port non-persist are unchanged.Verification
bun run typecheckbun test tests/ports.test.ts tests/cli-dispatch.test.ts tests/update-notify.test.ts— 66 pass / 0 failshouldPersistSelectedPortsibling case ((10100, 10198, 10198, { sibling: true })→ false; same args without the flag → true)chooseListenPortcall sites inhandleStartcarrysibling: siblingStart, so the re-pick path cannot silently regain the old behaviorocx config set port 10100+ocx service→ plist--port 10100,/healthzon 10100,openai_base_urlback on 10100.Checklist
Summary by CodeRabbit
Bug Fixes
Tests