Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design/v5/live/after/live-1440-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design/v5/live/after/live-1440-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design/v5/live/after/live-2560-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design/v5/live/after/live-2560-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design/v5/live/after/live-375-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design/v5/live/after/live-375-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design/v5/live/after/wall-1440.png
Binary file added docs/design/v5/live/after/wall-2560.png
Binary file added docs/design/v5/live/before/live-1440-dark.png
Binary file added docs/design/v5/live/before/live-2560-dark.png
Binary file added docs/design/v5/live/before/live-375-dark.png
Binary file added docs/design/v5/live/before/live-375-light.png
81 changes: 68 additions & 13 deletions public/app.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
// live.setkernel.com, v3 "Day" (setkernel-live#48; the design is docs/design/v3/day). One sentence on
// top says who is doing what; under it, the last 24 hours, one lane per engineer, with the Now
// column at the right edge. Live data comes from /api/state and /api/replay, then the WebSocket
// (/ws); ?demo runs a sample day through the same reducers as the Durable Object. Everything shown
// is built with textContent and attributes, never innerHTML, so nothing in a batch can inject markup.
// live.setkernel.com, v5 (setkernel-live#94): Showcase's page around v3's "Day" (setkernel-live#48;
// docs/design/v3/day). One sentence says who is doing what; under it, the last 24 hours, a lane for
// each engineer the feed sends, with the Now column at the right edge. Live data comes from /api/state
// and /api/replay, then the WebSocket (/ws); ?demo runs a sample day through the same reducers as the
// Durable Object. Demo mode (the dialog) walks one real public change in seven steps (lib/walk.js).
// Everything shown is built with textContent and attributes, never innerHTML, so nothing in a batch
// can inject markup.
import { ENGINEERS, applyBatch, emptyReplay, homeDay, recordReplay, view } from "/lib/state.js";
import { OFFLINE_AFTER_MS, createAnnouncer, fitHeadline, freshness, headline, plain, todaySince, zoneName } from "/lib/words.js";
import { OFFLINE_AFTER_MS, clock, createAnnouncer, fitHeadline, freshness, headline, isSilent, plain, todaySince, zoneName } from "/lib/words.js";
import { reviewers } from "/lib/line.js";
import { BIN, BINS, keyItems, prep, readout, scrubKey, tableRows } from "/lib/day.js";
import { BIN, BINS, keyItems, lanesOf, prep, readout, scrubKey, tableRows } from "/lib/day.js";
import { fitWall, pageMode } from "/lib/layout.js";
import { drawNowList, drawTall, drawWide, fillLegend, fillTable } from "/lib/chart.js";
import { drawNowList, drawTall, drawWide, fillLegend, fillTable, unit } from "/lib/chart.js";
import { busyDay, downDay, quietDay, runDay } from "/lib/demo.js";
import { mountStepper, steps } from "/lib/walk.js";

const $ = (id) => document.getElementById(id);
const root = document.documentElement;
Expand All @@ -28,8 +31,11 @@ let D = null, plot = null, scrub = null, mode = null, drawing = false, tableKey
const offline = () => Boolean(current.lastIngest) && serverNow() - current.lastIngest > OFFLINE_AFTER_MS;

