From 70e52ed35cb3ea7212fdbf9e85488d6e722e7d14 Mon Sep 17 00:00:00 2001 From: Daniel Rispler Date: Tue, 1 Dec 2026 21:30:12 +0200 Subject: [PATCH 01/11] Studio: an unreachable plotkeeper says so plainly, and Pre-flight says when it couldn't read issues (#1046) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01CVqACafozqqdDZevv65PCa --- scripts/snap/fixtures-runs.ts | 18 ++++++++++++++++++ scripts/snap/fixtures.ts | 3 ++- ui/map-pre-flight.ts | 11 ++++++++--- ui/notice.ts | 10 +++++++++- ui/tests/map-pre-flight.test.mjs | 14 ++++++++++++++ ui/tests/notice.test.mjs | 23 ++++++++++++++++++++++- ui/tests/transport.test.mjs | 15 +++++++++++++++ ui/transport.ts | 6 +++++- 8 files changed, 93 insertions(+), 7 deletions(-) diff --git a/scripts/snap/fixtures-runs.ts b/scripts/snap/fixtures-runs.ts index c1acba09e..ccf454969 100644 --- a/scripts/snap/fixtures-runs.ts +++ b/scripts/snap/fixtures-runs.ts @@ -151,6 +151,24 @@ export const mapPreFlightStatus = (): Fixture => pre_flight_predict: { __delay: 200, value: { __throw: "the writer is not set" } } as never, snapDone: "pre-flight status ok", }); +/** #1046: issues `gh` could not list read as a failure with its reason, not as "No open issues."; the text box and Pick parts by hand stay. */ +export const mapPreFlightIssuesFailed = (): Fixture => + mapOpened(` + document.getElementById("pre-flight-button").click(); + await wait(600); + const box = document.getElementById("map-pre-flight"); + const words = box.textContent; + if (!words.includes("Couldn't read the open issues: gh: not logged in")) log("snap:fail the failure line is missing: " + words); + if (words.includes("No open issues")) log("snap:fail a failed read says there are no open issues"); + const field = box.querySelector("textarea.pre-flight-text"); + if (!field || field.disabled || field.readOnly) log("snap:fail the text box is missing or not usable"); + const byHand = [...box.querySelectorAll("button")].find((b) => b.textContent === "Pick parts by hand"); + if (!byHand || byHand.disabled) return log("snap:fail Pick parts by hand is missing or disabled"); + log("pre-flight issues failed ok");`, { + map_state: mapState(), + pre_flight_issues: { __throw: "gh: not logged in" } as never, + snapDone: "pre-flight issues failed ok", + }); // Pre-flight's outside press (#666), with a real pointer: the overlay opened on the framed pre-flight, its result, `check` then run. const preFlightPressed = (check: string, done: string): Fixture => ({ ...mapOpened(` diff --git a/scripts/snap/fixtures.ts b/scripts/snap/fixtures.ts index a903eab5b..1dafc9698 100644 --- a/scripts/snap/fixtures.ts +++ b/scripts/snap/fixtures.ts @@ -11,7 +11,7 @@ import { mapBadgeList, mapNowSubagents, mapBase, mapCheckout, mapDefaultNoBanner import { readmeFixtures } from "./fixtures-readme.ts"; import { readmeBriefFixtures } from "./fixtures-readme-brief.ts"; import { mapFootprint, mapLatePlace, mapPanelBrief, mapPanelDiff, mapNotPlacedHint, mapPanelFieldHints, mapPanelFocus, mapPanelHead, mapPanelHistory, mapPanelLine2, mapPanelNoSession, mapPanelPeel, mapListFold, mapPanelSettings, mapPanelStory, mapPanelToggle, mapSheetClose, mapSheetExplained, mapSheetHere, mapSheetHolds, mapSheetKeptWidth, mapSheetResizeRedraw, mapSheetScrollShort, mapSheetStill, mapSheetUnratified, mapSheetWidth, mapToastBeside, mapTurnLight, mapPanelPatched, mapPanelAskStays, mapPanelBriefFoot, mapPrPanel, mapPrPanelPlaying, mapPrPanelRatify, mapPrPanelRewriting, mapPrPanelWriting, panelCaughtUp, panelExpanded, panelNeedsYou, panelFirstOpen, panelNoTrees, panelReplay, panelRunning, panelWhy, panelYourTurn } from "./fixtures-panel.ts"; -import { mapBackLaw, mapMicroWorld, mapMicroWorldBuilding, mapPreFlight, mapPreFlightOutside, mapPreFlightOutsideKept, mapPreFlightPalette, mapPreFlightPick, mapPreFlightStatus, mapRuns, mapRunsAnnounced, mapRunsBesideSheet, mapRunsPaused, mapTray, mapTrayAfterPush } from "./fixtures-runs.ts"; +import { mapBackLaw, mapMicroWorld, mapMicroWorldBuilding, mapPreFlight, mapPreFlightIssuesFailed, mapPreFlightOutside, mapPreFlightOutsideKept, mapPreFlightPalette, mapPreFlightPick, mapPreFlightStatus, mapRuns, mapRunsAnnounced, mapRunsBesideSheet, mapRunsPaused, mapTray, mapTrayAfterPush } from "./fixtures-runs.ts"; import { mapBriefAlsoGroups, mapBriefAnnounce, mapBriefBar, mapBriefBold, mapBriefBoldUnpaired, mapBriefChapterLast, mapBriefChapterMid, mapBriefChapters, mapBriefCopied, mapBriefCopyByHand, mapBriefExplainBack, mapBriefExplained, mapBriefFigure, mapBriefGuard, mapBriefHeights, mapBriefMapCheck, mapBriefNoFacts, mapBriefReview, mapBriefStillTrue, mapBriefNoStaleBase, mapBriefOrderRight, mapBriefOrderSlots, mapBriefOrderWrong, mapBriefOverturn, mapBriefPartialFacts, mapBriefPick, mapBriefRatify, mapBriefRatifyDetail, mapBriefRatifyEvidence, mapBriefShort, mapBriefSince, mapBriefStaleBase, mapBriefStart, mapBriefStepCode, mapBriefStory, mapBriefTall, mapBriefTaller, mapBriefTallScroll, mapBriefUnconfirmed, mapBriefWhy, mapBriefWhyDecision, mapBriefWriting, mapCatchUp, mapCatchUpBold, mapCatchUpCard, mapCatchUpStage, mapCatchUpSummarising, mapCatchUpWriting, mapDiffClosed, mapDiffLitGhost, mapDiffRatifyLit, mapDiffRemoval, mapDiffRemovalBrief, mapDiffSplit, mapDiffSplitBrief, listBriefMark, railBriefReady } from "./fixtures-brief.ts"; import { writersBriefsNeedClaude, writersFailed, writersKeyError, writersKeyNotSet, writersKeySet, writersList, writersOpenAI, writersPassed, writersSecretService } from "./fixtures-writers.ts"; @@ -74,6 +74,7 @@ export const fixtures = { // The contrast pass (#455) runs here too. mapPreFlight: (): Fixture => ({ ...mapPreFlight(), contrast: true }), mapPreFlightStatus, + mapPreFlightIssuesFailed, mapPreFlightOutside, mapPreFlightOutsideKept, mapPreFlightPalette, diff --git a/ui/map-pre-flight.ts b/ui/map-pre-flight.ts index 984e7f07c..d5ae54d43 100644 --- a/ui/map-pre-flight.ts +++ b/ui/map-pre-flight.ts @@ -15,12 +15,15 @@ import type { Expected, Fog, MapState, OpenIssue, PreFlight } from "./types.js"; /** A predicted part as the overlay lists it: its name, the texts of its laws on trust, its fog, and its staleness band. */ export type PreFlightRow = { id: string; name: string; trust: string[]; fog: string | null; stale: string | null }; +/** The open issues in the start phase: null while they load, the list, or why they could not be read (#1046). */ +export type Issues = OpenIssue[] | null | { failed: string }; + /** * What the overlay shows: the inputs (with the open issues, null while they load), the wait for the writer, the hand picker (with why the * prediction failed), or the pre-flight framed on the map. */ export type Phase = - | { kind: "start"; issues: OpenIssue[] | null } + | { kind: "start"; issues: Issues } | { kind: "predicting" } | { kind: "pick"; why: string | null } | { kind: "result"; pre: PreFlight }; @@ -78,15 +81,17 @@ const button = (words: string, title: string, click: () => void, kind = "") => { // What the overlay is doing, or why it failed, for `phase`: shown as a line and said in the overlay's status region (#456); none for the // rest. function statusWords(phase: Phase): string { + if (phase.kind === "start" && phase.issues !== null && "failed" in phase.issues) return `Couldn't read the open issues: ${phase.issues.failed}`; if (phase.kind === "start" && phase.issues === null) return "Reading the open issues…"; if (phase.kind === "predicting") return "Asking the writer which parts this will cross…"; if (phase.kind === "pick" && phase.why) return `No prediction: ${phase.why}. Pick the parts by hand.`; return ""; } -function startNodes(issues: OpenIssue[] | null, act: PreFlightActs): HTMLElement[] { +function startNodes(issues: Issues, act: PreFlightActs): HTMLElement[] { const list = text("div", "", "pre-flight-issues"); if (issues === null) list.append(text("p", statusWords({ kind: "start", issues }), "empty")); + else if ("failed" in issues) list.append(text("p", statusWords({ kind: "start", issues }), "empty")); else if (!issues.length) list.append(text("p", "No open issues.", "empty")); else list.append(...issues.map((issue) => button(`#${issue.number} ${issue.title}`, "Predict the parts this issue will cross", () => act.predict(issue.number, ""), "quiet pre-flight-issue"))); const field = document.createElement("textarea"); @@ -259,7 +264,7 @@ export function openPreFlight(fresh = false) { }) .catch((e) => { failure("pre_flight_issues")(e); - if (phase?.kind === "start" && shownProject() === project) show({ kind: "start", issues: [] }); + if (phase?.kind === "start" && shownProject() === project) show({ kind: "start", issues: { failed: messageOf(e).split("\n")[0] ?? "" } }); }); } diff --git a/ui/notice.ts b/ui/notice.ts index f293904c9..a9bed853e 100644 --- a/ui/notice.ts +++ b/ui/notice.ts @@ -24,8 +24,16 @@ function add(text: string) { return message; } -// A line a dismiss removes: an error, or a line for Daniel to act on, such as a late Allow's (`story.ts`). +/** What the transport says when plotkeeper cannot be reached (#1046). */ +export const UNREACHABLE = "plotkeeper is not reachable"; + +// Whether the top bar's connection line shows (retrying, or restarted with Reload), which already says plotkeeper is unreachable. +const connectionShows = () => Boolean(globalThis.document?.getElementById?.("connection")?.textContent); + +// A line a dismiss removes: an error, or a line for Daniel to act on, such as a late Allow's (`story.ts`). An unreachable error is not +// drawn while the connection line says it (#1046); it is still logged by the caller. export function showError(message: string) { + if (message.includes(UNREACHABLE) && connectionShows()) return; const added = add(message); if (added) errors.push(added); } diff --git a/ui/tests/map-pre-flight.test.mjs b/ui/tests/map-pre-flight.test.mjs index 484de27ee..ce2f6ecf6 100644 --- a/ui/tests/map-pre-flight.test.mjs +++ b/ui/tests/map-pre-flight.test.mjs @@ -173,3 +173,17 @@ test("the overlay opened again draws its status region empty before its words", await later(); assert.equal(region().text, "No prediction: the writer is not set. Pick the parts by hand."); }); + +test("issues that could not be read say so with the reason, and the text box and Pick parts by hand stay", () => { + const calls = []; + const nodes = /** @type {any[]} */ (preFlightNodes({ kind: "start", issues: { failed: "To get started with GitHub CLI, run: gh auth login" } }, doc, state, acts(calls))); + const said = texts(nodes); + assert.match(said, /Couldn't read the open issues: To get started with GitHub CLI, run: gh auth login/); + assert.doesNotMatch(said, /No open issues/); + const [field] = nodes.flatMap((node) => node.find("textarea")); + assert.ok(field, "the free text is a text field"); + field.value = "Make it faster"; + button(nodes, "Predict").listeners.click(); + button(nodes, "Pick parts by hand").listeners.click(); + assert.deepEqual(calls, [["predict", null, "Make it faster"], ["byHand"]]); +}); diff --git a/ui/tests/notice.test.mjs b/ui/tests/notice.test.mjs index 313d6efaf..8429842d5 100644 --- a/ui/tests/notice.test.mjs +++ b/ui/tests/notice.test.mjs @@ -3,9 +3,10 @@ import { test, beforeEach } from "node:test"; import assert from "node:assert/strict"; const line = { textContent: "", hidden: true }; +const connection = { textContent: "" }; let present = true; // The stand-in page: the notice line alone, and a log that keeps its lines. -globalThis.document = /** @type {any} */ ({ getElementById: () => (present ? line : null) }); +globalThis.document = /** @type {any} */ ({ getElementById: (id) => (id === "connection" ? connection : present ? line : null) }); const logged = []; globalThis.window = /** @type {any} */ ({ __TAURI__: { log: { warn: async (m) => logged.push(["warn", m]), error: async (m) => logged.push(["error", m]) } } }); const { showError, dismissNotice, setSettingsErrors, showNotice } = await import("../../dist/notice.js"); @@ -18,6 +19,7 @@ beforeEach(() => { dismissNotice(); line.textContent = ""; line.hidden = true; + connection.textContent = ""; }); test("a server error shows in the notice line", () => { @@ -105,3 +107,22 @@ test("an error with no notice element in the page is still sent to the log, and present = true; } }); + +test("an unreachable error draws nothing while the connection line shows, and draws without it; another error draws either way", () => { + const unreachable = "select: plotkeeper is not reachable"; + connection.textContent = "Lost connection to plotkeeper — retrying"; + failure("select", "error")(new Error("plotkeeper is not reachable")); + assert.deepEqual(lines(), []); + assert.equal(line.hidden, true); + assert.deepEqual(logged.at(-1), ["error", "select: plotkeeper is not reachable"]); + failure("rename", "error")(new Error("not a session id")); + assert.deepEqual(lines(), ["rename: not a session id"]); + dismissNotice(); + connection.textContent = ""; + failure("select", "error")(new Error("plotkeeper is not reachable")); + assert.deepEqual(lines(), [unreachable]); + connection.textContent = "plotkeeper restarted — this tab is out of date"; + dismissNotice(); + serverError(unreachable); + assert.deepEqual(lines(), []); +}); diff --git a/ui/tests/transport.test.mjs b/ui/tests/transport.test.mjs index 6e8ba42eb..43bb28313 100644 --- a/ui/tests/transport.test.mjs +++ b/ui/tests/transport.test.mjs @@ -4,8 +4,10 @@ import assert from "node:assert/strict"; const requests = []; let reply = { ok: true, body: null }; +let offline = false; // biome-ignore lint/suspicious/useAwait: a stand-in for an async API, so a throw in it rejects as the real one's would globalThis.fetch = /** @type {any} */ (async (url, init) => { + if (offline) throw new TypeError("Failed to fetch"); requests.push([url, init.method, JSON.parse(init.body)]); return { ok: reply.ok, status: reply.ok ? 200 : 500, json: async () => reply.body }; }); @@ -53,6 +55,19 @@ test("a refused command rejects with a CommandError carrying the server's reason e instanceof CommandError && e instanceof Error && e.message === "not a session id"); reply = { ok: false, body: null }; await assert.rejects(seam().core.invoke("rename", { id: "x", name: "y" }), { message: "rename: 500" }); + reply = { ok: false, body: "To get started with GitHub CLI, run: gh auth login" }; + await assert.rejects(seam().core.invoke("pre_flight_issues", { project: "p" }), { message: "To get started with GitHub CLI, run: gh auth login" }); +}); + +// The browser's network failure (plotkeeper is down) is plain words, not "Failed to fetch". +test("a fetch that rejects makes the command reject with a CommandError saying plotkeeper is not reachable", async () => { + const { CommandError } = await import("../../dist/transport.js"); + offline = true; + try { + await assert.rejects(seam().core.invoke("select", { id: "s1" }), (e) => e instanceof CommandError && e.message === "plotkeeper is not reachable"); + } finally { + offline = false; + } }); test("one event stream carries every event to the listeners of its name, until one is removed", async () => { diff --git a/ui/transport.ts b/ui/transport.ts index 5c5dae2e8..2a3369d4e 100644 --- a/ui/transport.ts +++ b/ui/transport.ts @@ -2,6 +2,7 @@ // `POST /api/` with its arguments as JSON, an event comes on the one `EventSource` at `/events`, and a log line is posted to // `/api/log`. It installs the seam `dom.ts` reads, so nothing else in the page knows the transport. +import { UNREACHABLE } from "./notice.js"; import type { Command } from "./types.js"; // The seam: commands, events and log lines. Its global keeps the name the Tauri shell gave it (#332 archived the shell), since the node @@ -38,7 +39,10 @@ export class CommandError extends Error { // The reply as JSON; a refusal rejects with a `CommandError` whose message is its reason, as a command's `Err` was. async function post(command: Command | "log" | "page_focus", args: unknown): Promise { - const response = await fetch(`/api/${command}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(args ?? {}) }); + // `fetch` rejects only when no reply came (plotkeeper is down); an HTTP refusal is a reply and keeps its reason. + const response = await fetch(`/api/${command}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(args ?? {}) }).catch(() => { + throw new CommandError(UNREACHABLE); + }); const body: unknown = await response.json().catch(() => null); if (!response.ok) throw new CommandError(typeof body === "string" ? body : `${command}: ${response.status}`); return body; From 970d091612ad502650cae25cf9ab2e5ecdfb3929 Mon Sep 17 00:00:00 2001 From: Daniel Rispler Date: Tue, 1 Dec 2026 21:35:16 +0200 Subject: [PATCH 02/11] Studio: a History row opens by mouse, and a hint closes when its trigger leaves the page (#1044) The left panel's outside press reads the event's path fixed at dispatch, so a History row's press, which draws the story over the row, no longer closes the panel. An open hint that no trigger on the page names closes; opening a hint queues a prune, which re-queues itself while a hint shows, so a stranded hint closes within a tick. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CVqACafozqqdDZevv65PCa --- docs/studio/behaviour/sessions.md | 4 +-- scripts/snap/fixtures-panel.ts | 33 +++++++++++++++-- ui/dom.ts | 31 +++++++++++----- ui/panel.ts | 6 ++-- ui/tests/hint-redraw.test.mjs | 59 +++++++++++++++++++++++++++++-- 5 files changed, 116 insertions(+), 17 deletions(-) diff --git a/docs/studio/behaviour/sessions.md b/docs/studio/behaviour/sessions.md index 018a1786a..57e8d816a 100644 --- a/docs/studio/behaviour/sessions.md +++ b/docs/studio/behaviour/sessions.md @@ -2,13 +2,13 @@ ## The session list -On the right, the session list: every session (Claude Code, agy and Codex), one line each with the agent's logo, its name and its state, grouped by its project, and, inside a repository, by state with "needs you" first. The list holds what Home showed (#382): a row that needs you adds a second line, the open question's first line, else who asks (a plan, a permission, or a subagent: its name and "asks"); a running row its Intention, or its current step until the Intention is known; an unseen row (your turn or idle, not landed) its last turn's Headline, which updates when the turn's summary is stored. No other row has a second line. A second line is one line, muted, at 11.5 px, cut with an ellipsis. **Cut text reads in full in place** (spec #582): a row's name, token and second line, like every text the layout cuts, keep their whole text in the page (find-in-page, copy and screen readers get all of it), and on hover, or focus on the control that holds them, the cut line scrolls its hidden end into view inside its own box (`cut()` in `ui/dom.ts`, the `.cut` class). A line that fits stays still, and with reduced motion asked for nothing moves. A text the layout shortens (a path) or that can be very long (a prompt) has a hint holding it whole instead. A prompt-named session's name has a hint of its own, its full name and its identity; the row's hint reads its name and state, as every row's does. The selected row adds how long it has waited ("Bash cargo test · 3m"); a session whose last step is a wake-up reads "worker … returned" until its next step. The agent's logo is 12 px in one muted tone; colour in the list is the "Needs you" pill only. **The brief mark** (#630): a live session whose PR has a waiting PR brief (the rail's "PR brief ready" row's rule, `briefs_waiting`; [The rail](rail.md)) carries one quiet mark on its row, the project dot's mist with no colour, in its own 24 px button beside the row's delete, as a button holds no button. Its hint reads "PR #N · brief waiting", and pressing it opens the Map view on that PR's panel, as the rail's row does, without selecting the row (`briefMarkFor` in `ui/rail-brief.ts`). It goes once the brief is read to its end at the PR's head and comes back after a push; an ended session is in History, not the list, and has none, so the Map view's tray stays its way in; the strip has none. Hovering a session's row makes it the spotlit session on the map: its footprint, its chip on its now's parts, and the other session badges dimmed ([The Map view](map.md), "Session badges"). A session row, like every button and link of the session list and the top bar, explains itself in a **hint** (spec #582), a styled hover that replaces the native `title`: it shows when the pointer rests on the control for half a second, or when Tab reaches it, at once while another hint is open, anywhere on the page; it sits above the control and flips below when the window's top is in the way, except in the session list and its strip, where it opens to the control's left, level with it, so it covers no row above or below (spec #658; `hint(trigger, text, "start")`, flipping to the right when the window's edge is in the way); it stays open while the pointer is on it, and closes on Esc. A row's hint reads its name and state, and adds that it touched no part in the last 7 days when it did not; it is built when the row is drawn, and the sidebar is drawn again when the map places the sessions. A hint that adds to the control's name is its accessible description; one that only repeats it adds nothing. `hint(trigger, text)` in `ui/dom.ts` makes one. A fold-out header (``), an input or a select, which the browser's own hint wiring cannot reach, shows its hint the same way, by the helper's own pointer and focus listeners (the same delays, the pointer may rest on the hint, Esc and leaving close it, focus never moves into it); a click on a fold-out header still folds it. A button that cannot be used right now (Ask while it waits for its answer, the question card's Send before every question has a choice, a micro-world's "Building…") is `aria-disabled="true"`, not `disabled`: it stays focusable, is announced as unavailable, ignores a click and Enter, and its hint says why. **Marks and dots** (a row's check mark and id mark, a project's mist dot, an agent's logo, a part's law marks and broken-law mark, the sheet's law marks, a stale part's band, a link's law mark, the story's failed-check mark and a clock) show their hint on the pointer alone (`mark()` in `ui/dom.ts`, and `hint()` on a span or an SVG shape): each is `role="img"` with an `aria-label` carrying its meaning, and none takes the Tab order, so what a mark says also stays reachable without a pointer, in the part sheet's law list and the row's own words. **No native `title` is left on the page** outside the terminal, an SVG `` included; the micro-world's frame is named by its `aria-label`. The snap pages keep it so: the hover rule (`scripts/snap/hover.mjs`, #220, rewritten by spec #582) runs after every snap page and fails on a control (`button`, `summary`, `a[href]`, `[role=button]`, the toasts, the spine) with no hint of its own (an ancestor's hover no longer counts), on any `title` attribute or SVG `<title>`, on a hint that only repeats its control's label, and on a hinted element the pointer cannot reach. +On the right, the session list: every session (Claude Code, agy and Codex), one line each with the agent's logo, its name and its state, grouped by its project, and, inside a repository, by state with "needs you" first. The list holds what Home showed (#382): a row that needs you adds a second line, the open question's first line, else who asks (a plan, a permission, or a subagent: its name and "asks"); a running row its Intention, or its current step until the Intention is known; an unseen row (your turn or idle, not landed) its last turn's Headline, which updates when the turn's summary is stored. No other row has a second line. A second line is one line, muted, at 11.5 px, cut with an ellipsis. **Cut text reads in full in place** (spec #582): a row's name, token and second line, like every text the layout cuts, keep their whole text in the page (find-in-page, copy and screen readers get all of it), and on hover, or focus on the control that holds them, the cut line scrolls its hidden end into view inside its own box (`cut()` in `ui/dom.ts`, the `.cut` class). A line that fits stays still, and with reduced motion asked for nothing moves. A text the layout shortens (a path) or that can be very long (a prompt) has a hint holding it whole instead. A prompt-named session's name has a hint of its own, its full name and its identity; the row's hint reads its name and state, as every row's does. The selected row adds how long it has waited ("Bash cargo test · 3m"); a session whose last step is a wake-up reads "worker … returned" until its next step. The agent's logo is 12 px in one muted tone; colour in the list is the "Needs you" pill only. **The brief mark** (#630): a live session whose PR has a waiting PR brief (the rail's "PR brief ready" row's rule, `briefs_waiting`; [The rail](rail.md)) carries one quiet mark on its row, the project dot's mist with no colour, in its own 24 px button beside the row's delete, as a button holds no button. Its hint reads "PR #N · brief waiting", and pressing it opens the Map view on that PR's panel, as the rail's row does, without selecting the row (`briefMarkFor` in `ui/rail-brief.ts`). It goes once the brief is read to its end at the PR's head and comes back after a push; an ended session is in History, not the list, and has none, so the Map view's tray stays its way in; the strip has none. Hovering a session's row makes it the spotlit session on the map: its footprint, its chip on its now's parts, and the other session badges dimmed ([The Map view](map.md), "Session badges"). A session row, like every button and link of the session list and the top bar, explains itself in a **hint** (spec #582), a styled hover that replaces the native `title`: it shows when the pointer rests on the control for half a second, or when Tab reaches it, at once while another hint is open, anywhere on the page; it sits above the control and flips below when the window's top is in the way, except in the session list and its strip, where it opens to the control's left, level with it, so it covers no row above or below (spec #658; `hint(trigger, text, "start")`, flipping to the right when the window's edge is in the way); it stays open while the pointer is on it, and closes on Esc. **A hint closes when no trigger on the page names it** (#1044): one whose control left the page under it, as a History row's does when its press opens the session's story, closes within a third of a second, never left in the window's corner; a control a redraw kept keeps its open hint, and a control a view sets aside and puts back keeps its hint, closed while it was away. A row's hint reads its name and state, and adds that it touched no part in the last 7 days when it did not; it is built when the row is drawn, and the sidebar is drawn again when the map places the sessions. A hint that adds to the control's name is its accessible description; one that only repeats it adds nothing. `hint(trigger, text)` in `ui/dom.ts` makes one. A fold-out header (`<summary>`), an input or a select, which the browser's own hint wiring cannot reach, shows its hint the same way, by the helper's own pointer and focus listeners (the same delays, the pointer may rest on the hint, Esc and leaving close it, focus never moves into it); a click on a fold-out header still folds it. A button that cannot be used right now (Ask while it waits for its answer, the question card's Send before every question has a choice, a micro-world's "Building…") is `aria-disabled="true"`, not `disabled`: it stays focusable, is announced as unavailable, ignores a click and Enter, and its hint says why. **Marks and dots** (a row's check mark and id mark, a project's mist dot, an agent's logo, a part's law marks and broken-law mark, the sheet's law marks, a stale part's band, a link's law mark, the story's failed-check mark and a clock) show their hint on the pointer alone (`mark()` in `ui/dom.ts`, and `hint()` on a span or an SVG shape): each is `role="img"` with an `aria-label` carrying its meaning, and none takes the Tab order, so what a mark says also stays reachable without a pointer, in the part sheet's law list and the row's own words. **No native `title` is left on the page** outside the terminal, an SVG `<title>` included; the micro-world's frame is named by its `aria-label`. The snap pages keep it so: the hover rule (`scripts/snap/hover.mjs`, #220, rewritten by spec #582) runs after every snap page and fails on a control (`button`, `summary`, `a[href]`, `[role=button]`, the toasts, the spine) with no hint of its own (an ancestor's hover no longer counts), on any `title` attribute or SVG `<title>`, on a hint that only repeats its control's label, and on a hinted element the pointer cannot reach. **The list holds its order under the pointer** (spec #659). While the pointer is in the list (the full list, the list open over the map, its strip, or the project "⋯" menu), the project groups and the rows in each keep the places of the last draw before it came in, and the strip's buttons theirs: a session that goes from running to needs you keeps its row and its state group, and only its glyph, second line and counts change, as do a header's rollup and dot. A session that starts meanwhile joins the end of its project's group (a new project the end of the groups, a session new to the strip its end), and one no longer listed leaves at once, so a row pressed is always a listed session. A row held in the folded Idle group stays in it, and a strip button whose session went idle stays, until the pointer leaves. The subagent rows under each session hold the same way (spec #820, item F): a subagent the list did not know when the pointer came in waits until it leaves, except one that needs you or failed unopened, which shows at once under its spawn, as a collapsed row shows those, and may move the rows below it; one that fades leaves at once, as a gone session does. When it leaves, the list and the strip are drawn once in the real order. The server's sort and sends are unchanged: the hold is the page's (`holdGroups` in `ui/projects.ts`, `holdList` in `ui/list.ts`, `heldAgents` in `ui/list-model.ts`). ⌘] and ⌘[, ⌘J and the jump to an unseen session step through the order on screen, held or not, as ↑ and ↓ do; a session Clear landed hid is not in it. ↑ and ↓ also step through the subagent rows as they show, and ⌘] and ⌘[ through sessions only. The strip's buttons follow the sidebar's order, project by project and by state, held or not, never the server's, so ⌘] and ⌘[ at the strip's width step through them as they show. A hint of something in the list (a row's, a project dot's, which opens over the rows) is drawn outside `.list`, and the pointer on it is still in the list: the hold ends when it leaves the hint for somewhere else, also once the hint's row is gone (its session ended under it). The keyboard in the list holds nothing. The snap `listHeld` checks it with synthetic pointer events. "Clear landed", quiet under "History · N", shows only while a landed session is in the list (#244, #382). It hides every landed row at once, ended ones included, from the list and the strip, and shows a toast, "Cleared N landed", with Undo for 8 seconds. Undo brings the rows back and nothing was deleted. When the 8 seconds pass, or the app quits inside them, each hidden session goes through Delete: its row drops, and its cards stay. The rows stay hidden until the sessions leave the list, so they never flash back before the delete lands, and a Clear in that gap does not commit them twice; a delete that fails brings its row back. A reload of the page forgets a pending clear. A session that stops being landed inside the window is left alone. The server hears each session until its delete is written, so a quit while the deletes are in flight still commits them. A second Clear inside the window adds its rows and restarts the 8 seconds. -Idle sessions collapse at the bottom; ended ones are in History, from the "History · N" link at the list's end or the palette's "Show history". The rest of the page is the map of a project (see [The Map view](map.md#the-map-view), #386): the session you click opens its story (see [The story rail](rail.md)) in the left panel over its project's map, or, while a Claude Code plan waits on you there, the plan view in its place (#899; [The story rail](rail.md), "The plan view"), and History, a turn's whole diff, a subagent's log and Settings open in the same panel. Only your click changes the session shown. +Idle sessions collapse at the bottom; ended ones are in History, from the "History · N" link at the list's end or the palette's "Show history". A History row opens its session's story when pressed with the mouse, as Enter on it does (#1044): a press inside the left panel never closes it, even when the press draws the story over the row. The rest of the page is the map of a project (see [The Map view](map.md#the-map-view), #386): the session you click opens its story (see [The story rail](rail.md)) in the left panel over its project's map, or, while a Claude Code plan waits on you there, the plan view in its place (#899; [The story rail](rail.md), "The plan view"), and History, a turn's whole diff, a subagent's log and Settings open in the same panel. Only your click changes the session shown. The palette (⌘⇧P; Ctrl+Shift+Space on Linux) lists every action with its keys, filtered by what you type; ↑ and ↓ move the active row, which a screen reader announces, as the filter is a combobox over a listbox of options, and Enter or a click runs one. It is a native popover with a visible × (named "Close"): Esc, a click outside it, its × or ⌘⇧P again close it, and every close puts the focus back where it was before it opened (#458). diff --git a/scripts/snap/fixtures-panel.ts b/scripts/snap/fixtures-panel.ts index 6c5105d30..5df81a410 100644 --- a/scripts/snap/fixtures-panel.ts +++ b/scripts/snap/fixtures-panel.ts @@ -555,7 +555,11 @@ export const mapPanelDiff = (): Fixture => if (panelOpen()) log("snap:fail Esc did not close the diff"); if (row("s1").getAttribute("aria-pressed") === "true") log("snap:fail closing the diff left its session selected"); log("panel ok");`); -/** History in the left panel, from the list's link. */ +// #312 is prompt-named, so its History row's name has its own hint (the listener path, #586). +const historySessions = [...busySessions(), session("e1", "", "ended", { name: null, prompt_name: "Map view drawer, #312", last_event_at: Date.now() - 2 * 86400e3, turns: [{ started_at: Date.now() - 600e3, ended_at: Date.now() - 300e3, prompt: "", id: null, message: null, checks: [], listed: [], files: { files: [{ root: "/w/plotkeeper", path: "hook/src/main.rs", from: null, added: 3, removed: 1, agent: null }], merged: 0 } }] }), session("e2", "Wire check covers MapState, #333", "ended", { last_event_at: Date.now() - 3 * 86400e3 })]; +/** + * History in the left panel, from the list's link; with the real pointer, a press on an ended session's row opens its story (#1044). + */ export const mapPanelHistory = (): Fixture => mapPanel(` document.querySelector("#history-link .history-link").click(); @@ -577,8 +581,33 @@ export const mapPanelHistory = (): Fixture => if (firm() !== "") log("snap:fail the removed History row's spotlight stuck: " + firm()); document.querySelector("#history-link .history-link").click(); await wait(300); + // The real pointer (#1044): hovering an ended session's name opens its hint, and pressing the row opens its story in the panel, + // selected, with no deselect after; the hint, its trigger gone with History, closes within a prune tick, and no hint is stranded. + const selects = []; + const fetched = window.fetch; + window.fetch = (url, init) => (String(url).endsWith("/api/select") && selects.push(JSON.parse(init.body).id ?? null), fetched(url, init)); + const name = panel.querySelector('.history .row[data-key="e1 "] .name'); + await __snapMove(name); + await wait(700); + const openHints = () => [...document.querySelectorAll("#hints .hint:popover-open")]; + if (!openHints().length) log("snap:fail hovering the History row's name opened no hint"); + await __snapClick(name); + await wait(400); + window.fetch = fetched; + if (!panelOpen() || panel.dataset.kind !== "story") log("snap:fail pressing the History row did not open its story: " + (panelOpen() ? panel.dataset.kind : "the panel closed")); + if (selects[0] !== "e1" || selects.includes(null)) log("snap:fail pressing the History row sent select " + JSON.stringify(selects)); + if (document.getElementById("session-name").textContent !== "Map view drawer, #312") log("snap:fail the story shows " + JSON.stringify(document.getElementById("session-name").textContent)); + for (const hint of openHints()) { + const trigger = document.querySelector('[interestfor="' + hint.id + '"], [data-hint="' + hint.id + '"]'); + const [h, t] = [hint.getBoundingClientRect(), trigger?.getBoundingClientRect()]; + const beside = t && h.left <= t.right + 24 && h.right >= t.left - 24 && h.top <= t.bottom + 24 && h.bottom >= t.top - 24; + log("snap:fail after the press the hint " + hint.id + " is open" + (beside ? "" : ", away from its trigger at " + Math.round(h.left) + "," + Math.round(h.top))); + } log("panel ok");`, { - sessions: [...busySessions(), session("e1", "Map view drawer, #312", "ended", { last_event_at: Date.now() - 2 * 86400e3, turns: [{ started_at: Date.now() - 600e3, ended_at: Date.now() - 300e3, prompt: "", id: null, message: null, checks: [], listed: [], files: { files: [{ root: "/w/plotkeeper", path: "hook/src/main.rs", from: null, added: 3, removed: 1, agent: null }], merged: 0 } }] }), session("e2", "Wire check covers MapState, #333", "ended", { last_event_at: Date.now() - 3 * 86400e3 })], + sessions: historySessions, + select: { __by: "id", values: Object.fromEntries(historySessions.map((s) => [s.id, { session: s, agent: null }])) }, + realPointer: true, + budget: 8000, }); /** Settings in the left panel from the top bar's gear, holding the writer section (#387); the gear again closes it. */ export const mapPanelSettings = (): Fixture => diff --git a/ui/dom.ts b/ui/dom.ts index 87e0d034b..b416bff4a 100644 --- a/ui/dom.ts +++ b/ui/dom.ts @@ -274,23 +274,35 @@ const named = (trigger: Element) => trigger.getAttribute("interestfor") ?? trigg // A hint stays while a trigger on the page names it, or while its trigger, kept off the page, still does. A trigger drawn again with // other words, as an unkeyed one is, names a new hint, so the old one goes, once it is closed: an open one waits for the next prune. +// A hint shows only while a trigger on the page names it (#1044): one whose trigger left the page, which gets no pointerleave, closes. +// Its recorded owner is not read for that, as `hint()` records each new trigger before `patch` may keep the older one. The listener +// path's open hint also stays with the trigger that opened it while that trigger is on the page, though a redraw gave it other words. +// While a hint shows, the prune runs again each tick, so one stranded by a page change that calls no `hint()` closes within a tick. function pruneHints() { pruneQueued = false; if (!document.querySelectorAll) return; - const wired = new Set([...document.querySelectorAll("[interestfor], [data-hint]")].map(named)); - let waiting = false; + const triggers = [...document.querySelectorAll("[interestfor], [data-hint]")]; + const wired = new Set(triggers.map(named)); + let showing = false; for (const [id, node] of hints) { - const owner = owners.get(id)?.deref(); - if (wired.has(id) || (owner && named(owner) === id)) continue; - if (node.matches(":popover-open")) { - waiting = true; + const open = node.matches(":popover-open"); + const opener = open && node === openHint && openTrigger !== null && triggers.includes(openTrigger); + if (wired.has(id) || opener) { + showing ||= open; + continue; + } + if (open) { + node.hidePopover(); + showing = true; continue; } + const owner = owners.get(id)?.deref(); + if (owner && named(owner) === id) continue; node.remove(); owners.delete(id); hints.delete(id); } - if (waiting) queuePrune(); + if (showing) queuePrune(); } function queuePrune() { if (pruneQueued) return; @@ -343,6 +355,7 @@ function showFor(trigger: Element, interest: Interest) { node.showPopover({ source: isSvg(trigger) ? anchorOver(trigger) : (trigger as HTMLElement) }); openTrigger = trigger; openHint = node; + queuePrune(); } function hideFor(trigger: Element, interest: Interest) { if (interest.pointer || interest.focus || openTrigger !== trigger) return; @@ -378,8 +391,10 @@ function listenOnHint(node: HTMLElement) { interest.pointer = false; loseInterest(trigger, interest); }); + // Opening, by either path, starts the prunes that close a hint whose trigger leaves the page. node.addEventListener("toggle", (event) => { - if ((event as ToggleEvent).newState === "closed" && openHint === node) openTrigger = openHint = null; + if ((event as ToggleEvent).newState === "open") queuePrune(); + else if (openHint === node) openTrigger = openHint = null; }); } diff --git a/ui/panel.ts b/ui/panel.ts index 88b37465d..c86e74ea0 100644 --- a/ui/panel.ts +++ b/ui/panel.ts @@ -143,9 +143,11 @@ export function startPanel(given: PanelDeps) { deps = given; element("panel-close").addEventListener("click", closePanel); // A press outside the panel closes it (light dismiss); the press that lands on a session's row or a part still does its own work. + // Where it landed is the event's path, fixed at dispatch: a History row's press has already drawn the story over the row by now, so + // the row's own ancestors no longer reach the panel (#1044). document.addEventListener("pointerdown", (event) => { - const target = event.target instanceof Element ? event.target : null; - if (pressClosesPanel(panelShown(), (selector) => target?.closest(selector) != null)) closePanel(); + const path = event.composedPath().filter((node): node is Element => node instanceof Element); + if (pressClosesPanel(panelShown(), (selector) => path.some((node) => node.matches(selector)))) closePanel(); }); // A redraw of the map draws its badges again: the open session stays spotlit. onDraw(() => openAgents(panelSession(panelShown()))); diff --git a/ui/tests/hint-redraw.test.mjs b/ui/tests/hint-redraw.test.mjs index 5ba098cb2..3683e4c0f 100644 --- a/ui/tests/hint-redraw.test.mjs +++ b/ui/tests/hint-redraw.test.mjs @@ -1,6 +1,6 @@ // The listener path's hints across redraws (spec #582's review): a view drawn again through `patch` hands `hint()` a new trigger each // time. The trigger the page keeps opens the hint its current `data-hint` names, with the current words; the hint gains no listeners per -// draw; a hint no trigger on the page names any more, its trigger dropped, leaves `#hints`; and a trigger whose hint was taken away opens nothing. Run: `npm test`. +// draw; a hint no trigger on the page names any more, its trigger dropped, leaves `#hints`; a trigger whose hint was taken away opens nothing; and an open hint whose trigger left the page closes (#1044). Run: `npm test`. import { test, mock, beforeEach, afterEach } from "node:test"; import assert from "node:assert/strict"; import v8 from "node:v8"; @@ -28,10 +28,11 @@ const inHints = (id) => hints.childNodes.some((node) => node.getAttribute?.("id" const open = () => hints.childNodes.filter((node) => node.popoverOpen); beforeEach(() => mock.timers.enable({ apis: ["setTimeout"] })); -// Every queued prune runs before the clock goes, so the next test's `hint()` queues its own. +// Every queued prune runs before the clock goes, so the next test's `hint()` queues its own: the hints close first, as a prune queues +// the next one while a hint shows. afterEach(() => { - mock.timers.tick(1000); for (const node of open()) node.hidePopover(); + mock.timers.tick(1000); mock.timers.reset(); }); @@ -137,3 +138,55 @@ test("the step's detail drawn without a shortened path opens no hint left from t mock.timers.tick(501); assert.deepEqual(open(), []); }); + +// A hint whose trigger left the page closes (#1044): no trigger on the page names it any more, and no further `hint()` call or redraw +// is needed, as when closing the left panel clears History under an open row hint. +test("an open listener-path hint whose trigger is removed closes within one prune tick", () => { + const line = row(); + patch(line, [hint(keyed(document.createElement("span"), "name-removed"), "Map view drawer · plotkeeper")]); + const [trigger] = line.childNodes; + trigger.listeners.pointerenter({}); + mock.timers.tick(501); + mock.timers.tick(1000); + assert.equal(open().length, 1, "the hint opened"); + line.replaceChildren(); + mock.timers.tick(300); + assert.deepEqual(open().map((node) => node.textContent), []); +}); + +// A redraw hands `hint()` a new trigger, which `patch` drops for the one on the page: the open hint stays, by either path. +for (const tag of ["span", "button"]) { + test(`an open hint whose ${tag} patch() kept across a redraw stays open`, () => { + const line = row(); + const draw = () => [hint(keyed(document.createElement(tag), `kept-${tag}`), "Kept words")]; + patch(line, draw()); + const [trigger] = line.childNodes; + if (tag === "span") { + trigger.listeners.pointerenter({}); + mock.timers.tick(501); + } else hintOf(trigger).showPopover(); + patch(line, draw()); + assert.equal(line.childNodes[0], trigger, "patch keeps the trigger"); + mock.timers.tick(900); + assert.deepEqual(open().map((node) => node.textContent), ["Kept words"]); + }); +} + +test("a trigger set aside and put back keeps its hint node, closed while it was away", () => { + const line = row(); + patch(line, [hint(keyed(document.createElement("span"), "set-aside"), "Set aside words")]); + const [trigger] = line.childNodes; + const shown = hintOf(trigger); + trigger.listeners.pointerenter({}); + mock.timers.tick(501); + line.replaceChildren(); + mock.timers.tick(600); + assert.ok(inHints(shown.getAttribute("id")), "the hint stays in #hints while its trigger is kept off the page"); + assert.equal(shown.popoverOpen, false, "the hint closed while its trigger was off the page"); + patch(line, [trigger]); + assert.equal(hintOf(trigger), shown); + trigger.listeners.pointerleave({}); + trigger.listeners.pointerenter({}); + mock.timers.tick(501); + assert.ok(shown.popoverOpen, "the kept hint opens again once its trigger is back"); +}); From a4738ff91c8c8834f28c432a6cd0c5ea7bbe93c7 Mon Sep 17 00:00:00 2001 From: Daniel Rispler <danielrispler@gmail.com> Date: Tue, 1 Dec 2026 21:37:51 +0200 Subject: [PATCH 03/11] Studio: a badge list whose badge goes away gives the focus to its part's button (#1045) A badge list open from the keyboard closes when a redraw drops its badge. The focus then fell to the page's body; it now lands on the plate's open button, the part's or the closed zone's sheet button, as paint() already does for a focused badge that a spotlit chip replaced. mapBadgeList gains both cases with real keys, a closed Terminals zone for the zone's, and a 9 s budget for the longer script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CVqACafozqqdDZevv65PCa --- scripts/snap/fixtures-map.ts | 52 +++++++++++++++++++++++++++++++++--- ui/map-agents.ts | 7 +++-- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/scripts/snap/fixtures-map.ts b/scripts/snap/fixtures-map.ts index fc797a4c8..acebe56a3 100644 --- a/scripts/snap/fixtures-map.ts +++ b/scripts/snap/fixtures-map.ts @@ -1,6 +1,6 @@ // The Map view: its states, fog and marks, the camera, broken laws, the scrubbed history, the base and its projects. -import type { Ci, MapDraft, MapDraftState, MapReviewItem, MapScan, MapState } from "../../ui/types.ts"; +import type { Ci, MapDraft, MapDraftState, MapReviewItem, MapScan, MapState, Session } from "../../ui/types.ts"; import { base, type Fixture } from "./base.ts"; import { planWaiting } from "./rail-fixtures.ts"; import { at, briefOf, busyPlace, busySessions, confirmFirst, mapBrief, mapFile, mapOpened, mapScanOf, mapState, openBrief, pairFile, panelChecks, session, step, storySteps, subagent, withSaved } from "./fixtures-shared.ts"; @@ -624,6 +624,9 @@ const badgeSessions = () => { }); return [...sessions, session("s8", "#410 · Reading review", "your_turn", { unseen: true, turns: touched("Reviewed how the core reads a turn", "core/lib.rs", "understanding/u.rs") })]; }; +// `sessions` with session `id` started on a new turn that has changed no file yet, so its badges go. +const emptyTurn = (sessions: Session[], id: string) => + sessions.map((s) => (s.id === id ? { ...s, turns: [...s.turns, { started_at: Date.now(), ended_at: null, prompt: "", id: null, message: null, checks: [], listed: [], files: null }] } : s)); const badgeFixture = (check: string, done: string): Fixture => { const sessions = badgeSessions(); const f = mapOpened(` @@ -644,8 +647,10 @@ const badgeFixture = (check: string, done: string): Fixture => { // A badge with the Needs-you accent and its open list (#562): real presses, as a mouse and keys give them. The badge's press opens the list // beside it and never the sheet; a row's press opens its story; Esc, a click outside and a zoom close it; the shot ends with Core's list open. -export const mapBadgeList = (): Fixture => - badgeFixture(` +export const mapBadgeList = (): Fixture => { + const sessions = badgeSessions(); + const daemon = session("s9", "#420 · Terminal resize", "running", { turns: [{ started_at: Date.now() - 600e3, ended_at: null, prompt: "", id: null, message: null, checks: [], listed: [], files: { files: [{ root: "/w/plotkeeper", path: "daemon/pty.rs", from: null, added: 3, removed: 1, agent: null }], merged: 0 } }] }); + const f = badgeFixture(` const sent = []; const fetched = window.fetch; window.fetch = (url, init) => { @@ -715,6 +720,37 @@ export const mapBadgeList = (): Fixture => if (badge("core").getAttribute("aria-expanded") !== "false" || badge("shell").getAttribute("aria-expanded") !== "true") log("snap:fail a list opened over another left expanded: core " + badge("core").getAttribute("aria-expanded") + ", shell " + badge("shell").getAttribute("aria-expanded")); await __snapKey("Escape"); await wait(60); + // A list open from the keyboard whose badge goes away (its session starts a turn that has changed no file yet) closes, and the + // keyboard lands on its part's button, never on the page's body (#1045). + const focusName = () => document.activeElement === document.body ? "the body" : document.activeElement?.className + " " + document.activeElement?.closest(".plate")?.dataset.id; + badge("shell").focus(); + await __snapKey("Enter"); + await wait(60); + if (!list.contains(document.activeElement)) log("snap:fail Enter on Shell's badge left the keyboard on " + focusName()); + __snapEmit("sessions", ${JSON.stringify(emptyTurn(sessions, "s1"))}); + await wait(250); + if (badge("shell") || listOpen()) log("snap:fail Shell's badge or its list stayed once its session's turn changed no file"); + if (document.activeElement !== document.querySelector("#map .plate[data-id=shell] .plate-open")) log("snap:fail with Shell's badge gone the keyboard is on " + focusName()); + __snapEmit("sessions", ${JSON.stringify(sessions)}); + await wait(250); + if (badge("shell")?.textContent !== "1") log("snap:fail Shell's badge did not come back: " + badge("shell")?.textContent); + // The same for a closed zone's badge: a session on the daemon gives Terminals a badge, and once it goes the keyboard is on the zone's + // sheet button. + const terminals = () => document.querySelector("#map .plate.zone[data-id=terminals]"); + __snapEmit("sessions", ${JSON.stringify([...sessions, daemon])}); + await wait(250); + const zoneBadge = terminals()?.querySelector(".session-badge"); + if (zoneBadge?.textContent !== "1") log("snap:fail Terminals' badge: " + zoneBadge?.outerHTML); + zoneBadge?.focus(); + await __snapKey("Enter"); + await wait(60); + if (!list.contains(document.activeElement)) log("snap:fail Enter on Terminals' badge left the keyboard on " + focusName()); + __snapEmit("sessions", ${JSON.stringify(emptyTurn([...sessions, daemon], "s9"))}); + await wait(250); + if (terminals()?.querySelector(".session-badge") || listOpen()) log("snap:fail Terminals' badge or its list stayed once its session's turn changed no file"); + if (document.activeElement !== terminals()?.querySelector(".plate-open")) log("snap:fail with Terminals' badge gone the keyboard is on " + focusName()); + __snapEmit("sessions", ${JSON.stringify(sessions)}); + await wait(250); // A row's press opens its story and closes the list, never the sheet. await __snapClick(badge("core")); await wait(60); @@ -727,7 +763,15 @@ export const mapBadgeList = (): Fixture => await wait(150); await __snapClick(badge("core")); await wait(60); - if (!listOpen()) log("snap:fail the list did not open again");`, "badge list ok"); + if (!listOpen()) log("snap:fail the list did not open again"); + // The keyboard ends on the list's first row, whose hint would open over Core once the script is done: the shot is of the list alone. + document.activeElement?.blur();`, "badge list ok"); + // Daemon and Workbench, where no session works until the daemon's comes, sit in Terminals, closed. + const file = JSON.parse(mapFile); + file.zones = [{ id: "terminals", name: "Terminals", caption: "Terminals, git and worktrees", purpose: "Owns the terminals and the repositories they work in." }]; + for (const part of file.parts as { id: string; zone?: string }[]) if (part.id === "daemon" || part.id === "workbench") part.zone = "terminals"; + return { ...f, map_state: mapState({ source: JSON.stringify(file) }), map_place: { ...badgePlace(), "daemon/pty.rs": ["daemon"] }, budget: 9000 }; +}; // The spotlight's view (#562): hovering #311's row spotlights it. Its chip replaces the badge on Core, Window and Shell, with its line on Core alone (a tie of // one file each goes to reading order); Understanding's badge dims and Hook's Needs-you one stays full. The shot keeps the hover. diff --git a/ui/map-agents.ts b/ui/map-agents.ts index 6f2390360..8c5c50e7d 100644 --- a/ui/map-agents.ts +++ b/ui/map-agents.ts @@ -157,7 +157,9 @@ function closeBadgeList() { if (badgeList().matches(":popover-open")) badgeList().hidePopover(); } -// The list closed, by a press outside, Esc or any of the cases above: its badge says so, and a focus inside it goes back to the badge. +// The list closed, by a press outside, Esc or any of the cases above: its badge says so, and a focus inside it goes back to the badge. A +// badge gone with the redraw that closed the list (its sessions' turns left the part) gives that focus to the plate's open button instead, +// as `paint` does for a focused badge that a chip replaced: the part's, or the closed zone's sheet button. function listClosed() { endHoverIn(badgeList()); const part = listPart; @@ -166,7 +168,8 @@ function listClosed() { if (part === null) return; const badge = badgeOn(part); badge?.setAttribute("aria-expanded", "false"); - if (badge && (document.activeElement === document.body || badgeList().contains(document.activeElement))) badge.focus({ preventScroll: true }); + if (document.activeElement !== document.body && !badgeList().contains(document.activeElement)) return; + (badge ?? currentMap()?.slots.canvas.querySelector<HTMLElement>(`.plate[data-id="${CSS.escape(part)}"] .plate-open`))?.focus({ preventScroll: true }); } function openList(part: string, badge: HTMLElement, rows: Badge["rows"], byKeyboard: boolean) { From c320080d3b49f6f8dadb1e04167cc0c33bce5eb1 Mon Sep 17 00:00:00 2001 From: Daniel Rispler <danielrispler@gmail.com> Date: Tue, 1 Dec 2026 21:39:17 +0200 Subject: [PATCH 04/11] Studio: after a project switch, a closing badge list leaves the focus alone (#1045) The badge list's close moves the focus only while the list's project is still the shown one, so a switch never lands it on the new map's plate of the same id. mapBadgeSwitch covers it. paint() and listClosed() share the plate's open-button lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CVqACafozqqdDZevv65PCa --- scripts/snap/fixtures-map.ts | 15 +++++++++++++++ scripts/snap/fixtures.ts | 3 ++- ui/map-agents.ts | 12 +++++++----- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/scripts/snap/fixtures-map.ts b/scripts/snap/fixtures-map.ts index acebe56a3..6609cacd3 100644 --- a/scripts/snap/fixtures-map.ts +++ b/scripts/snap/fixtures-map.ts @@ -2288,6 +2288,21 @@ export const mapSwitchSavesViews = (): Fixture => await wait(700); const saved = calls.filter(([command]) => command === "map_save_view").map(([, args]) => args.project).sort().join(); if (saved !== "/w/falinks,/w/plotkeeper") log("snap:fail the views saved were of " + JSON.stringify(saved));`); +/** + * A badge list open from the keyboard when another project shows (#1045): the list closes, and the keyboard is left alone, never put on + * the new map's plate of the same id. + */ +export const mapBadgeSwitch = (): Fixture => + switching(` + const list = document.getElementById("map-badge-list"); + document.querySelector("#map .plate[data-id=core] .session-badge")?.focus(); + await __snapKey("Enter"); + await wait(60); + if (!list.contains(document.activeElement)) return log("snap:fail Enter on Core's badge left the keyboard on " + document.activeElement?.className); + await open("/w/falinks"); + await wait(300); + if (list.matches(":popover-open")) log("snap:fail the list stayed open over falinks"); + if (document.activeElement?.closest("#map .plate")) log("snap:fail the switch put the keyboard on falinks' " + document.activeElement.closest("#map .plate").dataset.id);`, { realKeys: true }); /** A gone folder's empty state: the window's focus asks nothing about it. */ export const mapGoneFocus = (): Fixture => switching(` diff --git a/scripts/snap/fixtures.ts b/scripts/snap/fixtures.ts index a903eab5b..8e83610c7 100644 --- a/scripts/snap/fixtures.ts +++ b/scripts/snap/fixtures.ts @@ -7,7 +7,7 @@ import type { Fixture } from "./base.ts"; import { railFixtures } from "./rail-fixtures.ts"; import { list, withSaved } from "./fixtures-shared.ts"; import { alerts, cutText, cutTextStill, hints, installHint, listClearLanded, listHeld, listHints, listNarrow, listSecondLines, logDone, logFixture, logos, noticeErrors, notRecording, paletteFocus, paletteOpen, portLine, projectChevron, projectMenuScript, projectsSaved, railJumpHerdr, recording, skipLink, snapFrames, snapRealKeys, storeMoved, streamAboutFailed, streamRefused, streamRestarted, streamRetrying, toastKeys, whatsNewToast } from "./fixtures-page.ts"; -import { mapBadgeList, mapNowSubagents, mapBase, mapCheckout, mapDefaultNoBanner, mapNotGit, mapBriefPairLight, mapBriefSwitch, mapBroken, mapBusy, mapCalm, mapCamera, mapDotsOrder, mapDotsRetry, mapEmpty, mapFog, mapFogPlates, mapFresh, mapGlassMotion, mapGoneFocus, mapHeaderDot, mapMarkHints, mapScan, mapScanIgnore, mapScanMerge, mapScanGive, mapScanNoClaude, mapScanSwitch, mapScanZone, mapScanDissolved, mapScanDissolvedNone, mapDraftSteps, mapDrafting, mapDraftReview, mapDraftRound, mapDraftZoneSteps, mapDraftZoneFailed, mapDraftAccept, mapDraftPr, mapDraftPrMuted, mapDraftLoose, mapDraftReplace, mapDraftWrite, mapKeepCurrent, mapPendingClosed, mapPendingOpen, mapPendingSteps, mapPartKeys, mapPartRedraw, mapProjectGone, mapProjectRemoved, mapRefresher, mapPurposeWhole, mapSheetLongName, mapCaughtUp, mapCatchUpOlder, mapReview, mapScrubbed, mapSmallGaps, mapSpotlight, mapStale, mapSwitchSavesViews, mapTalksTo, mapZones, mapZoneMarks, mapZoneOpen, mapPlanLight, mapZoneSheet, mapZoneSheetNarrow, mapDiffZones } from "./fixtures-map.ts"; +import { mapBadgeList, mapBadgeSwitch, mapNowSubagents, mapBase, mapCheckout, mapDefaultNoBanner, mapNotGit, mapBriefPairLight, mapBriefSwitch, mapBroken, mapBusy, mapCalm, mapCamera, mapDotsOrder, mapDotsRetry, mapEmpty, mapFog, mapFogPlates, mapFresh, mapGlassMotion, mapGoneFocus, mapHeaderDot, mapMarkHints, mapScan, mapScanIgnore, mapScanMerge, mapScanGive, mapScanNoClaude, mapScanSwitch, mapScanZone, mapScanDissolved, mapScanDissolvedNone, mapDraftSteps, mapDrafting, mapDraftReview, mapDraftRound, mapDraftZoneSteps, mapDraftZoneFailed, mapDraftAccept, mapDraftPr, mapDraftPrMuted, mapDraftLoose, mapDraftReplace, mapDraftWrite, mapKeepCurrent, mapPendingClosed, mapPendingOpen, mapPendingSteps, mapPartKeys, mapPartRedraw, mapProjectGone, mapProjectRemoved, mapRefresher, mapPurposeWhole, mapSheetLongName, mapCaughtUp, mapCatchUpOlder, mapReview, mapScrubbed, mapSmallGaps, mapSpotlight, mapStale, mapSwitchSavesViews, mapTalksTo, mapZones, mapZoneMarks, mapZoneOpen, mapPlanLight, mapZoneSheet, mapZoneSheetNarrow, mapDiffZones } from "./fixtures-map.ts"; import { readmeFixtures } from "./fixtures-readme.ts"; import { readmeBriefFixtures } from "./fixtures-readme-brief.ts"; import { mapFootprint, mapLatePlace, mapPanelBrief, mapPanelDiff, mapNotPlacedHint, mapPanelFieldHints, mapPanelFocus, mapPanelHead, mapPanelHistory, mapPanelLine2, mapPanelNoSession, mapPanelPeel, mapListFold, mapPanelSettings, mapPanelStory, mapPanelToggle, mapSheetClose, mapSheetExplained, mapSheetHere, mapSheetHolds, mapSheetKeptWidth, mapSheetResizeRedraw, mapSheetScrollShort, mapSheetStill, mapSheetUnratified, mapSheetWidth, mapToastBeside, mapTurnLight, mapPanelPatched, mapPanelAskStays, mapPanelBriefFoot, mapPrPanel, mapPrPanelPlaying, mapPrPanelRatify, mapPrPanelRewriting, mapPrPanelWriting, panelCaughtUp, panelExpanded, panelNeedsYou, panelFirstOpen, panelNoTrees, panelReplay, panelRunning, panelWhy, panelYourTurn } from "./fixtures-panel.ts"; @@ -288,6 +288,7 @@ export const fixtures = { // Switching projects: both views saved, a gone folder never read on focus, a PR brief closed. mapSwitchSavesViews, mapGoneFocus, + mapBadgeSwitch, mapBriefSwitch, // The header dots: a failed read is tried again, and an older answer never lands over a newer one. mapDotsRetry, diff --git a/ui/map-agents.ts b/ui/map-agents.ts index 8c5c50e7d..97bb81f24 100644 --- a/ui/map-agents.ts +++ b/ui/map-agents.ts @@ -152,6 +152,8 @@ let listWasOpen = false; const badgeList = () => element("map-badge-list"); const listOpen = () => listPart !== null && badgeList().matches(":popover-open"); const badgeOn = (part: string) => currentMap()?.slots.canvas.querySelector<HTMLElement>(`.plate[data-id="${CSS.escape(part)}"] .session-badge`) ?? null; +// A plate's open button: the part's, or the closed zone's sheet button. +const openOn = (part: string) => currentMap()?.slots.canvas.querySelector<HTMLElement>(`.plate[data-id="${CSS.escape(part)}"] .plate-open`) ?? null; function closeBadgeList() { if (badgeList().matches(":popover-open")) badgeList().hidePopover(); @@ -159,17 +161,17 @@ function closeBadgeList() { // The list closed, by a press outside, Esc or any of the cases above: its badge says so, and a focus inside it goes back to the badge. A // badge gone with the redraw that closed the list (its sessions' turns left the part) gives that focus to the plate's open button instead, -// as `paint` does for a focused badge that a chip replaced: the part's, or the closed zone's sheet button. +// as `paint` does for a focused badge that a chip replaced. After a project switch the focus is left alone: the map shown is another's. function listClosed() { endHoverIn(badgeList()); - const part = listPart; + const [part, project] = [listPart, listProject]; listPart = null; listProject = null; if (part === null) return; const badge = badgeOn(part); badge?.setAttribute("aria-expanded", "false"); - if (document.activeElement !== document.body && !badgeList().contains(document.activeElement)) return; - (badge ?? currentMap()?.slots.canvas.querySelector<HTMLElement>(`.plate[data-id="${CSS.escape(part)}"] .plate-open`))?.focus({ preventScroll: true }); + if (project !== currentMap()?.project || (document.activeElement !== document.body && !badgeList().contains(document.activeElement))) return; + (badge ?? openOn(part))?.focus({ preventScroll: true }); } function openList(part: string, badge: HTMLElement, rows: Badge["rows"], byKeyboard: boolean) { @@ -321,7 +323,7 @@ export function paint() { else slot?.replaceChildren(...(byPlate[id] ? [badgeButton(id, byPlate[id], spot !== null && !byPlate[id].accent, held.length === 1 && held[0] === id ? "part" : "zone")] : [])); } // A focused badge a spotlit chip replaced (its session's story opened from its list) leaves the keyboard on its part's button, as a redraw does. - if (focused) (badgeOn(focused) ?? view.slots.canvas.querySelector<HTMLElement>(`.plate[data-id="${CSS.escape(focused)}"] .plate-open`))?.focus({ preventScroll: true }); + if (focused) (badgeOn(focused) ?? openOn(focused))?.focus({ preventScroll: true }); if (listPart !== null) { const rows = byPlate[listPart]?.rows; if (!rows || listProject !== view.project || deps.briefOpen()) closeBadgeList(); From efb5a5ec73c3536d64738119944ed16fb8bb6c52 Mon Sep 17 00:00:00 2001 From: Daniel Rispler <danielrispler@gmail.com> Date: Tue, 1 Dec 2026 21:55:02 +0200 Subject: [PATCH 05/11] Studio: the server caps a session name at 200 characters Worker: opencode/deepseek-v4.1-flash-free --- docs/studio/behaviour/sessions.md | 2 +- server/src/session_view.rs | 22 +++++++++++++- server/src/session_view/tests.rs | 50 +++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 server/src/session_view/tests.rs diff --git a/docs/studio/behaviour/sessions.md b/docs/studio/behaviour/sessions.md index 018a1786a..8a31b990e 100644 --- a/docs/studio/behaviour/sessions.md +++ b/docs/studio/behaviour/sessions.md @@ -46,7 +46,7 @@ Cmd+Shift+H, once `studio::GoHome`, is now `studio::ShowMap` (#386), "back to th **Planning and triage** (spec #967, #972). The core knows when a session is in an interactive planning skill or a triage, and keeps it on the session's wire form (`work.planning`: `planning`, `triage` or `null`). A typed command (the prompt's raw text, `/name` with an optional `plugin:` prefix, its name made of letters, digits, `-`, `_` and `:`, so a pasted path is none) or a `Skill` call enters it: `grill*`, `brainstorm*` and `speckit-clarify` are planning, `triage*` is triage. The helpers `prototype`, `research`, `domain-modeling` and `to-spec` keep the session where it is, and so do Claude Code's built-in commands that tend the session rather than its work (`/compact`, `/model`, `/effort`, `/clear`, `/doctor`, `/statusline` and the like; `BUILT_IN` in `core/src/work.rs`); any other command or skill (`implement`, `implement-spec`, `tdd`, `to-tickets`, …) leaves at once, and a new planning or triage command enters again. A session also leaves when a turn's files are stored and one of them is not Markdown (`.md`, `.markdown`): the turn's files come from the hook's git trees, so an edit made through Bash counts as an Edit or Write does, and a gitignored file (the trees are written by `git add -A`) or a file outside the repository never shows. Only a turn that started at or after the session last entered counts, so an earlier turn's files, stored late or again after a full replay, never end a later grilling; a full replay rebuilds the leave when the shell stores the files of each turn of the last 7 days again. A turn with no recorded trees (an agent that reports none, a folder outside git) leaves nothing. The first issue number of the session's first planning or triage command (`/triage 935`, `/grilling #931`) is its issue's third source, after its `issue-<n>-` branch and a Wayfinder claim, so a triage on `main` is named "#935 · main · …". -"Rename" names the session: the server appends a `StudioRename` line to the event log, so the name survives a restart; the page types nothing into the session. An empty name gives the row its folder's again. "Open" and "Close", which resumed and ended a session's terminal, are gone with the terminals. +"Rename" names the session: the server appends a `StudioRename` line to the event log, so the name survives a restart; the page types nothing into the session. An empty name gives the row its folder's again. A name is capped at 200 characters, counted in Unicode scalar values, and the server's rename is the cap's one authority: it trims the name first, and refuses a longer one with a reason rather than cutting it, so the cap holds whatever sends the name. Names already longer in an old log stay as they are. "Open" and "Close", which resumed and ended a session's terminal, are gone with the terminals. "Delete" asks, then drops the session's row: the server appends a `StudioDelete` line to the event log, so the row stays gone after a restart until a `SessionStart` of the session brings it back; its cards stay in the store, and no worktree or branch is removed. Clear landed, at the list's end, deletes the landed rows the same way once its Undo window has passed. diff --git a/server/src/session_view.rs b/server/src/session_view.rs index 8c1d5c1b2..a11f779c0 100644 --- a/server/src/session_view.rs +++ b/server/src/session_view.rs @@ -97,13 +97,30 @@ fn selection(studio: &Studio) -> serde_json::Value { serde_json::to_value(studio.selection()).expect("selection serializes") } +/// The longest a session name may be, counted in Unicode scalar values (spec #1036, root cause 4). +const NAME_LIMIT: usize = 200; + +/// The name `rename` stores: trimmed, and refused with a reason past [`NAME_LIMIT`] characters. The server +/// is the cap's one authority, so a client that sends more is refused rather than silently cut. +fn checked_name(name: &str) -> Result<&str, String> { + let name = name.trim(); + let count = name.chars().count(); + if count > NAME_LIMIT { + return Err(format!( + "a session name is at most {NAME_LIMIT} characters, and this one is {count}" + )); + } + Ok(name) +} + /// Daniel renamed session `id`: a `StudioRename` line in the event log, which the log thread then /// applies and a restart replays (danielrispler/Falinks#469). An empty `name` gives the row its folder's again. pub fn rename(id: String, name: String) -> Result<(), String> { + let name = checked_name(&name)?; append(&[serde_json::json!({ "session_id": id, "hook_event_name": studio_core::RENAME, - "studio_name": name.trim(), + "studio_name": name, "studio_received_ms": millis(), })]) } @@ -233,3 +250,6 @@ pub fn current_cards_key(app: &App) -> CardsKey { let (studio, cards, notes) = app.core_cards_and_notes(); cards_key(&studio, &cards, ¬es) } + +#[cfg(test)] +mod tests; diff --git a/server/src/session_view/tests.rs b/server/src/session_view/tests.rs new file mode 100644 index 000000000..312180152 --- /dev/null +++ b/server/src/session_view/tests.rs @@ -0,0 +1,50 @@ +use super::*; + +/// `n` characters of Hebrew and emoji, so a count is of characters, not bytes or UTF-16 code units. +fn mixed(n: usize) -> String { + ["ש", "😀", "ל"].into_iter().cycle().take(n).collect() +} + +#[test] +fn a_name_is_trimmed_and_refused_past_200_characters() { + let longest = mixed(NAME_LIMIT); + let too_long = mixed(NAME_LIMIT + 1); + let cases: [(&str, &str, Result<&str, String>); 4] = [ + ( + "200 characters of Hebrew and emoji", + longest.as_str(), + Ok(longest.as_str()), + ), + ( + "201 characters", + too_long.as_str(), + Err("a session name is at most 200 characters, and this one is 201".into()), + ), + ("whitespace only", " \t\n ", Ok("")), + ("surrounding spaces", " my session ", Ok("my session")), + ]; + for (case, name, expected) in cases { + assert_eq!(checked_name(name), expected, "{case}"); + } +} + +#[test] +fn a_refused_rename_appends_nothing_to_the_event_log() { + let home = tempfile::tempdir().unwrap(); + // SAFETY: nextest runs each test in a process of its own, and this test starts no thread (server/tests/isolated_home). + unsafe { + std::env::set_var("HOME", home.path()); + std::env::set_var("USERPROFILE", home.path()); + std::env::remove_var("XDG_DATA_HOME"); + } + let log = studio_hook::event_log(home.path()); + std::fs::create_dir_all(log.parent().unwrap()).unwrap(); + std::fs::write(&log, "").unwrap(); + let refused = rename("s1".into(), mixed(NAME_LIMIT + 1)).unwrap_err(); + assert!(refused.contains("200"), "{refused}"); + assert_eq!( + std::fs::read_to_string(&log).unwrap(), + "", + "the refused rename appended a line" + ); +} From d51057a8f7398e4db9a438e0b6407f7b8b46bfe3 Mon Sep 17 00:00:00 2001 From: Daniel Rispler <danielrispler@gmail.com> Date: Tue, 1 Dec 2026 22:16:16 +0200 Subject: [PATCH 06/11] Studio: Esc skips a list that isn't drawn over the map, and the top bar keeps its buttons in a narrow window (#1047) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CVqACafozqqdDZevv65PCa --- scripts/snap/all.mjs | 4 +- scripts/snap/fixtures-page.ts | 91 +++++++++++++++++++++++++++++++++++ scripts/snap/fixtures.ts | 8 ++- scripts/snap/snap.mjs | 8 ++- ui/layout.ts | 6 +++ ui/main.ts | 6 +-- ui/style.css | 8 ++- ui/tests/layout.test.mjs | 19 +++++++- 8 files changed, 141 insertions(+), 9 deletions(-) diff --git a/scripts/snap/all.mjs b/scripts/snap/all.mjs index 96ff75884..ab44ce94c 100644 --- a/scripts/snap/all.mjs +++ b/scripts/snap/all.mjs @@ -18,8 +18,8 @@ const failsOnPurpose = new Set(["railIdleFail"]); // The README fixtures are drawn at the pictures' size, `readmeSize`. The map fixtures and the writer section are drawn at 1900x1180, the rest at snap's default size. // A fixture named `…Narrow` is drawn at 1000x800, below the 1007 px where the map keeps one overlay open (#385); the map's and the -// writer section's, in the Settings panel over the map (#387), at 1900x1180. A fixture named `…Short` is drawn at 1300x700, a short window. -const sizeOf = (name) => (name.startsWith("readme") ? readmeSize : name.endsWith("Narrow") ? "1000x800" : name.endsWith("Short") ? "1300x700" : name.startsWith("map") || name.startsWith("writers") ? "1900x1180" : undefined); +// writer section's, in the Settings panel over the map (#387), at 1900x1180. A fixture named `…Phone` is drawn at 390x800 and `…Small` at 640x800 (#1047). A fixture named `…Short` is drawn at 1300x700, a short window. +const sizeOf = (name) => (name.startsWith("readme") ? readmeSize : name.endsWith("Phone") ? "390x800" : name.endsWith("Small") ? "640x800" : name.endsWith("Narrow") ? "1000x800" : name.endsWith("Short") ? "1300x700" : name.startsWith("map") || name.startsWith("writers") ? "1900x1180" : undefined); const shardFlag = process.argv.slice(2).find((arg) => arg.startsWith("--shard="))?.slice("--shard=".length); let queue; diff --git a/scripts/snap/fixtures-page.ts b/scripts/snap/fixtures-page.ts index e390ccaa1..34fc5487f 100644 --- a/scripts/snap/fixtures-page.ts +++ b/scripts/snap/fixtures-page.ts @@ -1051,3 +1051,94 @@ export const railJumpHerdr = (): Fixture => { snapDone: "jump ok", }; }; + +/** + * Esc and the list (#1047), with the real pointer and keys. In the full layout the list is a column, so a story opened from a row with + * the pointer left on the list closes at the first Esc: the hover's peek class on the body is not an overlay there. `…Narrow` is the strip + * layout (snap:all draws it at 1000x800), where the list opened over the map is the first thing Esc closes, and the story stays. + */ +const escList = (narrow: boolean): Fixture => { + const sessions = list().sessions as Session[]; + return { + ...list(), + select: { __by: "id", values: Object.fromEntries(sessions.map((s) => [s.id, { session: s, agent: null }])) }, + snapScript: ` + const wait = (ms) => new Promise((done) => setTimeout(done, ms)); + const panel = () => document.body.dataset.panel; + const layout = document.body.dataset.layout; + if (layout !== ${JSON.stringify(narrow ? "strip" : "full")}) return log("snap:fail the layout is " + layout); + await wait(300); + ${ + narrow + ? `// The story is open; the strip's list opens over the map and Esc closes it first. + await __snapClick(document.querySelector("#strip .open")); + await wait(100); + if (!document.body.classList.contains("list-open")) return log("snap:fail the strip's button did not open the list: " + document.body.className); + await __snapKey("Escape"); + await wait(100); + if (document.body.classList.contains("list-open") || document.body.classList.contains("list-peek")) log("snap:fail the first Esc left the list open: " + document.body.className); + if (panel() !== "story") log("snap:fail the first Esc also closed the story: panel " + panel()); + await __snapKey("Escape"); + await wait(100); + if (panel() === "story") log("snap:fail the second Esc left the story open");` + : `// A press on a row that is not selected opens its story, and the pointer stays on the list. + const row = document.querySelector('#groups .session-row[data-key="s3 "]'); + await __snapClick(row); + // The pointer rests on the list's foot, which has no hint, since an open hint takes the first Esc alone (spec #582). + await __snapMove(document.querySelector(".list-foot")); + await wait(900); + if (document.querySelector("#hints :popover-open")) return log("snap:fail a hint is open, so Esc would close it alone"); + if (!document.body.classList.contains("list-peek")) return log("snap:fail the pointer on the list did not peek it: " + document.body.className); + if (panel() !== "story") return log("snap:fail the row's press did not open a story: panel " + panel() + " body " + document.body.className); + await __snapKey("Escape"); + await wait(100); + if (panel() === "story") log("snap:fail the first Esc left the story open: body " + document.body.className);` + } + log("esc list ok");`, + realKeys: true, + realPointer: true, + snapDone: "esc list ok", + }; +}; +export const listEsc = (): Fixture => escList(false); +export const listEscNarrow = (): Fixture => escList(true); + +/** + * The top bar keeps its buttons in a narrow window (#1047): with the install hint, a restart notice with Reload and Needs you showing, + * every button lies wholly inside the window and is the element at its own centre; the text gives way and ends in "…". `…Phone` is drawn at + * 390x800, `…Small` at 640x800 and `…Narrow` at 1000x800 (snap:all's sizes for those suffixes). + */ +export const topBar = (): Fixture => ({ + ...list(), + snapScript: ` + const wait = (ms) => new Promise((done) => setTimeout(done, ms)); + await wait(300); + const answered = window.fetch; + window.fetch = (url, init) => + String(url) === "/api/about" ? Promise.resolve({ ok: true, status: 200, json: async () => ({ version: "0.2.0", start: 2 }) }) : answered(url, init); + __snapStream("open"); + __snapStream("error"); + __snapStream("open"); + window.dispatchEvent(Object.assign(new Event("beforeinstallprompt", { cancelable: true }), { prompt: async () => {} })); + await wait(300); + const bar = document.querySelector(".top"); + const buttons = [...bar.querySelectorAll("button")].filter((b) => b.checkVisibility()); + const names = buttons.map((b) => b.id || b.textContent || b.getAttribute("aria-label")); + for (const want of ["Install", "×", "connection-reload", "needs-you", "settings-button"]) + if (!names.some((n) => n.startsWith(want))) log("snap:fail the bar shows no " + want + ": " + names.join(", ")); + const win = [innerWidth, innerHeight]; + for (const b of buttons) { + const r = b.getBoundingClientRect(); + const name = b.id || b.textContent; + if (r.left < 0 || r.top < 0 || r.right > win[0] || r.bottom > win[1]) log("snap:fail " + name + " is outside the window: " + JSON.stringify(r) + " in " + win); + const at = document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2); + if (!b.contains(at)) log("snap:fail " + name + " is not at its own centre; " + (at?.id || at?.tagName) + " is"); + } + if (bar.scrollWidth > bar.clientWidth) log("snap:fail the bar overflows: " + bar.scrollWidth + " over " + bar.clientWidth); + if (bar.getBoundingClientRect().height > 34) log("snap:fail the bar is " + bar.getBoundingClientRect().height + " px tall"); + log("top bar ok");`, + snapDone: "top bar ok", +}); +export const topBarPhone = (): Fixture => topBar(); +export const topBarSmall = (): Fixture => topBar(); +export const topBarNarrow = (): Fixture => topBar(); diff --git a/scripts/snap/fixtures.ts b/scripts/snap/fixtures.ts index 1dafc9698..80ac93047 100644 --- a/scripts/snap/fixtures.ts +++ b/scripts/snap/fixtures.ts @@ -6,7 +6,7 @@ import type { Fixture } from "./base.ts"; import { railFixtures } from "./rail-fixtures.ts"; import { list, withSaved } from "./fixtures-shared.ts"; -import { alerts, cutText, cutTextStill, hints, installHint, listClearLanded, listHeld, listHints, listNarrow, listSecondLines, logDone, logFixture, logos, noticeErrors, notRecording, paletteFocus, paletteOpen, portLine, projectChevron, projectMenuScript, projectsSaved, railJumpHerdr, recording, skipLink, snapFrames, snapRealKeys, storeMoved, streamAboutFailed, streamRefused, streamRestarted, streamRetrying, toastKeys, whatsNewToast } from "./fixtures-page.ts"; +import { alerts, cutText, cutTextStill, hints, installHint, listClearLanded, listHeld, listEsc, listEscNarrow, listHints, listNarrow, listSecondLines, logDone, logFixture, logos, noticeErrors, notRecording, paletteFocus, paletteOpen, portLine, projectChevron, projectMenuScript, projectsSaved, railJumpHerdr, recording, skipLink, snapFrames, snapRealKeys, storeMoved, streamAboutFailed, streamRefused, streamRestarted, streamRetrying, toastKeys, topBarNarrow, topBarPhone, topBarSmall, whatsNewToast } from "./fixtures-page.ts"; import { mapBadgeList, mapNowSubagents, mapBase, mapCheckout, mapDefaultNoBanner, mapNotGit, mapBriefPairLight, mapBriefSwitch, mapBroken, mapBusy, mapCalm, mapCamera, mapDotsOrder, mapDotsRetry, mapEmpty, mapFog, mapFogPlates, mapFresh, mapGlassMotion, mapGoneFocus, mapHeaderDot, mapMarkHints, mapScan, mapScanIgnore, mapScanMerge, mapScanGive, mapScanNoClaude, mapScanSwitch, mapScanZone, mapScanDissolved, mapScanDissolvedNone, mapDraftSteps, mapDrafting, mapDraftReview, mapDraftRound, mapDraftZoneSteps, mapDraftZoneFailed, mapDraftAccept, mapDraftPr, mapDraftPrMuted, mapDraftLoose, mapDraftReplace, mapDraftWrite, mapKeepCurrent, mapPendingClosed, mapPendingOpen, mapPendingSteps, mapPartKeys, mapPartRedraw, mapProjectGone, mapProjectRemoved, mapRefresher, mapPurposeWhole, mapSheetLongName, mapCaughtUp, mapCatchUpOlder, mapReview, mapScrubbed, mapSmallGaps, mapSpotlight, mapStale, mapSwitchSavesViews, mapTalksTo, mapZones, mapZoneMarks, mapZoneOpen, mapPlanLight, mapZoneSheet, mapZoneSheetNarrow, mapDiffZones } from "./fixtures-map.ts"; import { readmeFixtures } from "./fixtures-readme.ts"; import { readmeBriefFixtures } from "./fixtures-readme-brief.ts"; @@ -45,6 +45,12 @@ export const fixtures = { // The small keyboard, pointer and layout gaps (#462). mapSmallGaps, listNarrow, + // Esc and the list, and the top bar's buttons in a narrow window (#1047). + listEsc, + listEscNarrow, + topBarPhone, + topBarSmall, + topBarNarrow, // The page's structure: the skip link (#461). skipLink, // The hints (spec #582). diff --git a/scripts/snap/snap.mjs b/scripts/snap/snap.mjs index fd3ff6f3b..bb364e3e6 100644 --- a/scripts/snap/snap.mjs +++ b/scripts/snap/snap.mjs @@ -41,7 +41,13 @@ const site = mkdtempSync(join(tmpdir(), "snap-site-")); const profile = mkdtempSync(join(tmpdir(), "snap-chrome-")); cpSync(dist, site, { recursive: true }); const fixture = fixtures[name](); -writeFileSync(join(site, "index.html"), snapPage(readFileSync(join(dist, "index.html"), "utf8"), fixture, { bodyClasses, frames: !!framesFolder })); +const page = snapPage(readFileSync(join(dist, "index.html"), "utf8"), fixture, { bodyClasses, frames: !!framesFolder }); +// Headless Chrome's window is never narrower than 500 px, so a `…Phone` fixture (390 px) draws the page in a frame of the asked width, which +// is the page's own window (`innerWidth`) and keeps real input's coordinates, since the frame sits at the window's origin. +if (Number(width) < 500) { + writeFileSync(join(site, "page.html"), page); + writeFileSync(join(site, "index.html"), `<!doctype html><meta charset="utf-8"><body style="margin:0"><iframe src="page.html" style="display:block;border:0;width:${Number(width)}px;height:${Number(height)}px"></iframe>`); +} else writeFileSync(join(site, "index.html"), page); if (framesFolder) { rmSync(framesFolder, { recursive: true, force: true }); mkdirSync(framesFolder, { recursive: true }); diff --git a/ui/layout.ts b/ui/layout.ts index aff25c73e..8d9867353 100644 --- a/ui/layout.ts +++ b/ui/layout.ts @@ -17,3 +17,9 @@ export function arrange(window: number, { focus = false, folded = false } = {}): if (focus) return { mode: "focus", list: 0 }; return window >= narrowBelow && !folded ? { mode: "full", list } : { mode: "strip", list: strip }; } + +// Whether the session list is drawn over the map, which is when Esc closes it first: its overlay class is on the body and the layout is +// not the full one, the stylesheet's own condition for fixing the full list over the map. In the full layout the list is a column. +export function listOverlaid(classes: Iterable<string>, mode: LayoutMode): boolean { + return mode !== "full" && [...classes].some((name) => name === "list-open" || name === "list-peek"); +} diff --git a/ui/main.ts b/ui/main.ts index ef172505d..697aad84b 100644 --- a/ui/main.ts +++ b/ui/main.ts @@ -13,7 +13,7 @@ import { diffRequest, newestDiff } from "./diff.js"; import { element, failure, hint, invoke, listen, logUncaught, stopEvents, watchConnection } from "./dom.js"; import { type Actions, newestUnseen, nextNeedsYou, paletteEntries, run, stepLine, stepSession, titled, windowBinding } from "./keys.js"; import { hover, realClock } from "./hover.js"; -import { arrange } from "./layout.js"; +import { arrange, listOverlaid, type LayoutMode } from "./layout.js"; import { currentMap, fitMap, listRead, mapEscape, onDraw, openMap, projectsChanged, shownProject, startMap } from "./map.js"; import { startMapHistory } from "./map-history.js"; import { startMapSheet } from "./map-sheet.js"; @@ -168,8 +168,8 @@ const named: Record<string, (arg?: string) => void> = { // popover, and a modal dialog close on Esc themselves (#458). An open hint is among them, and Esc closes it alone: the layers under // it stay (spec #582, user story 5). if (document.querySelector("#hints :popover-open")) return; - const overlaid = ["list-open", "list-peek"].some((name) => document.body.classList.contains(name)); - if (!overlaid) return mapEscape(); + // The list is overlaid only where it is drawn over the map; the full layout's column has nothing to close (#1047). + if (!listOverlaid(document.body.classList, document.body.dataset.layout as LayoutMode)) return mapEscape(); document.body.classList.remove("list-open", "list-peek"); }, "studio::ToggleFocus": () => { diff --git a/ui/style.css b/ui/style.css index 5878cdc1d..ff8d6c994 100644 --- a/ui/style.css +++ b/ui/style.css @@ -58,8 +58,14 @@ body[data-layout="focus"] .list { visibility: hidden; } .top { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--sp-5); padding: 0 var(--sp-5) 0 var(--sp-6); white-space: nowrap; overflow: hidden; } .bar-project { font-size: var(--size-small); font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; } -/* The top bar's items never shrink (danielrispler/plotkeeper#127). The spacer takes the rest. */ +/* The top bar's buttons never shrink (danielrispler/plotkeeper#127), and its text gives way to them (#1047): the project name, the install + hint's sentence, the connection line and the port line shrink to nothing and end in "…", so every button stays inside the window. The + spacer takes the rest. */ .top > :not(.sp):not(.menu) { flex: none; } +.top > :is(.bar-project, .connection, #port-line):not(.sp):not(.menu) { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; } +/* The install hint's line gives its sentence and buttons to the bar as items of their own, so the sentence shrinks and the buttons do not. */ +#install-hint:not([hidden]) { display: contents; } +#install-hint > span { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; } .top .sp { flex: 1; } .top .menu[popover] { top: var(--bar); right: var(--sp-5); left: auto; width: max-content; max-width: calc(100vw - 2 * var(--sp-5)); } .top .menu .chip { text-align: start; } diff --git a/ui/tests/layout.test.mjs b/ui/tests/layout.test.mjs index 79e58266b..b604012e6 100644 --- a/ui/tests/layout.test.mjs +++ b/ui/tests/layout.test.mjs @@ -3,7 +3,7 @@ import { test } from "node:test"; import assert from "node:assert/strict"; import { openPage } from "./address-page.mjs"; -import { arrange } from "../../dist/layout.js"; +import { arrange, listOverlaid } from "../../dist/layout.js"; import { addressedSession, askedAddress, startProject, wasRemoved } from "../../dist/map-model.js"; test("from 1,007 pixels up the list shows in full, 252 pixels wide, beside the map", () => { @@ -32,6 +32,23 @@ test("a folded list in a wide window is its strip, and unfolded it is the full l assert.deepEqual(arrange(1512, { folded: true, focus: true }), { mode: "focus", list: 0 }); }); +// Esc closes the list first only when it is drawn over the map (#1047): the stylesheet draws the overlay for `list-open` or `list-peek` +// on a body whose layout is not the full one, so in the full layout the peek class (which hover sets at every width) shows nothing. +test("the list counts as overlaid for Esc only when its overlay class is on the body and the layout is not the full one", () => { + for (const [classes, mode, overlaid] of /** @type {[string[], import("../../dist/layout.js").LayoutMode, boolean][]} */ ([ + [["list-peek"], "full", false], + [["list-open"], "full", false], + [["list-open", "list-peek"], "full", false], + [["list-peek"], "strip", true], + [["list-open"], "strip", true], + [["list-open"], "focus", true], + [["list-peek", "map-open"], "focus", true], + [[], "strip", false], + [["map-open"], "strip", false], + [[], "full", false], + ])) assert.equal(listOverlaid(classes, mode), overlaid, `${classes} in ${mode}`); +}); + test("the page opens on the project its address asks for, else the last viewed project's map, else the first project's", () => { const saved = ["/w/falinks", "/w/plotkeeper", "/w/pokedex"]; assert.equal(startProject([null, "/w/plotkeeper"], saved, saved), "/w/plotkeeper"); From 4c61662ffa46df435c7946cc787071c2569898f6 Mon Sep 17 00:00:00 2001 From: Daniel Rispler <danielrispler@gmail.com> Date: Tue, 1 Dec 2026 22:20:57 +0200 Subject: [PATCH 07/11] Studio: the top bar's text is cut text with the full-text rule, and the new snap fixtures keep to it (#1047) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CVqACafozqqdDZevv65PCa --- scripts/snap/fixtures-page.ts | 2 +- ui/install-hint.ts | 6 +++--- ui/main.ts | 10 +++++----- ui/style.css | 7 ++++--- ui/tests/full-text.test.mjs | 3 +++ 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/scripts/snap/fixtures-page.ts b/scripts/snap/fixtures-page.ts index 34fc5487f..f498f58b1 100644 --- a/scripts/snap/fixtures-page.ts +++ b/scripts/snap/fixtures-page.ts @@ -1108,7 +1108,7 @@ export const listEscNarrow = (): Fixture => escList(true); * every button lies wholly inside the window and is the element at its own centre; the text gives way and ends in "…". `…Phone` is drawn at * 390x800, `…Small` at 640x800 and `…Narrow` at 1000x800 (snap:all's sizes for those suffixes). */ -export const topBar = (): Fixture => ({ +const topBar = (): Fixture => ({ ...list(), snapScript: ` const wait = (ms) => new Promise((done) => setTimeout(done, ms)); diff --git a/ui/install-hint.ts b/ui/install-hint.ts index fcb109ec3..b179836bc 100644 --- a/ui/install-hint.ts +++ b/ui/install-hint.ts @@ -2,7 +2,7 @@ // the open window, and a line when the page runs off the port an installed window opens. The manifest and icons are `manifest.webmanifest` // and `icons/`, served without the cookie (#878). -import { element, hint, pageStore, pressable, text } from "./dom.js"; +import { cut, element, hint, pageStore, pressable, text } from "./dom.js"; /** The port an installed app window opens: the manifest's `start_url` has no port of its own. */ const DEFAULT_PORT = 47800; @@ -33,7 +33,7 @@ export function startInstallHint() { const dismiss = pressable(text("button", "×", "quiet small"), null, close); dismiss.setAttribute("aria-label", "Dismiss"); line.replaceChildren( - text("span", "Install plotkeeper as an app: its own window and a Dock badge"), + cut(text("span", "Install plotkeeper as an app: its own window and a Dock badge")), hint(install, "Install plotkeeper as an app in Chrome"), hint(dismiss, "Hide this line for good"), ); @@ -67,5 +67,5 @@ export function startPortLine() { const line = element("port-line"); const port = location.port; line.hidden = port === "" || port === String(DEFAULT_PORT); - if (!line.hidden) line.textContent = `plotkeeper is on port ${port}: an installed app window opens ${DEFAULT_PORT}`; + if (!line.hidden) cut(line, `plotkeeper is on port ${port}: an installed app window opens ${DEFAULT_PORT}`); } diff --git a/ui/main.ts b/ui/main.ts index 697aad84b..9f629a327 100644 --- a/ui/main.ts +++ b/ui/main.ts @@ -10,7 +10,7 @@ import { startWatching } from "./answer.js"; import { forgetAsks } from "./ask.js"; import { recheckSeen } from "./seen.js"; import { diffRequest, newestDiff } from "./diff.js"; -import { element, failure, hint, invoke, listen, logUncaught, stopEvents, watchConnection } from "./dom.js"; +import { cut, element, failure, hint, invoke, listen, logUncaught, stopEvents, watchConnection } from "./dom.js"; import { type Actions, newestUnseen, nextNeedsYou, paletteEntries, run, stepLine, stepSession, titled, windowBinding } from "./keys.js"; import { hover, realClock } from "./hover.js"; import { arrange, listOverlaid, type LayoutMode } from "./layout.js"; @@ -494,20 +494,20 @@ void readData() // what it showed, and its actions stay. A reopen whose `about` fails is not live yet, so the line says it is retrying again. const RETRYING = "Lost connection to plotkeeper — retrying"; const RESTARTED = "plotkeeper restarted — this tab is out of date"; -const connection = element("connection"); +const connection = cut(element("connection")); const reloadButton = element("connection-reload"); reloadButton.addEventListener("click", () => location.reload()); let outOfDate = false; function restarted() { outOfDate = true; stopEvents(); - connection.textContent = RESTARTED; + cut(connection, RESTARTED); connection.classList.add("restarted"); reloadButton.hidden = false; } watchConnection((state) => { if (outOfDate) return; - connection.textContent = state === "retrying" ? RETRYING : ""; + cut(connection, state === "retrying" ? RETRYING : ""); if (state === "closed") return restarted(); if (state !== "reopened") return; invoke("about") @@ -518,7 +518,7 @@ watchConnection((state) => { else restarted(); }) .catch((why: unknown) => { - if (!outOfDate) connection.textContent = RETRYING; + if (!outOfDate) cut(connection, RETRYING); failure("about")(why); }); }); diff --git a/ui/style.css b/ui/style.css index ff8d6c994..6cda7a91a 100644 --- a/ui/style.css +++ b/ui/style.css @@ -59,13 +59,14 @@ body[data-layout="focus"] .list { visibility: hidden; } white-space: nowrap; overflow: hidden; } .bar-project { font-size: var(--size-small); font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; } /* The top bar's buttons never shrink (danielrispler/plotkeeper#127), and its text gives way to them (#1047): the project name, the install - hint's sentence, the connection line and the port line shrink to nothing and end in "…", so every button stays inside the window. The + hint's sentence, the connection line and the port line (cut text, `cut()` in dom.ts) shrink to nothing and end in "…", so every button stays inside the window. The spacer takes the rest. */ .top > :not(.sp):not(.menu) { flex: none; } -.top > :is(.bar-project, .connection, #port-line):not(.sp):not(.menu) { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; } +.top > :is(.bar-project, .connection, #port-line):not(.sp):not(.menu) { flex: 0 1 auto; min-width: 0; } /* The install hint's line gives its sentence and buttons to the bar as items of their own, so the sentence shrinks and the buttons do not. */ #install-hint:not([hidden]) { display: contents; } -#install-hint > span { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; } +#install-hint > .cut { flex: 0 1 auto; min-width: 0; } +.connection.cut, #port-line.cut, #install-hint > .cut { overflow: hidden; text-overflow: ellipsis; } .top .sp { flex: 1; } .top .menu[popover] { top: var(--bar); right: var(--sp-5); left: auto; width: max-content; max-width: calc(100vw - 2 * var(--sp-5)); } .top .menu .chip { text-align: start; } diff --git a/ui/tests/full-text.test.mjs b/ui/tests/full-text.test.mjs index 10ce5d9b8..3d91ec814 100644 --- a/ui/tests/full-text.test.mjs +++ b/ui/tests/full-text.test.mjs @@ -206,6 +206,9 @@ const covered = { ".subagent-log .log-call summary": "log.ts: the summary's title", ".map-canvas": "map.ts: the map area is a camera, not a text; it pans and zooms to what it cuts", ".map-scan-canvas": "map-scan.ts: the scan's canvas fits its plates to its size; a plate's hint holds its name, folder and file count", + ".connection.cut": "main.ts: the connection line is cut text that scrolls in place (cut())", + "#port-line.cut": "install-hint.ts: the port line is cut text that scrolls in place (cut())", + "#install-hint > .cut": "install-hint.ts: the install sentence is cut text that scrolls in place (cut())", ".bar-project": "map.ts: the top bar's project name has the project's path as its title", ".map-view": "map.ts: the map is cut at its rounded corner; the camera pans to what it cuts", ".map-panel": "panel.ts: the left panel's body scrolls, so nothing in it is cut; the panel only rounds its corners", From 315f6bf647a89ad1ddaa23b59459d2e2bbd55ccb Mon Sep 17 00:00:00 2001 From: Daniel Rispler <danielrispler@gmail.com> Date: Tue, 1 Dec 2026 22:56:46 +0200 Subject: [PATCH 08/11] Studio: a permission shows its command whole, and the rename and Delete dialogs bound long names (#1049) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CVqACafozqqdDZevv65PCa --- docs/studio/behaviour/cards.md | 2 +- scripts/snap/fixtures-page.ts | 140 +++++++++++++++++++++++++++++++++ scripts/snap/fixtures.ts | 7 +- ui/decisions.ts | 4 +- ui/index.html | 5 +- ui/questions.ts | 7 +- ui/story.ts | 21 ++++- ui/style.css | 15 +++- 8 files changed, 187 insertions(+), 14 deletions(-) diff --git a/docs/studio/behaviour/cards.md b/docs/studio/behaviour/cards.md index 9ef172653..30450987b 100644 --- a/docs/studio/behaviour/cards.md +++ b/docs/studio/behaviour/cards.md @@ -31,7 +31,7 @@ A turn a wake-up opened that changed nothing itself writes only its summary and In a Claude Code session, a plan (`ExitPlanMode`), a question (`AskUserQuestion`) or another tool's permission docks at the top of the session's story with its answers while plotkeeper's answer hook waits for them (#892). The hook waits at Claude Code's `PermissionRequest`, which leaves the terminal's own dialog open the whole time, so the first answer, the page's or the terminal's, decides. - **A plan or a question waits in the background**, whenever plotkeeper runs, whether or not the page shows its session: open the session later and its card still has its buttons. The hook waits while the server whose pid `plotkeeper.running.json` names lives, for up to 29 minutes 50 seconds, just under the entry's 1800 s timeout. When it gives up (that deadline, or plotkeeper stopped) it records a `StudioWaitEnded` line, and the session's block is marked "stopped waiting" (`stopped_waiting` on the session). -- **Any other tool's permission** keeps the older rule: it waits only while the page shows its session in a visible window, for up to 120 seconds, so the page never approves a command out of context. +- **Any other tool's permission** keeps the older rule: it waits only while the page shows its session in a visible window, for up to 120 seconds, so the page never approves a command out of context. Its command is shown whole (#1049): a block that keeps the command's line breaks and wraps long lines inside the card, never past its edge, so what Allow approves is all in view. Past about twelve lines the block scrolls on its own, with Allow and Deny always under it, and the agent's description follows on its own line. The decision history draws the same command the same way, with no height cap. - **One ask per call.** Each wait leaves its own ask, `asks/<session>/<nonce>.json`, and the server sends every ask of the shown session, so a plan, a subagent's question and a permission at once do not end each other's waits. The hook removes only its own ask when it ends; it also ends, with no answer, when its ask is removed. - **Matching.** A `PermissionRequest` names no call id, so a question's card takes the ask of its tool, its questions and its agent, and the core records a card's answer against the open call the same way: a plan by its text and agent, a question by its questions, so a field one event carries and another lacks (`planFilePath`) does not break the match. A question answered on the page is recorded as the card's, under its call's id. - **Where an ask stands.** The core answers, for an ask's tool, input and agent, whether its call is unseen (its `PreToolUse` has not landed yet), open, stopped waiting, or closed on the card or in the terminal (`Session::ask_state`), keeping a session's recently closed blocks for that. diff --git a/scripts/snap/fixtures-page.ts b/scripts/snap/fixtures-page.ts index f498f58b1..136e257c7 100644 --- a/scripts/snap/fixtures-page.ts +++ b/scripts/snap/fixtures-page.ts @@ -1142,3 +1142,143 @@ const topBar = (): Fixture => ({ export const topBarPhone = (): Fixture => topBar(); export const topBarSmall = (): Fixture => topBar(); export const topBarNarrow = (): Fixture => topBar(); + +/** The selected session `id` of `list()`, its story open, and `extra` over it. */ +const storyOf = (extra: Partial<Fixture> = {}, name?: string, change: Partial<Session> = {}): Fixture => { + const sessions = (list().sessions as Session[]).map((s) => (s.id === "s3" ? { ...s, ...(name !== undefined && { name }), ...change } : s)); + const own = sessions.find((s) => s.id === "s3") as Session; + return { ...list(), sessions, select: { __by: "id", values: Object.fromEntries(sessions.map((s) => [s.id, { session: s, agent: null }])) }, ...extra, selected: { session: own, agent: null } } as Fixture; +}; + +/** + * A permission's command is shown whole (#1049): in the dock a two-line command, a 300-character one and a 30-line one are blocks inside the + * card's width, the two-line one two or more lines tall, the 30-line one capped (about twelve lines) with its own scroll, and Allow under + * each box. The decision history's entry for the two-line command keeps its line break, with no height cap. + */ +export const permissionCommand = (): Fixture => { + const ask = (nonce: string, command: string, description?: string) => ({ nonce, hook_event_name: "PermissionRequest", tool_name: "Bash", agent_id: null, tool_input: { command, description }, asked_ms: Date.now() - 60e3 }); + const two = 'echo "done"\nrm -rf ~/Documents'; + const long = "echo " + "a".repeat(295); + const many = Array.from({ length: 30 }, (_, n) => "echo line " + (n + 1)).join("\n"); + const decision = { call: "c9", agent: null, tool: "Bash", input: { command: two }, answer: "allow" as const, at: Date.now() - 600e3, source: "card" as const, mode: null, message: null }; + return storyOf({ + watch: [ask("p1", two, "Say it is done"), ask("p2", long), ask("p3", many)], + cards: { brief: null, goal: null, answers: [], open: [], design: [], decisions: [decision], risk_notes: [], decision_notes: [] }, + snapScript: ` + const wait = (ms) => new Promise((done) => setTimeout(done, ms)); + await wait(500); + const cards = [...document.querySelectorAll("#dock .decision")]; + if (cards.length !== 3) return log("snap:fail the dock holds " + cards.length + " permission cards"); + // The lines a text is drawn on: one box per line fragment, the distinct tops of its range's rects. + const linesOf = (node) => { + const range = document.createRange(); + range.selectNodeContents(node); + return new Set([...range.getClientRects()].map((r) => Math.round(r.top))).size; + }; + const rowHeight = (node) => { const lh = parseFloat(getComputedStyle(node).lineHeight); return Number.isNaN(lh) ? parseFloat(getComputedStyle(node).fontSize) * 1.5 : lh; }; + cards.forEach((card, i) => { + const box = card.querySelector("code"); + const [c, b] = [card.getBoundingClientRect(), box.getBoundingClientRect()]; + const allow = [...card.querySelectorAll("button")].find((x) => x.textContent === "Allow").getBoundingClientRect(); + const lines = linesOf(box); + if (b.left < c.left - 0.5 || b.right > c.right + 0.5) log("snap:fail command " + i + " is outside the card: " + [b.left, b.right] + " in " + [c.left, c.right]); + if (box.scrollWidth > box.clientWidth + 1) log("snap:fail command " + i + " scrolls sideways"); + if (allow.top < b.bottom - 0.5) log("snap:fail Allow is not below command " + i); + if (i === 0 && lines < 2) log("snap:fail the two-line command is " + lines + " lines tall"); + if (i === 0 && box.nextElementSibling === null && !card.querySelector(".description")) log("snap:fail the description is missing"); + if (i === 1 && lines < 2) log("snap:fail the 300-character command is " + lines + " lines tall"); + if (i === 2) { + if (b.height > rowHeight(box) * 14) log("snap:fail the 30-line command is " + b.height + " px tall, not capped"); + if (box.scrollHeight <= box.clientHeight + 1) log("snap:fail the capped command does not scroll"); + } + }); + const description = cards[0].querySelector(".description"); + if (description && description.getBoundingClientRect().top < cards[0].querySelector("code").getBoundingClientRect().bottom - 0.5) log("snap:fail the description is not under the command"); + const fold = document.getElementById("decisions"); + if (fold.hidden) return log("snap:fail the decision history is not shown"); + fold.open = true; + await wait(100); + const entry = fold.querySelector("li code"); + if (!entry) return log("snap:fail the history has no command"); + if (entry.textContent !== ${JSON.stringify(two)}) log("snap:fail the entry's text is " + JSON.stringify(entry.textContent)); + if (linesOf(entry) < 2) log("snap:fail the history entry lost its line break: " + entry.getBoundingClientRect().height); + if (getComputedStyle(entry).maxHeight !== "none") log("snap:fail the history entry is capped: " + getComputedStyle(entry).maxHeight); + log("command ok");`, + snapDone: "command ok", + }, undefined, { state: "needs_you", landed: false }); +}; + +/** + * The rename dialog counts characters as the server does (#1049, #1048): 201 emoji are 201 characters, though 402 UTF-16 units, so Save is + * unavailable (`aria-disabled`, never `disabled`) and a note gives the limit; 200 are accepted, and the field has no `maxlength`. + */ +export const renameCap = (): Fixture => + storyOf({ + snapScript: ` + const wait = (ms) => new Promise((done) => setTimeout(done, ms)); + await wait(300); + document.getElementById("rename").click(); + const dialog = document.getElementById("rename-dialog"); + const field = document.getElementById("rename-field"); + const save = document.getElementById("rename-dialog-save"); + const note = () => [...dialog.querySelectorAll("p")].find((p) => p.textContent === "Names are at most 200 characters." && p.checkVisibility()); + const type = async (words) => { field.value = words; field.dispatchEvent(new Event("input", { bubbles: true })); await wait(50); }; + if (!dialog.open) return log("snap:fail the rename dialog did not open"); + if (field.hasAttribute("maxlength")) log("snap:fail the field has a maxlength"); + await type("😀".repeat(201)); + if (field.value !== "😀".repeat(201)) log("snap:fail the field cut the 201 emoji to " + [...field.value].length); + if (save.getAttribute("aria-disabled") !== "true") log("snap:fail Save is available with 201 emoji"); + if (save.disabled) log("snap:fail Save is disabled, not aria-disabled"); + if (!note()) log("snap:fail no note with 201 emoji"); + await type("😀".repeat(200)); + if (save.hasAttribute("aria-disabled")) log("snap:fail Save is unavailable with 200 emoji"); + if (note()) log("snap:fail the note shows with 200 emoji"); + await type("😀".repeat(201)); + save.click(); + await wait(100); + if (!dialog.open) log("snap:fail a press on the unavailable Save closed the dialog"); + log("rename ok");`, + snapDone: "rename ok", + }); + +/** + * A name stored before the cap (#1049): 4,800 characters, a long word among them. The rename and Delete dialogs wrap it and keep inside the + * window, their buttons visible, scrolling the name inside the dialog. `…Phone` is drawn at 390x800. + */ +const longName = (): Fixture => { + const name = ("Long words wrap " + "w".repeat(600) + " ").repeat(7).slice(0, 4800); + return storyOf({ + snapScript: ` + const wait = (ms) => new Promise((done) => setTimeout(done, ms)); + await wait(300); + const inside = (dialog, what) => { + const r = dialog.getBoundingClientRect(); + if (r.left < -0.5 || r.top < -0.5 || r.right > innerWidth + 0.5 || r.bottom > innerHeight + 0.5) log("snap:fail the " + what + " dialog is outside the window: " + JSON.stringify(r) + " in " + [innerWidth, innerHeight]); + if (dialog.scrollWidth > dialog.clientWidth + 1) log("snap:fail the " + what + " dialog scrolls sideways"); + for (const button of dialog.querySelectorAll(".ask-buttons button")) { + const b = button.getBoundingClientRect(); + if (!button.checkVisibility() || b.bottom > r.bottom + 0.5 || b.right > r.right + 0.5 || b.top < r.top - 0.5) log("snap:fail " + what + "'s " + button.textContent + " is not in view"); + const at = document.elementFromPoint(b.left + b.width / 2, b.top + b.height / 2); + if (!button.contains(at)) log("snap:fail " + what + "'s " + button.textContent + " is covered"); + } + }; + document.getElementById("rename").click(); + const rename = document.getElementById("rename-dialog"); + await wait(100); + if (!rename.open) return log("snap:fail the rename dialog did not open"); + inside(rename, "rename"); + rename.close("cancel"); + document.getElementById("delete").click(); + const remove = document.getElementById("delete-dialog"); + await wait(100); + if (!remove.open) return log("snap:fail the Delete dialog did not open"); + inside(remove, "Delete"); + const said = remove.querySelector("form > p"); + if (said.scrollHeight <= said.clientHeight + 1) log("snap:fail the Delete dialog's text does not scroll its long name"); + if (remove.scrollHeight > remove.clientHeight + 1) log("snap:fail the whole Delete dialog scrolls, so its buttons can leave the view"); + log("long name ok");`, + snapDone: "long name ok", + }, name); +}; +export const longNameDialogs = (): Fixture => longName(); +export const longNameDialogsPhone = (): Fixture => longName(); diff --git a/scripts/snap/fixtures.ts b/scripts/snap/fixtures.ts index af46355c1..9ea02c999 100644 --- a/scripts/snap/fixtures.ts +++ b/scripts/snap/fixtures.ts @@ -6,7 +6,7 @@ import type { Fixture } from "./base.ts"; import { railFixtures } from "./rail-fixtures.ts"; import { list, withSaved } from "./fixtures-shared.ts"; -import { alerts, cutText, cutTextStill, hints, installHint, listClearLanded, listHeld, listEsc, listEscNarrow, listHints, listNarrow, listSecondLines, logDone, logFixture, logos, noticeErrors, notRecording, paletteFocus, paletteOpen, portLine, projectChevron, projectMenuScript, projectsSaved, railJumpHerdr, recording, skipLink, snapFrames, snapRealKeys, storeMoved, streamAboutFailed, streamRefused, streamRestarted, streamRetrying, toastKeys, topBarNarrow, topBarPhone, topBarSmall, whatsNewToast } from "./fixtures-page.ts"; +import { alerts, cutText, cutTextStill, hints, installHint, listClearLanded, listHeld, listEsc, listEscNarrow, listHints, listNarrow, listSecondLines, logDone, longNameDialogs, longNameDialogsPhone, permissionCommand, renameCap, logFixture, logos, noticeErrors, notRecording, paletteFocus, paletteOpen, portLine, projectChevron, projectMenuScript, projectsSaved, railJumpHerdr, recording, skipLink, snapFrames, snapRealKeys, storeMoved, streamAboutFailed, streamRefused, streamRestarted, streamRetrying, toastKeys, topBarNarrow, topBarPhone, topBarSmall, whatsNewToast } from "./fixtures-page.ts"; import { mapBadgeList, mapBadgeSwitch, mapNowSubagents, mapBase, mapCheckout, mapDefaultNoBanner, mapNotGit, mapBriefPairLight, mapBriefSwitch, mapBroken, mapBusy, mapCalm, mapCamera, mapDotsOrder, mapDotsRetry, mapEmpty, mapFog, mapFogPlates, mapFresh, mapGlassMotion, mapGoneFocus, mapHeaderDot, mapMarkHints, mapScan, mapScanIgnore, mapScanMerge, mapScanGive, mapScanNoClaude, mapScanSwitch, mapScanZone, mapScanDissolved, mapScanDissolvedNone, mapDraftSteps, mapDrafting, mapDraftReview, mapDraftRound, mapDraftZoneSteps, mapDraftZoneFailed, mapDraftAccept, mapDraftPr, mapDraftPrMuted, mapDraftLoose, mapDraftReplace, mapDraftWrite, mapKeepCurrent, mapPendingClosed, mapPendingOpen, mapPendingSteps, mapPartKeys, mapPartRedraw, mapProjectGone, mapProjectRemoved, mapRefresher, mapPurposeWhole, mapSheetLongName, mapCaughtUp, mapCatchUpOlder, mapReview, mapScrubbed, mapSmallGaps, mapSpotlight, mapStale, mapSwitchSavesViews, mapTalksTo, mapZones, mapZoneMarks, mapZoneOpen, mapPlanLight, mapZoneSheet, mapZoneSheetNarrow, mapDiffZones } from "./fixtures-map.ts"; import { readmeFixtures } from "./fixtures-readme.ts"; import { readmeBriefFixtures } from "./fixtures-readme-brief.ts"; @@ -51,6 +51,11 @@ export const fixtures = { topBarPhone, topBarSmall, topBarNarrow, + // Untrusted text has a bound (#1049). + permissionCommand, + renameCap, + longNameDialogs, + longNameDialogsPhone, // The page's structure: the skip link (#461). skipLink, // The hints (spec #582). diff --git a/ui/decisions.ts b/ui/decisions.ts index 08ae389bc..2545ccf42 100644 --- a/ui/decisions.ts +++ b/ui/decisions.ts @@ -134,9 +134,7 @@ function entry(decision: Decision): HTMLElement { } // What the call does: a command, a path or a link; otherwise its whole input. const detail = input.command ?? input.file_path ?? input.url ?? JSON.stringify(input); - const shown = document.createElement("p"); - shown.append(code(String(detail))); - item.append(shown); + item.append(code(String(detail))); item.append(text("p", `Answer: ${answerText(decision)}`, "answer")); const risk = riskText(decision, notes); if (risk !== null) item.append(text("p", risk, "risk")); diff --git a/ui/index.html b/ui/index.html index 10dfe4a3d..c7c44dbc4 100644 --- a/ui/index.html +++ b/ui/index.html @@ -195,10 +195,11 @@ <h1 class="visually-hidden">plotkeeper</h1> </div> <!-- The questions of rename and close (danielrispler/Falinks#469). --> <dialog id="rename-dialog" class="ask" aria-labelledby="rename-heading"> - <form method="dialog"> + <form id="rename-form" method="dialog"> <h2 id="rename-heading" class="ask-title">Rename session</h2> <label for="rename-field">Name this session</label> - <input id="rename-field" name="session-name" autocomplete="off" spellcheck="false" autofocus> + <input id="rename-field" name="session-name" autocomplete="off" spellcheck="false" autofocus aria-describedby="rename-note"> + <p id="rename-note" class="ask-note" aria-live="polite"></p> <!-- The default button comes first, so Enter in the field renames. --> <div class="ask-buttons"><button id="rename-dialog-save" type="submit" class="btn" value="rename">Rename</button><button id="rename-dialog-cancel" type="submit" class="btn" value="cancel">Cancel</button></div> </form> diff --git a/ui/questions.ts b/ui/questions.ts index 3a0867b78..0eef74d35 100644 --- a/ui/questions.ts +++ b/ui/questions.ts @@ -103,10 +103,9 @@ export function decisionElement(ask: Ask): HTMLElement { // What the call does: a command, a path or a link; otherwise its whole input. const detail = input.command ?? input.file_path ?? input.url ?? JSON.stringify(input); block.append(text("p", "Permission", "header"), text("p", `Allow ${ask.tool_name}?`, "asked")); - const shown = document.createElement("p"); - shown.append(code(String(detail))); - if (typeof input.description === "string") shown.append(text("span", ` ${input.description}`, "description")); - block.append(shown); + // The command whole, as a block (#1049); what the agent says it is for follows on its own line. + block.append(code(String(detail))); + if (typeof input.description === "string") block.append(text("p", input.description, "description")); block.append(answerButtons([["Allow", decide("allow")], ["Deny", decide("deny")]])); return block; } diff --git a/ui/story.ts b/ui/story.ts index e26fd5b49..d5649b343 100644 --- a/ui/story.ts +++ b/ui/story.ts @@ -7,7 +7,7 @@ import { modelLine, reports } from "./capabilities.js"; import { logo, logoKey, noContextNote } from "./logos.js"; -import { age, code, cut, element, failure, glyphOnly, hint, invoke, keepOnly, keyed, patch, pressable, prose, revealsOnOpen, stamp, text, unhint, unseenWords } from "./dom.js"; +import { age, availability, code, cut, element, failure, glyphOnly, hint, invoke, isUnavailable, keepOnly, keyed, patch, pressable, prose, revealsOnOpen, stamp, text, unhint, unseenWords } from "./dom.js"; import { askAnchor, asked, openAsk } from "./ask.js"; import { askFor, openDecisions, timedOut, timedOutPlans } from "./answer.js"; import { rendered, renderedInline } from "./markdown.js"; @@ -967,11 +967,30 @@ function panelOf(session: Session): HTMLElement { }); } +/** The longest session name, in characters: the server's cap (`NAME_LIMIT`, #1048). */ +const NAME_LIMIT = 200; + // Rename (danielrispler/Falinks#469): the row's name, kept in the event log. An empty name gives the row its folder's again. function askName(session: Session) { const dialog = element("rename-dialog", HTMLDialogElement); const field = element("rename-field", HTMLInputElement); + const save = element("rename-dialog-save"); + const note = element("rename-note"); + // The cap counts characters as the server does, Unicode scalar values: the field has no `maxlength`, which counts UTF-16 units (#1049). + const check = () => { + const over = [...field.value.trim()].length > NAME_LIMIT; + // Always on the page and filled or emptied, so its polite live region announces the limit as it is passed. + note.textContent = over ? `Names are at most ${NAME_LIMIT} characters.` : ""; + availability(save, "Save this name (↩)", over ? `Names are at most ${NAME_LIMIT} characters` : null); + }; + field.oninput = check; + // Enter in the field and a press on Save both submit the form; an unavailable Save submits nothing. + const form = element("rename-form", HTMLFormElement); + form.onsubmit = (event) => { + if (isUnavailable(save) && (event.submitter === null || event.submitter === save)) event.preventDefault(); + }; field.value = session.name ?? ""; + check(); dialog.onclose = async () => { if (dialog.returnValue !== "rename") return; await invoke("rename", { id: session.id, name: field.value.trim() }).catch(failure("rename", "error")); diff --git a/ui/style.css b/ui/style.css index 6cda7a91a..14059d22d 100644 --- a/ui/style.css +++ b/ui/style.css @@ -411,7 +411,11 @@ h1 { margin: 0 0 var(--sp-4); } background: none; } .choices li .btn:hover:not(:disabled, [aria-disabled="true"]) { background: var(--hover); } .answer-buttons { display: flex; flex-wrap: wrap; gap: var(--sp-4); } -.decision .description { color: var(--muted); } +.decision .description { color: var(--muted); margin: var(--sp-2) 0 0; } +/* A permission's command is shown whole (#1049): a block that keeps its line breaks and wraps anywhere. In the dock it stops at about + twelve lines and scrolls on its own, so Allow and Deny stay under it; the history's entry approves nothing and has no cap. */ +.decision code, .decisions li > code { display: block; white-space: pre-wrap; overflow-wrap: anywhere; text-overflow: clip; margin: var(--sp-2) 0 0; padding: var(--sp-2) var(--sp-3); } +.decision code { max-height: 12lh; overflow-y: auto; } /* A plan's three answers (#892): "Approve · auto mode" leads, and Change… opens a box for what to change, which grows with its words between three lines and ten. */ :is(.question, .plan-bar) .primary:not([aria-disabled="true"]) { background: var(--selected); } @@ -592,7 +596,14 @@ h1 { margin: 0 0 var(--sp-4); } /* Workspaces (danielrispler/Falinks#576): a clicked workspace's actions, under its row. */ /* The questions of rename and close (danielrispler/Falinks#469). */ .ask { background: var(--surface); color: var(--fg); border: 0; border-radius: var(--radius); box-shadow: var(--shadow); - padding: var(--sp-5); width: var(--popover); } + padding: var(--sp-5); width: var(--popover); overflow-wrap: anywhere; overflow: auto; overscroll-behavior: contain; box-sizing: border-box; } +/* A long name (#1049): the dialog keeps its maximum height, its text scrolls inside it and its buttons stay in view under it. */ +.ask[open] { display: flex; flex-direction: column; } +.ask > form { display: flex; flex-direction: column; min-height: 0; } +.ask > form > p { min-height: 0; overflow: auto; } +.ask > form > :is(.ask-buttons, .ask-title, label) { flex: none; } +.ask .ask-note:empty { display: none; } +.ask .ask-note { margin: var(--sp-3) 0 0; font-size: var(--size-small); color: var(--muted); } /* A backdrop honours overscroll-behavior only as a scroll container, hence overflow hidden: a scroll over it never reaches the page. */ .ask::backdrop { background: var(--backdrop); overflow: hidden; overscroll-behavior: contain; } .ask p { margin: 0 0 var(--sp-4); } From fb7d65e87901a921db8b56618fd6ceeabd7abe32 Mon Sep 17 00:00:00 2001 From: Daniel Rispler <danielrispler@gmail.com> Date: Tue, 1 Dec 2026 23:08:02 +0200 Subject: [PATCH 09/11] Docs: the Map view describes #1036's fixes Worker: opencode/deepseek-v4.1-flash-free --- docs/studio/behaviour/map.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/studio/behaviour/map.md b/docs/studio/behaviour/map.md index 69659d4b3..a457d37da 100644 --- a/docs/studio/behaviour/map.md +++ b/docs/studio/behaviour/map.md @@ -346,9 +346,10 @@ The window's Map view (`ui/map.ts`, `server/src/map.rs`) draws a project's map o - **A closed zone's marks** are the ones that would make Daniel open it, rolled up from its parts: the mist when any part would show fog at his effective tiers (thick when any is thick); one session badge, the count of distinct sessions on any of its parts (marked, or with a running subagent), accented when any needs him, its list the popover a part's badge opens, its subagent rows rolled up as Workers' were; the footprint's brackets when the spotlit session's footprint holds any of its parts (firm when any is firm); the broken-law dot and rim when any part has a broken law; a story turn's `turn-lit` ring when the turn lit any of its parts; and pre-flight's dashed frame and word when any predicted or picked part is inside. While a session is spotlit, a closed zone holding any part of its now shows that session's chip in place of its badge, with the chip's line when the home part is inside. A closed zone shows no law diamonds, staleness bands or tier. An open frame carries none of these marks: its parts carry their own, as parts always do, and a part inside behaves as any part (sheet, badge, fog, laws, tier). - **A past commit's map** draws its zones all closed and read-only, with no + or − and nothing saved. - **The camera** (#383). The map area never scrolls: it pans and zooms the world. **Panning**: dragging the empty background pans the view, under an open hand that closes while dragging; dragging a part still moves and saves the part. **Zoom**: a wheel, a two-finger scroll or a trackpad pinch (which the browser reports as a wheel with Ctrl held) over the map zooms around the pointer and never scrolls the page, held between 40 % and 200 %. A wheel's delta is read in pixels whatever its `deltaMode` (a line is 16 px, a page the map area's height); a plain wheel zooms about ×1.16 per 100 px tick (rate 0.0015 a pixel), each event held between ×0.8 and ×1.25, and a pinch keeps its faster rate (0.012 a pixel) (#669). **Fit**: `0`, `studio::FitMap` in the palette, or the quiet Fit button after Pre-flight in the map head, whose hover names its keys from the keymap, puts the whole map in view, centred with a gutter, at no more than 125 %. Each project's view is saved in `map-state.json` beside its positions a moment after it moves, so it survives a restart; a project never moved opens at 100 % with the world's corner at the area's. When a part's sheet opens, the camera pans just enough to show that part whole beside it, once per opening; positions are never written by revealing. A PR brief takes the camera while it plays and gives Daniel's view back, as it found it, when it closes; while it plays, a drag of the background or a zoom does nothing. -- **The left panel** (`ui/panel.ts`, #385). While the view shows, everything Daniel reads beside the map opens in one panel floating over the map's left side, so he never leaves the map to read: a session's story (the story rail itself, moved in; see [The story rail](rail.md)), History, a turn's whole diff, a PR's panel, or Settings. Pressing a session's row in the list, or in a session badge's list on the map, opens its story there, and that session is the spotlit session while it is open; a second press on the same row, or Esc, closes it and selects no session. A subagent's row in a badge's list (a Worker's or a Helper's), or a subagent's line, opens that subagent's log in the panel (#386); closing it selects no session. History opens there from the list's "History · N" and `studio::ShowHistory`; a turn's diff (the evidence line's "more lines" and "Open full diff", or `studio::OpenFullDiff`) opens there widened to at most 780 px and closes the part's sheet, and its Back shows the story again. Settings opens there from a quiet gear at the top bar's end, or `studio::ShowSettings`. A PR's panel (the `pr` kind, a project and a PR number; [PR briefs](pr-briefs.md#the-pr-panel)) opens there from a tray row, the rail's brief row, the session row's brief mark, the history strip's Brief or a part sheet's chapter; a chapter plays on the map beside it and Esc returns to it, and a project switch closes the panel of the project left. Its width is the rail's. The panel and the part's sheet (and the drawer) share one glass, Treatment C's part sheet, in one class, `glass`: a near-opaque surface, an 18 px backdrop blur, a top highlight, a faint 1 px edge, a deep shadow and a 14 px corner, inset 22 px from the map's edges. Neither darkens the map, which stays lit and clickable; a PR brief alone dims the map, and dims both with it. Each slides in 12 px with a fade on Treatment C's ease, at once under reduced motion. Opening or closing one never moves a part: the map keeps the whole stage and the cards float over it, and when the panel or the sheet would cover the part in focus (the sheet's part, the parts of the spotlit session's now) the camera pans just enough, never past what the band between them holds. Below 1007 px only one is open: opening the sheet closes the panel, and the other way round. The Ready for review tray sits at the map's foot on the left, in the same glass, since the map pans under it (#571); while the panel is open it is hidden, at every width, so it never lands in the middle of the map, and it is back when the panel closes (#666). The panel's × (named "Close") sits on its views' header line, beside the story's "⋯" and level with the History, Settings and diff titles (#571). -- **Esc** peels the layers, in order: an overlay (the pre-flight), a session badge's list, a drawer, a PR brief's not-confirmed popover, a PR brief (closing it keeps its step, and leaves its PR panel open), a scrubbed commit (back to now), a part's or a zone's sheet, ▶ replay in the session panel (#1026: it stops and the panel stays), the left panel (a PR panel included). On the bare map it does nothing: the map is never left. While a hint is open, Esc closes the hint alone and peels nothing (spec #582). -- **Pre-flight** (`server/src/pre_flight.rs`, `understanding/src/pre_flight.rs`, `ui/map-pre-flight.ts`; #394 of spec #378). Before starting work, Daniel sees which parts it will likely cross. The map's head has a quiet Pre-flight button, and the palette has `studio::PreFlight`; either opens an overlay over the map in the glass, and pressing it again closes it. A pointer press outside the overlay and its button (on the map, a plate, the tray or the list) closes it too while it shows its inputs or a framed pre-flight; while Daniel picks parts by hand, or waits on the writer, such a press leaves it open, so a stray press loses neither his picks nor the prediction (#666). Its inputs are an open issue (the project's open issues as `gh issue list` gives them), one or two lines of free text, or parts picked by hand. For an issue or text, the server asks the PR briefs' writer, which has no tools (`claude -p`, model `prBriefs.model`), which part ids the work will cross; the issue's title and body go only to that writer, fenced as text to read, never to a background run. Ids not on the map are dropped; a failed call, a reply that does not read or one that names no part on the map shows the hand picker with why. The parts are framed on the map with a dashed outline and the word *predicted* (*picked* for parts picked by hand), and the overlay lists each with its laws on trust, its fog and its staleness band (the map's own, below). Clear takes the pre-flight off the map. One pre-flight is kept per project, in the data folder's `pre-flight-by-project/`, and the Map view's payload carries it (`pre_flight`). When a PR's brief is written and the project's pre-flight is of an issue, the server notes every issue the PR closes (not only the lowest, which the facts still read as the spec) with each one's parent (`gh issue view --json parent`); a brief whose PR closes the pre-flighted issue, or a sub-issue of it, opens with "You expected X, Y; it touched X, Z", where touched is the parts the brief's shape found (those that fog and the ones only mentioned). A pre-flight from free text or hand-picked parts has no issue, so no brief carries its line. The overlay closes with Esc before every other layer, and its field is a text field, so single-key shortcuts do not fire while Daniel types in it. A past commit's map shows no pre-flight. +- **The left panel** (`ui/panel.ts`, #385). While the view shows, everything Daniel reads beside the map opens in one panel floating over the map's left side, so he never leaves the map to read: a session's story (the story rail itself, moved in; see [The story rail](rail.md)), History, a turn's whole diff, a PR's panel, or Settings. Pressing a session's row in the list, or in a session badge's list on the map, opens its story there, and that session is the spotlit session while it is open; a second press on the same row, or Esc, closes it and selects no session. A subagent's row in a badge's list (a Worker's or a Helper's), or a subagent's line, opens that subagent's log in the panel (#386); closing it selects no session. History opens there from the list's "History · N" and `studio::ShowHistory`; a turn's diff (the evidence line's "more lines" and "Open full diff", or `studio::OpenFullDiff`) opens there widened to at most 780 px and closes the part's sheet, and its Back shows the story again. Settings opens there from a quiet gear at the top bar's end, or `studio::ShowSettings`. A PR's panel (the `pr` kind, a project and a PR number; [PR briefs](pr-briefs.md#the-pr-panel)) opens there from a tray row, the rail's brief row, the session row's brief mark, the history strip's Brief or a part sheet's chapter; a chapter plays on the map beside it and Esc returns to it, and a project switch closes the panel of the project left. Its width is the rail's. The panel and the part's sheet (and the drawer) share one glass, Treatment C's part sheet, in one class, `glass`: a near-opaque surface, an 18 px backdrop blur, a top highlight, a faint 1 px edge, a deep shadow and a 14 px corner, inset 22 px from the map's edges. Neither darkens the map, which stays lit and clickable; a PR brief alone dims the map, and dims both with it. Each slides in 12 px with a fade on Treatment C's ease, at once under reduced motion. Opening or closing one never moves a part: the map keeps the whole stage and the cards float over it, and when the panel or the sheet would cover the part in focus (the sheet's part, the parts of the spotlit session's now) the camera pans just enough, never past what the band between them holds. Below 1007 px only one is open: opening the sheet closes the panel, and the other way round. The Ready for review tray sits at the map's foot on the left, in the same glass, since the map pans under it (#571); while the panel is open it is hidden, at every width, so it never lands in the middle of the map, and it is back when the panel closes (#666). The panel's × (named "Close") sits on its views' header line, beside the story's "⋯" and level with the History, Settings and diff titles (#571). A press outside the panel closes it (light dismiss), unless it lands in the panel or in what works beside it: the side area and its tray, a brief or another layer over the map, a toast, the list, a hint, a popover, a dialog, the top bar or the map's head. Where the press landed is read from the event's path as it was dispatched, so a press inside the panel never closes it, even one that redraws the panel under it, as pressing a History row does when its story opens (#1044). +- **Hints** (#1044). Every hint on the page, the map's own included, closes when no trigger on the page names it: one whose control the page dropped closes within a third of a second, never left in the window's corner, while a control a redraw kept keeps its open hint, and a control a view sets aside and puts back keeps its hint, closed while it was away. [The session list](sessions.md) has the rule. +- **Esc** peels the layers, in order: an overlay (the pre-flight), a session badge's list, a drawer, a PR brief's not-confirmed popover, a PR brief (closing it keeps its step, and leaves its PR panel open), a scrubbed commit (back to now), a part's or a zone's sheet, ▶ replay in the session panel (#1026: it stops and the panel stays), the left panel (a PR panel included). On the bare map it does nothing: the map is never left. While a hint is open, Esc closes the hint alone and peels nothing (spec #582). The session list is a layer only while it is drawn over the map: the first Esc closes the open list there, even with the pointer resting on it, and in the full layout, where the list is its own column, Esc goes straight to the map's layers (#1047). +- **Pre-flight** (`server/src/pre_flight.rs`, `understanding/src/pre_flight.rs`, `ui/map-pre-flight.ts`; #394 of spec #378). Before starting work, Daniel sees which parts it will likely cross. The map's head has a quiet Pre-flight button, and the palette has `studio::PreFlight`; either opens an overlay over the map in the glass, and pressing it again closes it. A pointer press outside the overlay and its button (on the map, a plate, the tray or the list) closes it too while it shows its inputs or a framed pre-flight; while Daniel picks parts by hand, or waits on the writer, such a press leaves it open, so a stray press loses neither his picks nor the prediction (#666). Its inputs are an open issue (the project's open issues as `gh issue list` gives them), one or two lines of free text, or parts picked by hand. It says "Reading the open issues…" while they load, and when they cannot be read it says "Couldn't read the open issues: <reason>", the reason's first line (for a `gh` that is not logged in, "To get started with GitHub CLI, run: gh auth login"), never "No open issues."; its text box and Pick parts by hand work as they do otherwise (#1046). For an issue or text, the server asks the PR briefs' writer, which has no tools (`claude -p`, model `prBriefs.model`), which part ids the work will cross; the issue's title and body go only to that writer, fenced as text to read, never to a background run. Ids not on the map are dropped; a failed call, a reply that does not read or one that names no part on the map shows the hand picker with why. The parts are framed on the map with a dashed outline and the word *predicted* (*picked* for parts picked by hand), and the overlay lists each with its laws on trust, its fog and its staleness band (the map's own, below). Clear takes the pre-flight off the map. One pre-flight is kept per project, in the data folder's `pre-flight-by-project/`, and the Map view's payload carries it (`pre_flight`). When a PR's brief is written and the project's pre-flight is of an issue, the server notes every issue the PR closes (not only the lowest, which the facts still read as the spec) with each one's parent (`gh issue view --json parent`); a brief whose PR closes the pre-flighted issue, or a sub-issue of it, opens with "You expected X, Y; it touched X, Z", where touched is the parts the brief's shape found (those that fog and the ones only mentioned). A pre-flight from free text or hand-picked parts has no issue, so no brief carries its line. The overlay closes with Esc before every other layer, and its field is a text field, so single-key shortcuts do not fire while Daniel types in it. A past commit's map shows no pre-flight. - **PR briefs** (`server/src/pr_briefs.rs`, `ui/map-brief.ts`; the one doc for them is [PR briefs](pr-briefs.md)). When a lookup finds a PR ready the server writes its brief through `write_pr_brief` (always with `claude -p`, whatever `summaries.writer` says; model: `prBriefs.model` in `settings.json`, Opus by default, read on each write, the writer's and the claim check's alike) and stores it per PR and head under the data folder's `pr-briefs-by-project/`. A new head marks the stored brief stale; it is written again when Daniel opens it, or when two lookups in a row see the same head. Opening a tray row opens the PR's panel, whose chapter, Continue reading or Ratify plays the brief as a single story or one chapter. A PR that would fog more than two parts has one tray row, whose panel lists its chapters; each chapter plays on its own and resumes at the step left, its frame holds every part its behaviour crosses, the overview (when there is one) plays before the first chapter opened and once per brief, and Also touched shows on the last step of the last chapter (the PR's other changed files in groups by kind, each with a See the code of its files; an older brief's writer lines instead): the zones holding any part it lights, either end of a hop's link, or any Map diff mark are opened for the brief, unsaved (framing runs after they open; a zone only the brief holds open has no − while it plays, one Daniel saved open keeps its −, and closing the brief gives back the open set it found, as it gives back the camera), and every link of its steps' hops, and every link the Map diff tags, is drawn exactly between its parts as a line carrying its own id, `data-from`, tag and part-keyed `data-mark` (a hop inside one zone included, carrying the diamonds of its link's laws, as it has no line at rest that would); the light runs the step's links at one speed and parts light as it arrives, the camera frames the parts the brief lights, the panel keeps its tallest step's height and crossfades, a figure (`states`, `sequence`, `compare`) is drawn by code from the writer's labels, citations sit in quiet type, a brief written from less than its full facts shows a "Partial facts · N" chip listing what it lacked, and an item the checks left flagged says "not confirmed from the facts", a mark whose popover lists why. A step's "See the code" opens the changed files of the parts it lights, with their diffs, in the drawer above the brief (`pr_diff`; every file on the Ratify or last step; what the step quoted when git cannot give them). Opening a brief returns a scrubbed map to now; closing it with Esc or Leave keeps the step it was at, and finishing it starts it over. Motion respects reduced motion, where the whole step lights at once. A check of kind `pick` is answered in the panel (pick, take it back, Check); an `order` check shows its question until its map answer is built. - **Ready for review** (`server/src/prs.rs`, `ui/map-tray.ts`). The server asks `gh pr view <branch> --json number,title,isDraft,state,headRefOid,body,closingIssuesReferences` for each listed session's branch: at once when a turn ends, and when the page gains focus or the Map view opens through one cooldown of a minute per repository with an in-flight guard; never on a timer. A PR is ready when it is open and not a draft; its head is kept in memory and replaced by a later lookup. The tray at the map's foot lists the project's ready PRs: each PR is one row, a button that opens its PR panel (#957), whatever its chapters; a PR whose brief is being written ahead has no row until it lands, and one Daniel asked for from the panel keeps "writing the brief…" (the map stays usable); one without a brief opens, and opening writes it in the background, the panel saying "Writing the brief…" until it lands and fills in; one whose write failed says so and opens to try again; after a push, a stored brief's row says why it is what it is: its read carried over, or it was rewritten ([Since you read](pr-briefs.md#ready-detection)). At start only the ready PRs whose head moved within `briefBackfill.hours` (2 by default; the older `catchUp.hours` is still read) get their brief written or a stale one rewritten, the newest head first and at most 3; a PR that becomes ready while `plotkeeper` runs is written at once; any other is written when opened. Any PR number found still names its session ("PR #N"). A ready PR whose touched parts would not fog at Daniel's effective tiers (Core always, Interface-only when the map's diff names the part, Black box never) gets no brief: the lookup builds its facts, finds no required part, writes nothing, does not gather it again at the same head, and it has no tray row. - **Ratifying** (`server/src/ratify.rs`, `ui/ratify.ts`, `ui/map-ratify.ts`). Daniel accepts or overturns what a PR changed on the map and what its agent decided; it never blocks anything, and the merged map is in effect at once. An item is a map change (a part, zone, outside actor, link, law or flow added, changed or removed, read by code from the map's diff; a part's `tier` never counts; its `zone` does, below) keyed by (PR, kind, map id), or a decision the agent declared, from the brief's `decisions`, keyed by (PR, decision id). Decision ids come from the writer entry and survive a reworded rewrite; a decided item a rewrite no longer holds keeps its record and is still listed. The state is `ratify.json` in the data folder, per project: when the project's first run was (`since`) and a record per decided item (`accepted`, `overturned`, or `pending`, with the time and what the item said). A reader ignores what it does not know. No record means ratified for anything that landed on or before `since`, and "not yet ratified" for anything after; a `pending` record marks an item not yet ratified whenever it landed, which is how Daniel's own file keeps the laws #295 left open, edited once by hand (no product logic names them). The brief ends with a **Ratify** step listing its items (nothing is added when all are ratified), each with Accept and Overturn. A part's or a link's row carries a **detail**, old beside new, which the step shows under the row as "Was" and "Now" lines (no colour), only for what changed: for a part, its name, caption ("Caption", #643, so an Edited part on the Map diff always has a line saying what changed), purpose and held items, matched by name (a name held twice, by its first, second… time), each with its `paths` change, and the patterns its own `paths` gained and lost, and a "Zone" line naming the zone it was in and the one it is in now when they differ (a part that moved zone is an Edited part, and a renamed zone is the zone's change, not the part's); for a zone, its name, caption and purpose; for a link, its kind and reason, and "Direction" (`from to to`) when its ends swapped. An added item shows its every line with nothing before, a removed one with nothing after. Both maps are converted first (`system_map::convert`), so a version 1 side's `description` shows as the old purpose. An `import` link the PR adds carries its **evidence** (#499): the import sites behind it, read from the PR's head in commit mode when the brief was written and stored on the brief (`link_evidence`), never extracted live, and shown only while the open PR's head is the brief's; its second line shows one site and "(+N imports across M files)", the site opening its code from the head in the drawer, numbered with its line marked (`ratify_site`, not the diff), the count listing every site there, each opening its code. A removed link shows none. The part sheet marks a law row, and a link's row in "Talks to", "Not yet ratified" with the same two buttons, for a map item that landed after the first run with no record. **Overturn** records the decision and copies a self-contained prompt to the clipboard (the PR number, its branch while the PR is open, the item's id and its wording, and for a part its new purpose and the names of its held items, for a link its ends, kind and reason, and for an added link its import sites; `navigator.clipboard.writeText()`), saying "Prompt copied, paste it into your agent"; when the clipboard refuses, the prompt shows in a small box with a Copy button. The note shows only on the sheet or the brief that holds the overturned item. Nothing is typed into a session. @@ -357,7 +358,7 @@ The window's Map view (`ui/map.ts`, `server/src/map.rs`) draws a project's map o - **Fog** (`server/src/fog.rs`). The first time the view opens a project, the server records the default branch's tip, so every part starts clear. After that it walks the new first-parent commits and files each part's changes in `map-state.json`: **thick** when a law on the part, a link at it (its id or ends), a flow through it or its `paths` changed, or the part was added; **thin** when files it owns changed (placed by the union of the commit's map and its parent's, so a moved file touches both parts) or only its name, caption, purpose, held items (their paths included) or `zone` did, or the `kind` or `reason` of a link at it; nothing for `ignored` or `tier`. A part's `zone` changing is thin, like its other words, and is named "zone" in its why; a zone's own words fog no part. A removed part leaves the live map. Each entry keeps its commit, its strength, the PR its subject names (`Title (#N)`, else none) and why it fogs the part (#495, `fog::Change`): "added", "paths", `law <id>`, `link <id>` and `flow <id>` for each law, link or flow whose say on the part changed (a link's kind or reason too), each of the part's own words that changed (`name`, `caption`, `purpose`, `holds`), and the count of its files changed (`3 files`). An entry filed before #495 has neither PR nor why. What shows is by Daniel's effective tier: a Black box part never, an Interface-only part only thick. Strength is never a count. **Reading a brief clears it** (#342): a chapter is complete when its last step was seen (`watchSeen`) and its check was answered, right or wrong, when it holds one; a single story is one chapter over all its lit parts. Once every chapter of a PR's brief that lights a part is complete, that PR's entries leave that part at once and the mist lifts; a part no chapter lights keeps its fog, and leaving mid-chapter clears nothing. Completion is kept as "read at head X" per chapter in `map-state.json` (`fog.reads`). A PR read before it merges files fog at merge only for the parts touched by the diff from X to the squash commit, limited to the paths the squash commit itself changes (so main merged into the branch fogs nothing), at the strength that diff earns; none when nothing was pushed after the read. A read carried over to a new head (a pure rebase, or a push that fogs nothing; [Since you read](pr-briefs.md#ready-detection)) counts as read at that head, so fog at merge runs from it and a rebase does not pull main's edits into the PR's fog. `Clear fog` on its sheet still clears a whole part, and so does reading its [part catch-up](pr-briefs.md#part-catch-ups) to the end, for the entries it covered. - **Mist.** A fogged plate has a cool-grey mist around it (#455): dense beyond the plate's edges and at its rim, thinning to nothing over its name, caption and marks, so they read at full contrast (4.5:1, measured by snap's contrast pass); the caption is not dimmed. Thin and thick still read apart: thick is denser, with a rim and a slow drift. `Clear fog` on the part's sheet clears that part's fog and lifts the mist (no motion under reduced motion), and is logged as its own event (Stop rules). - **The part sheet** (`ui/map-sheet.ts`) opens over the map's top right, in the left panel's glass, on a click that was not a drag (a press on a session badge opens its list instead, and a press in that list never reaches the plate). First, under its name and caption, the **status row** (spec #1011, #1014): the tier as a pressable `Core ▾` (its hint says what the tier is; `aria-expanded` says whether the three tier buttons show), which opens them in place under the row, with the selected tier's meaning under them while explanations are on, and every tier button's hint its own meaning; the open state is kept across the sheet's draws for the same part (a tier press, a `?` flip, a map reload) and starts closed on another part's sheet. Beside the tier, the CI chip, only where the sheet shows CI (a part with a check-backed law, or one a run broke): `✓ CI passing`, or `CI` and the run's word (failing when a run broke another part's law, failed, not read), its hint the run's whole line (so "the law tests did not run", "its log cannot be read" and "for an earlier commit" stay on the sheet), and a press opens the CI drawer when there is a run to show. When a run on main breaks one of this part's laws the chip is instead one red row filling the rest of the line, exactly `✕ A law's test failed on main`, naming no law, with a quiet `Log` that opens the drawer; it stays on the tier's line at 360 px. On a past commit's sheet the tier is plain text and there is no CI chip. Then the catch-up card (spec #1011, #1015). A fogged part's is the **Decide card**, which answers "do you already know this?": the count (`N changes since you caught up`, `changesLine`); one muted source line (`fogSource`, `ui/map-model.ts`): `Latest thick change: #PR · <why>` (or `Latest change:` when no entry is thick; the short commit when the entry has no PR), `<why>` being the entry's why list with the catch-up step's own law written "the law below" and first; once the waiting [part catch-up](pr-briefs.md#part-catch-ups) is stored, its title and a `Must stay true` row with the headline of its Must stay true step (no row when the outline has no such step), carrying the law's own mark (filled when a check backs it, hollow on trust) only when the step names a law that is on this part; and the buttons: the part catch-up as a light primary (`Catch up · N steps`), or the one PR brief chapter that lights it, and `Clear fog` (hint "Clears this part's fog without reading what changed"), which lifts the mist without reading. Before, Now and Where are left to the catch-up reader. While a catch-up is written or failed, or the main button is a PR brief chapter, the card has the count, the source line and the buttons (and the stage line or "Read the one you have"), with no title or law row. A part with no fog's is one row: `Caught up`, then ` · ` and the staleness line when the part has a band (a fogged part shows none: catching up or clearing the fog clears the band), the Interface-only or Black box line under it, and the Refresher on the right (below). A past commit's sheet has no card. Then the purpose, whole, muted and small, with no clamp and no More (it draws a backtick span as code; a plate's hover text shows no backtick); a zone's sheet draws its purpose the same way. Then the sections, each a fold that opens on its own and shows a short value beside its title (none for History, whose rows load later), in this order (the four folds, and This session here while a story is open): **Laws** (backed by a check or on trust), **Talks to** (every link at either end of the part, in the map's order: an arrow, → when the link runs from this part and ← when it runs to it, the other end, the link's kind and its reason when it has one; the sheet has no other list of links; "No link at this part" when there is none), **This session here** (below), **Holds** (the held items, each its name, its sentence and its key files, its `paths` as written, each file a link that opens it in Daniel's editor, the main checkout's copy (`open_in_editor` with the project and no root; spec #873, ticket #883; underlined, its ↗ always shown), while a folder (a path ending in `/`) stays plain text; an item without paths is a note, its name in italics followed by "· note", then its sentence, so it never reads as a heading, #525; none when the part holds nothing), and **History** (the history strip, below). The tier (Core, Interface-only, Black box) is changed in place from the status row and kept in `map-state.json`; there is no Tier or CI fold, no chips row and no marks list. The folds Daniel opened stay open in this browser (`map-sheet-folds`, beside the sheet's width); a browser that keeps nothing starts with all folded. The first Esc closes it; the next closes the left panel, if open. × (named "Close") closes it too, and so does a click on the empty map (#445): a press on the background that moves 4 px or less between down and up closes the sheet and its drawer, while one that moves further pans and keeps them. A click on another part switches the sheet to that part. The not placed line, the sheet, the drawer under it and the background runs are one column at most the map's height less its insets, the line first, so it keeps the map's top right and an open sheet never pushes it down over a part (#466). The not placed line is one line of fixed height, and while a sheet is open its slot keeps that height even with no line in it, so sessions starting and stopping to need Daniel never move the sheet (#472, #694; in the event log the list changed about every 30 s while agents ran). The column scrolls as one: the sheet and the drawer never scroll on their own, except the two that keep a short scroll of their own: a drawer's code block and the History strip (which can hold thousands of pixels of commits); no drawer text gives the column a sideways scroll, and a scroll past its end never moves the map. The sheet is 360 px wide at first; dragging its left edge resizes it between 300 px and half the map, and so do the left and right arrow keys while that edge has the focus. The width is kept in this browser, and a double-click on the edge puts it back to 360 px. **The sheet explains itself** (spec #520, #522): while the page-wide `explanations` setting is on (the default), each fold (Laws, Talks to, This session here, Holds, History) has one muted line first in its body, shown when it is open; the selected tier's meaning sits under the tier buttons when they are open, and every tier button's hint is its meaning; in Talks to, a link kind's line follows only the first link of that kind, and "Not yet ratified"'s only the first unratified link. The catch-up card has no explanation line. Each fold's summary and the selected tier button carry `aria-describedby` to their line; while off, no line is drawn and no attribute points at one. A `?` toggle beside the × (named "Explanations", with `aria-pressed`; hint "Hide explanations" or "Show explanations"; filled when on, a muted ring when off) flips the setting through the server's settings write (`set_explanations`), and so does the palette's `studio::ToggleExplanations`; the open sheet draws again at once, and a `?` that had the focus keeps it. A flip while a write is in flight waits for its reply, so a double click ends where it started and no write is refused as stale. Every text is in `ui/explanations.ts`, worded to "you", at most 12 words each. **This session here** (spec #549, #561): while a session's story is open in the left panel beside the sheet, a fold, third after Laws and Talks to, lists the open session's turns of the last 7 days (the page's cut: a turn's end, or its start if it never ended) that changed the part, Workers' files included, newest first, each its number in the story (from 1), its Headline (else its prompt's first line) and its age (minutes, hours, then days). With none it says "No turn of this session changed this part in the last 7 days", but nothing while `map_place` has yet to answer for a file of those turns; the section, and the newest turn's "Show on map", follow a new answer when it lands, and "Turns older than 7 days aren't listed" shows under it only when the session has older turns. Pressing a row scrolls the story to the turn, unfolds it, moves the focus to its line and flashes its outline once in the warm ring (held still for that second under reduced motion), then pans the turn's parts clear of the panel and the sheet (`revealParts`). The section follows the story as it changes, keeps a focused row's focus, and is not drawn for a subagent's view or on a past commit's sheet. Below 1007 px the sheet takes the panel's place, so the section never shows there, and no session is remembered for it. -- **Keyboard** (#460). Each plate holds an open button over its name and caption, named by them, beside its session badge rather than around it. Tab reaches a part's button and then its badge (Enter or Space opens the badge's list and moves the focus into it; Esc closes it and puts the focus back on the badge), the parts in the map's reading order (top to bottom, then left to right; a plate within half a plate's height of a row's highest plate reads on that row; `readingOrder` in `ui/map-model.ts`), set when the map draws; a redraw keeps the focus on the same part's button, or on its new badge, also when the badges come after the map (a new commit asks `map_place` again); a focused badge that a spotlit chip replaces (its list's row opened that session's story) leaves the focus on its part's button. Enter or Space opens the part's sheet, as a click does, and the page's focus ring marks the part; in a brief's order question the same press counts as a tap. Zones take part in the same order by their spot: a closed zone's Tab stops are its sheet button, then its +, then its badge; an open zone's are its header's sheet button, then its −, with its parts after the header in their own reading order. Enter or Space on the + or − opens or folds the zone (and saves it), and on the sheet button opens its sheet. Actors take no focus, since a click on them does nothing. Plates cannot be moved from the keyboard, nor the camera panned or zoomed: placement is Daniel's own arrangement, and every action the map offers stays reachable without it (#452). +- **Keyboard** (#460). Each plate holds an open button over its name and caption, named by them, beside its session badge rather than around it. Tab reaches a part's button and then its badge (Enter or Space opens the badge's list and moves the focus into it; Esc closes it and puts the focus back on the badge), the parts in the map's reading order (top to bottom, then left to right; a plate within half a plate's height of a row's highest plate reads on that row; `readingOrder` in `ui/map-model.ts`), set when the map draws; a redraw keeps the focus on the same part's button, or on its new badge, also when the badges come after the map (a new commit asks `map_place` again); a focused badge that a spotlit chip replaces (its list's row opened that session's story) leaves the focus on its part's button; a badge list that closes because its badge went away, as a redraw drops it when no session is on the part any more, sends a focus that was in the list, or left on the page's body, to that plate's open button, the part's or the closed zone's sheet button, and leaves the focus alone after a project switch (#1045). Enter or Space opens the part's sheet, as a click does, and the page's focus ring marks the part; in a brief's order question the same press counts as a tap. Zones take part in the same order by their spot: a closed zone's Tab stops are its sheet button, then its +, then its badge; an open zone's are its header's sheet button, then its −, with its parts after the header in their own reading order. Enter or Space on the + or − opens or folds the zone (and saves it), and on the sheet button opens its sheet. Actors take no focus, since a click on them does nothing. Plates cannot be moved from the keyboard, nor the camera panned or zoomed: placement is Daniel's own arrangement, and every action the map offers stays reachable without it (#452). - **Staleness bands** (`server/src/staleness.rs`, `ui/map-stale.ts`, #392). A part whose effective tier is Core carries a mild band along its plate's foot, in the muted text tone and firmer with each band, once Daniel has not engaged with it for 3 weeks (band 1), 6 (band 2) or 12 (band 3); its plate's hint adds "You last engaged with this part 3 weeks or more ago" (6, 12), and its sheet's `Caught up` row gives the band's line after ` · `, with the UTC date of the last engagement, "6 weeks or more since you last engaged with this part, on <date>", or, with no engagement since tracking began (the baseline, or the part's first commit when later), "6 weeks or more: not engaged since tracking began on <date>". The server words that line (`staleness::lines`, `MapState.stale_why`). Interface-only and Black box parts never band; a past commit's map shows none. Staleness is the time since his last entered activity on the part, never since its last commit: a brief chapter read to its end that lights it (read from `fog.reads`, so a chapter read before staleness shipped counts, and kept in `staleness.parts` too as it is read, since a brief rewritten to light its parts differently clears its `fog.reads`), a part catch-up, the refresher, or `Clear fog`. Any of them clears the band at once. A part's baseline is the first time this build showed the project's map (`staleness.since` in `map-state.json`) or, when later, the committer time of the first first-parent commit on the default branch whose `system-map.json` lists the part's id, so nothing is stale on day one and a part added to the map, a split's new parts included, starts with no band; a newer activity beats either. That time is read from git's history of the map file once per project and part while the server runs and is never stored (`staleness::births`, `history::part_births`); the other activities are kept there per part (`staleness.parts`, the last one's time and kind). The bands show on the map, on the part's sheet and at pre-flight only (`MapState.stale`, the band of each stale part), never anywhere else. - **The refresher** (#392). A part's sheet with no fog offers **Refresher** in its one row, on the right of "Caught up": the part as the map has it now, drawn by code from the map file at once, never a writer call. The sheet already shows its caption, purpose, held items, laws with their backing and links; the refresher opens in the row's place and adds the flows through the part (each flow's hops on a link at the part, in order), or "No flow of the map crosses this part". Entering it is an activity on the part (`map_refresher`), so its band clears, and is logged (Stop rules). - **The header's dot.** A project's header in the session list carries one quiet dot, with no count, while a part whose effective tier is Core is fogged, a law is broken (below) or a PR brief is waiting (a ready PR of the project has a stored brief, as `pr_briefs.rs` keeps them; it counts as waiting until the PR is no longer ready); its hover names which. The page asks the server (`map_marks`) when the saved project list changes and when the page gains focus, never on a timer. From 3ae5bad2c6efb8a2655273329c1041948aaad793 Mon Sep 17 00:00:00 2001 From: Daniel Rispler <danielrispler@gmail.com> Date: Tue, 1 Dec 2026 23:35:50 +0200 Subject: [PATCH 10/11] Studio: the final review's fixes to the four root causes (#1036) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - A hover hint closes when its trigger is replaced by a new one with the same key, not only when no trigger names it; the #1044 hint tests are one table, with rows for that case and for an interestfor hint closed by the prune its toggle queues. - The connection line gives way last in the top bar, and the bar's gaps tighten at phone width, so the retrying line keeps "Lost connection…" at 390 px; the top-bar fixture checks it. - An unreachable error drawn before the connection line showed goes when the stream's state changes. - The rename dialog trims as Rust's str::trim does (Unicode White_Space) before it counts; renameCap is a table with trim rows, and the Rust table gains a trim-then-count row. - Pre-flight's failed read goes through issuesOf, which the node test drives; permissionCommand checks the description sits right under the command. - UNREACHABLE lives in transport.ts; docs follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CVqACafozqqdDZevv65PCa --- docs/studio/behaviour/map.md | 4 +- docs/studio/behaviour/plotkeeper.md | 1 + docs/studio/behaviour/sessions.md | 4 +- scripts/snap/fixtures-page.ts | 64 +++++++++++---- server/src/session_view/tests.rs | 9 +- ui/dom.ts | 9 +- ui/main.ts | 4 +- ui/map-pre-flight.ts | 21 +++-- ui/notice.ts | 15 +++- ui/story.ts | 7 +- ui/style.css | 9 +- ui/tests/hint-redraw.test.mjs | 123 ++++++++++++++-------------- ui/tests/map-pre-flight.test.mjs | 10 ++- ui/tests/notice.test.mjs | 20 ++++- ui/transport.ts | 7 +- 15 files changed, 196 insertions(+), 111 deletions(-) diff --git a/docs/studio/behaviour/map.md b/docs/studio/behaviour/map.md index a457d37da..3a0f98c5e 100644 --- a/docs/studio/behaviour/map.md +++ b/docs/studio/behaviour/map.md @@ -347,9 +347,9 @@ The window's Map view (`ui/map.ts`, `server/src/map.rs`) draws a project's map o - **A past commit's map** draws its zones all closed and read-only, with no + or − and nothing saved. - **The camera** (#383). The map area never scrolls: it pans and zooms the world. **Panning**: dragging the empty background pans the view, under an open hand that closes while dragging; dragging a part still moves and saves the part. **Zoom**: a wheel, a two-finger scroll or a trackpad pinch (which the browser reports as a wheel with Ctrl held) over the map zooms around the pointer and never scrolls the page, held between 40 % and 200 %. A wheel's delta is read in pixels whatever its `deltaMode` (a line is 16 px, a page the map area's height); a plain wheel zooms about ×1.16 per 100 px tick (rate 0.0015 a pixel), each event held between ×0.8 and ×1.25, and a pinch keeps its faster rate (0.012 a pixel) (#669). **Fit**: `0`, `studio::FitMap` in the palette, or the quiet Fit button after Pre-flight in the map head, whose hover names its keys from the keymap, puts the whole map in view, centred with a gutter, at no more than 125 %. Each project's view is saved in `map-state.json` beside its positions a moment after it moves, so it survives a restart; a project never moved opens at 100 % with the world's corner at the area's. When a part's sheet opens, the camera pans just enough to show that part whole beside it, once per opening; positions are never written by revealing. A PR brief takes the camera while it plays and gives Daniel's view back, as it found it, when it closes; while it plays, a drag of the background or a zoom does nothing. - **The left panel** (`ui/panel.ts`, #385). While the view shows, everything Daniel reads beside the map opens in one panel floating over the map's left side, so he never leaves the map to read: a session's story (the story rail itself, moved in; see [The story rail](rail.md)), History, a turn's whole diff, a PR's panel, or Settings. Pressing a session's row in the list, or in a session badge's list on the map, opens its story there, and that session is the spotlit session while it is open; a second press on the same row, or Esc, closes it and selects no session. A subagent's row in a badge's list (a Worker's or a Helper's), or a subagent's line, opens that subagent's log in the panel (#386); closing it selects no session. History opens there from the list's "History · N" and `studio::ShowHistory`; a turn's diff (the evidence line's "more lines" and "Open full diff", or `studio::OpenFullDiff`) opens there widened to at most 780 px and closes the part's sheet, and its Back shows the story again. Settings opens there from a quiet gear at the top bar's end, or `studio::ShowSettings`. A PR's panel (the `pr` kind, a project and a PR number; [PR briefs](pr-briefs.md#the-pr-panel)) opens there from a tray row, the rail's brief row, the session row's brief mark, the history strip's Brief or a part sheet's chapter; a chapter plays on the map beside it and Esc returns to it, and a project switch closes the panel of the project left. Its width is the rail's. The panel and the part's sheet (and the drawer) share one glass, Treatment C's part sheet, in one class, `glass`: a near-opaque surface, an 18 px backdrop blur, a top highlight, a faint 1 px edge, a deep shadow and a 14 px corner, inset 22 px from the map's edges. Neither darkens the map, which stays lit and clickable; a PR brief alone dims the map, and dims both with it. Each slides in 12 px with a fade on Treatment C's ease, at once under reduced motion. Opening or closing one never moves a part: the map keeps the whole stage and the cards float over it, and when the panel or the sheet would cover the part in focus (the sheet's part, the parts of the spotlit session's now) the camera pans just enough, never past what the band between them holds. Below 1007 px only one is open: opening the sheet closes the panel, and the other way round. The Ready for review tray sits at the map's foot on the left, in the same glass, since the map pans under it (#571); while the panel is open it is hidden, at every width, so it never lands in the middle of the map, and it is back when the panel closes (#666). The panel's × (named "Close") sits on its views' header line, beside the story's "⋯" and level with the History, Settings and diff titles (#571). A press outside the panel closes it (light dismiss), unless it lands in the panel or in what works beside it: the side area and its tray, a brief or another layer over the map, a toast, the list, a hint, a popover, a dialog, the top bar or the map's head. Where the press landed is read from the event's path as it was dispatched, so a press inside the panel never closes it, even one that redraws the panel under it, as pressing a History row does when its story opens (#1044). -- **Hints** (#1044). Every hint on the page, the map's own included, closes when no trigger on the page names it: one whose control the page dropped closes within a third of a second, never left in the window's corner, while a control a redraw kept keeps its open hint, and a control a view sets aside and puts back keeps its hint, closed while it was away. [The session list](sessions.md) has the rule. +- **Hints** (#1044). Every hint on the page, the map's own included, closes when no trigger on the page names it: one whose control the page dropped closes within a third of a second, never left in the window's corner, while a control a redraw kept keeps its open hint, and a control a view sets aside and puts back keeps its hint, closed while it was away. A hover hint whose control a redraw replaced with a new one of the same key closes too. [The session list](sessions.md) has the rule. - **Esc** peels the layers, in order: an overlay (the pre-flight), a session badge's list, a drawer, a PR brief's not-confirmed popover, a PR brief (closing it keeps its step, and leaves its PR panel open), a scrubbed commit (back to now), a part's or a zone's sheet, ▶ replay in the session panel (#1026: it stops and the panel stays), the left panel (a PR panel included). On the bare map it does nothing: the map is never left. While a hint is open, Esc closes the hint alone and peels nothing (spec #582). The session list is a layer only while it is drawn over the map: the first Esc closes the open list there, even with the pointer resting on it, and in the full layout, where the list is its own column, Esc goes straight to the map's layers (#1047). -- **Pre-flight** (`server/src/pre_flight.rs`, `understanding/src/pre_flight.rs`, `ui/map-pre-flight.ts`; #394 of spec #378). Before starting work, Daniel sees which parts it will likely cross. The map's head has a quiet Pre-flight button, and the palette has `studio::PreFlight`; either opens an overlay over the map in the glass, and pressing it again closes it. A pointer press outside the overlay and its button (on the map, a plate, the tray or the list) closes it too while it shows its inputs or a framed pre-flight; while Daniel picks parts by hand, or waits on the writer, such a press leaves it open, so a stray press loses neither his picks nor the prediction (#666). Its inputs are an open issue (the project's open issues as `gh issue list` gives them), one or two lines of free text, or parts picked by hand. It says "Reading the open issues…" while they load, and when they cannot be read it says "Couldn't read the open issues: <reason>", the reason's first line (for a `gh` that is not logged in, "To get started with GitHub CLI, run: gh auth login"), never "No open issues."; its text box and Pick parts by hand work as they do otherwise (#1046). For an issue or text, the server asks the PR briefs' writer, which has no tools (`claude -p`, model `prBriefs.model`), which part ids the work will cross; the issue's title and body go only to that writer, fenced as text to read, never to a background run. Ids not on the map are dropped; a failed call, a reply that does not read or one that names no part on the map shows the hand picker with why. The parts are framed on the map with a dashed outline and the word *predicted* (*picked* for parts picked by hand), and the overlay lists each with its laws on trust, its fog and its staleness band (the map's own, below). Clear takes the pre-flight off the map. One pre-flight is kept per project, in the data folder's `pre-flight-by-project/`, and the Map view's payload carries it (`pre_flight`). When a PR's brief is written and the project's pre-flight is of an issue, the server notes every issue the PR closes (not only the lowest, which the facts still read as the spec) with each one's parent (`gh issue view --json parent`); a brief whose PR closes the pre-flighted issue, or a sub-issue of it, opens with "You expected X, Y; it touched X, Z", where touched is the parts the brief's shape found (those that fog and the ones only mentioned). A pre-flight from free text or hand-picked parts has no issue, so no brief carries its line. The overlay closes with Esc before every other layer, and its field is a text field, so single-key shortcuts do not fire while Daniel types in it. A past commit's map shows no pre-flight. +- **Pre-flight** (`server/src/pre_flight.rs`, `understanding/src/pre_flight.rs`, `ui/map-pre-flight.ts`; #394 of spec #378). Before starting work, Daniel sees which parts it will likely cross. The map's head has a quiet Pre-flight button, and the palette has `studio::PreFlight`; either opens an overlay over the map in the glass, and pressing it again closes it. A pointer press outside the overlay and its button (on the map, a plate, the tray or the list) closes it too while it shows its inputs or a framed pre-flight; while Daniel picks parts by hand, or waits on the writer, such a press leaves it open, so a stray press loses neither his picks nor the prediction (#666). Its inputs are an open issue (the project's open issues as `gh issue list` gives them), one or two lines of free text, or parts picked by hand. It says "Reading the open issues…" while they load, and when they cannot be read it says "Couldn't read the open issues: <reason>", the reason's first line as the server words it, `gh: ` and the first line `gh` printed on its error output (`gh cannot run: …` when it could not start; `ci_laws::gh` in `server/src/ci_laws.rs`), never "No open issues."; its text box and Pick parts by hand work as they do otherwise (#1046). For an issue or text, the server asks the PR briefs' writer, which has no tools (`claude -p`, model `prBriefs.model`), which part ids the work will cross; the issue's title and body go only to that writer, fenced as text to read, never to a background run. Ids not on the map are dropped; a failed call, a reply that does not read or one that names no part on the map shows the hand picker with why. The parts are framed on the map with a dashed outline and the word *predicted* (*picked* for parts picked by hand), and the overlay lists each with its laws on trust, its fog and its staleness band (the map's own, below). Clear takes the pre-flight off the map. One pre-flight is kept per project, in the data folder's `pre-flight-by-project/`, and the Map view's payload carries it (`pre_flight`). When a PR's brief is written and the project's pre-flight is of an issue, the server notes every issue the PR closes (not only the lowest, which the facts still read as the spec) with each one's parent (`gh issue view --json parent`); a brief whose PR closes the pre-flighted issue, or a sub-issue of it, opens with "You expected X, Y; it touched X, Z", where touched is the parts the brief's shape found (those that fog and the ones only mentioned). A pre-flight from free text or hand-picked parts has no issue, so no brief carries its line. The overlay closes with Esc before every other layer, and its field is a text field, so single-key shortcuts do not fire while Daniel types in it. A past commit's map shows no pre-flight. - **PR briefs** (`server/src/pr_briefs.rs`, `ui/map-brief.ts`; the one doc for them is [PR briefs](pr-briefs.md)). When a lookup finds a PR ready the server writes its brief through `write_pr_brief` (always with `claude -p`, whatever `summaries.writer` says; model: `prBriefs.model` in `settings.json`, Opus by default, read on each write, the writer's and the claim check's alike) and stores it per PR and head under the data folder's `pr-briefs-by-project/`. A new head marks the stored brief stale; it is written again when Daniel opens it, or when two lookups in a row see the same head. Opening a tray row opens the PR's panel, whose chapter, Continue reading or Ratify plays the brief as a single story or one chapter. A PR that would fog more than two parts has one tray row, whose panel lists its chapters; each chapter plays on its own and resumes at the step left, its frame holds every part its behaviour crosses, the overview (when there is one) plays before the first chapter opened and once per brief, and Also touched shows on the last step of the last chapter (the PR's other changed files in groups by kind, each with a See the code of its files; an older brief's writer lines instead): the zones holding any part it lights, either end of a hop's link, or any Map diff mark are opened for the brief, unsaved (framing runs after they open; a zone only the brief holds open has no − while it plays, one Daniel saved open keeps its −, and closing the brief gives back the open set it found, as it gives back the camera), and every link of its steps' hops, and every link the Map diff tags, is drawn exactly between its parts as a line carrying its own id, `data-from`, tag and part-keyed `data-mark` (a hop inside one zone included, carrying the diamonds of its link's laws, as it has no line at rest that would); the light runs the step's links at one speed and parts light as it arrives, the camera frames the parts the brief lights, the panel keeps its tallest step's height and crossfades, a figure (`states`, `sequence`, `compare`) is drawn by code from the writer's labels, citations sit in quiet type, a brief written from less than its full facts shows a "Partial facts · N" chip listing what it lacked, and an item the checks left flagged says "not confirmed from the facts", a mark whose popover lists why. A step's "See the code" opens the changed files of the parts it lights, with their diffs, in the drawer above the brief (`pr_diff`; every file on the Ratify or last step; what the step quoted when git cannot give them). Opening a brief returns a scrubbed map to now; closing it with Esc or Leave keeps the step it was at, and finishing it starts it over. Motion respects reduced motion, where the whole step lights at once. A check of kind `pick` is answered in the panel (pick, take it back, Check); an `order` check shows its question until its map answer is built. - **Ready for review** (`server/src/prs.rs`, `ui/map-tray.ts`). The server asks `gh pr view <branch> --json number,title,isDraft,state,headRefOid,body,closingIssuesReferences` for each listed session's branch: at once when a turn ends, and when the page gains focus or the Map view opens through one cooldown of a minute per repository with an in-flight guard; never on a timer. A PR is ready when it is open and not a draft; its head is kept in memory and replaced by a later lookup. The tray at the map's foot lists the project's ready PRs: each PR is one row, a button that opens its PR panel (#957), whatever its chapters; a PR whose brief is being written ahead has no row until it lands, and one Daniel asked for from the panel keeps "writing the brief…" (the map stays usable); one without a brief opens, and opening writes it in the background, the panel saying "Writing the brief…" until it lands and fills in; one whose write failed says so and opens to try again; after a push, a stored brief's row says why it is what it is: its read carried over, or it was rewritten ([Since you read](pr-briefs.md#ready-detection)). At start only the ready PRs whose head moved within `briefBackfill.hours` (2 by default; the older `catchUp.hours` is still read) get their brief written or a stale one rewritten, the newest head first and at most 3; a PR that becomes ready while `plotkeeper` runs is written at once; any other is written when opened. Any PR number found still names its session ("PR #N"). A ready PR whose touched parts would not fog at Daniel's effective tiers (Core always, Interface-only when the map's diff names the part, Black box never) gets no brief: the lookup builds its facts, finds no required part, writes nothing, does not gather it again at the same head, and it has no tray row. - **Ratifying** (`server/src/ratify.rs`, `ui/ratify.ts`, `ui/map-ratify.ts`). Daniel accepts or overturns what a PR changed on the map and what its agent decided; it never blocks anything, and the merged map is in effect at once. An item is a map change (a part, zone, outside actor, link, law or flow added, changed or removed, read by code from the map's diff; a part's `tier` never counts; its `zone` does, below) keyed by (PR, kind, map id), or a decision the agent declared, from the brief's `decisions`, keyed by (PR, decision id). Decision ids come from the writer entry and survive a reworded rewrite; a decided item a rewrite no longer holds keeps its record and is still listed. The state is `ratify.json` in the data folder, per project: when the project's first run was (`since`) and a record per decided item (`accepted`, `overturned`, or `pending`, with the time and what the item said). A reader ignores what it does not know. No record means ratified for anything that landed on or before `since`, and "not yet ratified" for anything after; a `pending` record marks an item not yet ratified whenever it landed, which is how Daniel's own file keeps the laws #295 left open, edited once by hand (no product logic names them). The brief ends with a **Ratify** step listing its items (nothing is added when all are ratified), each with Accept and Overturn. A part's or a link's row carries a **detail**, old beside new, which the step shows under the row as "Was" and "Now" lines (no colour), only for what changed: for a part, its name, caption ("Caption", #643, so an Edited part on the Map diff always has a line saying what changed), purpose and held items, matched by name (a name held twice, by its first, second… time), each with its `paths` change, and the patterns its own `paths` gained and lost, and a "Zone" line naming the zone it was in and the one it is in now when they differ (a part that moved zone is an Edited part, and a renamed zone is the zone's change, not the part's); for a zone, its name, caption and purpose; for a link, its kind and reason, and "Direction" (`from to to`) when its ends swapped. An added item shows its every line with nothing before, a removed one with nothing after. Both maps are converted first (`system_map::convert`), so a version 1 side's `description` shows as the old purpose. An `import` link the PR adds carries its **evidence** (#499): the import sites behind it, read from the PR's head in commit mode when the brief was written and stored on the brief (`link_evidence`), never extracted live, and shown only while the open PR's head is the brief's; its second line shows one site and "(+N imports across M files)", the site opening its code from the head in the drawer, numbered with its line marked (`ratify_site`, not the diff), the count listing every site there, each opening its code. A removed link shows none. The part sheet marks a law row, and a link's row in "Talks to", "Not yet ratified" with the same two buttons, for a map item that landed after the first run with no record. **Overturn** records the decision and copies a self-contained prompt to the clipboard (the PR number, its branch while the PR is open, the item's id and its wording, and for a part its new purpose and the names of its held items, for a link its ends, kind and reason, and for an added link its import sites; `navigator.clipboard.writeText()`), saying "Prompt copied, paste it into your agent"; when the clipboard refuses, the prompt shows in a small box with a Copy button. The note shows only on the sheet or the brief that holds the overturned item. Nothing is typed into a session. diff --git a/docs/studio/behaviour/plotkeeper.md b/docs/studio/behaviour/plotkeeper.md index aaf036b04..32be7d71a 100644 --- a/docs/studio/behaviour/plotkeeper.md +++ b/docs/studio/behaviour/plotkeeper.md @@ -27,6 +27,7 @@ Each start has its own id, its start time in Unix ms, which `about` returns beside the version; the page keeps the id it read at load (#909). The token stays per start and is not saved (spec #319), so a restart reaches a tab left open in one of two ways: its stream's reconnect is refused, since its cookie holds the old token, or, since the cookie is host-only and the new start's cookie covers every port, the stream opens again against the new server. Both look the same on the page: - While the stream retries (plotkeeper stopped, the machine asleep, the network down), the top bar says "Lost connection to plotkeeper — retrying". The line clears when the stream opens again, its first open, the load's, included: a stream that fails before it ever opened says it is retrying too, and its first open clears the line with no read again. +- A command that finds plotkeeper unreachable (the browser's request failed, with no reply) fails with "plotkeeper is not reachable", never the browser's own words; a refusal keeps the server's reason (#1046). While the top bar's line shows, retrying or restarted, that error is not repeated in the notice line, and one the notice line drew before the line showed goes when the stream's state changes, so it is never left after the reconnect. The top bar's text gives way to its buttons in a narrow window (#1047), and the connection line gives way last: the project name, the install hint's sentence and the port line shrink to nothing first, and in a window 480 px wide or less the bar's gaps tighten, so at 390 px the retrying line still reads "Lost connection…". After a restart at 390 px with the install hint showing, Reload takes most of that room and the notice is cut further. - Each open after the first asks `about` before anything else. The same start: the page reads again what it reads at load, the settings, the saved projects, the sessions, the selection, the writer's notice, whether a harness is wired and the cards, with no notice. It does not open the selected session's panel or map again, or show What's new or the store notice again (#912), so the view stays where Daniel left it and a notice he dismissed stays dismissed. When the load's `about` failed, the page holds no start, so the first reopen whose `about` answers takes that start as the same one and reads again. A reopen whose `about` fails is not live yet: the top bar says "Lost connection to plotkeeper — retrying" again, until the next open. - Another start, or a stream the browser closed for good, as it does when a refusal answers: the page closes its stream, so no event of the new build reaches the old page's code, and reads none of its data again; only a focus or a press still asks the server, as before. The top bar says "plotkeeper restarted — this tab is out of date", with **Reload**, which loads the page again. The notice stays until then. Nothing is redrawn: the page keeps what it showed, and its actions stay, so a press reaches the new server as before. - The limit: events the new server sends between the reopen and `about`'s answer are applied, as at any open. diff --git a/docs/studio/behaviour/sessions.md b/docs/studio/behaviour/sessions.md index 3089e87f6..683e8f7f3 100644 --- a/docs/studio/behaviour/sessions.md +++ b/docs/studio/behaviour/sessions.md @@ -2,7 +2,7 @@ ## The session list -On the right, the session list: every session (Claude Code, agy and Codex), one line each with the agent's logo, its name and its state, grouped by its project, and, inside a repository, by state with "needs you" first. The list holds what Home showed (#382): a row that needs you adds a second line, the open question's first line, else who asks (a plan, a permission, or a subagent: its name and "asks"); a running row its Intention, or its current step until the Intention is known; an unseen row (your turn or idle, not landed) its last turn's Headline, which updates when the turn's summary is stored. No other row has a second line. A second line is one line, muted, at 11.5 px, cut with an ellipsis. **Cut text reads in full in place** (spec #582): a row's name, token and second line, like every text the layout cuts, keep their whole text in the page (find-in-page, copy and screen readers get all of it), and on hover, or focus on the control that holds them, the cut line scrolls its hidden end into view inside its own box (`cut()` in `ui/dom.ts`, the `.cut` class). A line that fits stays still, and with reduced motion asked for nothing moves. A text the layout shortens (a path) or that can be very long (a prompt) has a hint holding it whole instead. A prompt-named session's name has a hint of its own, its full name and its identity; the row's hint reads its name and state, as every row's does. The selected row adds how long it has waited ("Bash cargo test · 3m"); a session whose last step is a wake-up reads "worker … returned" until its next step. The agent's logo is 12 px in one muted tone; colour in the list is the "Needs you" pill only. **The brief mark** (#630): a live session whose PR has a waiting PR brief (the rail's "PR brief ready" row's rule, `briefs_waiting`; [The rail](rail.md)) carries one quiet mark on its row, the project dot's mist with no colour, in its own 24 px button beside the row's delete, as a button holds no button. Its hint reads "PR #N · brief waiting", and pressing it opens the Map view on that PR's panel, as the rail's row does, without selecting the row (`briefMarkFor` in `ui/rail-brief.ts`). It goes once the brief is read to its end at the PR's head and comes back after a push; an ended session is in History, not the list, and has none, so the Map view's tray stays its way in; the strip has none. Hovering a session's row makes it the spotlit session on the map: its footprint, its chip on its now's parts, and the other session badges dimmed ([The Map view](map.md), "Session badges"). A session row, like every button and link of the session list and the top bar, explains itself in a **hint** (spec #582), a styled hover that replaces the native `title`: it shows when the pointer rests on the control for half a second, or when Tab reaches it, at once while another hint is open, anywhere on the page; it sits above the control and flips below when the window's top is in the way, except in the session list and its strip, where it opens to the control's left, level with it, so it covers no row above or below (spec #658; `hint(trigger, text, "start")`, flipping to the right when the window's edge is in the way); it stays open while the pointer is on it, and closes on Esc. **A hint closes when no trigger on the page names it** (#1044): one whose control left the page under it, as a History row's does when its press opens the session's story, closes within a third of a second, never left in the window's corner; a control a redraw kept keeps its open hint, and a control a view sets aside and puts back keeps its hint, closed while it was away. A row's hint reads its name and state, and adds that it touched no part in the last 7 days when it did not; it is built when the row is drawn, and the sidebar is drawn again when the map places the sessions. A hint that adds to the control's name is its accessible description; one that only repeats it adds nothing. `hint(trigger, text)` in `ui/dom.ts` makes one. A fold-out header (`<summary>`), an input or a select, which the browser's own hint wiring cannot reach, shows its hint the same way, by the helper's own pointer and focus listeners (the same delays, the pointer may rest on the hint, Esc and leaving close it, focus never moves into it); a click on a fold-out header still folds it. A button that cannot be used right now (Ask while it waits for its answer, the question card's Send before every question has a choice, a micro-world's "Building…") is `aria-disabled="true"`, not `disabled`: it stays focusable, is announced as unavailable, ignores a click and Enter, and its hint says why. **Marks and dots** (a row's check mark and id mark, a project's mist dot, an agent's logo, a part's law marks and broken-law mark, the sheet's law marks, a stale part's band, a link's law mark, the story's failed-check mark and a clock) show their hint on the pointer alone (`mark()` in `ui/dom.ts`, and `hint()` on a span or an SVG shape): each is `role="img"` with an `aria-label` carrying its meaning, and none takes the Tab order, so what a mark says also stays reachable without a pointer, in the part sheet's law list and the row's own words. **No native `title` is left on the page** outside the terminal, an SVG `<title>` included; the micro-world's frame is named by its `aria-label`. The snap pages keep it so: the hover rule (`scripts/snap/hover.mjs`, #220, rewritten by spec #582) runs after every snap page and fails on a control (`button`, `summary`, `a[href]`, `[role=button]`, the toasts, the spine) with no hint of its own (an ancestor's hover no longer counts), on any `title` attribute or SVG `<title>`, on a hint that only repeats its control's label, and on a hinted element the pointer cannot reach. +On the right, the session list: every session (Claude Code, agy and Codex), one line each with the agent's logo, its name and its state, grouped by its project, and, inside a repository, by state with "needs you" first. The list holds what Home showed (#382): a row that needs you adds a second line, the open question's first line, else who asks (a plan, a permission, or a subagent: its name and "asks"); a running row its Intention, or its current step until the Intention is known; an unseen row (your turn or idle, not landed) its last turn's Headline, which updates when the turn's summary is stored. No other row has a second line. A second line is one line, muted, at 11.5 px, cut with an ellipsis. **Cut text reads in full in place** (spec #582): a row's name, token and second line, like every text the layout cuts, keep their whole text in the page (find-in-page, copy and screen readers get all of it), and on hover, or focus on the control that holds them, the cut line scrolls its hidden end into view inside its own box (`cut()` in `ui/dom.ts`, the `.cut` class). A line that fits stays still, and with reduced motion asked for nothing moves. A text the layout shortens (a path) or that can be very long (a prompt) has a hint holding it whole instead. A prompt-named session's name has a hint of its own, its full name and its identity; the row's hint reads its name and state, as every row's does. The selected row adds how long it has waited ("Bash cargo test · 3m"); a session whose last step is a wake-up reads "worker … returned" until its next step. The agent's logo is 12 px in one muted tone; colour in the list is the "Needs you" pill only. **The brief mark** (#630): a live session whose PR has a waiting PR brief (the rail's "PR brief ready" row's rule, `briefs_waiting`; [The rail](rail.md)) carries one quiet mark on its row, the project dot's mist with no colour, in its own 24 px button beside the row's delete, as a button holds no button. Its hint reads "PR #N · brief waiting", and pressing it opens the Map view on that PR's panel, as the rail's row does, without selecting the row (`briefMarkFor` in `ui/rail-brief.ts`). It goes once the brief is read to its end at the PR's head and comes back after a push; an ended session is in History, not the list, and has none, so the Map view's tray stays its way in; the strip has none. Hovering a session's row makes it the spotlit session on the map: its footprint, its chip on its now's parts, and the other session badges dimmed ([The Map view](map.md), "Session badges"). A session row, like every button and link of the session list and the top bar, explains itself in a **hint** (spec #582), a styled hover that replaces the native `title`: it shows when the pointer rests on the control for half a second, or when Tab reaches it, at once while another hint is open, anywhere on the page; it sits above the control and flips below when the window's top is in the way, except in the session list and its strip, where it opens to the control's left, level with it, so it covers no row above or below (spec #658; `hint(trigger, text, "start")`, flipping to the right when the window's edge is in the way); it stays open while the pointer is on it, and closes on Esc. **A hint closes when no trigger on the page names it** (#1044): one whose control left the page under it, as a History row's does when its press opens the session's story, closes within a third of a second, never left in the window's corner; a control a redraw kept keeps its open hint, and a control a view sets aside and puts back keeps its hint, closed while it was away. A hover hint is held by the control that opened it: when a redraw puts a new control with the same key in its place, the hint closes too, as the new control was never hovered. A row's hint reads its name and state, and adds that it touched no part in the last 7 days when it did not; it is built when the row is drawn, and the sidebar is drawn again when the map places the sessions. A hint that adds to the control's name is its accessible description; one that only repeats it adds nothing. `hint(trigger, text)` in `ui/dom.ts` makes one. A fold-out header (`<summary>`), an input or a select, which the browser's own hint wiring cannot reach, shows its hint the same way, by the helper's own pointer and focus listeners (the same delays, the pointer may rest on the hint, Esc and leaving close it, focus never moves into it); a click on a fold-out header still folds it. A button that cannot be used right now (Ask while it waits for its answer, the question card's Send before every question has a choice, a micro-world's "Building…") is `aria-disabled="true"`, not `disabled`: it stays focusable, is announced as unavailable, ignores a click and Enter, and its hint says why. **Marks and dots** (a row's check mark and id mark, a project's mist dot, an agent's logo, a part's law marks and broken-law mark, the sheet's law marks, a stale part's band, a link's law mark, the story's failed-check mark and a clock) show their hint on the pointer alone (`mark()` in `ui/dom.ts`, and `hint()` on a span or an SVG shape): each is `role="img"` with an `aria-label` carrying its meaning, and none takes the Tab order, so what a mark says also stays reachable without a pointer, in the part sheet's law list and the row's own words. **No native `title` is left on the page** outside the terminal, an SVG `<title>` included; the micro-world's frame is named by its `aria-label`. The snap pages keep it so: the hover rule (`scripts/snap/hover.mjs`, #220, rewritten by spec #582) runs after every snap page and fails on a control (`button`, `summary`, `a[href]`, `[role=button]`, the toasts, the spine) with no hint of its own (an ancestor's hover no longer counts), on any `title` attribute or SVG `<title>`, on a hint that only repeats its control's label, and on a hinted element the pointer cannot reach. **The list holds its order under the pointer** (spec #659). While the pointer is in the list (the full list, the list open over the map, its strip, or the project "⋯" menu), the project groups and the rows in each keep the places of the last draw before it came in, and the strip's buttons theirs: a session that goes from running to needs you keeps its row and its state group, and only its glyph, second line and counts change, as do a header's rollup and dot. A session that starts meanwhile joins the end of its project's group (a new project the end of the groups, a session new to the strip its end), and one no longer listed leaves at once, so a row pressed is always a listed session. A row held in the folded Idle group stays in it, and a strip button whose session went idle stays, until the pointer leaves. The subagent rows under each session hold the same way (spec #820, item F): a subagent the list did not know when the pointer came in waits until it leaves, except one that needs you or failed unopened, which shows at once under its spawn, as a collapsed row shows those, and may move the rows below it; one that fades leaves at once, as a gone session does. When it leaves, the list and the strip are drawn once in the real order. The server's sort and sends are unchanged: the hold is the page's (`holdGroups` in `ui/projects.ts`, `holdList` in `ui/list.ts`, `heldAgents` in `ui/list-model.ts`). ⌘] and ⌘[, ⌘J and the jump to an unseen session step through the order on screen, held or not, as ↑ and ↓ do; a session Clear landed hid is not in it. ↑ and ↓ also step through the subagent rows as they show, and ⌘] and ⌘[ through sessions only. The strip's buttons follow the sidebar's order, project by project and by state, held or not, never the server's, so ⌘] and ⌘[ at the strip's width step through them as they show. A hint of something in the list (a row's, a project dot's, which opens over the rows) is drawn outside `.list`, and the pointer on it is still in the list: the hold ends when it leaves the hint for somewhere else, also once the hint's row is gone (its session ended under it). The keyboard in the list holds nothing. The snap `listHeld` checks it with synthetic pointer events. @@ -46,7 +46,7 @@ Cmd+Shift+H, once `studio::GoHome`, is now `studio::ShowMap` (#386), "back to th **Planning and triage** (spec #967, #972). The core knows when a session is in an interactive planning skill or a triage, and keeps it on the session's wire form (`work.planning`: `planning`, `triage` or `null`). A typed command (the prompt's raw text, `/name` with an optional `plugin:` prefix, its name made of letters, digits, `-`, `_` and `:`, so a pasted path is none) or a `Skill` call enters it: `grill*`, `brainstorm*` and `speckit-clarify` are planning, `triage*` is triage. The helpers `prototype`, `research`, `domain-modeling` and `to-spec` keep the session where it is, and so do Claude Code's built-in commands that tend the session rather than its work (`/compact`, `/model`, `/effort`, `/clear`, `/doctor`, `/statusline` and the like; `BUILT_IN` in `core/src/work.rs`); any other command or skill (`implement`, `implement-spec`, `tdd`, `to-tickets`, …) leaves at once, and a new planning or triage command enters again. A session also leaves when a turn's files are stored and one of them is not Markdown (`.md`, `.markdown`): the turn's files come from the hook's git trees, so an edit made through Bash counts as an Edit or Write does, and a gitignored file (the trees are written by `git add -A`) or a file outside the repository never shows. Only a turn that started at or after the session last entered counts, so an earlier turn's files, stored late or again after a full replay, never end a later grilling; a full replay rebuilds the leave when the shell stores the files of each turn of the last 7 days again. A turn with no recorded trees (an agent that reports none, a folder outside git) leaves nothing. The first issue number of the session's first planning or triage command (`/triage 935`, `/grilling #931`) is its issue's third source, after its `issue-<n>-` branch and a Wayfinder claim, so a triage on `main` is named "#935 · main · …". -"Rename" names the session: the server appends a `StudioRename` line to the event log, so the name survives a restart; the page types nothing into the session. An empty name gives the row its folder's again. A name is capped at 200 characters, counted in Unicode scalar values, and the server's rename is the cap's one authority: it trims the name first, and refuses a longer one with a reason rather than cutting it, so the cap holds whatever sends the name. Names already longer in an old log stay as they are. "Open" and "Close", which resumed and ended a session's terminal, are gone with the terminals. +"Rename" names the session: the server appends a `StudioRename` line to the event log, so the name survives a restart; the page types nothing into the session. An empty name gives the row its folder's again. A name is capped at 200 characters, counted in Unicode scalar values, and the server's rename is the cap's one authority: it trims the name first, and refuses a longer one with a reason rather than cutting it, so the cap holds whatever sends the name. The rename dialog counts the same way, with no `maxlength` (which counts UTF-16 units, so 100 emoji): past 200 characters its Save is unavailable (`aria-disabled`, its hint giving the limit) and a note under the field says "Names are at most 200 characters."; Enter submits nothing then. It trims as the server does, of Unicode White_Space (JavaScript's own `trim` keeps U+0085 and drops U+FEFF, the other way round), so it never refuses a name the server takes. Names already longer in an old log stay as they are: the rename and Delete dialogs wrap them, long words too, and hold them inside the window, scrolling the name inside the dialog with its buttons in view (#1049). "Open" and "Close", which resumed and ended a session's terminal, are gone with the terminals. "Delete" asks, then drops the session's row: the server appends a `StudioDelete` line to the event log, so the row stays gone after a restart until a `SessionStart` of the session brings it back; its cards stay in the store, and no worktree or branch is removed. Clear landed, at the list's end, deletes the landed rows the same way once its Undo window has passed. diff --git a/scripts/snap/fixtures-page.ts b/scripts/snap/fixtures-page.ts index 136e257c7..fae03cd0d 100644 --- a/scripts/snap/fixtures-page.ts +++ b/scripts/snap/fixtures-page.ts @@ -546,7 +546,7 @@ ${body}`; /** * The stream drops and comes back to the same start (#909): the top bar says it is retrying, the line clears on the reopen, and the page * reads its data again with no word, leaving the view where it was: the story closed stays closed, and the store notice dismissed (#912) - * stays dismissed. An error before the first open says it is retrying too, and the first open clears the line with no read. It drops again, + * stays dismissed. An unreachable error drawn while the stream was live goes when it drops (#1046). An error before the first open says it is retrying too, and the first open clears the line with no read. It drops again, * for the picture. */ export const streamRetrying = (): Fixture => ({ @@ -559,7 +559,12 @@ export const streamRetrying = (): Fixture => ({ const notice = document.getElementById("notice"); if (notice.hidden) log("snap:fail no store notice at the load"); document.getElementById("notice-dismiss").click(); + // An unreachable error drawn before the line showed goes once the connection changes (#1046), and stays gone after the reopen. + __snapEmit("server-error", "select: plotkeeper is not reachable"); + await wait(50); + if (notice.textContent !== "select: plotkeeper is not reachable") log("snap:fail the unreachable error before the drop: " + notice.textContent); __snapStream("error"); + if (notice.textContent.includes("not reachable")) log("snap:fail the unreachable error stays beside the retrying line: " + notice.textContent); if (!line.checkVisibility() || line.textContent !== "Lost connection to plotkeeper — retrying") log("snap:fail the retrying line: " + line.textContent); if (!reload.hidden) log("snap:fail Reload shows while the stream retries"); document.getElementById("panel-close").click(); @@ -1105,7 +1110,8 @@ export const listEscNarrow = (): Fixture => escList(true); /** * The top bar keeps its buttons in a narrow window (#1047): with the install hint, a restart notice with Reload and Needs you showing, - * every button lies wholly inside the window and is the element at its own centre; the text gives way and ends in "…". `…Phone` is drawn at + * every button lies wholly inside the window and is the element at its own centre; the text gives way and ends in "…". Before the restart, + * while the stream retries, the connection line is the text that gives way last, so it still reads "Lost connection…". `…Phone` is drawn at * 390x800, `…Small` at 640x800 and `…Narrow` at 1000x800 (snap:all's sizes for those suffixes). */ const topBar = (): Fixture => ({ @@ -1117,9 +1123,20 @@ const topBar = (): Fixture => ({ window.fetch = (url, init) => String(url) === "/api/about" ? Promise.resolve({ ok: true, status: 200, json: async () => ({ version: "0.2.0", start: 2 }) }) : answered(url, init); __snapStream("open"); + window.dispatchEvent(Object.assign(new Event("beforeinstallprompt", { cancelable: true }), { prompt: async () => {} })); __snapStream("error"); + await wait(300); + // The connection line, which quiets the unreachable notice while it shows (#1046), stays readable: the text beside it gives way + // first, so it keeps at least "Lost connection" and its "…" in view. + const connection = document.getElementById("connection"); + const words = connection.firstElementChild?.firstChild; + if (!words || words.textContent !== "Lost connection to plotkeeper — retrying") return log("snap:fail no retrying line: " + connection.textContent); + const head = document.createRange(); + head.setStart(words, 0); + head.setEnd(words, "Lost connection".length); + const need = head.getBoundingClientRect().width + 12; + if (connection.clientWidth < need) log("snap:fail the retrying line is " + connection.clientWidth + " px wide, under the " + Math.round(need) + " px 'Lost connection…' takes"); __snapStream("open"); - window.dispatchEvent(Object.assign(new Event("beforeinstallprompt", { cancelable: true }), { prompt: async () => {} })); await wait(300); const bar = document.querySelector(".top"); const buttons = [...bar.querySelectorAll("button")].filter((b) => b.checkVisibility()); @@ -1143,7 +1160,7 @@ export const topBarPhone = (): Fixture => topBar(); export const topBarSmall = (): Fixture => topBar(); export const topBarNarrow = (): Fixture => topBar(); -/** The selected session `id` of `list()`, its story open, and `extra` over it. */ +/** `list()` with its session s3 selected and its story open, `extra` over it; `name` and `change`, when given, change s3. */ const storyOf = (extra: Partial<Fixture> = {}, name?: string, change: Partial<Session> = {}): Fixture => { const sessions = (list().sessions as Session[]).map((s) => (s.id === "s3" ? { ...s, ...(name !== undefined && { name }), ...change } : s)); const own = sessions.find((s) => s.id === "s3") as Session; @@ -1185,15 +1202,17 @@ export const permissionCommand = (): Fixture => { if (box.scrollWidth > box.clientWidth + 1) log("snap:fail command " + i + " scrolls sideways"); if (allow.top < b.bottom - 0.5) log("snap:fail Allow is not below command " + i); if (i === 0 && lines < 2) log("snap:fail the two-line command is " + lines + " lines tall"); - if (i === 0 && box.nextElementSibling === null && !card.querySelector(".description")) log("snap:fail the description is missing"); if (i === 1 && lines < 2) log("snap:fail the 300-character command is " + lines + " lines tall"); if (i === 2) { if (b.height > rowHeight(box) * 14) log("snap:fail the 30-line command is " + b.height + " px tall, not capped"); if (box.scrollHeight <= box.clientHeight + 1) log("snap:fail the capped command does not scroll"); } }); - const description = cards[0].querySelector(".description"); - if (description && description.getBoundingClientRect().top < cards[0].querySelector("code").getBoundingClientRect().bottom - 0.5) log("snap:fail the description is not under the command"); + // The description is the element right after the command, drawn under it. + const command = cards[0].querySelector("code"); + const description = command.nextElementSibling; + if (!description?.classList.contains("description") || description.textContent !== "Say it is done") log("snap:fail the command is not followed by its description: " + description?.outerHTML.slice(0, 80)); + else if (description.getBoundingClientRect().top < command.getBoundingClientRect().bottom - 0.5) log("snap:fail the description is not under the command"); const fold = document.getElementById("decisions"); if (fold.hidden) return log("snap:fail the decision history is not shown"); fold.open = true; @@ -1210,7 +1229,9 @@ export const permissionCommand = (): Fixture => { /** * The rename dialog counts characters as the server does (#1049, #1048): 201 emoji are 201 characters, though 402 UTF-16 units, so Save is - * unavailable (`aria-disabled`, never `disabled`) and a note gives the limit; 200 are accepted, and the field has no `maxlength`. + * unavailable (`aria-disabled`, never `disabled`) and a note gives the limit; 200 are accepted, and the field has no `maxlength`. It trims + * as the server's `str::trim` does, Unicode White_Space, before it counts: the spaces and next-line characters (U+0085) around 200 emoji + * go, and a byte-order mark (U+FEFF), which the server keeps, counts. */ export const renameCap = (): Fixture => storyOf({ @@ -1225,15 +1246,24 @@ export const renameCap = (): Fixture => const type = async (words) => { field.value = words; field.dispatchEvent(new Event("input", { bubbles: true })); await wait(50); }; if (!dialog.open) return log("snap:fail the rename dialog did not open"); if (field.hasAttribute("maxlength")) log("snap:fail the field has a maxlength"); - await type("😀".repeat(201)); - if (field.value !== "😀".repeat(201)) log("snap:fail the field cut the 201 emoji to " + [...field.value].length); - if (save.getAttribute("aria-disabled") !== "true") log("snap:fail Save is available with 201 emoji"); - if (save.disabled) log("snap:fail Save is disabled, not aria-disabled"); - if (!note()) log("snap:fail no note with 201 emoji"); - await type("😀".repeat(200)); - if (save.hasAttribute("aria-disabled")) log("snap:fail Save is unavailable with 200 emoji"); - if (note()) log("snap:fail the note shows with 200 emoji"); - await type("😀".repeat(201)); + const most = "😀".repeat(200); + // Each name typed, and whether Save takes it. + const cases = [ + ["201 emoji", most + "😀", false], + ["200 emoji", most, true], + ["200 emoji with spaces around them", " " + most + " ", true], + ["200 emoji and a next-line character", most + "\u0085", true], + ["200 emoji and a byte-order mark", most + "\ufeff", false], + ]; + for (const [what, words, takes] of cases) { + await type(words); + if (field.value !== words) log("snap:fail the field cut " + what + " to " + [...field.value].length); + if (takes && save.hasAttribute("aria-disabled")) log("snap:fail Save is unavailable with " + what); + if (!takes && save.getAttribute("aria-disabled") !== "true") log("snap:fail Save is available with " + what); + if (save.disabled) log("snap:fail Save is disabled, not aria-disabled, with " + what); + if (takes === Boolean(note())) log("snap:fail the note " + (takes ? "shows" : "is missing") + " with " + what); + } + await type(most + "😀"); save.click(); await wait(100); if (!dialog.open) log("snap:fail a press on the unavailable Save closed the dialog"); diff --git a/server/src/session_view/tests.rs b/server/src/session_view/tests.rs index 312180152..11b680f28 100644 --- a/server/src/session_view/tests.rs +++ b/server/src/session_view/tests.rs @@ -9,7 +9,8 @@ fn mixed(n: usize) -> String { fn a_name_is_trimmed_and_refused_past_200_characters() { let longest = mixed(NAME_LIMIT); let too_long = mixed(NAME_LIMIT + 1); - let cases: [(&str, &str, Result<&str, String>); 4] = [ + let padded = format!(" \u{85}{longest}\u{85} "); + let cases: [(&str, &str, Result<&str, String>); 5] = [ ( "200 characters of Hebrew and emoji", longest.as_str(), @@ -22,6 +23,11 @@ fn a_name_is_trimmed_and_refused_past_200_characters() { ), ("whitespace only", " \t\n ", Ok("")), ("surrounding spaces", " my session ", Ok("my session")), + ( + "200 characters with surrounding spaces and next-line characters, trimmed before the count", + padded.as_str(), + Ok(longest.as_str()), + ), ]; for (case, name, expected) in cases { assert_eq!(checked_name(name), expected, "{case}"); @@ -36,6 +42,7 @@ fn a_refused_rename_appends_nothing_to_the_event_log() { std::env::set_var("HOME", home.path()); std::env::set_var("USERPROFILE", home.path()); std::env::remove_var("XDG_DATA_HOME"); + std::env::remove_var("XDG_CACHE_HOME"); } let log = studio_hook::event_log(home.path()); std::fs::create_dir_all(log.parent().unwrap()).unwrap(); diff --git a/ui/dom.ts b/ui/dom.ts index b416bff4a..aa5a141e3 100644 --- a/ui/dom.ts +++ b/ui/dom.ts @@ -276,7 +276,8 @@ const named = (trigger: Element) => trigger.getAttribute("interestfor") ?? trigg // other words, as an unkeyed one is, names a new hint, so the old one goes, once it is closed: an open one waits for the next prune. // A hint shows only while a trigger on the page names it (#1044): one whose trigger left the page, which gets no pointerleave, closes. // Its recorded owner is not read for that, as `hint()` records each new trigger before `patch` may keep the older one. The listener -// path's open hint also stays with the trigger that opened it while that trigger is on the page, though a redraw gave it other words. +// path's open hint stays with the trigger that opened it while that trigger is on the page, though a redraw gave it other words, and +// closes once that trigger left it, though a new trigger with the same key names it. // While a hint shows, the prune runs again each tick, so one stranded by a page change that calls no `hint()` closes within a tick. function pruneHints() { pruneQueued = false; @@ -286,8 +287,10 @@ function pruneHints() { let showing = false; for (const [id, node] of hints) { const open = node.matches(":popover-open"); - const opener = open && node === openHint && openTrigger !== null && triggers.includes(openTrigger); - if (wired.has(id) || opener) { + // The listener path's open hint is held by the trigger that opened it, alone: once that one left the page, a new trigger with the + // same key, which got no pointerenter, does not hold it, or it would stay drawn over the window's corner. + const opener = open && node === openHint ? openTrigger : null; + if (opener ? triggers.includes(opener) : wired.has(id)) { showing ||= open; continue; } diff --git a/ui/main.ts b/ui/main.ts index 9f629a327..1e8e37426 100644 --- a/ui/main.ts +++ b/ui/main.ts @@ -4,7 +4,7 @@ // server's events to the regions and lays the list out by the width rule in `layout.ts`. import "./transport.js"; -import { dismissNotice, NOT_RECORDING, setSettingsErrors, showError, showNotice } from "./notice.js"; +import { dismissNotice, dropUnreachable, NOT_RECORDING, setSettingsErrors, showError, showNotice } from "./notice.js"; import { withGateNotice, withWriterNotice } from "./writer-notice.js"; import { startWatching } from "./answer.js"; import { forgetAsks } from "./ask.js"; @@ -507,6 +507,8 @@ function restarted() { } watchConnection((state) => { if (outOfDate) return; + // An unreachable error drawn while the stream was live is stale now: the line says it, or plotkeeper is back (#1046). + dropUnreachable(); cut(connection, state === "retrying" ? RETRYING : ""); if (state === "closed") return restarted(); if (state !== "reopened") return; diff --git a/ui/map-pre-flight.ts b/ui/map-pre-flight.ts index d5ae54d43..a1dae32f1 100644 --- a/ui/map-pre-flight.ts +++ b/ui/map-pre-flight.ts @@ -63,6 +63,16 @@ export async function settle(asked: Promise<PreFlight>): Promise<Phase> { } } +/** The open issues `read` answers, or why it could not read them: its reason's first line, as `gh`'s own reason may run on (#1046). */ +export async function issuesOf(read: Promise<OpenIssue[]>): Promise<Issues> { + try { + return await read; + } catch (e) { + failure("pre_flight_issues")(e); + return { failed: messageOf(e).split("\n")[0] ?? "" }; + } +} + /** A matched brief's line: "You expected Hook, Core; it touched Window, Hook", by the parts' names on `doc`; null for a brief with none. */ export function expectedLine(expected: Expected | undefined | null, doc: LoadedMap | null): string | null { if (!expected) return null; @@ -258,14 +268,9 @@ export function openPreFlight(fresh = false) { const pre = view.state.pre_flight; if (pre && !fresh) return show({ kind: "result", pre }); show({ kind: "start", issues: null }); - invoke("pre_flight_issues", { project }) - .then((issues) => { - if (phase?.kind === "start" && shownProject() === project) show({ kind: "start", issues }); - }) - .catch((e) => { - failure("pre_flight_issues")(e); - if (phase?.kind === "start" && shownProject() === project) show({ kind: "start", issues: { failed: messageOf(e).split("\n")[0] ?? "" } }); - }); + void issuesOf(invoke("pre_flight_issues", { project })).then((issues) => { + if (phase?.kind === "start" && shownProject() === project) show({ kind: "start", issues }); + }); } /** diff --git a/ui/notice.ts b/ui/notice.ts index a9bed853e..f38e5b718 100644 --- a/ui/notice.ts +++ b/ui/notice.ts @@ -2,6 +2,8 @@ // as a `server-error` event (`main.ts`) and from the UI's own helper (`logLine` in dom.ts), once per distinct message // until Daniel dismisses it. Settings errors and the Claude Code version notice share the line and keep their rules. +import { UNREACHABLE } from "./transport.js"; + // The error lines this module added, so a dismiss removes them and nothing else. let errors: string[] = []; @@ -24,8 +26,6 @@ function add(text: string) { return message; } -/** What the transport says when plotkeeper cannot be reached (#1046). */ -export const UNREACHABLE = "plotkeeper is not reachable"; // Whether the top bar's connection line shows (retrying, or restarted with Reload), which already says plotkeeper is unreachable. const connectionShows = () => Boolean(globalThis.document?.getElementById?.("connection")?.textContent); @@ -38,6 +38,17 @@ export function showError(message: string) { if (added) errors.push(added); } +// Drops a drawn unreachable error once the connection changes (#1046): the top bar's line says it now, or plotkeeper is back. One drawn +// before the line showed would otherwise stay after the reconnect. The other lines stay. +export function dropUnreachable() { + const notice = line(); + const stale = errors.filter((l) => l.includes(UNREACHABLE)); + if (!notice || !stale.length) return; + const rest = linesOf(notice.textContent).filter((l) => !stale.includes(l)); + notice.textContent = rest.join("\n"); + notice.hidden = !rest.length; +} + // A plain notice, such as Claude Code's version changing: it joins the line and no dismiss removes it. export const showNotice = (message: string) => void add(message); diff --git a/ui/story.ts b/ui/story.ts index d5649b343..8635cbc9d 100644 --- a/ui/story.ts +++ b/ui/story.ts @@ -969,6 +969,9 @@ function panelOf(session: Session): HTMLElement { /** The longest session name, in characters: the server's cap (`NAME_LIMIT`, #1048). */ const NAME_LIMIT = 200; +// `name` trimmed as the server's `str::trim` trims it, of Unicode White_Space: JavaScript's `trim` keeps U+0085 and drops U+FEFF, which +// the server does the other way round, so a name the server takes would be refused here, or one it refuses sent. +const trimmed = (name: string) => name.replace(/^\p{White_Space}+|\p{White_Space}+$/gu, ""); // Rename (danielrispler/Falinks#469): the row's name, kept in the event log. An empty name gives the row its folder's again. function askName(session: Session) { @@ -978,7 +981,7 @@ function askName(session: Session) { const note = element("rename-note"); // The cap counts characters as the server does, Unicode scalar values: the field has no `maxlength`, which counts UTF-16 units (#1049). const check = () => { - const over = [...field.value.trim()].length > NAME_LIMIT; + const over = [...trimmed(field.value)].length > NAME_LIMIT; // Always on the page and filled or emptied, so its polite live region announces the limit as it is passed. note.textContent = over ? `Names are at most ${NAME_LIMIT} characters.` : ""; availability(save, "Save this name (↩)", over ? `Names are at most ${NAME_LIMIT} characters` : null); @@ -993,7 +996,7 @@ function askName(session: Session) { check(); dialog.onclose = async () => { if (dialog.returnValue !== "rename") return; - await invoke("rename", { id: session.id, name: field.value.trim() }).catch(failure("rename", "error")); + await invoke("rename", { id: session.id, name: trimmed(field.value) }).catch(failure("rename", "error")); }; dialog.returnValue = ""; dialog.showModal(); diff --git a/ui/style.css b/ui/style.css index 14059d22d..3b28a0ee9 100644 --- a/ui/style.css +++ b/ui/style.css @@ -60,12 +60,15 @@ body[data-layout="focus"] .list { visibility: hidden; } .bar-project { font-size: var(--size-small); font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; } /* The top bar's buttons never shrink (danielrispler/plotkeeper#127), and its text gives way to them (#1047): the project name, the install hint's sentence, the connection line and the port line (cut text, `cut()` in dom.ts) shrink to nothing and end in "…", so every button stays inside the window. The - spacer takes the rest. */ + spacer takes the rest. The connection line gives way last: while it shows it quiets the notice line's unreachable error (#1046), so it is + the one message that must stay readable. The other text shrinks first, each to nothing, before it does; in a phone-width window the bar's + gaps tighten, so it keeps "Lost connection…" beside the buttons. */ .top > :not(.sp):not(.menu) { flex: none; } -.top > :is(.bar-project, .connection, #port-line):not(.sp):not(.menu) { flex: 0 1 auto; min-width: 0; } +.top > :is(.bar-project, #port-line), #install-hint > .cut { flex: 0 1000 auto; min-width: 0; } +.top > #connection { flex: 0 1 auto; min-width: 0; } +@media (max-width: 30em) { .top { gap: var(--sp-3); } } /* The install hint's line gives its sentence and buttons to the bar as items of their own, so the sentence shrinks and the buttons do not. */ #install-hint:not([hidden]) { display: contents; } -#install-hint > .cut { flex: 0 1 auto; min-width: 0; } .connection.cut, #port-line.cut, #install-hint > .cut { overflow: hidden; text-overflow: ellipsis; } .top .sp { flex: 1; } .top .menu[popover] { top: var(--bar); right: var(--sp-5); left: auto; width: max-content; max-width: calc(100vw - 2 * var(--sp-5)); } diff --git a/ui/tests/hint-redraw.test.mjs b/ui/tests/hint-redraw.test.mjs index 3683e4c0f..7f683a903 100644 --- a/ui/tests/hint-redraw.test.mjs +++ b/ui/tests/hint-redraw.test.mjs @@ -69,25 +69,6 @@ test("an unkeyed span drawn again leaves no hint of its first draw in #hints", ( assert.ok(inHints(line.childNodes[0].getAttribute("data-hint"))); }); -test("an unkeyed summary drawn again while its hint is open keeps that hint until it closes", () => { - const line = row(); - const draw = () => [hint(document.createElement("summary"), "Show or hide the sessions")]; - patch(line, draw()); - const [kept] = line.childNodes; - kept.listeners.pointerenter({}); - mock.timers.tick(501); - const [shown] = open(); - const id = shown.getAttribute("id"); - patch(line, draw()); - mock.timers.tick(300); - assert.ok(inHints(id), "the open hint stays while the pointer rests on its trigger"); - assert.ok(shown.popoverOpen); - kept.listeners.pointerleave({}); - mock.timers.tick(200); - mock.timers.tick(300); - assert.equal(inHints(id), false); -}); - test("a keyed span drawn again ten times keeps one set of listeners on its hint", () => { const line = row(); const draw = () => [hint(keyed(document.createElement("span"), "mark-redrawn"), "A plain terminal")]; @@ -139,54 +120,70 @@ test("the step's detail drawn without a shortened path opens no hint left from t assert.deepEqual(open(), []); }); -// A hint whose trigger left the page closes (#1044): no trigger on the page names it any more, and no further `hint()` call or redraw -// is needed, as when closing the left panel clears History under an open row hint. -test("an open listener-path hint whose trigger is removed closes within one prune tick", () => { - const line = row(); - patch(line, [hint(keyed(document.createElement("span"), "name-removed"), "Map view drawer · plotkeeper")]); - const [trigger] = line.childNodes; - trigger.listeners.pointerenter({}); - mock.timers.tick(501); - mock.timers.tick(1000); - assert.equal(open().length, 1, "the hint opened"); - line.replaceChildren(); - mock.timers.tick(300); - assert.deepEqual(open().map((node) => node.textContent), []); -}); - -// A redraw hands `hint()` a new trigger, which `patch` drops for the one on the page: the open hint stays, by either path. -for (const tag of ["span", "button"]) { - test(`an open hint whose ${tag} patch() kept across a redraw stays open`, () => { +// An open hint across a change to the page: it shows only while a trigger on the page names it (#1044). A trigger that left the page +// gets no pointerleave, so its hint closes within one prune tick, with no further `hint()` call or redraw, as when closing the left panel +// clears History under an open row hint; a trigger `patch()` kept across a redraw keeps it open, by either path. `open` is how the hint +// opens: "pointer", the listener path's hover; "interest", the browser's `interestfor` opening it with no call of the page's, after the +// prunes `hint()` queued have ended. `then` checks what follows. +const keyedDraw = (/** @type {string} */ tag, /** @type {string} */ key) => () => [hint(keyed(document.createElement(tag), key), "Kept words")]; +/** @type {{ name: string, draw: () => any[], open: "pointer" | "interest", change: (line: any, draw: () => any[]) => void, shows: string[], then?: (line: any, trigger: any, shown: any) => void }[]} */ +const openAcross = [ + { name: "an open listener-path hint whose trigger is removed closes within one prune tick", draw: keyedDraw("span", "name-removed"), open: "pointer", change: (line) => line.replaceChildren(), shows: [] }, + { name: "an open hint whose span patch() kept across a redraw stays open", draw: keyedDraw("span", "kept-span"), open: "pointer", change: (line, draw) => patch(line, draw()), shows: ["Kept words"] }, + { name: "an open hint whose button patch() kept across a redraw stays open", draw: keyedDraw("button", "kept-button"), open: "interest", change: (line, draw) => patch(line, draw()), shows: ["Kept words"] }, + { name: "an open listener-path hint whose trigger is replaced by a new one with the same key closes", draw: keyedDraw("span", "probe-row"), open: "pointer", change: (line, draw) => line.replaceChildren(...draw()), shows: [] }, + { name: "an open interestfor hint whose button is removed closes within one prune tick", draw: keyedDraw("button", "interest-removed"), open: "interest", change: (line) => line.replaceChildren(), shows: [] }, + { + name: "an unkeyed summary drawn again while its hint is open keeps that hint until it closes", + draw: () => [hint(document.createElement("summary"), "Show or hide the sessions")], + open: "pointer", + change: (line, draw) => patch(line, draw()), + shows: ["Show or hide the sessions"], + then: (line, trigger, shown) => { + assert.equal(line.childNodes[0], trigger, "patch keeps the summary"); + trigger.listeners.pointerleave({}); + mock.timers.tick(200); + mock.timers.tick(300); + assert.equal(inHints(shown.getAttribute("id")), false, "the old hint goes once it closed"); + }, + }, + { + name: "a trigger set aside and put back keeps its hint node, closed while it was away", + draw: keyedDraw("span", "set-aside"), + open: "pointer", + change: (line) => line.replaceChildren(), + shows: [], + then: (line, trigger, shown) => { + mock.timers.tick(600); + assert.ok(inHints(shown.getAttribute("id")), "the hint stays in #hints while its trigger is kept off the page"); + patch(line, [trigger]); + assert.equal(hintOf(trigger), shown); + trigger.listeners.pointerleave({}); + trigger.listeners.pointerenter({}); + mock.timers.tick(501); + assert.ok(shown.popoverOpen, "the kept hint opens again once its trigger is back"); + }, + }, +]; +for (const { name, draw, open: how, change, shows, then } of openAcross) { + test(name, () => { const line = row(); - const draw = () => [hint(keyed(document.createElement(tag), `kept-${tag}`), "Kept words")]; patch(line, draw()); const [trigger] = line.childNodes; - if (tag === "span") { + const shown = hintOf(trigger); + if (how === "pointer") { trigger.listeners.pointerenter({}); mock.timers.tick(501); - } else hintOf(trigger).showPopover(); - patch(line, draw()); - assert.equal(line.childNodes[0], trigger, "patch keeps the trigger"); - mock.timers.tick(900); - assert.deepEqual(open().map((node) => node.textContent), ["Kept words"]); + } else { + mock.timers.tick(300); + shown.showPopover(); + shown.listeners.toggle({ newState: "open" }); + } + mock.timers.tick(1000); + assert.deepEqual(open().map((node) => node.textContent), [shown.textContent], "the hint opened"); + change(line, draw); + mock.timers.tick(300); + assert.deepEqual(open().map((node) => node.textContent), shows, "within one prune tick"); + then?.(line, trigger, shown); }); } - -test("a trigger set aside and put back keeps its hint node, closed while it was away", () => { - const line = row(); - patch(line, [hint(keyed(document.createElement("span"), "set-aside"), "Set aside words")]); - const [trigger] = line.childNodes; - const shown = hintOf(trigger); - trigger.listeners.pointerenter({}); - mock.timers.tick(501); - line.replaceChildren(); - mock.timers.tick(600); - assert.ok(inHints(shown.getAttribute("id")), "the hint stays in #hints while its trigger is kept off the page"); - assert.equal(shown.popoverOpen, false, "the hint closed while its trigger was off the page"); - patch(line, [trigger]); - assert.equal(hintOf(trigger), shown); - trigger.listeners.pointerleave({}); - trigger.listeners.pointerenter({}); - mock.timers.tick(501); - assert.ok(shown.popoverOpen, "the kept hint opens again once its trigger is back"); -}); diff --git a/ui/tests/map-pre-flight.test.mjs b/ui/tests/map-pre-flight.test.mjs index ce2f6ecf6..01f17b878 100644 --- a/ui/tests/map-pre-flight.test.mjs +++ b/ui/tests/map-pre-flight.test.mjs @@ -5,7 +5,7 @@ import assert from "node:assert/strict"; import { fakeDocument } from "./dom.mjs"; globalThis.document = fakeDocument(); -const { expectedLine, paintPreFlight, preFlightNodes, preFlightRows, settle } = await import("../../dist/map-pre-flight.js"); +const { expectedLine, issuesOf, paintPreFlight, preFlightNodes, preFlightRows, settle } = await import("../../dist/map-pre-flight.js"); const { windowBinding } = await import("../../dist/keys.js"); const { initial } = await import("../../dist/settings.js"); @@ -174,11 +174,13 @@ test("the overlay opened again draws its status region empty before its words", assert.equal(region().text, "No prediction: the writer is not set. Pick the parts by hand."); }); -test("issues that could not be read say so with the reason, and the text box and Pick parts by hand stay", () => { +test("issues that could not be read say so with the reason, and the text box and Pick parts by hand stay", async () => { const calls = []; - const nodes = /** @type {any[]} */ (preFlightNodes({ kind: "start", issues: { failed: "To get started with GitHub CLI, run: gh auth login" } }, doc, state, acts(calls))); + const issues = await issuesOf(Promise.reject(new Error("gh: not logged in to github.com\nrun gh auth login"))); + assert.deepEqual(issues, { failed: "gh: not logged in to github.com" }, "the reason's first line"); + const nodes = /** @type {any[]} */ (preFlightNodes({ kind: "start", issues }, doc, state, acts(calls))); const said = texts(nodes); - assert.match(said, /Couldn't read the open issues: To get started with GitHub CLI, run: gh auth login/); + assert.match(said, /Couldn't read the open issues: gh: not logged in to github.com/); assert.doesNotMatch(said, /No open issues/); const [field] = nodes.flatMap((node) => node.find("textarea")); assert.ok(field, "the free text is a text field"); diff --git a/ui/tests/notice.test.mjs b/ui/tests/notice.test.mjs index 8429842d5..ff8a50954 100644 --- a/ui/tests/notice.test.mjs +++ b/ui/tests/notice.test.mjs @@ -9,7 +9,7 @@ let present = true; globalThis.document = /** @type {any} */ ({ getElementById: (id) => (id === "connection" ? connection : present ? line : null) }); const logged = []; globalThis.window = /** @type {any} */ ({ __TAURI__: { log: { warn: async (m) => logged.push(["warn", m]), error: async (m) => logged.push(["error", m]) } } }); -const { showError, dismissNotice, setSettingsErrors, showNotice } = await import("../../dist/notice.js"); +const { showError, dismissNotice, dropUnreachable, setSettingsErrors, showNotice } = await import("../../dist/notice.js"); const { failure, logLine } = await import("../../dist/dom.js"); // What the page does with a `server-error` event (`main.ts`), whose payload is the error's message. const serverError = showError; @@ -126,3 +126,21 @@ test("an unreachable error draws nothing while the connection line shows, and dr serverError(unreachable); assert.deepEqual(lines(), []); }); + +// An unreachable error drawn before the connection line showed is stale once the connection changes (#1046): the line says it, or +// plotkeeper is back. The page drops it whenever the stream's state changes (`main.ts`); the other lines stay. +test("a drawn unreachable error goes when the connection changes, and the other lines stay", () => { + showNotice("Claude Code 3 changed."); + serverError("rename: not a session id"); + serverError("select: plotkeeper is not reachable"); + dropUnreachable(); + assert.deepEqual(lines(), ["Claude Code 3 changed.", "rename: not a session id"]); + assert.equal(line.hidden, false); + dismissNotice(); + assert.deepEqual(lines(), ["Claude Code 3 changed."], "a dismiss still removes the error that stayed"); + line.textContent = ""; + serverError("select: plotkeeper is not reachable"); + dropUnreachable(); + assert.deepEqual(lines(), []); + assert.equal(line.hidden, true, "a line left empty hides"); +}); diff --git a/ui/transport.ts b/ui/transport.ts index 2a3369d4e..76845a75d 100644 --- a/ui/transport.ts +++ b/ui/transport.ts @@ -2,9 +2,11 @@ // `POST /api/<command>` with its arguments as JSON, an event comes on the one `EventSource` at `/events`, and a log line is posted to // `/api/log`. It installs the seam `dom.ts` reads, so nothing else in the page knows the transport. -import { UNREACHABLE } from "./notice.js"; import type { Command } from "./types.js"; +/** What a command rejects with when plotkeeper cannot be reached (#1046): the one message for it, which the notice line reads. */ +export const UNREACHABLE = "plotkeeper is not reachable"; + // The seam: commands, events and log lines. Its global keeps the name the Tauri shell gave it (#332 archived the shell), since the node // tests stand in for it under that name; only this file and `dom.ts`'s one reader name it. type Seam = { @@ -92,4 +94,5 @@ export function transport(): Seam { }; } -window.__TAURI__ ??= transport(); +// A test's page that imports the notice line may have no window. +if (globalThis.window) window.__TAURI__ ??= transport(); From 575470e165e3da06c516602229d0ce583ea6bae7 Mon Sep 17 00:00:00 2001 From: Daniel Rispler <danielrispler@gmail.com> Date: Tue, 1 Dec 2026 23:38:32 +0200 Subject: [PATCH 11/11] Studio: the hint table's follow-up step is `after`, as Biome refuses a `then` key (#1036) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CVqACafozqqdDZevv65PCa --- ui/tests/hint-redraw.test.mjs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ui/tests/hint-redraw.test.mjs b/ui/tests/hint-redraw.test.mjs index 7f683a903..244dc5e9c 100644 --- a/ui/tests/hint-redraw.test.mjs +++ b/ui/tests/hint-redraw.test.mjs @@ -124,9 +124,9 @@ test("the step's detail drawn without a shortened path opens no hint left from t // gets no pointerleave, so its hint closes within one prune tick, with no further `hint()` call or redraw, as when closing the left panel // clears History under an open row hint; a trigger `patch()` kept across a redraw keeps it open, by either path. `open` is how the hint // opens: "pointer", the listener path's hover; "interest", the browser's `interestfor` opening it with no call of the page's, after the -// prunes `hint()` queued have ended. `then` checks what follows. +// prunes `hint()` queued have ended. `after` checks what follows. const keyedDraw = (/** @type {string} */ tag, /** @type {string} */ key) => () => [hint(keyed(document.createElement(tag), key), "Kept words")]; -/** @type {{ name: string, draw: () => any[], open: "pointer" | "interest", change: (line: any, draw: () => any[]) => void, shows: string[], then?: (line: any, trigger: any, shown: any) => void }[]} */ +/** @type {{ name: string, draw: () => any[], open: "pointer" | "interest", change: (line: any, draw: () => any[]) => void, shows: string[], after?: (line: any, trigger: any, shown: any) => void }[]} */ const openAcross = [ { name: "an open listener-path hint whose trigger is removed closes within one prune tick", draw: keyedDraw("span", "name-removed"), open: "pointer", change: (line) => line.replaceChildren(), shows: [] }, { name: "an open hint whose span patch() kept across a redraw stays open", draw: keyedDraw("span", "kept-span"), open: "pointer", change: (line, draw) => patch(line, draw()), shows: ["Kept words"] }, @@ -139,7 +139,7 @@ const openAcross = [ open: "pointer", change: (line, draw) => patch(line, draw()), shows: ["Show or hide the sessions"], - then: (line, trigger, shown) => { + after: (line, trigger, shown) => { assert.equal(line.childNodes[0], trigger, "patch keeps the summary"); trigger.listeners.pointerleave({}); mock.timers.tick(200); @@ -153,7 +153,7 @@ const openAcross = [ open: "pointer", change: (line) => line.replaceChildren(), shows: [], - then: (line, trigger, shown) => { + after: (line, trigger, shown) => { mock.timers.tick(600); assert.ok(inHints(shown.getAttribute("id")), "the hint stays in #hints while its trigger is kept off the page"); patch(line, [trigger]); @@ -165,7 +165,7 @@ const openAcross = [ }, }, ]; -for (const { name, draw, open: how, change, shows, then } of openAcross) { +for (const { name, draw, open: how, change, shows, after } of openAcross) { test(name, () => { const line = row(); patch(line, draw()); @@ -184,6 +184,6 @@ for (const { name, draw, open: how, change, shows, then } of openAcross) { change(line, draw); mock.timers.tick(300); assert.deepEqual(open().map((node) => node.textContent), shows, "within one prune tick"); - then?.(line, trigger, shown); + after?.(line, trigger, shown); }); }