Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(ibm): make the command palette and the mobile stylesheet survive the partner's origin

nirholasf49cd1a048c2
diff --git a/docs/ops/ibm-hosted-page-audit.md b/docs/ops/ibm-hosted-page-audit.md
index a9073888b..21aab3cb0 100644
--- a/docs/ops/ibm-hosted-page-audit.md
+++ b/docs/ops/ibm-hosted-page-audit.md
@@ -45,6 +45,34 @@ Runtime `i18n.js` had the same shape: it fetched `/locales/<code>.json` and
catalogs travel with the code. On three.ws itself that resolves to `''` and the
URLs are byte-identical to what they always were.
+`public/atlas.js` had it too, and it was found the same way on 2026-09-09: the
+command palette fetched `/atlas-index.json` root-relative, so on the hosted copy
+it asked IBM's server for the site index and logged a 404 on every load. It now
+derives its origin from `import.meta.url` exactly as `i18n.js` does, and
+`/atlas-index.json` carries the same CORS grant as `/locales/*.json`.
+
+**3. A CORS grant on an entry module but not on what it imports.**
+Also 2026-09-09. `/atlas.js` had the grant; `./atlas/score.js`, the one module it
+imports, did not. A module script's dependencies are fetched under CORS too, so a
+blocked import fails the whole graph and the grant on the entry point buys
+nothing: the palette never mounted on the hosted copy even though `atlas.js`
+itself answered with `access-control-allow-origin: *`. When you grant CORS to a
+module, walk its import graph and grant every file in it.
+
+**4. A post-build sweep rewriting a file that ships verbatim.**
+`pages/ibm/` is copied to `dist/ibm/` byte-for-byte on purpose: these are
+publish-once artifacts under a strict `script-src 'self' three.ws` CSP, and the
+copy plugin skips Rollup and the whole `transformIndexHtml` chain to keep them
+that way. The `mobile-ergonomics` plugin's `closeBundle` pass walks every HTML
+file in `dist/` rather than only Vite's inputs, so it reached all three IBM
+artifacts *after* `build-ibm-shell.mjs`'s root-relative guard had already passed
+them, and injected `<link rel="stylesheet" href="/mobile.css">` into each. On
+three.ws that is correct and invisible; on IBM's domain it is a 404 for a
+stylesheet only we have. `VERBATIM_DIST_DIRS` in `vite.config.js` now keeps that
+sweep out of `dist/ibm/`. Any future post-build pass over `dist/` owes these
+files the same exemption, and the guard in the builder cannot catch it, because
+by then the builder has already run.
+
## Running it
```bash
diff --git a/public/atlas.js b/public/atlas.js
index e47f4955e..019376d76 100644
--- a/public/atlas.js
+++ b/public/atlas.js
@@ -45,7 +45,23 @@ import { rankPages, rankIntents, highlight } from './atlas/score.js';
if (document.documentElement.hasAttribute('data-no-atlas')) return;
if (document.querySelector('meta[name="atlas"][content="off"]')) return;
- var INDEX_URL = '/atlas-index.json';
+ // The page index travels with the code, not with the page. atlas.js is served
+ // cross-origin onto pages we do not host (the publish-once partnership page
+ // IBM hosts on its own domain reads it from three.ws), and a root-relative
+ // '/atlas-index.json' there asks the PUBLISHER'S server for a file only
+ // three.ws has, so the palette opened empty and logged a 404 on every load.
+ // Deriving the base from import.meta.url keeps the two together. On three.ws
+ // itself the origin matches and the URL is byte-identical to what it always
+ // was. src/i18n.js resolves its catalogs the same way, for the same reason.
+ var ASSET_ORIGIN = (function () {
+ try {
+ var origin = new URL(import.meta.url).origin;
+ return origin !== location.origin ? origin : '';
+ } catch (_) {
+ return '';
+ }
+ })();
+ var INDEX_URL = ASSET_ORIGIN + '/atlas-index.json';
var RECENT_KEY = 'tws:atlas:recent';
var HINT_KEY = 'tws:atlas:hinted';
var RECENT_MAX = 6;
diff --git a/vercel.json b/vercel.json
index 8f0c7de6c..ee28f21b1 100644
--- a/vercel.json
+++ b/vercel.json
@@ -247,6 +247,22 @@
},
"continue": true
},
+ {
+ "src": "/atlas-index\\.json",
+ "headers": {
+ "access-control-allow-origin": "*",
+ "cross-origin-resource-policy": "cross-origin"
+ },
+ "continue": true
+ },
+ {
+ "src": "/atlas/(.+)\\.js",
+ "headers": {
+ "access-control-allow-origin": "*",
+ "cross-origin-resource-policy": "cross-origin"
+ },
+ "continue": true
+ },
{
"src": "/ios-bridge\\.[0-9a-f]+\\.js",
"headers": {
diff --git a/vite.config.js b/vite.config.js
index a6e395ae6..c8ea0e94a 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -85,6 +85,19 @@ const MOBILE_ERGONOMICS_EXCLUDED = new Set([
'footer.html',
]);
+// Directories under dist/ that are copied VERBATIM from pages/ and must not be
+// rewritten by the post-build sweep below. dist/ibm/ holds the publish-once
+// partner artifacts: they are uploaded to a host we do not control, so a
+// root-relative URL in them resolves against the PUBLISHER'S domain, not ours.
+// build-ibm-shell.mjs refuses to bake one for exactly that reason, and the
+// sweep ran after that guard and injected `<link href="/mobile.css">` into all
+// three anyway, so the hosted copy 404ed on a stylesheet only three.ws has
+// (measured by `npm run audit:ibm-hosted` on 2026-09-09). Their CSP is also
+// `script-src 'self' three.ws`, and their whole contract is to stay
+// byte-for-byte identical wherever they are served, which is why the copy
+// plugin skips Rollup and the transformIndexHtml chain to begin with.
+const VERBATIM_DIST_DIRS = new Set(['ibm']);
+
// Without viewport-fit=cover every env(safe-area-inset-*) resolves to 0, so
// the safe-area padding in mobile.css is dead code on an iPhone.
function withViewportFitCover(html) {
@@ -2832,6 +2845,7 @@ const appConfig = {
continue;
}
if (stat.isDirectory()) {
+ if (VERBATIM_DIST_DIRS.has(entry) && dir === distDir) continue;
walk(full);
continue;
}