From 79826b9a4d9b9cd749f33f7a77939faf0969e510 Mon Sep 17 00:00:00 2001 From: ruv Date: Sun, 26 Apr 2026 20:15:48 -0400 Subject: [PATCH] fix(dashboard): pass Vite BASE_URL to worker for GH-Pages base resolution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Worker was resolving /nvsim-pkg/ against self.location.origin, which under GitHub Pages stripped the /RuView/nvsim/ prefix and 404'd on the WASM module. Main thread now reads import.meta.env.BASE_URL and forwards it in the boot RPC; worker resolves against that. Verified live at https://ruvnet.github.io/RuView/nvsim/ — boot succeeds, witness verified, determinism gate ✓. Co-Authored-By: claude-flow --- dashboard/src/transport/WasmClient.ts | 6 +++++- dashboard/src/transport/worker.ts | 12 ++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dashboard/src/transport/WasmClient.ts b/dashboard/src/transport/WasmClient.ts index b3e63a28..8dbb2313 100644 --- a/dashboard/src/transport/WasmClient.ts +++ b/dashboard/src/transport/WasmClient.ts @@ -91,8 +91,12 @@ export class WasmClient implements NvsimClient { async boot(): Promise { if (this.bootInfo) return this.bootInfo; + // Pass Vite's resolved BASE_URL so the worker can locate /nvsim-pkg/ + // under the same prefix the dashboard is served from (e.g. /RuView/nvsim/ + // on GitHub Pages, "/" in dev). + const base = import.meta.env.BASE_URL ?? '/'; const r = await this.rpc<{ buildVersion: string; frameMagic: number; frameBytes: number; expectedWitnessHex: string }>( - { type: 'boot' }, + { type: 'boot', base }, ); this.bootInfo = { buildVersion: r.buildVersion, diff --git a/dashboard/src/transport/worker.ts b/dashboard/src/transport/worker.ts index c169bbf2..8227a618 100644 --- a/dashboard/src/transport/worker.ts +++ b/dashboard/src/transport/worker.ts @@ -38,9 +38,12 @@ let expectedReferenceWitnessHex!: () => string; let hexWitness!: (b: Uint8Array) => string; let referenceWitness!: () => Uint8Array; -async function loadPkg(): Promise { - const baseHref = `${ws.location.origin}/`; - const pkgUrl = new URL('nvsim-pkg/nvsim.js', baseHref).href; +async function loadPkg(base: string): Promise { + // `base` is the dashboard's BASE_URL injected by Vite, prefixed with the + // origin so we get an absolute URL the dynamic import can resolve. In dev + // this is "/", in prod under GitHub Pages it's "/RuView/nvsim/". + const absoluteBase = new URL(base, ws.location.origin).href; + const pkgUrl = new URL('nvsim-pkg/nvsim.js', absoluteBase).href; const pkg = (await import(/* @vite-ignore */ pkgUrl)) as NvsimPkg; await pkg.default(); _WasmPipeline = pkg.WasmPipeline; @@ -119,7 +122,8 @@ ws.addEventListener('message', async (ev: MessageEvent): Promise => { try { switch (m.type) { case 'boot': { - await loadPkg(); + const base = (m.base as string | undefined) ?? '/'; + await loadPkg(base); ensureRebuild(); post({ type: 'booted',