refactor(cli): resolve platform-dependent paths inside the domains - #1409
Conversation
Every composite root resolved a platform-dependent binary path and passed `platform` as a separate dep field. A test could pair `platform: "win32"` with a path some other platform resolved, and the domain forwarded that platform to the spawn — a pairing production never produces. The deps now carry the platform plus the inputs a path needs, so one value decides both the path and the spawn. `playwrightCliCandidates` in core/ replaces `shell/playwright.ts`; the domains pick the first existing candidate via their `checkExists` dep. WIZ-11280
WalkthroughThe refactor centralizes Playwright candidate discovery in Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/domains/doctor/checks/androidAppium.ts`:
- Line 7: Move the pure resolveAppiumBin implementation from shell/appium into
core, preserving its deterministic path-building behavior and zero-I/O contract.
Update all consumers, including the Android Appium doctor check, to import the
core symbol, and remove or stop using the shell location so shell remains
limited to I/O.
In `@src/domains/install/android/driver.ts`:
- Line 4: Move the pure resolveAppiumBin implementation from the shell layer
into an appropriate src/core path-resolution module, preserving its behavior and
exports. Update the Android driver import and every other reference to use the
new ~/core/... location, and remove the obsolete shell definition.
In `@src/domains/runtimeEnv/resolvePinned.ts`:
- Around line 37-38: Update the Playwright resolution logic around
playwrightCliCandidates so POSIX environments require the extension-less
playwright shim and do not treat playwright.cmd alone as resolved. Keep Windows
support for the .cmd wrapper, using platform-aware validation consistent with
the candidates returned by playwrightCliCandidates.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 12523886-348c-42ca-b827-20cfd5c9ed40
📒 Files selected for processing (28)
AGENTS.mdsrc/commands/doctor/handler.tssrc/commands/flows/buildFlowsRunDeps.tssrc/commands/install/android.tssrc/commands/install/browsers.fixtures.tssrc/commands/install/browsers.test.tssrc/commands/install/browsers.tssrc/core/messages/install.tssrc/core/playwrightBins.test.tssrc/core/playwrightBins.tssrc/domains/doctor/checks/android.fixtures.tssrc/domains/doctor/checks/android.test.tssrc/domains/doctor/checks/android.tssrc/domains/doctor/checks/androidAppium.tssrc/domains/doctor/checks/index.tssrc/domains/doctor/checks/playwright.test.tssrc/domains/doctor/checks/playwright.tssrc/domains/doctor/checks/runChecks.test.tssrc/domains/install/android/avd.test.tssrc/domains/install/android/avd.tssrc/domains/install/android/driver.test.tssrc/domains/install/android/driver.tssrc/domains/install/android/index.tssrc/domains/install/android/installAndroid.test.tssrc/domains/install/browsers.tssrc/domains/runtimeEnv/resolvePinned.tssrc/shell/playwright.test.tssrc/shell/playwright.ts
💤 Files with no reviewable changes (4)
- src/shell/playwright.ts
- src/shell/playwright.test.ts
- src/commands/doctor/handler.ts
- src/commands/install/android.ts
Relates to WIZ-11280
Overview of Changes
Every composite root resolved a platform-dependent binary path and then passed
platformas a separate dep field, so a test could pairplatform: "win32"with a path some other platform resolved. The domain forwarded that platform to the spawn, which routed a POSIX path through cmd.exe — a pairing production never produces. The deps now carry the platform plus the inputs a path needs (env dir, android home), and the domain resolves the path itself, so one value decides both the path and the spawn.shell/playwright.tsis gone. Its win32 candidate list is now a pureplaywrightCliCandidates(envDir, platform)incore/, and the domains pick the first existing candidate through theircheckExistsdep instead of callingexistsSyncbehind a throw. That also drops the try/catch in the doctor handler.installUiautomator2Driverwas not in the issue, but leaving it mismatchable while its siblinginstallAvdswas fixed would have been worse.Testing
bun run typecheck bun run lint bun run format:check bun run knip bun run test bun run buildAll pass;
bun run testis 1221 pass / 0 fail. Five new tests assert win32 resolution at each seam — playwright candidate ordering, the doctor Playwright and Appium checks,install browsers, andinstall android. Each failed before its fix; the Appium one reproduced the issue exactly, pairingplatform: "win32"with a POSIX path. Expected paths are built withjoin, so they stay correct on a win32 host (see WIZ-11279).Checklist
Structural only — no behavior change. Follow-ups filed while reviewing: WIZ-11283 (the one surviving instance, in
createAppiumServer) and WIZ-11284 (two different Playwright-not-found strings). WIZ-11281 should land on top of this;resolvePinned.tskeeps a second hardcoded shim-name list that must change with the candidate list, noted on that issue.