From d07c9ca2ac122884ab8eefc20bb8e7a00da73599 Mon Sep 17 00:00:00 2001 From: mendezr Date: Wed, 28 Oct 2026 16:37:44 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20feature:=20show=20Activity=20Mo?= =?UTF-8?q?nitor=20operator=20decision=20trails?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add persistent decision receipts, shared amber/stuck predicates, and the folded Decisions filter and legend. Consume the additive last_operator_action payload planned in #14996 without requiring it on legacy rows. Hive-Run: hivecommons/hive#14998 Hive-Plan: activity-monitor-decision-trail-phases-2-3 Hive-Spec: hivecommons/hive#14998#scope-1-5 Signed-off-by: mendezr --- .../added-activity-monitor-decision-trail.md | 1 + .../stage_tracker_operator_action.test.js | 130 ++++++++++++++++++ src/pkg/dashboard/static/components.css | 11 ++ src/pkg/dashboard/static/index.html | 90 +++++++++++- 4 files changed, 225 insertions(+), 7 deletions(-) create mode 100644 changelog.d/added-activity-monitor-decision-trail.md create mode 100644 src/pkg/dashboard/stage_tracker_operator_action.test.js diff --git a/changelog.d/added-activity-monitor-decision-trail.md b/changelog.d/added-activity-monitor-decision-trail.md new file mode 100644 index 0000000000..5d53b77597 --- /dev/null +++ b/changelog.d/added-activity-monitor-decision-trail.md @@ -0,0 +1 @@ +- Activity Monitor rows with a recorded operator action show a persistent, keyboard-focusable ✓ decision trail, turn amber after 30 minutes without a stage change, and can be filtered by awaiting a decision, acted, or acted and still stuck. diff --git a/src/pkg/dashboard/stage_tracker_operator_action.test.js b/src/pkg/dashboard/stage_tracker_operator_action.test.js new file mode 100644 index 0000000000..bfaaf19e14 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_operator_action.test.js @@ -0,0 +1,130 @@ +// Exercise the shipped pure helpers, without a browser or server ledger. +const test = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); +const html = fs.readFileSync(path.join(__dirname, 'static/index.html'), 'utf8'); +const css = fs.readFileSync(path.join(__dirname, 'static/components.css'), 'utf8'); +function pick(name) { + const match = html.match(new RegExp('function ' + name + '\\([^]*?\\n \\}\\n')); + assert.ok(match, name + ' missing'); + return match[0]; +} +const names = ['stageTrackerOperatorStuck', 'stageTrackerDecisionMatches', 'stageTrackerOperatorStage', + 'stageTrackerOperatorTooltip', 'stageTrackerOperatorBadgeHtml', 'stageTrackerOperatorPRBadge', + 'stageTrackerHeadline', 'stageTrackerHoldLabels', 'stageTrackerSoakLeft', 'stageTrackerHumanMergeReasonWord']; +const esc = text => String(text).replace(/&/g, '&').replace(/"/g, '"').replace(//g, '>'); +const constant = html.match(/const STAGE_TRACKER_OPERATOR_STUCK_MS = [^;]+;/); +assert.ok(constant); +const helpers = new Function('esc', constant[0] + '\n' + names.map(pick).join('\n') + '\nreturn {' + names.join(',') + '};')(esc); +const { stageTrackerOperatorTooltip: tooltip, stageTrackerOperatorStuck: stuck, + stageTrackerDecisionMatches: matches, stageTrackerOperatorBadgeHtml: badge, + stageTrackerOperatorPRBadge: prBadge } = helpers; +const now = Date.parse('2026-10-28T16:00:00Z'); +function item(minutes = 12, stage = 85, action = {}) { + return { stage, caption: 'Waiting for an approval', last_operator_action: { + action: 'decide:approve', at: new Date(now - minutes * 60000).toISOString(), stage: 85, outcome: 'ok', ...action, + } }; +} + +test('decision trail orders waiting, choice/time, then hive result in human words', () => { + assert.equal(tooltip(item(), now), 'Waiting on: Needs a human decision. You chose: Approve, 12 min ago. Hive: action recorded; waiting for progress.'); + assert.equal(tooltip({}, now), ''); + assert.equal(tooltip(null, now), ''); + assert.doesNotMatch(tooltip(item(), now), /stage\/|085|decide:/); +}); + +test('moved-on receipt persists, without an amber warning', () => { + const moved = item(90, 110); + assert.match(tooltip(moved, now), /Addressed — now at Merged/); + assert.equal(stuck(moved, now), false); + assert.match(badge(moved, now), />✓<\/span>/); + assert.doesNotMatch(badge(moved, now), /ham-operator-stuck/); +}); + +test('amber uses a strict single threshold and human caption, not a reason token', () => { + assert.equal(stuck(item(30), now), false); + assert.equal(stuck(item(30), now + 1), true); + const delayed = { ...item(42), caption: 'Approval recorded\nwaiting for review', reason: 'raw-stage-token' }; + assert.match(tooltip(delayed, now), /Still at Needs a human decision 42 min after you asked — hive says: Approval recorded waiting for review\./); + assert.doesNotMatch(tooltip(delayed, now), /\n|raw-stage-token/); + assert.match(badge(delayed, now), /ham-operator-stuck/); + assert.match(tooltip({ ...item(42), caption: '' }, now), /no further progress reported/); +}); + +test('failed outcomes and malformed timestamps are honest, single-line copy', () => { + assert.match(tooltip(item(42, 85, { outcome: 'Permission denied\nPlease sign in' }), now), /Hive: action failed: Permission denied Please sign in\./); + const invalid = item(42, 85, { at: 'not-a-time' }); + assert.equal(stuck(invalid, now), false); + assert.match(tooltip(invalid, now), /time unavailable/); + assert.equal(stuck(item(42, 85, { stage: undefined }), now), false); + assert.equal(stuck(item(-5), now), false); + assert.equal(stuck({}, now), false); +}); + +test('all submitted actions receive plain labels', () => { + for (const action of ['hold', 'release', 'retry', 'needs-human', 'accept-triage', 'decide:delegate', + 'decide:direction', 'decide:close-superseded', 'decide:close-wontfix']) { + assert.doesNotMatch(tooltip(item(12, 85, { action }), now), /Submit an action|decide:/); + } +}); + +test('decision buckets share the badge predicate and distinguish acted from awaiting', () => { + for (const stage of [15, 17, 45, 85, 90]) assert.equal(matches({ stage }, 'awaiting', now), true); + assert.equal(matches({ stage: 50, modifiers: ['needs-decision'] }, 'awaiting', now), true); + assert.equal(matches({ stage: 50 }, 'awaiting', now), false); + assert.equal(matches(item(), 'awaiting', now), false); + assert.equal(matches({}, 'acted', now), false); + assert.equal(matches({}, 'stuck', now), false); + for (const row of [item(), item(42), item(42, 110)]) { + assert.equal(matches(row, 'acted', now), true); + assert.equal(matches(row, 'stuck', now), stuck(row, now)); + } +}); + +test('badge is focusable, escaped, and absent for legacy payloads', () => { + assert.equal(badge({}, now), ''); + const row = item(42, 85, { outcome: ' "try again"' }); + const rendered = badge(row, now); + const tip = esc(tooltip(row, now)); + assert.ok(rendered.includes('title="' + tip + '" aria-label="' + tip + '"')); + assert.match(rendered, /tabindex="0"/); + assert.doesNotMatch(rendered, /|style=|animation|blink/); + assert.match(css, /\.ham-badge\.ham-operator-stuck\s*\{ color: var\(--amber\); \}/); +}); + +test('nested PR receipts use the full tracker item, not an issue action', () => { + const pr = item(42); + const ctx = { operatorItems: new Map([['org/repo/pr#7', pr]]) }; + assert.equal(prBadge({ number: 7 }, { repo: 'org/repo' }, now, ctx), badge(pr, now)); + assert.equal(prBadge({ number: 8 }, { repo: 'org/repo', ...item() }, now, ctx), ''); + assert.ok(pick('stageTrackerSubRowHtml').includes('stageTrackerOperatorPRBadge')); + const row = pick('stageTrackerRowHtml'); + assert.ok(row.includes('stageTrackerOperatorPRBadge')); + assert.equal((row.match(/stageTrackerOperatorBadgeHtml\(item, nowMs\)/g) || []).length, 3); +}); + +test('quiet payloads re-render once a minute so amber and the stuck filter age without a new response', () => { + let clock = now; + let renders = 0; + const tick = new Function('_stageTracker', 'Date', 'renderStageTracker', 'document', + 'let _stageTrackerOperatorMinute = -1;\n' + pick('stageTrackerTickClock') + '\nreturn stageTrackerTickClock;')( + { items: [item()] }, { now: () => clock }, () => renders++, { querySelector: () => null }); + tick(); + tick(); + assert.equal(renders, 1); + clock += 60000; + tick(); + assert.equal(renders, 2); +}); + +test('decision filter is normalized, saved with other filters, synced and reset', () => { + assert.match(pick('stageTrackerDefaultFilter'), /decision: ''/); + assert.match(pick('stageTrackerNormalizeFilter'), /\['', 'awaiting', 'acted', 'stuck'\]/); + assert.match(pick('stageTrackerFilterActive'), /!!f\.decision/); + assert.match(pick('stageTrackerMatches'), /stageTrackerDecisionMatches\(item, f\.decision/); + assert.match(pick('hamFilter'), /case 'decision': f\.decision = f\.decision === value \? '' : value/); + assert.match(pick('hamFilter'), /stageTrackerSaveFilter\(\)/); + assert.match(pick('stageTrackerSaveFilter'), /localStorage\.setItem/); + assert.match(pick('stageTrackerSyncToolbar'), /b\.dataset\.arg1 === f\.decision/); +}); diff --git a/src/pkg/dashboard/static/components.css b/src/pkg/dashboard/static/components.css index bf89bb2604..a631ab2e82 100644 --- a/src/pkg/dashboard/static/components.css +++ b/src/pkg/dashboard/static/components.css @@ -826,3 +826,14 @@ a.nav-chip:active, .py-1-px-4 { padding: var(--sp-1) var(--sp-4); } .py-2-px-4 { padding: var(--sp-2) var(--sp-4); } .d-block { display: block; } + +/* Persistent decision receipt, separate from the progress arrow's motion. */ +.ham-badge.ham-operator-badge { + color: var(--green); + border-color: currentColor; +} +.ham-badge.ham-operator-stuck { color: var(--amber); } +.ham-operator-badge:focus-visible { + outline: var(--focus-ring-width) solid color-mix(in srgb, var(--brand) var(--component-border-emphasis), transparent); + outline-offset: var(--focus-ring-offset); +} diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 4f4f30a64e..14f024554b 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -7182,6 +7182,12 @@

