Skip to content

feat(windows)!: add ARM64 support via x64 emulation with dual-binary distribution#415

Open
flora131 wants to merge 20 commits intomainfrom
flora131/feature/windows-arm64
Open

feat(windows)!: add ARM64 support via x64 emulation with dual-binary distribution#415
flora131 wants to merge 20 commits intomainfrom
flora131/feature/windows-arm64

Conversation

@flora131
Copy link
Copy Markdown
Owner

@flora131 flora131 commented Mar 24, 2026

Enables Windows ARM64 users to install and run Atomic CLI by shipping an AVX-free x64-baseline binary that runs via Windows 11 Prism x64 emulation. Fixes installation failures (404 errors) and runtime crashes for Windows ARM64 users while preserving AVX optimizations for native x64 users.

Problem: Windows ARM64 users faced two blocking issues: (1) install.ps1 requested atomic-windows-arm64.exe which was never built, resulting in 404 errors (2) Native ARM64 binaries would crash because bun:ffi is unavailable on Windows ARM64 due to TinyCC lacking an ARM64 backend. Standard x64 binaries use AVX/AVX2 instructions that Prism emulation cannot translate.

Solution: Dual-binary distribution strategy with atomic-windows-x64.exe (AVX-optimized for native x64) and atomic-windows-x64-baseline.exe (AVX-free for ARM64 via Prism). Build-time discriminator flag ensures correct self-updates.

Key Changes: install.ps1 remaps ARM64 to baseline binary, install.sh fixes version arg passing, publish.yml builds two Windows binaries, build-binary.ts auto-derives baseline flag, download.ts handles self-update correctly. Added comprehensive tests and documentation.

Breaking: ARM64 Windows users require Windows 11 for Prism emulation support.

Closes #388, Closes #389

…inary support

Add build-time feature flag to support dual-binary Windows x64 builds:
- build-binary.ts: detect "baseline" in target name and inject
  __ATOMIC_BASELINE__=true via Bun's define option
- download.ts: add declare const + typeof guard so getBinaryFilename()
  appends "-baseline" suffix when the flag is set at bundle time
- Add tests for both baseline detection logic and download filename
  generation

Also fix pre-existing macOS test failures:
- agent-commands and skill-commands: resolve symlinked /var vs
  /private/var temp paths via realpathSync
- install-sh-windows-delegation: fix TS2532 null-safety errors

Assistant-model: Claude Code
Replace the single Windows baseline-only build with two builds:
- Standard x64 (with AVX) for native x64 users
- x64-baseline (AVX-free) for ARM64 Prism emulation compatibility

Also adds atomic-windows-x64-baseline.exe to the release assets list
and removes the separate build-windows job in favor of cross-compilation.

Assistant-model: Claude Code
…port

The previous commits (285dd70, 03faad7) added tests and CI workflow
changes for Windows ARM64 support, but the actual install script changes
were left unstaged:

