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-tracker-hive-note-tuck.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor: a row's "Hive: …" note shows for 30 s when it is new, then slides left into a small ⬡ info icon so the list stays quiet; the icon's tooltip keeps the note and its age, a click (or Enter / Space) opens it for another 30 s, a hidden tab pauses the clock, and ⚙ → Hive notes → *Auto-collapse hive notes* (default on) turns it off.
8 changes: 8 additions & 0 deletions src/docs/dashboard-copy-inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,11 @@ Left for a follow-up under the same issue: the ⋯ decision consequences and
`api_repo_item_decision.go`, `row_action_result.go`,
`delegated_decision_human_merge.go`) and `STAGE_TRACKER_MERGE_PATH_WORDS.sweep`
(*automerge sweep* as a merge **path** name on merged rows).

## Hive notes, show then tuck

| Builder | Reaches | Words | Held by |
|---|---|---:|---|
| `stageTrackerEventHtml` with auto-collapse on (`tracker-motion.js`) | the row's event line, open for 30 s then tucked into a ⬡-i button | the line itself unchanged; the button adds `aria-label` *Hive note* (2) | `TestStageTrackerNoteTuckNode` |
| `stageTrackerNoteTitle` | the button's tooltip | the line and its age: *Hive: moved to CI / Review · 2m ago* (≤ line + 3) | same |
| `stageTrackerNoteTuckSectionHtml` (`tracker-sound.js`) | ⚙ → Hive notes | title (2), hint (≈ 70), *Auto-collapse hive notes (default on)* (5) | `TestStageTrackerNoteTuckWiring` |
2 changes: 1 addition & 1 deletion src/docs/dashboard-sections.md
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ A still chevron means **waiting**; its tooltip already says where it stands and

**Event line** — one short plain sentence under the strip about the latest thing that happened to the row, from the difference between two tracker payloads (the poll / SSE refetch the tracker already makes; no extra requests): *Hive: moved to CI / Review · 12s ago*, *Hive: fell back to Claimed — a reviewer requested changes* (a lower stage number reads as a fall only when the stage table's `falls_to` — the stage engine's regression rule — says so; triage accepted 015 → 010, a decision made 085 → 080 or the author resuming 072 → 070 read *moved to*), *Hive: waiting on a person*, *Hive: hold released*, *You: approved*.

It lives two minutes, dims for its last third, and a row carries only its latest line. **Set back** — a row wearing `regressed` colours the line's lead red. **Merged** — see *Merged (the chip, the ledger, the flight)* below. The CSS class names are shared so the sibling Activity Monitor PRs (needs-human options, decision trail) compose on them: `cue-working`, `cue-acting`, `cue-event`, `cue-setback`, `cue-merged`, `cue-decision` (badge, sibling PR), `cue-spin` (the one spin keyframe), `cue-flight` / `ham-merged-count` (the glyph and the Merged chip); the colour tokens `--cue-state`, `--cue-work`, `--cue-decision` on `.ham-row` are declared in the *Cue tokens* paragraph under [Let hive decide](#let-hive-decide) below.
A row carries only its latest line. **Show, then tuck** (owner, 2026-10-29: "show the hive comments when they are new for 30s. then they should shrink to the left inside a hive-info icon … someone can click on the icon to expand the info for another 30s. then it shrinks back again"): the line opens for 30 s (`STAGE_TRACKER_CAPTION_SHOW_MS`) from the moment it is written, then the text slides a few pixels left and fades (≈400 ms ease-in-out, a wipe from the right) into a small ⬡-i button (`.cue-event-ico`, `aria-label="Hive note"`) sitting where *Hive:* sat; the line keeps one fixed height so the chevrons above never shift. The button's tooltip holds the whole note and its age (*Hive: moved to CI / Review · 2m ago*) and is the only thing hover does; a click (or Enter / Space) re-opens the line for another 30 s, a click while it is open tucks it at once (`aria-expanded` follows). Each row has its own window but one shared timer fires the next tuck; a hidden tab freezes every open window and gives the hidden time back on return, so a note is never spent unseen. Tucked notes stay with the row until a newer line replaces them or the row leaves the payload (no 2-minute expiry). Lines only arise from payload differences, so a freshly loaded page starts with no notes rather than a wall of open ones. Under `prefers-reduced-motion: reduce` the toggle is instant. ⚙ → **Hive notes** → **Auto-collapse hive notes** (default on, `hive.tracker.notetuck`) turns this off: the line then stays open, lives two minutes and dims for its last third as before, with no button. **Set back** — a row wearing `regressed` colours the line's lead red. **Merged** — see *Merged (the chip, the ledger, the flight)* below. The CSS class names are shared so the sibling Activity Monitor PRs (needs-human options, decision trail) compose on them: `cue-working`, `cue-acting`, `cue-event`, `cue-setback`, `cue-merged`, `cue-decision` (badge, sibling PR), `cue-spin` (the one spin keyframe), `cue-flight` / `ham-merged-count` (the glyph and the Merged chip); the colour tokens `--cue-state`, `--cue-work`, `--cue-decision` on `.ham-row` are declared in the *Cue tokens* paragraph under [Let hive decide](#let-hive-decide) below.

Legend, in the operator's words: **working** (icon turns), **waiting on X** (still; tooltip names X), **set back by Y** (red lead on the event line), **merged** (✓ glows, a bee rises to the Merged chip or off the top of the screen). Under `prefers-reduced-motion: reduce` every cue animation stops; the words stay.

Expand Down
199 changes: 199 additions & 0 deletions src/pkg/dashboard/stage_tracker_note_tuck_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
package dashboard

import (
"strings"
"testing"
)

// The hive note under a row's chevrons shows for 30 s when it is new, then
// tucks into a ⬡-i icon; a click re-opens it for another 30 s (owner,
// 2026-10-29). These tests lift the pure pieces and the in-place sync and
// drive them against a fake clock + DOM.

func stageTrackerNoteTuckJS(t *testing.T, html string) string {
t.Helper()
return strings.Join([]string{
"function esc(s) { if (typeof s !== 'string') return ''; return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\"/g, '&quot;'); }",
jsConstLine(t, html, "STAGE_TRACKER_EVENT_MS"),
jsConstLine(t, html, "STAGE_TRACKER_TERMINAL"),
jsConstLine(t, html, "STAGE_TRACKER_CAPTION_SHOW_MS"),
jsConstLine(t, html, "STAGE_TRACKER_NOTE_TUCK_KEY"),
jsConstLine(t, html, "STAGE_TRACKER_NOTE_LABEL"),
jsConstLine(t, html, "STAGE_TRACKER_NOTE_ICON"),
jsFunc(t, html, "stageTrackerAgoText"),
jsFunc(t, html, "stageTrackerItemKey"),
jsFunc(t, html, "stageTrackerPRKey"),
jsFunc(t, html, "stageTrackerStateMap"),
jsFunc(t, html, "stageTrackerStageFell"),
jsConstBlock(t, html, "STAGE_TRACKER_WORK_WORDS"),
jsConstBlock(t, html, "STAGE_TRACKER_EVENT_MOD_WORDS"),
jsConstLine(t, html, "STAGE_TRACKER_EVENT_COVERED_BY_PR"),
jsFunc(t, html, "stageTrackerEventText"),
jsFunc(t, html, "stageTrackerEventsNext"),
jsFunc(t, html, "stageTrackerNoteEvents"),
jsFunc(t, html, "stageTrackerNoteOwnerEvent"),
jsFunc(t, html, "stageTrackerEventHtml"),
jsFunc(t, html, "stageTrackerNoteTuckSetting"),
jsFunc(t, html, "stageTrackerSetNoteTuck"),
jsFunc(t, html, "stageTrackerNoteOpen"),
jsFunc(t, html, "stageTrackerNoteToggled"),
jsFunc(t, html, "stageTrackerNoteNextDue"),
jsFunc(t, html, "stageTrackerNoteShift"),
jsFunc(t, html, "stageTrackerNoteTitle"),
jsFunc(t, html, "stageTrackerNoteSync"),
jsFunc(t, html, "stageTrackerNoteSchedule"),
jsFunc(t, html, "stageTrackerNoteToggle"),
jsFunc(t, html, "stageTrackerNoteVisibility"),
jsFunc(t, html, "stageTrackerRowSrcKey"),
"let _stageTrackerEvents = {}; let _stageTrackerStates = null; let _stageTrackerNoteTimer = 0; let _stageTrackerNoteHiddenAt = 0;",
}, "\n") + "\n"
}

// A fake clock whose setTimeout fires from tick(ms), and the few DOM calls
// stageTrackerNoteSync makes: querySelectorAll('.cue-event[data-cue-key]'),
// querySelector('.cue-event-ico'), classList, title, get/setAttribute.
const stageTrackerNoteTuckFixture = `
const assert = require('assert');
let clock = Date.parse('2026-10-29T20:17:00Z');
Date.now = () => clock;
let timers = []; let timerSeq = 0;
global.setTimeout = (fn, ms) => { const id = ++timerSeq; timers.push({ id, at: clock + (ms || 0), fn }); return id; };
global.clearTimeout = id => { timers = timers.filter(x => x.id !== id); };
function tick(ms) { const until = clock + ms; while (true) { const due = timers.filter(x => x.at <= until).sort((a, b) => a.at - b.at)[0]; if (!due) break; timers = timers.filter(x => x !== due); clock = Math.max(clock, due.at); due.fn(); } clock = until; }
const store = {}; global.localStorage = { getItem: k => (k in store ? store[k] : null), setItem(k, v) { store[k] = String(v); } };
function el(cls, attrs) {
const e = { className: cls || '', title: '', attrs: Object.assign({}, attrs || {}), children: [],
classList: { add(c) { if (!e.className.split(' ').includes(c)) e.className = (e.className + ' ' + c).trim(); }, remove(c) { e.className = e.className.split(' ').filter(x => x && x !== c).join(' '); }, contains(c) { return e.className.split(' ').includes(c); } },
getAttribute(k) { return k in e.attrs ? e.attrs[k] : null; }, setAttribute(k, v) { e.attrs[k] = String(v); },
querySelector(sel) { return e.querySelectorAll(sel)[0] || null; },
querySelectorAll(sel) { const out = []; const walk = n => { for (const c of n.children) { if (sel === '.cue-event[data-cue-key]' ? (c.classList.contains('cue-event') && c.attrs['data-cue-key'] != null) : c.classList.contains(sel.slice(1))) out.push(c); walk(c); } }; walk(e); return out; } };
return e;
}
const panel = el('panel');
global.document = { hidden: false, getElementById(id) { return id === 'activity-monitor-panel' ? panel : null; } };
// Build a line element from the rendered HTML, as the page's reconcile would.
function mount(key) {
const html = stageTrackerEventHtml(key, { events: _stageTrackerEvents, nowMs: Date.now() });
const p = el((html.match(/^<p class="([^"]*)"/) || [])[1], { 'data-cue-key': key });
if (/class="cue-event-ico"/.test(html)) { const b = el('cue-event-ico', { 'aria-expanded': (html.match(/aria-expanded="(\w+)"/) || [])[1] }); b.title = (html.match(/ title="([^"]*)"/) || [])[1]; p.children.push(b); }
panel.children.push(p); return p;
}
const tucked = p => p.classList.contains('cue-event-tucked');
`

func TestStageTrackerNoteTuckNode(t *testing.T) {
html := indexHTML(t)
runStageTrackerRowActionsScript(t, stageTrackerNoteTuckJS(t, html)+stageTrackerNoteTuckFixture+`
assert.strictEqual(STAGE_TRACKER_CAPTION_SHOW_MS, 30000);
assert.strictEqual(stageTrackerNoteTuckSetting(), true, 'default on');

// A new line: open, with the ⬡-i button carrying the whole note as its tooltip.
stageTrackerNoteOwnerEvent('k', 'approved', Date.now());
let html = stageTrackerEventHtml('k', { events: _stageTrackerEvents, nowMs: Date.now() });
assert.ok(html.startsWith('<p class="cue-event cue-event-tuckable" data-cue-key="k"><button type="button" class="cue-event-ico" aria-label="Hive note" aria-expanded="true" title="You: approved · 0s ago" data-action="stageTrackerNoteToggle" data-arg0="k" data-stop="1">'), html);
assert.ok(html.includes('<span class="cue-event-body"><span class="cue-event-who">You:</span> <span class="cue-event-text">approved</span>'), html);
assert.ok(!html.includes('cue-event-fading'), 'no 2-minute fade while auto-collapse is on');
const p = mount('k');
stageTrackerNoteSync(panel, Date.now());
assert.ok(!tucked(p), 'open when new');
assert.strictEqual(timers.length, 1, 'one shared timer armed');

// 30 s later it tucks; the tooltip keeps the note and its age.
tick(29999); assert.ok(!tucked(p), 'still open at 29.999 s');
tick(1); assert.ok(tucked(p), 'tucked at 30 s');
assert.strictEqual(p.querySelector('.cue-event-ico').getAttribute('aria-expanded'), 'false');
assert.strictEqual(p.querySelector('.cue-event-ico').title, 'You: approved · 30s ago');
assert.strictEqual(timers.length, 0, 'nothing left to time');
// A fresh node rendered now arrives already tucked (no replayed slide).
assert.ok(/^<p class="cue-event cue-event-tuckable cue-event-tucked"/.test(stageTrackerEventHtml('k', { events: _stageTrackerEvents, nowMs: Date.now() })));

// Click re-opens for another 30 s, then it tucks again.
stageTrackerNoteToggle('k');
assert.ok(!tucked(p), 'click re-opens');
tick(29000); assert.ok(!tucked(p));
tick(1000); assert.ok(tucked(p), 'tucks again after another 30 s');
// Click while open tucks at once.
stageTrackerNoteToggle('k'); assert.ok(!tucked(p));
stageTrackerNoteToggle('k'); assert.ok(tucked(p), 'a click while open tucks at once');
assert.strictEqual(timers.length, 0);

// Hidden tab pauses the window: 20 s open, hidden for 60 s, visible → 10 s left.
stageTrackerNoteToggle('k'); tick(20000); assert.ok(!tucked(p));
stageTrackerNoteVisibility(true); document.hidden = true; assert.strictEqual(timers.length, 0, 'no timer while hidden');
tick(60000); stageTrackerNoteSync(panel, Date.now()); assert.ok(!tucked(p), 'not spent unseen');
document.hidden = false; stageTrackerNoteVisibility(false);
assert.ok(!tucked(p), 'still open on return');
tick(9999); assert.ok(!tucked(p)); tick(1); assert.ok(tucked(p), 'the remaining 10 s run after return');

// Rows have independent clocks, one timer.
stageTrackerNoteOwnerEvent('a', 'one', Date.now()); const pa = mount('a');
tick(10000);
stageTrackerNoteOwnerEvent('b', 'two', Date.now()); const pb = mount('b');
stageTrackerNoteSync(panel, Date.now());
assert.strictEqual(timers.length, 1, 'still one shared timer with two open lines');
tick(20000); assert.ok(tucked(pa) && !tucked(pb), 'a tucks first'); tick(10000); assert.ok(tucked(pb));

// Pure helpers: shift only moves open windows; a tucked line stays put.
assert.deepStrictEqual(stageTrackerNoteShift({ x: { at: 100, tucked: true }, y: { at: 100 } }, 50), { x: { at: 100, tucked: true }, y: { at: 100, openAt: 150 } });
assert.strictEqual(stageTrackerNoteNextDue({}, 0, true), Infinity);

// Payload diffs: auto-collapse keeps lines (no 2-minute expiry) until the
// row leaves the payload; off, the old expiry holds.
const stages = [{ number: 40, label: 'Claimed' }, { number: 50, label: 'CI / Review' }];
const issue = { repo: 'r', kind: 'pr', number: 1, stage: 40, caption: '' };
const prev = stageTrackerStateMap([issue]); const next = stageTrackerStateMap([Object.assign({}, issue, { stage: 50 })]);
let ev = stageTrackerEventsNext({}, prev, next, stages, 0, Infinity);
assert.deepStrictEqual(Object.keys(ev), ['r/pr#1']);
assert.deepStrictEqual(Object.keys(stageTrackerEventsNext(ev, next, next, stages, STAGE_TRACKER_EVENT_MS * 10, Infinity)), ['r/pr#1'], 'kept, tucked, well past 2 min');
assert.deepStrictEqual(stageTrackerEventsNext(ev, next, {}, stages, 1000, Infinity), {}, 'dropped when its row leaves');
assert.deepStrictEqual(stageTrackerEventsNext(ev, next, next, stages, STAGE_TRACKER_EVENT_MS + 1), {}, 'default ttl still expires');

// The tucked flag, aria-expanded and the ageing tooltip are not reasons to swap a row's node.
const a = stageTrackerEventHtml('k', { events: _stageTrackerEvents, nowMs: Date.now() });
_stageTrackerEvents.k = Object.assign({}, _stageTrackerEvents.k, { tucked: false, openAt: Date.now() });
const b = stageTrackerEventHtml('k', { events: _stageTrackerEvents, nowMs: Date.now() + 5000 });
assert.notStrictEqual(a, b); assert.strictEqual(stageTrackerRowSrcKey(a), stageTrackerRowSrcKey(b), 'same source key across a tuck / re-open / age');

// Preference off: the line stays open, no button, the old fade returns.
stageTrackerSetNoteTuck(false);
assert.strictEqual(stageTrackerNoteTuckSetting(), false);
assert.strictEqual(stageTrackerNoteOpen({ at: 0, tucked: true }, 10 * STAGE_TRACKER_CAPTION_SHOW_MS, false), true, 'off keeps every line open');
html = stageTrackerEventHtml('k', { events: _stageTrackerEvents, nowMs: Date.now() + STAGE_TRACKER_EVENT_MS * 0.8 });
assert.ok(html.startsWith('<p class="cue-event cue-event-fading" data-cue-key="k"><span class="cue-event-who">You:</span>'), html);
assert.ok(!html.includes('cue-event-ico'));
stageTrackerNoteSync(panel, Date.now());
assert.ok(!tucked(p) && !tucked(pa) && !tucked(pb), 'off un-tucks every line in place');
assert.strictEqual(timers.length, 0, 'nothing to time when off');
stageTrackerSetNoteTuck(true);
`)
}

// TestStageTrackerNoteTuckWiring: the page carries the markup, the CSS (tokens
// only, reduced motion → instant toggle), the ⚙ toggle, and the visibility
// hook; the window is the one the owner asked for.
func TestStageTrackerNoteTuckWiring(t *testing.T) {
html := indexHTML(t)
for _, want := range []string{
`const STAGE_TRACKER_CAPTION_SHOW_MS = 30000;`,
`const STAGE_TRACKER_NOTE_TUCK_KEY = 'hive.tracker.notetuck';`,
`aria-label="${STAGE_TRACKER_NOTE_LABEL}"`,
`data-action="stageTrackerNoteToggle"`,
`id="sts-notetuck-on" data-change-action="stageTrackerNoteTuckChange" data-arg-types="c"`,
`Auto-collapse hive notes <span class="text-muted">(default on)</span>`,
`stageTrackerNoteVisibility(document.visibilityState !== 'visible')`,
`ctx.noteTuck = stageTrackerNoteTuckSetting();`,
`if (typeof stageTrackerNoteSync === 'function') stageTrackerNoteSync(el, nowMs);`,
`.cue-event.cue-event-tuckable { display: flex; align-items: center;`,
`transition: clip-path 400ms ease-in-out, opacity 350ms ease-in-out, transform 400ms ease-in-out;`,
`.cue-event-tucked .cue-event-body { opacity: 0; transform: translateX(-8px); clip-path: inset(0 100% 0 0); pointer-events: none; }`,
`@media (prefers-reduced-motion: reduce) { .cue-event-body, .cue-event-ico { transition: none; } }`,
} {
if !strings.Contains(html, want) {
t.Errorf("index.html lacks %q", want)
}
}
// The line keeps one fixed height either way so the chevrons never shift.
if !strings.Contains(html, `.cue-event.cue-event-tuckable { display: flex; align-items: center; gap: 0; height: 1.6em; line-height: 1.6em;`) {
t.Errorf("tuckable line has no fixed height")
}
}
Loading
Loading