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/fixed-celebrate-nested-pr-row.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor: the merge celebration (βœ“ glow, token to "Merged today") now plays for a PR drawn inline on its issue's row β€” before, only the counter ticked because such rows carried no sub-row key; rows stamp the PR keys they draw and βš™ β†’ Merges gains a **Test celebration** button. Reported by @clubanderson.
2 changes: 1 addition & 1 deletion src/docs/dashboard-sections.md
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ Fed by `GET /api/stage-tracker`. Every issue and pull request follows the same p

**Confirmations and "Don't ask again".** Each confirm dialog a row action raises β€” Approve (including a sentinel-flagged head: *⚠ Sentinel flagged security-relevant changes at 40a959b …*), Let hive decide, Close as superseded / won't-fix, Mark needs-human and the rest β€” carries a **Don't ask again for this action** box. Ticking it and confirming stores `hive.tracker.confirm.<action>=skip` in this browser's `localStorage` (one key per action id, e.g. `hive.tracker.confirm.decide:delegate`); later clicks on that action run at once. Nothing the dialog would have said is lost: the result toast carries the same ⚠ sentinel line (it is per head, so skipping the confirm never skips the warning) and the one-line item summary. Actions that need your text (*Give direction…*, *Send back…*, the superseder picker) always ask. The βš™ settings dialog's **Confirmations** section lists which actions are skipped and has one **Reset confirmations** button that turns them all back on.

**Merged today.** The toolbar's right end shows a small hex glyph with **Merged today: N** β€” pull requests the hive saw merge since your local midnight (seeded after a reload from the tracker payload's `merged_24h` list, the audit log's `pr_merged` entries over the last 24 hours, and grown live by the same merge detector that plays the zap); hovering lists the last five with their times. When a PR on the list merges its row does **not** simply vanish on the next refresh: it stays pinned for about 2.5 s, its βœ“ cell glows amber, the event line reads *Hive: merged #14947 Β· by hive*, a flat brand-amber hex token lifts out of the βœ“ cell and arcs (β‰ˆ0.5 s) to the counter, which ticks up with a soft scale-pop β€” the merge zap, when sound is on, plays as the token lands β€” and then the row takes its normal exit. Several merges in one refresh stagger 200 ms apart with at most three tokens in flight (the rest tick the count without flying); a merged PR that is filtered out or on another page still counts. Under reduced motion nothing flies: the count ticks and the row glows. The βš™ dialog's **Merges** section has **Celebrate merges** (default on, `hive.tracker.celebrate`); off, the row leaves as before and the zap plays at once. The row effect is reusable in the SPA as `celebrateRow(rowEl, {kind: 'merged' | 'closed-by-merge'})`.
**Merged today.** The toolbar's right end shows a small hex glyph with **Merged today: N** β€” pull requests the hive saw merge since your local midnight (seeded after a reload from the tracker payload's `merged_24h` list, the audit log's `pr_merged` entries over the last 24 hours, and grown live by the same merge detector that plays the zap); hovering lists the last five with their times. When a PR on the list merges its row does **not** simply vanish on the next refresh: it stays pinned for about 2.5 s, its βœ“ cell glows amber, the event line reads *Hive: merged #14947 Β· by hive*, a flat brand-amber hex token lifts out of the βœ“ cell and arcs (β‰ˆ0.5 s) to the counter, which ticks up with a soft scale-pop β€” the merge zap, when sound is on, plays as the token lands β€” and then the row takes its normal exit. Several merges in one refresh stagger 200 ms apart with at most three tokens in flight (the rest tick the count without flying); a merged PR that is filtered out or on another page still counts. Under reduced motion nothing flies: the count ticks and the row glows. A PR drawn inline on its issue's row (the usual case β€” one covering PR, no sub-row) celebrates on that issue row: every row stamps the PR keys it draws (`data-ham-prs`) and the SPA remembers each PR's host row from the last payload, so the flight has somewhere to start from even when the merge also closes the issue. The βš™ dialog's **Merges** section has **Celebrate merges** (default on, `hive.tracker.celebrate`); off, the row leaves as before and the zap plays at once. **Test celebration** beside it plays one flight from the first row of the list to the counter (pop and zap, the count unchanged) so the effect can be checked without waiting for a merge; under reduced motion it says so and only pops. The row effect is reusable in the SPA as `celebrateRow(rowEl, {kind: 'merged' | 'closed-by-merge'})`.