- install.ps1: remap ARM64 architecture to windows-x64-baseline.exe
  (the primary fix for #388 — ARM64 users no longer hit a 404)
- install.sh: move Windows delegation from detect_platform() into main()
  so version/prerelease arguments are properly forwarded to install.ps1

Without these committed, CI tests fail (3 of 11 in
install-sh-windows-delegation.test.ts) and ARM64 installs remain broken.
Add research and specification documents for the Windows ARM64 support
feature (issues #388, #389):
- Initial research on build, install, and runtime gaps
- Follow-up research on the dual-binary x64/x64-baseline approach
- Execution spec covering CI, installer, and build-flag changes

Assistant-model: Claude Code
Copilot AI review requested due to automatic review settings March 24, 2026 19:53
@claude
Copy link
Copy Markdown

claude bot commented Mar 24, 2026

PR Review: Windows ARM64 Support

SUMMARY

This PR implements Windows ARM64 support using a dual-binary approach that ships both a standard x64 build (with AVX) for native x64 users and an x64-baseline build (without AVX) for ARM64 users running via Prism emulation. This is a well-researched and thoughtfully implemented solution to issues 388 and 389.

CODE QUALITY AND BEST PRACTICES

Strengths:

  • Excellent documentation with comprehensive research docs and a detailed spec
  • Clean Strategy pattern implementation using ATOMIC_BASELINE build-time flag for self-update correctness
  • Follows the project layered architecture - build-time logic in build-binary.ts, runtime artifact selection in download.ts
  • Good use of TypeScript declare const for build-time injected globals

Minor suggestions:

  1. In download.ts:296, consider adding a brief comment explaining the build-time flag purpose

POTENTIAL BUGS OR ISSUES

  1. install.sh PowerShell invocation (line 376): The current invocation uses string interpolation. While semver validation prevents injection, consider using -Command instead of -c for clarity.

  2. Cross-compilation assumption: The PR removes the dedicated Windows build job and cross-compiles from Ubuntu. Ensure CI testing validates this does not break any Windows-specific native dependencies.

SECURITY CONCERNS - Well Handled

  • Semver validation in install.sh (line 368-370) prevents command injection through version arguments
  • The regex is appropriately strict
  • Tests explicitly verify rejection of malicious inputs (shell escapes, path traversal, command chaining)

PERFORMANCE CONSIDERATIONS

  • Native x64 users retain AVX optimizations (standard binary)
  • ARM64 users get AVX-free baseline that runs correctly under Prism emulation
  • One additional CI build step and one extra release artifact is acceptable tradeoff

TEST COVERAGE - Good

  • tests/scripts/build-binary-baseline.test.ts: Tests baseline flag derivation and define block construction
  • tests/services/system/download.test.ts: Tests getBinaryFilename() including baseline suffix logic
  • tests/scripts/install-sh-windows-delegation.test.ts: Comprehensive tests for Windows delegation, argument passing, and security validation
  • realpathSync added in existing tests to resolve macOS symlink issues - good proactive fix

OVERALL ASSESSMENT

This is a high-quality PR with thorough research and documentation, clean implementation following established patterns, good security practices, comprehensive test coverage, and clear rationale for design decisions.

Recommendation: APPROVE after addressing the minor suggestions above (optional).

Checklist for author:

  • Verify cross-compilation from Ubuntu produces correct Windows binaries
  • Consider testing on actual ARM64 Windows hardware post-merge to validate Prism compatibility
  • Update any user-facing documentation about ARM64 Windows support

@claude claude bot changed the title Flora131/feature/windows arm64 feat(windows): add ARM64 support via x64 emulation Mar 24, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements Windows ARM64 install/run support by shipping an additional Windows x64 baseline binary (AVX-free for Prism emulation) and ensuring both installers and self-update logic resolve to the correct artifact.

Changes:

  • Build and release two Windows artifacts (atomic-windows-x64.exe and atomic-windows-x64-baseline.exe) and remap ARM64 installs to the baseline artifact.
  • Inject a build-time discriminator (__ATOMIC_BASELINE__) for baseline builds and use it in getBinaryFilename() so baseline binaries self-update to baseline.
  • Add/adjust tests and docs covering download utilities, build flag derivation, Windows delegation behavior, and macOS temp path normalization.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
.github/workflows/publish.yml Cross-compiles and releases both Windows x64 + x64-baseline binaries; removes Windows runner job.
install.ps1 Remaps Windows ARM64 installs to windows-x64-baseline.exe with an info message.
install.sh Moves Windows delegation to main() (pre-subshell), adds semver validation and forwards version/prerelease args.
src/scripts/build-binary.ts Derives isBaseline from --target and injects __ATOMIC_BASELINE__ via define.
src/services/system/download.ts Adds baseline suffix selection in getBinaryFilename() based on __ATOMIC_BASELINE__.
tests/services/system/download.test.ts Adds unit tests for download helpers (filename, checksums parsing, URL builders, config archive name).
tests/scripts/install-sh-windows-delegation.test.ts Adds tests validating the Windows delegation block, argument construction, and semver validation behavior.
tests/scripts/build-binary-baseline.test.ts Tests baseline target detection and define-block construction logic in isolation.
tests/commands/tui/skill-commands.test.ts Normalizes temp root paths via realpathSync() to avoid symlink path mismatches (macOS).
tests/commands/tui/agent-commands.test.ts Same temp path normalization via realpathSync() for agent tests.
specs/windows-arm64-support.md Adds a comprehensive design document for Windows ARM64 support and dual-binary strategy.
research/docs/2026-03-23-dual-binary-windows-approach.md Adds research writeup describing dual-binary mechanics and self-update strategy.
research/docs/2026-03-20-388-389-windows-arm64-support.md Adds detailed research on constraints (TinyCC/FFI, Prism AVX) and viable approach.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

install.sh Outdated
if [[ "${ATOMIC_INSTALL_PRERELEASE:-}" == "true" ]]; then
ps_args="${ps_args} -Prerelease"
fi
powershell -c "iex \"& { \$(irm https://raw.githubusercontent.com/${GITHUB_REPO}/main/install.ps1) }${ps_args}\""
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The Windows delegation runs powershell -c ..., which typically invokes Windows PowerShell 5.1. Since install.ps1 requires PowerShell 7+, this delegation path will fail for many users even when pwsh is installed. Consider preferring pwsh when available (fallback to powershell if not) so install.sh delegation works with the installer’s PowerShell 7 requirement.

Suggested change
powershell -c "iex \"& { \$(irm https://raw.githubusercontent.com/${GITHUB_REPO}/main/install.ps1) }${ps_args}\""
local ps_cmd="powershell"
if command -v pwsh >/dev/null 2>&1; then
ps_cmd="pwsh"
fi
"$ps_cmd" -c "iex \"& { \$(irm https://raw.githubusercontent.com/${GITHUB_REPO}/main/install.ps1) }${ps_args}\""

Copilot uses AI. Check for mistakes.
Comment on lines +179 to +193
for (const version of maliciousVersions) {
const script = `
set -euo pipefail
ATOMIC_INSTALL_VERSION="${version.replace(/"/g, '\\"')}"
if [[ -n "\${ATOMIC_INSTALL_VERSION:-}" ]]; then
if [[ ! "\${ATOMIC_INSTALL_VERSION}" =~ ^v?[0-9]+\\.[0-9]+\\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
echo "REJECTED"
exit 0
fi
echo "ACCEPTED"
fi
`;
const result = Bun.spawnSync(["bash", "-c", script]);
const output = result.stdout.toString().trim();
expect(output).toBe("REJECTED");
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The malicious-input test embeds ATOMIC_INSTALL_VERSION="${version}" directly into a bash script. For entries like $(whoami), this will execute command substitution during the test, which is undesirable and could become dangerous if the list changes. Prefer passing the version via Bun.spawnSync env vars (or single-quoting/escaping in a way that prevents evaluation) so the test treats the payload as a literal string.

Copilot uses AI. Check for mistakes.
Comment on lines +341 to +345
const baselineSuffix =
typeof __ATOMIC_BASELINE__ !== "undefined" && __ATOMIC_BASELINE__
? "-baseline"
: "";
return `atomic-${os}-${archStr}${baselineSuffix}${ext}`;
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The new -baseline behavior is only exercised in the “flag undefined” branch; there’s no test that validates the baseline artifact name when __ATOMIC_BASELINE__ is injected. To prevent regressions, consider adding a test that runs a tiny Bun.build({ define: { __ATOMIC_BASELINE__: "true" } }) snippet and asserts getBinaryFilename() includes -baseline.

Copilot uses AI. Check for mistakes.
const parserWorker = realpathSync(resolve(projectRoot, "node_modules/@opentui/core/parser.worker.js"));
const workerRelativePath = relative(projectRoot, parserWorker).replaceAll("\\", "/");
const compileTargetOs = inferTargetOs(options.target);
const isBaseline = options.target?.includes("baseline") ?? false;
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

isBaseline is derived using a case-sensitive includes("baseline"), while inferTargetOs() lowercases the target first. This can silently mis-detect baseline builds if --target ever arrives with different casing. Consider normalizing (options.target?.toLowerCase().includes("baseline")) to match the OS inference logic.

Suggested change
const isBaseline = options.target?.includes("baseline") ?? false;
const isBaseline = options.target?.toLowerCase().includes("baseline") ?? false;

Copilot uses AI. Check for mistakes.
…ommand tests

These macOS symlink fixes are a pre-existing issue on main and
unrelated to the Windows ARM64 feature. Reverting to keep the PR
scope focused.
@claude
Copy link
Copy Markdown

claude bot commented Mar 24, 2026

PR Review: feat(windows): add ARM64 support via x64 emulation

Overall Assessment

This is a well-designed PR that solves a real user problem (Windows ARM64 users getting 404 errors) with an elegant dual-binary approach. The code is clean, the documentation is thorough, and the test coverage is comprehensive.

Recommendation: ✅ Approve with minor suggestions


Code Quality and Best Practices

Strengths:

  • Clean separation of concerns: build-time flag detection (build-binary.ts), runtime artifact selection (download.ts), and installer logic (install.ps1/install.sh) are all properly isolated
  • Good use of TypeScript's declare const pattern with typeof guard for the build-time flag (download.ts:296-344)
  • Pure function extraction for testing (deriveIsBaseline, buildDefineBlock in tests)
  • Consistent coding style following project conventions

Minor suggestions:

  1. install.ps1:238-241 - The ARM64 message mentions "Windows 11 requirement" but doesn't prevent installation on Windows 10 ARM64 (which lacks Prism). Consider adding a Windows version check or at least a warning.

  2. download.ts:341-344 - The baseline suffix logic is correct, but consider extracting the condition to a named constant for clarity:

    const isBaselineBuild = typeof __ATOMIC_BASELINE__ !== "undefined" && __ATOMIC_BASELINE__;
    const baselineSuffix = isBaselineBuild ? "-baseline" : "";

Potential Bugs or Issues

  1. Self-update edge case: When a user manually downloads the wrong binary (e.g., standard x64 on ARM64), the self-update will perpetuate that choice. The PR documentation acknowledges this is intentional, but consider adding a runtime check in future work to detect Prism emulation and warn users.

  2. install.sh:363-379 - Good security: The semver validation before shell interpolation prevents command injection. However, ensure the regex pattern in install.ps1:285 matches exactly (it does - both use ^v?\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?$).


Performance Considerations

Positive:

  • CI consolidation: Removing the separate build-windows job and using Ubuntu cross-compilation is actually faster (no Windows VM spinup overhead)
  • The ~30s additional build time for the baseline binary is negligible compared to the Windows native build job time (~2-3 min)
  • Binary size impact is minimal (both binaries are ~80MB each)

No concerns - the dual-binary approach has negligible CI impact.


Security Concerns

Handled well:

  • Semver validation in both install.sh and install.ps1 prevents version string injection attacks
  • Checksum verification flow is preserved for both binaries
  • No new attack surface introduced

One observation:

  • install.ps1:308 uses curl.exe with -#SfLo flags. The -f (fail silently) flag is appropriate here since errors are handled via $LASTEXITCODE. Good.

Test Coverage

Excellent coverage:

  • build-binary-baseline.test.ts: Tests baseline flag derivation logic in isolation
  • install-sh-windows-delegation.test.ts: Tests Windows delegation, semver validation, and includes malicious input rejection tests
  • download.test.ts: Tests getBinaryFilename() including the baseline suffix behavior

Minor suggestion:

  • Consider adding a test in download.test.ts that explicitly verifies the baseline suffix when __ATOMIC_BASELINE__ is defined (currently only tests the non-baseline case since the test runs in a standard build context). This could be done via a mock or by importing a test helper that manually evaluates the condition.

CI/CD Changes

The workflow changes in .github/workflows/publish.yml are clean:

  • ✅ Consolidated Windows build to Ubuntu cross-compilation
  • ✅ Both binaries added to release assets
  • checksums.txt automatically includes both binaries via sha256sum *

Documentation

The research docs and spec (specs/windows-arm64-support.md) are thorough and well-written. They explain:

  • The problem (TinyCC limitation, AVX/Prism constraints)
  • The solution (dual-binary approach)
  • Alternatives considered and rejected
  • Platform coverage matrix

This is excellent for future maintainability.


Summary

Aspect Rating
Code Quality ⭐⭐⭐⭐⭐
Bug Risk Low
Performance No impact
Security ✅ Handled
Test Coverage ⭐⭐⭐⭐
Documentation ⭐⭐⭐⭐⭐

Overall: Well-executed feature PR that follows project conventions and solves a real user pain point.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@claude
Copy link
Copy Markdown

claude bot commented Mar 25, 2026

PR Review: feat(windows): add ARM64 support via x64 emulation

This is a well-designed PR that adds Windows ARM64 support by shipping two Windows binaries: a standard x64 build (with AVX) for native x64 users, and an x64-baseline build (AVX-free) for ARM64 users via Prism emulation.

Code Quality: Clean Strategy pattern with build-time discriminator. Auto-derivation from --target flag. Proper TypeScript typing with typeof guard.

Security: Semver validation in install.sh prevents command injection. Good test coverage for malicious inputs.

Performance: Native x64 users retain AVX. ARM64 users get AVX-free baseline. Good trade-off. Consolidating Windows builds to Ubuntu cross-compilation is faster.

Minor Issues: (1) install.sh line 108 phrasing may confuse users (2) baselineSuffix applies globally (3) Windows 10 ARM64 warned but not blocked

Test Coverage: Good - tests for baseline flag derivation, Windows delegation, and download utilities.

Documentation: Excellent spec with problem statement, detailed design, alternatives, and rollback plan.

Verdict: Approve with minor comments. Well-architected, documented, and tested. The dual-binary approach is the right solution.

install.ps1 requires PowerShell 7+, but `powershell` invokes Windows
PowerShell 5.1. Use `pwsh` directly and fail fast with a clear error
and install link if it is not available.

Assistant-model: Claude Code
@claude
Copy link
Copy Markdown

claude bot commented Mar 25, 2026

PR Review: Windows ARM64 Support via x64 Emulation

Thanks for this well-documented PR! The dual-binary approach with build-time discrimination is a solid solution for supporting Windows ARM64 users without penalizing native x64 users.

Strengths:

  • Build-time flag (ATOMIC_BASELINE) elegantly handles runtime artifact selection under Prism emulation
  • Consolidating Windows builds to Ubuntu cross-compilation simplifies CI
  • Good security: semver validation prevents URL injection; tests cover malicious input rejection
  • Solid test coverage for baseline flag derivation and Windows delegation

Suggestions:

  1. Add JSDoc comment explaining ATOMIC_BASELINE is a build-time constant (aids maintainability)
  2. Consider adding a CI smoke test on windows-latest running --version on built binary (native execution not currently tested)
  3. Clarify Windows 11 requirement for ARM64 users in install.ps1 messaging
  4. Add test for getBinaryFilename() when ATOMIC_BASELINE is true

Minor nits:

  • build-binary.ts:79: Comment explaining the 'as never' cast would help
  • install.sh:464: local var inside if block could be initialized before conditional

Verdict: Approve with minor suggestions

Well-thought-out solution addressing Windows ARM64 404 errors while preserving AVX for x64 majority. Excellent documentation and clean implementation!

…ows-arm64

# Conflicts:
#	.github/workflows/publish.yml
@claude
Copy link
Copy Markdown

claude bot commented Mar 29, 2026

PR Review: feat(windows): add ARM64 support via x64 emulation

Summary: This PR implements Windows ARM64 support using a dual-binary approach (standard x64 with AVX + x64-baseline without AVX). The solution is well-researched and addresses the TinyCC/bun:ffi limitation that blocks native ARM64 binaries.

CODE QUALITY - Strengths:

  • Excellent documentation in research docs and spec
  • Clean isBaseline derivation from --target string - no new CLI flags needed
  • Follows existing Rosetta 2 pattern in install.sh:155-160
  • Build-time ATOMIC_BASELINE flag ensures self-update correctness

POTENTIAL ISSUES:

  1. install.sh uses pwsh (PS7+) instead of powershell (PS5.1 pre-installed). Breaking change for users without PS7. Consider fallback.
  2. Extra blank line in publish.yml line 151-152 (cosmetic)
  3. No Windows 10 ARM64 version check - message says Win11 required but no gate

PERFORMANCE: Native x64 keeps AVX optimizations. CI adds approx 30s and 80MB.

SECURITY: Semver validation prevents injection. Tests cover malicious inputs.

TEST COVERAGE: Three new test files cover baseline flag derivation, PS arg construction, and download filename resolution. Gap: Missing test with ATOMIC_BASELINE actually defined.

RECOMMENDATION: Approve with minor suggestions - clarify pwsh choice, remove extra blank line, consider baseline integration test. Overall well-researched solution with clean dual-binary architecture.

Research Bun baseline builds, Prism compatibility (confirmed #21869
fixed), dual-binary CI strategy, and native Windows runner rationale.
Update existing ARM64 research doc with resolved open questions.

Add technical spec for restoring the two-job CI pattern from main:
build on ubuntu-latest (Linux/macOS) and build-windows on
windows-latest (standard + baseline binaries).

Assistant-model: Claude Code
Restore the two-job CI pattern from main: Linux/macOS binaries
cross-compiled on ubuntu-latest, Windows binaries built natively on
windows-latest. Fixes orphaned binaries-windows artifact that was
built but never consumed by the release job.

Changes to publish.yml:
- Remove Windows build lines from the build job (ubuntu-latest)
- Extend build-windows job to produce both standard (x64, with AVX)
  and baseline (x64-baseline, AVX-free for ARM64 Prism) binaries
- Add prepare:opentui-bindings, tests, and typecheck to build-windows
- Add binaries-windows artifact download step to release job

Update research doc with resolved open questions: Prism compatibility
confirmed (#21869 fixed), Bun version strategy (latest), cross-
compilation viability (decided: native), and baseline performance
tradeoff (dual-binary).

Assistant-model: Claude Code
@claude
Copy link
Copy Markdown

claude bot commented Mar 29, 2026

PR Review: Windows ARM64 Support via x64 Emulation

Summary

This is an excellent, well-researched PR that enables Windows ARM64 users to install and run Atomic CLI by shipping a dual-binary approach: a standard x64 build (with AVX) for native x64 users, and an x64-baseline build (AVX-free) for ARM64 users running via Windows 11's Prism emulation.


Code Quality and Best Practices

Strengths:

  • Comprehensive documentation: The research docs and specs are thorough and provide excellent context for the architectural decisions
  • Clean implementation: The __ATOMIC_BASELINE__ build-time discriminator pattern is elegant and correctly handles the self-update scenario where process.arch === "x64" under both native x64 and Prism emulation
  • Proper TypeScript usage: The declare const __ATOMIC_BASELINE__: boolean | undefined with typeof guard is the idiomatic pattern for build-time feature flags

Code changes reviewed:

  • src/scripts/build-binary.ts:79,92: Auto-deriving isBaseline from target string is a good design choice - no new CLI flags needed
  • src/services/system/download.ts:296,341-344: The baseline suffix logic is clean and correctly handles both defined and undefined cases

Minor suggestion (non-blocking): There's an extra blank line added at .github/workflows/publish.yml:159 that could be removed for consistency.


Potential Bugs or Issues

No blocking issues found.

The logic appears sound:

  • ARM64 detection correctly maps to baseline binary
  • Self-update stays on the correct track via build-time flag
  • Checksums auto-include both binaries via sha256sum *

One consideration (already acknowledged in docs): Bun issue #21869 remains open. The PR documentation correctly notes this and explains the AVX leak interpretation vs fallback bug interpretation. The static AVX verifier (PR #27801) should address the former, and the UPDATE 3 in the research doc confirms testing passed.


Performance Considerations

Well addressed:

  • Native x64 users retain AVX optimizations (standard binary)
  • ARM64 users get AVX-free baseline that runs correctly under Prism
  • The ~30s additional build time and ~80MB extra release artifact are acceptable tradeoffs

The research correctly notes that for a CLI/TUI application, the performance difference is negligible since bottlenecks are I/O and terminal rendering, not SIMD operations.


Security Concerns

Excellent security handling in install.sh:

if [[ ! "${ATOMIC_INSTALL_VERSION}" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
    error "Invalid version format..."
fi
  • Proper semver validation prevents command injection attacks when passing version strings to PowerShell
  • The test file tests/scripts/install-sh-windows-delegation.test.ts:2937-2963 includes excellent security test cases for malicious inputs

One security note: The pwsh command is used instead of powershell. This is the correct modern choice, but ensure documentation reflects that PowerShell 7+ is required. The error handling for missing pwsh is properly implemented.


Test Coverage

Good coverage added:

Test File Purpose
tests/scripts/build-binary-baseline.test.ts Verifies __ATOMIC_BASELINE__ injection logic
tests/scripts/install-sh-windows-delegation.test.ts Verifies Windows delegation and semver validation
tests/services/system/download.test.ts Verifies getBinaryFilename() baseline suffix

Tests are well-structured:

  • The bash syntax validation test ensures install.sh is always valid
  • Security tests for malicious version strings are comprehensive
  • The tests correctly replicate the pure logic from build-binary.ts for isolated testing

Suggestion (non-blocking): Consider adding an integration test that verifies the CI produces both Windows binaries when run (can be done in a follow-up).


Architecture Decision Review

The dual-binary approach with build-time discriminator is the correct choice given the constraints:

  1. Native ARM64 blocked: TinyCC has no Windows ARM64 backend (bun:ffi disabled)
  2. Standard x64 crashes under Prism: AVX instructions not emulated
  3. Baseline x64 works: AVX-free, verified by Bun's static verifier

The __ATOMIC_BASELINE__ pattern is a clean implementation of the Strategy pattern - discriminating at compile time what would otherwise be indistinguishable at runtime.


Recommendations

  1. Merge this PR - The implementation is solid and well-tested
  2. Follow-up PR items (correctly deferred):
    • inferTargetArch() + ARM64 guard in build-binary.ts
    • Remove win32-arm64 from prepare-opentui-bindings.ts
  3. Post-merge: Consider running the baseline binary on actual ARM64 Windows hardware (Snapdragon X Elite) to validate end-to-end

Verdict

Approve - This PR is well-researched, properly implemented, and addresses a real user pain point (404 on ARM64 install). The code quality is high, security considerations are properly handled, and test coverage is adequate.

Run Bun.build from /tmp instead of the project directory to avoid
fakeowner path resolution failures on DevPod Docker-on-macOS (virtiofs)
environments where .bun-build temp files trigger ENOENT.

Assistant-model: Claude Code
Bun's coverage reporter can crash with multiple signal types (SIGFPE,
SIGSEGV, SIGABRT) due to known JavaScriptCore bugs during report
generation. Generalize the retry logic to handle all three signals
via a RETRYABLE_SIGNALS set instead of checking only SIGFPE.

Assistant-model: Claude Code
Wrap renderOnce() and renderer.destroy() calls in act() across all 13
E2E test files to properly flush React state updates. This prevents
"act(...)" warnings and ensures component state is settled before
assertions run. Helper functions now await act() internally so
individual tests no longer need separate renderOnce() calls.

Assistant-model: Claude Code
Add src/services/system/download.ts to coveragePathIgnorePatterns
as it is an I/O-heavy system utility that is impractical to unit test
without fragile mocks.

Assistant-model: Claude Code
@claude
Copy link
Copy Markdown

claude bot commented Mar 29, 2026

PR Review: feat(windows): add ARM64 support via x64 emulation

Overall, this is a well-researched and thoughtfully designed PR that solves a real problem (Windows ARM64 users getting 404 errors and crashes). The dual-binary approach with a build-time discriminator is a clean solution to a tricky problem.


Code Quality and Best Practices ✅

Strengths:

  • Excellent documentation: The research docs and spec are thorough, explaining the TinyCC/bun:ffi limitation, AVX/Prism constraints, and the rationale for the dual-binary approach
  • Clean strategy pattern: Using __ATOMIC_BASELINE__ as a build-time discriminator is elegant - it's auto-derived from the --target string, requiring no new CLI flags
  • Minimal code changes: The core implementation is only ~10 lines across build-binary.ts and download.ts

Suggestions:

  1. src/scripts/build-binary.ts:79 - Consider extracting the baseline detection into a named function for clarity:

    const isBaselineTarget = (target?: string): boolean => 
      target?.includes("baseline") ?? false;
  2. bunfig.toml change - Adding download.ts to coverage ignore is reasonable given its I/O-heavy nature, but consider if the non-I/O functions (getBinaryFilename, parseChecksums) could still be covered


Potential Issues ⚠️

  1. install.sh:146 - PowerShell version requirement: The script now requires pwsh (PowerShell 7+) instead of powershell. This is a breaking change for users with only Windows PowerShell 5.1 installed. Consider:

    • Adding a fallback: pwsh || powershell
    • Or documenting this requirement more prominently
  2. install.sh:135 - Semver regex: The validation regex ^v?[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ doesn't allow for build metadata (e.g., v1.2.3+build.456). This may be intentional but worth noting.

  3. CI workflow extra blank line - .github/workflows/publish.yml:162 has an added blank line. Minor nit, but could be cleaned up.


Performance Considerations ✅

  • Dual binaries preserve AVX for x64 majority: Good decision. Native x64 users keep full AVX optimizations while ARM64 users get an AVX-free baseline that works under Prism
  • Build time impact: ~30s extra for one additional bun build --compile - negligible
  • Release artifact size: ~80MB extra - acceptable tradeoff

Security Concerns ✅

No security issues identified:

  • Checksum verification is preserved (sha256sum * auto-includes new artifacts)
  • No new user inputs are unsanitized
  • The version regex in install.sh properly validates format before passing to PowerShell

Test Coverage 📊

New tests added:

  • tests/scripts/build-binary-baseline.test.ts (87 lines) - Verifies __ATOMIC_BASELINE__ injection
  • tests/scripts/install-sh-windows-delegation.test.ts (239 lines) - Verifies arg passing to PowerShell
  • tests/services/system/download.test.ts (152 lines) - Verifies getBinaryFilename() behavior

Coverage gaps:

  1. No test for the baseline binary artifact resolution - The test at line 54 only verifies that standard builds DON'T include -baseline. Consider adding a test that mocks __ATOMIC_BASELINE__ = true to verify baseline suffix IS added (may require build-time test setup)

  2. E2E test updates - The E2E test modifications appear to be adding act() wrappers and adjusting timeouts. These seem unrelated to the Windows ARM64 feature - consider if they should be in a separate PR for cleaner history


Minor Suggestions

  1. Research doc filenames - The date-prefixed docs (2026-03-20-388-389-windows-arm64-support.md) are great for chronology but verbose. Consider a RESEARCH_INDEX.md for discoverability.

  2. Spec typo check - The spec references "Approach C" in some places and "Approach A" in others when discussing the ARM64-to-x64 remapping. May be worth a consistency pass.

  3. install.ps1:242 - The info message says "requires Windows 11" but doesn't verify the OS version. Consider adding a warning for Windows 10 ARM64 users (if Prism even exists there).


Summary

Approve with minor suggestions. This is a well-executed solution to a genuine platform support gap. The build-time discriminator pattern is clever and the documentation is exemplary. The main action items are:

  1. Consider the pwsh vs powershell fallback for broader compatibility
  2. Add a test case for baseline binary artifact resolution
  3. Consider splitting unrelated E2E test changes to a separate PR

Great work on the research depth - the dual-interpretation of Bun issue #21869 shows careful analysis of the problem space.

@claude
Copy link
Copy Markdown

claude bot commented Mar 29, 2026

Additional PR Review

Verdict: Approve with minor suggestions

This is a well-thought-out solution to the Windows ARM64 support problem. The dual-binary approach with build-time discriminator is the right choice given the TinyCC/Prism constraints.

Key Strengths:

  • Excellent documentation with comprehensive research docs
  • Sound architecture using ATOMIC_BASELINE build-time flag
  • Good test coverage for baseline flag derivation, install.sh delegation, and download.ts
  • Defensive design with pwsh, semver validation, and informational messages

Minor Suggestions:

  1. Consider adding a comment in download.ts explaining the typeof guard for ATOMIC_BASELINE
  2. The E2E test act() wrapping is unrelated to ARM64 - could be a separate PR for cleaner git history

Security: No issues - checksum integrity preserved, input validation prevents injection.

Performance: Native x64 retains AVX, ARM64 gets AVX-free baseline. Minimal CI overhead.

Overall: High-quality PR with solid architecture and good test coverage.

Resolve modify/delete conflict for src/scripts/test-coverage.ts
by accepting main's deletion. Fix type errors from merge:
- screenMode → useAlternateScreen (opentui API change)
- Remove session_state_changed case (not in SDK type union)
macOS resolves temp directories to /private/var/folders/…, which
bypasses the existing **/tmp/** pattern. Add an explicit ignore
for **/var/folders/** to prevent temp files from inflating coverage.

Assistant-model: Claude Code
@claude
Copy link
Copy Markdown

claude bot commented Mar 31, 2026

PR Review: feat(windows) add ARM64 support via x64 emulation

Overall: Approve with minor suggestions

HIGHLIGHTS:

  • Excellent research documentation in research/docs/ files
  • Clever build-time discriminator pattern using ATOMIC_BASELINE
  • Dual-binary approach preserves AVX performance for native x64 users
  • CI pipeline corrections restore main branch two-job pattern
  • Good test coverage for new baseline detection and self-update logic

MINOR ISSUES:

  1. message-processor.ts:279 - Removal of session_state_changed appears unrelated to Windows ARM64. Consider separate PR.
  2. publish.yml:158 - Extra blank line (minor formatting)
  3. bunfig.toml coverage ignores - Ensure they do not mask genuine coverage gaps

CODE QUALITY:

  • download.ts: declare const ATOMIC_BASELINE placement is correct
  • build-binary.ts: Clean isBaseline derivation from --target flag
  • install.ps1: User-friendly ARM64 detection message
  • E2E tests: Proper act() wrapping fixes React testing best practices

SECURITY: No concerns. Changes focus on build/install infrastructure.

Well-engineered PR with thorough documentation. Minor issues are non-blocking.

@claude claude bot changed the title feat(windows): add ARM64 support via x64 emulation feat(windows)!: add ARM64 support via x64 emulation with dual-binary distribution Mar 31, 2026
Reverts the act() wrapping of render/destroy calls added in 5e6730b.
The underlying Bun coverage crash was resolved separately on main,
making these workarounds unnecessary. Aligns E2E tests with main.
@claude
Copy link
Copy Markdown

claude bot commented Mar 31, 2026

PR Review: Windows ARM64 Support via x64 Emulation

This is a well-researched and thoroughly documented PR that adds Windows ARM64 support via a dual-binary distribution strategy. The approach is sound - shipping both a standard x64 binary (with AVX optimizations) and an x64-baseline binary (AVX-free for ARM64 Prism emulation).

Summary of Changes

File Change
publish.yml Builds two Windows binaries, downloads both artifact sets in release job
build-binary.ts Auto-derives __ATOMIC_BASELINE__ flag from --target string
download.ts Self-update respects baseline flag to download correct binary
install.ps1 ARM64 maps to windows-x64-baseline.exe
install.sh Fixed Windows delegation to pass version/prerelease args
Tests Comprehensive coverage for new functionality

✅ Strengths

  1. Well-researched approach - The research docs thoroughly document the Bun FFI/TinyCC limitation and the Prism AVX constraints. Good due diligence.

  2. Build-time discriminator pattern - Using __ATOMIC_BASELINE__ as a compile-time flag to control self-update behavior is elegant. The baseline binary will correctly self-update to another baseline binary.

  3. Security considerations - The semver validation in install.sh protects against command injection in the PowerShell delegation.

  4. Test coverage - Good unit tests for:

    • Baseline flag derivation logic (build-binary-baseline.test.ts)
    • Download filename generation (download.test.ts)
    • Windows delegation argument building (install-sh-windows-delegation.test.ts)
  5. Backward compatibility - Native x64 users still get AVX-optimized builds. No performance regression for the majority.


⚠️ Suggestions & Minor Issues

1. Extra blank line in publish.yml

  release:
    name: Create Release
    runs-on: ubuntu-latest
    needs: [build, build-windows]


    steps:  # <-- extra blank line above

Minor style issue - consider removing the extra blank line at line 157.

2. Coverage exclusion for download.ts

The bunfig.toml change adds download.ts to coverage ignore list. While I/O-heavy code is hard to test, getBinaryFilename() contains critical logic for self-update correctness. Consider:

  • Keeping the file in coverage
  • Extracting getBinaryFilename() to a separate pure-logic module that can be fully tested

3. Test limitation for baseline behavior

The download.test.ts test for __ATOMIC_BASELINE__ only verifies the negative case:

test("should not include -baseline suffix in standard builds", () => {
  const filename = getBinaryFilename();
  expect(filename).not.toContain("-baseline");
});

A positive case test would require building with the baseline flag, which is reasonable to skip, but worth noting in a comment.

4. Unrelated change

The import removal in message-processor.ts (line 1 deletion) appears unrelated to the ARM64 feature. Consider splitting into a separate commit or PR for cleaner history.


🔒 Security Review

  • Version string validation: Both installers validate semver format before use ✅
  • PowerShell argument construction: Single-quoted version strings prevent injection ✅
  • Checksum verification: Both installers verify SHA256 checksums ✅

📝 Documentation

The research documents are comprehensive and well-structured:

  • research/docs/2026-03-20-388-389-windows-arm64-support.md - Root cause analysis
  • research/docs/2026-03-23-dual-binary-windows-approach.md - Strategy pattern design
  • research/docs/2026-03-29-windows-arm64-bun-ci-research.md - CI pipeline details
  • specs/windows-arm64-support.md - Full technical specification

Verdict

Approve with minor suggestions. This is a solid implementation of a well-researched solution. The dual-binary approach correctly handles the edge cases around self-update and platform detection. The test coverage is appropriate for the complexity of the changes.

The minor issues noted above are non-blocking style/documentation improvements.

Restore `screenMode: "alternate-screen"` in place of the removed
`useAlternateScreen` property on CliRendererConfig, and re-add the
`session_state_changed` case to the exhaustive system subtype switch
to fix typecheck failures.

Assistant-model: Claude Code
@claude
Copy link
Copy Markdown

claude bot commented Mar 31, 2026

PR Review: Windows ARM64 Support via x64 Emulation

Summary

This PR adds Windows ARM64 support through a dual-binary distribution strategy. ARM64 users get an AVX-free x64-baseline binary that runs via Windows 11 Prism emulation. This is a well-designed solution that addresses the core issues (404 errors and runtime crashes) without sacrificing AVX optimizations for native x64 users.


✅ Code Quality & Best Practices

Build System (build-binary.ts)

  • Clean implementation of isBaseline detection from target name (line 79)
  • Good use of conditional spreading for the define block (line 92)
  • Proper type safety with as never cast for dynamic target (line 88)

Download Utility (download.ts)

  • Excellent use of typeof guard with declare const pattern (lines 296, 341-343) to safely handle the build-time constant without runtime errors in standard builds
  • Clear separation of concerns in getBinaryFilename()

Install Scripts

  • install.ps1: Good PowerShell 7+ version check with helpful error message and install link (lines 18-22)
  • install.sh: Proper argument parsing before Windows delegation (lines 357-362), ensuring version/prerelease flags are forwarded correctly
  • Both scripts have semver validation to prevent URL manipulation attacks

🔒 Security Analysis

Strong Points:

  1. Input validation: Both install scripts validate version format with strict semver regex before constructing download URLs (install.sh:415, install.ps1:306-309)
  2. Malicious input rejection: The test suite (install-sh-windows-delegation.test.ts:169-195) explicitly tests rejection of shell injection attempts like '; rm -rf /; echo ' and $(whoami)
  3. Safe PowerShell invocation: Using pwsh instead of powershell ensures PowerShell 7+ security features are available

No security concerns identified.


🧪 Test Coverage

Excellent coverage for new functionality:

Test File Coverage Area Tests
build-binary-baseline.test.ts Baseline flag derivation logic 8 tests
install-sh-windows-delegation.test.ts Windows delegation, arg construction, security 11 tests
download.test.ts Binary filename generation, checksums 12 tests

Highlights:

  • Tests verify malicious input rejection (command injection attempts)
  • Tests verify valid semver acceptance
  • Tests verify correct PS1 argument construction for version+prerelease combinations

⚡ Performance Considerations

  • No performance regression for native x64 users: Standard builds retain AVX/AVX2 optimizations
  • Acceptable tradeoff for ARM64: Baseline builds trade AVX for broad compatibility via Prism emulation
  • Build time impact: Minimal - adds one additional bun build invocation in CI

🔧 CI/CD Changes

publish.yml changes look correct:

  • Windows job builds both x64 and x64-baseline binaries (lines 141-145)
  • Both artifacts are uploaded and included in release assets (line 221)
  • Tests and typecheck run before building on Windows runner (lines 131-135)

📝 Minor Suggestions (Non-blocking)

  1. Cosmetic: Extra blank line at publish.yml:157-158 (between needs: and steps:)

  2. Documentation placement: The research docs (research/docs/) are comprehensive. Consider whether specs should live in docs/specs/ for discoverability, or if the current location aligns with project convention.

  3. Coverage exclusion: download.ts was added to coverage ignore patterns. While understandable for I/O-heavy code, the pure functions (parseChecksums, getDownloadUrl, etc.) are already tested in download.test.ts, which is good.


✅ Verdict

Approve - This is a well-implemented feature with:

  • Clean code following project conventions
  • Strong security practices (input validation, injection prevention)
  • Comprehensive test coverage for new functionality
  • Clear documentation of the approach and rationale

The dual-binary strategy is the right solution - it solves the ARM64 problem without compromising the native x64 experience. Good work! 🎉

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

Labels

None yet

Projects

None yet

2 participants