diff --git a/changelog.d/added-16475-code-activity-reader.md b/changelog.d/added-16475-code-activity-reader.md
new file mode 100644
index 0000000000..bd965eb20d
--- /dev/null
+++ b/changelog.d/added-16475-code-activity-reader.md
@@ -0,0 +1 @@
+- Add an opt-in code activity reader at `?kiosk=1&view=reader`. It shows pushed changes from `/api/matrix/lines` as readable, wrapping paragraph cards with green `+` additions and red `−` removals, with the repository, PR link, file, stage and observed time. It supports pause with P, Space or the button, pauses while you scroll, uses a static layout for reduced motion and stops in hidden tabs. The Matrix view is unchanged (#16475).
diff --git a/changelog.d/fixed-tracker-mobile-chevron-height.md b/changelog.d/fixed-tracker-mobile-chevron-height.md
new file mode 100644
index 0000000000..7aa1273c89
--- /dev/null
+++ b/changelog.d/fixed-tracker-mobile-chevron-height.md
@@ -0,0 +1 @@
+- Keep Activity tracker chevrons compact on mobile while preserving their caption and icon alignment.
diff --git a/src/docs/dashboard.md b/src/docs/dashboard.md
index 83dff09b74..25a8e220da 100644
--- a/src/docs/dashboard.md
+++ b/src/docs/dashboard.md
@@ -604,6 +604,45 @@ The **Hive activity monitor** section (sidebar, Dashboard group; expanded by def
The endpoint returns `stages` (the stage table with `short`, `branch_from`, configured dwell and `falls_to` — the lower same-kind stages a move to which is a regression per the stage engine, so the event line says "fell back to" only for those; 015 → 010 triage accepted, 085 → 080 decision made and 072 → 070 author resuming read "moved to"), `items` (one per open issue/PR represented by the status snapshot, including actionable and held items plus display-only non-actionable issues, drafts, and exempt PRs: `labels`, `created_at`, `updated_at`, `bucket`, `bucket_reason`, stage, `stage_since`, humanised `reason`/`caption`, `actor`, `modifiers`, `author_kind` + `author_kind_source` (`label`, `inferred`, or `registry` — the author has a contributor-hub profile on this hive, so their clanker pushed it; the row icon, tooltip and claimant all read this one value), `lane`, `tier`, `linked_pr`, `linked_prs` (number, title, url, author, author kind, stage, `stage_since`, `caption` and `modifiers` of each open covering PR — enough to draw the nested sub-row without a second lookup), `nested_under` (on a PR: the issue it is listed under), nudge info and the last eight `history` hops from the stage store) and `author_kind_labels`. It answers `{"status":"initializing"}` until the first scan.
+## Code activity reader
+
+The code activity reader is a kiosk view at `?kiosk=1&view=reader` that shows
+pushed changes as readable paragraphs. It is the planned successor to the
+Matrix code view ([#16137](https://github.com/hivecommons/hive/issues/16137)).
+Until the cutover, both views are available. The reader uses the same opt-in
+setting and authorized `GET /api/matrix/lines` endpoint as Matrix, so it has
+the same `dashboard.matrix` repository allowlist, author restriction and
+scrub/path filters. When `dashboard.matrix.enabled` is set, the header shows a
+**Reader** tab next to **Matrix**. Without that setting, the endpoint answers
+404 and the view says it is not enabled. The reader adds no permission and no
+anonymous access.
+
+- **Cards.** Consecutive lines from one file at one PR head form one card,
+ which shows that contiguous changed region in order. Indentation, blank lines
+ and repeated lines are kept. Added lines start with a green `+` and
+ removed lines (`op: "-"`) with a red `−`. Long lines wrap at a fixed font size and
+ are never truncated. Every card shows the repository
+ and PR number, the file, the source stage (`pushed`), and when hive
+ observed the change. The repository links to the pull request, using the source's
+ `pr_url` when it is an https URL and otherwise the derived GitHub link. Code is
+ always shown as text and is never parsed as HTML.
+- **Pacing.** One card is read at a time. A card stays in focus for a few
+ seconds plus a little more for each line, up to 30 seconds, and then the
+ next card scrolls into view. New work waits behind the paragraph being read.
+ When the reader is caught up, it holds quietly. It has no replay, filler,
+ typing effect or sound.
+- **Pause.** Press **P**, press **Space**, or use the **Pause** button to pause
+ or resume. Scrolling with the wheel, touch, arrow keys, Page Up/Page Down,
+ Home or End also pauses the reader so you can inspect the text. The feed is
+ native, scrollable text.
+- **Motion.** With `prefers-reduced-motion`, every card is shown at once and
+ nothing scrolls by itself. In a hidden tab, the reader stops advancing until
+ the tab is visible again.
+
+The feed currently carries pushed added lines, as shown in Matrix. Removal lines
+and whole published-checkpoint regions come from the published-checkpoint
+source ([#16476](https://github.com/hivecommons/hive/issues/16476)).
+
## PR review and link signals
PR pills also carry GitHub's own review state and conversation evidence
diff --git a/src/docs/streaming-the-activity-monitor.md b/src/docs/streaming-the-activity-monitor.md
index 41272618ab..4d4b9e2835 100644
--- a/src/docs/streaming-the-activity-monitor.md
+++ b/src/docs/streaming-the-activity-monitor.md
@@ -296,7 +296,7 @@ full-screen Activity Monitor.
## Matrix mode (separate channel)
-When `dashboard.matrix.enabled` is set, the Activity Monitor header also shows a **Matrix** tab that opens `?kiosk=1&view=matrix` in the same window.
+When `dashboard.matrix.enabled` is set, the Activity Monitor header also shows a **Matrix** tab that opens `?kiosk=1&view=matrix` in the same window. It also shows a **Reader** tab that opens the [code activity reader](dashboard.md#code-activity-reader) at `?kiosk=1&view=reader`. The reader uses the same lines, shown as readable paragraphs.
Matrix is an experimental, default-off code display for a separate channel,
[`twitch.tv/hivecommonsmatrix`](https://www.twitch.tv/hivecommonsmatrix).
diff --git a/src/pkg/dashboard/reader_ui_test.go b/src/pkg/dashboard/reader_ui_test.go
new file mode 100644
index 0000000000..88b566c977
--- /dev/null
+++ b/src/pkg/dashboard/reader_ui_test.go
@@ -0,0 +1,221 @@
+package dashboard
+
+import (
+ "os"
+ "os/exec"
+ "strings"
+ "testing"
+)
+
+func TestReaderUIWiring(t *testing.T) {
+ html := indexHTML(t)
+ read := func(name string) string {
+ t.Helper()
+ b, err := os.ReadFile("static-src/" + name)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return string(b)
+ }
+ js := read("js/reader.js")
+ for _, forbidden := range []string{"innerHTML", "outerHTML", "insertAdjacentHTML", "document.write", "new EventSource", "Math.random", "AudioContext", "new Audio"} {
+ if strings.Contains(js, forbidden) {
+ t.Errorf("reader.js contains forbidden sink/effect %q", forbidden)
+ }
+ }
+ for _, want := range []string{"visibilitychange", "prefers-reduced-motion: reduce", "'/api/matrix/lines?since='", "source.addEventListener('code-lines'", "'wheel'", "'touchstart'"} {
+ if !strings.Contains(js, want) {
+ t.Errorf("reader.js missing %q", want)
+ }
+ }
+ for _, want := range []string{"window.HIVE_READER = kiosk && view === 'reader';", "document.body.classList.add('reader-mode');", "hiveReaderStart();", "if (window.HIVE_READER) window.hiveReaderAttach(source);", `id="oc-reader-tab" href="?kiosk=1&view=reader"`, "getElementById('oc-reader-tab')"} {
+ if !strings.Contains(html, want) {
+ t.Errorf("generated page missing %q", want)
+ }
+ }
+ // The Matrix entry point stays until the cutover (#16477).
+ if !strings.Contains(html, `id="oc-matrix-tab"`) || !strings.Contains(html, "window.HIVE_MATRIX = kiosk && view === 'matrix';") {
+ t.Error("generated page lost the Matrix entry point")
+ }
+ start := strings.Index(html, `id="oc-reader-tab"`)
+ open := html[strings.LastIndex(html[:start], "")]
+ if !strings.Contains(open, " hidden") {
+ t.Errorf("reader header tab %q must be hidden until the status payload enables it", open)
+ }
+ css := read("css/reader.css")
+ // Long text wraps at a fixed size and the feed scrolls natively.
+ for _, want := range []string{"white-space: pre-wrap; overflow-wrap: anywhere;", "body.reader-mode .reader-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto;", "font: 20px/1.5 monospace;"} {
+ if !strings.Contains(css, want) {
+ t.Errorf("reader.css missing %q", want)
+ }
+ }
+ for _, forbidden := range []string{"text-overflow", "vw;", "line-clamp", "nowrap"} {
+ if strings.Contains(css, forbidden) {
+ t.Errorf("reader.css must not shrink or truncate text (%q)", forbidden)
+ }
+ }
+ for _, rule := range strings.Split(css, "}") {
+ selector, _, ok := strings.Cut(strings.TrimSpace(rule), "{")
+ if !ok {
+ continue
+ }
+ for _, part := range strings.Split(selector, ",") {
+ if !strings.HasPrefix(strings.TrimSpace(part), "body.reader-mode ") {
+ t.Errorf("unscoped reader selector %q", part)
+ }
+ }
+ }
+ manifest := read("manifest.txt")
+ for _, file := range []string{"js/reader.js", "css/reader.css"} {
+ if !strings.Contains(manifest, file+"\n") {
+ t.Errorf("manifest missing %s", file)
+ }
+ if !strings.Contains(html, read(file)) {
+ t.Errorf("generated page is missing current %s", file)
+ }
+ }
+}
+
+// Exercise rendering, pacing, pause and reduced motion with deterministic
+// DOM/clock doubles; no browser, network or real timers required.
+func TestReaderUIBehavior(t *testing.T) {
+ node, err := exec.LookPath("node")
+ if err != nil {
+ t.Skip("node unavailable")
+ }
+ cmd := exec.Command(node, "-e", readerBrowserTest)
+ if out, err := cmd.CombinedOutput(); err != nil {
+ t.Fatalf("reader browser behavior: %v\n%s", err, out)
+ }
+}
+
+const readerBrowserTest = `
+const assert = require('assert');
+const fs = require('fs');
+const vm = require('vm');
+const reader = fs.readFileSync('static-src/js/reader.js', 'utf8');
+const boot = fs.readFileSync('static-src/js/boot.js', 'utf8').split('})();')[0] + '})();';
+const at = '2026-11-03T12:00:00Z';
+const first = [
+ {seq: 1, repo: 'org/repo', pr: 2, head: 'abc', path: 'main.go', line: '', at},
+ {seq: 2, repo: 'org/repo', pr: 2, head: 'abc', path: 'main.go', line: '', at},
+ {seq: 3, repo: 'org/repo', pr: 2, head: 'abc', path: 'main.go', line: '\tx := 1', at},
+ {seq: 4, repo: 'org/repo', pr: 2, head: 'abc', path: 'main.go', line: '\tx := 1', at},
+ {seq: 5, repo: 'org/repo', pr: 2, head: 'abc', path: 'main.go', line: ' old()', op: '-', at},
+ {seq: 6, repo: 'org/other', pr: 7, head: 'def', path: 'README.md', line: 'a very long line '.repeat(40), pr_url: 'https://example.test/review/7', at},
+];
+async function scenario(query, opts = {}) {
+ const docEvents = {}, timers = new Map(), requests = [], scrolls = [], sse = {};
+ // page caps each response like the server does; seq always reports the newest line held.
+ let id = 0, status = opts.status || 200, seq = 6, lines = first, page = opts.page || Infinity;
+ const elements = [];
+ function el(tag) { const e = {tagName: tag.toUpperCase(), children: [], listeners: {}, attrs: {}, className: '',
+ textContent: '', hidden: false, scrollTop: 0, offsetHeight: 10, classList: {add(){}},
+ setAttribute(k, v){this.attrs[k] = v}, append(...a){this.children.push(...a)}, appendChild(a){this.children.push(a); return a},
+ removeChild(a){this.children.splice(this.children.indexOf(a), 1)}, replaceChildren(...a){this.children = a},
+ addEventListener(n, fn){this.listeners[n] = fn}, scrollIntoView(o){scrolls.push(o)}};
+ elements.push(e); return e; }
+ const doc = {body: el('body'), hidden: false, createElement: el,
+ getElementById(id){return elements.find(e => e.id === id)},
+ addEventListener(n, fn){(docEvents[n] ||= []).push(fn)}};
+ const motion = {matches: !!opts.reduced, addEventListener(n, fn){this.change = fn}};
+ const win = {location: {href: 'https://hive.test/' + query}, matchMedia(){return motion}, addEventListener(){}};
+ const c = vm.createContext({window: win, document: doc, URL, location: {hash: ''}, history: {replaceState(){}},
+ localStorage: {getItem(){return null}, setItem(){}},
+ requestAnimationFrame(){throw new Error('reader must not animate frames')},
+ setTimeout(fn){timers.set(++id, fn); return id}, clearTimeout(i){timers.delete(i)}, setInterval(){}, dashboardSetInterval(){},
+ fetch(url){requests.push(url); const body = {seq, source: 'pushed-lines', lines: lines.slice(0, page)}; lines = lines.slice(page);
+ return Promise.resolve({status, ok: status === 200, json(){return Promise.resolve(body)}})},
+ Date, Math});
+ vm.runInContext(reader, c); c.hiveReaderStart = win.hiveReaderStart;
+ vm.runInContext(boot, c);
+ for (const fn of docEvents.DOMContentLoaded || []) fn();
+ const flush = async () => {for (let i = 0; i < 12; i++) await Promise.resolve()};
+ await flush();
+ if (!win.HIVE_READER) {assert.equal(requests.length, 0); assert(!doc.getElementById('hive-reader')); return;}
+ const byClass = n => elements.find(e => e.className === n);
+ const feed = byClass('reader-feed'), statusEl = byClass('reader-status'), button = byClass('reader-pause');
+ const fire = () => {assert.equal(timers.size, 1); const [k, fn] = [...timers][0]; timers.delete(k); fn()};
+ const key = (key, code) => docEvents.keydown[0]({key, code, target: doc.body, preventDefault(){}});
+ assert.equal(requests[0], '/api/matrix/lines?since=0');
+ if (status !== 200) {
+ assert.equal(feed.children.length, 0); assert.equal(timers.size, 0);
+ assert(statusEl.textContent.includes(status === 404 ? 'not enabled' : 'Sign in'));
+ return;
+ }
+ const meta = card => card.children[0].children, rows = card => card.children[1].children.map(r => r.textContent);
+ const checkFirst = card => {
+ // One contiguous region: blank, indented and repeated lines kept as text.
+ assert.deepEqual(rows(card), ['+ \n', '+ \n', '+ \tx := 1\n', '+ \tx := 1\n', '\u2212 old()\n']);
+ assert.equal(card.children[1].tagName, 'PRE');
+ assert.deepEqual(card.children[1].children.map(r => r.className), ['reader-line reader-add', 'reader-line reader-add', 'reader-line reader-add', 'reader-line reader-add', 'reader-line reader-del']);
+ const [repo, file, stage, time] = meta(card);
+ assert.equal(repo.tagName, 'A'); assert.equal(repo.textContent, 'org/repo #2');
+ assert.equal(repo.href, 'https://github.com/org/repo/pull/2'); assert.equal(repo.attrs.rel, 'noopener noreferrer');
+ assert.equal(file.textContent, 'main.go'); assert.equal(stage.textContent, 'pushed');
+ assert.equal(time.tagName, 'TIME'); assert.equal(time.attrs.datetime, '2026-11-03T12:00:00.000Z');
+ assert(time.textContent.startsWith('observed '));
+ };
+ const checkSecond = card => {
+ assert.equal(meta(card)[0].href, 'https://example.test/review/7');
+ assert.equal(meta(card)[1].textContent, 'README.md');
+ assert.equal(rows(card)[0], '+ ' + 'a very long line '.repeat(40) + '\n');
+ };
+ win.hiveReaderAttach({addEventListener(n, fn){sse[n] = fn}});
+ if (opts.page) {
+ // A capped page resumes from the last returned line, not the newest seq,
+ // so no line is skipped and the region stays one contiguous card.
+ await flush();
+ assert.deepEqual(requests, ['/api/matrix/lines?since=0', '/api/matrix/lines?since=2', '/api/matrix/lines?since=4']);
+ assert.equal(feed.children.length, 2); checkFirst(feed.children[0]); checkSecond(feed.children[1]);
+ return;
+ }
+ if (opts.reduced) {
+ // Static and scrollable: everything shown at once, nothing scheduled or scrolled.
+ assert.equal(feed.children.length, 2); assert.equal(timers.size, 0); assert.equal(scrolls.length, 0);
+ checkFirst(feed.children[0]); checkSecond(feed.children[1]);
+ lines = [{seq: 7, repo: 'org/repo', pr: 2, head: 'abc', path: 'b.go', line: 'next', at}]; seq = 7;
+ sse['code-lines'](); await flush();
+ assert.equal(feed.children.length, 3); assert.equal(timers.size, 0); assert.equal(scrolls.length, 0);
+ return;
+ }
+ // The first paragraph is shown; the next waits for it to be read.
+ assert.equal(feed.children.length, 1); checkFirst(feed.children[0]);
+ assert.equal(timers.size, 1); assert.equal(scrolls.at(-1).behavior, 'smooth');
+ assert(statusEl.textContent.includes('1 change waiting'));
+ // Incoming work queues behind the paragraph being read.
+ lines = [{seq: 7, repo: 'org/repo', pr: 2, head: 'abc', path: 'b.go', line: 'next', at}]; seq = 7;
+ sse['code-lines'](); await flush();
+ assert.equal(requests.at(-1), '/api/matrix/lines?since=6');
+ assert.equal(feed.children.length, 1); assert.equal(timers.size, 1);
+ // P pauses and resumes; the button mirrors it.
+ key('p'); assert.equal(timers.size, 0); assert.equal(button.textContent, 'Resume');
+ assert.equal(button.attrs['aria-pressed'], 'true'); assert(statusEl.textContent.startsWith('paused'));
+ key(' ', 'Space'); assert.equal(timers.size, 1); assert.equal(button.textContent, 'Pause');
+ fire(); assert.equal(feed.children.length, 2); checkSecond(feed.children[1]);
+ // Wheel, touch and navigation keys pause for inspection; the button resumes.
+ byClass('reader-scroll').listeners.wheel(); assert.equal(timers.size, 0); assert.equal(button.textContent, 'Resume');
+ button.listeners.click(); assert.equal(timers.size, 1);
+ byClass('reader-scroll').listeners.touchstart(); assert.equal(timers.size, 0);
+ button.listeners.click(); key('PageDown'); assert.equal(timers.size, 0);
+ button.listeners.click(); assert.equal(timers.size, 1);
+ // A hidden tab stops all motion.
+ doc.hidden = true; docEvents.visibilitychange.forEach(fn => fn()); assert.equal(timers.size, 0);
+ doc.hidden = false; docEvents.visibilitychange.forEach(fn => fn()); await flush();
+ fire(); assert.equal(feed.children.length, 3); assert.equal(rows(feed.children[2])[0], '+ next\n');
+ // Caught up: a quiet hold with no replay or filler.
+ fire(); assert.equal(timers.size, 0); assert.equal(feed.children.length, 3);
+ assert(statusEl.textContent.includes('Caught up'));
+ sse['code-lines'](); await flush(); assert.equal(timers.size, 0); assert.equal(feed.children.length, 3);
+ status = 403; sse['code-lines'](); await flush();
+ assert.equal(feed.children.length, 0); assert(statusEl.textContent.includes('Sign in'));
+}
+(async () => {
+ await scenario(''); await scenario('?view=reader'); await scenario('?kiosk=1'); await scenario('?kiosk=1&view=matrix');
+ await scenario('?kiosk=1&view=reader');
+ await scenario('?kiosk=1&view=reader', {reduced: true});
+ await scenario('?kiosk=1&view=reader', {reduced: true, page: 2});
+ for (const status of [404, 401, 403]) await scenario('?kiosk=1&view=reader', {status});
+})().catch(e => {console.error(e); process.exit(1)});
+`
diff --git a/src/pkg/dashboard/static-src/css/reader.css b/src/pkg/dashboard/static-src/css/reader.css
new file mode 100644
index 0000000000..9f3a4398ca
--- /dev/null
+++ b/src/pkg/dashboard/static-src/css/reader.css
@@ -0,0 +1,25 @@
+body.reader-mode #hive-dashboard-root { display: none !important; }
+body.reader-mode #hive-reader {
+ --reader-bg: #0b0f0c;
+ --reader-surface: #121a14;
+ --reader-text: #e8f5eb;
+ --reader-muted: #b8ccbb;
+ --reader-add: #7ee2a0;
+ --reader-del: #ff8f8f;
+ --reader-tail: 10rem;
+ position: fixed; inset: 0; z-index: 100000; display: flex; flex-direction: column;
+ background: var(--reader-bg); color: var(--reader-text); font: 20px/1.5 monospace;
+}
+body.reader-mode .reader-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-5); padding: var(--sp-3) var(--sp-5); color: var(--reader-muted); font-size: var(--fs-touch); overflow-wrap: anywhere; }
+body.reader-mode .reader-status { flex: 1 1 auto; color: var(--reader-text); }
+body.reader-mode .reader-pause { font: inherit; color: var(--reader-text); background: var(--reader-surface); border: 1px solid var(--reader-muted); border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-6); cursor: pointer; }
+body.reader-mode .reader-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-0) var(--sp-5) var(--reader-tail); }
+body.reader-mode .reader-card { max-width: 80rem; margin: 0 auto 1.5rem; padding: var(--sp-3) var(--sp-5); background: var(--reader-surface); border-radius: var(--radius); }
+body.reader-mode .reader-meta { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; color: var(--reader-muted); font-size: var(--fs-touch); overflow-wrap: anywhere; }
+body.reader-mode .reader-repo { color: var(--reader-text); font-weight: 600; }
+body.reader-mode a.reader-repo { text-decoration: underline; }
+body.reader-mode .reader-diff { margin: .5rem 0 0; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
+body.reader-mode .reader-add { color: var(--reader-add); }
+body.reader-mode .reader-del { color: var(--reader-del); }
+body.reader-mode #hive-reader [hidden] { display: none !important; }
+body.reader-mode #kiosk-cta { position: fixed; right: var(--sp-6); bottom: var(--sp-6); z-index: 100001; opacity: .85; }
diff --git a/src/pkg/dashboard/static-src/css/tracker.css b/src/pkg/dashboard/static-src/css/tracker.css
index edc493b6fb..84f4e682bf 100644
--- a/src/pkg/dashboard/static-src/css/tracker.css
+++ b/src/pkg/dashboard/static-src/css/tracker.css
@@ -445,7 +445,7 @@
line is centred under the first rather than ragged-left. */
.ham-chevron-copy { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--ham-chevron-text-lines); line-clamp: var(--ham-chevron-text-lines); max-height: calc(var(--ham-chevron-text-lines) * var(--ham-chevron-line-height) * 1em); flex: 0 1 auto; min-width: 0; overflow: hidden; white-space: normal; overflow-wrap: anywhere; text-align: center; }
.ham-chevron-copy :is(.ham-seg-t, .ham-detour, .ham-holder, .ham-gate-detail) { display: inline; white-space: normal; overflow-wrap: anywhere; }
- .ham-chevron-copy > .ham-decision-trigger { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--ham-chevron-text-lines); line-clamp: var(--ham-chevron-text-lines); max-width: 100%; overflow: hidden; white-space: normal; overflow-wrap: anywhere; }
+ .ham-chevron-copy > .ham-decision-trigger { min-height: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--ham-chevron-text-lines); line-clamp: var(--ham-chevron-text-lines); max-width: 100%; overflow: hidden; white-space: normal; overflow-wrap: anywhere; }
.config-tooltip.ham-chevron-tip { overflow-wrap: anywhere; max-width: calc(100vw - var(--sp-8)); max-height: calc(100vh - var(--sp-8)); overflow-y: auto; pointer-events: auto; }
@keyframes ham-pulse { 0%, 100% { opacity: 0; } 50% { opacity: 0.3; } }
/* ---- tracker-cues: the Activity Monitor's shared cue vocabulary ------
diff --git a/src/pkg/dashboard/static-src/html/faq.html b/src/pkg/dashboard/static-src/html/faq.html
index 9586cb3fba..6075f22dea 100644
--- a/src/pkg/dashboard/static-src/html/faq.html
+++ b/src/pkg/dashboard/static-src/html/faq.html
@@ -267,7 +267,7 @@ Where to get help
diff --git a/src/pkg/dashboard/static-src/html/topbar.html b/src/pkg/dashboard/static-src/html/topbar.html
index 2b07aaeb9d..8cbee4a4dd 100644
--- a/src/pkg/dashboard/static-src/html/topbar.html
+++ b/src/pkg/dashboard/static-src/html/topbar.html
@@ -26,6 +26,7 @@
+
diff --git a/src/pkg/dashboard/static-src/js/boot.js b/src/pkg/dashboard/static-src/js/boot.js
index c73bd07343..4a07d91459 100644
--- a/src/pkg/dashboard/static-src/js/boot.js
+++ b/src/pkg/dashboard/static-src/js/boot.js
@@ -41,6 +41,12 @@
document.body.classList.add('matrix-mode');
document.addEventListener('DOMContentLoaded', function(){ typeof hiveMatrixStart === 'function' && hiveMatrixStart(); });
}
+ // Code activity reader (#16475): same opt-in data as Matrix, read as paragraphs.
+ window.HIVE_READER = kiosk && view === 'reader';
+ if(window.HIVE_READER){
+ document.body.classList.add('reader-mode');
+ document.addEventListener('DOMContentLoaded', function(){ typeof hiveReaderStart === 'function' && hiveReaderStart(); });
+ }
window.HIVE_KIOSK=kiosk;
window.HIVE_POPOUT=popout&&!kiosk;
window.HIVE_DISPLAY=display&&!kiosk;
diff --git a/src/pkg/dashboard/static-src/js/reader.js b/src/pkg/dashboard/static-src/js/reader.js
new file mode 100644
index 0000000000..5a3130d774
--- /dev/null
+++ b/src/pkg/dashboard/static-src/js/reader.js
@@ -0,0 +1,231 @@
+// Code activity reader (#16475): changed regions as readable paragraphs on
+// the kiosk. Opt-in like Matrix and fed by the same authorized pull endpoint
+// (the shared SSE stream only nudges). Code is always set with textContent.
+(function(){
+ 'use strict';
+ var pull = function(){};
+ window.hiveReaderAttach = function(source){
+ if (!window.HIVE_READER) return;
+ source.addEventListener('code-lines', function(){ pull(); });
+ source.addEventListener('open', function(){ pull(); });
+ };
+ window.hiveReaderStart = function(){
+ if (!window.HIVE_READER || document.getElementById('hive-reader')) return;
+ // Cards kept on screen, regions waiting to be read, and how long one
+ // paragraph stays in focus before the next arrives.
+ var MAX_CARDS = 60, MAX_PENDING = 40, BASE_DWELL = 5000, LINE_DWELL = 600, MAX_DWELL = 30000;
+ var NAV_KEYS = ['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End'];
+ var STAGES = {'pushed-lines': 'pushed'};
+ var root = document.createElement('main');
+ root.id = 'hive-reader';
+ root.setAttribute('aria-label', 'Code activity reader');
+ document.body.appendChild(root);
+ function element(tag, className, text, parent){
+ var el = document.createElement(tag);
+ el.className = className;
+ if (text) el.textContent = text;
+ (parent || root).appendChild(el);
+ return el;
+ }
+ var bar = element('div', 'reader-bar');
+ element('span', 'reader-source', 'Source: changes pushed by hive · public allowlisted repos', bar);
+ var status = element('span', 'reader-status', 'Waiting for pushed changes…', bar);
+ status.setAttribute('role', 'status');
+ var button = element('button', 'reader-pause', 'Pause', bar);
+ button.setAttribute('type', 'button');
+ button.setAttribute('aria-pressed', 'false');
+ button.setAttribute('title', 'Pause or resume (P / Space)');
+ var scroller = element('div', 'reader-scroll');
+ scroller.setAttribute('tabindex', '0');
+ var feed = element('div', 'reader-feed', '', scroller);
+ var motion = window.matchMedia('(prefers-reduced-motion: reduce)');
+ var pending = [], current = null, readUntil = 0, timer = 0, lastSeq = 0;
+ var enabled = false, manualPause = false, loading = false, again = false, problem = '';
+ function paused(){ return manualPause || document.hidden; }
+ function regionKey(line){ return [line.repo, line.pr, line.head || '', line.path].join('\u0000'); }
+ // Consecutive lines of one file at one head form one contiguous region;
+ // a gap in seq (a dropped line or another file) starts a new one. Only
+ // unread regions grow, so a paragraph on screen never changes.
+ function group(lines, stage){
+ lines.forEach(function(line){
+ var last = pending[pending.length - 1], seq = Number(line.seq) || 0;
+ if (last && last.key === regionKey(line) && seq && seq === last.lastSeq + 1) {
+ last.lines.push(line); last.lastSeq = seq; last.at = line.at;
+ return;
+ }
+ pending.push({key: regionKey(line), repo: line.repo, pr: Number(line.pr) || 0, path: line.path,
+ stage: stage, prUrl: line.pr_url, lines: [line], lastSeq: seq, at: line.at});
+ });
+ if (pending.length > MAX_PENDING) pending = pending.slice(-MAX_PENDING);
+ }
+ // Prefer an https pr_url from the source; otherwise derive the link from repo and PR number.
+ function prLink(region){
+ if (typeof region.prUrl === 'string' && /^https:\/\/[^\s<>"']+$/.test(region.prUrl)) return region.prUrl;
+ if (/^[\w.-]+\/[\w.-]+$/.test(region.repo || '') && region.pr > 0) {
+ return 'https://github.com/' + region.repo + '/pull/' + region.pr;
+ }
+ return '';
+ }
+ function observed(at){
+ var ms = Date.parse(at);
+ if (!Number.isFinite(ms)) return {iso: '', text: 'observed time unknown'};
+ var d = new Date(ms);
+ // The shared helper honours the dashboard time-zone preference.
+ var shown = typeof formatDashboardDateTime === 'function' ? formatDashboardDateTime(d) : d.toISOString();
+ return {iso: d.toISOString(), text: 'observed ' + shown};
+ }
+ function card(region){
+ var article = document.createElement('article');
+ article.className = 'reader-card';
+ var meta = element('header', 'reader-meta', '', article);
+ var href = prLink(region);
+ var repo = element(href ? 'a' : 'span', 'reader-repo', region.repo + (region.pr > 0 ? ' #' + region.pr : ''), meta);
+ if (href) {
+ repo.href = href;
+ repo.setAttribute('target', '_blank');
+ repo.setAttribute('rel', 'noopener noreferrer');
+ }
+ element('span', 'reader-file', region.path, meta);
+ element('span', 'reader-stage', region.stage, meta);
+ var when = observed(region.at);
+ var time = element('time', 'reader-time', when.text, meta);
+ if (when.iso) time.setAttribute('datetime', when.iso);
+ var diff = element('pre', 'reader-diff', '', article);
+ region.lines.forEach(function(line){
+ var del = line.op === '-';
+ var row = element('span', 'reader-line ' + (del ? 'reader-del' : 'reader-add'), '', diff);
+ row.textContent = (del ? '\u2212' : line.op || '+') + ' ' + line.line + '\n';
+ });
+ return article;
+ }
+ function dwell(region){ return Math.min(MAX_DWELL, BASE_DWELL + region.lines.length * LINE_DWELL); }
+ // Drop the oldest cards and keep the visible text where it was.
+ function trim(){
+ while (feed.children.length > MAX_CARDS) {
+ var first = feed.children[0], height = first.offsetHeight || 0;
+ feed.removeChild(first);
+ scroller.scrollTop = Math.max(0, (scroller.scrollTop || 0) - height);
+ }
+ }
+ function reveal(region, scroll){
+ region.node = card(region);
+ feed.appendChild(region.node);
+ trim();
+ current = region;
+ readUntil = Date.now() + dwell(region);
+ if (scroll && region.node.scrollIntoView) region.node.scrollIntoView({block: 'start', behavior: motion.matches ? 'auto' : 'smooth'});
+ }
+ function updateStatus(){
+ var text = problem;
+ if (!text && enabled) {
+ if (pending.length) text = pending.length + (pending.length === 1 ? ' change' : ' changes') + ' waiting';
+ else text = current ? 'Caught up · holding until new changes are pushed' : 'Waiting for pushed changes…';
+ }
+ if (paused()) text = 'paused' + (text ? ' · ' + text : '');
+ status.textContent = text;
+ button.textContent = manualPause ? 'Resume' : 'Pause';
+ button.setAttribute('aria-pressed', manualPause ? 'true' : 'false');
+ }
+ function stop(){ clearTimeout(timer); timer = 0; }
+ function advance(){
+ timer = 0;
+ if (!enabled || paused() || motion.matches) return;
+ // Quiet hold when caught up: no replay, no filler, nothing scheduled.
+ if (pending.length) {
+ reveal(pending.shift(), true);
+ timer = setTimeout(advance, dwell(current));
+ }
+ updateStatus();
+ }
+ // Starts the next reveal once the current paragraph's dwell ends; never
+ // restarts a running dwell, so incoming work cannot interrupt reading.
+ function schedule(fresh){
+ if (timer || !enabled || paused()) { updateStatus(); return; }
+ if (motion.matches) {
+ // Static and scrollable: everything is shown, nothing scrolls by itself.
+ while (pending.length) reveal(pending.shift(), false);
+ updateStatus();
+ return;
+ }
+ if (fresh && current) {
+ readUntil = Date.now() + dwell(current);
+ if (current.node && current.node.scrollIntoView) current.node.scrollIntoView({block: 'start', behavior: 'smooth'});
+ }
+ var wait = readUntil - Date.now();
+ if (pending.length && wait <= 0) { advance(); return; }
+ if (pending.length) timer = setTimeout(advance, wait);
+ updateStatus();
+ }
+ function setPaused(value){
+ if (manualPause === value) return;
+ manualPause = value;
+ stop();
+ if (!manualPause) schedule(true);
+ updateStatus();
+ }
+ function inspect(){ setPaused(true); }
+ function clearContent(message){
+ stop();
+ enabled = false; pending = []; current = null; lastSeq = 0; problem = message;
+ feed.replaceChildren();
+ updateStatus();
+ }
+ pull = function(){
+ if (loading) { again = true; return; }
+ loading = true; again = false;
+ fetch('/api/matrix/lines?since=' + lastSeq, {cache: 'no-store', credentials: 'same-origin'})
+ .then(function(response){
+ if (response.status === 404) { clearContent('The code activity reader is not enabled on this hive'); return null; }
+ if (response.status === 401 || response.status === 403) { clearContent('Sign in with permission to read code activity'); return null; }
+ if (!response.ok) throw new Error('reader pull failed');
+ return response.json();
+ }).then(function(data){
+ if (!data) return;
+ var seq = Number(data.seq) || 0;
+ // A restarted hive can reset its sequence; start over cleanly.
+ if (seq < lastSeq) { stop(); pending = []; current = null; lastSeq = 0; feed.replaceChildren(); }
+ var raw = Array.isArray(data.lines) ? data.lines : [];
+ var incoming = raw.filter(function(line){
+ return line && typeof line.line === 'string' && typeof line.repo === 'string' && typeof line.path === 'string';
+ });
+ var source = typeof data.source === 'string' ? data.source : '';
+ group(incoming, STAGES[source] || source || 'pushed');
+ // data.seq is the newest line the hive holds, not the last one in
+ // this page: the server caps a page, so resume from the last line
+ // returned and pull again until the page reaches the newest seq.
+ var returned = raw.length ? Number(raw[raw.length - 1] && raw[raw.length - 1].seq) || 0 : 0;
+ var more = returned > 0 && returned < seq;
+ lastSeq = more ? returned : seq;
+ enabled = true; problem = '';
+ // Hold the reveal while catching up so a region split across
+ // pages still arrives as one paragraph.
+ if (more) { again = true; updateStatus(); return; }
+ schedule(false);
+ }).catch(function(){ problem = 'Code activity unavailable · retrying'; updateStatus(); })
+ .finally(function(){ loading = false; if (again) pull(); });
+ };
+ button.addEventListener('click', function(){ setPaused(!manualPause); });
+ scroller.addEventListener('wheel', inspect, {passive: true});
+ scroller.addEventListener('touchstart', inspect, {passive: true});
+ document.addEventListener('visibilitychange', function(){
+ if (document.hidden) { stop(); updateStatus(); return; }
+ schedule(true); pull();
+ });
+ document.addEventListener('keydown', function(event){
+ var target = event.target || {};
+ if (event.ctrlKey || event.metaKey || event.altKey ||
+ /INPUT|TEXTAREA|SELECT/.test(target.tagName) || target.isContentEditable) return;
+ if (NAV_KEYS.indexOf(event.key) >= 0) { inspect(); return; }
+ if (event.repeat) return;
+ if (event.key === 'p' || event.key === 'P' || (event.code === 'Space' && target.tagName !== 'BUTTON')) {
+ event.preventDefault(); setPaused(!manualPause);
+ }
+ });
+ motion.addEventListener('change', function(){ stop(); schedule(false); });
+ updateStatus(); pull();
+ // Recover from missed nudges, endpoint activation and transient failures.
+ if (typeof dashboardSetInterval === 'function') {
+ dashboardSetInterval('reader-poll', function(){ if (!document.hidden) pull(); }, 30000);
+ }
+ };
+})();
diff --git a/src/pkg/dashboard/static-src/js/refresh.js b/src/pkg/dashboard/static-src/js/refresh.js
index e9b865ac63..2f57184955 100644
--- a/src/pkg/dashboard/static-src/js/refresh.js
+++ b/src/pkg/dashboard/static-src/js/refresh.js
@@ -482,6 +482,8 @@
if (typeof data.matrixEnabled === 'boolean') {
const matrixTab = document.getElementById('oc-matrix-tab');
if (matrixTab) matrixTab.hidden = !data.matrixEnabled;
+ const readerTab = document.getElementById('oc-reader-tab');
+ if (readerTab) readerTab.hidden = !data.matrixEnabled;
}
if (document.body.style.opacity === '0') document.body.style.opacity = '1';
const scrollAnchor = captureScrollAnchor();
diff --git a/src/pkg/dashboard/static-src/js/sse-bootstrap.js b/src/pkg/dashboard/static-src/js/sse-bootstrap.js
index 16a90550c5..925a9cfce8 100644
--- a/src/pkg/dashboard/static-src/js/sse-bootstrap.js
+++ b/src/pkg/dashboard/static-src/js/sse-bootstrap.js
@@ -29,6 +29,7 @@
const source = new EventSource('/api/events');
_eventSource = source;
if (window.HIVE_MATRIX) window.hiveMatrixAttach(source);
+ if (window.HIVE_READER) window.hiveReaderAttach(source);
_sseOpenedAtMs = Date.now();
_sseLastFrameAtMs = 0;
const conn = document.getElementById('conn');
diff --git a/src/pkg/dashboard/static-src/manifest.txt b/src/pkg/dashboard/static-src/manifest.txt
index 468411c7b3..29f97e4627 100644
--- a/src/pkg/dashboard/static-src/manifest.txt
+++ b/src/pkg/dashboard/static-src/manifest.txt
@@ -34,9 +34,11 @@ css/review-campaigns.css
css/kiosk.css
css/popout.css
css/matrix.css
+css/reader.css
css/variables.css
glue/style-close-body-open.html
js/matrix.js
+js/reader.js
js/boot.js
glue/boot-script-close.html
html/auth.html
diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html
index 6a2c4eb941..d440f1441e 100644
--- a/src/pkg/dashboard/static/index.html
+++ b/src/pkg/dashboard/static/index.html
@@ -1782,7 +1782,7 @@
line is centred under the first rather than ragged-left. */
.ham-chevron-copy { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--ham-chevron-text-lines); line-clamp: var(--ham-chevron-text-lines); max-height: calc(var(--ham-chevron-text-lines) * var(--ham-chevron-line-height) * 1em); flex: 0 1 auto; min-width: 0; overflow: hidden; white-space: normal; overflow-wrap: anywhere; text-align: center; }
.ham-chevron-copy :is(.ham-seg-t, .ham-detour, .ham-holder, .ham-gate-detail) { display: inline; white-space: normal; overflow-wrap: anywhere; }
- .ham-chevron-copy > .ham-decision-trigger { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--ham-chevron-text-lines); line-clamp: var(--ham-chevron-text-lines); max-width: 100%; overflow: hidden; white-space: normal; overflow-wrap: anywhere; }
+ .ham-chevron-copy > .ham-decision-trigger { min-height: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--ham-chevron-text-lines); line-clamp: var(--ham-chevron-text-lines); max-width: 100%; overflow: hidden; white-space: normal; overflow-wrap: anywhere; }
.config-tooltip.ham-chevron-tip { overflow-wrap: anywhere; max-width: calc(100vw - var(--sp-8)); max-height: calc(100vh - var(--sp-8)); overflow-y: auto; pointer-events: auto; }
@keyframes ham-pulse { 0%, 100% { opacity: 0; } 50% { opacity: 0.3; } }
/* ---- tracker-cues: the Activity Monitor's shared cue vocabulary ------
@@ -7099,6 +7099,31 @@
body.matrix-mode .matrix-list small { color: var(--matrix-muted); }
body.matrix-mode #hive-matrix [hidden] { display: none !important; }
body.matrix-mode #kiosk-cta { position: fixed; right: var(--sp-6); bottom: var(--sp-6); z-index: 100001; opacity: .85; }
+body.reader-mode #hive-dashboard-root { display: none !important; }
+body.reader-mode #hive-reader {
+ --reader-bg: #0b0f0c;
+ --reader-surface: #121a14;
+ --reader-text: #e8f5eb;
+ --reader-muted: #b8ccbb;
+ --reader-add: #7ee2a0;
+ --reader-del: #ff8f8f;
+ --reader-tail: 10rem;
+ position: fixed; inset: 0; z-index: 100000; display: flex; flex-direction: column;
+ background: var(--reader-bg); color: var(--reader-text); font: 20px/1.5 monospace;
+}
+body.reader-mode .reader-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-5); padding: var(--sp-3) var(--sp-5); color: var(--reader-muted); font-size: var(--fs-touch); overflow-wrap: anywhere; }
+body.reader-mode .reader-status { flex: 1 1 auto; color: var(--reader-text); }
+body.reader-mode .reader-pause { font: inherit; color: var(--reader-text); background: var(--reader-surface); border: 1px solid var(--reader-muted); border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-6); cursor: pointer; }
+body.reader-mode .reader-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-0) var(--sp-5) var(--reader-tail); }
+body.reader-mode .reader-card { max-width: 80rem; margin: 0 auto 1.5rem; padding: var(--sp-3) var(--sp-5); background: var(--reader-surface); border-radius: var(--radius); }
+body.reader-mode .reader-meta { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; color: var(--reader-muted); font-size: var(--fs-touch); overflow-wrap: anywhere; }
+body.reader-mode .reader-repo { color: var(--reader-text); font-weight: 600; }
+body.reader-mode a.reader-repo { text-decoration: underline; }
+body.reader-mode .reader-diff { margin: .5rem 0 0; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
+body.reader-mode .reader-add { color: var(--reader-add); }
+body.reader-mode .reader-del { color: var(--reader-del); }
+body.reader-mode #hive-reader [hidden] { display: none !important; }
+body.reader-mode #kiosk-cta { position: fixed; right: var(--sp-6); bottom: var(--sp-6); z-index: 100001; opacity: .85; }
.var-empty{color:var(--muted);font-size:var(--fs-sm);padding:var(--sp-2) var(--sp-0)}
.var-section{margin-top:var(--sp-6);border-top:1px solid var(--border);padding-top:var(--sp-5)}
.var-heading{font-weight:600;font-size:var(--fs-sm);margin-bottom:var(--sp-4)}
@@ -7463,6 +7488,237 @@
}
};
})();
+// Code activity reader (#16475): changed regions as readable paragraphs on
+// the kiosk. Opt-in like Matrix and fed by the same authorized pull endpoint
+// (the shared SSE stream only nudges). Code is always set with textContent.
+(function(){
+ 'use strict';
+ var pull = function(){};
+ window.hiveReaderAttach = function(source){
+ if (!window.HIVE_READER) return;
+ source.addEventListener('code-lines', function(){ pull(); });
+ source.addEventListener('open', function(){ pull(); });
+ };
+ window.hiveReaderStart = function(){
+ if (!window.HIVE_READER || document.getElementById('hive-reader')) return;
+ // Cards kept on screen, regions waiting to be read, and how long one
+ // paragraph stays in focus before the next arrives.
+ var MAX_CARDS = 60, MAX_PENDING = 40, BASE_DWELL = 5000, LINE_DWELL = 600, MAX_DWELL = 30000;
+ var NAV_KEYS = ['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End'];
+ var STAGES = {'pushed-lines': 'pushed'};
+ var root = document.createElement('main');
+ root.id = 'hive-reader';
+ root.setAttribute('aria-label', 'Code activity reader');
+ document.body.appendChild(root);
+ function element(tag, className, text, parent){
+ var el = document.createElement(tag);
+ el.className = className;
+ if (text) el.textContent = text;
+ (parent || root).appendChild(el);
+ return el;
+ }
+ var bar = element('div', 'reader-bar');
+ element('span', 'reader-source', 'Source: changes pushed by hive · public allowlisted repos', bar);
+ var status = element('span', 'reader-status', 'Waiting for pushed changes…', bar);
+ status.setAttribute('role', 'status');
+ var button = element('button', 'reader-pause', 'Pause', bar);
+ button.setAttribute('type', 'button');
+ button.setAttribute('aria-pressed', 'false');
+ button.setAttribute('title', 'Pause or resume (P / Space)');
+ var scroller = element('div', 'reader-scroll');
+ scroller.setAttribute('tabindex', '0');
+ var feed = element('div', 'reader-feed', '', scroller);
+ var motion = window.matchMedia('(prefers-reduced-motion: reduce)');
+ var pending = [], current = null, readUntil = 0, timer = 0, lastSeq = 0;
+ var enabled = false, manualPause = false, loading = false, again = false, problem = '';
+ function paused(){ return manualPause || document.hidden; }
+ function regionKey(line){ return [line.repo, line.pr, line.head || '', line.path].join('\u0000'); }
+ // Consecutive lines of one file at one head form one contiguous region;
+ // a gap in seq (a dropped line or another file) starts a new one. Only
+ // unread regions grow, so a paragraph on screen never changes.
+ function group(lines, stage){
+ lines.forEach(function(line){
+ var last = pending[pending.length - 1], seq = Number(line.seq) || 0;
+ if (last && last.key === regionKey(line) && seq && seq === last.lastSeq + 1) {
+ last.lines.push(line); last.lastSeq = seq; last.at = line.at;
+ return;
+ }
+ pending.push({key: regionKey(line), repo: line.repo, pr: Number(line.pr) || 0, path: line.path,
+ stage: stage, prUrl: line.pr_url, lines: [line], lastSeq: seq, at: line.at});
+ });
+ if (pending.length > MAX_PENDING) pending = pending.slice(-MAX_PENDING);
+ }
+ // Prefer an https pr_url from the source; otherwise derive the link from repo and PR number.
+ function prLink(region){
+ if (typeof region.prUrl === 'string' && /^https:\/\/[^\s<>"']+$/.test(region.prUrl)) return region.prUrl;
+ if (/^[\w.-]+\/[\w.-]+$/.test(region.repo || '') && region.pr > 0) {
+ return 'https://github.com/' + region.repo + '/pull/' + region.pr;
+ }
+ return '';
+ }
+ function observed(at){
+ var ms = Date.parse(at);
+ if (!Number.isFinite(ms)) return {iso: '', text: 'observed time unknown'};
+ var d = new Date(ms);
+ // The shared helper honours the dashboard time-zone preference.
+ var shown = typeof formatDashboardDateTime === 'function' ? formatDashboardDateTime(d) : d.toISOString();
+ return {iso: d.toISOString(), text: 'observed ' + shown};
+ }
+ function card(region){
+ var article = document.createElement('article');
+ article.className = 'reader-card';
+ var meta = element('header', 'reader-meta', '', article);
+ var href = prLink(region);
+ var repo = element(href ? 'a' : 'span', 'reader-repo', region.repo + (region.pr > 0 ? ' #' + region.pr : ''), meta);
+ if (href) {
+ repo.href = href;
+ repo.setAttribute('target', '_blank');
+ repo.setAttribute('rel', 'noopener noreferrer');
+ }
+ element('span', 'reader-file', region.path, meta);
+ element('span', 'reader-stage', region.stage, meta);
+ var when = observed(region.at);
+ var time = element('time', 'reader-time', when.text, meta);
+ if (when.iso) time.setAttribute('datetime', when.iso);
+ var diff = element('pre', 'reader-diff', '', article);
+ region.lines.forEach(function(line){
+ var del = line.op === '-';
+ var row = element('span', 'reader-line ' + (del ? 'reader-del' : 'reader-add'), '', diff);
+ row.textContent = (del ? '\u2212' : line.op || '+') + ' ' + line.line + '\n';
+ });
+ return article;
+ }
+ function dwell(region){ return Math.min(MAX_DWELL, BASE_DWELL + region.lines.length * LINE_DWELL); }
+ // Drop the oldest cards and keep the visible text where it was.
+ function trim(){
+ while (feed.children.length > MAX_CARDS) {
+ var first = feed.children[0], height = first.offsetHeight || 0;
+ feed.removeChild(first);
+ scroller.scrollTop = Math.max(0, (scroller.scrollTop || 0) - height);
+ }
+ }
+ function reveal(region, scroll){
+ region.node = card(region);
+ feed.appendChild(region.node);
+ trim();
+ current = region;
+ readUntil = Date.now() + dwell(region);
+ if (scroll && region.node.scrollIntoView) region.node.scrollIntoView({block: 'start', behavior: motion.matches ? 'auto' : 'smooth'});
+ }
+ function updateStatus(){
+ var text = problem;
+ if (!text && enabled) {
+ if (pending.length) text = pending.length + (pending.length === 1 ? ' change' : ' changes') + ' waiting';
+ else text = current ? 'Caught up · holding until new changes are pushed' : 'Waiting for pushed changes…';
+ }
+ if (paused()) text = 'paused' + (text ? ' · ' + text : '');
+ status.textContent = text;
+ button.textContent = manualPause ? 'Resume' : 'Pause';
+ button.setAttribute('aria-pressed', manualPause ? 'true' : 'false');
+ }
+ function stop(){ clearTimeout(timer); timer = 0; }
+ function advance(){
+ timer = 0;
+ if (!enabled || paused() || motion.matches) return;
+ // Quiet hold when caught up: no replay, no filler, nothing scheduled.
+ if (pending.length) {
+ reveal(pending.shift(), true);
+ timer = setTimeout(advance, dwell(current));
+ }
+ updateStatus();
+ }
+ // Starts the next reveal once the current paragraph's dwell ends; never
+ // restarts a running dwell, so incoming work cannot interrupt reading.
+ function schedule(fresh){
+ if (timer || !enabled || paused()) { updateStatus(); return; }
+ if (motion.matches) {
+ // Static and scrollable: everything is shown, nothing scrolls by itself.
+ while (pending.length) reveal(pending.shift(), false);
+ updateStatus();
+ return;
+ }
+ if (fresh && current) {
+ readUntil = Date.now() + dwell(current);
+ if (current.node && current.node.scrollIntoView) current.node.scrollIntoView({block: 'start', behavior: 'smooth'});
+ }
+ var wait = readUntil - Date.now();
+ if (pending.length && wait <= 0) { advance(); return; }
+ if (pending.length) timer = setTimeout(advance, wait);
+ updateStatus();
+ }
+ function setPaused(value){
+ if (manualPause === value) return;
+ manualPause = value;
+ stop();
+ if (!manualPause) schedule(true);
+ updateStatus();
+ }
+ function inspect(){ setPaused(true); }
+ function clearContent(message){
+ stop();
+ enabled = false; pending = []; current = null; lastSeq = 0; problem = message;
+ feed.replaceChildren();
+ updateStatus();
+ }
+ pull = function(){
+ if (loading) { again = true; return; }
+ loading = true; again = false;
+ fetch('/api/matrix/lines?since=' + lastSeq, {cache: 'no-store', credentials: 'same-origin'})
+ .then(function(response){
+ if (response.status === 404) { clearContent('The code activity reader is not enabled on this hive'); return null; }
+ if (response.status === 401 || response.status === 403) { clearContent('Sign in with permission to read code activity'); return null; }
+ if (!response.ok) throw new Error('reader pull failed');
+ return response.json();
+ }).then(function(data){
+ if (!data) return;
+ var seq = Number(data.seq) || 0;
+ // A restarted hive can reset its sequence; start over cleanly.
+ if (seq < lastSeq) { stop(); pending = []; current = null; lastSeq = 0; feed.replaceChildren(); }
+ var raw = Array.isArray(data.lines) ? data.lines : [];
+ var incoming = raw.filter(function(line){
+ return line && typeof line.line === 'string' && typeof line.repo === 'string' && typeof line.path === 'string';
+ });
+ var source = typeof data.source === 'string' ? data.source : '';
+ group(incoming, STAGES[source] || source || 'pushed');
+ // data.seq is the newest line the hive holds, not the last one in
+ // this page: the server caps a page, so resume from the last line
+ // returned and pull again until the page reaches the newest seq.
+ var returned = raw.length ? Number(raw[raw.length - 1] && raw[raw.length - 1].seq) || 0 : 0;
+ var more = returned > 0 && returned < seq;
+ lastSeq = more ? returned : seq;
+ enabled = true; problem = '';
+ // Hold the reveal while catching up so a region split across
+ // pages still arrives as one paragraph.
+ if (more) { again = true; updateStatus(); return; }
+ schedule(false);
+ }).catch(function(){ problem = 'Code activity unavailable · retrying'; updateStatus(); })
+ .finally(function(){ loading = false; if (again) pull(); });
+ };
+ button.addEventListener('click', function(){ setPaused(!manualPause); });
+ scroller.addEventListener('wheel', inspect, {passive: true});
+ scroller.addEventListener('touchstart', inspect, {passive: true});
+ document.addEventListener('visibilitychange', function(){
+ if (document.hidden) { stop(); updateStatus(); return; }
+ schedule(true); pull();
+ });
+ document.addEventListener('keydown', function(event){
+ var target = event.target || {};
+ if (event.ctrlKey || event.metaKey || event.altKey ||
+ /INPUT|TEXTAREA|SELECT/.test(target.tagName) || target.isContentEditable) return;
+ if (NAV_KEYS.indexOf(event.key) >= 0) { inspect(); return; }
+ if (event.repeat) return;
+ if (event.key === 'p' || event.key === 'P' || (event.code === 'Space' && target.tagName !== 'BUTTON')) {
+ event.preventDefault(); setPaused(!manualPause);
+ }
+ });
+ motion.addEventListener('change', function(){ stop(); schedule(false); });
+ updateStatus(); pull();
+ // Recover from missed nudges, endpoint activation and transient failures.
+ if (typeof dashboardSetInterval === 'function') {
+ dashboardSetInterval('reader-poll', function(){ if (!document.hidden) pull(); }, 30000);
+ }
+ };
+})();
// Apply layout immediately; keep the shell visible while live data loads.
// NOTE: only body classes are set here — the .layout-toggle buttons do NOT
// exist in the DOM yet at this point, so any label write here is a no-op.
@@ -7506,6 +7762,12 @@
document.body.classList.add('matrix-mode');
document.addEventListener('DOMContentLoaded', function(){ typeof hiveMatrixStart === 'function' && hiveMatrixStart(); });
}
+ // Code activity reader (#16475): same opt-in data as Matrix, read as paragraphs.
+ window.HIVE_READER = kiosk && view === 'reader';
+ if(window.HIVE_READER){
+ document.body.classList.add('reader-mode');
+ document.addEventListener('DOMContentLoaded', function(){ typeof hiveReaderStart === 'function' && hiveReaderStart(); });
+ }
window.HIVE_KIOSK=kiosk;
window.HIVE_POPOUT=popout&&!kiosk;
window.HIVE_DISPLAY=display&&!kiosk;
@@ -8022,6 +8284,7 @@