Skip to content

fix(cli): make local startup collision-safe - #609

Merged
Aymericr merged 1 commit into
mainfrom
fix/cli-startup-feedback
Aug 7, 2026
Merged

fix(cli): make local startup collision-safe#609
Aymericr merged 1 commit into
mainfrom
fix/cli-startup-feedback

Conversation

@Aymericr

@Aymericr Aymericr commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • let the operating system select a free loopback port by default
  • fall back automatically when an explicitly requested port is already occupied
  • report a foreign health responder immediately instead of waiting 30 seconds
  • show live, durable setup stages and useful first-run next steps
  • exercise the real default-port path in the packed-runtime smoke test

Root cause

The released smoke test always passed --port 0, so it skipped the default port-selection path. On macOS, a service listening on the IPv6 wildcard could own port 3000 while the CLI's IPv4 bind probe still appeared to succeed. Pascal then started on 3000, health requests reached the foreign app, and the CLI waited for the full health timeout.

Verification

  • bunx biome check packages/cli/README.md packages/cli/scripts/smoke-packed-runtime.ts packages/cli/src/bin/pascal.ts packages/cli/src/editor-process.ts packages/cli/src/runtime.test.ts packages/cli/src/terminal-progress.ts packages/cli/src/terminal-progress.test.ts
  • bun run --cwd packages/cli check-types
  • bun test packages/cli/src (23 pass)
  • bun run --cwd packages/cli build
  • bun run --cwd packages/cli build-runtime
  • bun run --cwd packages/cli stage-runtime
  • bun run --cwd packages/cli smoke-runtime
  • clean packed-tarball lifecycle with another application occupying port 3000

Note

Medium Risk
Changes default binding and port/health logic for the managed local editor process; behavior is covered by new tests and smoke coverage but affects every local start path.

Overview
Makes local editor startup avoid port clashes and fail fast when something else is already listening.

Port selection now defaults to an OS-assigned free loopback port (preferredPort 0 instead of 3000). If you pass --port <n> and that port already accepts connections, Pascal picks another port automatically instead of probing a fixed range or erroring. README documents this behavior.

Health checks distinguish Pascal from other apps on the same port: a non-matching /api/health response raises port_conflict immediately instead of waiting out the full health timeout.

Interactive pascal editor (non---json) shows staged progress via new TerminalProgress and EditorStartProgress callbacks through startEditor. First-time runtime installs get a short “next steps” block (status, logs --follow, stop).

Tests and smoke: packed-runtime smoke occupies port 3000 (IPv6 wildcard) and asserts the editor does not bind there; unit tests cover occupied-port fallback and fast foreign-health failure.

Reviewed by Cursor Bugbot for commit 6181f60. Bugbot is set up for automated code reviews on this repo. Configure here.

@Aymericr
Aymericr merged commit 81cd17d into main Aug 7, 2026
3 checks passed
@Aymericr
Aymericr deleted the fix/cli-startup-feedback branch August 7, 2026 13:37
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