Skip to content

fix(server): improve remote port fallback handling - #3

Merged
foxytanuki merged 2 commits into
personalfrom
fix/437-remote-port-range-fallback
Mar 31, 2026
Merged

foxytanuki merged 2 commits into
personalfrom
fix/437-remote-port-range-fallback

Conversation

@foxytanuki

@foxytanuki foxytanuki commented Mar 31, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • fall back across the default remote port range (19432-19439) instead of failing immediately on the first occupied port
  • detect Bun port conflicts reliably via err.code === "EADDRINUSE" while keeping the Pi runtime aligned with the same retry behavior
  • update tests and docs to reflect remote range fallback and exact-port retry semantics

What this does

  • remote sessions can recover when 19432 is already occupied by trying the next port in the default range
  • explicit PLANNOTATOR_PORT still preserves exact-port behavior
  • Bun and Pi now agree on port-conflict handling

What this does not solve

  • it does not provide a good cross-integration story for telling the user which port was ultimately chosen
  • that is especially awkward in Claude Code, where the PermissionRequest / ExitPlanMode success path does not offer a clean user-visible channel for a custom Plannotator is ready at http://... message

Related workaround

  • OpenCode-specific URL notification workaround: feat(opencode): show plan review URL in session #2
  • that makes the URL visible, but it relies on session.prompt() rather than a proper status/tool UI surface, so it comes with tradeoffs like queued delivery and session noise

Why this stays fork-only for now

This improves backend robustness, but the UX is still incomplete until the chosen port can be surfaced cleanly across integrations. Because of that, I’m treating this as a reference implementation rather than something I’d upstream as-is.

Testing

  • bun test packages/server/remote.test.ts apps/pi-extension/server/network.test.ts

Check EADDRINUSE via error codes so remote port fallback still advances when Bun omits the code from the message. Keep the retry logic aligned across Bun and Pi runtimes with regression coverage for Bun-style errors.
@foxytanuki
foxytanuki merged commit 658acd5 into personal Mar 31, 2026
@foxytanuki
foxytanuki deleted the fix/437-remote-port-range-fallback branch April 4, 2026 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant