Skip to content

Windows port PR 2: local dev experience#536

Open
ldstreet wants to merge 3 commits into
windows/pr1-compile-launchfrom
windows/pr2-dev-experience
Open

Windows port PR 2: local dev experience#536
ldstreet wants to merge 3 commits into
windows/pr1-compile-launchfrom
windows/pr2-dev-experience

Conversation

@ldstreet
Copy link
Copy Markdown
Collaborator

Summary

  • setup-windows.ps1 (2a) — idempotent bootstrap: VS Build Tools components, Rust 1.95.0 (CI pin), Node LTS (bun has no Win-ARM binary), Git for Windows (provides Git Bash for the ORT helper), just (justfile runner), VC++ redists, LLVM, and a frontend/.env.local template. Defensively strips a UTF-8 BOM from an existing .env.local (PS 5.1 default-BOM I/O is a notorious footgun).
  • tauri-windows.ps1 + tauri.windows.conf.json (2b) — one-command just windows-build / just windows-dev wrappers. Handles vcvarsall.bat lookup, CARGO_TARGET_DIR off-source (Parallels-safe), ORT helper invocation, and the bun→npm overlay. Wraps both native and cross-arch builds (arch=arm64 / x64 / arm64_amd64).
  • docs (2c) — docs/windows-build.md end-to-end guide, frontend/.env.local.template, README (Prerequisites + Development sections mirroring macOS/Linux/iOS), CLAUDE.md (.env.local requirement note).

Stacked on #520

Base branch is windows/pr1-compile-launch, not master. Wait for #520 to merge before this can land on master.

Patterns mirrored from #520 / master

  • Rust 1.95.0 pin via -RustToolchain parameter (matches dtolnay/rust-toolchain in CI)
  • ORT helper extended for arm64: onnxruntime-pins.sh gets windows_arm64_* entries; provide-windows-onnxruntime.sh reads ORT_TARGET_ARCH (default x64, so CI behavior unchanged). tauri-windows.ps1 derives it from -Arch.
  • iOS recipe-delegates-to-script idiom (just ios-build-onnxruntime → script; same shape for just windows-buildtauri-windows.ps1)
  • README per-platform Prerequisites + Development sections (added Windows blocks parallel to macOS/Linux/iOS)
  • Inline # why: comments on every non-obvious workaround (MSYS2 path mangling, --passive vs --quiet, BOM-strip, etc.)

Manual smoke