Hive activity moni + + Decisions + + + + @@ -7190,6 +7196,7 @@

Hive activity moni Merged today: 0 +

✓ Addressed: an operator chose an action; focus the badge for the decision trail. Amber ✓: still on the same step after 30 minutes. The moving indicator on the progress arrow means work is in flight, not that a decision was recorded.

@@ -14071,7 +14078,7 @@

Where to get help

var _stageTrackerGroup = STAGE_TRACKER_GROUP_DEFAULT; var _stageTrackerCollapsed = {}; function stageTrackerDefaultFilter() { - return { kind: 'all', repo: '', q: '', labels: [], needsHuman: false, onHold: false, age: 'any', author: 'any', attention: false, sort: 'furthest', dir: 'desc', size: STAGE_TRACKER_DEFAULT_PAGE_SIZE, page: 1 }; + return { kind: 'all', repo: '', q: '', labels: [], needsHuman: false, onHold: false, decision: '', age: 'any', author: 'any', attention: false, sort: 'furthest', dir: 'desc', size: STAGE_TRACKER_DEFAULT_PAGE_SIZE, page: 1 }; } var _stageTrackerFilter = stageTrackerDefaultFilter(); // Type-to-filter text of the "all labels" dialog (not persisted). @@ -14115,6 +14122,64 @@