**Multi-select.** The checkbox in a row's left gutter selects the row; **Shift+click** selects the range from the last clicked row, **Cmd/Ctrl+click** toggles, **Cmd/Ctrl+Shift+click** adds a range to what is selected; with a row focused, **Space** toggles it (Shift+Space extends). Cmd/Ctrl- or Shift-clicking the row itself, away from its links, selects it too. A selection bar appears above the list with the count, **Clear**, and the same actions for the whole selection β€” *Decide…* (opens the group as a menu, *Let hive decide* first β€” each selected row gets its own delegated-decision job, see below), *Hold*, *Release hold*, *Re-evaluate now*, *Mark needs-human…*, *Copy links* β€” each enabled only when it is valid for every selected row and otherwise greyed with the first reason ("Not applicable to acme/console#12", "Sign in with write access…"). Right-clicking a selected row acts on the whole selection. Bulk actions run one request per row, in list order, under a progress toast ("Hold 2/5 β€” acme/console#12…"); the result toast lists each failure by row and the successes stand, after which the list and the status snapshot refresh (a hive-wide rescan is sent once per batch). Selection is keyed on the row's item (repository, kind, number), not its node, so the live re-render keeps it; a row that leaves the list β€” merged, closed, filtered or paged out β€” leaves the selection.