function fillWords() {
const targets = Object.fromEntries(Object.entries(reviewers(current.agents, current.line, ENGINEERS)).map(([author, reviewer]) => [reviewer, author]));
const hl = headline({ ...current, now: serverNow(), timeZone: TZ, names: ENGINEERS, targets });
// only the engineers the feed sends: no other lane, and no other name in the words
const lanes = lanesOf(current);
const targets = Object.fromEntries(Object.entries(reviewers(current.agents, current.line, lanes)).map(([author, reviewer]) => [reviewer, author]));
const feed = (current.feed ?? []).filter((e) => lanes.includes(e?.agent));
const hl = headline({ ...current, feed, now: serverNow(), timeZone: TZ, names: lanes, targets });
root.classList.remove("mood-live", "mood-quiet", "mood-offline", "mood-waiting");
root.classList.add(`mood-${hl.mood}`);
const h1 = $("headline");
Expand All @@ -52,19 +58,55 @@ function fillWords() {
// the Halifax day (hq#177, question 5), on the visitor's clock
const now = serverNow();
$("chart-sub").textContent = `Times in ${zoneName(now, TZ)}. Today's counts ${todaySince(now, TZ)}.`;
showBanner(hl.mood);
showFresh(hl.mood);
}

const glyph = (id, g) => $(id).setAttribute("href", `#${g}`);

// The page's own state, above the headline: nothing when the office is at work.
const BANNERS = {
offline: () => ["g-off", false, `Updates stopped at ${clock(current.lastIngest, TZ)}`, "Everything below is the last picture the page had, kept as it was."],
waiting: () => ["g-wait", true, "Waiting for the first update", "Nothing has arrived yet. Numbers show a dash until they are real, not a zero."],
quiet: () => ["g-info", true, "A quiet spell: nobody is working right now", "The lanes show the day so far. New work appears here by itself."],
};
function showBanner(mood) {
const b = $("banner");
b.hidden = !BANNERS[mood];
if (b.hidden) return;
const [g, calm, head, text] = BANNERS[mood]();
glyph("banner-g", g);
b.classList.toggle("calm", calm);
$("banner-h").textContent = head;
$("banner-t").textContent = text;
}

// "About a minute behind" in place of LIVE (hq#177, question 4): events leave the office 60 s late.
// Offline says only how long ago; waiting, and the demo, say nothing of the office.
function showFresh(mood = root.classList.contains("mood-offline") ? "offline" : "live") {
function showFresh(mood = root.classList.contains("mood-offline") ? "offline" : root.classList.contains("mood-waiting") ? "waiting" : "live") {
const fresh = DEMO ? "" : freshness(current.lastIngest, serverNow());
$("fresh").textContent = !fresh ? "" : mood === "offline" ? fresh : `About a minute behind · ${fresh}`;
glyph("fresh-g", DEMO ? "g-info" : mood === "offline" ? "g-off" : mood === "waiting" ? "g-wait" : "g-live");
$("fresh-g").parentNode.toggleAttribute("hidden", !DEMO && !fresh);
showConn(mood, fresh);
}

// The chip in the top bar: the page's connection in a few words, a glyph beside them, never colour alone.
function showConn(mood, fresh) {
const down = lanesOf(current).filter((n) => isSilent(current.agents?.[n])).length;
const [g, bad, words] = DEMO ? ["g-info", false, "Demo: sample data"]
: mood === "waiting" ? ["g-wait", false, "Waiting for the first update"]
: mood === "offline" ? ["g-off", true, `Offline · last update ${clock(current.lastIngest, TZ)}`]
: down ? ["g-silent", true, `Live · ${down === 1 ? "one engineer" : `${down} engineers`} not reporting`]
: ["g-live", false, `Live · ${fresh}`];
glyph("conn-g", g);
$("conn").classList.toggle("bad", bad);
$("conn-t").textContent = words;
}

function render() {
if (!$("plot").clientWidth) return; // not laid out (yet): nothing to measure the chart by
mode = pageMode(innerWidth, WALL);
mode = pageMode(innerWidth / unit(), WALL); // in the chart's units: the root font grows with the screen
root.dataset.mode = mode;
const nowS = Math.floor(serverNow() / 1000);
const oldT0 = D?.t0;
Expand Down Expand Up @@ -156,7 +198,8 @@ function apply(msg) {
if (msg.t === "batch" && Array.isArray(msg.events)) {
// the page keeps its own copy of the replay buffer up to date, with the same reducer
replay = recordReplay(replay, { events: msg.events }, serverNow());
announcer.add(msg.events);
const lanes = lanesOf(current);
announcer.add(msg.events.filter((e) => lanes.includes(e?.agent)));
}
render();
}
Expand Down Expand Up @@ -232,6 +275,18 @@ function startDemo() {
}, 2000);
}

// ---- Demo mode: a full-screen dialog, drawn the first time it opens; focus goes back to its opener
let stepper = null, opener = null;
function openDemo(ev) {
stepper ??= mountStepper($("steps"), steps(TZ));
opener = ev.currentTarget;
$("demo").showModal();
}
$("demo-open").addEventListener("click", openDemo);
$("how-open").addEventListener("click", openDemo);
$("demo-close").addEventListener("click", () => $("demo").close());
$("demo").addEventListener("close", () => (opener ?? $("demo-open")).focus());

// keep "updated N s ago" ticking, and the mood, the window and "Today since" moving when nothing arrives
setInterval(() => { if (!document.hidden) showFresh(); }, 1000);
setInterval(() => { if (!document.hidden) render(); }, 15_000);
Expand Down
2 changes: 1 addition & 1 deletion public/early.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Runs before the first paint (a classic script in <head>, since the CSP allows no inline
// script): ?wall picks the wall, a fixed 16:9 canvas in one dark theme (hq#177, question 7), so
// nothing shifts or flashes afterwards. The page itself has one theme and stores nothing.
// nothing shifts or flashes afterwards. The page follows the system's light or dark and stores nothing.
(() => {
if (/[?&]wall(=|&|$)/.test(location.search)) document.documentElement.classList.add("wall");
})();
Binary file not shown.
Binary file added public/fonts/manrope-latin-800-normal.woff2
Binary file not shown.
Loading
Loading