Page: one-row header, slimmer compose bar, scroll to the newest turn; probe screenshots and the CDP script that takes them

This commit is contained in:
Meta Vens 2026-12-02 21:07:39 +01:00
commit 5fa427266a
28 changed files with 75 additions and 11 deletions

View file

@ -14,8 +14,8 @@
<div class="tools">
<button id="smaller" class="tool" type="button" aria-label="Smaller text">A&minus;</button>
<button id="larger" class="tool" type="button" aria-label="Larger text">A+</button>
<button id="theme" class="tool" type="button" aria-label="Change theme">Theme</button>
<button id="signout" class="tool" type="button" hidden>Sign out</button>
<button id="theme" class="tool" type="button" aria-label="Switch light or dark theme">&#9680;</button>
<button id="signout" aria-label="Sign out" class="tool" type="button" hidden>Exit</button>
</div>
</header>
<main id="view" aria-live="polite"><p class="note">Loading&hellip;</p></main>

View file

@ -17,10 +17,10 @@ html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: var(--fs)/1.65 var(--body); overflow-wrap: anywhere; }
.bar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: .5rem;
padding: .4rem max(.75rem, env(safe-area-inset-left)); background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { background: none; border: 0; color: var(--accent); font: 600 1.05rem var(--head); letter-spacing: .06em; text-transform: uppercase; min-height: 44px; padding: 0 .25rem; cursor: pointer; }
.tools { display: flex; gap: .25rem; flex-wrap: wrap; justify-content: flex-end; }
.tool { background: none; border: 1px solid var(--line); color: var(--muted); font: 500 .8rem var(--head); border-radius: .5rem; min-height: 44px; min-width: 44px; padding: 0 .6rem; cursor: pointer; }
main { max-width: 44rem; margin: 0 auto; padding: .75rem max(.75rem, env(safe-area-inset-left)) 9rem; }
.brand { white-space: nowrap; background: none; border: 0; color: var(--accent); font: 600 1.05rem var(--head); letter-spacing: .06em; text-transform: uppercase; min-height: 44px; padding: 0 .25rem; cursor: pointer; }
.tools { display: flex; gap: .2rem; justify-content: flex-end; }
.tool { background: none; border: 1px solid var(--line); color: var(--muted); font: 500 .8rem var(--head); border-radius: .5rem; min-height: 44px; min-width: 44px; padding: 0 .5rem; cursor: pointer; }
main { max-width: 44rem; margin: 0 auto; padding: .75rem max(.75rem, env(safe-area-inset-left)) 10rem; }
h1, h2 { font-family: var(--head); font-weight: 300; line-height: 1.2; margin: .5rem 0 .75rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; }
.note, .small { color: var(--muted); font-size: .9rem; line-height: 1.5; }
@ -59,7 +59,7 @@ textarea { resize: vertical; line-height: 1.5; }
@media (prefers-reduced-motion: reduce) { .bar2 i { animation: none; width: 100%; } }
.compose { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); padding: .5rem max(.75rem, env(safe-area-inset-left)) max(.5rem, env(safe-area-inset-bottom)); }
.compose .in { max-width: 44rem; margin: 0 auto; }
.compose textarea { min-height: 3.2rem; max-height: 40vh; }
.compose textarea { min-height: 2.8rem; max-height: 30vh; }
.compose .row { margin-top: .4rem; }
.compose .btn { flex: 1 1 8rem; }
@media (min-width: 700px) { :root { --fs: 1.2rem; } main { padding-top: 1.25rem; } }

View file