Where to get help

} } + // One clock/predicate for both the persistent badge and Decisions filter. + const STAGE_TRACKER_OPERATOR_STUCK_MS = 30 * 60 * 1000; + var _stageTrackerOperatorMinute = -1; + function stageTrackerOperatorStuck(item, nowMs) { + const action = item && item.last_operator_action; + const at = action && Date.parse(action.at); + return !!action && action.stage != null && item.stage != null && Number(action.stage) === Number(item.stage) && + Number.isFinite(at) && nowMs - at > STAGE_TRACKER_OPERATOR_STUCK_MS; + } + function stageTrackerDecisionMatches(item, bucket, nowMs) { + const acted = !!item.last_operator_action; + if (bucket === 'acted') return acted; + if (bucket === 'stuck') return stageTrackerOperatorStuck(item, nowMs); + if (bucket !== 'awaiting') return true; + const mods = Array.isArray(item.modifiers) ? item.modifiers : []; + return !acted && (!!item.superseded || [15, 17, 45, 85, 90].includes(Number(item.stage)) || + mods.some(m => ['needs-human', 'needs-decision', 'needs-triage', 'possible-dupe'].includes(m))); + } + function stageTrackerOperatorStage(stage) { + // Reuse the row's human headline, not a stage/NNN label or reason token. + return stageTrackerHeadline({ stage: Number(stage) || 0 }); + } + function stageTrackerOperatorTooltip(item, nowMs) { + const action = item && item.last_operator_action; + if (!action) return ''; + const words = text => String(text || '').replace(/\s+/g, ' ').trim(); + const labels = { hold: 'Hold', release: 'Release hold', retry: 'Re-evaluate now', 'needs-human': 'Ask a human', + 'accept-triage': 'Accept triage', 'decide:approve': 'Approve', 'decide:delegate': 'Let hive decide', + 'decide:direction': 'Give direction', 'decide:close-superseded': 'Close as superseded', + 'decide:close-wontfix': "Close as won't-fix" }; + const chosen = labels[action.action] || 'Submit an action'; + const at = Date.parse(action.at); + const minutes = Number.isFinite(at) ? Math.max(0, Math.floor((nowMs - at) / 60000)) : null; + const when = minutes === null ? 'time unavailable' : minutes + ' min ago'; + const current = stageTrackerOperatorStage(item.stage); + const previous = action.stage == null ? 'the current step' : stageTrackerOperatorStage(action.stage); + const moved = action.stage != null && item.stage != null && Number(action.stage) !== Number(item.stage); + const failed = action.outcome && action.outcome !== 'ok'; + const next = failed ? 'action failed: ' + words(action.outcome) : moved ? 'Addressed — now at ' + current : 'action recorded; waiting for progress'; + let tip = 'Waiting on: ' + previous + '. You chose: ' + chosen + ', ' + when + '. Hive: ' + next + '.'; + if (stageTrackerOperatorStuck(item, nowMs)) { + // Caption is already human copy; never expose the raw reason token. + const reason = failed ? words(action.outcome) : words(item.caption) || 'no further progress reported'; + tip += ' Still at ' + current + ' ' + minutes + ' min after you asked — hive says: ' + reason + '.'; + } + return tip; + } + function stageTrackerOperatorBadgeHtml(item, nowMs) { + if (!item || !item.last_operator_action) return ''; + const tip = esc(stageTrackerOperatorTooltip(item, nowMs)); + return `✓`; + } + function stageTrackerOperatorPRBadge(lp, issue, nowMs, ctx) { + const key = (issue.repo || '') + '/pr#' + lp.number; + const item = ctx && ctx.operatorItems && ctx.operatorItems.get(key); + return stageTrackerOperatorBadgeHtml(item || lp, nowMs); + } + // " — Xm left" for a 095 row whose payload carries the soak remaining. function stageTrackerSoakLeft(item) { const sec = Number(item.soak_remaining_seconds) || 0; @@ -14614,6 +14679,7 @@

