Skip to content

Refactor preview port scanner Effect patterns#3082

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/idiomatic-effect-patterns-77d8
Draft

Refactor preview port scanner Effect patterns#3082
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/idiomatic-effect-patterns-77d8

Conversation

@cursor

@cursor cursor Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Added an Effect Context.Reference for the preview port scanner platform, so tests can provide win32 through a layer instead of mutating process.platform.
  • Replaced command-scan null fallbacks with Effect.option/Option handling and switched timeout constants to Duration.seconds values.
  • Updated the port scanner test file to use @effect/vitest assertions in the touched coverage.

Why

This keeps the preview port scanner more idiomatic and testable with Effect: runtime platform is now injectable via context, expected command failures are modeled as optional fallbacks, and tests no longer monkey-patch global Node state.

UI Changes

None.

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

Verification:

  • pnpm --filter t3 exec vp test run src/preview/PortScanner.test.ts (17 tests passed)
  • pnpm exec vp run typecheck
  • pnpm exec vp check (0 errors, 11 existing warnings)
Open in Web View Automation 

Note

Refactor PortScanner to inject platform context and use Effect-native patterns

  • Introduces CurrentPlatform as a Context.Reference in PortScanner.ts, replacing direct reads of process.platform so the Windows code path can be injected in tests without monkey-patching.
  • Replaces null-based fallback control flow with Effect.option and Option.isSome checks in PortDiscovery.make.
  • Replaces numeric millisecond timeout constants with Duration-based constants (LSOF_TIMEOUT, WINDOWS_LISTENER_TIMEOUT).
  • Migrates PortScanner.test.ts assertions from expect to @effect/vitest assert APIs, updates the mock ProcessRunner to return a typed ProcessSpawnError, and supplies CurrentPlatform via the test layer.

Macroscope summarized ba5fd84.

cursoragent and others added 2 commits June 14, 2026 16:06
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jun 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Expo continuous deployment is ready!

  • Project → t3-code
  • Platforms → android, ios
  • Scheme → t3code-preview
  🤖 Android 🍎 iOS
Fingerprint ae17d94b35f91f9c608a63dadbc3ddd9f4ba056e 313e506a7f15a9c3f15b01d787d68a12382432bf
Build Details Build Permalink
DetailsDistribution: INTERNAL
Build profile: preview:dev
Runtime version: ae17d94b35f91f9c608a63dadbc3ddd9f4ba056e
App version: 0.1.0
Git commit: 817bb447f46bb6025ac1ab7864fd54273ee18150
Build Permalink
DetailsDistribution: INTERNAL
Build profile: preview:dev
Runtime version: 313e506a7f15a9c3f15b01d787d68a12382432bf
App version: 0.1.0
Git commit: 817bb447f46bb6025ac1ab7864fd54273ee18150
Update Details Update Permalink
DetailsBranch: pr-3082
Runtime version: ae17d94b35f91f9c608a63dadbc3ddd9f4ba056e
Git commit: 817bb447f46bb6025ac1ab7864fd54273ee18150
Update Permalink
DetailsBranch: pr-3082
Runtime version: 313e506a7f15a9c3f15b01d787d68a12382432bf
Git commit: 817bb447f46bb6025ac1ab7864fd54273ee18150
Update QR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant