fix: load models on GitHub Pages sub-path deployments (issue #13)#14
Conversation
Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: #13
⏳ Usage Limit ReachedThe automated solution draft was interrupted because the Anthropic Claude Code usage limit was reached. 📊 Limit Information
🔄 How to ContinueAuto-resume is enabled. The session will automatically resume (with context preserved) when the limit resets. 🤖 Models used:
📎 Execution log uploaded as Gist (3462KB)This session was interrupted due to usage limits. The session will automatically resume when the limit resets. |
|
⏰ Auto Resume (on limit reset) Auto-resuming automated work session at 2026-06-10T17:01:03.574Z This session automatically resumed after the usage limit reset, continuing with the previous context preserved. The PR has been converted to draft mode while work is in progress. This is an auto-resumed session. Please wait for the session to finish, and provide your feedback. |
- Add browser-commander e2e (web/e2e/browser-commander/subpath-load.mjs, npm run test:e2e:bc) loading SmolLM2 135M Instruct under the /<repo>/ sub-path, asserting the ORT glue is served from the sub-path and no 'no available backend found' error appears (R1). - Add the Playwright chromium-subpath project + spec and the sub-path static server that reproduce the GitHub Pages project-site layout. - Add docs/case-studies/issue-13: timeline, requirements (R1-R7), root-cause analysis, the fix, codebase-wide audit, online research with citations, and before/after screenshots (R3). - Add changelog fragment for the sub-path ORT backend fix. - Relocate stray repro screenshots into the case-study folder.
Wires the issue-#13 browser-commander e2e (npm run test:e2e:bc) into the E2E workflow so the sub-path model-load regression is verified continuously, not only manually.
Working session summaryAll requirements are addressed and PR #14 is finalized. Summary of what was completed: Issue #13 — "It does not work" — ResolvedRoot cause: On the GitHub Pages project-site deployment ( The fix: Resolve the ORT base from the deployment base in both threads — Requirements delivered:
Verification: All three CI workflows pass (CI/CD Pipeline, Build and Deploy, E2E Tests including the new browser-commander step). Working tree clean, PR marked ready, changelog fragment added. PR: #14 This summary was automatically extracted from the AI working session output. |
🔄 Solution Draft Log (auto resume on limit reset)This log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
📊 Context and tokens usage:Claude Opus 4.8: (3 sub-sessions)
Total: (25.0K new + 488.7K cache writes + 9.9M cache reads) input tokens, 76.7K output tokens, $10.060093 cost Claude Haiku 4.5:
Total: 15.4K input tokens, 518 output tokens, $0.028029 cost 🤖 Models used:
Note: This session was automatically resumed after a usage limit reset, with the previous context preserved. 📎 Log file uploaded as Gist (1623KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
This reverts commit a28927f.
Fix sub-path (GitHub Pages project-site) model loading — issue #13
Fixes #13.
The bug
On the deployed site
https://link-assistant.github.io/model-in-browser/(aGitHub Pages project site, served under the
/model-in-browser/sub-path)the app failed with:
No model ever loaded; Retry Load reproduced the failure every time.
Root cause
The inference worker derived ONNX Runtime Web's WASM
wasmPathsfromself.location.origin, which is scheme + host + port only — it drops the/model-in-browser/sub-path. ORT then tried toimport()its glue moduleort-wasm-simd-threaded.jsep.mjsfromhttps://host/ort/…instead ofhttps://host/model-in-browser/ort/…, which 404s. The failed dynamic importsurfaces inside ORT as the generic "no available backend found" message.
It shipped unnoticed because the e2e suite ran against
vite preview, whichserves at the origin root — where origin-based resolution is accidentally
correct, so the sub-path layout that triggers the bug was never exercised.
The fix
Resolve the ORT base from the deployment base, not the origin, in both
threads (defence in depth):
App.tsxusesimport.meta.env.BASE_URL(Vite's configured base, sub-path-aware)and posts it to the worker.
worker.tsprefers that value; its fallback resolves../ort/relative tothe worker's own location (
<base>assets/…→<base>ort/), so it is correctunder any sub-path with no
origininvolved.Codebase-wide audit (R6)
The ORT
wasmPathsderivation was the only origin-rooted asset path. TheCandle WASM engine, app JS/CSS bundles, and model weights are all resolved
relatively (Vite,
base: './') or fetched from absolute remote URLs, so they arealready sub-path-safe. Full audit table in the case study.
Debug / verbose mode (R4)
Added
?debug=1(orlocalStorage.mib_debug = '1'): the app and worker now logthe resolved ORT base path, so any future asset-path problem is self-diagnosing.
Tests (R1, R2)
web/e2e/browser-commander/subpath-load.mjs(
npm run test:e2e:bc): boots a sub-path server, drives Chromium viabrowser-commander,
loads SmolLM2 135M Instruct (q8), and asserts the ORT glue is served from
the sub-path with no backend error. Passing.
web/e2e/subpath.spec.tsrun by a newchromium-subpathproject againstweb/e2e/subpath-server.mjs(reproduces theGitHub Pages project-site layout with production COOP/COEP headers). Fails on
the pre-fix code, passes on the fix. Passing (9.9s).
the sub-path.
Case study (R3)
docs/case-studies/issue-13/README.md— timeline, full requirements table(R1–R7), root-cause analysis, the fix, codebase-wide audit, the
report-upstream decision (R5: N/A, bug is in this repo), online research with
citations, and before/after screenshots.
Upstream report (R5)
Not applicable — the root cause is in this repository's code. ORT/transformers.js
behaved correctly (they requested the configured URL); the supported
env.backends.onnx.wasm.wasmPathsoverride is exactly what the fix uses.Screenshots
Release
Adds a
patchchangelog fragment (changelog.d/20260610_150000_fix_subpath_ort_backend.md).