diff --git a/crates/ghostlight-dungeon/page/index.html b/crates/ghostlight-dungeon/page/index.html
index d71103e..4284902 100644
--- a/crates/ghostlight-dungeon/page/index.html
+++ b/crates/ghostlight-dungeon/page/index.html
@@ -14,8 +14,8 @@
-
-
+
+
Loading…
diff --git a/crates/ghostlight-dungeon/page/page.css b/crates/ghostlight-dungeon/page/page.css
index bd901a3..63dd93a 100644
--- a/crates/ghostlight-dungeon/page/page.css
+++ b/crates/ghostlight-dungeon/page/page.css
@@ -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; } }
diff --git a/crates/ghostlight-dungeon/page/page.js b/crates/ghostlight-dungeon/page/page.js
index 3dfae55..0018ec3 100644
--- a/crates/ghostlight-dungeon/page/page.js
+++ b/crates/ghostlight-dungeon/page/page.js
@@ -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() {
diff --git a/probes/page/01-signin-desktop.png b/probes/page/01-signin-desktop.png
new file mode 100644
index 0000000..af8ab62
Binary files /dev/null and b/probes/page/01-signin-desktop.png differ
diff --git a/probes/page/01-signin-phone.png b/probes/page/01-signin-phone.png
new file mode 100644
index 0000000..95d4955
Binary files /dev/null and b/probes/page/01-signin-phone.png differ
diff --git a/probes/page/02-worlds-empty-desktop.png b/probes/page/02-worlds-empty-desktop.png
new file mode 100644
index 0000000..345c486
Binary files /dev/null and b/probes/page/02-worlds-empty-desktop.png differ
diff --git a/probes/page/02-worlds-empty-phone.png b/probes/page/02-worlds-empty-phone.png
new file mode 100644
index 0000000..4011304
Binary files /dev/null and b/probes/page/02-worlds-empty-phone.png differ
diff --git a/probes/page/03-begin-desktop.png b/probes/page/03-begin-desktop.png
new file mode 100644
index 0000000..2cd822f
Binary files /dev/null and b/probes/page/03-begin-desktop.png differ
diff --git a/probes/page/03-begin-phone.png b/probes/page/03-begin-phone.png
new file mode 100644
index 0000000..9d3fe4d
Binary files /dev/null and b/probes/page/03-begin-phone.png differ
diff --git a/probes/page/04-ready-desktop.png b/probes/page/04-ready-desktop.png
new file mode 100644
index 0000000..d848464
Binary files /dev/null and b/probes/page/04-ready-desktop.png differ
diff --git a/probes/page/04-ready-phone.png b/probes/page/04-ready-phone.png
new file mode 100644
index 0000000..d2e4f1e
Binary files /dev/null and b/probes/page/04-ready-phone.png differ
diff --git a/probes/page/05-narration-desktop.png b/probes/page/05-narration-desktop.png
new file mode 100644
index 0000000..bd679af
Binary files /dev/null and b/probes/page/05-narration-desktop.png differ
diff --git a/probes/page/05-narration-phone.png b/probes/page/05-narration-phone.png
new file mode 100644
index 0000000..40c0c3e
Binary files /dev/null and b/probes/page/05-narration-phone.png differ
diff --git a/probes/page/06-question-desktop.png b/probes/page/06-question-desktop.png
new file mode 100644
index 0000000..88bb6b0
Binary files /dev/null and b/probes/page/06-question-desktop.png differ
diff --git a/probes/page/06-question-phone.png b/probes/page/06-question-phone.png
new file mode 100644
index 0000000..2592c24
Binary files /dev/null and b/probes/page/06-question-phone.png differ
diff --git a/probes/page/07-answered-scrollback-desktop.png b/probes/page/07-answered-scrollback-desktop.png
new file mode 100644
index 0000000..a3ea861
Binary files /dev/null and b/probes/page/07-answered-scrollback-desktop.png differ
diff --git a/probes/page/07-answered-scrollback-phone.png b/probes/page/07-answered-scrollback-phone.png
new file mode 100644
index 0000000..7b98690
Binary files /dev/null and b/probes/page/07-answered-scrollback-phone.png differ
diff --git a/probes/page/08-fault-retry-desktop.png b/probes/page/08-fault-retry-desktop.png
new file mode 100644
index 0000000..f0a6b60
Binary files /dev/null and b/probes/page/08-fault-retry-desktop.png differ
diff --git a/probes/page/08-fault-retry-phone.png b/probes/page/08-fault-retry-phone.png
new file mode 100644
index 0000000..1c8785d
Binary files /dev/null and b/probes/page/08-fault-retry-phone.png differ
diff --git a/probes/page/09-fault-after-retry-desktop.png b/probes/page/09-fault-after-retry-desktop.png
new file mode 100644
index 0000000..8700fe3
Binary files /dev/null and b/probes/page/09-fault-after-retry-desktop.png differ
diff --git a/probes/page/09-fault-after-retry-phone.png b/probes/page/09-fault-after-retry-phone.png
new file mode 100644
index 0000000..8534f48
Binary files /dev/null and b/probes/page/09-fault-after-retry-phone.png differ
diff --git a/probes/page/10-refusal-line-desktop.png b/probes/page/10-refusal-line-desktop.png
new file mode 100644
index 0000000..0da664d
Binary files /dev/null and b/probes/page/10-refusal-line-desktop.png differ
diff --git a/probes/page/10-refusal-line-phone.png b/probes/page/10-refusal-line-phone.png
new file mode 100644
index 0000000..d338df8
Binary files /dev/null and b/probes/page/10-refusal-line-phone.png differ
diff --git a/probes/page/11-worlds-seeding-failed-ready-desktop.png b/probes/page/11-worlds-seeding-failed-ready-desktop.png
new file mode 100644
index 0000000..04d641c
Binary files /dev/null and b/probes/page/11-worlds-seeding-failed-ready-desktop.png differ
diff --git a/probes/page/11-worlds-seeding-failed-ready-phone.png b/probes/page/11-worlds-seeding-failed-ready-phone.png
new file mode 100644
index 0000000..0f357dd
Binary files /dev/null and b/probes/page/11-worlds-seeding-failed-ready-phone.png differ
diff --git a/probes/page/12-seeding-progress-desktop.png b/probes/page/12-seeding-progress-desktop.png
new file mode 100644
index 0000000..bf90db4
Binary files /dev/null and b/probes/page/12-seeding-progress-desktop.png differ
diff --git a/probes/page/12-seeding-progress-phone.png b/probes/page/12-seeding-progress-phone.png
new file mode 100644
index 0000000..ef12a18
Binary files /dev/null and b/probes/page/12-seeding-progress-phone.png differ
diff --git a/probes/page/shoot.mjs b/probes/page/shoot.mjs
new file mode 100644
index 0000000..f4258a5
--- /dev/null
+++ b/probes/page/shoot.mjs
@@ -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 [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();