Validated end-to-end on Parallels Win11 ARM64: git checkoutsetup-windows.ps1just windows-dev → Maple launches to login screen with Vite hot-reload. onnxruntime.dll loads at runtime on native ARM64 (extends #520's x64-under-emulation data point).

Out of scope

  • Authenticode signing — PR 7 (MPLR-goufxxvn)
  • Native ARM64 shipping decision — MPLR-xhfehqft spike, still todo (partial data now: build + app launch confirmed on ARM64; CI cost / WebView2 / ort native-arm64 coverage TBD)

Test plan

  • build-windows jobs (both PR + master push) pass — should be unaffected since ORT_TARGET_ARCH defaults to x64
  • Fresh Win11 VM: git clonesetup-windows.ps1just windows-dev succeeds in ~30 min (the "Done when" criterion for MPLR-rqofgxpz)
  • just windows-build on ARM64 produces a working native NSIS installer

🤖 Generated with Claude Code

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aba8ab6e-0763-4e82-afba-aebe3cc72275

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 windows/pr2-dev-experience

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 and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 26, 2026

Deploying maple with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2f47114
Status: ✅  Deploy successful!
Preview URL: https://4c03f287.maple-ca8.pages.dev
Branch Preview URL: https://windows-pr2-dev-experience.maple-ca8.pages.dev

View logs

@ldstreet ldstreet force-pushed the windows/pr2-dev-experience branch from f3d5dae to 2e31359 Compare May 26, 2026 17:02
@ldstreet ldstreet force-pushed the windows/pr1-compile-launch branch from 4e074dc to c5e79a2 Compare May 26, 2026 17:10
@ldstreet ldstreet force-pushed the windows/pr2-dev-experience branch from 2e31359 to 19af7c4 Compare May 26, 2026 17:10
ldstreet and others added 3 commits May 26, 2026 13:31
Idempotent PowerShell bootstrap for a fresh Win10/11 (x64 or ARM64) dev
machine. Installs the Visual Studio Build Tools 2022 components, Node.js
LTS, rustup, and standalone LLVM that PR 1's manual smoke discovered the
hard way; writes a working frontend/.env.local template pointing at the
prod enclave URL; safe to re-run.

scripts/setup-windows.ps1 (MPLR-vuskayhx / 2a):
- Preflight: PowerShell version, OS caption, admin check, winget
  availability, ExecutionPolicy relaxation (npm.ps1 needs RemoteSigned).
- winget packages: VC++ 2015+ x64 (and ARM64 on ARM hosts — rollup's
  native module links against it), Node.js LTS (bun has no Win-ARM
  binary), rustup, LLVM.LLVM (backstop for `ring` 0.17 on
  aarch64-pc-windows-msvc, which needs clang for ARM64 asm even when
  the VS clang-cl component is present).
- VS Build Tools 2022: downloads vs_BuildTools.exe and installs the
  exact components needed (VCTools workload, VC.Tools.x86.x64,
  VC.Tools.ARM64, VC.Llvm.Clang, Windows11SDK.22621). Branches on whether
  BuildTools is already installed: 'modify' subcommand with --installPath
  for adding to an existing install (avoids exit-1 from redundant --add
  args on top of present components), full install with
  --includeRecommended otherwise. --passive instead of --quiet because
  --quiet swallows exit codes on the modify path. Single-string
  ArgumentList with explicit quoting because Start-Process -ArgumentList
  <array> doesn't reliably quote space-containing paths in PowerShell 5.1.
  Verifies on disk via vswhere after install completes — 'finished
  install' from the bootstrapper doesn't always mean components landed.
- Rust toolchain: pinned to 1.95.0 via a new -RustToolchain script
  parameter (default '1.95.0') that matches the CI pin in
  .github/workflows/desktop-build.yml + desktop-pr-build.yml. Installs
  the toolchain if absent, sets it as default, then on ARM64 hosts also
  adds x86_64-pc-windows-msvc as an extra target so the same machine can
  cross-compile the x64 Tauri bundle.
- frontend/.env.local template: writes UTF-8 (no BOM, since Vite chokes
  on a BOM in .env files) with VITE_OPEN_SECRET_API_URL pointing at the
  prod enclave URL. Closes the silent white-screen-on-launch footgun
  caught during PR 1 smoke (Vite bakes env vars at build time, so an
  empty .env.local bundles empty strings).
- ASCII-only output (the file itself is BOM-less ASCII). The few cases
  where flavor text in 'Next steps' wants an em-dash use '--' instead.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Closes the second half of PR 1's pain: every fresh Windows shell needed a
Developer PowerShell open (vcvarsall.bat), cargo target dir on the source
tree breaks on Parallels shared folders, and the ort crate would
auto-download an unpinned ONNX Runtime instead of using the SHA-verified
CI helper. These wrappers eliminate all three so the dev loop is a single
`just windows-dev`.

frontend/src-tauri/tauri.windows.conf.json (MPLR-kgoqxeac / 2b):
- Minimal Tauri config overlay that swaps bun -> npm for
  beforeDevCommand / beforeBuildCommand. bun has no Windows ARM64 binary
  (Node.js LTS via winget is the established workaround per
  setup-windows.ps1) so the default `bun dev` / `bun run build` would fail
  before tauri ever ran. Applied via `--config` from the just recipes,
  not the default config -- everywhere else still uses bun.

scripts/tauri-windows.ps1 (MPLR-kgoqxeac / 2b):
- One PowerShell wrapper that handles `tauri build` and `tauri dev` based
  on a -Command parameter. Steps the dev would otherwise hand-roll on
  every invocation:
  1. Locate VS Build Tools via vswhere (errors if setup-windows.ps1
     hasn't been run).
  2. Set CARGO_TARGET_DIR to %USERPROFILE%\maple-cargo-target (off the
     source tree so Parallels shared-folder writes don't corrupt cargo
     metadata). Overridable via -CargoTargetDir.
  3. Source frontend/src-tauri/scripts/provide-windows-onnxruntime.sh via
     Git Bash; parse its KEY=VALUE output and import as process env vars.
     This mirrors how desktop-build.yml + desktop-pr-build.yml feed those
     three vars into \$GITHUB_ENV -- local dev gets the same SHA-pinned
     ORT as CI. -SkipOrt falls back to the ort crate's auto-download.
  4. Chain vcvarsall.bat <arch> with the tauri command in a single
     cmd.exe invocation so the MSVC env survives into the build. Apply
     the Windows overlay via --config.
- Defaults to arch=arm64 (Snapdragon X laptops + Apple Silicon Parallels
  are the primary audience); arm64_amd64 / x64 also accepted.

justfile (MPLR-kgoqxeac / 2b):
- New `windows-build` and `windows-dev` recipes, both guarded by the
  [windows] attribute (just hides them off-Windows so the recipe list
  stays clean for mac/linux devs). Each is a one-line PowerShell call
  into scripts/tauri-windows.ps1 with the corresponding -Command.
- Recipes accept an `arch` parameter that pipes straight through to
  vcvarsall (same arg shape as the iOS ios-dev-sim simulator parameter).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Closes the doc gap from PR 1 smoke: without docs, the next Windows
contributor would rediscover every gotcha the hard way (clang-cl
requirement, Parallels target-dir corruption, vcvarsall arch confusion,
silent white-screen from missing .env.local).

frontend/.env.local.template (MPLR-yeksjfcj / 2c):
- Template with prod enclave URL pre-filled, comments explain the Vite
  build-time-baking gotcha and which vars are overridable. setup-windows.ps1
  writes the same content into .env.local automatically; this file gives
  mac/linux devs (and non-bootstrap Windows devs) the same source of truth.
- Kept .env.example as-is (abstract / self-hoster oriented); the new
  template is the working-default counterpart.

docs/windows-build.md (MPLR-yeksjfcj / 2c):
- End-to-end Windows dev guide: prerequisites (link to setup-windows.ps1),
  first build (just windows-build), iteration loop (just windows-dev),
  .env.local handling, gotchas table covering every footgun PR 1 smoke
  hit, CI vs local parity matrix (Rust 1.95.0, ORT 1.22.0 helper, Tauri
  overlay), and pointers to MPLR-goufxxvn (code signing) +
  MPLR-xhfehqft (native ARM64 shipping decision) for what's deferred.

README.md (MPLR-yeksjfcj / 2c):
- New "Windows" subsection under Prerequisites mirroring the existing
  macOS / Linux blocks: one-line setup invocation + link to the full
  guide.
- New "Windows Development" section parallel to "iOS Development":
  the just windows-build / windows-dev quick reference + brief note on
  what the wrappers handle, plus a link to docs/windows-build.md.

CLAUDE.md (MPLR-yeksjfcj / 2c):
- Note in the Environment section that .env.local is required for any
  local build on any platform. Calls out the silent white-screen failure
  mode and points at the template + Windows-specific automation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ldstreet ldstreet force-pushed the windows/pr2-dev-experience branch from 19af7c4 to 2f47114 Compare May 26, 2026 17:39
@ldstreet ldstreet marked this pull request as ready for review May 26, 2026 18:19
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

@ldstreet ldstreet requested a review from AnthonyRonning May 26, 2026 20:24
Copy link
Copy Markdown
Contributor

@AnthonyRonning AnthonyRonning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I like many of these changes, nix should be used instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this points to a local backend which I don't expect us to really be running on a windows vm? to validate and test the windows build I think it probably makes sense to point to a prod/staging environment. but this file definitely feels like a duplicate, what if we point to /.env.example but in the windows setup we overwrite the value to be a real env?

Comment thread scripts/tauri-windows.ps1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this at all. Please use nix on windows.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd definitely love to use nix to stay consistent with the other platforms but my understanding is windows doesn't support nix unless you run it in a linux subsystem but then you wouldn't be able to compile the windows artifacts you need. did you have a specific strategy in mind for using nix on windows?

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.

2 participants