Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(preview): preserve direct localhost navigation #3939

MergedChrrxs(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/3939/headmerged by juliusmarminge View on GitHub

What Changed

  • Treat preview address-bar submissions as direct URL targets by using the existing explicit { kind: "url" } navigation intent.
  • Normalize schemeless direct targets (localhost:5173 to HTTP and public hosts to HTTPS) without consulting the environment connection or remapping loopback hosts.
  • Keep empty-state server cards on discovered-server routing, including WSL environment-host remapping.
  • Add regression coverage for explicit localhost URLs, schemeless direct targets, and empty-state server-card remapping.

Why

Address-bar submissions incorrectly reused the resolver intended for discovered servers. In WSL environments, that resolver replaced loopback hosts with the environment IP, so entering https://localhost:8000/dashboard?mode=test#top navigated to https://172.25.85.75:8000/dashboard?mode=test#top instead.

Using the existing direct-URL intent fixes that boundary without adding a new abstraction or changing server-discovery behavior. Direct targets still use the shared URL normalizer, preserving the prior scheme defaults for schemeless input. Fixes #3938.

UI Changes

No visual UI, animation, motion, timing, or interaction-design changes. The deterministic navigation result changes as follows:

Address-bar result
BeforeThe entered loopback host could be replaced with the WSL environment IP.
AfterThe entered protocol, loopback host, port, path, query, and fragment are preserved.

Screenshots and video are therefore not applicable.

Validation

  • vp test run --passWithNoTests --project unit from apps/web — 1,283 tests passed
  • vp run typecheck from apps/web
  • vp check from the repository root
  • vp run typecheck from the repository root — all 15 workspace tasks passed

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes (not applicable; no visual UI change)
  • I included a video for animation/interaction changes (not applicable; no animation or interaction-design change)

Note

Low Risk Narrow preview navigation routing change with regression tests; no auth, data, or broad architectural impact.

Overview Fixes preview address-bar navigation in remote environments (e.g. WSL) where typed loopback URLs were incorrectly rewritten to the environment host IP.

Address bar submissions now go through resolveBrowserNavigationTarget with { kind: "url" }, which applies normalizePreviewUrl for schemeless input but does not remap loopback hosts via the environment connection. Empty-state discovered servers still use resolveDiscoveredServerUrl via handleOpenServerUrl, so localhost dev servers continue to map onto the WSL/private-network host when picked from the server list.

Regression tests cover direct localhost preservation, schemeless direct URLs, empty-state remapping, and resolver unit behavior.

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

Note

Fix direct localhost URL navigation in preview chrome row

  • URL submission via the chrome row now calls normalizePreviewUrl instead of resolveDiscoveredServerUrl, preserving direct localhost URLs rather than remapping them to the environment host.
  • URLs opened from the empty state still go through resolveDiscoveredServerUrl via a new handleOpenServerUrl handler in PreviewView.tsx.
  • A shared navigateToResolvedUrl callback centralizes the logic for driving previewBridge.navigate and calling rememberPreviewUrl.
Macroscope summarized f6b2915.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      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: da5e6309-b94e-4ecf-8afd-4ff0b1b11651

      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

      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.

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

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved

      This is a targeted bug fix that preserves direct localhost URLs in WSL environments by using appropriate URL normalization based on navigation context. The change is well-scoped with clear intent and includes comprehensive test coverage.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).

      Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 7c723d8b330f681181002facd1d3b8177ffe633e. Configure [here](https://www.cursor.com/dashboard/bugbot).
    5. juliusmarminge merged this2fae0d0

    6. juliusmarminge closed this

Sign in to join this conversation.