Skip to content

fix(packaging): prune non-target native binaries - #12174

Merged
Jinwoo-H merged 1 commit into
mainfrom
intel-mac-deprecate
Aug 3, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
intel-mac-deprecate

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • prune node-pty prebuild and ABI-tagged output directories by the electron-builder target architecture
  • keep only the matching @parcel/watcher native package, including same-architecture Linux libc variants
  • reject missing, unsupported, and universal architecture values instead of falling back to the build host

Problem

The Apple-silicon app bundled unused x86_64-only node-pty and Parcel watcher files. macOS detected those Intel components and displayed a Rosetta deprecation warning even though Orca and the native modules it actually loaded were arm64.

Validation

  • focused electron-builder config tests: 35 passed
  • full typecheck, lint, reliability gates, and test suite passed
  • built x64 followed by arm64 to reproduce production cross-architecture accumulation
  • audited all 36 Mach-O files in each app: every arm64 bundle file contains arm64 and every x64 bundle file contains x86_64
  • verified exact node-pty prebuild/bin and Parcel watcher inventories in both bundles
  • spawned a real PTY and received a real filesystem-watch event under both packaged runtimes; x64 passed through Rosetta on an arm64 Mac
  • packaged CLI smoke checks and ad-hoc deep code-sign verification passed for both apps

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3c92fdc9-c140-4301-a904-8694689abd14

📥 Commits

Reviewing files that changed from the base of the PR and between a20165a and c2e61d3.

📒 Files selected for processing (2)
  • config/packaged-runtime-node-modules.cjs
  • config/scripts/electron-builder-config.test.mjs

📝 Walkthrough

Walkthrough

The packaging runtime now normalizes Electron architecture values, including numeric enums and armv7l, and validates supported architectures. Node-pty pruning filters both prebuilds and bin directories by target platform and architecture. Parcel watcher pruning keeps only the selected platform and architecture variants. Tests cover architecture-specific retention, removal of unrelated artifacts, unsupported architectures, and updated afterPack configuration.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and validation, but it omits the required Screenshots, Testing, AI Review Report, Security Audit, and Notes sections. Add all required template sections, including explicit visual-change status, test checklist results, AI review scope, security audit findings, and platform-specific notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: pruning non-target native binaries during packaging.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds architecture-aware pruning of native binaries during Electron packaging to fix a Rosetta deprecation warning on Apple Silicon. Previously, the pruner kept all same-platform prebuilds (e.g., both darwin-arm64 and darwin-x64), so Intel components ended up in arm64 bundles.

  • Introduces normalizeElectronArchitecture to canonicalize both numeric Arch enum values and string names (including armv7l→arm), and throws for universal and unknown values instead of falling back to the build host's arch.
  • Refactors prunePackagedNodePty to use a new pruneNodePtyNativeDirectories helper that prunes both prebuilds/ (exact architecture match) and bin/ (ABI-tagged suffix match), removing cross-architecture outputs accumulated from sequential builds.
  • Extends prunePackagedParcelWatcher to filter by architecture as well as platform, correctly preserving Linux libc variant suffixes (e.g., -glibc) while dropping non-target arch packages.

Confidence Score: 5/5

Safe to merge. The pruning functions are additive restrictions on what survives packaging; at worst a misconfiguration would prune too aggressively, causing a startup crash caught at packaging time, rather than shipping wrong binaries silently.

The two changed files contain tightly scoped build-time pruning logic with no runtime surface. The new normalizeElectronArchitecture helper handles all enum and string variants correctly. Both prebuilds/ and bin/ pruning use exact-prefix matching with clearly tested edge cases. The Linux libc suffix logic correctly preserves glibc/musl variants while dropping wrong-arch packages.

Files Needing Attention: No files require special attention. Both files are well-tested and the changes are isolated to build-time packaging helpers.

Important Files Changed

Filename Overview
config/packaged-runtime-node-modules.cjs Core pruning logic: adds architecture-aware filtering for node-pty prebuilds/bin and @parcel/watcher subpackages. Logic is correct, including Linux libc suffix handling and validation that rejects universal and unknown architectures.
config/scripts/electron-builder-config.test.mjs Test coverage updated to pass numeric Arch enum values, verify bin/ directory pruning, assert universal arch rejection, and add arch: 1 to the afterPack fixture (required since prunePackagedRuntimeNodeModules now validates the arch before reading the filesystem).

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[afterPack context.arch] --> B[prunePackagedRuntimeNodeModules]
    B --> C[normalizeElectronArchitecture]
    C -- number enum --> D{ELECTRON_ARCHITECTURE_BY_ENUM lookup}
    C -- armv7l string --> E[map to 'arm']
    C -- other string --> F[pass through]
    D --> G{in PACKAGED_NATIVE_ARCHITECTURES?}
    E --> G
    F --> G
    G -- no: universal/unknown --> H[throw Unsupported packaged runtime architecture]
    G -- yes: ia32/x64/arm/arm64 --> I[normalized architecture string]
    I --> J[prunePackagedNodePty]
    I --> K[prunePackagedParcelWatcher]
    J --> L[pruneNodePtyNativeDirectories prebuilds/ exact match]
    J --> M[pruneNodePtyNativeDirectories bin/ suffix match]
    J --> N{win32?}
    N -- yes --> O[ensurePackagedNodePtyConptyRuntime]
    N -- no --> P[rmSync third_party/conpty + deps/winpty]
    K --> Q[targetPrefix = keepPrefix + arch]
    Q --> R{matches targetPrefix or targetPrefix- suffix?}
    R -- no --> S[rmSync non-matching watcher- subpackage]
    R -- yes --> T[keep]
Loading

Reviews (1): Last reviewed commit: "fix(packaging): prune non-target native ..." | Re-trigger Greptile

@Jinwoo-H
Jinwoo-H merged commit 128e3e3 into main Aug 3, 2026
44 checks passed
@Jinwoo-H
Jinwoo-H deleted the intel-mac-deprecate branch August 3, 2026 17:54
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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