Skip to content

fix: install platform-correct native binaries for extensions (#102) - #106

Open
jackson-zhou wants to merge 1 commit into
Sidenai:mainfrom
jackson-zhou:fix/extension-platform-detection
Open

jackson-zhou wants to merge 1 commit into
Sidenai:mainfrom
jackson-zhou:fix/extension-platform-detection

Conversation

@jackson-zhou

Copy link
Copy Markdown

Summary

Fixes #102. Platform-specific extensions (e.g. Kilo Code, which bundles kilo/ffmpeg/bwrap native binaries) installed the wrong architecture on macOS - the downloaded bin/kilo was an ELF ... musl aarch64 (Alpine Linux) binary, causing ENOEXEC.

Root cause

The SideX marketplace proxy's search returns a single "latest" version whose targetPlatform field is omitted but whose VSIX asset URI (base64-encoded in the path) points at alpine-arm64. The proxy serves whatever platform is baked into that base64 and ignores the targetPlatform query parameter, so every OS downloaded the alpine-arm64 build.

Changes (6 files)

  • marketplace.rs / lib.rs: add current_target_platform() that maps the current build target (Rust cfg!, always correct for the host) to Open VSX's targetPlatform format (e.g. darwin-arm64, linux-x64).
  • extensions.rs: rewrite_proxy_vsix_platform decodes the proxy's base64 VSIX URL, swaps the embedded platform to current_target_platform(), and re-encodes. This is the authoritative correction point - the proxy can't be fixed without deploy access, so the backend rewrites the URL before downloading. ensure_target_platform also appends the param for non-proxy URLs. Includes unit tests.
  • extensionResourceLoader.ts: use the query-param form (version?targetPlatform=) for Open VSX manifest URLs in Tauri. The version+platform path segment that the Microsoft Marketplace uses 404s on Open VSX, aborting installation before the backend download runs.
  • host.cjs: stub vscode.window notebook/editor APIs (visibleNotebookEditors, activeNotebookEditor) in the SideX Node extension host.
  • extHost.api.impl.ts: same notebook API stubs on the webview-side extension host, where kilo-code actually activates.

Why notebook API stubs are required for #102

The host.cjs / extHost.api.impl.ts changes are not a separate improvement - they are required for #102 to be verifiably fixed:

  1. Extension installation lacks platform detection — native binaries (e.g. Kilo Code) download wrong architecture on macOS #102's core fix (platform detection + URL rewrite) makes SideX download the correct platform-specific VSIX (e.g. darwin-arm64 instead of alpine-arm64).
  2. But after installing the correct VSIX, extensions with native binaries (the exact extensions Extension installation lacks platform detection — native binaries (e.g. Kilo Code) download wrong architecture on macOS #102 is about) call vscode.window.visibleNotebookEditors.map(...) during activate().
  3. SideX's extension host hasn't implemented these notebook window APIs, so visibleNotebookEditors is undefined, and .map() throws "Cannot read properties of undefined" - the extension fails to activate, registers no commands, and the sidebar won't load.
  4. Without the stubs, Extension installation lacks platform detection — native binaries (e.g. Kilo Code) download wrong architecture on macOS #102 is unfixable in practice: the correct binary downloads but the extension still can't run. The bug report ("can't install/use Kilo Code") remains unresolved.

The stubs are minimal (return empty array / undefined, matching VS Code's contract when no notebook editors are open) and only prevent the crash - they don't implement notebook functionality.

Verification (macOS arm64, dev mode)

  • bin/kilo is Mach-O 64-bit executable arm64 (was ELF ... musl)
  • Kilo Code sidebar loads, commands register, prompts send without ENOEXEC or "Cannot read properties of undefined"
  • cargo check / eslint / prettier / cargo test (4 unit tests) all pass

Fixes #102

…#102)

Platform-specific extensions (e.g. Kilo Code, which bundles `kilo`,
`ffmpeg`, `bwrap`) installed the wrong architecture on macOS - the
downloaded `bin/kilo` was an `ELF ... musl aarch64` (Alpine Linux)
binary, causing `ENOEXEC`.

## Root cause

The SideX marketplace proxy's search returns a single "latest" version
whose `targetPlatform` field is omitted but whose VSIX asset URI
(base64-encoded in the path) points at `alpine-arm64`. The proxy serves
whatever platform is baked into that base64 and ignores the
`targetPlatform` query parameter, so every OS downloaded the alpine-arm64
build.

## Changes (6 files)

- `marketplace.rs` / `lib.rs`: add `current_target_platform()` that maps
  the current build target (Rust `cfg!`, always correct for the host) to
  Open VSX's `targetPlatform` format (e.g. `darwin-arm64`, `linux-x64`).
- `extensions.rs`: `rewrite_proxy_vsix_platform` decodes the proxy's
  base64 VSIX URL, swaps the embedded platform to `current_target_platform()`,
  and re-encodes. This is the authoritative correction point - the proxy
  can't be fixed without deploy access, so the backend rewrites the URL
  before downloading. `ensure_target_platform` also appends the param for
  non-proxy URLs. Includes unit tests.
- `extensionResourceLoader.ts`: use the query-param form
  (`version?targetPlatform=`) for Open VSX manifest URLs in Tauri. The
  `version+platform` path segment that the Microsoft Marketplace uses 404s
  on Open VSX, aborting installation before the backend download runs.
- `host.cjs`: stub `vscode.window` notebook/editor APIs
  (`visibleNotebookEditors`, `activeNotebookEditor`) in the SideX Node
  extension host. Extensions calling `.map()` on them (e.g. kilo-code's
  `gatherEditorContext`) crash with "Cannot read properties of undefined"
  because these APIs aren't implemented yet.
- `extHost.api.impl.ts`: same notebook API stubs on the webview-side
  extension host, where kilo-code actually activates.

## Verification (macOS arm64, dev mode)

- `bin/kilo` is `Mach-O 64-bit executable arm64` (was `ELF ... musl`)
- Kilo Code sidebar loads, commands register, prompts send without
  `ENOEXEC` or "Cannot read properties of undefined".

Fixes Sidenai#102
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.

Extension installation lacks platform detection — native binaries (e.g. Kilo Code) download wrong architecture on macOS

1 participant