Where to get help

stage: lp.stage || 0, stage_since: lp.stage_since || '', modifiers: lp.modifiers || [], deferred_modifiers: lp.deferred_modifiers || [], caption: lp.caption || '', reason: lp.reason || '', human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', decision_needed: lp.decision_needed || null }; let ref = stageTrackerPRRef(pr.number, pr.url, pr.author_kind, pr.author, pr.title, (pr.title ? pr.title + ' · ' : '') + stageTrackerTooltip(pr, nowMs) + ' · ' + stageTrackerLinkedTip(issue, pr.number, ctx)); + ref += stageTrackerOperatorPRBadge(lp, issue, nowMs, ctx); if (lp.base_ref) ref += ` ${esc(lp.base_ref)}`; const chip = ctx && ctx.repoChips ? stageTrackerRepoChipHtml(pr.repo, ctx) : ''; if (chip) ref = `${chip}${ref}`; @@ -14790,7 +14856,7 @@

Where to get help

// One covering PR: a single entry whose strip the PR's stage drives. const lp = linked[0]; const who = (lp.author_kind || 'hive') + (lp.author ? ' · @' + lp.author : ''); - prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)) + (lp.base_ref ? ` ${esc(lp.base_ref)}` : '')]; + prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)) + stageTrackerOperatorPRBadge(lp, item, nowMs, ctx) + (lp.base_ref ? ` ${esc(lp.base_ref)}` : '')]; shown = Object.assign({}, item, { via_pr: true, stage: lp.stage || 40, stage_since: lp.stage_since || item.stage_since, modifiers: lp.modifiers || item.modifiers, deferred_modifiers: lp.deferred_modifiers || item.deferred_modifiers || [], caption: lp.caption || item.caption, reason: lp.reason || item.reason, human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', decision_needed: lp.decision_needed || null }); } else if (linked.length) { @@ -14815,7 +14881,7 @@

