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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/added-16475-code-activity-reader.md
Original file line number Diff line number Diff line change
@@ -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).
1 change: 1 addition & 0 deletions changelog.d/fixed-tracker-mobile-chevron-height.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Keep Activity tracker chevrons compact on mobile while preserving their caption and icon alignment.
39 changes: 39 additions & 0 deletions src/docs/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/docs/streaming-the-activity-monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
221 changes: 221 additions & 0 deletions src/pkg/dashboard/reader_ui_test.go
Original file line number Diff line number Diff line change
@@ -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], "<a "):]
open = open[:strings.Index(open, ">")]
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: '<script>alert(1)</script>', 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), ['+ <script>alert(1)</script>\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)});
`
25 changes: 25 additions & 0 deletions src/pkg/dashboard/static-src/css/reader.css
Original file line number Diff line number Diff line change
@@ -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; }
Loading
Loading