@ -234,13 +234,13 @@ function playView(row) {
$retryRow = el("div", { class: "row" });
show(el("h1", {}, row.title), el("p", { class: "small" }, "Earlier turns stay on screen while this page is open; after a reload the open turn is shown again."), $log, $status, $retryRow);
document.querySelector(".compose")?.remove();
$text = el("textarea", { id: "say", rows: "2", "aria-label": "What do you do?", placeholder: "What do you do?" });
$text = el("textarea", { id: "say", rows: "2", "aria-label": "What do you do?", placeholder: "What do you do? (Empty Send carries on an unfinished turn.)" });
$text.value = LS.get("draft:" + S.timeline) || "";
$text.addEventListener("input", () => LS.set("draft:" + S.timeline, $text.value));
$send = el("button", { class: "btn", type: "button", onclick: () => send($text.value) }, "Send");
document.body.append(el("div", { class: "compose" }, el("div", { class: "in" }, $text, el("div", { class: "row" }, $send,
el("button", { class: "btn alt", type: "button", onclick: () => send("") }, "Continue"))
, el("p", { class: "small", id: "sendnote", style: "margin:.3rem 0 0" }, "Leave the box empty and press Send or Continue to carry on an unfinished turn."))));
el("button", { class: "btn alt", type: "button", title: "Carry on an unfinished turn", onclick: () => send("") }, "Continue"))
)));
connect();
}
const leavePlay = () => document.querySelector(".compose")?.remove();
@ -268,6 +268,7 @@ function onTurn(view) {
$status.className = "status"; $status.textContent = ""; $retryRow.replaceChildren();
return;
}
const nearBottom = !S.log.length || window.innerHeight + window.scrollY >= document.documentElement.scrollHeight - 240;
let entry = S.log.find((e) => e.id === turn.id);
if (!entry) { entry = { id: turn.id, you: S.nextYou }; S.nextYou = null; S.log.push(entry); }
Object.assign(entry, { state: turn.state, narration: turn.narration, question: turn.question, refusal: turn.refusal, fault: turn.fault });
@ -289,7 +290,7 @@ function onTurn(view) {
} else if (turn.refusal) {
$retryRow.append(el("button", { class: "btn alt", type: "button", onclick: editAgain, disabled: !S.lastText }, "Edit and resend"));
}
last.node?.scrollIntoView?.({ block: "end", behavior: "smooth" });
if (nearBottom) window.scrollTo(0, document.documentElement.scrollHeight);
}
function renderLog() {

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

63
probes/page/shoot.mjs Normal file
View file

@ -0,0 +1,63 @@
// Drives the page probe (api::tests::serve_the_page_for_a_browser_probe) in headless
// Chrome over CDP and writes screenshots at 360 px and desktop width.
// usage: node shoot.mjs <base-url> <out-dir> [chrome-path]
import { spawn } from "node:child_process";
import { writeFileSync, mkdirSync, mkdtempSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
const [base, out, chrome = "C:/Program Files/Google/Chrome/Application/chrome.exe"] = process.argv.slice(2);
mkdirSync(out, { recursive: true });
const port = 9333;
const proc = spawn(chrome, ["--headless=new", `--remote-debugging-port=${port}`, `--user-data-dir=${mkdtempSync(join(tmpdir(), "shoot-"))}`, "--no-first-run", "about:blank"], { stdio: "ignore" });
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
let targets;
for (let i = 0; i < 50; i++) { try { targets = await (await fetch(`http://127.0.0.1:${port}/json`)).json(); break; } catch { await sleep(200); } }
const ws = new WebSocket(targets.find((t) => t.type === "page").webSocketDebuggerUrl);
await new Promise((r) => (ws.onopen = r));
let id = 0; const pending = new Map();
ws.onmessage = (m) => { const d = JSON.parse(m.data); if (d.id && pending.has(d.id)) { pending.get(d.id)(d); pending.delete(d.id); } };
const cdp = (method, params = {}) => new Promise((r) => { const n = ++id; pending.set(n, r); ws.send(JSON.stringify({ id: n, method, params })); });
const js = async (expression) => (await cdp("Runtime.evaluate", { expression, awaitPromise: true, returnByValue: true })).result.result?.value;
const widths = { phone: [360, 740], desktop: [1100, 800] };
async function shot(name) {
for (const [label, [w, h]] of Object.entries(widths)) {
await cdp("Emulation.setDeviceMetricsOverride", { width: w, height: h, deviceScaleFactor: label === "phone" ? 2 : 1, mobile: label === "phone" });
await sleep(350);
const overflow = await js("document.documentElement.scrollWidth > document.documentElement.clientWidth");
const { result } = await cdp("Page.captureScreenshot", { format: "png" });
writeFileSync(join(out, `${name}-${label}.png`), Buffer.from(result.data, "base64"));
console.log(name, label, "horizontal-overflow:", overflow);
}
}
const go = async (url) => { await cdp("Page.navigate", { url }); await sleep(900); };
const click = (sel) => js(`document.querySelector(${JSON.stringify(sel)}).click()`);
const fill = (sel, v) => js(`(()=>{const e=document.querySelector(${JSON.stringify(sel)});e.value=${JSON.stringify(v)};e.dispatchEvent(new Event('input',{bubbles:true}))})()`);
const clickText = (text) => js(`[...document.querySelectorAll('button')].find(b=>b.textContent.trim()===${JSON.stringify(text)}).click()`);
const waitFor = async (expr, ms = 20000) => { for (let t = 0; t < ms; t += 250) { if (await js(expr)) return true; await sleep(250); } return false; };
await cdp("Page.enable");
await go(base + "/"); await waitFor("!!document.querySelector('#invite')"); await shot("01-signin");
await go(base + "/#invite=abcdefgh1234"); await sleep(300);
await go(base + "/probe/login"); await waitFor("document.body.innerText.includes('Your worlds')"); await shot("02-worlds-empty");
await clickText("Begin a new world"); await waitFor("!!document.querySelector('#title')"); await shot("03-begin");
await fill("#title", "Ashfall"); await fill("#name", "Deru"); await clickText("Begin");
await waitFor("!!document.querySelector('#say')"); await shot("04-ready");
await fill("#say", "I walk up the ash road to the gate and nod to the woman at the toll hut."); await clickText("Send");
await waitFor("document.body.innerText.includes('You are late')"); await sleep(500); await shot("05-narration");
await fill("#say", "I ask what I am late for."); await clickText("Send");
await waitFor("document.body.innerText.includes('Which way')"); await sleep(500); await shot("06-question");
await fill("#say", "The lower road."); await clickText("Send");
await waitFor("document.body.innerText.includes('dogs do not bark')"); await sleep(500); await shot("07-answered-scrollback");
await fill("#say", "I draw my sword on the toll woman."); await clickText("Send");
await waitFor("document.body.innerText.includes('lost the thread')"); await sleep(500); await shot("08-fault-retry");
await clickText("Retry"); await waitFor("document.body.innerText.includes('lost the thread')"); await sleep(800); await shot("09-fault-after-retry");
// A refusal needs a dispatch the world refuses; the scripted model cannot make one cheaply, so the
// turn view the daemon would send is handed to the page's own renderer.
await js(`onTurn({timeline:S.timeline,turn:{id:'probe-refusal',state:'closed',narration:null,question:null,refusal:'The world refuses that: the toll woman is not within your reach.',fault:null,resolving:false}})`);
await sleep(300); await shot("10-refusal-line");
// Seeding and failed rows come from the daemon's timeline status; stub the list to see them rendered.
await js(`window.fetch=(u,o)=>String(u).endsWith('api/timelines')?Promise.resolve(new Response(JSON.stringify({timelines:[{timeline:'t1',status:'seeding',title:'Zyphos, a long first evening',current:true,createdAt:new Date().toISOString()},{timeline:'t2',status:'failed',reason:'the storyteller was unavailable',title:'Delvehold',createdAt:new Date().toISOString()},{timeline:'t3',status:'ready',parent:'t0',title:'Ashfall',createdAt:new Date().toISOString()}]}),{status:200})):Promise.reject(new Error('stub'));`);
await js("listView()"); await sleep(500); await shot("11-worlds-seeding-failed-ready");
await js("openTimeline('t1')"); await sleep(500); await shot("12-seeding-progress");
ws.close(); proc.kill();