Where to get help

if (isIssue) { leadHtml = `
${stageTrackerIcon('issue', 'ham-kind-ico')}${chip} - #${Number(item.number) || 0} + #${Number(item.number) || 0}${stageTrackerOperatorBadgeHtml(item, nowMs)} ${esc(title)} ${item.claim_reference ? `refs` : ''} ${item.is_tracker ? `tracker${item.children && item.children.total ? ' ' + Number(item.children.completed) + '/' + Number(item.children.total) : ''}` : ''} @@ -14833,13 +14899,13 @@

Where to get help

const ak = item.author_kind || 'hive'; leadHtml = ``; } else { const li = stageTrackerPRIssueSlot(item); - prRefs = [stageTrackerPRRef(item.number, item.url, item.author_kind || '', item.author, title, (title ? title + ' · ' : '') + stageTrackerTooltip(shown, nowMs))]; + prRefs = [stageTrackerPRRef(item.number, item.url, item.author_kind || '', item.author, title, (title ? title + ' · ' : '') + stageTrackerTooltip(shown, nowMs)) + stageTrackerOperatorBadgeHtml(item, nowMs)]; leadHtml = li.number ? `
${stageTrackerIcon('issue', 'ham-kind-ico')}${chip} @@ -15511,6 +15577,7 @@

Where to get help

f.labels = Array.isArray(f.labels) ? f.labels.filter(l => typeof l === 'string' && l).map(l => l.toLowerCase()) : []; f.needsHuman = !!f.needsHuman; f.onHold = !!f.onHold; + if (!['', 'awaiting', 'acted', 'stuck'].includes(f.decision)) f.decision = ''; if (!(f.age in STAGE_TRACKER_AGE_MS) && f.age !== 'stale') f.age = 'any'; if (['human', 'clanker', 'hive'].indexOf(f.author) < 0) f.author = 'any'; f.attention = !!f.attention; @@ -15523,7 +15590,7 @@

Where to get help

// True when any narrowing filter (not sort / paging) is set. function stageTrackerFilterActive(f) { - return f.kind !== 'all' || !!f.repo || !!f.q || f.labels.length > 0 || f.needsHuman || f.onHold || f.age !== 'any' || f.author !== 'any' || f.attention; + return f.kind !== 'all' || !!f.repo || !!f.q || f.labels.length > 0 || f.needsHuman || f.onHold || !!f.decision || f.age !== 'any' || f.author !== 'any' || f.attention; } // Does one item pass the narrowing filters? ctx.nowMs anchors the age @@ -15549,6 +15616,7 @@

Where to get help

} if (f.needsHuman && !stageTrackerItemNeedsHuman(item)) return false; if (f.onHold && !stageTrackerItemOnHold(item)) return false; + if (!stageTrackerDecisionMatches(item, f.decision, Number(ctx.nowMs) || Date.now())) return false; if (f.author !== 'any' && (item.author_kind || '') !== f.author) return false; if (f.attention && !stageTrackerNeedsAttention(item)) return false; if (f.age !== 'any') { @@ -15765,6 +15833,7 @@

Where to get help

case 'q': f.q = value || ''; break; case 'age': f.age = value || 'any'; break; case 'author': f.author = value || 'any'; break; + case 'decision': f.decision = f.decision === value ? '' : value; break; case 'attention': f.attention = value === 'toggle' ? !f.attention : !!value; break; case 'sort': f.sort = value || 'furthest'; break; case 'dir': f.dir = value === 'toggle' ? (f.dir === 'asc' ? 'desc' : 'asc') : value; break; @@ -15787,6 +15856,7 @@

Where to get help

function stageTrackerSyncToolbar(f) { document.querySelectorAll('#activity-monitor-toolbar .ham-chip[data-arg0="kind"]').forEach(b => b.setAttribute('aria-pressed', b.dataset.arg1 === f.kind ? 'true' : 'false')); const setVal = (id, v) => { const el = document.getElementById(id); if (el && el.value !== String(v) && document.activeElement !== el) el.value = String(v); }; + document.querySelectorAll('#activity-monitor-toolbar .ham-chip[data-arg0="decision"]').forEach(b => b.setAttribute('aria-pressed', b.dataset.arg1 === f.decision ? 'true' : 'false')); setVal('activity-monitor-q', f.q); setVal('activity-monitor-age', f.age); setVal('activity-monitor-author', f.author); @@ -15926,6 +15996,12 @@

All labels

+ ''; } function stageTrackerTickClock() { + // A quiet/304 payload still ages into amber and into the stuck bucket. + const minute = Math.floor(Date.now() / 60000); + if (_stageTracker && Array.isArray(_stageTracker.items) && minute !== _stageTrackerOperatorMinute) { + _stageTrackerOperatorMinute = minute; + if (_stageTracker.items.some(it => it.last_operator_action)) renderStageTracker(); + } const el = document.querySelector('#activity-monitor-meta .ham-updated'); if (!el || !_stageTracker) return; const wrap = document.createElement('span'); @@ -15964,7 +16040,7 @@

All labels

if (sel.innerHTML !== want) sel.innerHTML = want; } stageTrackerSyncToolbar(f); - const ctx = { nowMs, stages, moves: _stageTrackerMoves }; + const ctx = { nowMs, stages, moves: _stageTrackerMoves, operatorItems: new Map(d.items.map(it => [stageTrackerItemKey(it), it])) }; ctx.workers = stageTrackerWorkers(window._lastStatus); ctx.events = _stageTrackerEvents; ctx.sharedPRs = stageTrackerSharedPRs(d.items); From ec7f111fa6fd49eed25948324dacefb744b9ab85 Mon Sep 17 00:00:00 2001 From: mendezr Date: Wed, 28 Oct 2026 16:46:23 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=90=9B=20fix:=20wire=20decision=20hel?= =?UTF-8?q?pers=20into=20activity=20monitor=20fixtures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Load the shipped operator receipt helpers in row and filter fixtures, update the motion context assertion, and cover decision filtering through stageTrackerVisible. Use the existing focus spacing token and sync the shared hub stylesheet. Signed-off-by: mendezr --- .../dashboard/stage_tracker_motion_test.go | 4 +++- .../stage_tracker_operator_action_test.go | 21 +++++++++++++++++++ .../stage_tracker_repo_grouping_test.go | 1 + src/pkg/dashboard/stage_tracker_ui_test.go | 14 +++++++++++++ src/pkg/dashboard/static/components.css | 2 +- src/pkg/hub/static/components.css | 11 ++++++++++ 6 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 src/pkg/dashboard/stage_tracker_operator_action_test.go diff --git a/src/pkg/dashboard/stage_tracker_motion_test.go b/src/pkg/dashboard/stage_tracker_motion_test.go index b6ec46ab7e..1710b1d71e 100644 --- a/src/pkg/dashboard/stage_tracker_motion_test.go +++ b/src/pkg/dashboard/stage_tracker_motion_test.go @@ -39,7 +39,7 @@ func TestStageTrackerMotionWiring(t *testing.T) { `function stageTrackerAnimateMoves(root)`, `function stageTrackerMotionEffect(setting, reduced)`, `stageTrackerNoteMerges(data); stageTrackerNoteOpened(data); stageTrackerNoteMoves(data); }`, - `const ctx = { nowMs, stages, moves: _stageTrackerMoves };`, + `const ctx = { nowMs, stages, moves: _stageTrackerMoves, operatorItems: new Map(d.items.map(it => [stageTrackerItemKey(it), it])) };`, `if (Object.keys(_stageTrackerMoves).length) { stageTrackerAnimateMoves(el); _stageTrackerMoves = {}; }`, `window.matchMedia('(prefers-reduced-motion: reduce)').matches`, `@media (prefers-reduced-motion: reduce) { .ham-anim-layer { display: none; } }`, @@ -454,6 +454,7 @@ func TestStageTrackerMotionRowStamp(t *testing.T) { jsFunc(t, html, "stageTrackerMoveAttrs"), jsFunc(t, html, "stageTrackerRefOf"), jsFunc(t, html, "stageTrackerRowToolsHtml"), + stageTrackerOperatorJS(t, html), jsFunc(t, html, "stageTrackerRowHtml"), jsFunc(t, html, "stageTrackerPRIssueSlot"), }, "\n") + ` @@ -572,6 +573,7 @@ func TestStageTrackerMotionPreviewSample(t *testing.T) { jsFunc(t, html, "stageTrackerShortAgo"), jsFunc(t, html, "stageTrackerRefOf"), jsFunc(t, html, "stageTrackerRowToolsHtml"), + stageTrackerOperatorJS(t, html), jsFunc(t, html, "stageTrackerRowHtml"), jsFunc(t, html, "stageTrackerPRIssueSlot"), jsFunc(t, html, "stageTrackerItemKey"), diff --git a/src/pkg/dashboard/stage_tracker_operator_action_test.go b/src/pkg/dashboard/stage_tracker_operator_action_test.go new file mode 100644 index 0000000000..e574b9e637 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_operator_action_test.go @@ -0,0 +1,21 @@ +package dashboard + +import ( + "strings" + "testing" +) + +// stageTrackerOperatorJS supplies the decision helpers used by both row +// rendering and filtering. Keep the fixtures on the shipped implementation. +func stageTrackerOperatorJS(t *testing.T, html string) string { + t.Helper() + return strings.Join([]string{ + jsConstLine(t, html, "STAGE_TRACKER_OPERATOR_STUCK_MS"), + jsFunc(t, html, "stageTrackerOperatorStuck"), + jsFunc(t, html, "stageTrackerDecisionMatches"), + jsFunc(t, html, "stageTrackerOperatorStage"), + jsFunc(t, html, "stageTrackerOperatorTooltip"), + jsFunc(t, html, "stageTrackerOperatorBadgeHtml"), + jsFunc(t, html, "stageTrackerOperatorPRBadge"), + }, "\n") +} diff --git a/src/pkg/dashboard/stage_tracker_repo_grouping_test.go b/src/pkg/dashboard/stage_tracker_repo_grouping_test.go index ff87da8b61..20f64fd9c7 100644 --- a/src/pkg/dashboard/stage_tracker_repo_grouping_test.go +++ b/src/pkg/dashboard/stage_tracker_repo_grouping_test.go @@ -124,6 +124,7 @@ func stageTrackerRepoGroupingHarness(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerLabelFamily"), jsFunc(t, html, "stageTrackerNormalizeFilter"), jsFunc(t, html, "stageTrackerFilterActive"), + stageTrackerOperatorJS(t, html), jsFunc(t, html, "stageTrackerMatches"), jsFunc(t, html, "stageTrackerSort"), jsFunc(t, html, "stageTrackerPage"), diff --git a/src/pkg/dashboard/stage_tracker_ui_test.go b/src/pkg/dashboard/stage_tracker_ui_test.go index 3b85b11118..f7ed9447c6 100644 --- a/src/pkg/dashboard/stage_tracker_ui_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_test.go @@ -131,6 +131,7 @@ func TestStageTrackerRows(t *testing.T) { jsFunc(t, html, "stageTrackerLabelDialogData"), jsFunc(t, html, "stageTrackerNormalizeFilter"), jsFunc(t, html, "stageTrackerFilterActive"), + stageTrackerOperatorJS(t, html), jsFunc(t, html, "stageTrackerMatches"), jsFunc(t, html, "stageTrackerSort"), jsFunc(t, html, "stageTrackerPage"), @@ -851,6 +852,7 @@ func TestStageTrackerFilterSortPage(t *testing.T) { jsFunc(t, html, "stageTrackerLabelDialogData"), jsFunc(t, html, "stageTrackerNormalizeFilter"), jsFunc(t, html, "stageTrackerFilterActive"), + stageTrackerOperatorJS(t, html), jsFunc(t, html, "stageTrackerMatches"), jsFunc(t, html, "stageTrackerVisible"), jsFunc(t, html, "stageTrackerRowCount"), @@ -915,6 +917,18 @@ assert.deepStrictEqual(nums(stageTrackerVisible(items, F({ attention: true }), c assert.deepStrictEqual(nums(stageTrackerVisible(items, F({ repo: 'a/c', kind: 'pr' }), ctx)), [4]); assert.deepStrictEqual(nums(stageTrackerVisible(items, F({ attention: true, author: 'human' }), ctx)), [], 'filters compose'); +// Decision filters run through the same shipped predicate as the row badge. +const decisions = [ + { kind: 'pr', repo: 'a/b', number: 30, stage: 85 }, + { kind: 'pr', repo: 'a/b', number: 31, stage: 85, last_operator_action: { stage: 85, at: ago(31 * 60000) } }, + { kind: 'pr', repo: 'a/b', number: 32, stage: 110, last_operator_action: { stage: 85, at: ago(H) } }, +]; +assert.deepStrictEqual(nums(stageTrackerVisible(decisions, F({ decision: 'awaiting' }), ctx)), [30]); +assert.deepStrictEqual(nums(stageTrackerVisible(decisions, F({ decision: 'acted' }), ctx)), [31, 32]); +assert.deepStrictEqual(nums(stageTrackerVisible(decisions, F({ decision: 'stuck' }), ctx)), [31]); +assert.strictEqual(stageTrackerFilterActive(F({ decision: 'acted' })), true); +assert.strictEqual(stageTrackerNormalizeFilter({ decision: 'bogus' }).decision, ''); + // A PR nested under a listed issue shares that issue's row; when a filter // (label chips, the Pull requests tab, …) drops the issue the PR must still // render as its own row — an item never disappears because its issue did. diff --git a/src/pkg/dashboard/static/components.css b/src/pkg/dashboard/static/components.css index a631ab2e82..e421e01a86 100644 --- a/src/pkg/dashboard/static/components.css +++ b/src/pkg/dashboard/static/components.css @@ -835,5 +835,5 @@ a.nav-chip:active, .ham-badge.ham-operator-stuck { color: var(--amber); } .ham-operator-badge:focus-visible { outline: var(--focus-ring-width) solid color-mix(in srgb, var(--brand) var(--component-border-emphasis), transparent); - outline-offset: var(--focus-ring-offset); + outline-offset: var(--sp-1); } diff --git a/src/pkg/hub/static/components.css b/src/pkg/hub/static/components.css index bf89bb2604..e421e01a86 100644 --- a/src/pkg/hub/static/components.css +++ b/src/pkg/hub/static/components.css @@ -826,3 +826,14 @@ a.nav-chip:active, .py-1-px-4 { padding: var(--sp-1) var(--sp-4); } .py-2-px-4 { padding: var(--sp-2) var(--sp-4); } .d-block { display: block; } + +/* Persistent decision receipt, separate from the progress arrow's motion. */ +.ham-badge.ham-operator-badge { + color: var(--green); + border-color: currentColor; +} +.ham-badge.ham-operator-stuck { color: var(--amber); } +.ham-operator-badge:focus-visible { + outline: var(--focus-ring-width) solid color-mix(in srgb, var(--brand) var(--component-border-emphasis), transparent); + outline-offset: var(--sp-1); +} From dec5a812a792ecb217fcd964a0ac2b56d9187b1a Mon Sep 17 00:00:00 2001 From: architect <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Wed, 28 Oct 2026 13:30:42 -0400 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=90=9B=20fix:=20run=20activity=20moni?= =?UTF-8?q?tor=20node=20fixtures=20from=20a=20temp=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hive-Fix-Attempt: 1/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: architect <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- src/pkg/dashboard/stage_tracker_ui_test.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/pkg/dashboard/stage_tracker_ui_test.go b/src/pkg/dashboard/stage_tracker_ui_test.go index f7ed9447c6..3cb9e952f1 100644 --- a/src/pkg/dashboard/stage_tracker_ui_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_test.go @@ -1,7 +1,9 @@ package dashboard import ( + "os" "os/exec" + "path/filepath" "strings" "testing" ) @@ -788,10 +790,7 @@ assert.ok(/[^<]*<\/span>/.test(row) && !/ row = stageTrackerRowHtml({ repo: 'acme/console', number: 106, kind: 'pr', stage: 110 }, stages, ctx); assert.ok(/
  • /.test(row) && titled(strip(row)).length === 1, row); ` - // Over stdin: the lifted fixture exceeds Linux's per-argument limit. - cmd := exec.Command(node, "-") - cmd.Stdin = strings.NewReader(script) - if out, err := cmd.CombinedOutput(); err != nil { + if out, err := runNodeScript(t, node, script); err != nil { t.Fatalf("node Hive activity monitor fixture failed: %v\n%s", err, out) } } @@ -1046,8 +1045,18 @@ assert.strictEqual(stageTrackerNormalizeFilter({ needsHuman: 'yes' }).needsHuman assert.strictEqual(stageTrackerNormalizeFilter({ onHold: 1 }).onHold, true); assert.strictEqual(stageTrackerLabelDialogData(stageTrackerLabelFacets(parked, F({ needsHuman: true, onHold: true }))).selected, 2); ` - cmd := exec.Command(node, "-e", script) - if out, err := cmd.CombinedOutput(); err != nil { + if out, err := runNodeScript(t, node, script); err != nil { t.Fatalf("node Hive activity monitor fixture failed: %v\n%s", err, out) } } + +// runNodeScript runs script from a temp file: a large fixture passed via +// `node -e` can exceed the Linux single-argument limit (128KiB). +func runNodeScript(t *testing.T, node, script string) ([]byte, error) { + t.Helper() + path := filepath.Join(t.TempDir(), "fixture.js") + if err := os.WriteFile(path, []byte(script), 0o600); err != nil { + t.Fatal(err) + } + return exec.Command(node, path).CombinedOutput() +}