web: gated access, anchored viewers, mobile tabs and chat colour

- serve.mjs requires a signed session cookie for every page, artifact and the
  WebSocket, with a password file, 30-day sessions, login throttling and public
  brand assets for the sign-in page.
- The diff viewer is a fixed-height top-anchored panel whose toolbar (modes,
  copy, previous, next, close as icons) is its first row; the artifact viewer is
  likewise a fixed frame so its navigation never moves.
- The audit's selected tab uses the app's normal selected surface and bottom
  accent. Sessions that were not recorded say so plainly.
- Chat code blocks are syntax-coloured; graph pinch-zoom works with two fingers
  while a single pointer still pans and clicks nodes.
- Phones always keep the destination bar (pane collapse is wide-only), with the
  destinations spread evenly and Search on the right; the list default width is
  narrower; the theme colour matches the app.
- Code-format and layout tests, plus the full browser suite, pass.
This commit is contained in:
2026-10-20 02:21:51 +01:00
parent d7763ec466
commit ebf02c3bed
17 changed files with 558 additions and 42 deletions
+9 -1
View File
@@ -8,6 +8,7 @@ import { writeChatStars } from "../chatStars.js";
import { describeError } from "../format.js";
import { SHELL_OUTPUT_LIMIT, newChatOperationId } from "../repository.js";
import { codeBlockLabel, parseInline, parseMarkdown } from "../markdown.js";
import { highlight } from "../highlight.js";
import { formatDuration } from "../runs.js";
import { humanBytes } from "../artifacts.js";
import { changeStat, diffLineClass, diffLineSymbol } from "../changes.js";
@@ -2710,7 +2711,14 @@ function renderMarkdownBlock(block) {
if (block.kind === "code") {
const code = h("div", { class: "md-code-block" });
code.append(h("div", { class: "md-code-label", text: codeBlockLabel(block.language) }));
code.append(h("pre", { class: "md-pre" }, h("code", { text: block.code })));
const pre = h("pre", { class: "md-pre" });
const body = h("code");
for (const token of highlight(block.code, block.language)) {
if (token.kind === "plain") body.append(document.createTextNode(token.text));
else body.append(h("span", { class: `tok-${token.kind}`, text: token.text }));
}
pre.append(body);
code.append(pre);
return code;
}
if (block.kind === "rule") return h("hr", { class: "md-rule" });
+31 -23
View File
@@ -114,24 +114,7 @@ function openChangeViewer(files, startIndex, trigger = null) {
text: `${changePositionLabel(index, files.length)} · changed by ${(entry.steps ?? []).join(" → ")}`,
}),
);
const head = h(
"div",
{ class: "change-viewer-head" },
titles,
h("button", {
class: "change-viewer-copy",
type: "button",
text: "Copy raw patch",
disabled: !hasPatch,
onclick: () => copyText(entry.patch ?? ""),
}),
h("button", {
class: "change-viewer-close",
type: "button",
text: "Close diff",
onclick: closeChangeViewer,
}),
);
const head = h("div", { class: "change-viewer-head" }, titles);
const controls = h(
"div",
@@ -160,10 +143,22 @@ function openChangeViewer(files, startIndex, trigger = null) {
}),
h("div", { class: "change-viewer-spacer" }),
h("button", {
class: "change-page",
class: "change-icon",
type: "button",
"data-action": "copy",
title: "Copy raw patch",
"aria-label": "Copy raw patch",
text: "\u29c9",
disabled: !hasPatch,
onclick: () => copyText(entry.patch ?? ""),
}),
h("button", {
class: "change-icon",
type: "button",
"data-page": "prev",
text: "Previous file",
title: "Previous file",
"aria-label": "Previous file",
text: "\u2039",
disabled: index === 0,
onclick: () => {
index = Math.max(index - 1, 0);
@@ -172,10 +167,12 @@ function openChangeViewer(files, startIndex, trigger = null) {
},
}),
h("button", {
class: "change-page",
class: "change-icon",
type: "button",
"data-page": "next",
text: "Next file",
title: "Next file",
"aria-label": "Next file",
text: "\u203a",
disabled: index === files.length - 1,
onclick: () => {
index = Math.min(index + 1, files.length - 1);
@@ -183,6 +180,15 @@ function openChangeViewer(files, startIndex, trigger = null) {
renderViewer();
},
}),
h("button", {
class: "change-icon",
type: "button",
"data-action": "close",
title: "Close diff",
"aria-label": "Close diff",
text: "\u00d7",
onclick: closeChangeViewer,
}),
);
const body = h("div", { class: "change-viewer-body" });
@@ -199,7 +205,9 @@ function openChangeViewer(files, startIndex, trigger = null) {
body.append(renderRenderedDiff(entry));
}
panel.replaceChildren(head, controls, body);
// The toolbar is the first row: paging/copy/close never move when the
// path or the diff length changes.
panel.replaceChildren(controls, head, body);
};
renderViewer();
+6 -1
View File
@@ -305,7 +305,12 @@ function auditArtifact(step, name, emptyMessage) {
/** The exported session, rendered in place, with the raw file one click away. */
function auditSession(step) {
const artifact = systemArtifacts(step).find((entry) => entry.name === "session.html");
if (!artifact) return renderSessionExport(step);
if (!artifact) {
return h("div", {
class: "muted",
text: "Session not recorded for this visit. Sessions are exported by model stages.",
});
}
const resolved = resolvedArtifactUrl(artifact, state.url);
const wrap = h("div", { class: "audit-session" });
if (!resolved) {