Expand Down
109 changes: 102 additions & 7 deletions src/pkg/dashboard/stage_tracker_cues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ console.log('ok');
// then the row takes its normal exit; several merges stagger 200 ms apart
// under a flight cap; reduced motion flies nothing and ticks at once; the
// toggle off keeps the old immediate zap and no pin.
func TestStageTrackerCelebrateNode(t *testing.T) {
html := indexHTML(t)
lifted := strings.Join([]string{
// stageTrackerCelebrateJS lifts the merge detector and the celebration
// module (counter, token flight, pinned rows) out of index.html.
func stageTrackerCelebrateJS(t *testing.T, html string) string {
t.Helper()
return strings.Join([]string{
"function esc(s) { return String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\"/g, '&quot;'); }",
jsConstLine(t, html, "STAGE_TRACKER_EVENT_MS"),
jsConstLine(t, html, "STAGE_TRACKER_MERGED_TIP_MAX"),
Expand Down Expand Up @@ -211,8 +213,19 @@ func TestStageTrackerCelebrateNode(t *testing.T) {
jsFunc(t, html, "stageTrackerMergeState"),
jsFunc(t, html, "stageTrackerCarryOpen"),
jsFunc(t, html, "stageTrackerNewlyMerged"),
jsFunc(t, html, "stageTrackerRowPRKeys"),
jsFunc(t, html, "stageTrackerPRHosts"),
jsFunc(t, html, "stageTrackerItemKey"),
jsFunc(t, html, "stageTrackerTestCelebration"),
jsConstLine(t, html, "STAGE_TRACKER_CELEBRATE_TEST_KEY"),
}, "\n")
runStageTrackerRowActionsScript(t, lifted+`
}

// stageTrackerCelebrateFixture is the fake clock + DOM the celebration
// tests run against: timers advance with tick(ms); elements support the
// few selectors the module uses (`[a="v"]`, `[a~="v"][data-ham-key]`,
// `.cls`, `.ham-row[data-ham-key] .ham-seg.cap`).
const stageTrackerCelebrateFixture = `
const assert = require('assert');
// ---- fake clock + DOM ----
let clock = Date.parse('2026-10-28T16:30:00Z');
Expand All @@ -234,7 +247,7 @@ function el(tag, attrs) {
getBoundingClientRect() { return e.rect || { left: 0, top: 0, width: 10, height: 10 }; },
get outerHTML() { return '<div class="' + e.className + '"></div>'; },
querySelector(sel) { return e.querySelectorAll(sel)[0] || null; },
querySelectorAll(sel) { const out = []; const m = sel.match(/^\[([\w-]+)="(.*)"\]$/); const cls = sel.match(/^\.([\w-]+)/); const walk = n => { for (const c of n.children) { if (m && c.attrs[m[1]] === m[2].replace(/\\(.)/g, '$1')) out.push(c); else if (cls && c.classList.contains(cls[1]) && (!sel.includes('[data-at]') || c.attrs['data-at'] != null)) out.push(c); walk(c); } }; walk(e); return out; },
querySelectorAll(sel) { const out = []; const unesc = v => v.replace(/\\(.)/g, '$1'); const m = sel.match(/^\[([\w-]+)="(.*)"\]$/); const word = sel.match(/^\[([\w-]+)~="(.*)"\]\[data-ham-key\]$/); const cls = sel.match(/^\.([\w-]+)/); const capOfRow = sel === '.ham-row[data-ham-key] .ham-seg.cap'; const walk = n => { for (const c of n.children) { if (capOfRow) { if (c.classList.contains('cap') && c.closest('.ham-row') && c.closest('.ham-row').classList.contains('ham-row')) out.push(c); } else if (m && c.attrs[m[1]] === unesc(m[2])) out.push(c); else if (word && c.attrs['data-ham-key'] != null && String(c.attrs[word[1]] || '').split(' ').includes(unesc(word[2]))) out.push(c); else if (!m && !word && cls && c.classList.contains(cls[1]) && (!sel.includes('[data-at]') || c.attrs['data-at'] != null)) out.push(c); walk(c); } }; walk(e); return out; },
closest(sel) { let n = e; while (n) { if (n.attrs && n.attrs['data-ham-key'] != null) return n; n = n.parentNode; } return null; },
};
return e;
Expand All @@ -246,16 +259,22 @@ const store = {}; global.localStorage = { getItem: k => (k in store ? store[k] :
let reduced = false; function stageTrackerReducedMotion() { return reduced; }
let soundOn = true; function stageTrackerSoundGate() { return soundOn; }
const zaps = []; function stageTrackerPlayZap(c) { zaps.push(c); }
const toasts = []; function showToast(msg, type) { toasts.push([type, msg]); }
let renders = 0; function renderStageTracker() { renders++; }
const srcs = new Map(); function stageTrackerRowSrcOf(node) { return srcs.get(node); }
let _stageTrackerEvents = {};
const STAGE_TRACKER_TERMINAL = 110;
var _stageTrackerMergeState = null, _stageTrackerZapped = {}, _stageTrackerMergedToday = {}, _stageTrackerMergedTodayCount = -1, _stageTrackerCelebrating = {}, _stageTrackerCelebratePending = {}, _stageTrackerFlights = 0, _stageTrackerReleaseTimer = 0;
function row(key) { const r = el('div', { 'data-ham-key': key }); const strip = el('div'); strip.classList.add('ham-strip-row'); const cap = el('li'); cap.classList.add('ham-seg'); cap.classList.add('cap'); cap.rect = { left: 300, top: 400, width: 20, height: 20 }; strip.appendChild(cap); r.appendChild(strip); srcs.set(r, '<row ' + key + '>'); return r; }
var _stageTrackerPRHost = {}; var _stageTrackerMergeState = null, _stageTrackerZapped = {}, _stageTrackerMergedToday = {}, _stageTrackerMergedTodayCount = -1, _stageTrackerCelebrating = {}, _stageTrackerCelebratePending = {}, _stageTrackerFlights = 0, _stageTrackerReleaseTimer = 0;
function row(key, prs) { const r = el('div', { 'data-ham-key': key }); r.classList.add('ham-row'); if (prs) r.attrs['data-ham-prs'] = prs; const strip = el('div'); strip.classList.add('ham-strip-row'); const cap = el('li'); cap.classList.add('ham-seg'); cap.classList.add('cap'); cap.rect = { left: 300, top: 400, width: 20, height: 20 }; strip.appendChild(cap); r.appendChild(strip); srcs.set(r, '<row ' + key + '>'); return r; }
const header = { key: '__header__', html: 'h' };
const items = (...nums) => ({ items: nums.map(x => ({ repo: 'o/r', kind: 'pr', number: x, stage: 50 })) });
const payloadMerged = (...nums) => ({ items: [], recently_merged: nums.map(x => ({ repo: 'o/r', number: x, merged_at: new Date(clock).toISOString() })) });

`

func TestStageTrackerCelebrateNode(t *testing.T) {
html := indexHTML(t)
runStageTrackerRowActionsScript(t, stageTrackerCelebrateJS(t, html)+stageTrackerCelebrateFixture+`
// 1. A merge: pinned β‰₯ 2 s, glow, token to the counter, count ticks, zap on arrival, then released.
panel.appendChild(row('o/r/pr#1')); panel.appendChild(row('o/r/pr#2'));
stageTrackerNoteMerges(items(1, 2));
Expand Down Expand Up @@ -322,3 +341,79 @@ assert.ok(r11.children.some(c => c.classList.contains('cue-event') && /closed by
console.log('ok');
`)
}

// TestStageTrackerCelebrateNestedPRRow replays the payload shape hive's hive
// serves (captured 2026-10-28 from /api/stage-tracker): a PR nested under
// its issue is drawn inline on the issue row β€” no sub-row, no
// data-ham-sub-key β€” and on merge the payload drops both the PR and the
// issue while recently_merged lists the PR. The flight must leave from the
// issue row; before the fix only the counter popped.
func TestStageTrackerCelebrateNestedPRRow(t *testing.T) {
html := indexHTML(t)
runStageTrackerRowActionsScript(t, stageTrackerCelebrateJS(t, html)+stageTrackerCelebrateFixture+`
const before = { items: [
{ repo: 'hivecommons/hive', number: 14816, kind: 'issue', stage: 85, linked_prs: [{ number: 14822, stage: 85, url: 'https://github.com/hivecommons/hive/pull/14822' }] },
{ repo: 'hivecommons/hive', number: 14822, kind: 'pr', stage: 85, nested_under: 14816 },
{ repo: 'hivecommons/hive', number: 15009, kind: 'issue', stage: 40, linked_prs: [{ number: 15017, stage: 60 }, { number: 15020, stage: 85 }] },
{ repo: 'hivecommons/hive', number: 15017, kind: 'pr', stage: 60, nested_under: 15009 },
{ repo: 'hivecommons/hive', number: 15020, kind: 'pr', stage: 85, nested_under: 15009 },
{ repo: 'hivecommons/docs', number: 500, kind: 'pr', stage: 70 },
], recently_merged: [{ repo: 'hivecommons/hive', number: 14992, merged_at: '2026-10-28T18:47:47Z' }], merged_24h: [{ repo: 'hivecommons/hive', number: 14992, merged_at: '2026-10-28T18:47:47Z' }] };
const after = { items: before.items.filter(it => it.number !== 14816 && it.number !== 14822), recently_merged: [{ repo: 'hivecommons/hive', number: 14822, merged_at: new Date(clock).toISOString() }].concat(before.recently_merged), merged_24h: [{ repo: 'hivecommons/hive', number: 14822, merged_at: new Date(clock).toISOString() }].concat(before.merged_24h) };

// The row stamps the PR keys it draws (the real renderer does this via stageTrackerRowPRKeys).
assert.strictEqual(stageTrackerRowPRKeys(before.items[0]), 'hivecommons/hive/pr#14822');
assert.strictEqual(stageTrackerRowPRKeys(before.items[2]), 'hivecommons/hive/pr#15017 hivecommons/hive/pr#15020');
assert.strictEqual(stageTrackerRowPRKeys(before.items[5]), 'hivecommons/docs/pr#500');
assert.deepStrictEqual(stageTrackerPRHosts(before), {
'hivecommons/hive/pr#14822': 'hivecommons/hive/issue#14816',
'hivecommons/hive/pr#15017': 'hivecommons/hive/issue#15009',
'hivecommons/hive/pr#15020': 'hivecommons/hive/issue#15009',
'hivecommons/docs/pr#500': 'hivecommons/docs/pr#500',
});

// Board as drawn: the issue rows (inline PR, no sub-row) and the standalone PR row.
panel.appendChild(row('hivecommons/hive/issue#14816', 'hivecommons/hive/pr#14822'));
panel.appendChild(row('hivecommons/hive/issue#15009', 'hivecommons/hive/pr#15017 hivecommons/hive/pr#15020'));
panel.appendChild(row('hivecommons/docs/pr#500', 'hivecommons/docs/pr#500'));
stageTrackerNoteMerges(before);
assert.strictEqual(n.textContent, '1', 'seeded from merged_24h, no flourish');
assert.strictEqual(stageTrackerCelebrateRowKey('hivecommons/hive/pr#14822', panel), 'hivecommons/hive/issue#14816', 'inline PR resolves to its issue row');
assert.strictEqual(stageTrackerCelebrateRowKey('hivecommons/hive/pr#15020', panel), 'hivecommons/hive/issue#15009');
assert.strictEqual(stageTrackerCelebrateRowKey('hivecommons/docs/pr#500', panel), 'hivecommons/docs/pr#500');

// The merge: the issue row is pinned and celebrated, a token flies, the count ticks on landing.
stageTrackerNoteMerges(after);
assert.deepStrictEqual(Object.keys(_stageTrackerCelebrating), ['hivecommons/hive/issue#14816'], 'the issue row is the celebrating row');
let rows = stageTrackerPinnedRows(panel, [{ key: '__header__', html: 'h' }, { key: 'hivecommons/hive/issue#15009', html: 'x' }, { key: 'hivecommons/docs/pr#500', html: 'y' }], clock);
assert.ok(rows.some(r => r.key === 'hivecommons/hive/issue#14816' && r.pinned), 'the dropped issue row is pinned');
assert.strictEqual(n.textContent, '1', 'count waits for the token');
tick(0);
const issueRow = panel.children[0];
assert.ok(issueRow.classList.contains('cue-merged'), 'issue row glows: ' + issueRow.className);
assert.ok(issueRow.children.some(c => c.classList.contains('cue-event') && /merged #14822 Β· by hive/.test(c.textContent)), 'event line names the merged PR');
assert.strictEqual(body.children.length, 1, 'a token is in flight');
tick(STAGE_TRACKER_CELEBRATE_FLY_MS * 1.5 + 1);
assert.strictEqual(body.children.length, 0); assert.strictEqual(n.textContent, '2', 'count ticked on landing'); assert.deepStrictEqual(zaps, [1]);

// Host memory: a PR whose row left the DOM between renders (no stamp to find) still resolves through the last payload.
panel.children.length = 0;
panel.appendChild(row('hivecommons/hive/issue#15009'));
assert.strictEqual(stageTrackerCelebrateRowKey('hivecommons/hive/pr#15017', panel), 'hivecommons/hive/issue#15009', 'resolved via nested_under from the last payload');
assert.strictEqual(stageTrackerCelebrateRowKey('hivecommons/hive/pr#99999', panel), '', 'unknown PR: counter only');

// βš™ β†’ Merges β†’ Test celebration: one flight from the first row, pop + zap, the count unchanged.
zaps.length = 0; chip.classList.remove('cue-tick');
const r = stageTrackerTestCelebration();
assert.deepStrictEqual(r, { flew: true }, JSON.stringify(toasts));
assert.strictEqual(body.children.length, 1, 'test token in flight');
tick(STAGE_TRACKER_CELEBRATE_FLY_MS * 1.5 + 1);
assert.strictEqual(n.textContent, '2', 'the test does not count'); assert.ok(chip.classList.contains('cue-tick'), 'but pops'); assert.deepStrictEqual(zaps, [1], 'and zaps');
assert.ok(!panel.children[0].children.some(c => c.classList.contains('cue-event')), 'no event line is written for a test');
tick(STAGE_TRACKER_CELEBRATE_PIN_MS + 1);
assert.ok(!panel.children[0].classList.contains('cue-merged'), 'test glow clears');
panel.children.length = 0;
assert.deepStrictEqual(stageTrackerTestCelebration(), { flew: false });
assert.ok(toasts.some(x => x[0] === 'warning' && /No row to celebrate on/.test(x[1])), JSON.stringify(toasts));
`)
}
Loading
Loading