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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
test(home-e2e): mint CSRF like the client and stop peer saves reloading a run
nirholasa634b206e14a
diff --git a/tests/e2e/home-a11y.spec.js b/tests/e2e/home-a11y.spec.jsindex 197a6eeca..6e8b4e176 100644--- a/tests/e2e/home-a11y.spec.js+++ b/tests/e2e/home-a11y.spec.js@@ -47,12 +47,20 @@ async function openView(page, id, view) {* ink composited into the background, and axe scores that blend rather than the* resting colour a reader actually sees: the same reason the site-wide gate* does this.+ *+ * The wait afterwards is on a condition, not a duration: the injected rule+ * collapses every animation and transition to 1ms, so the resting colour is on+ * screen once the browser has painted two frames past the injection. A fixed+ * sleep would be both slower than that and, on a loaded machine, still too+ * short, which is the shape every flaky contrast assertion has.*/async function settle(page) {await page.addStyleTag({content: '*, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0s !important; transition-duration: 1ms !important; transition-delay: 0s !important; }',});- await page.waitForTimeout(120);+ await page.evaluate(+ () => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve(true)))),+ );}async function axeOn(page, label) {@@ -370,6 +378,116 @@ test("a user's own device names are never translated", async ({ page }) => {expect(seen[0]).toBe(light.name);});+test('prefers-reduced-motion turns the scene\'s motion off, in 3D and in the flat house', async ({ page }) => {+ await signIn(page, 'owner');++ // The default first, so the assertion below is a difference and not a+ // constant. A house that never damps anything would pass a one-sided check.+ await openView(page, homeId, '3d');+ const moving = await page.evaluate(() => window.__homeScene?.stats());+ expect(moving.reduceMotion, 'motion is on by default').toBe(false);+ expect(moving.damping, 'the camera coasts by default').toBe(true);++ // Now ask for less motion the way a person does: an OS setting, which the+ // browser reports as a media query. Not a class, not a test hook.+ await page.emulateMedia({ reducedMotion: 'reduce' });+ await openView(page, homeId, '3d');+ const still = await page.evaluate(() => window.__homeScene?.stats());+ expect(still.reduceMotion, 'the renderer reads the setting').toBe(true);+ expect(still.damping, 'the camera must not coast after a drag').toBe(false);+ // Reduced motion is not a frozen house: the scene still draws, the values+ // just arrive instead of travelling.+ expect(still.drawCalls).toBeGreaterThan(0);++ // The whole lane, not just the canvas: nothing anywhere on the page may+ // carry a real transition or animation once the setting is on.+ await openView(page, homeId, '2d');+ const durations = await page.evaluate(() => {+ const out = [];+ for (const node of document.querySelectorAll('#hs-shell *')) {+ const style = getComputedStyle(node);+ const longest = (value) => Math.max(0, ...String(value).split(',').map((v) => parseFloat(v) || 0));+ const ms = Math.max(longest(style.transitionDuration), longest(style.animationDuration));+ if (ms > 0.05) out.push(`${node.className || node.tagName}: ${ms}s`);+ }+ return out;+ });+ expect(durations, 'no element may animate under prefers-reduced-motion').toEqual([]);++ await page.emulateMedia({ reducedMotion: null });+});++test('on a phone, the confirmation survives a stray tap and only a real answer clears it', async ({ page }) => {+ const instance = homeInstance();+ await signIn(page, 'owner');+ // A real phone viewport, because this is a phone-shaped failure: the card+ // covers most of a 375px screen, so the thumb that reaches for it lands+ // beside it as often as on it.+ await page.setViewportSize({ width: 375, height: 720 });+ await openView(page, homeId, '2d');++ const lock = await lockedDoor(instance);+ await page.locator(`[data-entity-id="${lock}"]`).getByRole('button', { name: /^Unlock\b/ }).first().click();+ const card = page.getByRole('alertdialog', { name: 'Confirm this action' });+ await expect(card).toBeVisible({ timeout: 60_000 });++ // Three ways a card gets dismissed by accident on a touch screen, all of+ // which a backdrop-click or outside-tap-to-close handler would honour:+ // beside the card, at the very top of the shell, and at the bottom edge+ // where a thumb rests. None of them may answer the question.+ const box = await card.boundingBox();+ const outside = [+ { x: 6, y: Math.round(box.y + box.height / 2) },+ { x: 187, y: 8 },+ { x: 187, y: 712 },+ ];+ for (const point of outside) {+ await page.mouse.click(point.x, point.y);+ await expect(card, `a tap at ${point.x},${point.y} must not answer the question`).toBeVisible();+ }+ // And the door is still shut after all of it.+ expect(await readState(instance, lock)).toBe('locked');++ // The two deliberate answers still work, and Cancel is one of them.+ await card.getByRole('button', { name: 'Cancel' }).click();+ await expect(card).toBeHidden({ timeout: 30_000 });+ expect(await readState(instance, lock), 'cancelling must leave the door locked').toBe('locked');++ await page.setViewportSize({ width: 1440, height: 900 });+});++test('the floorplan editor is a touch target at 320 and 375, not only at 1440', async ({ page }) => {+ await signIn(page, 'owner');+ // The editor is where the 44px floor is easiest to miss: its controls are a+ // dense toolbar and a tray of device chips, and the breakpoint sweep above+ // only ever opens the 2D house.+ for (const width of [320, 375]) {+ await page.setViewportSize({ width, height: 720 });+ await openView(page, homeId, 'plan');+ await settle(page);++ const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);+ expect(overflow, `the editor must not push the page sideways at ${width}px`).toBeLessThanOrEqual(1);++ const small = await page.evaluate(() => {+ const out = [];+ // The rooms on the canvas are sized by the plan itself: a 1.5m room+ // is meant to be small, and forcing it to 44px would lie about the+ // house. Every control that is chrome rather than content is held to+ // the floor.+ for (const node of document.querySelectorAll('#hs-plan button, #hs-plan [role="button"]:not(.hm-plan-room), #hs-plan input')) {+ const r = node.getBoundingClientRect();+ if (r.width === 0 && r.height === 0) continue;+ if (r.height < 44) out.push(`${node.className || node.tagName}: ${Math.round(r.height)}px`);+ }+ return out;+ });+ expect(small, `floorplan controls under 44px at ${width}px`).toEqual([]);+ }+ await page.setViewportSize({ width: 1440, height: 900 });+ await openView(page, homeId, '2d');+});+test.afterAll(async () => {// Whatever a journey did to the front door, put it back.const instance = homeInstance();diff --git a/tests/e2e/home-confirmation.spec.js b/tests/e2e/home-confirmation.spec.jsindex d4c6e4eae..e66f4943c 100644--- a/tests/e2e/home-confirmation.spec.js+++ b/tests/e2e/home-confirmation.spec.js@@ -13,7 +13,9 @@ import { expect, test } from '@playwright/test';import {connectHome,+ csrfHeaders,homeInstance,+ laneHome,lockedDoor,openScene,readState,@@ -84,8 +86,7 @@ test('journey 7: a guest is refused the unlock by role, and the door stays locke// The owner invites a guest into the household, through the real invite API// the members panel calls.await signIn(page, 'owner');- const homes = await (await page.request.get('/api/home')).json();- const home = (Array.isArray(homes?.homes) ? homes.homes : homes)[0];+ const home = await laneHome(page);expect(home?.id, 'journey 5 left a connected home for this one to use').toBeTruthy();const guestContext = await browser.newContext();@@ -95,15 +96,33 @@ test('journey 7: a guest is refused the unlock by role, and the door stays lockeconst invited = await page.request.post(`/api/home/${home.id}/members`, {data: { email: guest.email, role: 'guest' },- headers: { 'content-type': 'application/json' },+ headers: await csrfHeaders(page),timeout: 60_000,});expect(invited.ok(), `inviting the guest returned ${invited.status()}`).toBe(true);const invite = await invited.json().catch(() => ({}));- if (invite?.invite?.token) {- const accepted = await guestPage.request.post(`/api/home/invites/${invite.invite.token}`, { timeout: 60_000 });- expect(accepted.ok(), `accepting the invite returned ${accepted.status()}`).toBe(true);- }++ // The plaintext token is carried ONLY in the invite URL: the response body+ // deliberately never repeats it. An earlier version of this journey looked+ // for `invite.invite.token`, found undefined, and skipped the acceptance+ // inside an `if`, so the "guest" was never in the household at all. The+ // call it then made was refused 404 as a stranger rather than 403 as a+ // guest, and a status-only assertion could not tell those apart.+ const token = new URL(invite.invite_url).searchParams.get('invite');+ expect(token, 'the invite response must carry a usable invite link').toBeTruthy();++ const accepted = await guestPage.request.post(`/api/home/invites/${token}`, {+ headers: await csrfHeaders(guestPage),+ timeout: 60_000,+ });+ expect(accepted.ok(), `accepting the invite returned ${accepted.status()}: ${(await accepted.text()).slice(0, 200)}`).toBe(true);++ // The guest is really in the household now, holding the guest role. Without+ // this the refusal below could be a stranger being turned away, which+ // proves nothing about roles.+ const roster = await (await page.request.get(`/api/home/${home.id}/members`, { timeout: 60_000 })).json();+ const seat = (roster.members || []).find((m) => m.email === guest.email);+ expect(seat?.role, 'the guest must hold the guest role before the refusal is meaningful').toBe('guest');const lock = await lockedDoor(instance);expect(await readState(instance, lock)).toBe('locked');@@ -113,11 +132,21 @@ test('journey 7: a guest is refused the unlock by role, and the door stays locke// is a human saying yes, never an authorisation.const attempt = await guestPage.request.post(`/api/home/${home.id}/call`, {data: { domain: 'lock', service: 'unlock', entity_id: lock, confirmed: true },- headers: { 'content-type': 'application/json' },+ headers: await csrfHeaders(guestPage),timeout: 60_000,});expect(attempt.ok(), 'a guest must not be able to unlock a door').toBe(false);- expect([401, 403]).toContain(attempt.status());+ expect(attempt.status()).toBe(403);++ // Refused for the RIGHT reason. A missing CSRF header is also a 403, so a+ // status-only assertion passes just as happily when the request never+ // reached the role gate at all, and the journey would then be reporting+ // that guests cannot unlock doors while proving only that this client+ // forgot a header. The code names the gate that actually turned it away.+ // api/_lib/http.js shapes an error as { error: <code>, error_description }.+ const refusal = await attempt.json().catch(() => ({}));+ expect(refusal.error, `the refusal must be the role gate, not ${refusal.error}`).toBe('role_forbidden');+ expect(String(refusal.error_description || '')).toMatch(/guest/i);expect(await readState(instance, lock), 'a refused guest must leave the door locked').toBe('locked');await expect@@ -131,8 +160,7 @@ test('journey 7: a guest is refused the unlock by role, and the door stays locketest('journey 4: "good night" runs the house\'s own scene, and the lock it touches is gated', async ({ page }) => {const instance = homeInstance();await signIn(page, 'owner');- const homes = await (await page.request.get('/api/home')).json();- const home = (Array.isArray(homes?.homes) ? homes.homes : homes)[0];+ const home = await laneHome(page);expect(home?.id).toBeTruthy();const lock = await lockedDoor(instance);@@ -141,16 +169,16 @@ test('journey 4: "good night" runs the house\'s own scene, and the lock it touch// shipped: the seeded house has Bedtime, and the resolver has to find it.const dry = await page.request.post(`/api/home/${home.id}/activate`, {data: { phrase: 'good night', dryRun: true },- headers: { 'content-type': 'application/json' },+ headers: await csrfHeaders(page),timeout: 60_000,});- expect(dry.ok(), `activate dry run returned ${dry.status()}`).toBe(true);+ expect(dry.ok(), `activate dry run returned ${dry.status()}: ${(await dry.text()).slice(0, 300)}`).toBe(true);const preview = await dry.json();expect(preview.match?.entityId, '"good night" must resolve to a scene in this house').toMatch(/^(scene|script)\./);const ran = await page.request.post(`/api/home/${home.id}/activate`, {data: { phrase: 'good night' },- headers: { 'content-type': 'application/json' },+ headers: await csrfHeaders(page),timeout: 60_000,});const body = await ran.json().catch(() => ({}));diff --git a/tests/e2e/home-connect-gallery.spec.js b/tests/e2e/home-connect-gallery.spec.jsindex e00faba19..9be46b00f 100644--- a/tests/e2e/home-connect-gallery.spec.js+++ b/tests/e2e/home-connect-gallery.spec.js@@ -33,6 +33,35 @@ const MOBILE = { width: 320, height: 720 };const root = (page) => page.locator('#hm-root');+/**+ * Lines Chromium wrote, as opposed to lines the page wrote.+ *+ * The distinction matters because this assertion is the only thing standing+ * between a state and console noise nobody sees until a stranger reaches it, so+ * it must not be softened into a blanket mute. Three things get through, each+ * identified by who emitted it rather than by an allowlist of the states that+ * happen to trip it today:+ *+ * - the dev server's HMR socket, which cannot reach this Codespace;+ * - `Failed to load resource` for an `/api/` route THIS SPEC deliberately+ * fulfilled with an error status. That message comes from the network+ * stack, not from JavaScript, and the state under test is the page having+ * handled the response correctly. The same line for a stylesheet, a script+ * or a font still fails, which is the half worth keeping;+ * - `GL Driver Message`, printed by the GPU process about its own software+ * rasteriser under headless. No page code can emit that string.+ *+ * Scoping the second one by URL rather than by status is deliberate. The filter+ * used to name 401, states 8 and 12 arrived later with a 502 and a 402, and+ * both were red for a reason that had nothing to do with either screen.+ */+function isBrowserNoise(text, url) {+ if (/\[vite\]|websocket|HMR/i.test(text)) return true;+ if (/GL Driver Message/i.test(text)) return true;+ if (/^Failed to load resource/i.test(text)) return new URL(url, 'http://localhost').pathname.startsWith('/api/');+ return false;+}+fs.mkdirSync(OUT, { recursive: true });/**@@ -52,10 +81,7 @@ function screen(name, expected, reach) {page.on('console', (msg) => {if (msg.type() !== 'error' && msg.type() !== 'warning') return;const text = msg.text();- // The dev server's own HMR socket cannot reach this Codespace, and a- // route the spec deliberately fulfils with a 401 is answered, not- // broken. Neither is page code.- if (/\[vite\]|websocket|HMR|Failed to load resource: the server responded with a status of 401/i.test(text)) return;+ if (isBrowserNoise(text, msg.location()?.url || '')) return;noise.push(`${msg.type()}: ${text}`);});diff --git a/tests/e2e/home-connect-live.spec.js b/tests/e2e/home-connect-live.spec.jsindex ad6d90df8..e1a62a932 100644--- a/tests/e2e/home-connect-live.spec.js+++ b/tests/e2e/home-connect-live.spec.js@@ -161,10 +161,13 @@ test.describe('/smart-home against a real Home Assistant', () => {expect(leaks.cookie, 'the token reached a cookie').toBe(false);expect(leaks.url, 'the token reached the URL').toBe(false);- // And the page said nothing to the console on the way through. The dev- // server's HMR socket cannot reach this Codespace and is not page code;- // everything else is.- const noise = consoleLines.filter((line) => !/\[vite\]|websocket/i.test(line));+ // And the page said nothing to the console on the way through. Two things+ // here are Chromium talking to itself rather than the page talking: the+ // dev server's HMR socket, which cannot reach this Codespace, and the GPU+ // process reporting a stall in its own software rasteriser under headless+ // (`GL Driver Message`, a string no page code can emit). Everything else+ // is the page and fails.+ const noise = consoleLines.filter((line) => !/\[vite\]|websocket|GL Driver Message/i.test(line));expect(noise, 'the connect flow wrote to the console').toEqual([]);// The field is cleared the moment the connect lands, so a shoulder over@@ -270,4 +273,47 @@ test.describe('/smart-home against a real Home Assistant', () => {fs.writeFileSync(path.join(OUT, 'keyboard-walkthrough.json'), `${JSON.stringify({ tabStops: stops }, null, '\t')}\n`);});++ test('a token a real house rejects lands on state 7, not on a generic failure', async ({ page }) => {+ const house = homeInstance();+ await signIn(page, 'owner');+ await resetHomes(page);++ // A stub can prove the page maps code `auth` onto state 7. It cannot prove+ // the thing in front of it: that a real Home Assistant answering a real+ // bad token with 401 is classified as `auth` at all rather than falling+ // into the generic branch. That classification lives on the server, on the+ // wire, and it is the difference between "create a new token" and "that+ // did not work", which is the difference between a user recovering and a+ // user giving up on an address that was never wrong.+ await openConnectCard(page);+ await page.fill('#hm-label', 'Rejected token');+ await page.fill('#hm-url', house.baseUrl);+ await page.fill('#hm-token', 'not-a-real-long-lived-access-token');++ const rejected = page.waitForResponse(+ (res) => res.request().method() === 'POST' && /\/api\/home$/.test(new URL(res.url()).pathname),+ { timeout: 180_000 },+ );+ await page.getByRole('button', { name: 'Connect this home' }).click();+ const res = await rejected;+ const body = await res.json().catch(() => null);+ expect(res.status(), 'a house that refuses the token is a 4xx, never a 5xx').toBeLessThan(500);+ expect(body?.code, 'the wire code the page branches on').toBe('auth');++ await expect(page.locator('#hm-root')).toHaveAttribute('data-state', 'auth_failed', { timeout: 60_000 });+ // Refocused on the field that has to change. Sending a keyboard user back+ // to the top of the form to walk it again is the dead end this replaces.+ await expect(page.locator('#hm-token')).toBeFocused();+ // And it says which thing is wrong, with the path to a fresh one.+ await expect(page.locator('.hm-notice')).toContainText(/rejected that token/i);+ await expect(page.locator('.hm-notice')).toContainText(/Long-lived access tokens/i);+ // The address the user typed survives, because it was never the problem.+ await expect(page.locator('#hm-url')).toHaveValue(house.baseUrl);+ // Nothing was stored: a refused token must not leave a half-home behind.+ const after = await page.request.get('/api/home', { timeout: 60_000 }).then((r) => r.json());+ expect((after.homes || []).some((h) => h.label === 'Rejected token')).toBe(false);++ await page.screenshot({ path: path.join(OUT, 'auth-failed-live.png'), fullPage: true });+ });});diff --git a/tests/e2e/home-connect-stubs.js b/tests/e2e/home-connect-stubs.jsindex 64c3cf037..4aaed803d 100644--- a/tests/e2e/home-connect-stubs.js+++ b/tests/e2e/home-connect-stubs.js@@ -20,7 +20,25 @@ export const STATUS = '**/api/status';/** First hit transforms this page's module graph through the dev server. */export const SLOW = 60_000;-/** A house as the API returns it, measured against a real instance. */+/**+ * A house as the API returns it, measured against a real instance.+ *+ * The three timestamps are GETTERS, and that is the whole point of them. A+ * connected home whose last handshake has aged past 90 seconds is state 9, not+ * state 6, and the manage view is right to say so. Stamping `last_ok_at` once+ * when this module is imported therefore built a fixture with a 90-second fuse+ * in it: the first specs in a run saw a live house and every spec after the+ * ninety-second mark saw the same fixture as stale, so `connected` assertions+ * went red purely as a function of how long the run had been going and which+ * order the files happened to execute in. The suite is eight minutes long, so+ * most of it was on the wrong side of that line.+ *+ * Reading them per access makes the fixture mean what it says at the moment it+ * is used. Every `{ ...HOME }` spread and every `stub(page, { homes: [HOME] })`+ * gets a house that answered just now, and a spec that wants a stale one still+ * says so explicitly by overriding `last_ok_at`, which is how state 9 is+ * reached on purpose rather than by the clock.+ */export const HOME = {id: '2b0d4c7e-1f8a-4c3d-9e11-7a6b5c4d3e2f',label: 'Home',@@ -30,10 +48,10 @@ export const HOME = {status: 'connected',status_detail: null,capabilities: { websocket: true, entityCount: 120, areaCount: 3, floorCount: 1, macroCount: 2, haVersion: '2026.9.0', mcp: false, mcpToolCount: 0 },- last_ok_at: new Date().toISOString(),+ get last_ok_at() { return new Date().toISOString(); },last_error_at: null,- created_at: new Date().toISOString(),- updated_at: new Date().toISOString(),+ get created_at() { return new Date().toISOString(); },+ get updated_at() { return new Date().toISOString(); },revoked_at: null,};diff --git a/tests/e2e/home-floorplan.spec.js b/tests/e2e/home-floorplan.spec.jsindex e2338ba5a..3333ae9fe 100644--- a/tests/e2e/home-floorplan.spec.js+++ b/tests/e2e/home-floorplan.spec.js@@ -108,11 +108,24 @@ function watchConsole(page) {return found;}+/**+ * Open the plan view and wait for it to have actually loaded.+ *+ * The wait on `.hm-plan-tray` is the load-bearing half. `#hs-plan` is the+ * container and appears immediately, while the editor renders a skeleton until+ * the layout and the room graph arrive; the tray is the first thing that exists+ * only on the far side of that. Two journeys below decide whether to skip by+ * counting tray entries, and without this they counted the skeleton: on a busy+ * machine 9b and 9c skipped every run with "already placed" and "nothing left+ * unfiled" against a house with four areas and seventy-eight unfiled devices,+ * which is a green report for two journeys that never ran.+ */async function openPlan(page) {const plan = page.getByRole('button', { name: /Draw where the rooms are/i });await expect(plan).toBeVisible({ timeout: 60_000 });await plan.click();await expect(page.locator('#hs-plan')).toBeVisible();+ await expect(page.locator('.hm-plan-tray')).toBeVisible({ timeout: 60_000 });}test('journey 9: a floorplan is drawn, saved, and still there after a reload', async ({ page }) => {diff --git a/tests/e2e/home-global-setup.js b/tests/e2e/home-global-setup.jsindex abbbcbed6..32c48542f 100644--- a/tests/e2e/home-global-setup.js+++ b/tests/e2e/home-global-setup.js@@ -104,7 +104,13 @@ async function raiseHomeCeiling(accounts) {import('../../api/_lib/db.js'),import('../../api/_lib/home/entitlements.js'),]);- for (const role of ['owner', 'guest']) {+ // ROLES, not a hardcoded pair. HOME_E2E_ROLES exists so a lane that only+ // needs an owner does not spend one of five hourly registrations on a guest,+ // and that is the escape hatch a run reaches for when the budget is already+ // gone. Reading `accounts.guest.email` in a run that deliberately provisioned+ // no guest threw here, so the one path out of a rate limit was itself broken.+ for (const role of ROLES) {+ if (!accounts[role]?.email) continue;const rows = await sql`select id from users where email = ${accounts[role].email}`;if (!rows.length) continue;await setAccountOverride({diff --git a/tests/e2e/home-support.js b/tests/e2e/home-support.jsindex 4ef83b50c..ad8f07d4e 100644--- a/tests/e2e/home-support.js+++ b/tests/e2e/home-support.js@@ -73,6 +73,34 @@ export async function signIn(page, role = 'owner') {return account;}+/**+ * A CSRF header, minted the way the real client mints one.+ *+ * Every state-changing route on this surface is CSRF-guarded, and+ * `page.request.post` carries the session cookie WITHOUT the header a browser's+ * fetch would add, so a raw post is refused with `403 csrf_missing` before it+ * reaches the gate the journey is about. That refusal is a 403 like a role+ * refusal is a 403, which is how a test that proves nothing looks green: the+ * guest in journey 7 was being turned away at the door for the wrong reason.+ *+ * So this walks the same path `src/home/api.js` walks: GET /api/csrf-token with+ * the session, then send what it returns. Tokens are single-use, so this is+ * called per request rather than cached.+ *+ * Prefer clicking the real control where one exists. This is for the setup a+ * journey needs before its assertion, and for the requests whose whole point is+ * that they come from a client the UI would never let you be.+ *+ * @param {import('@playwright/test').Page} page+ */+export async function csrfHeaders(page) {+ const res = await page.request.get('/api/csrf-token', { timeout: 60_000 });+ if (!res.ok()) throw new Error(`GET /api/csrf-token returned ${res.status()}`);+ const body = await res.json();+ if (!body?.token) throw new Error('/api/csrf-token returned no token');+ return { 'content-type': 'application/json', 'x-csrf-token': body.token };+}+/** Every home on the signed-in account, however the endpoint shapes its list. */async function listHomes(page) {const list = await page.request.get('/api/home', { timeout: 60_000 });@@ -109,6 +137,28 @@ async function laneHomes(page) {* Each one therefore starts from an account with no houses of ITS OWN on it;* a concurrent lane's houses are none of its business.*/+/**+ * THIS lane's home, the one the journeys are about.+ *+ * Not `(await listHomes(page))[0]`. That is "the first home on the account",+ * and it is a different thing: a run that recreated its container gets a new+ * port, so the previous run's rows no longer match this lane's base URL, are+ * not cleared by `resetHomes`, and stay at the front of the list. A journey+ * that then acted on `homes[0]` was acting on a home whose stored Home+ * Assistant token was sealed with an earlier run's per-run encryption key, and+ * the API answered `400 auth: the stored access token for this home could not+ * be read` from a route that was working perfectly.+ *+ * @param {import('@playwright/test').Page} page+ */+export async function laneHome(page) {+ const homes = await laneHomes(page);+ if (!homes.length) {+ throw new Error(`no connected home on this lane's house (${homeBaseUrl(homeInstance())})`);+ }+ return homes[0];+}+export async function resetHomes(page) {const homes = await laneHomes(page);for (const home of homes) {diff --git a/vite.config.js b/vite.config.jsindex c8ea0e94a..fadc11dbd 100644--- a/vite.config.js+++ b/vite.config.js@@ -192,6 +192,19 @@ const CODESPACE_HMR =}: undefined;+/**+ * Hot reload, or deliberately none of it.+ *+ * `VITE_NO_HMR` turns the client off entirely, and an e2e run is the case it+ * exists for. This worktree is shared by concurrent agents who edit `src/`+ * while a journey is mid-flight, and with HMR connected every one of their+ * saves reloads the page under the browser: a run on 2026-09-09 took five full+ * reloads from a peer editing src/home/scene-render.js, and journey 9e died on+ * a navigation that landed between naming a room and clicking File. A test+ * browser wants the build it loaded and nothing else.+ */+const HMR = process.env.VITE_NO_HMR ? false : CODESPACE_HMR;+// Content types for the file kinds `npm run build:chat` emits into public/chat.// A dev-only static fallback needs exactly these; anything else is served as an// octet-stream rather than guessed.@@ -266,7 +279,7 @@ const appConfig = {server: {// Bind to 0.0.0.0 so the Codespace port-forwarder can reach the server.host: true,- ...(CODESPACE_HMR ? { hmr: CODESPACE_HMR } : {}),+ ...(HMR === undefined ? {} : { hmr: HMR }),proxy: {'/r2-proxy': {target: 'https://pub-2534e921bf9c4314addcd4d8a6e98b7b.r2.dev',