The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Boss Mode: four viewer prototypes for ⌘B's office (#1169)
Dee1f265e50761e
diff --git a/docs/research/2026-10-11-boss-mode/README.md b/docs/research/2026-10-11-boss-mode/README.mdnew file mode 100644index 000000000..06064e8ff--- /dev/null+++ b/docs/research/2026-10-11-boss-mode/README.md@@ -0,0 +1,177 @@+# Boss Mode: ⌘B's office++2026-10-11. ⌘B sends a typed task to the harness it belongs to, or starts a new one, in about 0.6 s+(`docs/design/2026-10-09-auto-router.md`). It has to stay that fast, so it stays a box. Boss Mode is a+Store harness in Essentials that serves as ⌘B's office: a viewer of everything ⌘B dispatched and+where each task stands now. It shows which harness took a task, whether it is working, waiting on you,+done or failed, how long ago, and on which machine. The real agent chat sits to its right+(70% viewer / 30% chat, `desktop/design/dsh-workspace.md`), where you ask the boss "where is the ledger+migration?", "what's stuck?", "what finished overnight?".++These are four viewer prototypes for that office. They were made the way the+[Memories brain prototypes](../2026-10-10-memory-brain/README.md) were made: one shared data module,+a loopback server that can show your real desk, an invented desk by default, and four concepts that+each own one idea. Each has to answer two questions at a glance: **what did I hand off, and what+needs me?**++## How to open them++```bash+node docs/research/2026-10-11-boss-mode/serve.mjs 47612+open http://127.0.0.1:47612/ # an invented desk that keeps moving+open "http://127.0.0.1:47612/?real" # your own desk, read only+```++On the invented desk, tasks finish, ask questions and arrive while you watch. `?still` holds it in+place (the screenshots use it), and `?select=d06` opens on one task. Every page also opens straight from+the file system on the invented desk. Nothing here sends anything to a harness: Enter on a task that+needs you only says what Harness would do ("would bring it forward").++## Four concepts++| | Taken from | The one idea | At a glance |+|---|---|---|---|+| [Approach](approach.html) | Air traffic control: an approach radar, flight strips | **The nearer the centre, the more it needs you** | Amber targets hold at fixes beside you; finished ones line up on final |+| [The Pass](pass.html) | A restaurant's expo station: the ticket rail, the heat lamps, the bump bar | **Finished work dies in the window if you leave it there** | "ALL DAY 6 FIRED · 3 NEED YOU · 8 UP · 2 86'D" |+| [Switchboard](switchboard.html) | A cord switchboard: jacks, supervisory lamps, toll tickets | **Where your words went, and how sure the operator was** | Flashing lamps want you; steady white lamps mean pull the cord |+| [Score](score.html) | A conductor's full score: cutaway staves, rehearsal marks, fermatas | **What happened since you handed it off, read like music** | Amber fermatas held at "now"; a bright *Fine* is unread |++1. **Approach.** You are the airfield at the centre of a radar scope. ⌘B is a departure: the task takes off+ and climbs out to its machine's sector. Working tasks fly there, and the sweep paints them once per+ scan, leaving history trails. A task that asks you something enters the holding pattern at its+ machine's fix, near the field, and flashes. Finished tasks line up on the final approach course and+ wait for you to land them (read them). A failure squawks an emergency; a task ⌘B sent nowhere sits at+ the field with "no route". Harnesses ⌘B never sent anything to show as untracked primary returns. The+ strip bay on the right holds a flight strip for every task, most urgent first, and the ATIS line+ counts the desk. Keys: `tab`, `h f e` (holding, final, emergency), `⏎` land, `space` land the next,+ `u` undo, `/` find, `t` trails, `s` strips.+2. **The Pass.** Every handoff is a thermal-paper ticket that the printer fires onto the steel rail, oldest first.+ A cook with a question flags its ticket CHEF? and clips the question to it, with a waiting timer+ that turns red. Finished work comes up on the pass under heat lamps. It starts warm, with steam, and+ cools while it waits. Past three hours it is "dying in the window". Read tickets go on the spike;+ failed ones are 86'd on the board. The stations show every cook on every machine. The keyboard is a+ kitchen's bump bar: `← →`, `↑ ↓` between rail, pass, spike and 86, `1–9`, `⏎` read, `b` pick up,+ `r` recall, `a` call all day.+3. **Switchboard.** ⌘B is the operator. Every harness on every machine is a line with a jack, a jewel lamp+ and a designation strip, in a panel per machine under a brass nameplate. Every task is a cord from the+ keyshelf to the line that took it. The lamps work the way supervisory lamps did: a flashing lamp is a+ line signalling the operator (it needs you), a steady white lamp means the call is over and the cord is+ waiting to be pulled (done, unread), red is trouble, green is talking. The selected cord shows+ **Jev's confidence** on the cord, and a **ghost cord** runs to the line ⌘B nearly chose. Its toll ticket+ logs the call: what you said, the line, the operator's reasoning, and placed, connected and hung-up+ times. Enter listens in: the call's rhythm since it was placed, your turns above the line and its+ turns below. Keys: `← →` cords, `n` flashing, `w` hung up, `x` trouble, `0–9` dial a line, `⏎` listen+ in, `p` pull the cord, `r` ring.+4. **Score.** The desk is a full score. Time runs left to right, with one staff per harness, grouped and+ bracketed by machine as an orchestra is by family. Like an engraver's measures, each bar is as wide as+ what happened in it, so a quiet night folds up and a busy hour opens out. Each task you handed off is a+ boxed rehearsal mark, and its cue drops to the staff that took it. Turns are notes, beamed when the+ harness played fast; your own turns are gold accents. A harness that finished ends in a double bar and+ *Fine*. One that needs you holds a **fermata**: its last note is sustained, glowing, to "now". It is a+ cutaway score, so staves appear when a harness enters, and harnesses ⌘B never sent to are one-line+ percussion staves. Keys: `j k`, `n` next held, `f` next unread, `[ ]` cues, `h l` time, `+ −` zoom,+ `⏎` the part (the score makes room for it), `space` plays the night back, and `m` adds sound.++All four are keyboard first, run without libraries or network, and render every task, question and+summary as text only, because those are written by people and models and may contain anything. In+headless Chromium at the pane's size (1300×1100) and at 760×980, none logged an error or requested+anything off this computer, on the still desk, on the moving desk for 70 s with keys pressed, and on a+real desk (`shoot.mjs` checks the first).++## Screenshots (invented desk only)++| | |+|---|---|+|  | **approach.jpg**: three tasks holding near the field (one for 9 h), eight on final, two emergencies, the laptop's sector closed. **approach-final.jpg**: a finished task picked on final. **approach-narrow.jpg**: the strip bay drops below the scope. |+|  | **pass.jpg**: the rail with three CHEF? flags, eight plates up and cooling, the spike, the 86 board. **pass-ticket.jpg**: the ledger migration's ticket read in full. **pass-narrow.jpg**: the stations fold away. |+|  | **switchboard.jpg**: the ledger migration's cord to build-box, "Jev 0.90", its ghost to the next best line, and the toll ticket. **switchboard-listen.jpg**: listening in. **switchboard-narrow.jpg**. |+|  | **score.jpg**: 22 hours on the page, three fermatas held, the night folded up. **score-part.jpg**: a held harness's part beside the score. **score-narrow.jpg**. |++Run `PLAYWRIGHT=<path to playwright/index.mjs> node docs/research/2026-10-11-boss-mode/shoot.mjs [page]`+to retake them; it fails on any console error or off-computer request.++## The data model: what the Boss Mode harness would keep++The prototypes all read one shape (`boss-data.js`). The invented desk is built in it. The real adapter+(`serve.mjs`) fills as much of it as Harness keeps today.++```+desk+ now, real+ machines { id, name, here, online, since }+ harnesses { id, machine, engine, name, project, state, since, createdAt, lastTurnAt, tokens,+ question, summary, turns: [{ at, by: you | agent, size }], boss }+ dispatches — the office's book: one row per task handed to ⌘B+ id, n #06+ at when you pressed Return+ text, via what you typed or said; box | voice | phone | dial | tui+ decision { kind: session | new | none, p, runnerUp: { name, p }, why, ms, cost }+ harness, machine the harness it landed in (a new one when decision.kind = new)+ created, landedAt whether ⌘B made the harness; when the words were typed into it+ state, since routing | working | asking | done | failed | stopped | offline | undelivered+ history [{ at, state }] every change since the dispatch+ question what it is asking you, when asking+ summary, error, pr what it did, what went wrong, the pull request it opened+ seenAt when you picked a finished one up: done and not seen is "needs you"+```++"Needs you" has four causes: **asking**, **failed**, **undelivered** (⌘B decided nothing, so nothing was+sent), and **done but not yet seen**. The fourth is why `seenAt` belongs in the office's book. The+desktop's "done (unread)" (`harness_activity.dart`) depends on a pane having been opened, while the+office's depends on the person having read the result. The prototypes keep `seenAt` in the browser for+now.++## Your real desk (`?real`) and what is missing++`serve.mjs` reads, on each request and never writing:++- **Every harness on every reachable machine**, through the daemon's local bridge, the way Harness+ Monitor does (`machine_select`, then `agents_list` with `monitor: true`, through+ `store/agents/harness-monitor/lib/inventory.mjs`). This gives each harness's state (working, needs+ input, done, failed, stopped, offline), machine, project and tokens.+- **What you said to each harness, and when**, from the session index (`session-search.db`, opened+ read-only through `store/agents/memories/lib/sessions.mjs`).+- **What each harness last said**, from the daemon's turn summaries (`summaries.json`).+- **⌘B's recent prompts**: the `task_box_recent_v1` key of the desktop's state file+ (`~/.harness/desktop-app-v2/state.json`). Only that key is read; that file also holds credentials.+ Each prompt is matched to the newest message with exactly those words in the session index, which+ says when it landed and in which harness.+- **How sure ⌘B was**: the router's `[route]` lines in the daemon log, when they are still there.++**⌘B's routing history is not persisted anywhere usable.** The prompts kept for the box are text only,+with no time or destination. `lastRoutedTask` exists only in memory (`app_state.dart`). The router's log+lines name the chosen harness and the runner-up with their probabilities, but carry neither the text+nor an id, and the log is halved once it passes 10 MB. On one real desk, the one prompt the box+remembered matched no message this computer had indexed. So `?real` shows each harness's latest+message from the last 36 hours as a handoff. Those typed into the pane are marked as such ("typed into+the pane", a cord with no operator), and ⌘B's prompts show as ⌘B's when they can be matched. Each page+says which notes apply.++What the office needs before it can be built for real:++1. **A dispatch log.** The router (`cli/src/services/router.ts`) is the one place every client's decision+ passes, but it only decides; the client acts. It could append each decision (text, time, kind, Jev's+ pick and runner-up, cost) to a small append-only log. The client could then confirm the landing with+ the agent and session it used, which the desktop already knows when it calls `markLanding`. That is+ the `dispatches` table above. The viewer joins it to `agents_list` for the live state.+2. **States that survive a restart.** `monitor.activity` is `done` or `failed` only from the last+ `turn_ended` held in the daemon's memory (`cli/src/lib/harnessMonitor.ts`), so a daemon restart+ forgets that a harness finished or failed.+3. **The question itself.** A `commander_question` reaches a tool connection only when it connects+ (`cli/src/core/questions.ts`), so a viewer reconnects to learn what is being asked. The office wants+ the question text with the agent row.++## The workspace++These pages are the left 70% of the workspace. The right 30% is the Boss Mode agent's chat. Its tools+would be the same reads `serve.mjs` makes, plus the dispatch log. A page can tell the chat what "this+one" means by writing its selection to the viewer's state file, as Memories does, so "answer it" or+"why did it fail?" in the chat applies to the strip, ticket, cord or staff that is selected.++## Files++- `boss-data.js`: the shared data module, the invented desk and its simulation, and `?real`.+- `serve.mjs`: the loopback-only server and the read-only real-desk adapter.+- `index.html`, `index.js`: the picker.+- `approach.*`, `pass.*`, `switchboard.*`, `score.*`: the four prototypes.+- `shoot.mjs`: takes the screenshots and checks every page, on the invented desk only.diff --git a/docs/research/2026-10-11-boss-mode/approach-final.jpg b/docs/research/2026-10-11-boss-mode/approach-final.jpgnew file mode 100644index 000000000..e9683b1f1Binary files /dev/null and b/docs/research/2026-10-11-boss-mode/approach-final.jpg differdiff --git a/docs/research/2026-10-11-boss-mode/approach-narrow.jpg b/docs/research/2026-10-11-boss-mode/approach-narrow.jpgnew file mode 100644index 000000000..9e00adf1fBinary files /dev/null and b/docs/research/2026-10-11-boss-mode/approach-narrow.jpg differdiff --git a/docs/research/2026-10-11-boss-mode/approach.html b/docs/research/2026-10-11-boss-mode/approach.htmlnew file mode 100644index 000000000..66799a9a1--- /dev/null+++ b/docs/research/2026-10-11-boss-mode/approach.html@@ -0,0 +1,110 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width,initial-scale=1">+<title>Approach</title>+<style>+ :root {+ --bg: #020604; --text: #cfe9da; --muted: #7c9a8a; --faint: #44594d; --line: #13231b;+ --green: #6fdc9c; --amber: #ffb547; --red: #ff5a4f; --ice: #bfe8ff; --grey: #5d6b64;+ --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;+ color-scheme: dark;+ }+ * { box-sizing: border-box; }+ html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 12px/1.45 var(--mono); }+ #app { position: fixed; inset: 0; display: grid; grid-template-columns: 1fr 352px; }+ body.nostrips #app { grid-template-columns: 1fr 0; }+ body.nostrips #bay { display: none; }+ #scope { position: relative; min-width: 0; min-height: 0; }+ canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }++ #atis { position: absolute; left: 18px; top: 14px; right: 18px; pointer-events: none; white-space: nowrap; overflow: hidden; }+ #atis .t { color: var(--green); letter-spacing: .38em; font-weight: 600; font-size: 13px; }+ #atis .l { color: var(--muted); margin-top: 3px; letter-spacing: .06em; overflow: hidden; text-overflow: ellipsis; }+ #atis .l b { color: var(--text); font-weight: 500; }+ #atis .l .hot { color: var(--amber); }+ #atis .l .em { color: var(--red); }+ #atis .l .fin { color: var(--ice); }+ #clock { position: absolute; right: 18px; top: 14px; color: var(--muted); letter-spacing: .12em; text-align: right; pointer-events: none; }+ #clock .s { color: var(--faint); margin-top: 3px; letter-spacing: .06em; }++ #filter { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); padding: 6px 12px; border: 1px solid #1f3a2c; background: rgba(2,8,5,.85);+ color: var(--text); font-size: 13px; display: none; white-space: nowrap; border-radius: 3px; }+ #filter.on { display: block; }+ #filter .c { color: var(--green); }+ #filter i { display: inline-block; width: .6em; height: 1.05em; background: var(--text); transform: translateY(2px); animation: blink 1.05s steps(1) infinite; }+ #filter .n { color: var(--faint); margin-left: 10px; }+ @keyframes blink { 50% { opacity: 0; } }++ #keys { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 12px; pointer-events: none; }+ #keys kbd { font: inherit; color: var(--muted); }+ #toast { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); color: var(--ice); letter-spacing: .08em; opacity: 0; transition: opacity .4s; pointer-events: none; white-space: nowrap; }+ #toast.on { opacity: 1; }++ /* the strip bay: flight progress strips, most urgent on top */+ #bay { border-left: 1px solid var(--line); background: linear-gradient(#030a07, #020604); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }+ #bay header { padding: 14px 14px 8px; color: var(--muted); letter-spacing: .3em; font-size: 11px; display: flex; justify-content: space-between; }+ #bay header span:last-child { letter-spacing: .06em; color: var(--faint); }+ #strips { flex: 1; overflow-y: auto; padding: 0 10px 40px; scrollbar-width: thin; scrollbar-color: #1d3328 transparent; }+ .group { margin: 12px 0 6px; color: var(--faint); letter-spacing: .24em; font-size: 10px; display: flex; gap: 8px; align-items: center; }+ .group::after { content: ''; flex: 1; height: 1px; background: var(--line); }+ .group b { color: var(--muted); font-weight: 500; }+ .strip { display: grid; grid-template-columns: 84px 1fr 54px; border: 1px solid #16271e; border-left: 3px solid var(--edge, #2b4a3a); margin: 0 0 5px; background: #06100b; cursor: pointer; }+ .strip > div { padding: 4px 7px; min-width: 0; }+ .strip > div + div { border-left: 1px solid #13231b; }+ .strip .cs { color: var(--text); font-weight: 600; letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+ .strip .ty { color: var(--faint); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+ .strip .rt { color: var(--muted); font-size: 10.5px; letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+ .strip .tx { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+ .strip .tm { text-align: right; color: var(--muted); font-size: 10.5px; }+ .strip .tm b { display: block; color: var(--edge, var(--text)); font-weight: 600; font-size: 11px; letter-spacing: .06em; }+ .strip .more { grid-column: 1 / -1; border-left: 0 !important; border-top: 1px solid #13231b; display: none; padding: 8px 9px 9px; color: var(--text); white-space: normal; }+ .strip.sel { background: #0b1d14; border-color: #24402f; outline: 1px solid var(--edge); }+ .strip.sel .more { display: block; }+ .strip.sel .tx { white-space: normal; }+ .strip.dim { opacity: .28; }+ .more .said { color: var(--edge); margin-bottom: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }+ .more .row { color: var(--muted); font-size: 11px; margin-top: 3px; overflow-wrap: anywhere; }+ .more .row b { color: var(--text); font-weight: 500; }+ .more .act { color: var(--faint); margin-top: 8px; font-size: 11px; }+ .more .act kbd { font: inherit; color: var(--text); }+ .strip.hold { --edge: var(--amber); }+ .strip.em { --edge: var(--red); }+ .strip.fin { --edge: var(--ice); }+ .strip.enr { --edge: var(--green); }+ .strip.cst { --edge: var(--grey); }+ .strip.gnd { --edge: #34463c; opacity: .62; }+ .strip.hold.flash { animation: stripflash 1.1s steps(1) infinite; }+ @keyframes stripflash { 50% { background: #1a1205; } }+ #loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--faint); letter-spacing: .3em; pointer-events: none; }++ @media (max-width: 980px) {+ #clock { display: none; }+ #app { grid-template-columns: 1fr; grid-template-rows: 1fr 38%; }+ body.nostrips #app { grid-template-rows: 1fr 0; }+ #bay { border-left: 0; border-top: 1px solid var(--line); }+ }+ @media (prefers-reduced-motion: reduce) { .strip.hold.flash, #filter i { animation: none; } }+</style>+</head>+<body>+<div id="app">+ <section id="scope" aria-label="Approach radar: every task you handed off, nearer the centre the more it needs you">+ <canvas id="radar"></canvas>+ <div id="atis"><div class="t">APPROACH</div><div class="l" id="atisline"></div></div>+ <div id="clock"></div>+ <div id="toast"></div>+ <div id="filter"><span class="c">/</span> <span id="q"></span><i></i><span class="n" id="qn"></span></div>+ <footer id="keys"></footer>+ </section>+ <aside id="bay" aria-label="Flight strips">+ <header><span>STRIPS</span><span id="baycount"></span></header>+ <div id="strips"></div>+ </aside>+</div>+<div id="loading">acquiring targets</div>+<script src="boss-data.js"></script>+<script src="approach.js"></script>+</body>+</html>diff --git a/docs/research/2026-10-11-boss-mode/approach.jpg b/docs/research/2026-10-11-boss-mode/approach.jpgnew file mode 100644index 000000000..f08b0f893Binary files /dev/null and b/docs/research/2026-10-11-boss-mode/approach.jpg differdiff --git a/docs/research/2026-10-11-boss-mode/approach.js b/docs/research/2026-10-11-boss-mode/approach.jsnew file mode 100644index 000000000..0c3aab701--- /dev/null+++ b/docs/research/2026-10-11-boss-mode/approach.js@@ -0,0 +1,651 @@+// Approach: the desk as an approach radar. You are the field at the centre; every task you handed off is a+// flight. ⌘B is the departure; working tasks fly their machine's sector; a task that needs you holds at+// its fix near the field, flashing; finished ones line up on final, waiting for you to land them (read+// them); a failed one squawks an emergency. The nearer the centre, the more it needs you.+(function () {+ 'use strict'+ const B = window.BossData+ const MONO = getComputedStyle(document.documentElement).getPropertyValue('--mono') || 'monospace'+ const C = { green: '#6fdc9c', amber: '#ffb547', red: '#ff5a4f', ice: '#bfe8ff', grey: '#5d6b64', white: '#eef7f1', dim: '#2f6b4c', ring: '#14271d', text: '#cfe9da', muted: '#7c9a8a', faint: '#44594d' }+ const KIND = {+ hold: { code: 'HLD', color: C.amber, label: 'HOLDING', note: 'asking you' },+ em: { code: 'EM', color: C.red, label: 'EMERGENCY', note: 'failed or went nowhere' },+ fin: { code: 'FNL', color: C.ice, label: 'ON FINAL', note: 'finished, not read' },+ enr: { code: 'WRK', color: C.green, label: 'EN ROUTE', note: 'working' },+ dep: { code: 'HO', color: C.white, label: 'DEPARTING', note: 'just handed off' },+ cst: { code: 'CST', color: C.grey, label: 'COASTING', note: 'machine out of reach' },+ gnd: { code: 'GND', color: '#4c6357', label: 'ON THE GROUND', note: 'read, stopped or answered' },+ }+ const ORDER = ['hold', 'em', 'fin', 'dep', 'enr', 'cst', 'gnd']+ const FINAL_BEARING = Math.PI * 1.25 // 225°: the runway's final approach course runs out to the south-west+ const SCAN_MS = 4200+ const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches++ const canvas = document.getElementById('radar')+ const ctx = canvas.getContext('2d')+ const $ = (id) => document.getElementById(id)+ let desk = null+ let W = 0, H = 0, DPR = 1, cx = 0, cy = 0, R = 100+ let sel = null+ let query = null, typing = false+ let trails = true+ let sweep = 0, lastFrame = performance.now()+ const tracks = new Map() // dispatch id → { shown, trail, lit, seeded }+ const prims = new Map() // harness id → the same, for harnesses ⌘B did not send to+ const landings = new Map() // dispatch id → { from, at }+ let lastLanded = []+ let toastTimer = 0+ let ladder = -Infinity++ // ── what each dispatch is on the scope ──────────────────────────────────────────────────────────────++ function kindOf(d, now) {+ if (d.state === 'routing') return 'dep'+ if (d.state === 'asking') return 'hold'+ if (d.state === 'failed' || d.state === 'undelivered') return 'em'+ if (d.state === 'done') return d.seenAt ? 'gnd' : 'fin'+ if (d.state === 'offline') return 'cst'+ if (d.state === 'working') return d.landedAt && now - d.landedAt < 5000 ? 'dep' : 'enr'+ return 'gnd'+ }+ const callsign = (d) => d.harness ? `${B.engine(B.harness(d.harness)?.engine).call}${d.n}` : `BOSS${d.n}`+ const proj = (d) => { const p = (B.harness(d.harness)?.project ?? 'no route').toUpperCase(); return p.length > 11 ? p.slice(0, 10) + '…' : p }+ function hash(text) { let h = 2166136261; for (const ch of text) { h ^= ch.charCodeAt(0); h = Math.imul(h, 16777619) } return ((h >>> 0) % 10007) / 10007 }+ const matches = (d) => {+ if (!query) return true+ const h = B.harness(d.harness)+ const hay = `${callsign(d)} ${d.text} ${h?.name ?? ''} ${h?.project ?? ''} ${d.machine ?? ''} ${d.question ?? ''} ${d.summary ?? ''}`.toLowerCase()+ return query.toLowerCase().split(/\s+/).filter(Boolean).every((w) => hay.includes(w))+ }++ // ── geometry ────────────────────────────────────────────────────────────────────────────────────────++ const at = (bearing, r) => ({ x: cx + Math.sin(bearing) * r, y: cy - Math.cos(bearing) * r })+ const bearingOf = (p) => { let b = Math.atan2(p.x - cx, -(p.y - cy)); return b < 0 ? b + Math.PI * 2 : b }++ let sectors = []+ function layoutSectors() {+ const ms = [...desk.machines].sort((a, b) => (b.here - a.here) || (b.online - a.online))+ const weight = ms.map((m) => 2 + desk.dispatches.filter((d) => d.machine === m.id && kindOf(d, desk.now) !== 'gnd').length + 0.5 * desk.harnesses.filter((h) => h.machine === m.id && !h.boss).length)+ const total = weight.reduce((a, b) => a + b, 0)+ let b0 = -0.35+ sectors = ms.map((m, i) => {+ const span = (weight[i] / total) * Math.PI * 2+ const s = { machine: m, b0, b1: b0 + span, mid: b0 + span / 2 }+ b0 += span+ // The holding fix sits mid-sector, but never on the final approach course.+ let fix = s.mid+ const off = Math.atan2(Math.sin(fix - FINAL_BEARING), Math.cos(fix - FINAL_BEARING))+ if (Math.abs(off) < 0.42) fix = FINAL_BEARING + Math.sign(off || 1) * 0.42+ s.fix = fix+ return s+ })+ }+ const sectorOf = (machineId) => sectors.find((s) => s.machine.id === machineId) ?? sectors[0]++ function activity(h, now) {+ if (!h) return 0+ let n = 0+ for (let i = h.turns.length - 1; i >= 0 && now - h.turns[i].at < 12 * B.MIN; i--) n+++ return Math.min(1, n / 10)+ }++ /** Where a flight truly is at time t: what the sweep paints when it passes. */+ function truePos(d, kind, t, rank) {+ const h = B.harness(d.harness)+ const s = sectorOf(d.machine)+ if (kind === 'hold') {+ const fix = at(s.fix, 0.3 * R)+ const u = { x: Math.sin(s.fix), y: -Math.cos(s.fix) }, v = { x: -u.y, y: u.x }+ const L = 0.075 * R, rr = 0.026 * R+ const per = 2 * L + 2 * Math.PI * rr+ const phase = (((t / 26000) + rank.i / Math.max(1, rank.n)) % 1) * per+ let a, b+ if (phase < L) { a = -L / 2 + phase; b = rr }+ else if (phase < L + Math.PI * rr) { const th = (phase - L) / rr; a = L / 2 + Math.sin(th) * rr; b = Math.cos(th) * rr }+ else if (phase < 2 * L + Math.PI * rr) { a = L / 2 - (phase - L - Math.PI * rr); b = -rr }+ else { const th = (phase - 2 * L - Math.PI * rr) / rr; a = -L / 2 - Math.sin(th) * rr; b = -Math.cos(th) * rr }+ return { x: fix.x + u.x * a + v.x * b, y: fix.y + u.y * a + v.y * b }+ }+ if (kind === 'fin') return at(FINAL_BEARING, (0.1 + Math.min(0.05, 0.36 / Math.max(1, rank.n)) * rank.i) * R)+ if (kind === 'em') {+ if (d.state === 'undelivered') return at(Math.PI * 0.25 + 0.18 * rank.i, 0.075 * R)+ const c = at(s.mid + 0.32, 0.19 * R)+ const th = t / 5200 + rank.i * 2+ return { x: c.x + Math.cos(th) * 0.014 * R, y: c.y + Math.sin(th) * 0.014 * R }+ }+ // En route, departing and coasting: a place in the machine's sector, further out the longer it has run.+ const span = s.b1 - s.b0+ const age = Math.max(1, (t - (d.landedAt ?? d.at)) / B.MIN)+ const a = Math.min(1, Math.log10(age + 1) / Math.log10(16 * 60))+ const base = { b: s.b0 + span * (0.14 + 0.72 * hash(d.id + (h?.id ?? ''))), r: (0.5 + 0.42 * a) * R }+ const go = kind === 'cst' ? 0 : 0.25 + activity(h, t)+ const ph = hash(d.id) * 6.28+ const pos = at(base.b + 0.05 * Math.sin(t / 21000 * go + ph) * Math.min(1, span), base.r + 0.03 * R * Math.cos(t / 17000 * go + ph))+ if (kind === 'dep') {+ const k = d.landedAt ? Math.min(1, (t - d.landedAt) / 5000) : 0+ const e = 1 - Math.pow(1 - k, 3)+ return { x: cx + (pos.x - cx) * (0.04 + 0.96 * e), y: cy + (pos.y - cy) * (0.04 + 0.96 * e) }+ }+ return pos+ }++ function primPos(h, t) {+ const s = sectorOf(h.machine)+ const span = s.b1 - s.b0+ const working = h.state === 'working'+ const r = (working ? 0.62 + 0.3 * hash(h.id + 'r') : 0.9 + 0.06 * hash(h.id + 'r')) * R+ return at(s.b0 + span * (0.08 + 0.84 * hash(h.id)) + (working ? 0.04 * Math.sin(t / 19000 + hash(h.id) * 6) : 0), r)+ }++ // ── the flights on the scope now, and the strips in the bay ────────────────────────────────────────++ function flights(now) {+ const out = desk.dispatches.map((d) => ({ d, kind: kindOf(d, now) }))+ const rankIn = (pred, sort) => { const list = out.filter(pred).sort(sort); list.forEach((f, i) => { f.rank = { i, n: list.length } }) }+ for (const s of sectors) rankIn((f) => f.kind === 'hold' && f.d.machine === s.machine.id, (a, b) => a.d.since - b.d.since)+ rankIn((f) => f.kind === 'fin', (a, b) => a.d.since - b.d.since)+ rankIn((f) => f.kind === 'em' && f.d.state === 'undelivered', (a, b) => a.d.at - b.d.at)+ for (const s of sectors) rankIn((f) => f.kind === 'em' && f.d.state === 'failed' && f.d.machine === s.machine.id, (a, b) => a.d.at - b.d.at)+ for (const f of out) f.rank ??= { i: 0, n: 1 }+ return out+ }+ function stripOrder(list) {+ return [...list].sort((a, b) => ORDER.indexOf(a.kind) - ORDER.indexOf(b.kind)+ || (a.kind === 'fin' ? a.d.since - b.d.since : a.kind === 'hold' ? a.d.since - b.d.since : b.d.at - a.d.at))+ }++ // ── drawing ─────────────────────────────────────────────────────────────────────────────────────────++ function resize() {+ const box = $('scope').getBoundingClientRect()+ DPR = Math.min(2, window.devicePixelRatio || 1)+ W = box.width; H = box.height+ canvas.width = Math.round(W * DPR); canvas.height = Math.round(H * DPR)+ cx = W / 2; cy = H / 2 + 14+ R = Math.max(80, Math.min(W / 2 - 34, (H - 120) / 2))+ tracks.clear(); prims.clear()+ }++ function scope(now) {+ ctx.save()+ ctx.fillStyle = '#010302'; ctx.fillRect(0, 0, W, H)+ const g = ctx.createRadialGradient(cx, cy, 0, cx, cy, R * 1.04)+ g.addColorStop(0, '#06160e'); g.addColorStop(0.7, '#03100a'); g.addColorStop(1, '#020805')+ ctx.fillStyle = g; ctx.beginPath(); ctx.arc(cx, cy, R * 1.02, 0, Math.PI * 2); ctx.fill()+ // Closed sectors: a machine that is asleep.+ for (const s of sectors) {+ if (s.machine.online) continue+ ctx.save(); ctx.beginPath(); ctx.moveTo(cx, cy); ctx.arc(cx, cy, R, s.b0 - Math.PI / 2, s.b1 - Math.PI / 2); ctx.closePath(); ctx.clip()+ ctx.strokeStyle = 'rgba(93,107,100,.07)'; ctx.lineWidth = 1+ for (let k = -R * 2; k < R * 2; k += 9) { ctx.beginPath(); ctx.moveTo(cx + k, cy - R); ctx.lineTo(cx + k + R * 2, cy + R); ctx.stroke() }+ ctx.restore()+ }+ // Range rings, and what each band means.+ ctx.lineWidth = 1+ for (const [k, word] of [[0.24, 'NEEDS YOU'], [0.47, 'FINAL'], [0.72, ''], [1, 'ON ITS OWN']]) {+ ctx.strokeStyle = k === 1 ? '#1f3a2c' : C.ring+ ctx.setLineDash(k === 0.72 ? [2, 6] : [])+ ctx.beginPath(); ctx.arc(cx, cy, k * R, 0, Math.PI * 2); ctx.stroke()+ if (word) {+ ctx.setLineDash([]); ctx.font = `10px ${MONO}`; ctx.fillStyle = '#2b4637'; ctx.textAlign = 'center'+ const p = at(Math.PI * 0.79, k * R - 7)+ ctx.save(); ctx.translate(p.x, p.y); ctx.rotate(-Math.PI * 0.21); ctx.fillText(spaced(word), 0, 0); ctx.restore()+ }+ }+ ctx.setLineDash([])+ // Compass rose on the rim.+ for (let deg = 0; deg < 360; deg += 5) {+ const b = deg * Math.PI / 180+ const len = deg % 30 === 0 ? 10 : deg % 10 === 0 ? 6 : 3+ const a = at(b, R), c = at(b, R - len)+ ctx.strokeStyle = deg % 30 === 0 ? '#2d4b3b' : '#1a2e24'+ ctx.beginPath(); ctx.moveTo(a.x, a.y); ctx.lineTo(c.x, c.y); ctx.stroke()+ if (deg % 30 === 0) {+ const p = at(b, R + 12); ctx.fillStyle = '#2e4a3b'; ctx.font = `9.5px ${MONO}`; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'+ ctx.fillText(String(deg).padStart(3, '0'), p.x, p.y)+ }+ }+ // Sector boundaries and names.+ for (const s of sectors) {+ const a = at(s.b0, 0.25 * R), c = at(s.b0, R)+ ctx.strokeStyle = '#1d3428'; ctx.setLineDash([3, 5]); ctx.beginPath(); ctx.moveTo(a.x, a.y); ctx.lineTo(c.x, c.y); ctx.stroke(); ctx.setLineDash([])+ const p = at(s.mid, R * 0.93)+ ctx.textAlign = 'center'; ctx.textBaseline = 'middle'+ ctx.font = `600 11px ${MONO}`; ctx.fillStyle = s.machine.online ? '#4f7d64' : '#3a4a42'+ ctx.fillText(spaced(s.machine.name.toUpperCase()), p.x, p.y)+ ctx.font = `9.5px ${MONO}`; ctx.fillStyle = '#2f4a3c'+ const sub = s.machine.online ? `${s.machine.here ? 'this computer · ' : ''}${s.machine.os}` : `closed · asleep since ${B.clock(s.machine.since)}`+ ctx.fillText(sub, p.x, p.y + 14)+ // The holding fix.+ const f = at(s.fix, 0.3 * R)+ ctx.strokeStyle = s.machine.online ? '#3b5f4b' : '#2a3a32'; ctx.lineWidth = 1+ ctx.beginPath(); ctx.moveTo(f.x, f.y - 5); ctx.lineTo(f.x + 4.5, f.y + 3); ctx.lineTo(f.x - 4.5, f.y + 3); ctx.closePath(); ctx.stroke()+ ctx.font = `9px ${MONO}`; ctx.fillStyle = '#35574a'; ctx.textAlign = 'left'+ ctx.fillText(fixName(s.machine.name), f.x + 7, f.y + 10)+ // Its holding pattern, drawn when someone is in it.+ if (desk.dispatches.some((d) => d.state === 'asking' && d.machine === s.machine.id)) {+ const u = { x: Math.sin(s.fix), y: -Math.cos(s.fix) }, v = { x: -u.y, y: u.x }+ const L = 0.075 * R, rr = 0.026 * R+ ctx.save(); ctx.translate(f.x, f.y); ctx.transform(u.x, u.y, v.x, v.y, 0, 0)+ ctx.strokeStyle = 'rgba(255,181,71,.22)'; ctx.setLineDash([3, 4])+ ctx.beginPath(); ctx.moveTo(-L / 2, rr); ctx.lineTo(L / 2, rr); ctx.arc(L / 2, 0, rr, Math.PI / 2, -Math.PI / 2, true); ctx.lineTo(-L / 2, -rr); ctx.arc(-L / 2, 0, rr, -Math.PI / 2, Math.PI / 2, true); ctx.stroke()+ ctx.restore()+ }+ }+ // The field: you, a runway and its final approach course.+ const thr = at(FINAL_BEARING, 0.03 * R), end = at(FINAL_BEARING + Math.PI, 0.03 * R)+ ctx.strokeStyle = '#7aa58c'; ctx.lineWidth = 3; ctx.beginPath(); ctx.moveTo(thr.x, thr.y); ctx.lineTo(end.x, end.y); ctx.stroke()+ ctx.lineWidth = 1+ const fEnd = at(FINAL_BEARING, 0.47 * R)+ ctx.strokeStyle = 'rgba(191,232,255,.16)'; ctx.setLineDash([6, 6]); ctx.beginPath(); ctx.moveTo(thr.x, thr.y); ctx.lineTo(fEnd.x, fEnd.y); ctx.stroke(); ctx.setLineDash([])+ for (let k = 1; k <= 8; k++) {+ const p = at(FINAL_BEARING, (0.03 + k * 0.055) * R), q = { x: Math.cos(FINAL_BEARING) * 4, y: Math.sin(FINAL_BEARING) * 4 }+ ctx.strokeStyle = 'rgba(191,232,255,.14)'; ctx.beginPath(); ctx.moveTo(p.x - q.x, p.y - q.y); ctx.lineTo(p.x + q.x, p.y + q.y); ctx.stroke()+ }+ // You. When something holds for you, the field glows.+ const holding = desk.dispatches.some((d) => d.state === 'asking')+ if (holding && !reduced) {+ const k = (now % 2400) / 2400+ ctx.strokeStyle = `rgba(255,181,71,${0.45 * (1 - k)})`; ctx.lineWidth = 1.2+ ctx.beginPath(); ctx.arc(cx, cy, 0.02 * R + k * 0.2 * R, 0, Math.PI * 2); ctx.stroke(); ctx.lineWidth = 1+ }+ ctx.font = `600 10px ${MONO}`; ctx.fillStyle = holding ? '#ffd08a' : '#9cc5ad'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'+ ctx.fillText('YOU', cx + 0.06 * R, cy + 0.05 * R)+ ctx.restore()+ }+ const spaced = (text) => text.split('').join(' ')+ const fixName = (name) => { const v = name.toUpperCase().replace(/[^A-Z]/g, ''); const c = v[0] + v.slice(1).replace(/[AEIOU]/g, ''); return (c + v).slice(0, 5) }++ function sweepArm(now) {+ if (reduced) return+ ctx.save()+ const grad = ctx.createConicGradient(sweep - Math.PI / 2 - 1.3, cx, cy)+ grad.addColorStop(0, 'rgba(111,220,156,0)')+ grad.addColorStop(0.16, 'rgba(111,220,156,0.018)')+ grad.addColorStop(0.2068, 'rgba(111,220,156,0.075)')+ grad.addColorStop(0.2070, 'rgba(111,220,156,0)')+ ctx.fillStyle = grad+ ctx.beginPath(); ctx.moveTo(cx, cy); ctx.arc(cx, cy, R, sweep - Math.PI / 2 - 1.3, sweep - Math.PI / 2); ctx.closePath(); ctx.fill()+ const tip = at(sweep, R)+ ctx.strokeStyle = 'rgba(140,240,180,.38)'; ctx.lineWidth = 1.2+ ctx.beginPath(); ctx.moveTo(cx, cy); ctx.lineTo(tip.x, tip.y); ctx.stroke()+ ctx.restore()+ }++ /** The sweep paints a target as it passes: the shown position jumps, the old one stays as a history dot. */+ function paint(track, p, prev, now) {+ if (!track.shown || reduced) { track.shown = p; track.lit = reduced ? 0.85 : 1; return }+ const b = bearingOf(p)+ const crossed = prev <= sweep ? (b > prev && b <= sweep) : (b > prev || b <= sweep)+ if (crossed) {+ if (Math.hypot(track.shown.x - p.x, track.shown.y - p.y) > 0.6) { track.trail.push(track.shown); if (track.trail.length > 6) track.trail.shift() }+ track.shown = p; track.lit = 1+ } else track.lit = Math.max(0.42, track.lit - 0.0045)+ }++ function seed(track, d, kind, now, rank) {+ // A flight that was already flying has a history: lay its last scans down as dots.+ if (track.seeded || reduced) return+ track.seeded = true+ for (let k = 5; k >= 1; k--) {+ const t = now - k * SCAN_MS+ if (d.landedAt && t < d.landedAt + 5000 && kind !== 'hold') continue+ track.trail.push(truePos(d, kind, t, rank))+ }+ }++ const blink = (now, hz = 1) => Math.floor(now / (500 / hz)) % 2 === 0++ function targets(now, list, prevSweep) {+ const placed = []+ const blocks = []+ // Primaries: harnesses ⌘B never sent to — on the desk, not in the book.+ for (const h of desk.harnesses) {+ if (h.boss || h.state === 'stopped') continue+ const tr = prims.get(h.id) ?? { trail: [], lit: 0 }+ prims.set(h.id, tr)+ const p = primPos(h, now)+ paint(tr, p, prevSweep, now)+ const s = tr.shown+ ctx.strokeStyle = h.state === 'working' ? `rgba(111,220,156,${0.28 + 0.3 * tr.lit})` : 'rgba(93,107,100,.35)'+ ctx.lineWidth = 1+ ctx.beginPath(); ctx.moveTo(s.x - 3, s.y); ctx.lineTo(s.x + 3, s.y); ctx.moveTo(s.x, s.y - 3); ctx.lineTo(s.x, s.y + 3); ctx.stroke()+ if (h.state === 'working') {+ ctx.font = `9.5px ${MONO}`; ctx.fillStyle = 'rgba(111,220,156,.34)'; ctx.textBaseline = 'middle'+ const label = h.name.toLowerCase(), right = s.x + 6 + ctx.measureText(label).width < W - 8+ ctx.textAlign = right ? 'left' : 'right'; ctx.fillText(label, right ? s.x + 6 : s.x - 6, s.y)+ }+ }+ for (const f of list) {+ const { d, kind } = f+ if (kind === 'gnd' && !landings.has(d.id)) continue+ let tr = tracks.get(d.id)+ if (!tr || tr.kind !== kind) { tr = { trail: tr?.kind === kind ? tr.trail : [], lit: 1, kind, shown: tr?.shown }; tracks.set(d.id, tr) }+ const landing = landings.get(d.id)+ let p+ if (landing) {+ const k = Math.min(1, (now - landing.at) / 1700)+ if (k >= 1) { landings.delete(d.id); continue }+ const thr = at(FINAL_BEARING, 0.03 * R), end = at(FINAL_BEARING + Math.PI, 0.03 * R)+ p = k < 0.6 ? lerp(landing.from, thr, ease(k / 0.6)) : lerp(thr, end, ease((k - 0.6) / 0.4))+ tr.shown = p; tr.lit = 1 - k * 0.6+ } else {+ seed(tr, d, kind, now, f.rank)+ p = truePos(d, kind, now, f.rank)+ if (kind === 'dep' || kind === 'hold') { tr.shown = p; tr.lit = 1 } else paint(tr, p, prevSweep, now)+ }+ const s = tr.shown+ const k = landing ? KIND.fin : KIND[kind]+ const on = matches(d)+ const alpha = on ? 1 : 0.16+ const flashing = kind === 'hold' && !blink(now, 0.9)+ // History trail.+ if (trails && !landing) tr.trail.forEach((q, i) => { ctx.fillStyle = hexa(k.color, alpha * (0.1 + 0.36 * (i + 1) / tr.trail.length)); ctx.beginPath(); ctx.arc(q.x, q.y, 1.5, 0, Math.PI * 2); ctx.fill() })+ // The target symbol.+ ctx.save(); ctx.globalAlpha = alpha+ ctx.shadowColor = k.color; ctx.shadowBlur = reduced ? 0 : 10 * tr.lit+ ctx.fillStyle = hexa(k.color, 0.45 + 0.55 * tr.lit); ctx.strokeStyle = ctx.fillStyle; ctx.lineWidth = 1.4+ if (kind === 'hold') { ctx.beginPath(); ctx.moveTo(s.x, s.y - 5); ctx.lineTo(s.x + 5, s.y); ctx.lineTo(s.x, s.y + 5); ctx.lineTo(s.x - 5, s.y); ctx.closePath(); flashing ? ctx.stroke() : ctx.fill() }+ else if (kind === 'em') { ctx.beginPath(); ctx.arc(s.x, s.y, 5.5, 0, Math.PI * 2); ctx.stroke(); ctx.beginPath(); ctx.moveTo(s.x - 3, s.y - 3); ctx.lineTo(s.x + 3, s.y + 3); ctx.moveTo(s.x + 3, s.y - 3); ctx.lineTo(s.x - 3, s.y + 3); ctx.stroke() }+ else if (kind === 'fin' || landing) { const dir = FINAL_BEARING + Math.PI; const a = at(0, 0); ctx.beginPath(); ctx.moveTo(s.x + Math.sin(dir) * 6, s.y - Math.cos(dir) * 6); ctx.lineTo(s.x + Math.sin(dir + 2.4) * 4.5, s.y - Math.cos(dir + 2.4) * 4.5); ctx.lineTo(s.x + Math.sin(dir - 2.4) * 4.5, s.y - Math.cos(dir - 2.4) * 4.5); ctx.closePath(); ctx.fill(); void a }+ else if (kind === 'cst') { ctx.strokeRect(s.x - 3.5, s.y - 3.5, 7, 7) }+ else if (kind === 'dep') { ctx.beginPath(); for (let i = 0; i < 8; i++) { const r = i % 2 ? 2.2 : 5.5, th = i * Math.PI / 4; ctx.lineTo(s.x + Math.cos(th) * r, s.y + Math.sin(th) * r) } ctx.closePath(); ctx.fill() }+ else { ctx.beginPath(); ctx.arc(s.x, s.y, 3.4, 0, Math.PI * 2); ctx.fill() }+ ctx.restore()+ placed.push({ x: s.x - 7, y: s.y - 7, w: 14, h: 14 })+ if (!landing) blocks.push({ f, s, k, alpha, flashing, tr })+ }+ // Data blocks, most urgent placed first so they win the clear spots.+ blocks.sort((a, b) => (b.f.d.id === sel) - (a.f.d.id === sel) || ORDER.indexOf(a.f.kind) - ORDER.indexOf(b.f.kind) || a.f.rank.i - b.f.rank.i)+ ladder = -Infinity+ for (const b of blocks) dataBlock(b, now, placed)+ // The selected flight: brackets, and its line home.+ const chosen = blocks.find((b) => b.f.d.id === sel)+ if (chosen) {+ const s = chosen.s, c = chosen.k.color+ ctx.strokeStyle = c; ctx.lineWidth = 1.2+ const r = 11, q = 4+ for (const [sx, sy] of [[-1, -1], [1, -1], [1, 1], [-1, 1]]) { ctx.beginPath(); ctx.moveTo(s.x + sx * r, s.y + sy * (r - q)); ctx.lineTo(s.x + sx * r, s.y + sy * r); ctx.lineTo(s.x + sx * (r - q), s.y + sy * r); ctx.stroke() }+ if (chosen.f.kind === 'hold' || chosen.f.kind === 'em') {+ ctx.strokeStyle = hexa(c, 0.35); ctx.setLineDash([2, 5]); ctx.beginPath(); ctx.moveTo(s.x, s.y); ctx.lineTo(cx, cy); ctx.stroke(); ctx.setLineDash([])+ }+ }+ }++ function dataBlock({ f, s, k, alpha, flashing }, now, placed) {+ const d = f.d, isSel = d.id === sel+ const lines = [callsign(d)]+ const age = B.ago(now - (f.kind === 'enr' || f.kind === 'dep' ? (d.landedAt ?? d.at) : d.since))+ if (f.kind === 'hold') lines.push(`${k.code} ${age} ${proj(d)}`)+ else if (f.kind === 'em') lines.push(d.state === 'undelivered' ? 'NO ROUTE' : `EM ${proj(d)}`)+ else if (f.kind === 'fin' && !isSel) { lines[0] = `${callsign(d).padEnd(9)}${age.padStart(4)} ${proj(d)}` }+ else if (f.kind === 'fin') lines.push(`${k.code} ${age} ${proj(d)}`)+ else if (f.kind === 'dep') lines.push(`HO ${proj(d)}`)+ else lines.push(`${k.code} ${age} ${proj(d)}`)+ if (isSel || f.kind === 'hold') {+ const words = d.question ?? d.summary ?? d.error ?? d.text+ lines.push(clip(words, isSel ? 34 : 26))+ if (isSel) lines.push(clip(`“${d.text}”`, 34))+ }+ ctx.font = `600 11px ${MONO}`+ const w = Math.max(...lines.map((l, i) => { ctx.font = `${i === 0 ? 600 : 400} ${i < 2 ? 11 : 10.5}px ${MONO}`; return ctx.measureText(l).width })) + 4+ const h = lines.length * 13 + 2+ let box = null, least = Infinity+ if (f.kind === 'fin' && isSel) {+ // The chosen arrival opens out on the other side of the course, clear of the ladder.+ box = { x: Math.max(8, s.x - 30 - w), y: Math.max(50, s.y - 30 - h), w, h }+ } else if (f.kind === 'fin') {+ // The arrival sequence: one line each, in a ladder beside the final approach course.+ const side = { x: -Math.cos(FINAL_BEARING), y: -Math.sin(FINAL_BEARING) }+ box = { x: s.x + side.x * 26 + 4, y: Math.max(s.y + side.y * 26 - h / 2, ladder + 14), w, h }+ ladder = box.y+ } else {+ for (const dist of [10, 26, 46, 70]) {+ for (const [ux, uy] of [[1, -1], [1, 1], [-1, -1], [-1, 1], [1, 0], [-1, 0], [0, -1], [0, 1]]) {+ const c = { x: ux > 0 ? s.x + dist : ux < 0 ? s.x - dist - w : s.x - w / 2, y: uy < 0 ? s.y - dist - h : uy > 0 ? s.y + dist : s.y - h / 2, w, h }+ if (c.x < 4 || c.y < 46 || c.x + w > W - 4 || c.y + h > H - 30) continue+ const hit = placed.reduce((sum, o) => sum + Math.max(0, Math.min(c.x + c.w, o.x + o.w) - Math.max(c.x, o.x)) * Math.max(0, Math.min(c.y + c.h, o.y + o.h) - Math.max(c.y, o.y)), 0)+ if (hit < least) { least = hit; box = c }+ if (!hit) break+ }+ if (least === 0) break+ }+ box ??= { x: s.x + 14, y: s.y - h - 8, w, h }+ }+ placed.push(box)+ ctx.save(); ctx.globalAlpha = alpha+ // Leader line.+ const lx = box.x > s.x ? box.x - 2 : box.x + w + 2, ly = box.y + 7+ ctx.strokeStyle = hexa(k.color, 0.4); ctx.lineWidth = 1+ ctx.beginPath(); ctx.moveTo(s.x + Math.sign(lx - s.x) * 5, s.y); ctx.lineTo(lx, ly); ctx.stroke()+ if (isSel) { ctx.fillStyle = 'rgba(2,10,6,.86)'; ctx.fillRect(box.x - 5, box.y - 3, w + 10, h + 6); ctx.strokeStyle = hexa(k.color, 0.5); ctx.strokeRect(box.x - 5, box.y - 3, w + 10, h + 6) }+ ctx.textAlign = 'left'; ctx.textBaseline = 'top'+ lines.forEach((l, i) => {+ ctx.font = `${i === 0 ? 600 : 400} ${i < 2 ? 11 : 10.5}px ${MONO}`+ ctx.fillStyle = i === 0 ? (flashing ? hexa(k.color, 0.35) : k.color) : i === 1 ? hexa(k.color, 0.78) : (i === 2 && f.kind === 'hold' ? '#f3d9ad' : '#a9c3b5')+ ctx.fillText(l, box.x, box.y + i * 13)+ })+ if (f.kind === 'dep' && blink(now, 1.6)) { ctx.fillStyle = C.white; ctx.font = `600 11px ${MONO}`; ctx.fillText('◂ HO', box.x + ctx.measureText(lines[0] + ' ').width + 6, box.y) }+ ctx.restore()+ }++ const clip = (text, n) => { const t = String(text ?? '').replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t }+ const lerp = (a, b, k) => ({ x: a.x + (b.x - a.x) * k, y: a.y + (b.y - a.y) * k })+ const ease = (k) => k < 0.5 ? 2 * k * k : 1 - Math.pow(-2 * k + 2, 2) / 2+ function hexa(hex, a) { const n = parseInt(hex.slice(1), 16); return `rgba(${n >> 16},${(n >> 8) & 255},${n & 255},${a})` }++ function frame(t) {+ const now = Date.now()+ const dt = Math.min(100, t - lastFrame); lastFrame = t+ const prev = sweep+ if (!reduced) sweep = (sweep + (dt / SCAN_MS) * Math.PI * 2) % (Math.PI * 2)+ desk.now = now+ ctx.setTransform(DPR, 0, 0, DPR, 0, 0)+ scope(now)+ sweepArm(now)+ const list = flights(now)+ targets(now, list, prev)+ if (now - lastBay > 1000) bay()+ requestAnimationFrame(frame)+ }++ // ── ATIS line, the strip bay ────────────────────────────────────────────────────────────────────────++ const phonetic = ['ALFA', 'BRAVO', 'CHARLIE', 'DELTA', 'ECHO', 'FOXTROT', 'GOLF', 'HOTEL', 'INDIA', 'JULIETT', 'KILO', 'LIMA', 'MIKE', 'NOVEMBER', 'OSCAR', 'PAPA', 'QUEBEC', 'ROMEO', 'SIERRA', 'TANGO']+ let lastBay = 0+ function bay() {+ lastBay = Date.now()+ const now = desk.now+ const list = flights(now)+ const counts = Object.fromEntries(ORDER.map((k) => [k, list.filter((f) => f.kind === k).length]))+ const line = $('atisline')+ line.replaceChildren()+ const add = (text, cls) => { const s = document.createElement(cls ? 'b' : 'span'); if (cls) s.className = cls; s.textContent = text; line.append(s) }+ add(`INFORMATION ${phonetic[new Date(now).getHours() % phonetic.length]} · `)+ add(`${counts.hold} HOLDING`, counts.hold ? 'hot' : ''); add(' · ')+ add(`${counts.em} EMERGENCY`, counts.em ? 'em' : ''); add(' · ')+ add(`${counts.fin} ON FINAL`, counts.fin ? 'fin' : ''); add(' · ')+ add(`${counts.enr + counts.dep} EN ROUTE`); add(' · ')+ const closed = desk.machines.filter((m) => !m.online)+ add(closed.length ? `SECTOR ${closed.map((m) => m.name.toUpperCase()).join(', ')} CLOSED` : 'ALL SECTORS OPEN')+ if (desk.real) add(' · YOUR DESK')+ $('clock').replaceChildren(Object.assign(document.createElement('div'), { textContent: new Date(now).toLocaleTimeString('en-GB') + ' L' }),+ Object.assign(document.createElement('div'), { className: 's', textContent: desk.real ? 'your desk, read only' : 'an invented desk' }))+ const strips = $('strips')+ const order = stripOrder(list)+ $('baycount').textContent = `${order.filter((f) => f.kind !== 'gnd').length} airborne · ${counts.gnd} down`+ const keep = strips.scrollTop+ strips.replaceChildren()+ let group = null+ for (const f of order) {+ if (f.kind === 'dep' && group === 'enr') { /* departures sit with en route */ }+ const g = f.kind === 'dep' ? 'enr' : f.kind+ if (g !== group) {+ group = g+ const head = document.createElement('div'); head.className = 'group'+ const b = document.createElement('b'); b.textContent = KIND[g].label+ head.append(b, ` ${list.filter((x) => (x.kind === 'dep' ? 'enr' : x.kind) === g).length} · ${KIND[g].note}`)+ strips.append(head)+ }+ strips.append(strip(f, now))+ }+ strips.scrollTop = keep+ }++ function strip(f, now) {+ const d = f.d, h = B.harness(d.harness)+ const el = document.createElement('div')+ el.className = `strip ${f.kind === 'dep' ? 'enr' : f.kind}${d.id === sel ? ' sel' : ''}${f.kind === 'hold' ? ' flash' : ''}${matches(d) ? '' : ' dim'}`+ el.dataset.id = d.id+ const c1 = document.createElement('div')+ c1.append(Object.assign(document.createElement('div'), { className: 'cs', textContent: callsign(d) }),+ Object.assign(document.createElement('div'), { className: 'ty', textContent: h ? B.engine(h.engine).short : '—' }))+ const c2 = document.createElement('div')+ c2.append(Object.assign(document.createElement('div'), { className: 'rt', textContent: h ? `${(d.machine ?? '').toUpperCase()} → ${h.project.toUpperCase()}${d.created ? ' · NEW' : ''}` : 'NO ROUTE' }),+ Object.assign(document.createElement('div'), { className: 'tx', textContent: d.text }))+ const c3 = document.createElement('div'); c3.className = 'tm'+ const code = f.kind === 'dep' ? 'HO' : f.kind === 'em' && d.state === 'undelivered' ? 'NRT' : KIND[f.kind].code+ const age = B.ago(now - (f.kind === 'enr' || f.kind === 'dep' ? (d.landedAt ?? d.at) : d.since))+ c3.append(Object.assign(document.createElement('b'), { textContent: code }), age)+ el.append(c1, c2, c3)+ if (d.id === sel) el.append(more(f, now))+ el.addEventListener('click', () => select(d.id))+ return el+ }++ function more(f, now) {+ const d = f.d, h = B.harness(d.harness)+ const box = document.createElement('div'); box.className = 'more'+ const row = (label, text) => { const r = document.createElement('div'); r.className = 'row'; const b = document.createElement('b'); b.textContent = label; r.append(b, ' ', text); box.append(r) }+ if (d.state === 'asking') box.append(Object.assign(document.createElement('div'), { className: 'said', textContent: d.question }))+ else if (d.state === 'failed' || d.state === 'undelivered') box.append(Object.assign(document.createElement('div'), { className: 'said', textContent: d.error }))+ else if (d.summary) box.append(Object.assign(document.createElement('div'), { className: 'said', textContent: d.summary }))+ row('you said', `“${d.text}” at ${B.clock(d.at)}${d.via === 'voice' ? ', by voice' : ''}`)+ const dec = d.decision+ if (dec.kind === 'session') row('⌘B sent it to', `“${h?.name}”, already running · Jev ${dec.p?.toFixed(2)}${dec.runnerUp ? `, then “${dec.runnerUp.name}” ${dec.runnerUp.p.toFixed(2)}` : ''} · ${(dec.ms / 1000).toFixed(2)} s`)+ else if (dec.kind === 'new') row('⌘B started', `“${h?.name}”: ${dec.why} · Jev ${dec.p?.toFixed(2)} · ${(dec.ms / 1000).toFixed(2)} s`)+ else if (dec.kind === 'routing') row('⌘B', 'deciding…')+ else row('⌘B', 'decided nothing, so sent nothing')+ if (h) row('harness', `${h.name} · ${B.engine(h.engine).name} · ${h.project} on ${d.machine} · ${h.turns.filter((t) => t.at >= d.at).length} turns since`)+ const act = document.createElement('div'); act.className = 'act'+ const keys = f.kind === 'fin' ? [['⏎', 'land it (mark read)'], ['u', 'put the last one back']]+ : f.kind === 'hold' ? [['⏎', 'bring it forward'], ['→', 'answer in the chat']]+ : f.kind === 'em' ? [['⏎', d.state === 'undelivered' ? 'say it again' : 'bring it forward']]+ : f.kind === 'gnd' ? [['u', 'back on final']] : [['⏎', 'bring it forward']]+ keys.forEach(([k, w], i) => { if (i) act.append(' · '); act.append(Object.assign(document.createElement('kbd'), { textContent: k }), ` ${w}`) })+ box.append(act)+ return box+ }++ // ── keys ────────────────────────────────────────────────────────────────────────────────────────────++ function visibleOrder() { return stripOrder(flights(desk.now)).filter((f) => matches(f.d)) }+ function select(id) {+ sel = id+ bay()+ const el = document.querySelector(`.strip[data-id="${CSS.escape(id ?? '')}"]`)+ el?.scrollIntoView({ block: 'nearest' })+ }+ function move(step) {+ const order = visibleOrder().filter((f) => f.kind !== 'gnd' || sel)+ if (!order.length) return+ const i = order.findIndex((f) => f.d.id === sel)+ const next = order[(i < 0 ? (step > 0 ? 0 : order.length - 1) : (i + step + order.length) % order.length)]+ select(next.d.id)+ }+ function jump(kind) {+ const order = visibleOrder().filter((f) => f.kind === kind)+ if (!order.length) return toast(`nothing ${KIND[kind].label.toLowerCase()}`)+ const i = order.findIndex((f) => f.d.id === sel)+ select(order[(i + 1) % order.length].d.id)+ }+ function land(id) {+ const f = flights(desk.now).find((x) => x.d.id === id)+ if (!f || f.kind !== 'fin') return false+ const tr = tracks.get(id)+ landings.set(id, { from: tr?.shown ?? truePos(f.d, 'fin', desk.now, f.rank), at: Date.now() })+ lastLanded.push(id)+ B.markSeen(id)+ toast(`${callsign(f.d)} cleared to land · ${clip(f.d.summary, 60)}`)+ return true+ }+ function toast(text) {+ const el = $('toast'); el.textContent = text; el.classList.add('on')+ clearTimeout(toastTimer); toastTimer = setTimeout(() => el.classList.remove('on'), 2600)+ }+ function showFilter() {+ $('filter').classList.toggle('on', query !== null)+ $('q').textContent = query ?? ''+ $('qn').textContent = query ? `${desk.dispatches.filter(matches).length} of ${desk.dispatches.length}` : ''+ bay()+ }++ addEventListener('keydown', (e) => {+ if (e.metaKey || e.ctrlKey || e.altKey) return+ if (typing) {+ if (e.key === 'Escape') { query = null; typing = false }+ else if (e.key === 'Enter') { typing = false; const first = visibleOrder()[0]; if (first) select(first.d.id) }+ else if (e.key === 'Backspace') query = query.slice(0, -1)+ else if (e.key.length === 1) query += e.key+ else return+ e.preventDefault(); showFilter(); return+ }+ const f = flights(desk.now).find((x) => x.d.id === sel)+ switch (e.key) {+ case '/': query = ''; typing = true; showFilter(); break+ case 'Tab': move(e.shiftKey ? -1 : 1); break+ case 'j': case 'ArrowDown': move(1); break+ case 'k': case 'ArrowUp': move(-1); break+ case 'h': jump('hold'); break+ case 'f': jump('fin'); break+ case 'e': jump('em'); break+ case ' ': { const first = stripOrder(flights(desk.now)).find((x) => x.kind === 'fin'); if (first) { land(first.d.id); select(first.d.id) } else toast('nothing on final'); break }+ case 'Enter':+ if (!f) { move(1); break }+ if (f.kind === 'fin') land(f.d.id)+ else if (f.kind === 'hold') toast(`${callsign(f.d)}: would bring “${B.harness(f.d.harness)?.name}” forward — or answer it in the chat`)+ else if (f.d.state === 'undelivered') toast('would say it again to ⌘B, on the desk as it is now')+ else toast(`would bring “${B.harness(f.d.harness)?.name ?? '—'}” forward`)+ break+ case 'ArrowRight': if (f) toast('→ the chat beside this viewer knows which one you mean'); break+ case 'u': { const id = lastLanded.pop() ?? (f?.kind === 'gnd' ? f.d.id : null); if (id) { B.unseen(id); select(id); toast('back on final') } break }+ case 't': trails = !trails; toast(trails ? 'history trails on' : 'history trails off'); break+ case 's': document.body.classList.toggle('nostrips'); setTimeout(resize, 0); break+ case 'Escape': if (query !== null) { query = null; showFilter() } else select(null); break+ default: return+ }+ e.preventDefault()+ })++ canvas.addEventListener('click', (e) => {+ const box = canvas.getBoundingClientRect()+ const x = e.clientX - box.left, y = e.clientY - box.top+ let best = null, dist = 18+ for (const [id, tr] of tracks) { if (!tr.shown) continue; const dd = Math.hypot(tr.shown.x - x, tr.shown.y - y); if (dd < dist && kindOf(desk.dispatches.find((d) => d.id === id) ?? {}, desk.now) !== 'gnd') { dist = dd; best = id } }+ select(best)+ })++ function keysLine() {+ const keys = $('keys')+ const parts = [['tab', 'next'], ['h f e', 'holding · final · emergency'], ['⏎', 'land / bring forward'], ['space', 'land next'], ['u', 'undo'], ['/', 'find'], ['t', 'trails'], ['s', 'strips']]+ parts.forEach(([k, w], i) => { if (i) keys.append(' · '); keys.append(Object.assign(document.createElement('kbd'), { textContent: k }), ` ${w}`) })+ }++ B.load().then((d) => {+ desk = d+ $('loading').remove()+ layoutSectors()+ resize()+ keysLine()+ // Start on what needs you most.+ const first = stripOrder(flights(desk.now))[0]+ if (first && first.kind !== 'gnd') sel = first.d.id+ const pick = new URLSearchParams(location.search).get('select')+ if (pick) sel = pick+ bay()+ B.subscribe((_, event) => { if (event.type !== 'tick' && event.type !== 'turn') { layoutSectors(); bay() } })+ addEventListener('resize', () => { resize(); bay() })+ requestAnimationFrame(frame)+ }).catch((error) => { $('loading').textContent = `could not read the desk: ${error.message}` })+})()diff --git a/docs/research/2026-10-11-boss-mode/boss-data.js b/docs/research/2026-10-11-boss-mode/boss-data.jsnew file mode 100644index 000000000..273d811c5--- /dev/null+++ b/docs/research/2026-10-11-boss-mode/boss-data.js@@ -0,0 +1,412 @@+/*+ * The one data source every Boss Mode prototype reads: the desk as ⌘B's office would keep it.+ *+ * BossData.load() → Promise<desk>+ * BossData.subscribe(fn) → fn(desk, event) after every change; returns an unsubscribe+ * BossData.needsYou(d) → why a dispatch needs the person — 'asking' | 'failed' | 'undelivered' |+ * 'ready' (finished, not yet looked at) — or null+ * BossData.markSeen(id) / BossData.unseen(id) the person picked a finished one up, or put it back+ * BossData.engine(id) · BossData.ago(ms) · BossData.clock(at) · BossData.STATES+ *+ * desk = {+ * now, real, source, notes: [string],+ * machines: [{ id, name, here, online, since, os }]+ * harnesses: [{ id, machine, engine, name, project, state, since, createdAt, lastTurnAt, tokens,+ * question, summary, turns: [{ at, by: 'you' | 'agent', size }], boss: bool }]+ * dispatches: [{ id, n, at, text, via, decision: { kind, p, runnerUp, why, ms, cost }, harness, machine,+ * created, landedAt, state, since, seenAt, question, summary, pr, history: [{ at, state }] }]+ * }+ * The model is the one README.md describes: what the Boss Mode harness would keep.+ *+ * Opened as a file, or without ?real, it is an invented person's desk, made below, that keeps moving: tasks+ * finish, ask, and new ones arrive (?still holds it). Served by serve.mjs and opened with ?real, it is this+ * computer's own desk, read on request and never written anywhere. A classic script, so pages work from+ * file:// too.+ *+ * Everything in here is untrusted text written by models and people: render it with textContent only.+ */+(function () {+ 'use strict'+ const MIN = 60_000+ const HOUR = 3_600_000+ const served = location.protocol.startsWith('http')+ const real = /[?&]real\b/.test(location.search) && served+ const still = /[?&]still\b/.test(location.search)++ const ENGINES = {+ claude: { name: 'Claude Code', short: 'Claude', call: 'CLAUDE', color: '#d97757' },+ codex: { name: 'Codex', short: 'Codex', call: 'CODEX', color: '#3fae8c' },+ gemini: { name: 'Gemini CLI', short: 'Gemini', call: 'GEMINI', color: '#4f8ef7' },+ grok: { name: 'Grok Build', short: 'Grok', call: 'GROK', color: '#8a93a6' },+ opencode: { name: 'OpenCode', short: 'OpenCode', call: 'OPEN', color: '#c8c8c8' },+ hermes: { name: 'Hermes', short: 'Hermes', call: 'HERMES', color: '#d4a72c' },+ pi: { name: 'Pi', short: 'Pi', call: 'PI', color: '#b07cd8' },+ }+ const engine = (id) => ENGINES[id] ?? { name: id || 'agent', short: id || 'agent', call: String(id || 'AGENT').toUpperCase().slice(0, 6), color: '#8b8f96' }++ /** Every state a dispatch or a harness can be in, and whether it is the person's to act on. */+ const STATES = {+ routing: { label: 'Routing', word: 'deciding where it goes' },+ working: { label: 'Working', word: 'working' },+ asking: { label: 'Needs you', word: 'asking you', needs: true },+ done: { label: 'Done', word: 'finished' },+ failed: { label: 'Failed', word: 'failed', needs: true },+ undelivered: { label: 'Not sent', word: 'went nowhere', needs: true },+ offline: { label: 'Out of reach', word: 'on a machine that is asleep' },+ stopped: { label: 'Stopped', word: 'stopped' },+ idle: { label: 'Quiet', word: 'quiet' },+ }++ function needsYou(d) {+ if (!d) return null+ if (d.state === 'asking') return 'asking'+ if (d.state === 'failed') return 'failed'+ if (d.state === 'undelivered') return 'undelivered'+ if (d.state === 'done' && !d.seenAt) return 'ready'+ return null+ }++ function ago(ms) {+ if (!(ms >= 0)) return ''+ if (ms < 45_000) return 'now'+ if (ms < HOUR) return `${Math.round(ms / MIN)}m`+ if (ms < 36 * HOUR) { const h = Math.floor(ms / HOUR), m = Math.round((ms % HOUR) / MIN); return m && h < 10 ? `${h}h${String(m).padStart(2, '0')}` : `${Math.round(ms / HOUR)}h` }+ return `${Math.round(ms / (24 * HOUR))}d`+ }+ const clock = (at) => { const d = new Date(at); return `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}` }++ // ── what the person has picked up, kept in this browser only ───────────────────────────────────────++ const SEEN_KEY = 'boss-mode-seen-v1'+ function readSeen() { try { return JSON.parse(localStorage.getItem(SEEN_KEY) || '{}') || {} } catch { return {} } }+ function writeSeen(map) { try { localStorage.setItem(SEEN_KEY, JSON.stringify(map)) } catch { /* private window: it lasts the visit */ } }+ let seenMap = readSeen()++ // ── an invented person's desk ──────────────────────────────────────────────────────────────────────++ function rng(seed) {+ return function () {+ seed |= 0; seed = (seed + 0x6d2b79f5) | 0+ let t = Math.imul(seed ^ (seed >>> 15), 1 | seed)+ t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296+ }+ }++ const MACHINES = [+ ['studio', 'studio', true, 'macOS', null],+ ['build-box', 'build-box', false, 'Linux', null],+ ['laptop', 'laptop', false, 'macOS', 10.9],+ ]++ // [id, machine, engine, project, name, created h ago, state when nothing ⌘B sent changed it]+ const HARNESSES = [+ ['h-certs', 'build-box', 'codex', 'infra', 'Staging certs', 46, 'idle'],+ ['h-swipe', 'studio', 'claude', 'mobile-app', 'Swipe feel', 48, 'idle'],+ ['h-grid', 'studio', 'claude', 'widgets', 'Grid snapshots', 30, 'idle'],+ ['h-backfill', 'build-box', 'codex', 'ml-pipeline', 'Feature backfill', 40, 'idle'],+ ['h-resume', 'studio', 'claude', 'mobile-app', 'Resume crash', 26, 'idle'],+ ['h-rate', 'studio', 'codex', 'api-gateway', 'Rate limits', 28, 'idle'],+ ['h-tokens', 'studio', 'claude', 'design-system', 'Color tokens', 50, 'idle'],+ ['h-incident', 'studio', 'claude', 'payments', 'Incident review', 20, 'idle'],+ // Started by hand (⌘N), never through ⌘B: on the desk, not in the office's book.+ ['h-daemon', 'studio', 'codex', 'cli', 'Daemon restarts', 6.2, 'working'],+ ['h-copy', 'laptop', 'claude', 'website', 'Launch copy', 23, 'offline'],+ ['h-onboard', 'studio', 'claude', 'mobile-app', 'Onboarding in one step', 4.4, 'idle'],+ ]++ // [n, h ago, text, via, harness | {new harness}, p, runner-up [name, p] | null, state, state h ago, seen, words]+ // words: the summary of a finished task, the question of an asking one, what went wrong in a failed one.+ const N = (id, machine, engine, project, name) => ({ id, machine, engine, project, name })+ const DISPATCHES = [+ [1, 21.3, 'rotate the staging certs', 'box', 'h-certs', 0.88, ['new work', 0.07], 'done', 20.6, true,+ 'Rotated the staging certificates; the next rotation is due in 60 days.'],+ [2, 18.7, 'add a dark mode to the docs', 'box', N('h-darkdocs', 'studio', 'claude', 'docs-site', 'Docs dark mode'), 0.81, ['Broken links', 0.06], 'stopped', 17.9, true,+ 'Stopped by you after the first pass.'],+ [3, 17.2, 'make the swipe feel instant', 'voice', 'h-swipe', 0.66, ['Resume crash', 0.21], 'done', 16.1, true,+ 'Swipes now start on touch-down instead of after 80 ms. PR #871.'],+ [4, 16.4, 'drop the legacy renderer from the build', 'box', N('h-legacy', 'studio', 'codex', 'widgets', 'Drop legacy renderer'), 0.74, ['Grid snapshots', 0.19], 'done', 14.9, false,+ 'Removed it; the bundle is 84 KB lighter. Two tests leaned on it and were rewritten. PR #874.'],+ [5, 15.8, 'run the full eval on the new ranker and write up the numbers by morning', 'box', N('h-eval', 'build-box', 'codex', 'ml-pipeline', 'Ranker v7 eval'), 0.83, ['Feature backfill', 0.11], 'done', 10.2, false,+ 'v7 beats v6 on 11 of 12 slices; recall@10 is up 2.3 points. The write-up is in docs/evals/v7.md. PR #877.'],+ [6, 15.2, 'migrate the ledger tables to the new schema on staging, stop if any row count differs', 'box', N('h-ledger', 'build-box', 'claude', 'payments', 'Ledger migration'), 0.9, ['Incident review', 0.05], 'asking', 9.1, false,+ 'Row counts differ on ledger_entries by 14 rows, all soft-deleted. Skip them, or stop as you said?'],+ [7, 14.6, 'regenerate every widget snapshot against the grid renderer', 'box', 'h-grid', 0.71, ['Drop legacy renderer', 0.18], 'done', 13.0, false,+ 'Regenerated 214 snapshots. Three changed for real: the tooltip moved 2 px. PR #876.'],+ [8, 13.9, 'find every broken link on the docs site and fix them', 'box', N('h-links', 'studio', 'codex', 'docs-site', 'Broken links'), 0.77, ['Docs dark mode', 0.12], 'done', 12.7, false,+ 'Fixed 37 links. Four point at pages that no longer exist; they are listed in the PR. PR #878.'],+ [9, 13.1, 'backfill the features for September', 'box', 'h-backfill', 0.64, ['new work', 0.22], 'failed', 11.4, false,+ 'Out of disk on /data at 61% (1–19 September). Nothing is half-written; it can resume from the 20th once there is room.'],+ [10, 12.4, 'measure the battery drain overnight with the dial asleep', 'voice', N('h-battery', 'laptop', 'claude', 'firmware', 'Battery drain'), 0.71, ['new work', 0.12], 'offline', 10.9, false,+ 'Last heard measuring: 4.1 mA asleep after 90 minutes.'],+ [11, 11.0, 'write the runbook for a failed migration', 'box', N('h-runbook', 'studio', 'claude', 'infra', 'Failed-migration runbook'), 0.69, ['Ledger migration', 0.2], 'done', 9.8, false,+ 'ops/runbooks/failed-migration.md, with the rollback tried once on staging.'],+ [12, 5.3, 'cut a release from main', 'box', null, null, null, 'undelivered', 5.3, false,+ 'Nothing was sent: Jev could not be reached (the network was down).'],+ [13, 3.4, 'plot the regression', 'box', 'h-eval', 0.47, ['Feature backfill', 0.18], 'done', 2.9, false,+ 'Plotted recall@10 by slice; the only regression is long queries, down 0.4. The chart is in the write-up.'],+ [14, 2.8, 'the app crashes on resume, find out why', 'box', 'h-resume', 0.58, ['Swipe feel', 0.24], 'working', 2.8, false, null],+ [15, 2.5, 'rate limit per key, not per IP', 'box', 'h-rate', 0.77, ['Incident review', 0.08], 'done', 1.6, true,+ 'Limits are per API key now; anonymous traffic is still limited per IP. PR #879.'],+ [16, 2.1, 'make the landing page load instantly', 'box', N('h-landing', 'studio', 'codex', 'website', 'Landing speed'), 0.8, ['Launch copy', 0.09], 'asking', 1.3, false,+ 'The hero video is 14 MB. Swap it for a poster frame and load the video late, or compress it to about 2 MB?'],+ [17, 1.7, 'rename the color tokens by role', 'box', 'h-tokens', 0.69, ['new work', 0.14], 'working', 1.7, false, null],+ [18, 1.4, 'why is p99 latency up?', 'voice', N('h-p99', 'build-box', 'codex', 'api-gateway', 'p99 latency'), 0.62, ['Rate limits', 0.3], 'working', 1.4, false, null],+ [19, 1.1, 'merge it once CI is green', 'box', 'h-rate', 0.61, ['p99 latency', 0.2], 'done', 0.9, true,+ 'Merged #879 after CI passed.'],+ [20, 0.9, 'add the pricing table', 'box', N('h-pricing', 'studio', 'claude', 'website', 'Pricing table'), 0.72, ['Landing speed', 0.2], 'working', 0.9, false, null],+ [21, 0.6, 'terraform drift report', 'box', N('h-drift', 'build-box', 'codex', 'infra', 'Terraform drift'), 0.66, ['Staging certs', 0.25], 'done', 0.25, false,+ 'Two resources drifted: an S3 lifecycle rule and a security group. The plan is attached; nothing was applied.'],+ [22, 0.45, 'update the pin map for the v2 board', 'box', N('h-pins', 'studio', 'claude', 'firmware', 'Pin map v2'), 0.79, ['Battery drain', 0.12], 'asking', 0.3, false,+ 'The v2 schematic has two pins named BTN_A. Which is the knob’s push switch: GPIO4 or GPIO21?'],+ [23, 0.3, 'tldr the incident from last night', 'box', 'h-incident', 0.62, ['Ledger migration', 0.21], 'done', 0.22, false,+ 'A provider outage retried webhooks 40k times in a minute; retries now back off to one hour. No money moved twice.'],+ [24, 0.12, 'audit the icon set for missing sizes', 'box', N('h-icons', 'studio', 'codex', 'design-system', 'Icon audit'), 0.7, ['Color tokens', 0.22], 'working', 0.12, false, null],+ ]++ // What happens next while the page is open: [seconds after load, event]+ const SCRIPT = [+ [9, { dispatch: [25, 'freeze the eval set for this quarter', 'box', 'h-eval', 0.64, ['Feature backfill', 0.14]] }],+ [24, { finish: 'h-tokens', words: 'Renamed 48 tokens by role; the old names stay as aliases for one release. PR #884.' }],+ [41, { ask: 'h-resume', words: 'Found it: the session is read before it is restored. Fix it in the app, or in the SDK (which three other apps use)?' }],+ [60, { dispatch: [26, 'compress the hero video to about 2 MB', 'box', 'h-landing', 0.71, ['Pricing table', 0.12]] }],+ [82, { finish: 'h-p99', words: 'p99 rose with the new auth lookup: 38 ms a request, uncached. Caching it brings p99 back to 210 ms. PR #885.' }],+ [104, { ask: 'h-icons', words: '17 icons have no 16 px size. Draw them, or scale the 24 px ones down for now?' }],+ [126, { dispatch: [27, 'add a test for the retry backoff', 'voice', N('h-backoff', 'studio', 'claude', 'payments', 'Retry backoff test'), 0.76, ['Incident review', 0.17]] }],+ [150, { finish: 'h-pricing', words: 'Three tiers, monthly and yearly; a screenshot is in the PR. PR #886.' }],+ [176, { finish: 'h-eval', words: 'The eval set for Q4 is frozen at 12,480 queries; its hash is in evals/FROZEN.' }],+ ]++ const ID = (n) => `d${String(n).padStart(2, '0')}`++ function invented(now) {+ const random = rng(20261011)+ const machines = MACHINES.map(([id, name, here, os, asleep]) => ({ id, name, here, os, online: asleep == null, since: asleep == null ? null : now - asleep * HOUR }))+ const harnesses = new Map()+ const make = ([id, machine, eng, project, name, created, state]) => {+ const h = { id, machine, engine: eng, name, project, state, since: now - created * HOUR, createdAt: now - created * HOUR, lastTurnAt: null, tokens: 0, question: null, summary: null, turns: [], boss: false }+ harnesses.set(id, h)+ return h+ }+ for (const row of HARNESSES) make(row)++ /** Turns between two moments: bursts of agent turns with the person now and then, as work looks. */+ function play(h, from, to, { density = 1, you = 0.08 } = {}) {+ let t = from+ while (t < to) {+ const burst = 2 + Math.floor(random() * 7 * density)+ for (let i = 0; i < burst && t < to; i++) {+ h.turns.push({ at: t, by: random() < you ? 'you' : 'agent', size: Math.round(200 + Math.pow(random(), 2) * 5200) })+ t += (20 + random() * 140) * 1000+ }+ t += (4 + random() * 38) * MIN / density+ }+ }+ // What the harnesses did before the night's handoffs, so the desk has a past.+ for (const h of harnesses.values()) play(h, h.createdAt, Math.min(now - 18 * HOUR, h.createdAt + (1 + random() * 3) * HOUR), { density: 0.6, you: 0.18 })++ const dispatches = DISPATCHES.map(([n, h0, text, via, target, p, runnerUp, state, s0, seen, words]) => {+ const at = now - h0 * HOUR+ let h = null+ if (target && typeof target === 'object') h = make([target.id, target.machine, target.engine, target.project, target.name, h0 - 0.0002, 'idle'])+ else if (target) h = harnesses.get(target)+ const ms = Math.round(520 + random() * 260)+ const decision = !h+ ? { kind: 'none', p: null, runnerUp: null, why: words, ms: 8000, cost: 0 }+ : { kind: typeof target === 'object' ? 'new' : 'session', p, runnerUp: runnerUp ? { name: runnerUp[0], p: runnerUp[1] } : null, ms, cost: 0.000142 + random() * 0.00005,+ why: typeof target === 'object' ? `new work in ${h.project}, with ${engine(h.engine).short}` : `the same work on the same subject as “${h.name}”` }+ const since = now - s0 * HOUR+ const d = {+ id: ID(n), n, at, text, via, decision, harness: h?.id ?? null, machine: h?.machine ?? null, created: typeof target === 'object',+ landedAt: h ? at + ms : null, state, since, seenAt: seen ? since + 12 * MIN : null,+ question: state === 'asking' ? words : null, summary: state === 'done' || state === 'stopped' || state === 'offline' ? words : null,+ error: state === 'failed' || state === 'undelivered' ? words : null,+ pr: (words && /PR #(\d+)/.exec(words)?.[1]) ?? null,+ history: [{ at, state: 'routing' }, ...(h ? [{ at: at + ms, state: 'working' }] : []), ...(state !== 'working' ? [{ at: since, state }] : [])],+ }+ if (h) {+ h.boss = true+ h.turns.push({ at: at + ms, by: 'you', size: text.length * 4 })+ const end = state === 'working' ? now : since+ play(h, at + ms + 40_000, end, { density: state === 'working' ? 1.3 : 1, you: 0.04 })+ h.state = state === 'undelivered' ? h.state : state+ h.since = since+ h.question = d.question+ h.summary = d.summary ?? d.error+ }+ return d+ })+ // The hand-started ones keep busy, the way they do.+ const daemon = harnesses.get('h-daemon')+ play(daemon, daemon.createdAt, now, { density: 1.1, you: 0.2 })+ daemon.since = daemon.createdAt+ const onboard = harnesses.get('h-onboard')+ play(onboard, onboard.createdAt, now - 2.2 * HOUR, { density: 0.9, you: 0.2 })+ onboard.since = now - 2.2 * HOUR+ const copy = harnesses.get('h-copy')+ copy.since = now - 10.9 * HOUR++ for (const h of harnesses.values()) {+ h.turns.sort((a, b) => a.at - b.at)+ h.tokens = h.turns.reduce((sum, t) => sum + t.size * 9, 0)+ h.lastTurnAt = h.turns.at(-1)?.at ?? h.createdAt+ }+ return {+ now, real: false, source: 'an invented desk',+ notes: [],+ machines, harnesses: [...harnesses.values()], dispatches,+ }+ }++ // ── the invented desk keeps moving ─────────────────────────────────────────────────────────────────++ let desk = null+ const listeners = new Set()+ const emit = (event) => { for (const fn of listeners) { try { fn(desk, event) } catch (error) { console.error(error) } } }++ function harnessOf(id) { return desk.harnesses.find((h) => h.id === id) }++ function startSimulation() {+ const random = rng(1011)+ const started = Date.now()+ let next = 0+ setInterval(() => {+ const now = Date.now()+ desk.now = now+ // Working harnesses take turns.+ for (const h of desk.harnesses) {+ if (h.state !== 'working' || random() > 0.32) continue+ const size = Math.round(200 + Math.pow(random(), 2) * 5200)+ h.turns.push({ at: now, by: 'agent', size }); h.tokens += size * 9; h.lastTurnAt = now+ emit({ type: 'turn', harness: h.id })+ }+ while (next < SCRIPT.length && (now - started) / 1000 >= SCRIPT[next][0]) run(SCRIPT[next++][1], now)+ emit({ type: 'tick' })+ }, 1000)++ function latestFor(hid) { return desk.dispatches.filter((d) => d.harness === hid).sort((a, b) => b.at - a.at)[0] }+ function settle(h, state, words, now) {+ h.state = state; h.since = now+ h.question = state === 'asking' ? words : null+ h.summary = state === 'done' ? words : h.summary+ const d = latestFor(h.id)+ if (d && d.state === 'working') {+ d.state = state; d.since = now; d.history.push({ at: now, state })+ if (state === 'asking') d.question = words; else d.summary = words+ d.pr = /PR #(\d+)/.exec(words)?.[1] ?? null+ }+ emit({ type: state, harness: h.id, dispatch: d?.id })+ }+ function run(event, now) {+ if (event.finish) settle(harnessOf(event.finish), 'done', event.words, now)+ if (event.ask) settle(harnessOf(event.ask), 'asking', event.words, now)+ if (event.dispatch) {+ const [n, text, via, target, p, runnerUp] = event.dispatch+ const created = typeof target === 'object'+ const d = {+ id: ID(n), n, at: now, text, via, decision: { kind: 'routing', p: null, runnerUp: null, why: '', ms: 0, cost: 0 },+ harness: null, machine: null, created, landedAt: null, state: 'routing', since: now, seenAt: null,+ question: null, summary: null, error: null, pr: null, history: [{ at: now, state: 'routing' }],+ }+ desk.dispatches.push(d)+ emit({ type: 'dispatch', dispatch: d.id })+ // Jev answers in about 0.6 s; then the words land.+ setTimeout(() => {+ const at = Date.now()+ let h = created ? null : harnessOf(target)+ if (created) {+ h = { id: target.id, machine: target.machine, engine: target.engine, name: target.name, project: target.project, state: 'working', since: at, createdAt: at, lastTurnAt: at, tokens: 0, question: null, summary: null, turns: [], boss: true }+ desk.harnesses.push(h)+ }+ // A task sent to a harness that was asking answers it: that question is settled.+ for (const old of desk.dispatches) if (old.harness === h.id && old.state === 'asking') { old.state = 'done'; old.since = at; old.seenAt = at; old.summary = `Answered by #${n}.`; old.history.push({ at, state: 'done' }) }+ for (const old of desk.dispatches) if (old.harness === h.id && old.state === 'done' && !old.seenAt) { old.seenAt = at }+ const ms = at - now+ d.decision = { kind: created ? 'new' : 'session', p, runnerUp: runnerUp ? { name: runnerUp[0], p: runnerUp[1] } : null, ms, cost: 0.000161,+ why: created ? `new work in ${h.project}, with ${engine(h.engine).short}` : `the same work on the same subject as “${h.name}”` }+ d.harness = h.id; d.machine = h.machine; d.landedAt = at; d.state = 'working'; d.since = at+ d.history.push({ at, state: 'working' })+ h.state = 'working'; h.since = at; h.question = null; h.boss = true+ h.turns.push({ at, by: 'you', size: text.length * 4 }); h.lastTurnAt = at+ emit({ type: 'landed', dispatch: d.id, harness: h.id })+ }, 640)+ }+ }+ }++ // ── your own desk, through serve.mjs ───────────────────────────────────────────────────────────────++ async function fetchReal() {+ const answer = await fetch('/real/desk', { cache: 'no-store' })+ if (!answer.ok) throw new Error((await answer.json().catch(() => ({}))).error ?? `The server answered ${answer.status}.`)+ return answer.json()+ }++ function startPolling() {+ setInterval(async () => {+ try {+ const fresh = await fetchReal()+ applySeen(fresh)+ // Keep the same object, so a page holding `desk` sees the new rows.+ Object.assign(desk, fresh)+ emit({ type: 'refresh' })+ } catch (error) { emit({ type: 'error', error: String(error?.message ?? error) }) }+ desk.now = Date.now()+ emit({ type: 'tick' })+ }, 5000)+ }++ /** On your desk, what this view cannot know, said once in a corner: ⌘B keeps no record of its sends. */+ function notice(d) {+ const box = document.createElement('div')+ box.setAttribute('role', 'note')+ box.style.cssText = 'position:fixed;left:16px;top:52px;max-width:min(520px,calc(100% - 32px));z-index:90;padding:9px 12px;border:1px solid rgba(255,255,255,.12);border-radius:4px;background:rgba(10,10,12,.92);color:#b9bcc2;font:11.5px/1.5 ui-monospace,Menlo,monospace;transition:opacity .8s;pointer-events:none'+ const head = document.createElement('div')+ head.style.cssText = 'color:#e8e1d0;margin-bottom:3px'+ head.textContent = `Your desk, read only: ${d.dispatches.length} handoffs in 36 h, ${d.dispatches.filter((x) => x.via === 'box').length} of them through ⌘B.`+ box.append(head)+ for (const line of d.notes.slice(0, 5)) box.append(Object.assign(document.createElement('div'), { textContent: `· ${line}` }))+ document.body.append(box)+ setTimeout(() => { box.style.opacity = '0' }, 14000)+ setTimeout(() => box.remove(), 15000)+ }++ function applySeen(d) {+ for (const row of d.dispatches) if (seenMap[row.id]) row.seenAt = seenMap[row.id] === -1 ? null : seenMap[row.id]+ }++ let loading = null+ function load() {+ loading ??= (async () => {+ desk = real ? await fetchReal() : invented(Date.now())+ applySeen(desk)+ if (real) notice(desk)+ if (!still) (real ? startPolling : startSimulation)()+ return desk+ })()+ return loading+ }++ function subscribe(fn) { listeners.add(fn); return () => listeners.delete(fn) }++ function markSeen(id) {+ const d = desk?.dispatches.find((row) => row.id === id)+ if (!d) return+ d.seenAt = Date.now()+ seenMap[id] = d.seenAt; writeSeen(seenMap)+ emit({ type: 'seen', dispatch: id })+ }+ function unseen(id) {+ const d = desk?.dispatches.find((row) => row.id === id)+ if (!d) return+ d.seenAt = null+ seenMap[id] = -1; writeSeen(seenMap)+ emit({ type: 'unseen', dispatch: id })+ }++ /** The harness a dispatch landed in, and the dispatches a harness took. */+ const harness = (id) => desk?.harnesses.find((h) => h.id === id) ?? null+ const machine = (id) => desk?.machines.find((m) => m.id === id) ?? null++ window.BossData = { load, subscribe, needsYou, markSeen, unseen, engine, harness, machine, ago, clock, STATES, real, still, served, MIN, HOUR }+})()diff --git a/docs/research/2026-10-11-boss-mode/index.html b/docs/research/2026-10-11-boss-mode/index.htmlnew file mode 100644index 000000000..390c62553--- /dev/null+++ b/docs/research/2026-10-11-boss-mode/index.html@@ -0,0 +1,47 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width,initial-scale=1">+<title>Boss Mode</title>+<style>+ :root { --bg: #0b0c0e; --panel: #131518; --text: #e6e7e9; --muted: #8b8f96; --faint: #5a5e65; --line: #24272c; --accent: #ffb547; color-scheme: dark; }+ * { box-sizing: border-box; }+ body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 ui-monospace, "SF Mono", Menlo, monospace; }+ main { max-width: 1240px; margin: 0 auto; padding: 40px 16px 64px; }+ h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: .01em; }+ h1 span { color: var(--accent); }+ .lede { color: var(--muted); margin: 0 0 8px; max-width: 78ch; }+ .mode { color: var(--faint); margin: 0 0 28px; }+ .mode a { color: var(--text); }+ .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(520px, 1fr)); gap: 22px; }+ @media (max-width: 560px) { .grid { grid-template-columns: 1fr; } }+ .card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; display: flex; flex-direction: column; outline: none; }+ .card.sel { border-color: var(--accent); }+ .card a.shot { display: block; aspect-ratio: 1300 / 1100; background: #000 top center / cover no-repeat; border-bottom: 1px solid var(--line); }+ .card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }+ .card h2 { font-size: 16px; margin: 0; }+ .card h2 small { color: var(--faint); font-weight: 400; font-size: 12px; margin-left: 8px; }+ .card .from { color: var(--faint); font-size: 12px; }+ .card .idea { color: var(--accent); }+ .card p { margin: 0; color: var(--muted); }+ .card .keys { color: var(--faint); font-size: 12px; margin-top: auto; padding-top: 8px; }+ .card .open { display: flex; gap: 14px; padding-top: 6px; }+ .card .open a { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--faint); }+ .card .open a:hover { border-color: var(--text); }+ .card .open a.real { color: var(--accent); border-color: var(--accent); }+ .foot { color: var(--faint); margin-top: 28px; font-size: 12px; max-width: 90ch; }+ kbd { font: inherit; color: var(--muted); }+</style>+</head>+<body>+<main>+ <h1><span>◆</span> boss mode · ⌘B’s office</h1>+ <p class="lede">⌘B sends a task where it belongs in about 0.6 seconds and gets out of the way. Boss Mode is where you come back to: everything you handed off, which harness took it, and where it stands now. Four ways to see it, each built around one idea, each answering at a glance: what did I hand off, and what needs me? The chat beside the viewer answers the rest (“where is the ledger migration?”).</p>+ <p class="mode" id="mode"></p>+ <div class="grid" id="grid"></div>+ <p class="foot">Each is keyboard first: <kbd>j k</kbd> / arrows move, <kbd>⏎</kbd> opens, <kbd>/</kbd> finds, <kbd>esc</kbd> backs out. Here: <kbd>1–4</kbd> or arrows pick a card, <kbd>⏎</kbd> opens it, <kbd>r</kbd> opens it on your desk. The invented desk keeps moving: tasks finish, ask and arrive while you watch; add <kbd>?still</kbd> to hold it. Nothing here sends anything to a harness.</p>+</main>+<script src="index.js"></script>+</body>+</html>diff --git a/docs/research/2026-10-11-boss-mode/index.jpg b/docs/research/2026-10-11-boss-mode/index.jpgnew file mode 100644index 000000000..b25a0e831Binary files /dev/null and b/docs/research/2026-10-11-boss-mode/index.jpg differdiff --git a/docs/research/2026-10-11-boss-mode/index.js b/docs/research/2026-10-11-boss-mode/index.jsnew file mode 100644index 000000000..f2f444720--- /dev/null+++ b/docs/research/2026-10-11-boss-mode/index.js@@ -0,0 +1,66 @@+// The lookbook: one card per prototype. Opened by serve.mjs, each card also opens on your own desk.+(function () {+ 'use strict'+ const served = location.protocol.startsWith('http')+ const real = /[?&]real\b/.test(location.search)+ const PROTOTYPES = [+ ['approach', 'Approach', 'air traffic control · approach radar · flight strips',+ 'the nearer the centre, the more it needs you',+ 'You are the field. ⌘B is a departure; working tasks fly their machine’s sector, painted by the sweep. A task that asks you holds at its fix near the field, flashing. Finished ones line up on final, waiting for you to land them (read them). A failure squawks an emergency.',+ 'tab next · h f e holding, final, emergency · ⏎ land · space land next · u undo · / find · s strips'],+ ['pass', 'The Pass', 'a restaurant’s expo station · the ticket rail · heat lamps',+ 'finished work dies in the window if you leave it there',+ 'Every handoff is a ticket the printer fires onto the rail. A cook with a question flags it: CHEF?. Finished work comes up on the pass under the heat lamps and cools while it waits for you. Read ones go on the spike; failed ones are 86’d on the board. The expo calls it all day.',+ '← → along · ↑ ↓ rail, pass, spike, 86 · 1–9 ticket · ⏎ read · b pick up · r recall · a all day'],+ ['switchboard', 'Switchboard', 'the cord switchboard · supervisory lamps · toll tickets',+ 'where your words went, and how sure the operator was',+ '⌘B is an operator. Every harness on every machine is a line with a jack and a lamp; every task is a cord from the keyshelf to the line that took it. Flashing wants you, steady white means hung up: pull the cord. The toll ticket shows Jev’s confidence, and a ghost cord the line it nearly chose.',+ '← → cords · n flashing · w hung up · 0–9 dial a line · ⏎ listen in · p pull the cord'],+ ['score', 'Score', 'a conductor’s full score · cutaway staves · fermatas',+ 'what happened since you handed it off, read like music',+ 'One staff per harness, grouped by machine like an orchestra by family; bars as wide as what happened in them, so the night folds up. Each task is a rehearsal mark with its cue. Turns are notes, beamed when fast. Finished work ends in a double bar and Fine; a fermata is held for you.',+ 'j k staves · n next held · f next unread · [ ] cues · h l time · ⏎ the part · space play the night'],+ ]+ const mode = document.getElementById('mode')+ if (!served) mode.textContent = 'Opened as a file: an invented desk. Run serve.mjs (see README.md) to open them on your own.'+ else if (real) mode.append('Showing your own desk, read only. ', Object.assign(document.createElement('a'), { href: './', textContent: 'Show the invented desk instead' }))+ else mode.append('Showing an invented desk. ', Object.assign(document.createElement('a'), { href: './?real', textContent: 'Open them on your own desk' }))+ const grid = document.getElementById('grid')+ const cards = PROTOTYPES.map(([id, name, from, idea, says, keys], i) => {+ const card = document.createElement('article')+ card.className = 'card'+ const href = `${id}.html${real ? '?real' : ''}`+ const shot = Object.assign(document.createElement('a'), { className: 'shot', href, title: `Open ${name}` })+ shot.style.backgroundImage = `url("${id}.jpg")`+ const body = document.createElement('div')+ body.className = 'body'+ const title = document.createElement('h2')+ title.append(name, Object.assign(document.createElement('small'), { textContent: String(i + 1) }))+ body.append(title,+ Object.assign(document.createElement('div'), { className: 'from', textContent: from }),+ Object.assign(document.createElement('div'), { className: 'idea', textContent: idea }),+ Object.assign(document.createElement('p'), { textContent: says }),+ Object.assign(document.createElement('div'), { className: 'keys', textContent: keys }))+ const open = document.createElement('div')+ open.className = 'open'+ open.append(Object.assign(document.createElement('a'), { href: `${id}.html`, textContent: 'open' }))+ if (served) open.append(Object.assign(document.createElement('a'), { className: 'real', href: `${id}.html?real`, textContent: 'open on my desk' }))+ body.append(open)+ card.append(shot, body)+ grid.append(card)+ return { id, card }+ })+ let sel = 0+ const show = () => cards.forEach((c, i) => c.card.classList.toggle('sel', i === sel))+ addEventListener('keydown', (e) => {+ if (e.metaKey || e.ctrlKey || e.altKey) return+ if (/^[1-4]$/.test(e.key)) { sel = Number(e.key) - 1; show() }+ else if (['ArrowRight', 'ArrowDown', 'j', 'l'].includes(e.key)) { sel = (sel + 1) % cards.length; show() }+ else if (['ArrowLeft', 'ArrowUp', 'k', 'h'].includes(e.key)) { sel = (sel + cards.length - 1) % cards.length; show() }+ else if (e.key === 'Enter') location.href = `${cards[sel].id}.html${real ? '?real' : ''}`+ else if (e.key === 'r' && served) location.href = `${cards[sel].id}.html?real`+ else return+ e.preventDefault()+ })+ show()+})()diff --git a/docs/research/2026-10-11-boss-mode/pass-narrow.jpg b/docs/research/2026-10-11-boss-mode/pass-narrow.jpgnew file mode 100644index 000000000..8936c6336Binary files /dev/null and b/docs/research/2026-10-11-boss-mode/pass-narrow.jpg differdiff --git a/docs/research/2026-10-11-boss-mode/pass-ticket.jpg b/docs/research/2026-10-11-boss-mode/pass-ticket.jpgnew file mode 100644index 000000000..9c28b4e94Binary files /dev/null and b/docs/research/2026-10-11-boss-mode/pass-ticket.jpg differdiff --git a/docs/research/2026-10-11-boss-mode/pass.html b/docs/research/2026-10-11-boss-mode/pass.htmlnew file mode 100644index 000000000..310f0ed95--- /dev/null+++ b/docs/research/2026-10-11-boss-mode/pass.html@@ -0,0 +1,204 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width,initial-scale=1">+<title>The Pass</title>+<style>+ :root {+ --bg: #0b0c0d; --steel: #1a1d20; --text: #e7e3d8; --muted: #8d8a82; --faint: #55534e; --line: #23262a;+ --paper: #ebe5d5; --paper-2: #e2dbc8; --ink: #1d1b17; --ink-2: #5b564b;+ --red: #e5484d; --heat: #ffad4a; --green: #57c27e; --cold: #8fb3d9;+ --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;+ color-scheme: dark;+ }+ * { box-sizing: border-box; }+ html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 12px/1.4 var(--mono); }+ body { overflow: hidden; }+ #kitchen { position: fixed; inset: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 0;+ background:+ radial-gradient(ellipse 80% 50% at 50% 52%, rgba(255,173,74,.07), transparent 70%),+ repeating-linear-gradient(90deg, rgba(255,255,255,.012) 0 1px, transparent 1px 3px),+ linear-gradient(#0e1012, #0a0b0c); }++ /* the expo's call: all day */+ #call { display: flex; align-items: baseline; gap: 22px; padding: 14px 22px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; }+ #call .brand { color: var(--muted); letter-spacing: .34em; font-size: 11px; }+ #call .allday { font-size: 18px; letter-spacing: .06em; color: var(--text); overflow: hidden; text-overflow: ellipsis; }+ #call .allday .k { color: var(--faint); font-size: 12px; letter-spacing: .2em; margin-right: 10px; }+ #call .allday b { font-weight: 600; }+ #call .allday .hands { color: var(--red); }+ #call .allday .up { color: var(--heat); }+ #call .allday .x86 { color: #c9c4b8; text-decoration: line-through; text-decoration-color: var(--red); }+ #call .clock { margin-left: auto; color: var(--muted); text-align: right; font-size: 11px; }+ #call.flash .allday { animation: call 1.2s ease-out; }+ @keyframes call { 0% { color: #fff; text-shadow: 0 0 18px rgba(255,173,74,.8); } 100% { text-shadow: none; } }++ .zone { position: relative; min-height: 0; }+ .zone > h2 { position: absolute; left: 22px; top: 8px; margin: 0; font-size: 10.5px; font-weight: 500; letter-spacing: .3em; color: var(--faint); z-index: 3; }+ .zone > h2 b { color: var(--muted); font-weight: 500; }+ .zone.cur > h2 b { color: var(--text); }+ .zone.cur > h2::before { content: '▸ '; color: var(--heat); }++ /* the rail: tickets fired, hanging from steel */+ #rail { height: 352px; padding: 0 22px; }+ #rail .bar { position: absolute; left: 14px; right: 14px; top: 34px; height: 12px; border-radius: 3px;+ background: linear-gradient(#5d636a, #2c3035 45%, #1b1e21 55%, #3a3f45); box-shadow: 0 3px 8px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.22); }+ #rail .printer { position: absolute; right: 22px; top: 2px; width: 64px; height: 26px; border-radius: 4px 4px 0 0; background: linear-gradient(#2a2e33, #1a1d20); border: 1px solid #33383e; border-bottom: 0; color: var(--faint); font-size: 9px; text-align: center; line-height: 26px; letter-spacing: .2em; z-index: 4; }+ #rail .printer.on::after { content: ''; position: absolute; right: 8px; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }+ #railtickets { position: absolute; left: 22px; right: 96px; top: 30px; bottom: 0; }++ /* the pass: plates up under the heat lamps */+ #pass { padding: 0 22px; border-top: 1px solid #1d2023; border-bottom: 1px solid #1d2023;+ background: linear-gradient(rgba(255,173,74,.035), transparent 30%), linear-gradient(transparent 80%, rgba(255,255,255,.03)); }+ #pass .lamps { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }+ #pass .lamp { position: absolute; top: 0; width: 120px; height: 18px; transform: translateX(-50%); border-radius: 0 0 50% 50% / 0 0 100% 100%;+ background: linear-gradient(#3b3f44, #1c1f22); box-shadow: 0 6px 24px rgba(255,173,74,.35); }+ #pass .lamp::after { content: ''; position: absolute; left: 50%; top: 14px; width: 560px; height: 520px; transform: translateX(-50%);+ background: radial-gradient(ellipse 50% 60% at 50% 0%, rgba(255,160,60,.16), rgba(255,140,40,.05) 55%, transparent 75%); mix-blend-mode: screen; }+ #passplates { position: absolute; left: 22px; right: 22px; top: 34px; bottom: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); grid-auto-rows: min-content; gap: 14px 14px; align-content: start; overflow-y: auto; scrollbar-width: none; padding: 4px; margin: -4px; }+ #pass .empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--faint); letter-spacing: .2em; }++ /* the bottom: the spike, the 86 board, the stations */+ #floor { display: grid; grid-template-columns: 260px 1fr 300px; gap: 0; height: 206px; border-top: 1px solid var(--line); }+ #floor > section { position: relative; padding: 32px 18px 14px; min-width: 0; overflow: hidden; }+ #floor > section + section { border-left: 1px solid var(--line); }+ #spike .pin { position: absolute; left: 120px; top: 40px; width: 3px; height: 128px; background: linear-gradient(#cfd3d8, #6a7077); border-radius: 2px 2px 0 0; box-shadow: 0 0 6px rgba(255,255,255,.15); }+ #spike .pin::before { content: ''; position: absolute; left: -2px; top: -6px; border: 3.5px solid transparent; border-bottom: 7px solid #e6e9ec; }+ #spike .base { position: absolute; left: 84px; top: 166px; width: 76px; height: 10px; border-radius: 5px; background: linear-gradient(#4a5057, #24282c); }+ #spiked { position: absolute; left: 0; right: 0; top: 0; bottom: 0; }+ #spiked .stub { position: absolute; left: 66px; width: 112px; padding: 5px 7px; background: var(--paper-2); color: var(--ink); font-size: 9.5px; line-height: 1.3; border-radius: 1px; box-shadow: 0 1px 2px rgba(0,0,0,.5); text-transform: uppercase; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; filter: brightness(.82); }+ #spiked .stub.sel { outline: 2px solid var(--heat); filter: none; z-index: 5; }+ #spiked .stub::after { content: ''; position: absolute; left: 52px; top: 45%; width: 7px; height: 7px; border-radius: 50%; background: #0b0c0d; }+ #spike .count { position: absolute; left: 18px; bottom: 10px; color: var(--faint); font-size: 10.5px; }++ #board { background: linear-gradient(#141617, #111314); }+ #board .slate { position: absolute; left: 18px; right: 18px; top: 34px; bottom: 14px; border: 1px solid #2a2d30; border-radius: 3px; background: radial-gradient(ellipse at 30% 20%, #1d2122, #151819); padding: 12px 16px; overflow: hidden; }+ #board .row86 { color: #e8e2d2; font-size: 13px; letter-spacing: .05em; text-transform: uppercase; margin: 0 0 10px; transform: rotate(-.4deg); opacity: .92; cursor: pointer; padding: 2px 4px; }+ #board .row86 .no { color: var(--red); font-weight: 700; margin-right: 8px; }+ #board .row86 .why { display: block; text-transform: none; color: #a8a294; font-size: 11.5px; letter-spacing: 0; margin: 2px 0 0 0; transform: rotate(.3deg); }+ #board .row86.sel { outline: 1px dashed var(--red); }+ #board .none { color: var(--faint); }++ #stations .st { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin-bottom: 10px; }+ #stations .st b { color: var(--text); font-weight: 500; letter-spacing: .12em; text-transform: uppercase; font-size: 11px; }+ #stations .st .n { color: var(--faint); font-size: 10.5px; text-align: right; }+ #stations .st .cooks { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }+ #stations .st .cook { width: 12px; height: 12px; border-radius: 2px; background: #22262a; border: 1px solid #2f343a; }+ #stations .st .cook.working { background: var(--green); border-color: var(--green); box-shadow: 0 0 6px rgba(87,194,126,.6); }+ #stations .st .cook.asking { background: var(--red); border-color: var(--red); animation: bell 1s steps(1) infinite; }+ #stations .st .cook.done { background: var(--heat); border-color: var(--heat); }+ #stations .st.closed b { color: var(--faint); text-decoration: line-through; }+ @keyframes bell { 50% { opacity: .35; } }++ #keys { padding: 8px 16px 10px; text-align: center; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-top: 1px solid var(--line); }+ #keys kbd { font: inherit; color: var(--muted); }++ /* a ticket: thermal paper */+ .ticket { position: absolute; width: var(--tw, 172px); color: var(--ink); background: var(--paper); padding: 9px 10px 14px; font-size: 11px; line-height: 1.32; text-transform: uppercase;+ box-shadow: 0 10px 22px rgba(0,0,0,.55), 0 1px 0 rgba(255,255,255,.5) inset; cursor: pointer; transform-origin: 50% 0;+ -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 6px) no-repeat, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 10px 6px repeat-x;+ mask: linear-gradient(#000 0 0) top / 100% calc(100% - 6px) no-repeat, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 10px 6px repeat-x; }+ .ticket::before { content: ''; position: absolute; left: 50%; top: -1px; width: 28px; height: 9px; transform: translateX(-50%); background: linear-gradient(#8b9198, #3e4349); border-radius: 0 0 3px 3px; }+ .ticket .hd { display: flex; gap: 8px; font-weight: 700; font-size: 12px; margin-top: 2px; }+ .ticket .hd .at { font-weight: 500; color: var(--ink-2); }+ .ticket .meta { color: var(--ink-2); font-size: 10px; letter-spacing: .04em; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+ .ticket hr { border: 0; border-top: 1px dashed #9a937f; margin: 6px 0; }+ .ticket .order { display: grid; grid-template-columns: 14px 1fr; font-weight: 600; font-size: 11.5px; }+ .ticket .order .what { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }+ .ticket .cook { font-size: 10px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+ .ticket .timer { margin-top: 7px; display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 12px; padding: 3px 6px; color: #fff; background: #2f8a55; border-radius: 2px; }+ .ticket .timer.amber { background: #b9741c; }+ .ticket .timer.red { background: #b8312f; }+ .ticket .timer span { font-weight: 500; font-size: 9.5px; letter-spacing: .12em; opacity: .9; }+ .ticket.sel { outline: 2px solid var(--heat); outline-offset: 3px; z-index: 30 !important; }+ .ticket.dim { opacity: .2; }+ .ticket.new { animation: print 1.4s cubic-bezier(.2,.7,.2,1); }+ @keyframes print { 0% { clip-path: inset(0 0 100% 0); transform: translateY(-30px); } 60% { clip-path: inset(0 0 0 0); transform: translateY(-14px); } 100% { transform: none; } }+ .ticket.swing { animation: swing 2.6s ease-in-out infinite; }+ @keyframes swing { 0%, 100% { rotate: -1.3deg; } 50% { rotate: 1.3deg; } }++ /* the cook needs the chef: a red flag and the question chit */+ .ticket .flag { position: absolute; right: -2px; top: 14px; background: var(--red); color: #fff; font-weight: 700; font-size: 10px; letter-spacing: .1em; padding: 2px 7px 2px 9px; clip-path: polygon(8px 0, 100% 0, 100% 100%, 8px 100%, 0 50%); }+ .ticket .chit { margin: 8px -4px 0; padding: 7px 8px; background: #fff4d6; border-left: 3px solid var(--red); color: #3a2a12; font-size: 11px; text-transform: none; line-height: 1.38; font-style: italic;+ box-shadow: 0 1px 3px rgba(0,0,0,.25); display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }++ /* a plate up on the pass */+ .plate { position: relative; color: var(--ink); background: var(--paper); padding: 10px 12px 12px; font-size: 11px; line-height: 1.38; cursor: pointer;+ box-shadow: 0 0 0 1px rgba(255,190,110,.25), 0 14px 30px rgba(0,0,0,.55), 0 0 44px rgba(255,160,60,var(--warm, .22)); filter: saturate(var(--sat, 1)) hue-rotate(var(--hue, 0deg)); }+ .plate .hd { display: flex; justify-content: space-between; font-weight: 700; font-size: 12px; text-transform: uppercase; }+ .plate .order { text-transform: uppercase; font-weight: 600; font-size: 10.5px; color: var(--ink-2); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+ .plate .result { margin-top: 7px; padding-top: 7px; border-top: 1px dashed #9a937f; font-size: 11.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; min-height: 4.2em; }+ .plate .hd .where { font-weight: 500; color: var(--ink-2); font-size: 10.5px; }+ .plate .state { margin-top: 7px; font-size: 10px; font-weight: 700; letter-spacing: .1em; color: #a3501b; }+ .plate.cold .state { color: #3d6488; }+ .plate .up { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; font-size: 10px; color: var(--ink-2); line-height: 1.35; }+ .plate .stamp { flex: none; color: rgba(184,49,47,.8); border: 2px solid rgba(184,49,47,.65); font-weight: 800; font-size: 12px; letter-spacing: .1em; padding: 1px 6px; transform: rotate(-7deg); margin-left: 8px; }+ .plate .steam { position: absolute; left: 0; right: 0; top: -26px; height: 26px; pointer-events: none; }+ .plate .steam i { position: absolute; bottom: 0; width: 14px; height: 22px; border-radius: 50%; background: radial-gradient(rgba(255,255,255,.22), transparent 70%); filter: blur(3px); animation: steam 3.2s ease-out infinite; }+ @keyframes steam { 0% { transform: translateY(6px) scale(.6); opacity: 0; } 30% { opacity: .9; } 100% { transform: translateY(-14px) scale(1.4); opacity: 0; } }+ .plate.sel { box-shadow: 0 0 0 2px var(--heat), 0 0 0 6px rgba(255,173,74,.18), 0 14px 30px rgba(0,0,0,.55), 0 0 44px rgba(255,160,60,var(--warm, .22)); }+ .plate.dim { opacity: .2; }+ .plate.bumped { animation: bump .5s ease-in forwards; }+ @keyframes bump { to { transform: translate(-60px, 120px) rotate(-8deg) scale(.6); opacity: 0; } }++ /* a ticket read in full */+ #read { position: fixed; inset: 0; background: rgba(5,6,7,.72); backdrop-filter: blur(3px); display: none; align-items: flex-start; justify-content: center; padding: 48px 16px; z-index: 50; overflow-y: auto; }+ #read.on { display: flex; }+ #read .big { position: relative; width: min(470px, 100%); background: var(--paper); color: var(--ink); padding: 18px 20px 26px; font-size: 12.5px; line-height: 1.5; box-shadow: 0 30px 80px rgba(0,0,0,.7);+ -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 14px 8px repeat-x;+ mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 14px 8px repeat-x; }+ #read .big h1 { font-size: 15px; margin: 0; display: flex; justify-content: space-between; text-transform: uppercase; }+ #read .big .meta { color: var(--ink-2); text-transform: uppercase; font-size: 11px; }+ #read .big hr { border: 0; border-top: 1px dashed #9a937f; margin: 10px 0; }+ #read .big .order { font-weight: 700; text-transform: uppercase; font-size: 14px; overflow-wrap: anywhere; }+ #read .big .said { white-space: pre-wrap; overflow-wrap: anywhere; }+ #read .big .said.q { background: #fff4d6; border-left: 3px solid var(--red); padding: 8px 10px; font-style: italic; }+ #read .big .line { display: grid; grid-template-columns: 96px 1fr; gap: 8px; font-size: 11.5px; margin: 3px 0; }+ #read .big .line b { text-transform: uppercase; color: var(--ink-2); font-weight: 600; letter-spacing: .04em; }+ #read .big .tl { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; text-transform: uppercase; color: var(--ink-2); }+ #read .big .tl span b { color: var(--ink); }+ #read .big .keys { margin-top: 14px; font-size: 11px; color: var(--ink-2); }+ #read .big .keys kbd { font: inherit; font-weight: 700; color: var(--ink); }++ #find { position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%); background: #121416; border: 1px solid #2c3034; padding: 6px 12px; font-size: 13px; display: none; z-index: 40; white-space: nowrap; }+ #find.on { display: block; }+ #find .c { color: var(--heat); }+ #find i { display: inline-block; width: .6em; height: 1.05em; background: var(--text); transform: translateY(2px); animation: blink 1.05s steps(1) infinite; }+ @keyframes blink { 50% { opacity: 0; } }+ #toast { position: fixed; left: 50%; top: 58px; transform: translateX(-50%); background: #16181a; border: 1px solid #2d3135; color: var(--text); padding: 6px 14px; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 60; white-space: nowrap; letter-spacing: .04em; }+ #toast.on { opacity: 1; }+ #loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--faint); letter-spacing: .3em; pointer-events: none; }++ @media (max-width: 980px) {+ #floor { grid-template-columns: 180px 1fr; height: 214px; }+ #stations { display: none; }+ #spike .pin { left: 80px; } #spike .base { left: 44px; } #spiked .stub { left: 26px; }+ #call .allday { font-size: 15px; }+ #call .brand { display: none; }+ }+ @media (prefers-reduced-motion: reduce) {+ .ticket.swing, .plate .steam i, .ticket.new, #stations .cook.asking { animation: none !important; }+ }+</style>+</head>+<body>+<div id="kitchen">+ <header id="call"><span class="brand">THE PASS</span><span class="allday" id="allday"></span><span class="clock" id="clock"></span></header>+ <section class="zone" id="rail"><h2><b>THE RAIL</b> · fired, oldest first</h2><div class="bar"></div><div class="printer" id="printer">⌘B</div><div id="railtickets"></div></section>+ <section class="zone" id="pass"><h2><b>THE PASS</b> · up, waiting for you to pick it up</h2><div class="lamps" id="lamps"></div><div id="passplates"></div></section>+ <div id="floor">+ <section class="zone" id="spike"><h2><b>THE SPIKE</b></h2><div class="pin"></div><div class="base"></div><div id="spiked"></div><div class="count" id="spikecount"></div></section>+ <section class="zone" id="board"><h2><b>86</b> · failed, or never sent</h2><div class="slate" id="slate"></div></section>+ <section class="zone" id="stations"><h2><b>STATIONS</b></h2><div id="crew"></div></section>+ </div>+ <footer id="keys"></footer>+</div>+<div id="read"><article class="big" id="big"></article></div>+<div id="find"><span class="c">/</span> <span id="q"></span><i></i></div>+<div id="toast"></div>+<div id="loading">firing</div>+<script src="boss-data.js"></script>+<script src="pass.js"></script>+</body>+</html>diff --git a/docs/research/2026-10-11-boss-mode/pass.jpg b/docs/research/2026-10-11-boss-mode/pass.jpgnew file mode 100644index 000000000..2db0d9325Binary files /dev/null and b/docs/research/2026-10-11-boss-mode/pass.jpg differdiff --git a/docs/research/2026-10-11-boss-mode/pass.js b/docs/research/2026-10-11-boss-mode/pass.jsnew file mode 100644index 000000000..e024c3865--- /dev/null+++ b/docs/research/2026-10-11-boss-mode/pass.js@@ -0,0 +1,371 @@+// The Pass: ⌘B's office as a restaurant's expo station. Every task you handed off is a ticket the printer+// fires onto the rail. A cook with a question flags it for the chef. Finished work comes up on the pass+// under the heat lamps and waits for you to pick it up — and, like a plate, it dies in the window if you+// leave it there. Read ones go on the spike; failed ones are 86'd on the board. The bump bar is the+// keyboard.+(function () {+ 'use strict'+ const B = window.BossData+ const $ = (id) => document.getElementById(id)+ const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e }+ const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches+ const ZONES = ['rail', 'pass', 'spike', 'board']+ let desk = null+ let zone = 'pass', sel = null+ let query = null, typing = false+ let reading = false+ const bumped = []+ const fresh = new Set()+ let toastTimer = 0++ // ── what is where ──────────────────────────────────────────────────────────────────────────────────++ function zoneOf(d) {+ if (['routing', 'working', 'asking', 'offline'].includes(d.state)) return 'rail'+ if (d.state === 'done' && !d.seenAt) return 'pass'+ if (d.state === 'failed' || d.state === 'undelivered') return 'board'+ return 'spike'+ }+ const matches = (d) => {+ if (!query) return true+ const h = B.harness(d.harness)+ const hay = `#${d.n} ${d.text} ${h?.name ?? ''} ${h?.project ?? ''} ${d.machine ?? ''} ${d.question ?? ''} ${d.summary ?? ''} ${d.error ?? ''}`.toLowerCase()+ return query.toLowerCase().split(/\s+/).filter(Boolean).every((w) => hay.includes(w))+ }+ function items(z) {+ const list = desk.dispatches.filter((d) => zoneOf(d) === z)+ if (z === 'rail') return list.sort((a, b) => a.at - b.at)+ if (z === 'pass') return list.sort((a, b) => a.since - b.since)+ if (z === 'spike') return list.sort((a, b) => (b.seenAt ?? b.since) - (a.seenAt ?? a.since))+ return list.sort((a, b) => b.at - a.at)+ }+ const span = (ms) => {+ const m = Math.max(0, Math.floor(ms / 60000))+ return m < 60 ? `0:${String(m).padStart(2, '0')}` : `${Math.floor(m / 60)}:${String(m % 60).padStart(2, '0')}`+ }+ const upper = (t) => String(t ?? '').toUpperCase()+ const via = (d) => {+ const dec = d.decision+ if (dec.kind === 'routing') return '⌘B · DECIDING…'+ if (dec.kind === 'none') return '⌘B · SENT NOWHERE'+ if (dec.kind === 'direct') return 'TYPED IN THE PANE'+ const p = dec.p != null ? ` · JEV ${dec.p.toFixed(2).replace(/^0/, '')}` : ''+ return dec.kind === 'new' ? `⌘B · NEW${p}` : `⌘B · SAME WORK${p}`+ }++ // ── tickets ────────────────────────────────────────────────────────────────────────────────────────++ function ticket(d, now) {+ const h = B.harness(d.harness)+ const t = el('article', 'ticket')+ t.dataset.id = d.id+ const hd = el('div', 'hd'); hd.append(el('span', null, `#${String(d.n).padStart(2, '0')}`), el('span', 'at', B.clock(d.at)))+ t.append(hd, el('div', 'meta', h ? upper(h.project) : 'NO STATION'), el('div', 'meta', h ? upper(d.machine) : ''))+ t.append(el('hr'))+ const order = el('div', 'order'); order.append(el('span', null, '1'), el('span', 'what', upper(d.text)))+ t.append(order, el('hr'))+ t.append(el('div', 'cook', h ? `${upper(B.engine(h.engine).short)} · ${upper(h.name)}` : '—'))+ t.append(el('div', 'cook', via(d)))+ const timer = el('div', 'timer')+ if (d.state === 'asking') {+ const wait = now - d.since+ timer.classList.add(wait > 10 * B.MIN ? 'red' : 'amber')+ timer.append(el('span', null, 'WAITING'), span(wait))+ t.append(el('div', 'flag', 'CHEF?'), el('div', 'chit', d.question))+ if (!reduced) t.classList.add('swing')+ } else if (d.state === 'offline') {+ timer.style.background = '#55534e'+ timer.append(el('span', null, 'STATION CLOSED'), span(now - d.since))+ } else if (d.state === 'routing') {+ timer.style.background = '#3a3f45'+ timer.append(el('span', null, 'FIRING'), '0:00')+ } else {+ const on = now - (d.landedAt ?? d.at)+ timer.classList.add(on > 2 * B.HOUR ? 'amber' : 'green')+ timer.append(el('span', null, 'ON THE LINE'), span(on))+ }+ t.append(timer)+ if (d.id === sel) t.classList.add('sel')+ if (!matches(d)) t.classList.add('dim')+ if (fresh.has(d.id)) { t.classList.add('new'); fresh.delete(d.id) }+ t.addEventListener('click', () => { pick('rail', d.id); open() })+ return t+ }++ function plate(d, now) {+ const h = B.harness(d.harness)+ const p = el('article', 'plate')+ p.dataset.id = d.id+ const sat = now - d.since+ // Warm under the lamp at first; past three hours it is dying in the window, past eight it is cold.+ const k = Math.min(1, Math.max(0, (sat - 0.5 * B.HOUR) / (8 * B.HOUR)))+ p.style.setProperty('--warm', String(0.26 * (1 - k) + 0.02))+ p.style.setProperty('--sat', String(1 - 0.35 * k))+ p.style.setProperty('--hue', `${-14 * k}deg`)+ if (sat > 3 * B.HOUR) p.classList.add('cold')+ const hd = el('div', 'hd'); hd.append(el('span', null, `#${String(d.n).padStart(2, '0')} · ${upper(h?.project ?? '')}`))+ p.append(hd, el('div', 'order', upper(d.text)), el('div', 'result', d.summary ?? ''))+ p.append(el('div', 'state', sat > 3 * B.HOUR ? 'DYING IN THE WINDOW' : sat < 30 * B.MIN ? 'JUST UP' : 'UP'))+ const up = el('div', 'up')+ up.append(el('span', null, `${span(sat)} in the window · ${d.machine ?? ''}`), el('span', 'stamp', d.pr ? `PR #${d.pr}` : 'UP'))+ p.append(up)+ if (sat < 2 * B.HOUR && !reduced) {+ const steam = el('div', 'steam')+ for (let i = 0; i < 4; i++) { const w = el('i'); w.style.left = `${18 + i * 22}%`; w.style.animationDelay = `${i * 0.7}s`; steam.append(w) }+ p.append(steam)+ }+ if (d.id === sel) p.classList.add('sel')+ if (!matches(d)) p.classList.add('dim')+ p.addEventListener('click', () => { pick('pass', d.id); open() })+ return p+ }++ // ── the whole kitchen ──────────────────────────────────────────────────────────────────────────────++ function rects() {+ const out = new Map()+ for (const e of document.querySelectorAll('[data-id]')) out.set(e.dataset.id, e.getBoundingClientRect())+ return out+ }+ function flip(before) {+ if (reduced) return+ for (const e of document.querySelectorAll('[data-id]')) {+ const was = before.get(e.dataset.id)+ if (!was) continue+ const now = e.getBoundingClientRect()+ const dx = was.left - now.left, dy = was.top - now.top+ if (Math.abs(dx) + Math.abs(dy) < 2) continue+ e.animate([{ translate: `${dx}px ${dy}px` }, { translate: '0 0' }], { duration: 650, easing: 'cubic-bezier(.2,.7,.2,1)' })+ }+ }++ function render() {+ const before = rects()+ const now = desk.now+ // All day: the expo's count of everything on.+ const n = Object.fromEntries(ZONES.map((z) => [z, items(z)]))+ const asking = n.rail.filter((d) => d.state === 'asking').length+ const all = $('allday'); all.replaceChildren(el('span', 'k', 'ALL DAY'))+ const part = (text, cls) => all.append(cls ? el('b', cls, text) : text)+ part(`${n.rail.length - asking} FIRED`); part(' · ')+ part(`${asking} NEED YOU`, asking ? 'hands' : ''); part(' · ')+ part(`${n.pass.length} UP`, n.pass.length ? 'up' : ''); part(' · ')+ part(`${n.board.length} 86'D`, n.board.length ? 'x86' : '')+ const first = desk.dispatches.reduce((m, d) => Math.min(m, d.at), now)+ $('clock').replaceChildren(el('div', null, new Date(now).toLocaleTimeString('en-GB')), el('div', null, `${desk.real ? 'your desk' : 'an invented desk'} · service ${B.ago(now - first)}`))+ for (const z of ZONES) $(z).classList.toggle('cur', z === zone)++ // The rail: tickets overlap like real ones when the rail is full.+ const rail = $('railtickets')+ const width = rail.getBoundingClientRect().width+ const list = n.rail+ const tw = Math.max(150, Math.min(184, width / Math.max(1, list.length) - 12))+ const step = list.length > 1 ? Math.min(tw + 14, (width - tw) / (list.length - 1)) : 0+ rail.replaceChildren(...list.map((d, i) => {+ const t = ticket(d, now)+ t.style.setProperty('--tw', `${tw}px`)+ t.style.left = `${i * step}px`+ t.style.zIndex = String(d.state === 'asking' ? 20 + i : 1 + i)+ return t+ }))+ $('printer').classList.toggle('on', list.some((d) => d.state === 'routing'))++ // The pass, its lamps over it.+ const plates = $('passplates')+ plates.replaceChildren(...n.pass.map((d) => plate(d, now)))+ const passBox = $('pass').getBoundingClientRect()+ const lamps = $('lamps')+ const count = Math.max(2, Math.min(5, Math.round(passBox.width / 300)))+ lamps.replaceChildren(...Array.from({ length: count }, (_, i) => { const l = el('div', 'lamp'); l.style.left = `${((i + 0.5) / count) * 100}%`; return l }))+ $('pass').querySelector('.empty')?.remove()+ if (!n.pass.length) $('pass').append(el('div', 'empty', 'nothing up · the pass is clear'))++ // The spike: newest on top.+ const spiked = $('spiked')+ const shown = n.spike.slice(0, 9)+ spiked.replaceChildren(...shown.map((d, i) => {+ const s = el('div', 'stub', `#${String(d.n).padStart(2, '0')} ${d.state === 'stopped' ? 'STOPPED · ' : ''}${upper(d.text)}`)+ s.dataset.id = d.id+ s.style.top = `${48 + (shown.length - 1 - i) * 15}px`+ s.style.rotate = `${(((d.n * 37) % 11) - 5) * 0.9}deg`+ s.style.zIndex = String(20 - i)+ if (d.id === sel) s.classList.add('sel')+ s.addEventListener('click', () => { pick('spike', d.id); open() })+ return s+ }))+ $('spikecount').textContent = `${n.spike.filter((d) => d.state === 'done').length} picked up · ${n.spike.filter((d) => d.state === 'stopped').length} stopped`++ // The 86 board.+ const slate = $('slate')+ slate.replaceChildren(...(n.board.length ? n.board.map((d) => {+ const r = el('div', 'row86')+ r.dataset.id = d.id+ r.append(el('span', 'no', `86 #${String(d.n).padStart(2, '0')}`), d.text)+ r.append(el('span', 'why', d.error ?? ''))+ if (d.id === sel) r.classList.add('sel')+ r.addEventListener('click', () => { pick('board', d.id); open() })+ return r+ }) : [el('div', 'none', 'nothing 86’d')]))++ // Stations: every cook on every machine, lit by what they are doing.+ const crew = $('crew')+ crew.replaceChildren(...desk.machines.map((m) => {+ const cooks = desk.harnesses.filter((h) => h.machine === m.id && h.state !== 'stopped')+ const st = el('div', `st${m.online ? '' : ' closed'}`)+ st.append(el('b', null, m.name), el('span', 'n', m.online ? `${cooks.filter((h) => h.state === 'working').length} cooking · ${cooks.length} on` : `closed ${m.since ? B.clock(m.since) : ''}`))+ const row = el('div', 'cooks')+ for (const h of cooks) { const c = el('span', `cook ${h.state}`); c.title = `${h.name} · ${B.STATES[h.state]?.word ?? h.state}`; row.append(c) }+ st.append(row)+ return st+ }))+ flip(before)+ document.querySelector(`.plate.sel`)?.scrollIntoView({ block: 'nearest' })+ if (reading) open()+ }++ // ── reading a ticket ──────────────────────────────────────────────────────────────────────────────++ function open() {+ const d = desk.dispatches.find((x) => x.id === sel)+ if (!d) return+ reading = true+ const h = B.harness(d.harness)+ const big = $('big')+ big.replaceChildren()+ const h1 = el('h1'); h1.append(el('span', null, `#${String(d.n).padStart(2, '0')}`), el('span', null, `${B.clock(d.at)} · ${B.ago(desk.now - d.at)} ago`))+ big.append(h1, el('div', 'meta', h ? `${d.machine} · ${h.project} · ${B.engine(h.engine).name}` : 'no station'), el('hr'), el('div', 'order', d.text), el('hr'))+ if (d.state === 'asking') big.append(el('div', 'said q', d.question))+ else if (d.error) big.append(el('div', 'said', d.error))+ else if (d.summary) big.append(el('div', 'said', d.summary))+ else big.append(el('div', 'said', `${B.STATES[d.state]?.word ?? d.state}…`))+ big.append(el('hr'))+ const line = (k, v) => { const r = el('div', 'line'); r.append(el('b', null, k), el('span', null, v)); big.append(r) }+ line('cook', h ? `${h.name} (${B.engine(h.engine).short})` : '—')+ const dec = d.decision+ line('⌘B', dec.kind === 'session' ? `sent to “${h?.name}”, already running${dec.p != null ? ` · Jev ${dec.p.toFixed(2)}` : ''}${dec.runnerUp ? `; next best “${dec.runnerUp.name}” ${dec.runnerUp.p.toFixed(2)}` : ''}${dec.ms ? ` · ${(dec.ms / 1000).toFixed(2)} s` : ''}`+ : dec.kind === 'new' ? `started “${h?.name}”: ${dec.why}${dec.p != null ? ` · Jev ${dec.p.toFixed(2)}` : ''}${dec.ms ? ` · ${(dec.ms / 1000).toFixed(2)} s` : ''}`+ : dec.kind === 'direct' ? 'typed into the harness itself, not through ⌘B'+ : dec.kind === 'routing' ? 'deciding…' : 'decided nothing, so nothing was sent')+ line('said by', d.via === 'voice' ? 'voice' : d.via === 'pane' ? 'keyboard, in the pane' : 'keyboard, ⌘B')+ if (h) line('since', `${h.turns.filter((t) => t.at >= d.at).length} turns · ${h.tokens >= 1e6 ? `${(h.tokens / 1e6).toFixed(1)}M` : `${Math.round(h.tokens / 1000)}k`} tokens in all`)+ const tl = el('div', 'tl')+ const WORD = { routing: 'fired', working: 'on the line', asking: 'chef?', done: 'up', failed: "86'd", undelivered: "86'd", offline: 'station closed', stopped: 'stopped' }+ for (const step of d.history) { const s = el('span'); s.append(`${WORD[step.state] ?? step.state} `, el('b', null, B.clock(step.at))); tl.append(s) }+ if (d.seenAt) { const s = el('span'); s.append('picked up ', el('b', null, B.clock(d.seenAt))); tl.append(s) }+ big.append(el('hr'), tl)+ const keys = el('div', 'keys')+ const z = zoneOf(d)+ const k = z === 'pass' ? [['b', 'pick it up'], ['←→', 'next plate'], ['esc', 'back']]+ : d.state === 'asking' ? [['→', 'answer it in the chat'], ['⏎', 'bring it forward'], ['esc', 'back']]+ : z === 'spike' ? [['r', 'back on the pass'], ['esc', 'back']] : [['←→', 'next ticket'], ['esc', 'back']]+ k.forEach(([a, b], i) => { if (i) keys.append(' · '); keys.append(el('kbd', null, a), ` ${b}`) })+ big.append(keys)+ $('read').classList.add('on')+ }+ function close() { reading = false; $('read').classList.remove('on') }++ // ── the bump bar ───────────────────────────────────────────────────────────────────────────────────++ function pick(z, id) { zone = z; sel = id; render() }+ function move(step) {+ const list = items(zone).filter(matches)+ if (!list.length) return+ const i = list.findIndex((d) => d.id === sel)+ sel = list[i < 0 ? 0 : Math.max(0, Math.min(list.length - 1, i + step))].id+ render()+ }+ function zoneStep(step) {+ let i = ZONES.indexOf(zone)+ for (let k = 0; k < ZONES.length; k++) {+ i = (i + step + ZONES.length) % ZONES.length+ const list = items(ZONES[i]).filter(matches)+ if (list.length) { zone = ZONES[i]; sel = list[0].id; render(); return }+ }+ }+ function bump() {+ const d = desk.dispatches.find((x) => x.id === sel)+ if (!d) return+ if (zoneOf(d) === 'pass') {+ const node = document.querySelector(`.plate[data-id="${CSS.escape(d.id)}"]`)+ const list = items('pass').filter(matches)+ const next = list[list.findIndex((x) => x.id === d.id) + 1] ?? list[list.findIndex((x) => x.id === d.id) - 1]+ const go = () => { bumped.push(d.id); B.markSeen(d.id); sel = next?.id ?? null; if (!next) zoneStep(1); toast(`#${String(d.n).padStart(2, '0')} picked up · heard`) }+ if (node && !reduced) { node.classList.add('bumped'); setTimeout(go, 420) } else go()+ } else if (d.state === 'asking') toast('the cook is asking you: answer it in the chat →')+ else if (zoneOf(d) === 'rail') toast('still on the line')+ else toast('nothing to pick up')+ }+ function recall() {+ const id = bumped.pop() ?? (zoneOf(desk.dispatches.find((x) => x.id === sel) ?? {}) === 'spike' ? sel : null)+ const d = desk.dispatches.find((x) => x.id === id)+ if (!d || d.state !== 'done') return toast('nothing to recall')+ B.unseen(id); zone = 'pass'; sel = id; render(); toast(`#${String(d.n).padStart(2, '0')} recalled to the pass`)+ }+ function toast(text) {+ const t = $('toast'); t.textContent = text; t.classList.add('on')+ clearTimeout(toastTimer); toastTimer = setTimeout(() => t.classList.remove('on'), 2400)+ }++ addEventListener('keydown', (e) => {+ if (e.metaKey || e.ctrlKey || e.altKey) return+ if (typing) {+ if (e.key === 'Escape') { query = null; typing = false }+ else if (e.key === 'Enter') typing = false+ else if (e.key === 'Backspace') query = query.slice(0, -1)+ else if (e.key.length === 1) query += e.key+ else return+ e.preventDefault(); $('find').classList.toggle('on', query !== null); $('q').textContent = query ?? ''; render(); return+ }+ if (reading) {+ if (e.key === 'Escape' || e.key === 'q') close()+ else if (e.key === 'ArrowRight' || e.key === 'l') move(1)+ else if (e.key === 'ArrowLeft' || e.key === 'h') move(-1)+ else if (e.key === 'b' || e.key === ' ') { bump(); if (zoneOf(desk.dispatches.find((x) => x.id === sel) ?? {}) !== 'pass') close() }+ else if (e.key === 'r') { close(); recall() }+ else if (e.key === 'Enter') toast('would bring it forward in its pane')+ else return+ e.preventDefault(); return+ }+ if (/^[1-9]$/.test(e.key)) { const list = items(zone).filter(matches); const d = list[Number(e.key) - 1]; if (d) { sel = d.id; render() } e.preventDefault(); return }+ switch (e.key) {+ case 'ArrowRight': case 'l': move(1); break+ case 'ArrowLeft': case 'h': move(-1); break+ case 'ArrowDown': case 'j': zoneStep(1); break+ case 'ArrowUp': case 'k': zoneStep(-1); break+ case 'Enter': if (!sel) move(0); open(); break+ case 'b': case ' ': bump(); break+ case 'r': recall(); break+ case 'a': { const c = $('call'); c.classList.remove('flash'); void c.offsetWidth; c.classList.add('flash'); break }+ case '/': query = ''; typing = true; $('find').classList.add('on'); $('q').textContent = ''; break+ case 'Escape': if (query) { query = null; $('find').classList.remove('on'); render() } else { sel = null; render() } break+ default: return+ }+ e.preventDefault()+ })+ $('read').addEventListener('click', (e) => { if (e.target === $('read')) close() })++ function keysLine() {+ const parts = [['← →', 'along'], ['↑ ↓', 'rail · pass · spike · 86'], ['1–9', 'ticket'], ['⏎', 'read'], ['b', 'pick up'], ['r', 'recall'], ['a', 'all day'], ['/', 'find']]+ const keys = $('keys')+ parts.forEach(([k, w], i) => { if (i) keys.append(' · '); keys.append(el('kbd', null, k), ` ${w}`) })+ }++ B.load().then((d) => {+ desk = d+ $('loading').remove()+ keysLine()+ const pick0 = new URLSearchParams(location.search).get('select')+ const start = (pick0 && desk.dispatches.find((x) => x.id === pick0)) ?? items('pass')[0] ?? items('rail')[0]+ if (start) { zone = zoneOf(start); sel = start.id }+ render()+ let last = 0+ B.subscribe((_, event) => {+ if (event.type === 'dispatch') fresh.add(event.dispatch)+ if (event.type === 'turn') return+ if (event.type === 'tick' && Date.now() - last < 15000) return+ last = Date.now()+ render()+ })+ addEventListener('resize', render)+ }).catch((error) => { $('loading').textContent = `could not read the desk: ${error.message}` })+})()diff --git a/docs/research/2026-10-11-boss-mode/score-narrow.jpg b/docs/research/2026-10-11-boss-mode/score-narrow.jpgnew file mode 100644index 000000000..ee93aab00Binary files /dev/null and b/docs/research/2026-10-11-boss-mode/score-narrow.jpg differdiff --git a/docs/research/2026-10-11-boss-mode/score-part.jpg b/docs/research/2026-10-11-boss-mode/score-part.jpgnew file mode 100644index 000000000..96017b642Binary files /dev/null and b/docs/research/2026-10-11-boss-mode/score-part.jpg differdiff --git a/docs/research/2026-10-11-boss-mode/score.html b/docs/research/2026-10-11-boss-mode/score.htmlnew file mode 100644index 000000000..3027b4e45--- /dev/null+++ b/docs/research/2026-10-11-boss-mode/score.html@@ -0,0 +1,74 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width,initial-scale=1">+<title>Score</title>+<style>+ :root {+ --bg: #0c0b0a; --ink: #e8e1d0; --muted: #9a9284; --faint: #5c574e; --line: #24211d;+ --gold: #e8b860; --amber: #ffb547; --red: #ff6b5f; --fine: #f4efe2;+ --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;+ --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;+ color-scheme: dark;+ }+ * { box-sizing: border-box; }+ html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font: 12px/1.45 var(--mono); }+ #page { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }+ #head { position: fixed; left: 22px; right: 22px; top: 12px; display: flex; align-items: baseline; gap: 20px; white-space: nowrap; overflow: hidden; pointer-events: none; }+ #head .t { font: italic 22px/1 var(--serif); letter-spacing: .02em; color: var(--fine); }+ #head .t small { font: 11px var(--mono); font-style: normal; color: var(--faint); letter-spacing: .2em; margin-left: 10px; }+ #head .glance { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }+ #head .glance b { font-weight: 600; }+ #head .glance .held { color: var(--amber); }+ #head .glance .fine { color: var(--fine); }+ #head .glance .broke { color: var(--red); }+ #head .clock { margin-left: auto; color: var(--faint); }+ #cue { position: fixed; left: 22px; right: 22px; bottom: 34px; color: var(--muted); font: italic 14px/1.4 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }+ #cue b { font: 600 11px var(--mono); font-style: normal; color: var(--gold); border: 1px solid var(--gold); padding: 0 4px; margin-right: 8px; }+ #cue .who { font: 11px var(--mono); font-style: normal; color: var(--faint); margin-left: 10px; }+ #keys { position: fixed; left: 0; right: 0; bottom: 10px; text-align: center; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 12px; pointer-events: none; }+ #keys kbd { font: inherit; color: var(--muted); }++ /* a part: one harness's music, taken out of the score */+ #part { position: fixed; top: 54px; right: 16px; bottom: 56px; width: min(440px, calc(100% - 32px)); background: rgba(16,15,13,.97); border: 1px solid #2c2822; border-radius: 4px;+ box-shadow: 0 24px 60px rgba(0,0,0,.6); padding: 20px 22px; overflow-y: auto; transform: translateX(24px); opacity: 0; pointer-events: none; transition: opacity .25s, transform .3s cubic-bezier(.2,.7,.2,1); scrollbar-width: thin; scrollbar-color: #2c2822 transparent; }+ #part.on { opacity: 1; transform: none; pointer-events: auto; }+ #part h1 { font: italic 26px/1.15 var(--serif); margin: 0; color: var(--fine); overflow-wrap: anywhere; }+ #part .sub { color: var(--faint); margin-top: 4px; letter-spacing: .04em; }+ #part .now { margin: 18px 0 6px; padding: 10px 12px; border-left: 2px solid var(--edge, var(--faint)); background: rgba(255,255,255,.03); font: 15px/1.5 var(--serif); color: var(--ink); overflow-wrap: anywhere; }+ #part .now .k { display: block; font: 600 10.5px var(--mono); letter-spacing: .18em; color: var(--edge, var(--muted)); margin-bottom: 4px; text-transform: uppercase; }+ #part h2 { font: 500 10.5px var(--mono); letter-spacing: .2em; color: var(--faint); margin: 22px 0 8px; text-transform: uppercase; }+ #part .mark { display: grid; grid-template-columns: 34px 1fr; gap: 0 10px; margin-bottom: 12px; }+ #part .mark .box { font: 600 11px var(--mono); color: var(--gold); border: 1px solid var(--gold); text-align: center; height: 20px; line-height: 18px; }+ #part .mark .said { font: italic 14px/1.4 var(--serif); color: var(--ink); overflow-wrap: anywhere; }+ #part .mark .how { color: var(--faint); font-size: 11px; margin-top: 2px; overflow-wrap: anywhere; }+ #part .stats { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; color: var(--muted); font-size: 11.5px; }+ #part .stats b { color: var(--faint); font-weight: 400; }+ #part .keys { margin-top: 18px; color: var(--faint); font-size: 11px; }+ #part .keys kbd { font: inherit; color: var(--ink); }++ #find { position: fixed; left: 50%; top: 46px; transform: translateX(-50%); padding: 5px 12px; background: #141210; border: 1px solid #2c2822; font-size: 13px; display: none; white-space: nowrap; }+ #find.on { display: block; }+ #find .c { color: var(--gold); }+ #find i { display: inline-block; width: .6em; height: 1.05em; background: var(--ink); transform: translateY(2px); animation: blink 1.05s steps(1) infinite; }+ @keyframes blink { 50% { opacity: 0; } }+ #toast { position: fixed; left: 50%; top: 46px; transform: translateX(-50%); padding: 5px 12px; background: #141210; border: 1px solid #2c2822; opacity: 0; transition: opacity .3s; pointer-events: none; white-space: nowrap; }+ #toast.on { opacity: 1; }+ #loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--faint); letter-spacing: .3em; pointer-events: none; }+ @media (max-width: 900px) { #head .clock { display: none; } #head .t small { display: none; } }+</style>+</head>+<body>+<canvas id="page" aria-label="The night as an orchestral score: every harness is a staff, every task you handed off is a rehearsal mark, a fermata is held for you"></canvas>+<header id="head"><span class="t">Score<small>BOSS MODE</small></span><span class="glance" id="glance"></span><span class="clock" id="clock"></span></header>+<div id="cue"></div>+<aside id="part" aria-live="polite"></aside>+<div id="find"><span class="c">/</span> <span id="q"></span><i></i></div>+<div id="toast"></div>+<footer id="keys"></footer>+<div id="loading">tuning</div>+<script src="boss-data.js"></script>+<script src="score.js"></script>+</body>+</html>diff --git a/docs/research/2026-10-11-boss-mode/score.jpg b/docs/research/2026-10-11-boss-mode/score.jpgnew file mode 100644index 000000000..a6e7e323fBinary files /dev/null and b/docs/research/2026-10-11-boss-mode/score.jpg differdiff --git a/docs/research/2026-10-11-boss-mode/score.js b/docs/research/2026-10-11-boss-mode/score.jsnew file mode 100644index 000000000..14b40b448--- /dev/null+++ b/docs/research/2026-10-11-boss-mode/score.js@@ -0,0 +1,607 @@+// Score: the desk as a conductor's full score. Time runs left to right, one staff per harness, grouped by+// machine the way an orchestra is grouped by family. Each task you handed off is a rehearsal mark with its+// cue; the harness's turns are its notes, beamed where it played fast. A harness that finished ends in+// a double bar and "Fine"; one that needs you holds a fermata — a note held until you cue it. You read the+// night the way a conductor reads a page: what played, what ended, what is still held for you.+(function () {+ 'use strict'+ const B = window.BossData+ const css = getComputedStyle(document.documentElement)+ const MONO = css.getPropertyValue('--mono') || 'monospace'+ const SERIF = css.getPropertyValue('--serif') || 'serif'+ const C = { ink: '#e8e1d0', muted: '#9a9284', faint: '#5c574e', line: '#3a352e', gold: '#e8b860', amber: '#ffb547', red: '#ff6b5f', fine: '#f4efe2', green: '#9fd8a8' }+ const $ = (id) => document.getElementById(id)+ const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e }+ const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches+ const canvas = $('page')+ const ctx = canvas.getContext('2d')+ const SPANS = [6, 12, 22, 36].map((h) => h * B.HOUR)++ let desk = null+ let W = 0, H = 0, DPR = 1+ let L = 206, R = 0+ let span = SPANS[2], end = 0, follow = true+ let staves = [], groups = []+ let selStaff = 0, selMark = null+ let query = null, typing = false+ let partOpen = false+ let playing = null+ let sound = false, audio = null+ let toastTimer = 0++ // ── who plays what ─────────────────────────────────────────────────────────────────────────────────++ const dispatchesOf = (h) => desk.dispatches.filter((d) => d.harness === h.id).sort((a, b) => a.at - b.at)+ const latest = (h) => dispatchesOf(h).at(-1) ?? null+ function ending(h) {+ const d = latest(h)+ const state = d ? d.state : h.state+ if (state === 'asking') return 'held'+ if (state === 'failed') return 'broke'+ if (state === 'offline') return 'away'+ if (state === 'stopped') return 'stopped'+ if (state === 'working' || state === 'routing') return 'playing'+ if (state === 'done') return d && !d.seenAt ? 'fine' : 'fine-read'+ return h.state === 'working' ? 'playing' : 'quiet'+ }+ const matches = (h) => {+ if (!query) return true+ const hay = `${h.name} ${h.project} ${h.machine} ${dispatchesOf(h).map((d) => `${d.text} ${d.question ?? ''} ${d.summary ?? ''}`).join(' ')}`.toLowerCase()+ return query.toLowerCase().split(/\s+/).filter(Boolean).every((w) => hay.includes(w))+ }++ function layout() {+ const rect = canvas.getBoundingClientRect()+ DPR = Math.min(2, devicePixelRatio || 1)+ W = rect.width; H = rect.height+ canvas.width = Math.round(W * DPR); canvas.height = Math.round(H * DPR)+ L = W < 900 ? 132 : 206+ // An open part takes the right of the page, and the score makes room for it rather than hiding under it.+ R = W - (W < 900 ? 70 : 96) - (partOpen && W >= 1000 ? 456 : 0)+ const machines = [...desk.machines].sort((a, b) => (b.here - a.here) || (b.online - a.online))+ const t0 = desk.now - 36 * B.HOUR+ const plays = (h) => h.boss || h.state === 'working' || h.turns.some((t) => t.at > t0)+ groups = machines.map((m) => {+ const hs = desk.harnesses.filter((h) => h.machine === m.id && plays(h))+ const full = hs.filter((h) => h.boss).sort((a, b) => (dispatchesOf(a)[0]?.at ?? 0) - (dispatchesOf(b)[0]?.at ?? 0))+ const perc = hs.filter((h) => !h.boss).sort((a, b) => a.createdAt - b.createdAt)+ return { m, list: [...full.map((h) => ({ h, kind: 'full' })), ...perc.map((h) => ({ h, kind: 'perc' }))] }+ }).filter((g) => g.list.length)+ const top = 112, bottom = H - 64+ const need = groups.reduce((n, g) => n + g.list.reduce((k, s) => k + (s.kind === 'full' ? 40 : 22), 0) + 16, 0)+ const k = Math.max(0.6, Math.min(1.1, (bottom - top) / need))+ let y = top+ staves = []+ for (const g of groups) {+ g.top = y+ for (const s of g.list) {+ const h = (s.kind === 'full' ? 40 : 22) * k+ staves.push({ ...s, y: y + h / 2, hgt: h, group: g })+ y += h+ }+ g.bottom = y+ y += 16 * k+ }+ selStaff = Math.min(selStaff, staves.length - 1)+ bars = null+ }+ // Bars are as wide as what happened in them, the way an engraver spaces a dense measure wider: a quiet+ // night folds up, a busy hour opens out.+ let bars = null+ function spacing() {+ const from = end - span+ const first = new Date(from); first.setMinutes(0, 0, 0)+ const edges = [from]+ for (let t = first.getTime() + B.HOUR; t < end; t += B.HOUR) edges.push(t)+ edges.push(end)+ const busy = edges.slice(0, -1).map((t, i) => {+ const t1 = edges[i + 1]+ let n = 0+ for (const st of staves) for (const x of st.h.turns) if (x.at >= t && x.at < t1) n+++ n += 10 * desk.dispatches.filter((d) => d.at >= t && d.at < t1).length+ return n / ((t1 - t) / B.HOUR)+ })+ const most = Math.max(1, ...busy)+ const weight = busy.map((n, i) => ((edges[i + 1] - edges[i]) / B.HOUR) * (0.45 + 2.4 * Math.pow(n / most, 0.6)))+ const total = weight.reduce((a, b) => a + b, 0)+ let x = L+ bars = edges.map((t, i) => { const at = { t, x }; x += i < weight.length ? (weight[i] / total) * (R - L) : 0; return at })+ bars.key = `${Math.round(from / 60000)}:${span}:${desk.dispatches.length}`+ }+ function tx(t) {+ if (!bars) return L + ((t - (end - span)) / span) * (R - L)+ if (t <= bars[0].t) return L - ((bars[0].t - t) / span) * (R - L)+ for (let i = 1; i < bars.length; i++) {+ if (t <= bars[i].t) { const a = bars[i - 1], b = bars[i]; return a.x + ((t - a.t) / (b.t - a.t || 1)) * (b.x - a.x) }+ }+ return R + ((t - bars.at(-1).t) / span) * (R - L)+ }++ // ── engraving ──────────────────────────────────────────────────────────────────────────────────────++ function background() {+ ctx.fillStyle = '#0c0b0a'; ctx.fillRect(0, 0, W, H)+ const g = ctx.createRadialGradient(W * 0.55, H * 0.45, 0, W * 0.55, H * 0.45, Math.max(W, H) * 0.8)+ g.addColorStop(0, 'rgba(232,225,208,.025)'); g.addColorStop(1, 'rgba(0,0,0,.35)')+ ctx.fillStyle = g; ctx.fillRect(0, 0, W, H)+ }++ function timeline(now) {+ const from = end - span+ const first = staves[0], last = staves.at(-1)+ if (!first) return+ const yTop = first.group.top, yBot = last.group.bottom+ // Night: 23:00 to 07:00, a cooler wash and a moon.+ for (let d = new Date(from - 24 * B.HOUR); d.getTime() < end; d = new Date(d.getTime() + 24 * B.HOUR)) {+ const n0 = new Date(d); n0.setHours(23, 0, 0, 0)+ const n1 = new Date(n0.getTime() + 8 * B.HOUR)+ const x0 = Math.max(L, tx(n0.getTime())), x1 = Math.min(R, tx(n1.getTime()))+ if (x1 <= x0) continue+ ctx.fillStyle = 'rgba(120,140,200,.045)'; ctx.fillRect(x0, 92, x1 - x0, yBot - 92 + 6)+ ctx.font = `italic 12px ${SERIF}`; ctx.fillStyle = 'rgba(160,175,220,.45)'; ctx.textAlign = 'left'; ctx.textBaseline = 'alphabetic'+ if (x1 - x0 > 60) ctx.fillText('☾ night', x0 + 6, yBot + 16)+ }+ // Bar lines on the hour, through each family; bar numbers are the hours.+ const hour = new Date(from); hour.setMinutes(0, 0, 0)+ const every = span > 24 * B.HOUR ? 3 : span > 12 * B.HOUR ? 2 : 1+ for (let t = hour.getTime() + B.HOUR; t < end; t += B.HOUR) {+ const x = tx(t)+ if (x < L + 2 || x > R) continue+ ctx.strokeStyle = 'rgba(232,225,208,.08)'; ctx.lineWidth = 1+ for (const g of groups) { ctx.beginPath(); ctx.moveTo(x + 0.5, g.top + 2); ctx.lineTo(x + 0.5, g.bottom - 2); ctx.stroke() }+ const h = new Date(t).getHours()+ if (h % every) continue+ ctx.font = h === 0 ? `600 10.5px ${MONO}` : `10.5px ${MONO}`; ctx.fillStyle = h === 0 ? C.ink : C.faint; ctx.textAlign = 'center'; ctx.textBaseline = 'alphabetic'+ ctx.fillText(h === 0 ? new Date(t).toLocaleDateString('en-GB', { weekday: 'short', day: 'numeric' }).toLowerCase() : String(h).padStart(2, '0'), x, 62)+ }+ // Now: the conductor's place.+ const xn = tx(now)+ if (xn <= R + 1) {+ ctx.strokeStyle = 'rgba(232,184,96,.55)'; ctx.lineWidth = 1.5+ ctx.beginPath(); ctx.moveTo(xn, 66); ctx.lineTo(xn, yBot + 4); ctx.stroke()+ ctx.font = `600 10.5px ${MONO}`; ctx.fillStyle = C.gold; ctx.textAlign = 'center'; ctx.fillText(`now ${B.clock(now)}`, xn, 62)+ }+ }++ function marks(now) {+ // Rehearsal marks: one boxed number per task you handed off, its cue dropping to the staff that took it.+ const rows = [[], []]+ const list = desk.dispatches.filter((d) => d.at >= end - span - B.HOUR && d.at <= end).sort((a, b) => a.at - b.at)+ for (const d of list) {+ const x = tx(d.at)+ if (x < L - 10 || x > R + 30) continue+ const label = String(d.n)+ ctx.font = `600 10.5px ${MONO}`+ const w = ctx.measureText(label).width + 9+ let row = rows[0].some((r) => Math.abs(r - x) < w + 3) ? 1 : 0+ if (row === 1 && rows[1].some((r) => Math.abs(r - x) < w + 3)) row = 0+ rows[row].push(x)+ const y = 72 + row * 18+ const s = staves.find((st) => st.h.id === d.harness)+ const isSel = d.id === selMark || (s && staves[selStaff]?.h.id === d.harness)+ const dim = s && !matches(s.h)+ ctx.save(); if (dim) ctx.globalAlpha = 0.25+ if (s) {+ ctx.strokeStyle = isSel ? 'rgba(232,184,96,.75)' : 'rgba(232,184,96,.13)'; ctx.lineWidth = 1; ctx.setLineDash(isSel ? [] : [2, 4])+ ctx.beginPath(); ctx.moveTo(x + 0.5, y + 8); ctx.lineTo(x + 0.5, s.y - s.hgt * 0.3); ctx.stroke(); ctx.setLineDash([])+ }+ ctx.fillStyle = isSel ? C.gold : '#0c0b0a'; ctx.fillRect(x - w / 2, y - 7, w, 15)+ ctx.strokeStyle = d.state === 'undelivered' ? C.red : C.gold; ctx.lineWidth = 1; ctx.strokeRect(x - w / 2 + 0.5, y - 6.5, w - 1, 14)+ ctx.fillStyle = isSel ? '#1a140a' : d.state === 'undelivered' ? C.red : C.gold; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'+ ctx.fillText(label, x, y + 0.5)+ if (d.state === 'undelivered') { ctx.strokeStyle = C.red; ctx.beginPath(); ctx.moveTo(x - w / 2, y + 7); ctx.lineTo(x + w / 2, y - 7); ctx.stroke() }+ ctx.restore()+ }+ }++ function names() {+ for (const g of groups) {+ // The bracket that holds a machine's staves together, and the machine's name beside it.+ const x = L - 12+ ctx.strokeStyle = g.m.online ? 'rgba(232,225,208,.55)' : 'rgba(232,225,208,.2)'; ctx.lineWidth = 3+ ctx.beginPath(); ctx.moveTo(x, g.top + 2); ctx.lineTo(x, g.bottom - 2); ctx.stroke()+ ctx.lineWidth = 1.5+ ctx.beginPath(); ctx.moveTo(x - 1, g.top + 2); ctx.quadraticCurveTo(x + 2, g.top - 4, x + 10, g.top - 5); ctx.stroke()+ ctx.beginPath(); ctx.moveTo(x - 1, g.bottom - 2); ctx.quadraticCurveTo(x + 2, g.bottom + 4, x + 10, g.bottom + 5); ctx.stroke()+ ctx.save(); ctx.translate(14, (g.top + g.bottom) / 2); ctx.rotate(-Math.PI / 2)+ ctx.font = `600 10px ${MONO}`; ctx.fillStyle = g.m.online ? C.muted : C.faint; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'+ ctx.fillText((g.m.online ? g.m.name : `${g.m.name} · asleep`).toUpperCase().split('').join(' '), 0, 0)+ ctx.restore()+ }+ staves.forEach((s, i) => {+ const isSel = i === selStaff+ const right = L - 22+ ctx.save(); if (!matches(s.h)) ctx.globalAlpha = 0.25+ ctx.textAlign = 'right'; ctx.textBaseline = 'alphabetic'+ if (s.kind === 'full') {+ ctx.font = `italic ${isSel ? 14 : 13}px ${SERIF}`; ctx.fillStyle = isSel ? C.gold : C.ink+ ctx.fillText(fit(s.h.name, right - 26), right, s.y + 1)+ ctx.font = `9.5px ${MONO}`; ctx.fillStyle = C.faint+ ctx.fillText(fit(`${B.engine(s.h.engine).short} · ${s.h.project}`, right - 26), right, s.y + 13)+ } else {+ ctx.font = `italic 11.5px ${SERIF}`; ctx.fillStyle = isSel ? C.gold : C.faint+ ctx.fillText(fit(s.h.name, right - 26), right, s.y + 4)+ }+ ctx.restore()+ })+ }++ function staff(s, i, now) {+ const h = s.h+ const isSel = i === selStaff+ const end0 = ending(h)+ const ls = Math.min(5, s.hgt / 8)+ const from = end - span+ const xs = Math.max(L, tx(Math.max(from, h.createdAt)))+ const stopAt = ['held', 'playing'].includes(end0) ? now : h.since+ const xe = Math.min(R, tx(Math.min(end, stopAt)))+ ctx.save()+ if (!matches(h)) ctx.globalAlpha = 0.22+ if (isSel) { ctx.fillStyle = 'rgba(232,184,96,.06)'; ctx.fillRect(L - 4, s.y - s.hgt / 2 + 1, R - L + 90, s.hgt - 2) }+ const lineY = s.kind === 'full' ? [-2, -1, 0, 1, 2].map((k) => s.y + k * ls) : [s.y]+ // The staff lines, where the harness was on the desk; after its end, one faint line: tacet.+ ctx.strokeStyle = isSel ? 'rgba(232,225,208,.42)' : 'rgba(232,225,208,.24)'; ctx.lineWidth = 1+ if (xe > xs) for (const y of lineY) { ctx.beginPath(); ctx.moveTo(xs, y + 0.5); ctx.lineTo(xe, y + 0.5); ctx.stroke() }+ if (end0 !== 'held' && end0 !== 'playing' && xe < tx(now) && xe >= L) {+ ctx.strokeStyle = 'rgba(232,225,208,.07)'; ctx.setLineDash(end0 === 'away' ? [3, 4] : [])+ ctx.beginPath(); ctx.moveTo(xe, s.y + 0.5); ctx.lineTo(Math.min(R, tx(now)), s.y + 0.5); ctx.stroke(); ctx.setLineDash([])+ }+ // The notes.+ notes(s, ls, isSel, now)+ // How it ends.+ const ink = (a) => `rgba(232,225,208,${a})`+ const top = lineY[0], bot = lineY.at(-1)+ if ((end0 === 'fine' || end0 === 'fine-read' || end0 === 'stopped') && xe >= L && xe <= R) {+ const bright = end0 === 'fine'+ ctx.strokeStyle = bright ? C.fine : ink(0.4); ctx.lineWidth = 1+ ctx.beginPath(); ctx.moveTo(xe - 4, top - (s.kind === 'perc' ? 5 : 0)); ctx.lineTo(xe - 4, bot + (s.kind === 'perc' ? 5 : 0)); ctx.stroke()+ ctx.lineWidth = 3; ctx.beginPath(); ctx.moveTo(xe, top - (s.kind === 'perc' ? 5 : 0)); ctx.lineTo(xe, bot + (s.kind === 'perc' ? 5 : 0)); ctx.stroke()+ if (s.kind === 'full') {+ if (bright && !reduced) { ctx.shadowColor = 'rgba(244,239,226,.7)'; ctx.shadowBlur = 10 }+ ctx.font = `italic ${bright ? 600 : 400} 13px ${SERIF}`; ctx.fillStyle = bright ? C.fine : ink(0.4); ctx.textAlign = 'right'; ctx.textBaseline = 'alphabetic'+ ctx.fillText(end0 === 'stopped' ? 'stopped' : 'Fine', xe - 2, top - 5)+ ctx.shadowBlur = 0+ }+ }+ if (end0 === 'held') {+ // The last note, held: a fermata where it stopped, the note sustained to now, and a fermata at now.+ const x0 = Math.max(L, tx(h.since)), xn = Math.min(R, tx(now))+ const pulse = reduced ? 0.7 : 0.55 + 0.35 * Math.sin(now / 520)+ ctx.strokeStyle = `rgba(255,181,71,${0.35 + 0.4 * pulse})`; ctx.lineWidth = 2.2+ ctx.beginPath(); ctx.moveTo(x0, s.y); ctx.lineTo(xn, s.y); ctx.stroke()+ ctx.fillStyle = C.amber; whole(x0, s.y)+ fermata(x0, top - 6, 7, C.amber)+ if (!reduced) { ctx.shadowColor = C.amber; ctx.shadowBlur = 14 * pulse }+ fermata(xn + 2, top - 8, 11, C.amber)+ ctx.shadowBlur = 0+ }+ if (end0 === 'broke' && xe >= L) {+ ctx.strokeStyle = C.red; ctx.lineWidth = 1.6+ ctx.beginPath(); ctx.moveTo(xe, top - 4); for (let k = 0; k <= 6; k++) ctx.lineTo(xe + (k % 2 ? 4 : -2), top - 4 + k * ((bot - top + 8) / 6)); ctx.stroke()+ ctx.font = `italic 12.5px ${SERIF}`; ctx.fillStyle = C.red; ctx.textAlign = 'right'; ctx.fillText('broke off', xe - 4, top - 5)+ }+ // A word at the right edge, where the eye ends: what this staff needs from you now.+ const xr = Math.min(R, tx(now)) + 18+ ctx.textAlign = 'left'; ctx.textBaseline = 'middle'+ const word = { held: [`held ${B.ago(now - h.since)}`, C.amber, 600], fine: ['to read', C.fine, 500], broke: ['broke', C.red, 500], away: ['out of reach', C.faint, 400], playing: ['playing', 'rgba(159,216,168,.6)', 400] }[end0]+ if (word && xr < W - 10) { ctx.font = `${word[2]} 10.5px ${MONO}`; ctx.fillStyle = word[1]; ctx.fillText(word[0], end0 === 'held' ? xr + 6 : xr, s.y) }+ if (isSel && s.kind === 'full') dynamics(s, now)+ ctx.restore()+ }++ function hash(n) { let x = Math.sin(n * 12.9898) * 43758.5453; return x - Math.floor(x) }++ function notes(s, ls, isSel, now) {+ const from = end - span+ const turns = s.h.turns.filter((t) => t.at >= from && t.at <= end)+ const lit = playing ? playing.at : Infinity+ // Clusters: turns close together are one run, beamed.+ const runs = []+ for (const t of turns) {+ const r = runs.at(-1)+ if (r && t.by === 'agent' && r.by === 'agent' && t.at - r.last < 6 * B.MIN) { r.list.push(t); r.last = t.at } else runs.push({ by: t.by, list: [t], last: t.at })+ }+ const full = s.kind === 'full'+ for (const r of runs) {+ const x0 = tx(r.list[0].at), x1 = tx(r.last)+ if (x1 < L - 2 || x0 > R + 2) continue+ const played = r.list[0].at <= lit+ const alpha = played ? 1 : 0.18+ if (r.by === 'you') {+ // You: a gold note with an accent.+ const y = full ? s.y - 2 * ls : s.y+ ctx.fillStyle = `rgba(232,184,96,${alpha})`; ctx.strokeStyle = ctx.fillStyle+ if (full) { head(x0, y, ls); stem(x0, y, ls, true) } else cross(x0, y, 3)+ ctx.lineWidth = 1.2; ctx.beginPath(); ctx.moveTo(x0 - 3, y - ls * 3.6 - 3); ctx.lineTo(x0 + 3, y - ls * 3.6 - 1.5); ctx.lineTo(x0 - 3, y - ls * 3.6); ctx.stroke()+ continue+ }+ const n = r.list.length+ const m = Math.max(1, Math.min(n, Math.floor((x1 - x0) / 5.5) + 1))+ const ink = isSel ? `rgba(244,239,226,${alpha})` : `rgba(232,225,208,${0.78 * alpha})`+ ctx.fillStyle = ink; ctx.strokeStyle = ink+ if (!full) { for (let k = 0; k < m; k++) cross(m === 1 ? x0 : x0 + (k * (x1 - x0)) / (m - 1), s.y, 2.6); continue }+ const pts = []+ for (let k = 0; k < m; k++) {+ const t = r.list[Math.floor((k * n) / m)]+ const x = m === 1 ? x0 : x0 + (k * (x1 - x0)) / (m - 1)+ // Pitch: bigger answers sit higher, with a little melody from the turn's own time.+ const p = Math.max(-4, Math.min(4, Math.round(Math.log(t.size + 1) / Math.log(6000) * 7 - 4 + (hash(t.at % 100000) - 0.5) * 3)))+ const y = s.y - p * ls / 2+ pts.push({ x, y, p })+ head(x, y, ls)+ // Ledger lines beyond the staff.+ if (Math.abs(p) > 4) { ctx.lineWidth = 1; ctx.beginPath(); ctx.moveTo(x - 5, y); ctx.lineTo(x + 5, y); ctx.stroke() }+ }+ const up = pts.reduce((a, b) => a + b.p, 0) / pts.length < 0+ const len = ls * 3.4+ ctx.lineWidth = 1+ for (const q of pts) { const sx = up ? q.x + ls * 0.62 : q.x - ls * 0.62; ctx.beginPath(); ctx.moveTo(sx, q.y); ctx.lineTo(sx, up ? q.y - len : q.y + len); ctx.stroke() }+ if (pts.length > 1) {+ // Beams: one for a run, two when it played fast.+ const a = pts[0], b = pts.at(-1)+ const ya = up ? Math.min(...pts.map((q) => q.y)) - len : Math.max(...pts.map((q) => q.y)) + len+ const off = up ? ls * 0.62 : -ls * 0.62+ const beams = n / m > 2 || n > 6 ? 2 : 1+ for (let k = 0; k < beams; k++) {+ const yy = ya + (up ? k * 3.5 : -k * 3.5)+ ctx.fillRect(a.x + off - 0.5, yy - (up ? 0 : 2), b.x - a.x + 1, 2)+ }+ for (const q of pts) { const sx = q.x + off; ctx.beginPath(); ctx.moveTo(sx, q.y); ctx.lineTo(sx, ya); ctx.stroke() }+ } else if (n === 1) {+ // A lone turn: a flag.+ const q = pts[0], sx = up ? q.x + ls * 0.62 : q.x - ls * 0.62, ty = up ? q.y - len : q.y + len+ ctx.beginPath(); ctx.moveTo(sx, ty); ctx.quadraticCurveTo(sx + 5, ty + (up ? 4 : -4), sx + 4, ty + (up ? 9 : -9)); ctx.stroke()+ }+ }+ // Long silences get a rest.+ if (full) {+ let prev = Math.max(from, s.h.createdAt)+ const stop = ['held', 'playing'].includes(ending(s.h)) ? now : s.h.since+ for (const t of [...turns, { at: Math.min(stop, end) }]) {+ if (t.at - prev > 2.5 * B.HOUR) { const x = tx((prev + t.at) / 2); if (x > L + 10 && x < R - 10) rest(x, s.y, ls) }+ prev = Math.max(prev, t.at)+ }+ }+ }++ function head(x, y, ls) { ctx.beginPath(); ctx.ellipse(x, y, ls * 0.66, ls * 0.46, -0.35, 0, Math.PI * 2); ctx.fill() }+ function whole(x, y) { ctx.save(); ctx.lineWidth = 1.6; ctx.strokeStyle = ctx.fillStyle; ctx.beginPath(); ctx.ellipse(x, y, 5, 3.4, 0, 0, Math.PI * 2); ctx.stroke(); ctx.restore() }+ function stem(x, y, ls, up) { ctx.lineWidth = 1; ctx.beginPath(); ctx.moveTo(x + ls * 0.62, y); ctx.lineTo(x + ls * 0.62, up ? y - ls * 3.4 : y + ls * 3.4); ctx.stroke() }+ function cross(x, y, r) { ctx.lineWidth = 1.2; ctx.beginPath(); ctx.moveTo(x - r, y - r); ctx.lineTo(x + r, y + r); ctx.moveTo(x + r, y - r); ctx.lineTo(x - r, y + r); ctx.stroke() }+ function fermata(x, y, r, color) {+ ctx.save(); ctx.strokeStyle = color; ctx.fillStyle = color; ctx.lineWidth = r > 8 ? 2.2 : 1.6+ ctx.beginPath(); ctx.arc(x, y, r, Math.PI, 0); ctx.stroke()+ ctx.beginPath(); ctx.arc(x, y - 1, r > 8 ? 2.2 : 1.6, 0, Math.PI * 2); ctx.fill()+ ctx.restore()+ }+ function rest(x, y, ls) {+ ctx.save(); ctx.strokeStyle = 'rgba(232,225,208,.45)'; ctx.lineWidth = 1.6+ ctx.beginPath(); ctx.moveTo(x - 1.5, y - ls * 1.8); ctx.lineTo(x + 2, y - ls * 0.8); ctx.lineTo(x - 2, y + ls * 0.1); ctx.lineTo(x + 2, y + ls * 0.9); ctx.quadraticCurveTo(x - 3, y + ls * 0.6, x, y + ls * 1.8); ctx.stroke()+ ctx.restore()+ }+ function dynamics(s, now) {+ // Under the chosen staff: how loud it played, hour by hour.+ const from = end - span+ const step = Math.max(B.HOUR, span / 8)+ let last = null+ for (let t = from; t < Math.min(end, now); t += step) {+ const n = s.h.turns.filter((x) => x.at >= t && x.at < t + step && x.by === 'agent').length+ const mark = n === 0 ? null : n < 4 ? 'pp' : n < 9 ? 'p' : n < 16 ? 'mp' : n < 26 ? 'mf' : n < 40 ? 'f' : 'ff'+ if (!mark || mark === last) { last = mark ?? last; continue }+ last = mark+ ctx.font = `italic 700 12px ${SERIF}`; ctx.fillStyle = 'rgba(232,184,96,.75)'; ctx.textAlign = 'left'; ctx.textBaseline = 'alphabetic'+ const x = tx(t + step / 2)+ if (x > L && x < R - 10) ctx.fillText(mark, x, s.y + s.hgt / 2 - 1)+ }+ }+ function fit(text, width) { if (ctx.measureText(text).width <= width) return text; let t = text; while (t.length > 1 && ctx.measureText(t + '…').width > width) t = t.slice(0, -1); return t + '…' }++ function frame() {+ const now = Date.now()+ desk.now = now+ if (follow) end = now + span * 0.0+ if (playing) {+ const k = (now - playing.started) / playing.ms+ playing.at = end - span + k * span+ if (sound) chime(playing)+ if (k >= 1) playing = null+ }+ if (!bars || bars.key !== `${Math.round((end - span) / 60000)}:${span}:${desk.dispatches.length}` || now - (bars.made ?? 0) > 30000) { spacing(); bars.made = now }+ ctx.setTransform(DPR, 0, 0, DPR, 0, 0)+ background()+ timeline(now)+ names()+ staves.forEach((s, i) => staff(s, i, now))+ marks(now)+ if (playing) { const x = tx(playing.at); ctx.strokeStyle = 'rgba(232,184,96,.8)'; ctx.lineWidth = 2; ctx.beginPath(); ctx.moveTo(x, 66); ctx.lineTo(x, staves.at(-1).group.bottom); ctx.stroke() }+ requestAnimationFrame(frame)+ }++ // ── sound, off unless asked for: each note as the playhead passes it ─────────────────────────────────++ const SCALE = [0, 2, 4, 7, 9]+ function chime(p) {+ audio ??= new AudioContext()+ const before = p.heard ?? p.at+ p.heard = p.at+ let budget = 6+ staves.forEach((s, i) => {+ for (const t of s.h.turns) {+ if (t.at <= before || t.at > p.at || budget <= 0) continue+ budget--+ const o = audio.createOscillator(), g = audio.createGain()+ const deg = SCALE[(i + Math.floor(t.size / 900)) % SCALE.length] + 12 * (i % 3)+ o.frequency.value = (t.by === 'you' ? 330 : 196) * Math.pow(2, deg / 12)+ o.type = t.by === 'you' ? 'triangle' : 'sine'+ g.gain.setValueAtTime(0.0001, audio.currentTime)+ g.gain.exponentialRampToValueAtTime(t.by === 'you' ? 0.06 : 0.03, audio.currentTime + 0.01)+ g.gain.exponentialRampToValueAtTime(0.0001, audio.currentTime + 0.6)+ o.connect(g).connect(audio.destination); o.start(); o.stop(audio.currentTime + 0.65)+ }+ })+ }++ // ── the glance, the cue line, the part ─────────────────────────────────────────────────────────────++ function glance() {+ const ends = staves.filter((s) => s.kind === 'full').map((s) => ending(s.h))+ const n = (k) => ends.filter((e) => e === k).length+ const box = $('glance'); box.replaceChildren()+ const part = (text, cls) => box.append(cls ? el('b', cls, text) : text)+ part(`${n('held')} held for you`, n('held') ? 'held' : ''); part(' · ')+ part(`${n('fine')} finished, unread`, n('fine') ? 'fine' : ''); part(' · ')+ part(`${n('broke')} broke off`, n('broke') ? 'broke' : ''); part(' · ')+ part(`${n('playing')} playing`)+ $('clock').textContent = `${desk.real ? 'your desk' : 'an invented desk'} · ${Math.round(span / B.HOUR)}h on the page`+ }+ function cue() {+ const s = staves[selStaff]+ const box = $('cue'); box.replaceChildren()+ if (!s) return+ const d = desk.dispatches.find((x) => x.id === selMark) ?? latest(s.h)+ if (!d) { box.append(el('span', 'who', `${s.h.name} · ${B.engine(s.h.engine).short} · ${s.h.project} on ${s.h.machine} · started by hand, never sent a task by ⌘B`)); return }+ const words = d.state === 'asking' ? `held: ${d.question}` : d.state === 'done' ? `fine: ${d.summary}` : d.error ?? 'playing'+ box.append(el('b', null, String(d.n)), `“${d.text}”`, el('span', 'who', `→ ${s.h.name} · ${words}`))+ }++ function part() {+ const s = staves[selStaff]+ const box = $('part')+ box.replaceChildren()+ if (!s || !partOpen) { box.classList.remove('on'); return }+ const h = s.h+ const e = ending(h)+ box.style.setProperty('--edge', { held: '#ffb547', fine: '#f4efe2', broke: '#ff6b5f' }[e] ?? '#5c574e')+ box.append(el('h1', null, h.name), el('div', 'sub', `${B.engine(h.engine).name} · ${h.project} on ${h.machine}`))+ const d = latest(h)+ const now = el('div', 'now')+ const k = { held: `held for you · ${B.ago(desk.now - h.since)}`, fine: 'fine · unread', 'fine-read': 'fine · read', broke: 'broke off', away: 'out of reach', playing: 'playing', stopped: 'stopped', quiet: 'quiet' }[e]+ now.append(el('span', 'k', k), (d?.question ?? d?.summary ?? d?.error ?? h.summary ?? 'Nothing said yet.'))+ box.append(now)+ const list = dispatchesOf(h)+ if (list.length) {+ box.append(el('h2', null, 'cues you gave it'))+ for (const x of list) {+ const m = el('div', 'mark')+ const body = el('div')+ const dec = x.decision+ body.append(el('div', 'said', `“${x.text}”`), el('div', 'how', `${B.clock(x.at)}${x.via === 'voice' ? ' · by voice' : ''} · ${dec.kind === 'session' ? `⌘B: same work, Jev ${dec.p?.toFixed(2) ?? '—'}${dec.runnerUp ? `, next best “${dec.runnerUp.name}” ${dec.runnerUp.p.toFixed(2)}` : ''}` : dec.kind === 'new' ? `⌘B: new work, Jev ${dec.p?.toFixed(2) ?? '—'}` : dec.kind === 'direct' ? 'typed into the pane' : dec.kind}`))+ m.append(el('div', 'box', String(x.n)), body)+ box.append(m)+ }+ } else box.append(el('h2', null, 'started by hand: no cues from ⌘B'))+ box.append(el('h2', null, 'the part'))+ const st = el('div', 'stats')+ const row = (a, b) => st.append(el('b', null, a), el('span', null, b))+ const mine = h.turns.filter((t) => t.at > desk.now - span)+ row('turns', `${mine.filter((t) => t.by === 'agent').length} by it · ${mine.filter((t) => t.by === 'you').length} by you, in ${Math.round(span / B.HOUR)}h`)+ row('tokens', h.tokens >= 1e6 ? `${(h.tokens / 1e6).toFixed(1)}M` : `${Math.round(h.tokens / 1000)}k`)+ row('on the desk', `since ${B.clock(h.createdAt)} (${B.ago(desk.now - h.createdAt)})`)+ row('last turn', h.lastTurnAt ? `${B.ago(desk.now - h.lastTurnAt)} ago` : '—')+ box.append(st)+ const keys = el('div', 'keys')+ const kk = e === 'fine' ? [['r', 'mark it read'], ['esc', 'back to the score']] : e === 'held' ? [['→', 'answer in the chat'], ['esc', 'back']] : [['esc', 'back']]+ kk.forEach(([a, b], i) => { if (i) keys.append(' · '); keys.append(el('kbd', null, a), ` ${b}`) })+ box.append(keys)+ box.classList.add('on')+ }+ function refresh() { glance(); cue(); part() }++ // ── keys ───────────────────────────────────────────────────────────────────────────────────────────++ function pickStaff(i) { selStaff = Math.max(0, Math.min(staves.length - 1, i)); selMark = null; refresh() }+ function nextWhere(pred, dir = 1) {+ for (let k = 1; k <= staves.length; k++) {+ const i = (selStaff + dir * k + staves.length * 2) % staves.length+ if (pred(staves[i]) && matches(staves[i].h)) return pickStaff(i)+ }+ toast('none')+ }+ function stepMark(dir) {+ const list = desk.dispatches.filter((d) => d.harness).sort((a, b) => a.at - b.at)+ const cur = list.findIndex((d) => d.id === (selMark ?? latest(staves[selStaff]?.h ?? {})?.id))+ const d = list[Math.max(0, Math.min(list.length - 1, cur + dir))]+ if (!d) return+ const i = staves.findIndex((s) => s.h.id === d.harness)+ if (i >= 0) selStaff = i+ selMark = d.id+ if (tx(d.at) < L || tx(d.at) > R) { follow = false; end = Math.min(desk.now, d.at + span / 2) }+ refresh()+ }+ function markRead() {+ const s = staves[selStaff]+ const d = s && dispatchesOf(s.h).filter((x) => x.state === 'done' && !x.seenAt).at(-1)+ if (!d) return toast('nothing unread here')+ B.markSeen(d.id); toast(`#${d.n} read`); refresh()+ }+ function toast(text) { const t = $('toast'); t.textContent = text; t.classList.add('on'); clearTimeout(toastTimer); toastTimer = setTimeout(() => t.classList.remove('on'), 2200) }++ addEventListener('keydown', (e) => {+ if (e.metaKey || e.ctrlKey || e.altKey) return+ if (typing) {+ if (e.key === 'Escape') { query = null; typing = false }+ else if (e.key === 'Enter') typing = false+ else if (e.key === 'Backspace') query = query.slice(0, -1)+ else if (e.key.length === 1) query += e.key+ else return+ e.preventDefault(); $('find').classList.toggle('on', query !== null); $('q').textContent = query ?? ''; return+ }+ switch (e.key) {+ case 'j': case 'ArrowDown': pickStaff(selStaff + 1); break+ case 'k': case 'ArrowUp': pickStaff(selStaff - 1); break+ case 'g': pickStaff(0); break+ case 'G': pickStaff(staves.length - 1); break+ case 'n': nextWhere((s) => ending(s.h) === 'held'); break+ case 'N': nextWhere((s) => ending(s.h) === 'held', -1); break+ case 'f': nextWhere((s) => ending(s.h) === 'fine'); break+ case 'x': nextWhere((s) => ending(s.h) === 'broke'); break+ case ']': stepMark(1); break+ case '[': stepMark(-1); break+ case 'h': case 'ArrowLeft': follow = false; end = Math.max(desk.now - 48 * B.HOUR, end - span / 4); break+ case 'l': case 'ArrowRight': end = Math.min(desk.now, end + span / 4); follow = end >= desk.now; break+ case '$': follow = true; break+ case '0': follow = false; end = Math.min(desk.now, Math.min(...desk.dispatches.map((d) => d.at)) + span - B.HOUR); break+ case '+': case '=': span = SPANS[Math.max(0, SPANS.indexOf(span) - 1)]; glance(); break+ case '-': span = SPANS[Math.min(SPANS.length - 1, SPANS.indexOf(span) + 1)]; glance(); break+ case ' ': playing = { started: Date.now(), ms: reduced ? 1 : 12000, at: end - span }; if (sound) audio?.resume(); break+ case 'm': sound = !sound; if (sound) { audio ??= new AudioContext(); audio.resume() } toast(sound ? 'sound on: press space to hear the night' : 'sound off'); break+ case 'Enter': partOpen = !partOpen; layout(); part(); break+ case 'r': markRead(); break+ case '/': query = ''; typing = true; $('find').classList.add('on'); $('q').textContent = ''; break+ case 'Escape': if (partOpen) { partOpen = false; layout(); part() } else if (query) { query = null; $('find').classList.remove('on') } else { selMark = null; cue() } break+ default: return+ }+ e.preventDefault()+ })+ canvas.addEventListener('click', (e) => {+ const r = canvas.getBoundingClientRect(), y = e.clientY - r.top+ const i = staves.findIndex((s) => Math.abs(s.y - y) < s.hgt / 2)+ if (i >= 0) pickStaff(i)+ })++ function keysLine() {+ const parts = [['j k', 'staves'], ['n', 'next held'], ['f', 'next unread'], ['[ ]', 'cues'], ['h l', 'time'], ['+ −', 'zoom'], ['⏎', 'the part'], ['r', 'read'], ['space', 'play the night'], ['m', 'sound'], ['/', 'find']]+ parts.forEach(([k, w], i) => { if (i) $('keys').append(' · '); $('keys').append(el('kbd', null, k), ` ${w}`) })+ }++ B.load().then((d) => {+ desk = d+ end = desk.now+ $('loading').remove()+ layout()+ keysLine()+ const held = staves.findIndex((s) => ending(s.h) === 'held')+ selStaff = held >= 0 ? held : 0+ refresh()+ B.subscribe((_, event) => {+ if (['dispatch', 'landed', 'done', 'asking', 'refresh', 'seen', 'unseen'].includes(event.type)) {+ const id = staves[selStaff]?.h.id+ layout()+ const i = staves.findIndex((s) => s.h.id === id); if (i >= 0) selStaff = i+ refresh()+ }+ })+ addEventListener('resize', () => { layout(); refresh() })+ requestAnimationFrame(frame)+ }).catch((error) => { $('loading').textContent = `could not read the desk: ${error.message}` })+})()diff --git a/docs/research/2026-10-11-boss-mode/serve.mjs b/docs/research/2026-10-11-boss-mode/serve.mjsnew file mode 100644index 000000000..370a5fbc2--- /dev/null+++ b/docs/research/2026-10-11-boss-mode/serve.mjs@@ -0,0 +1,170 @@+#!/usr/bin/env node+/**+ * Serves the Boss Mode prototypes on this computer, and, for pages opened with ?real, this computer's own+ * desk: read on each request, only on loopback, and never written anywhere. It only reads.+ *+ * node docs/research/2026-10-11-boss-mode/serve.mjs [port]+ * open http://127.0.0.1:<port>/ an invented desk+ * open http://127.0.0.1:<port>/?real yours+ *+ * Where your desk comes from (README.md has the whole story):+ * - every harness on every reachable machine, and whether it is working, needs you, finished unread or+ * failed: the daemon's local bridge, read the way Harness Monitor reads it (`agents_list`, via+ * store/agents/harness-monitor/lib/inventory.mjs). Nothing is sent to any harness.+ * - what you said to each, and when: the session index (`session-search.db`, opened read-only).+ * - which of those you said to ⌘B: the box's recent prompts (`task_box_recent_v1` in the desktop's+ * state file; only that key is read, the rest of the file is never kept) matched to the message that+ * landed in a harness. ⌘B keeps no record of where a task went, so this is the best there is.+ * - how sure ⌘B was: the router's `[route]` lines in the daemon log, when they are still there.+ * - what a harness last said: the turn summaries the daemon keeps (`summaries.json`).+ */+import { createServer } from 'node:http'+import { open, readFile, stat } from 'node:fs/promises'+import { homedir } from 'node:os'+import { dirname, extname, join, normalize, sep } from 'node:path'+import { fileURLToPath } from 'node:url'++const here = dirname(fileURLToPath(import.meta.url))+const store = (path) => import(new URL(`../../../store/agents/${path}`, import.meta.url).href)+const { collect } = await store('harness-monitor/lib/inventory.mjs')+const { openIndex } = await store('memories/lib/sessions.mjs')++const HOUR = 3_600_000+const WINDOW = 36 * HOUR+const home = homedir()+const data = process.env.ADAPTER_DATA_DIR || join(home, '.harness', 'cli', 'data')+const desktopState = join(home, '.harness', 'desktop-app-v2', 'state.json')++const TYPES = { '.html': 'text/html; charset=utf-8', '.js': 'text/javascript; charset=utf-8', '.css': 'text/css; charset=utf-8', '.json': 'application/json', '.png': 'image/png', '.jpg': 'image/jpeg', '.svg': 'image/svg+xml', '.md': 'text/plain; charset=utf-8' }+const json = (res, status, body) => { res.writeHead(status, { 'content-type': 'application/json', 'cache-control': 'no-store' }); res.end(JSON.stringify(body)) }+const clip = (text, n) => { const t = String(text ?? '').replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t }++/** ⌘B's recent prompts, newest first: that one key of the desktop's state file, nothing else. */+async function boxPrompts() {+ try {+ const raw = JSON.parse(await readFile(desktopState, 'utf8'))+ const value = raw?.values?.task_box_recent_v1+ const parsed = typeof value === 'string' ? JSON.parse(value) : null+ return Array.isArray(parsed?.prompts) ? parsed.prompts.filter((p) => typeof p === 'string').slice(0, 20) : []+ } catch { return [] }+}++/** The router's decisions still in the daemon log: when, what kind, Jev's pick and runner-up. */+async function routeLines() {+ const path = join(data, 'harness.log')+ try {+ const info = await stat(path)+ const length = Math.min(info.size, 6 * 1024 * 1024)+ const handle = await open(path, 'r')+ const buffer = Buffer.alloc(length)+ await handle.read(buffer, 0, length, info.size - length)+ await handle.close()+ const out = []+ for (const line of buffer.toString('utf8').split('\n')) {+ if (!line.includes('[route]')) continue+ const at = Date.parse(line.slice(0, 40).match(/\d{4}-\d\d-\d\dT[\d:.]+Z?/)?.[0] ?? '')+ if (!Number.isFinite(at)) continue+ const kind = /\[route\]\s+session/.test(line) ? 'session' : /\[route\]\s+new/.test(line) ? 'new' : /nothing decided/.test(line) ? 'none' : null+ if (!kind) continue+ const pick = /"([^"]{1,300})"\s+([\d.]+)(?:,\s*then\s+"([^"]{1,300})"\s+([\d.]+))?/.exec(line)+ out.push({ at, kind, name: pick?.[1] ?? null, p: pick ? Number(pick[2]) : null, runnerUp: pick?.[3] ? { name: pick[3], p: Number(pick[4]) } : null })+ }+ return out+ } catch { return [] }+}++async function summaries() {+ try { return JSON.parse(await readFile(join(data, 'summaries.json'), 'utf8')) ?? {} } catch { return {} }+}++const remote = { at: 0, answers: new Map() }+let cache = null++async function desk() {+ if (cache && Date.now() - cache.at < 3500) return cache.desk+ const now = Date.now()+ const notes = []+ const inventory = await collect({ now, includeRemote: true, remote, timeoutMs: 8000 })+ for (const problem of inventory.problems) notes.push(`${problem.machine}: ${problem.error}`)+ const index = await openIndex(data)+ if (index.error) notes.push(index.error)+ const [prompts, routes, recaps] = await Promise.all([boxPrompts(), routeLines(), summaries()])++ const rows = inventory.rows.filter((row) => row.engine !== 'terminal' && (row.live || (row.lastActivity ?? 0) > now - WINDOW))+ const STATE = { working: 'working', starting: 'working', needsInput: 'asking', done: 'done', failed: 'failed', idle: 'done', stopped: 'stopped', offline: 'offline', unknown: 'done' }+ const turnsOf = index.db?.prepare('SELECT at, ask != \'\' AS you, length(answer) AS size FROM turns WHERE session_id = ? AND at >= ? ORDER BY at')+ const lastAsk = index.db?.prepare('SELECT at, ask, answer FROM turns WHERE session_id = ? AND ask != \'\' ORDER BY at DESC LIMIT 1')+ const lastAnswer = index.db?.prepare('SELECT answer FROM turns WHERE session_id = ? AND answer != \'\' ORDER BY at DESC LIMIT 1')+ const findAsk = index.db?.prepare('SELECT at, session_id FROM turns WHERE trim(ask) = ? AND at >= ? ORDER BY at DESC LIMIT 1')++ // Which harness each ⌘B prompt landed in: the newest message with exactly those words.+ const boxed = new Map()+ for (const text of prompts) {+ const hit = findAsk?.get(text.trim(), now - 7 * 24 * HOUR)+ if (hit) boxed.set(`${hit.session_id}\n${hit.at}`, text)+ }+ if (prompts.length && boxed.size < prompts.length) notes.push(`${prompts.length - boxed.size} of ⌘B's ${prompts.length} recent prompts are in no harness this computer indexes.`)++ const harnesses = []+ const dispatches = []+ for (const row of rows) {+ const state = STATE[row.activity] ?? 'done'+ // A harness whose finished turn you have opened since is quiet, not waiting to be read.+ const quiet = row.activity === 'idle' || row.activity === 'unknown'+ const recap = row.sessionId ? recaps[row.sessionId] : null+ const [head, ...body] = typeof recap === 'string' ? recap.split('\n\n') : []+ const said = clip(body.join(' ') || head || (row.sessionId ? lastAnswer?.get(row.sessionId)?.answer : '') || '', 320)+ const turns = row.sessionId && turnsOf ? turnsOf.all(row.sessionId, now - WINDOW).map((t) => ({ at: t.at, by: t.you ? 'you' : 'agent', size: t.size ?? 0 })) : []+ const h = {+ id: row.id, machine: row.machineId, engine: row.engine, name: clip(row.name, 80), project: clip(row.project, 60), state: quiet ? 'idle' : state,+ since: row.stateSince ?? row.lastActivity ?? now, createdAt: row.createdAt ?? now, lastTurnAt: row.lastActivity ?? null,+ tokens: row.tokens ?? 0, question: state === 'asking' ? said : null, summary: state !== 'asking' ? said : null, turns, boss: false,+ }+ harnesses.push(h)+ const ask = row.sessionId ? lastAsk?.get(row.sessionId) : null+ if (!ask || ask.at < now - WINDOW) continue+ const viaBox = boxed.get(`${row.sessionId}\n${ask.at}`)+ const route = viaBox ? routes.filter((r) => r.at <= ask.at + 2000 && r.at >= ask.at - 30_000).sort((a, b) => b.at - a.at)[0] : null+ h.boss = true+ dispatches.push({+ id: `r${dispatches.length + 1}`, n: 0, at: ask.at, text: clip(viaBox ?? ask.ask, 400), via: viaBox ? 'box' : 'pane',+ decision: viaBox+ ? { kind: route?.kind ?? 'session', p: route?.p ?? null, runnerUp: route?.runnerUp ?? null, why: route ? '' : 'the log no longer has this decision', ms: 0, cost: 0 }+ : { kind: 'direct', p: null, runnerUp: null, why: 'typed into the harness, not through ⌘B', ms: 0, cost: 0 },+ harness: h.id, machine: h.machine, created: false, landedAt: ask.at, state, since: state === 'working' ? ask.at : h.since,+ seenAt: quiet ? (row.lastActivity ?? now) : null,+ question: h.question, summary: state === 'failed' ? null : h.summary, error: state === 'failed' ? said : null, pr: /PR #(\d+)/.exec(said)?.[1] ?? null,+ history: [{ at: ask.at, state: 'working' }, ...(state !== 'working' ? [{ at: h.since, state }] : [])],+ })+ }+ dispatches.sort((a, b) => a.at - b.at).forEach((d, i) => { d.n = i + 1 })+ const machines = inventory.machines.map((m) => ({ id: m.machineId, name: clip(m.name, 40), here: m.current, online: m.online, since: null, os: '' }))+ .filter((m) => m.online || harnesses.some((h) => h.machine === m.id))+ if (!prompts.length) notes.push('⌘B has no recent prompts on this computer; every task shown was typed into its harness.')+ const result = { now, real: true, source: 'your desk', notes, machines, harnesses, dispatches }+ cache = { at: Date.now(), desk: result }+ return result+}++const server = createServer(async (req, res) => {+ try {+ const { port } = server.address()+ if (![`127.0.0.1:${port}`, `localhost:${port}`].includes(req.headers.host)) { json(res, 403, { error: 'Loopback only.' }); return }+ const site = req.headers['sec-fetch-site']+ if (site && site !== 'same-origin' && site !== 'none') { json(res, 403, { error: 'Only these pages may ask.' }); return }+ const url = new URL(req.url, `http://${req.headers.host}`)+ if (url.pathname === '/real/desk') { json(res, 200, await desk()); return }+ const path = normalize(join(here, url.pathname === '/' ? 'index.html' : decodeURIComponent(url.pathname)))+ if (!path.startsWith(here + sep) || !TYPES[extname(path)] || path.endsWith('.mjs')) { json(res, 404, { error: 'Not found.' }); return }+ const body = await readFile(path).catch(() => null)+ if (!body) { json(res, 404, { error: 'Not found.' }); return }+ res.writeHead(200, { 'content-type': TYPES[extname(path)], 'cache-control': 'no-store' })+ res.end(body)+ } catch (error) {+ json(res, 500, { error: String(error?.message ?? error) })+ }+})++server.listen(Number(process.argv[2] ?? 0), '127.0.0.1', () => {+ console.log(`Boss Mode prototypes: http://127.0.0.1:${server.address().port}/ (your desk: add ?real)`)+})diff --git a/docs/research/2026-10-11-boss-mode/shoot.mjs b/docs/research/2026-10-11-boss-mode/shoot.mjsnew file mode 100644index 000000000..24068e9e6--- /dev/null+++ b/docs/research/2026-10-11-boss-mode/shoot.mjs@@ -0,0 +1,68 @@+#!/usr/bin/env node+/**+ * Opens every prototype on the invented desk in headless Chromium, drives it by keys, fails on any console+ * error or any request that leaves this computer, and writes the screenshots in this folder. Never ?real:+ * committed screenshots show the invented desk only.+ *+ * PLAYWRIGHT=/path/to/playwright/index.mjs node docs/research/2026-10-11-boss-mode/shoot.mjs [only] [--out dir]+ */+import { spawn } from 'node:child_process'+import { dirname, join } from 'node:path'+import { fileURLToPath, pathToFileURL } from 'node:url'++const here = dirname(fileURLToPath(import.meta.url))+const args = process.argv.slice(2)+const outAt = args.indexOf('--out')+const out = outAt >= 0 ? args[outAt + 1] : here+const only = args.filter((a, i) => !a.startsWith('--') && (outAt < 0 || i !== outAt + 1))[0] ?? null+const playwright = process.env.PLAYWRIGHT ?? 'playwright'+const { chromium } = await import(playwright.startsWith('/') ? pathToFileURL(playwright).href : playwright)++const server = spawn(process.execPath, [join(here, 'serve.mjs'), '0'], { stdio: ['ignore', 'pipe', 'inherit'] })+const base = await new Promise((resolve, reject) => {+ server.stdout.on('data', (chunk) => { const m = /http:\/\/127\.0\.0\.1:(\d+)\//.exec(String(chunk)); if (m) resolve(m[0]) })+ server.on('exit', (code) => reject(new Error(`serve.mjs exited ${code}`)))+})++// [page, shot name, viewport, query, steps]: a step is a key, ['wait', ms], or ['eval', js]+const SHOTS = [+ ['approach', 'approach', [1300, 1100], 'still', [['wait', 9000]]],+ ['approach', 'approach-final', [1300, 1100], 'still', [['wait', 4500], 'f', 'f', ['wait', 4500]]],+ ['approach', 'approach-narrow', [760, 980], 'still', [['wait', 5000]]],+ ['pass', 'pass', [1300, 1100], 'still', [['wait', 2500]]],+ ['pass', 'pass-ticket', [1300, 1100], 'still', [['wait', 1500], 'k', 'Enter', ['wait', 900]]],+ ['pass', 'pass-narrow', [760, 980], 'still', [['wait', 2000]]],+ ['switchboard', 'switchboard', [1300, 1100], 'still', [['wait', 3500]]],+ ['switchboard', 'switchboard-listen', [1300, 1100], 'still', [['wait', 2500], 'Enter', ['wait', 1200]]],+ ['switchboard', 'switchboard-narrow', [760, 980], 'still', [['wait', 3000]]],+ ['score', 'score', [1300, 1100], 'still', [['wait', 2500]]],+ ['score', 'score-part', [1300, 1100], 'still', [['wait', 1500], 'n', 'Enter', ['wait', 900]]],+ ['score', 'score-narrow', [760, 980], 'still', [['wait', 2000]]],+ ['index', 'index', [1300, 1000], '', [['wait', 800]]],+]++const browser = await chromium.launch()+const failures = []+for (const [page, name, [width, height], query, steps] of SHOTS) {+ if (only && page !== only) continue+ const context = await browser.newContext({ viewport: { width, height }, deviceScaleFactor: 1, colorScheme: 'dark' })+ const tab = await context.newPage()+ const errors = []+ tab.on('console', (m) => { if (m.type() === 'error') errors.push(m.text()) })+ tab.on('pageerror', (e) => errors.push(String(e)))+ tab.on('request', (r) => { if (!r.url().startsWith(base) && !r.url().startsWith('data:')) errors.push(`left this computer: ${r.url()}`) })+ await tab.goto(`${base}${page === 'index' ? '' : `${page}.html`}${query ? `?${query}` : ''}`)+ for (const step of steps) {+ if (Array.isArray(step) && step[0] === 'wait') await tab.waitForTimeout(step[1])+ else if (Array.isArray(step) && step[0] === 'eval') await tab.evaluate(step[1])+ else await tab.keyboard.press(step)+ }+ const file = join(out, `${name}.jpg`)+ await tab.screenshot({ path: file, type: 'jpeg', quality: 86 })+ console.log(`${errors.length ? 'FAIL' : 'ok '} ${name} → ${file}${errors.length ? `\n ${errors.join('\n ')}` : ''}`)+ if (errors.length) failures.push(name)+ await context.close()+}+await browser.close()+server.kill()+process.exit(failures.length ? 1 : 0)diff --git a/docs/research/2026-10-11-boss-mode/switchboard-listen.jpg b/docs/research/2026-10-11-boss-mode/switchboard-listen.jpgnew file mode 100644index 000000000..af87737abBinary files /dev/null and b/docs/research/2026-10-11-boss-mode/switchboard-listen.jpg differdiff --git a/docs/research/2026-10-11-boss-mode/switchboard-narrow.jpg b/docs/research/2026-10-11-boss-mode/switchboard-narrow.jpgnew file mode 100644index 000000000..1514e85c4Binary files /dev/null and b/docs/research/2026-10-11-boss-mode/switchboard-narrow.jpg differdiff --git a/docs/research/2026-10-11-boss-mode/switchboard.html b/docs/research/2026-10-11-boss-mode/switchboard.htmlnew file mode 100644index 000000000..98fd0f2d5--- /dev/null+++ b/docs/research/2026-10-11-boss-mode/switchboard.html@@ -0,0 +1,79 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width,initial-scale=1">+<title>Switchboard</title>+<style>+ :root {+ --bg: #0d0907; --text: #efe6d4; --muted: #9b8e7a; --faint: #5e5446; --line: #2a2018;+ --brass: #c9a46a; --amber: #ffb547; --green: #7ee08f; --white: #fff6e3; --red: #ff5a4f;+ --paper: #e9e0cb; --ink: #241c14;+ --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;+ color-scheme: dark;+ }+ * { box-sizing: border-box; }+ html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 12px/1.45 var(--mono); }+ #board { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }+ #top { position: fixed; left: 18px; right: 18px; top: 12px; display: flex; align-items: baseline; gap: 18px; white-space: nowrap; overflow: hidden; pointer-events: none; }+ #top .brand { color: var(--brass); letter-spacing: .36em; font-size: 12px; font-weight: 600; }+ #top .lamps { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }+ #top .lamps b { font-weight: 600; }+ #top .lamps i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 5px 0 12px; transform: translateY(-1px); }+ #top .clock { margin-left: auto; color: var(--faint); }++ /* the toll ticket: the selected call, as the operator logged it */+ #ticket { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); width: min(880px, calc(100% - 32px)); background: var(--paper); color: var(--ink);+ padding: 12px 16px 12px 18px; box-shadow: 0 18px 40px rgba(0,0,0,.6); display: none; font-size: 11.5px; line-height: 1.45;+ background-image: repeating-linear-gradient(transparent 0 18px, rgba(80,60,30,.08) 18px 19px); }+ #ticket.on { display: grid; grid-template-columns: 118px 1fr 168px; gap: 0 16px; }+ #ticket::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--edge, #8a7a5a); }+ #ticket .no { border-right: 1px dashed #a89878; padding-right: 12px; }+ #ticket .no .t { font-size: 9.5px; letter-spacing: .2em; color: #6e604a; }+ #ticket .no .n { font-size: 26px; font-weight: 700; letter-spacing: .02em; line-height: 1.1; }+ #ticket .no .s { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--edge-ink, #6e604a); font-weight: 700; margin-top: 4px; }+ #ticket .body { min-width: 0; }+ #ticket .said { font-weight: 700; font-size: 13px; overflow-wrap: anywhere; }+ #ticket .row { display: grid; grid-template-columns: 76px 1fr; gap: 8px; margin-top: 3px; }+ #ticket .row b { color: #6e604a; font-weight: 600; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; padding-top: 1px; }+ #ticket .row span { overflow-wrap: anywhere; }+ #ticket .line { margin-top: 7px; padding: 6px 9px; background: rgba(255,255,255,.45); border-left: 3px solid var(--edge, #8a7a5a); font-style: italic; overflow-wrap: anywhere; }+ #ticket .stamp { border-left: 1px dashed #a89878; padding-left: 12px; font-size: 10.5px; color: #4b3f30; }+ #ticket .stamp div { display: flex; justify-content: space-between; border-bottom: 1px dotted #b9ab8c; padding: 2px 0; }+ #ticket .stamp div b { font-weight: 700; color: var(--ink); }+ #ticket .stamp .keys { display: block; border: 0; margin-top: 8px; color: #6e604a; line-height: 1.6; }+ #ticket .stamp .keys kbd { font: inherit; font-weight: 700; color: var(--ink); }+ #ticket .wave { display: block; width: 100%; height: 30px; margin-top: 8px; background: rgba(255,255,255,.3); }++ #dial { position: fixed; right: 18px; top: 40px; color: var(--amber); font-size: 18px; letter-spacing: .2em; opacity: 0; transition: opacity .2s; pointer-events: none; }+ #dial.on { opacity: 1; }+ #find { position: fixed; left: 50%; top: 44px; transform: translateX(-50%); padding: 5px 12px; background: rgba(20,14,10,.92); border: 1px solid #3a2c20; font-size: 13px; display: none; white-space: nowrap; }+ #find.on { display: block; }+ #find .c { color: var(--brass); }+ #find i { display: inline-block; width: .6em; height: 1.05em; background: var(--text); transform: translateY(2px); animation: blink 1.05s steps(1) infinite; }+ @keyframes blink { 50% { opacity: 0; } }+ #toast { position: fixed; left: 50%; top: 44px; transform: translateX(-50%); color: var(--white); background: rgba(20,14,10,.92); border: 1px solid #3a2c20; padding: 5px 12px; opacity: 0; transition: opacity .3s; pointer-events: none; white-space: nowrap; }+ #toast.on { opacity: 1; }+ #keys { position: fixed; left: 0; right: 0; bottom: 12px; text-align: center; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 12px; pointer-events: none; }+ #keys kbd { font: inherit; color: var(--muted); }+ #loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--faint); letter-spacing: .3em; pointer-events: none; }+ @media (max-width: 860px) {+ #ticket.on { grid-template-columns: 90px 1fr; }+ #ticket .stamp { display: none; }+ #top .clock { display: none; }+ }+</style>+</head>+<body>+<canvas id="board" aria-label="A switchboard: every harness is a line, every task you handed off is a cord plugged into the line that took it"></canvas>+<header id="top"><span class="brand">SWITCHBOARD</span><span class="lamps" id="lamps"></span><span class="clock" id="clock"></span></header>+<div id="dial"></div>+<div id="find"><span class="c">/</span> <span id="q"></span><i></i></div>+<div id="toast"></div>+<section id="ticket" aria-live="polite"></section>+<footer id="keys"></footer>+<div id="loading">ringing</div>+<script src="boss-data.js"></script>+<script src="switchboard.js"></script>+</body>+</html>diff --git a/docs/research/2026-10-11-boss-mode/switchboard.jpg b/docs/research/2026-10-11-boss-mode/switchboard.jpgnew file mode 100644index 000000000..fafb8448dBinary files /dev/null and b/docs/research/2026-10-11-boss-mode/switchboard.jpg differdiff --git a/docs/research/2026-10-11-boss-mode/switchboard.js b/docs/research/2026-10-11-boss-mode/switchboard.jsnew file mode 100644index 000000000..27c4b73aa--- /dev/null+++ b/docs/research/2026-10-11-boss-mode/switchboard.js@@ -0,0 +1,484 @@+// Switchboard: ⌘B is an operator, and this is its board. Every harness on every machine is a line with a+// jack and a lamp; every task you handed off is a cord from the keyshelf to the line that took it. The+// lamps say what needs you, the way they told an operator: a line flashing wants you, a steady white lamp+// means the call is over and the cord is waiting to be pulled (read), red is trouble, green is talking.+// The cord is where your words went; a ghost cord shows where ⌘B nearly sent them.+(function () {+ 'use strict'+ const B = window.BossData+ const MONO = getComputedStyle(document.documentElement).getPropertyValue('--mono') || 'monospace'+ const $ = (id) => document.getElementById(id)+ const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e }+ const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches+ const canvas = $('board')+ const ctx = canvas.getContext('2d')+ const LAMP = { flash: '#ffb547', white: '#fff3dc', green: '#7ee08f', red: '#ff5a4f', off: null, ring: '#ffb547' }++ let desk = null+ let W = 0, H = 0, DPR = 1+ let lines = [] // { h, x, y, num, panel }+ let panels = []+ let plugs = [] // { d, x, y }+ let shelfY = 0+ let sel = null // { kind: 'cord' | 'line', id }+ let listening = false+ let query = null, typing = false+ let dialed = '', dialTimer = 0+ const pulling = new Map() // dispatch id → started+ const plugging = new Map() // dispatch id → started+ let toastTimer = 0++ // ── what is plugged in, and what each lamp says ────────────────────────────────────────────────────++ const active = (d) => d.state !== 'stopped' && !(d.state === 'done' && d.seenAt)+ function lampOf(d) {+ if (d.state === 'routing') return 'ring'+ if (d.state === 'asking') return 'flash'+ if (d.state === 'done') return d.seenAt ? 'off' : 'white'+ if (d.state === 'failed' || d.state === 'undelivered') return 'red'+ if (d.state === 'working') return 'green'+ return 'off'+ }+ const RANK = { flash: 0, red: 1, white: 2, ring: 3, green: 4, off: 5 }+ function lineLamp(h) {+ const cords = desk.dispatches.filter((d) => d.harness === h.id && active(d))+ const best = cords.map(lampOf).sort((a, b) => RANK[a] - RANK[b])[0]+ if (best) return best+ if (h.state === 'working') return 'green'+ if (h.state === 'asking') return 'flash'+ if (h.state === 'failed') return 'red'+ return 'off'+ }+ const matches = (d) => {+ if (!query) return true+ const h = B.harness(d.harness)+ const hay = `#${d.n} ${d.text} ${h?.name ?? ''} ${h?.project ?? ''} ${d.machine ?? ''} ${d.question ?? ''} ${d.summary ?? ''}`.toLowerCase()+ return query.toLowerCase().split(/\s+/).filter(Boolean).every((w) => hay.includes(w))+ }++ // ── layout ─────────────────────────────────────────────────────────────────────────────────────────++ function layout() {+ const rect = canvas.getBoundingClientRect()+ DPR = Math.min(2, devicePixelRatio || 1)+ W = rect.width; H = rect.height+ canvas.width = Math.round(W * DPR); canvas.height = Math.round(H * DPR)+ const machines = [...desk.machines].sort((a, b) => (b.here - a.here) || (b.online - a.online))+ const onBoard = (h) => h.state !== 'stopped' || desk.dispatches.some((d) => d.harness === h.id && active(d))+ const groups = machines.map((m) => ({ m, hs: desk.harnesses.filter((h) => h.machine === m.id && onBoard(h)).sort((a, b) => a.createdAt - b.createdAt) })).filter((g) => g.hs.length || g.m.online)+ const total = groups.reduce((n, g) => n + g.hs.length, 0)+ const rows = total > 14 ? 3 : 2+ const cols = groups.map((g) => Math.max(1, Math.ceil(g.hs.length / rows)))+ const gap = 16, pad = 14+ const avail = W - 36 - gap * (groups.length - 1) - pad * 2 * groups.length+ const sx = Math.max(58, Math.min(96, avail / cols.reduce((a, b) => a + b, 0)))+ const sy = 86+ const top = 58+ let x = 18, num = 1+ panels = []; lines = []+ groups.forEach((g, i) => {+ const w = cols[i] * sx + pad * 2+ panels.push({ m: g.m, x, y: top, w, h: 92 + (rows - 1) * sy + 22 })+ g.hs.forEach((h, k) => {+ const c = Math.floor(k / rows), r = k % rows+ lines.push({ h, x: x + pad + c * sx + sx / 2, y: top + 92 + r * sy, num: num++, panel: g.m, w: sx })+ })+ x += w + gap+ })+ const fieldBottom = top + 92 + (rows - 1) * sy + 22+ shelfY = Math.max(fieldBottom + 170, H - 330)+ const cords = desk.dispatches.filter(active).sort((a, b) => a.at - b.at)+ const step = Math.min(66, (W - 80) / Math.max(1, cords.length))+ const start = W / 2 - (step * (cords.length - 1)) / 2+ plugs = cords.map((d, i) => ({ d, x: start + i * step, y: shelfY + 36 }))+ }+ const lineOf = (hid) => lines.find((l) => l.h.id === hid)++ // ── drawing ────────────────────────────────────────────────────────────────────────────────────────++ function wood() {+ const g = ctx.createLinearGradient(0, 0, 0, H)+ g.addColorStop(0, '#140d09'); g.addColorStop(0.5, '#110b08'); g.addColorStop(1, '#0b0705')+ ctx.fillStyle = g; ctx.fillRect(0, 0, W, H)+ // Grain.+ ctx.strokeStyle = 'rgba(120,80,50,.045)'; ctx.lineWidth = 1+ for (let y = 0; y < H; y += 7) { ctx.beginPath(); ctx.moveTo(0, y); for (let x = 0; x <= W; x += 60) ctx.lineTo(x, y + Math.sin((x + y * 3) / 90) * 2.2); ctx.stroke() }+ }++ function panel(p, now) {+ // Black bakelite with a brass edge.+ ctx.fillStyle = '#0a0807'; roundRect(p.x, p.y, p.w, p.h, 5); ctx.fill()+ ctx.strokeStyle = 'rgba(201,164,106,.35)'; ctx.lineWidth = 1.2; roundRect(p.x + 0.5, p.y + 0.5, p.w - 1, p.h - 1, 5); ctx.stroke()+ // The nameplate.+ const nw = Math.min(p.w - 20, 190), nx = p.x + p.w / 2 - nw / 2, ny = p.y + 9+ const brass = ctx.createLinearGradient(0, ny, 0, ny + 20)+ brass.addColorStop(0, '#d9b97f'); brass.addColorStop(0.5, '#a9844c'); brass.addColorStop(1, '#7a5d33')+ ctx.fillStyle = p.m.online ? brass : '#3b332a'; roundRect(nx, ny, nw, 20, 2); ctx.fill()+ ctx.fillStyle = p.m.online ? '#2a1d10' : '#81776a'; ctx.font = `700 10.5px ${MONO}`; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'+ let plate = spaced((p.m.online ? p.m.name : `${p.m.name} · closed`).toUpperCase())+ if (ctx.measureText(plate).width > nw - 10) { ctx.font = `700 9px ${MONO}`; plate = fit((p.m.online ? p.m.name : `${p.m.name} · closed`).toUpperCase(), nw - 10) }+ ctx.fillText(plate, p.x + p.w / 2, ny + 10.5)+ if (!p.m.online && p.m.since) { ctx.font = `9.5px ${MONO}`; ctx.fillStyle = '#6a6052'; ctx.fillText(`asleep since ${B.clock(p.m.since)}`, p.x + p.w / 2, p.y + p.h - 10) }+ }++ function jack(l, now) {+ const lamp = lineLamp(l.h)+ const closed = !l.panel.online+ const lit = lamp === 'flash' ? (reduced || Math.floor(now / 480) % 2 === 0) : lamp === 'ring' ? Math.floor(now / 120) % 2 === 0 : lamp !== 'off'+ const color = LAMP[lamp]+ const isSel = sel && ((sel.kind === 'line' && sel.id === l.h.id) || (sel.kind === 'cord' && desk.dispatches.find((d) => d.id === sel.id)?.harness === l.h.id))+ const dim = query && !desk.dispatches.some((d) => d.harness === l.h.id && matches(d)) && !`${l.h.name} ${l.h.project}`.toLowerCase().includes(query.toLowerCase())+ ctx.save()+ if (dim || closed) ctx.globalAlpha = 0.35+ // The lamp: a jewel above the jack.+ const ly = l.y - 16+ if (lit && color) {+ const glow = ctx.createRadialGradient(l.x, ly, 0, l.x, ly, 26)+ glow.addColorStop(0, hexa(color, lamp === 'green' ? 0.28 : 0.5)); glow.addColorStop(1, hexa(color, 0))+ ctx.fillStyle = glow; ctx.beginPath(); ctx.arc(l.x, ly, 26, 0, Math.PI * 2); ctx.fill()+ }+ const jewel = ctx.createRadialGradient(l.x - 1.5, ly - 1.5, 0.5, l.x, ly, 6)+ if (lit && color) { jewel.addColorStop(0, '#fffaf0'); jewel.addColorStop(0.35, color); jewel.addColorStop(1, hexa(color, 0.55)) }+ else { jewel.addColorStop(0, '#4a3f36'); jewel.addColorStop(1, '#1d1814') }+ ctx.fillStyle = jewel; ctx.beginPath(); ctx.arc(l.x, ly, 5.5, 0, Math.PI * 2); ctx.fill()+ ctx.strokeStyle = 'rgba(201,164,106,.4)'; ctx.lineWidth = 1; ctx.beginPath(); ctx.arc(l.x, ly, 6.5, 0, Math.PI * 2); ctx.stroke()+ // The jack: a brass ring and its hole.+ const ring = ctx.createRadialGradient(l.x - 2, l.y - 2, 1, l.x, l.y, 8)+ ring.addColorStop(0, '#f0d39a'); ring.addColorStop(0.6, '#b58d52'); ring.addColorStop(1, '#5e4526')+ ctx.fillStyle = ring; ctx.beginPath(); ctx.arc(l.x, l.y, 7.5, 0, Math.PI * 2); ctx.fill()+ ctx.fillStyle = '#050403'; ctx.beginPath(); ctx.arc(l.x, l.y, 3.6, 0, Math.PI * 2); ctx.fill()+ // The designation strip.+ const cw = Math.min(l.w - 8, 86), cx = l.x - cw / 2, cy = l.y - 56+ ctx.fillStyle = isSel ? '#fff4d8' : '#d6ccb4'; ctx.fillRect(cx, cy, cw, 27)+ ctx.fillStyle = '#241c14'; ctx.textAlign = 'left'; ctx.textBaseline = 'top'+ ctx.font = `700 9.5px ${MONO}`; ctx.fillText(String(l.num).padStart(2, '0'), cx + 4, cy + 3)+ ctx.font = `9px ${MONO}`; ctx.fillStyle = '#5b4d3a'+ const eng = B.engine(l.h.engine).short.toUpperCase()+ ctx.fillText(fit(eng, cw - 26), cx + 22, cy + 3.5)+ ctx.fillStyle = '#241c14'; ctx.font = `600 9px ${MONO}`+ ctx.fillText(fit(l.h.name.toUpperCase(), cw - 7), cx + 4, cy + 15)+ if (isSel) { ctx.strokeStyle = '#ffb547'; ctx.lineWidth = 1.5; ctx.strokeRect(cx - 2, cy - 2, cw + 4, 31) }+ ctx.restore()+ }++ function shelf() {+ // The keyshelf: a slab of walnut, its top face toward the board.+ const y = shelfY+ const top = ctx.createLinearGradient(0, y, 0, y + 60)+ top.addColorStop(0, '#3a2618'); top.addColorStop(1, '#24170e')+ ctx.fillStyle = top+ ctx.beginPath(); ctx.moveTo(30, y); ctx.lineTo(W - 30, y); ctx.lineTo(W - 10, y + 60); ctx.lineTo(10, y + 60); ctx.closePath(); ctx.fill()+ ctx.strokeStyle = 'rgba(201,164,106,.25)'; ctx.beginPath(); ctx.moveTo(30, y + 0.5); ctx.lineTo(W - 30, y + 0.5); ctx.stroke()+ const edge = ctx.createLinearGradient(0, y + 60, 0, y + 78)+ edge.addColorStop(0, '#1d120b'); edge.addColorStop(1, '#0c0705')+ ctx.fillStyle = edge; ctx.fillRect(10, y + 60, W - 20, 18)+ ctx.fillStyle = 'rgba(0,0,0,.5)'; ctx.fillRect(10, y + 78, W - 20, 6)+ }++ function plugAt(p, now) {+ const d = p.d+ const lamp = lampOf(d)+ const color = LAMP[lamp]+ const lit = lamp === 'flash' ? (reduced || Math.floor(now / 480) % 2 === 0) : lamp === 'ring' ? Math.floor(now / 120) % 2 === 0 : lamp !== 'off'+ const isSel = sel?.kind === 'cord' && sel.id === d.id+ ctx.save()+ if (!matches(d)) ctx.globalAlpha = 0.25+ // Its supervisory lamp, behind the hole.+ const ly = shelfY + 14+ if (lit && color) { const g = ctx.createRadialGradient(p.x, ly, 0, p.x, ly, 18); g.addColorStop(0, hexa(color, 0.45)); g.addColorStop(1, hexa(color, 0)); ctx.fillStyle = g; ctx.beginPath(); ctx.arc(p.x, ly, 18, 0, Math.PI * 2); ctx.fill() }+ ctx.fillStyle = lit && color ? color : '#2a211a'; ctx.beginPath(); ctx.arc(p.x, ly, 4, 0, Math.PI * 2); ctx.fill()+ // The hole the cord rises from.+ ctx.fillStyle = '#060403'; ctx.beginPath(); ctx.ellipse(p.x, p.y, 7, 3.2, 0, 0, Math.PI * 2); ctx.fill()+ // A brass tag on the shelf's edge.+ ctx.fillStyle = isSel ? '#ffd38a' : '#b0905c'; ctx.font = `700 10px ${MONO}`; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'+ ctx.fillText(`#${String(d.n).padStart(2, '0')}`, p.x, shelfY + 69)+ if (isSel) { ctx.strokeStyle = '#ffb547'; ctx.lineWidth = 1.2; ctx.beginPath(); ctx.moveTo(p.x - 14, shelfY + 78); ctx.lineTo(p.x + 14, shelfY + 78); ctx.stroke() }+ ctx.restore()+ }++ function cord(p, now) {+ const d = p.d+ const l = lineOf(d.harness)+ const isSel = sel?.kind === 'cord' && sel.id === d.id+ const a = { x: p.x, y: p.y }+ let b+ let k = 1+ if (!l) {+ // Sent nowhere: the plug dangles, no line at the other end.+ const sway = reduced ? 0 : Math.sin(now / 900 + d.n) * 6+ b = { x: p.x + 18 + sway, y: p.y - 70 }+ } else {+ b = { x: l.x, y: l.y }+ const started = plugging.get(d.id)+ if (started) { k = Math.min(1, (now - started) / 900); if (k >= 1) plugging.delete(d.id) }+ const pulled = pulling.get(d.id)+ if (pulled) { k = 1 - Math.min(1, (now - pulled) / 700) }+ if (k < 1) { const e = 1 - Math.pow(1 - k, 3); b = { x: a.x + (b.x - a.x) * e, y: a.y - 40 + (b.y - a.y + 40) * e } }+ }+ const sway = reduced ? 0 : Math.sin(now / 1700 + d.n * 1.7) * 5+ const c1 = { x: a.x, y: a.y - 110 }+ const c2 = { x: b.x + sway + (a.x - b.x) * 0.12, y: b.y + 120 + Math.abs(a.x - b.x) * 0.08 }+ const lamp = lampOf(d)+ const body = isSel ? '#d5ab6a' : lamp === 'flash' ? '#6a4a1f' : lamp === 'red' ? '#5a2620' : lamp === 'white' ? '#5a5244' : '#3b2b1f'+ ctx.save()+ if (!matches(d)) ctx.globalAlpha = 0.18+ if (isSel && !reduced) { ctx.shadowColor = 'rgba(255,190,110,.6)'; ctx.shadowBlur = 12 }+ ctx.lineCap = 'round'+ ctx.strokeStyle = '#0a0604'; ctx.lineWidth = 7; bez(a, c1, c2, b); ctx.stroke()+ ctx.shadowBlur = 0+ ctx.strokeStyle = body; ctx.lineWidth = 5; bez(a, c1, c2, b); ctx.stroke()+ ctx.strokeStyle = 'rgba(255,230,190,.16)'; ctx.lineWidth = 1.2; bez({ x: a.x - 1.2, y: a.y }, { x: c1.x - 1.2, y: c1.y }, { x: c2.x - 1.2, y: c2.y }, { x: b.x - 1.2, y: b.y }); ctx.stroke()+ // The plug: a brass sleeve in the jack, or dangling.+ ctx.translate(b.x, b.y)+ const ang = Math.atan2(b.y - c2.y, b.x - c2.x) + Math.PI / 2+ ctx.rotate(ang)+ const sleeve = ctx.createLinearGradient(-4, 0, 4, 0)+ sleeve.addColorStop(0, '#7a5d33'); sleeve.addColorStop(0.5, '#e6c58a'); sleeve.addColorStop(1, '#6e5330')+ ctx.fillStyle = sleeve; ctx.fillRect(-4, 0, 8, 15)+ ctx.fillStyle = '#1a120c'; ctx.fillRect(-3.2, 15, 6.4, 7)+ if (!l) { ctx.fillStyle = '#e8d7b0'; ctx.fillRect(-1.2, -5, 2.4, 6) }+ ctx.restore()+ if (!l) { ctx.font = `600 9.5px ${MONO}`; ctx.fillStyle = '#ff7a6f'; ctx.textAlign = 'left'; ctx.fillText('NO CIRCUIT', b.x + 12, b.y + 4) }+ return { a, c1, c2, b }+ }++ function ghost(p, now) {+ // Where ⌘B nearly sent it: the runner-up line, as a cord that was never plugged.+ const r = p.d.decision?.runnerUp+ if (!r) return+ const l = lines.find((x) => x.h.name === r.name && x.h.id !== p.d.harness)+ if (!l) return+ const a = { x: p.x, y: p.y }, b = { x: l.x, y: l.y }+ ctx.save()+ ctx.setLineDash([3, 6]); ctx.strokeStyle = 'rgba(255,214,150,.42)'; ctx.lineWidth = 1.4+ bez(a, { x: a.x, y: a.y - 110 }, { x: b.x, y: b.y + 140 }, b); ctx.stroke()+ ctx.setLineDash([])+ ctx.font = `600 10px ${MONO}`; ctx.fillStyle = 'rgba(255,214,150,.8)'; ctx.textAlign = 'center'+ ctx.fillText(`next best ${r.p.toFixed(2)}`, b.x, b.y + 26)+ ctx.restore()+ }++ function frame() {+ const now = Date.now()+ desk.now = now+ ctx.setTransform(DPR, 0, 0, DPR, 0, 0)+ wood()+ for (const p of panels) panel(p, now)+ for (const l of lines) jack(l, now)+ shelf()+ for (const p of plugs) plugAt(p, now)+ const chosen = plugs.find((p) => sel?.kind === 'cord' && p.d.id === sel.id)+ // Cords: the selected one last, on top; its ghost under it.+ let selGeo = null+ for (const p of plugs) if (p !== chosen) cord(p, now)+ if (chosen) { ghost(chosen, now); selGeo = cord(chosen, now) }+ if (chosen && selGeo && chosen.d.decision?.p != null) {+ const m = point(selGeo, 0.42)+ const text = `Jev ${chosen.d.decision.p.toFixed(2)}`+ ctx.font = `700 10.5px ${MONO}`; const w = ctx.measureText(text).width + 12+ ctx.fillStyle = '#e9e0cb'; ctx.fillRect(m.x - w / 2, m.y - 9, w, 18)+ ctx.fillStyle = '#241c14'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; ctx.fillText(text, m.x, m.y + 0.5)+ }+ for (const [id, t] of pulling) if (now - t > 700) pulling.delete(id)+ requestAnimationFrame(frame)+ }++ function bez(a, c1, c2, b) { ctx.beginPath(); ctx.moveTo(a.x, a.y); ctx.bezierCurveTo(c1.x, c1.y, c2.x, c2.y, b.x, b.y) }+ function point({ a, c1, c2, b }, t) {+ const u = 1 - t+ return { x: u * u * u * a.x + 3 * u * u * t * c1.x + 3 * u * t * t * c2.x + t * t * t * b.x, y: u * u * u * a.y + 3 * u * u * t * c1.y + 3 * u * t * t * c2.y + t * t * t * b.y }+ }+ function roundRect(x, y, w, h, r) { ctx.beginPath(); ctx.moveTo(x + r, y); ctx.arcTo(x + w, y, x + w, y + h, r); ctx.arcTo(x + w, y + h, x, y + h, r); ctx.arcTo(x, y + h, x, y, r); ctx.arcTo(x, y, x + w, y, r); ctx.closePath() }+ function fit(text, width) { if (ctx.measureText(text).width <= width) return text; let t = text; while (t.length > 1 && ctx.measureText(t + '…').width > width) t = t.slice(0, -1); return t + '…' }+ const spaced = (t) => t.split('').join(' ')+ function hexa(hex, a) { const n = parseInt(hex.slice(1), 16); return `rgba(${n >> 16},${(n >> 8) & 255},${n & 255},${a})` }++ // ── the header and the toll ticket ─────────────────────────────────────────────────────────────────++ function header() {+ const cords = desk.dispatches.filter(active)+ const count = (lamp) => cords.filter((d) => lampOf(d) === lamp).length+ const box = $('lamps'); box.replaceChildren()+ box.append('operator ⌘B')+ for (const [lamp, word] of [['flash', 'flashing for you'], ['white', 'hung up, pull the cord'], ['red', 'trouble'], ['green', 'talking']]) {+ const n = count(lamp)+ const dot = el('i'); dot.style.background = n ? LAMP[lamp] : '#3a2f26'; if (n) dot.style.boxShadow = `0 0 8px ${LAMP[lamp]}`+ box.append(dot, el('b', null, String(n)), ` ${word}`)+ }+ const down = desk.dispatches.length - cords.length+ box.append(` · ${down} cords down`)+ $('clock').textContent = `${new Date(desk.now).toLocaleTimeString('en-GB')} · ${desk.real ? 'your desk' : 'an invented desk'}`+ }++ function ticket() {+ const t = $('ticket')+ t.replaceChildren()+ if (!sel) { t.classList.remove('on'); return }+ t.classList.add('on')+ const EDGE = { flash: ['#d98a1c', '#8a5310'], white: ['#9a8e74', '#5d523f'], red: ['#c23b33', '#8f241e'], green: ['#3f9a59', '#2d6d40'], ring: ['#d98a1c', '#8a5310'], off: ['#8a7a5a', '#6e604a'] }+ if (sel.kind === 'line') {+ const l = lines.find((x) => x.h.id === sel.id)+ if (!l) { t.classList.remove('on'); return }+ const lamp = lineLamp(l.h)+ t.style.setProperty('--edge', EDGE[lamp][0]); t.style.setProperty('--edge-ink', EDGE[lamp][1])+ const no = el('div', 'no'); no.append(el('div', 't', 'LINE'), el('div', 'n', String(l.num).padStart(2, '0')), el('div', 's', B.STATES[l.h.state]?.label ?? l.h.state))+ const body = el('div', 'body'); body.append(el('div', 'said', l.h.name))+ const row = (k, v) => { const r = el('div', 'row'); r.append(el('b', null, k), el('span', null, v)); body.append(r) }+ row('line', `${B.engine(l.h.engine).name} · ${l.h.project} on ${l.panel.name}`)+ row('calls', 'no task of yours is on this line: you started it by hand, or ⌘B never sent to it')+ if (l.h.summary) body.append(el('div', 'line', l.h.summary))+ t.append(no, body)+ return+ }+ const d = desk.dispatches.find((x) => x.id === sel.id)+ if (!d) { t.classList.remove('on'); return }+ const h = B.harness(d.harness), l = lineOf(d.harness)+ const lamp = lampOf(d)+ t.style.setProperty('--edge', EDGE[lamp][0]); t.style.setProperty('--edge-ink', EDGE[lamp][1])+ const WORD = { flash: 'flashing', white: 'hung up', red: 'trouble', green: 'talking', ring: 'ringing', off: 'cleared' }+ const no = el('div', 'no'); no.append(el('div', 't', 'TOLL TICKET'), el('div', 'n', `#${String(d.n).padStart(2, '0')}`), el('div', 's', WORD[lamp]))+ const body = el('div', 'body')+ body.append(el('div', 'said', `“${d.text}”`))+ const row = (k, v) => { const r = el('div', 'row'); r.append(el('b', null, k), el('span', null, v)); body.append(r) }+ row('called', h ? `line ${String(l?.num ?? 0).padStart(2, '0')} · ${h.name} · ${B.engine(h.engine).short} · ${h.project} on ${d.machine}${d.created ? ' (a new line)' : ''}` : 'no line: nothing was connected')+ const dec = d.decision+ row('operator', dec.kind === 'session' ? `⌘B, by Jev ${dec.p?.toFixed(2) ?? ''}: the same work on the same subject${dec.runnerUp ? ` · next best “${dec.runnerUp.name}” ${dec.runnerUp.p.toFixed(2)}` : ''}`+ : dec.kind === 'new' ? `⌘B, by Jev ${dec.p?.toFixed(2) ?? ''}: ${dec.why}${dec.runnerUp ? ` · next best “${dec.runnerUp.name}” ${dec.runnerUp.p.toFixed(2)}` : ''}`+ : dec.kind === 'direct' ? 'none: you typed it into the line yourself'+ : dec.kind === 'routing' ? '⌘B, deciding…' : `⌘B could not connect it: ${d.error}`)+ const words = d.question ?? d.summary ?? d.error+ if (words && (listening || d.state === 'asking' || d.state === 'done' || d.state === 'failed')) body.append(el('div', 'line', `${d.state === 'asking' ? 'on the line, asking: ' : ''}${words}`))+ if (listening && h) {+ const c = el('canvas', 'wave'); body.append(c)+ requestAnimationFrame(() => wave(c, h, d))+ }+ const stamp = el('div', 'stamp')+ const st = (k, v) => { const r = el('div'); r.append(el('span', null, k), el('b', null, v)); stamp.append(r) }+ st('placed', B.clock(d.at))+ if (d.landedAt) st('connected', `${B.clock(d.landedAt)}${dec.ms ? ` · ${(dec.ms / 1000).toFixed(2)}s` : ''}`)+ if (d.state !== 'working' && d.state !== 'routing') st(WORD[lamp], B.clock(d.since))+ st('elapsed', B.ago(desk.now - d.at))+ if (h) st('turns since', String(h.turns.filter((x) => x.at >= d.at).length))+ const keys = el('div', 'keys')+ const k = lamp === 'white' ? [['p', 'pull the cord (read)'], ['⏎', 'listen in']] : lamp === 'flash' ? [['r', 'ring the line'], ['→', 'answer in the chat']] : [['⏎', 'listen in'], ['r', 'ring the line']]+ k.forEach(([a, b], i) => { if (i) keys.append(el('br')); keys.append(el('kbd', null, a), ` ${b}`) })+ stamp.append(keys)+ t.append(no, body, stamp)+ }++ /** Listening in: the call's rhythm since it was placed, your turns above the line, its below. */+ function wave(c, h, d) {+ const r = c.getBoundingClientRect()+ c.width = r.width * DPR; c.height = r.height * DPR+ const g = c.getContext('2d'); g.scale(DPR, DPR)+ const from = d.at, to = d.state === 'working' || d.state === 'asking' ? desk.now : Math.max(d.since, d.at + 60000)+ g.strokeStyle = 'rgba(36,28,20,.25)'; g.beginPath(); g.moveTo(0, r.height / 2); g.lineTo(r.width, r.height / 2); g.stroke()+ for (const t of h.turns) {+ if (t.at < from || t.at > to) continue+ const x = ((t.at - from) / (to - from)) * r.width+ const len = Math.min(r.height / 2 - 1, 3 + Math.sqrt(t.size) / 8)+ g.strokeStyle = t.by === 'you' ? '#a3501b' : '#241c14'; g.lineWidth = t.by === 'you' ? 2 : 1.2+ g.beginPath(); g.moveTo(x, r.height / 2); g.lineTo(x, r.height / 2 + (t.by === 'you' ? -len : len)); g.stroke()+ }+ }++ // ── keys ───────────────────────────────────────────────────────────────────────────────────────────++ function order() { return plugs.map((p) => p.d).filter(matches) }+ function choose(next) { sel = next; listening = false; ticket() }+ function step(n) {+ const list = order()+ if (!list.length) return+ const i = sel?.kind === 'cord' ? list.findIndex((d) => d.id === sel.id) : -1+ choose({ kind: 'cord', id: list[i < 0 ? 0 : (i + n + list.length) % list.length].id })+ }+ function nextLamp(lamp) {+ const list = order().filter((d) => lampOf(d) === lamp)+ if (!list.length) return toast(`no cord is ${{ flash: 'flashing', white: 'hung up', red: 'in trouble' }[lamp]}`)+ const i = sel?.kind === 'cord' ? list.findIndex((d) => d.id === sel.id) : -1+ choose({ kind: 'cord', id: list[(i + 1) % list.length].id })+ }+ function dial(digit) {+ dialed = (dialed + digit).slice(-3)+ $('dial').textContent = `☎ ${dialed}`; $('dial').classList.add('on')+ clearTimeout(dialTimer)+ dialTimer = setTimeout(() => {+ $('dial').classList.remove('on')+ const l = lines.find((x) => x.num === Number(dialed))+ dialed = ''+ if (!l) return toast('no such line')+ const cords = desk.dispatches.filter((d) => d.harness === l.h.id && active(d)).sort((a, b) => RANK[lampOf(a)] - RANK[lampOf(b)])+ choose(cords.length ? { kind: 'cord', id: cords[0].id } : { kind: 'line', id: l.h.id })+ }, 700)+ }+ function pull() {+ const d = sel?.kind === 'cord' && desk.dispatches.find((x) => x.id === sel.id)+ if (!d) return+ if (lampOf(d) !== 'white') return toast(lampOf(d) === 'flash' ? 'the line is flashing for you: answer it first' : 'the call is still on')+ pulling.set(d.id, Date.now())+ const list = order(), i = list.findIndex((x) => x.id === d.id)+ setTimeout(() => { B.markSeen(d.id); const nxt = order().filter((x) => x.id !== d.id)[Math.min(i, list.length - 2)]; layout(); choose(nxt ? { kind: 'cord', id: nxt.id } : null); header() }, 650)+ toast(`#${String(d.n).padStart(2, '0')} cleared · cord down`)+ }+ function toast(text) { const t = $('toast'); t.textContent = text; t.classList.add('on'); clearTimeout(toastTimer); toastTimer = setTimeout(() => t.classList.remove('on'), 2300) }++ addEventListener('keydown', (e) => {+ if (e.metaKey || e.ctrlKey || e.altKey) return+ if (typing) {+ if (e.key === 'Escape') { query = null; typing = false }+ else if (e.key === 'Enter') typing = false+ else if (e.key === 'Backspace') query = query.slice(0, -1)+ else if (e.key.length === 1) query += e.key+ else return+ e.preventDefault(); $('find').classList.toggle('on', query !== null); $('q').textContent = query ?? ''; return+ }+ if (/^[0-9]$/.test(e.key)) { dial(e.key); e.preventDefault(); return }+ switch (e.key) {+ case 'ArrowRight': case 'l': case 'Tab': step(e.shiftKey ? -1 : 1); break+ case 'ArrowLeft': case 'h': step(-1); break+ case 'n': nextLamp('flash'); break+ case 'w': nextLamp('white'); break+ case 'x': nextLamp('red'); break+ case 'Enter': if (!sel) step(1); listening = !listening; ticket(); break+ case 'p': pull(); break+ case 'r': { const d = sel?.kind === 'cord' && desk.dispatches.find((x) => x.id === sel.id); toast(d?.harness ? `would ring “${B.harness(d.harness)?.name}”: its pane comes forward` : 'pick a cord first'); break }+ case 'ArrowDown': case 'j': nextLamp('flash'); break+ case 'ArrowUp': case 'k': nextLamp('white'); break+ case '/': query = ''; typing = true; $('find').classList.add('on'); $('q').textContent = ''; break+ case 'Escape': if (query) { query = null; $('find').classList.remove('on') } else choose(null); break+ default: return+ }+ e.preventDefault()+ })+ canvas.addEventListener('click', (e) => {+ const r = canvas.getBoundingClientRect(), x = e.clientX - r.left, y = e.clientY - r.top+ const p = plugs.find((q) => Math.abs(q.x - x) < 16 && y > shelfY - 4 && y < shelfY + 84)+ if (p) return choose({ kind: 'cord', id: p.d.id })+ const l = lines.find((q) => Math.abs(q.x - x) < q.w / 2 && y > q.y - 60 && y < q.y + 14)+ if (l) { const cords = desk.dispatches.filter((d) => d.harness === l.h.id && active(d)).sort((a, b) => RANK[lampOf(a)] - RANK[lampOf(b)]); return choose(cords.length ? { kind: 'cord', id: cords[0].id } : { kind: 'line', id: l.h.id }) }+ })++ function keysLine() {+ const parts = [['← →', 'cords'], ['n', 'next flashing'], ['w', 'next hung up'], ['x', 'trouble'], ['0–9', 'dial a line'], ['⏎', 'listen in'], ['p', 'pull the cord'], ['r', 'ring'], ['/', 'find']]+ parts.forEach(([k, w], i) => { if (i) $('keys').append(' · '); $('keys').append(el('kbd', null, k), ` ${w}`) })+ }++ B.load().then((d) => {+ desk = d+ $('loading').remove()+ layout()+ keysLine()+ const first = order().sort((a, b) => RANK[lampOf(a)] - RANK[lampOf(b)] || a.since - b.since)[0]+ const pick = new URLSearchParams(location.search).get('select')+ if (pick) sel = { kind: 'cord', id: pick }+ else if (first) sel = { kind: 'cord', id: first.id }+ header(); ticket()+ B.subscribe((_, event) => {+ if (event.type === 'landed') { layout(); plugging.set(event.dispatch, Date.now()) }+ if (['dispatch', 'landed', 'done', 'asking', 'refresh', 'seen', 'unseen'].includes(event.type)) { layout(); header(); ticket() }+ if (event.type === 'tick' && Date.now() % 10000 < 1000) header()+ })+ addEventListener('resize', () => layout())+ requestAnimationFrame(frame)+ }).catch((error) => { $('loading').textContent = `could not read the desk: ${error.message}` })+})()