Skip to content
Source
Sign inSign up
pingdotgg/t3code

Select desktop backend port by sequential scan #1870

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/1870/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

So that your host is more stable across restarts when doing remote

What Changed

Why

UI Changes

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Medium Risk Changes desktop backend port selection during startup, which can affect app launch reliability and port-collision behavior if the preferred range is busy. Logic is straightforward and covered by new unit tests, but it touches the bootstrap path.

Overview Desktop startup now selects the backend port by sequentially probing from a stable preferred port (default 3773) instead of reserving a random ephemeral loopback port.

This introduces resolveDesktopBackendPort (with validation and bounded scan) plus Vitest coverage, and updates main.ts bootstrap/logging to use the new resolver.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit ca8118f26f6733bcedd9d7a08d4a0b17f618d68f. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Select desktop backend port by sequential scan from port 3773

  • Replaces NetService.reserveLoopbackPort with a new resolveDesktopBackendPort function in backendPort.ts that scans ports sequentially from a start port until it finds one available via canListenOnHost.
  • When T3CODE_PORT is unset, the desktop app now selects a backend port by scanning from DEFAULT_DESKTOP_BACKEND_PORT (3773) on the loopback host.
  • Validates startPort and maxPort inputs and throws if no available port is found within the range.
  • Behavioral Change: port selection now uses the first available port starting at 3773 rather than reserving an OS-assigned loopback port.
Macroscope summarized ca8118f.
    1. Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: 53a1d1ab-b7f7-4d38-8c24-ef8214a0da6c

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `feature/desktop-backend-port-scan`

      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. Approvability

      Verdict: Approved

      This PR refactors desktop backend port selection from ephemeral reservation to predictable sequential scanning starting at port 3773. The change is self-contained, includes comprehensive unit tests, and the author has recent ownership of the affected code. Low risk runtime behavior change with clear intent.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. juliusmarminge merged thise82b987

    5. juliusmarminge closed this

Sign in to join this conversation.