Skip to content

fix(desktop): bundle arm64 binaries for windows arm - #54689

Merged
Hona merged 3 commits into
anomalyco:devfrom
mweinbach:windows-arm-bundle
Oct 12, 2026
Merged

Hona merged 3 commits into
anomalyco:devfrom
mweinbach:windows-arm-bundle

Conversation

@mweinbach

@mweinbach mweinbach commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #45875

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Fixes two places where the Windows ARM64 desktop build bundled x64 native binaries:

  1. In CI, the aarch64-pc-windows-msvc Electron job runs on an x64 windows-2025 host without bun_install_flags: --cpu=*, and electron.vite.config.ts resolved @lydell/node-pty using process.platform/process.arch instead of OPENCODE_CLI_TARGET. As a result, opencode-desktop-win-arm64.exe packaged @lydell/node-pty-win32-x64. This resolves the node-pty package from OPENCODE_CLI_TARGET, installs --cpu=* for the Windows ARM64 CI build, excludes non-target @lydell/node-pty-* packages from electron-builder, and verifies the target conpty.node prebuild in afterPack.
  2. packages/core pinned bun-pty to 0.4.9, which only shipped an x64 rust_pty.dll and embedded it into cli-windows-arm64/bin/opencode.exe (failing dlopen with Windows error 193 on ARM64). Bumping bun-pty to 0.4.11 embeds rust_pty_arm64.dll when compiling for win32-arm64.
  3. Evaluates the electron-vite and electron-builder configs directly in their unit tests instead of spawning esbuild via loadConfigFromFile on every call, cutting those two test files from ~7.6s to ~1.7s.

How did you verify your code works?

  • Ran bun test ./electron.vite.config.test.ts ./electron-builder.config.test.ts in packages/desktop (verifying cross-architecture OPENCODE_CLI_TARGET resolution and FileMatcher filtering across all targets).
  • Ran bun typecheck in packages/core and bun run lint:changed.
  • Verified rust_pty_arm64.dll in bun-pty@0.4.11 has PE machine type 0xaa64 (ARM64).

Screenshots / recordings

N/A (build and packaging fix)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #44664

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Oct 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Oct 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@opencode-agent opencode-agent Bot left a comment

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.

The change looks correct. I couldn't verify it end to end, because that needs a Windows ARM64 CI build and machine.

On Linux I loaded both configs through the loaders the build tools actually use: electron-vite's loadConfigFromFile, and jiti for electron-builder.

  • With OPENCODE_CLI_TARGET=aarch64-pc-windows-msvc, the main build externalizes @lydell/node-pty-win32-arm64, and electron-builder excludes the other five node-pty packages. Without a target, both still fall back to the host.
  • The afterPack path matches the published @lydell/node-pty-win32-arm64@1.2.0-beta.12 layout (prebuilds/win32-arm64/conpty.node).
  • bun-pty 0.4.11 ships rust_pty_arm64.dll and selects it on win32/arm64.
  • The desktop config tests pass (9/9), and tsgo -b is clean.

Public API: unchanged. OPENCODE_CLI_TARGET was already read by the desktop scripts; it now also drives the vite and electron-builder configs, with the same host fallback, and is set in the publish workflow's packaging steps.

No blocking concerns.

Related: #44664

@Hona
Hona merged commit 854b3bb into anomalyco:dev Oct 12, 2026
9 of 10 checks passed
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.

Windows ARM64 native builds fail: bun:ffi unavailable in stable Bun, bun-pty ships x64-only DLL

2 participants