From 328c6dc447aa6203c516ce347086fefa7e221815 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Wed, 4 Nov 2026 12:48:00 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Activity=20Monitor:=20render=20a?= =?UTF-8?q?t=20most=20one=20hive=20note=20line=20per=20row?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A row stacked its "Needs human: …" line over the "Hive: moved to …" stage note. Rank every candidate — needs-human / decision > blocker > next move / claim > optional delegation > stage note — and render the winner alone on issue rows and PR sub-rows. A lower note's facts ride the winning line as a trailing clause only when they add something the row does not already say; a stage note that merely restates the lit chevron is dropped. The single line keeps its ⬡ icon, View link and one age. Fixes #16627 Signed-off-by: Andrew Anderson --- changelog.d/fixed-single-hive-note-line.md | 1 + .../stage_tracker_human_attention.test.js | 10 +- .../stage_tracker_single_note.test.js | 158 ++++++++++++++++++ .../static-src/js/tracker-human-attention.js | 103 ++++++++++-- .../static-src/js/tracker-row-layout.js | 5 +- .../static-src/js/tracker-row-render.js | 7 +- src/pkg/dashboard/static/index.html | 115 +++++++++++-- 7 files changed, 366 insertions(+), 33 deletions(-) create mode 100644 changelog.d/fixed-single-hive-note-line.md create mode 100644 src/pkg/dashboard/stage_tracker_single_note.test.js diff --git a/changelog.d/fixed-single-hive-note-line.md b/changelog.d/fixed-single-hive-note-line.md new file mode 100644 index 0000000000..b0978c77ac --- /dev/null +++ b/changelog.d/fixed-single-hive-note-line.md @@ -0,0 +1 @@ +- Activity Monitor: a tracker row (issue row or PR sub-row) now renders at most one hive note line. The needs-human / decision ask outranks the blocker, next-move and stage-transition notes; a lower note's facts ride the winning line as a trailing clause only when they say something the row does not already (a "moved to Needs human decision" note under a strip already lit at Needs human decision is dropped). The single line keeps its ⬡ icon, View link and one relative age ([#16627](https://github.com/hivecommons/hive/issues/16627)). diff --git a/src/pkg/dashboard/stage_tracker_human_attention.test.js b/src/pkg/dashboard/stage_tracker_human_attention.test.js index c70e5660b8..31a3812cf3 100644 --- a/src/pkg/dashboard/stage_tracker_human_attention.test.js +++ b/src/pkg/dashboard/stage_tracker_human_attention.test.js @@ -32,7 +32,7 @@ function load() { stageTrackerChipsHtml: () => '', stageTrackerMoveAttrs: () => '', stageTrackerSinceHtml: () => '', stageTrackerStripItems: it => `
  • `, stageTrackerCurrentStageHtml: it => `${it.stage}`, - stageTrackerEventHtml: (key, ctx) => `

    ${esc(ctx && ctx.note || 'live note')}

    `, + stageTrackerEventHtml: (key, ctx) => ctx && ctx.events && ctx.events[key] ? `

    Hive: ${esc(ctx.events[key].text)}

    ` : '', stageTrackerActionCtx: () => ({ user: 'viewer' }), stageTrackerLeadActionOnRow: item => item.optionalAction ? { id: 'decide:delegate', label: 'Let hive decide' } : null, }); @@ -59,12 +59,16 @@ function issue(linked) { test('covered issue shows the exact PR requirement/requester in visible prose without overriding its actual stage', () => { const c = load(), child = pr(), item = issue([child]), before = plain(item); - const html = c.stageTrackerRowHtml(item, [], { nowMs: 1, note: 'review comment' }); + const html = c.stageTrackerRowHtml(item, [], { nowMs: 1, events: { 'hivecommons/hive/issue#15937': { who: 'hive', text: 'review comment', at: 1 } } }); assert.match(html, /data-ham-kind="issue".*data-ham-stage="40"/); assert.match(html, /data-stage="85"/); assert.match(html, /PR #15985 — Needs human: Confirm the compatibility policy · next move: @maintainer · requested by a reviewer/); assert.match(html, />View PR #15985<\/a>/); - assert.match(html, /cue-event-tuckable.*data-cue-key=.*review comment.*Reopen/); + // One note line: the hive's stage note rides the human line as a + // trailing clause instead of a second "Hive: …" line. + assert.equal((html.match(/class="cue-event/g) || []).length, 1); + assert.match(html, /requested by a reviewer ]*>View PR #15985<\/a> · review comment/); + assert.doesNotMatch(html, /Hive: review comment/); assert.doesNotMatch(html, /Needs you|ham-preparation-head|
    blocker > next move > stage note, with the +// loser's facts folded in only when they add something the row does not +// already say. Runs the shipped tracker-motion + tracker-human-attention +// sources so the real tuckable line (⬡ icon, View link, one age) is what +// is asserted. +const test = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); +const vm = require('node:vm'); +const source = name => fs.readFileSync(path.join(__dirname, 'static-src/js', name + '.js'), 'utf8'); +const fn = (file, name) => { + const text = source(file); + const match = text.match(new RegExp('function ' + name + '\\([^\\n]*\\) \\{[^\\n]*\\}\\s*(?:\\n|$)')) + || text.match(new RegExp('function ' + name + '\\([^\\n]*\\) \\{[\\s\\S]*?\\n \\}')); + assert.ok(match, name); + return match[0]; +}; +const esc = value => String(value).replace(/[&<>"']/g, ch => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[ch])); +const STAGES = [ + { number: 40, label: 'stage/040-covered-by-pr', short: 'Covered by PR' }, + { number: 50, label: 'stage/050-ci-review', short: 'CI / Review' }, + { number: 85, label: 'stage/085-needs-human-decision', short: 'Needs human decision' }, +]; +function load() { + const c = vm.createContext({ Date, esc, console, + document: { hidden: false, getElementById: () => null }, + localStorage: { getItem: () => null, setItem: () => {} }, + setTimeout: () => 0, clearTimeout: () => {}, + dashboardSetInterval: () => 0, + STAGE_TRACKER_TERMINAL: 100, STAGE_TRACKER_PR_COLUMN: 40, + STAGE_TRACKER_PATH: [0, 10, 20, 40, 50, 80], + STAGE_TRACKER_LINKED_GLYPH: '↳', STAGE_TRACKER_SOFT_LINK_TIP: 'refs', + stageTrackerAnchor: n => Number(n) || 0, + stageTrackerAttentionTier: () => 1, + stageTrackerLeadStage: lp => lp.stage || 40, + stageTrackerIcon: (kind, cls) => ``, + stageTrackerPRRef: (n, url) => `#${n}`, + stageTrackerPRPillsHtml: ref => ref, + stageTrackerTitleHtml: text => `${esc(text)}`, + stageTrackerTooltip: it => it.caption || '', + stageTrackerLinkedTip: () => '', + stageTrackerActedBadgeHtml: () => '', stageTrackerRowToolsHtml: () => '', + stageTrackerChipsHtml: () => '', stageTrackerMoveAttrs: () => '', stageTrackerSinceHtml: () => '', + stageTrackerStripItems: it => `
  • `, + stageTrackerCurrentStageHtml: it => `

    ${esc((STAGES.find(s => s.number === Number(it.stage)) || {}).short || it.stage)}

    `, + stageTrackerActionCtx: () => ({ user: 'viewer' }), + stageTrackerLeadActionOnRow: () => null, + }); + vm.runInContext(fn('tracker-words-stage', 'stageTrackerStageName'), c); + for (const name of ['stageTrackerLinkedSuperseder', 'stageTrackerLinkedSupersededGone', 'stageTrackerLinkedSupersededText', 'stageTrackerLinkedSupersededTip']) vm.runInContext(fn('tracker-words-gate', name), c); + for (const name of ['stageTrackerItemKey', 'stageTrackerPRKey', 'stageTrackerRowPRKeys']) vm.runInContext(fn('tracker-merged', name), c); + for (const name of ['stageTrackerLinkedPRItem', 'stageTrackerLinkedPROpen', 'stageTrackerLinkedDrawnHere', 'stageTrackerLinkedSorted', 'stageTrackerHeadColsHtml', 'stageTrackerSubRowHtml']) vm.runInContext(fn('tracker-row-layout', name), c); + vm.runInContext(fn('tracker-row-render', 'stageTrackerRowHtml'), c); + vm.runInContext(fn('tracker-filter', 'stageTrackerPRIssueSlot'), c); + vm.runInContext(source('tracker-motion'), c); + vm.runInContext(source('tracker-human-attention'), c); + // Row chrome outside the note line is not under test. + vm.runInContext('stageTrackerCueClasses = () => ""; stageTrackerCueLineHtml = () => "";', c); + return c; +} +const NOW = 1_700_000_000_000; +const lines = html => html.match(/

    ]*>[\s\S]*?<\/p>/g) || []; +const ages = html => (html.match(/cue-event-age" data-at="(\d+)"/g) || []).length; + +// The screenshot: the reviewer's ask on the row plus the stage note that +// landed 3 min earlier, under a strip lit at Needs human decision. +function screenshotRow() { + const pr = { kind: 'pr', repo: 'hivecommons/hive', number: 16619, stage: 85, state: 'open', head: 'h16619', + url: 'https://github.com/hivecommons/hive/pull/16619', title: 'fix', base_ref: 'v5', + human_attention: { kind: 'pr', number: 16619, head: 'h16619', asked_by: 'a reviewer', + reason: '@clubanderson should decide whether #16619 or your own #16622 lands for #16617 — both close the same issue' }, + stage_actor: { kind: 'human', login: 'clubanderson', why: 'decide which PR lands' } }; + const item = { kind: 'issue', repo: 'hivecommons/hive', number: 16617, stage: 85, mirrored: true, linked_pr: 16619, + title: 'Fleet relaunch', linked_prs: [pr], url: 'https://github.com/hivecommons/hive/issues/16617', stage_actor: pr.stage_actor }; + const events = { 'hivecommons/hive/issue#16617': { who: 'hive', text: 'moved to Needs human decision', at: NOW - 180000, openAt: NOW - 180000 } }; + return { item, events }; +} + +test('needs-human ask + stage note → one line, the chevron restatement dropped, View PR and one age kept', () => { + const c = load(), { item, events } = screenshotRow(); + const html = c.stageTrackerRowHtml(item, STAGES, { nowMs: NOW, events, noteTuck: true }); + const found = lines(html); + assert.equal(found.length, 1, html); + const line = found[0]; + assert.match(line, /ham-human-context/); + assert.match(line, /cue-event-ico/, 'keeps its ⬡ icon'); + assert.match(line, /Needs human: @clubanderson should decide whether #16619 or your own #16622 lands for #16617/); + assert.match(line, /· requested by a reviewer ]*>View PR #16619<\/a>/); + assert.doesNotMatch(line, /moved to Needs human decision/, 'the lit chevron already reads Needs human decision'); + assert.doesNotMatch(html, /cue-event-who/, 'no second "Hive:" line'); + assert.equal(ages(line), 1, 'one relative timestamp'); +}); + +test('a stage note that says more than the chevron rides the human line as a trailing clause', () => { + const c = load(), { item, events } = screenshotRow(); + events['hivecommons/hive/issue#16617'].text = 'fell back to Needs human decision — reviewers split on the approach'; + const html = c.stageTrackerRowHtml(item, STAGES, { nowMs: NOW, events, noteTuck: true }); + const found = lines(html); + assert.equal(found.length, 1); + assert.match(found[0], /View PR #16619<\/a> · fell back to Needs human decision — reviewers split on the approach/); + assert.equal(ages(found[0]), 1); +}); + +test('a row with only a stage note still shows exactly one line, the hive note itself', () => { + const c = load(); + const item = { kind: 'issue', repo: 'hivecommons/hive', number: 16630, stage: 50, title: 'solo', state: 'open', + url: 'https://github.com/hivecommons/hive/issues/16630', linked_prs: [], stage_actor: { kind: 'hive' } }; + const events = { 'hivecommons/hive/issue#16630': { who: 'hive', text: 'moved to CI / Review', at: NOW - 5000 } }; + const html = c.stageTrackerRowHtml(item, STAGES, { nowMs: NOW, events, noteTuck: true }); + const found = lines(html); + assert.equal(found.length, 1, html); + assert.match(found[0], /cue-event-who">Hive:<\/span> moved to CI \/ Review/); + assert.doesNotMatch(html, /ham-human-context/); +}); + +test('remediation next move + stage note → one line with the move first and the note folded', () => { + const c = load(); + const item = { kind: 'pr', repo: 'hivecommons/hive', number: 16640, stage: 50, state: 'open', head: 'h', title: 'pr', + url: 'https://github.com/hivecommons/hive/pull/16640', base_ref: 'v5', + stage_actor: { kind: 'human', login: 'author', why: '@author must push a fix; the hive does not edit a person’s PR' } }; + const events = { 'hivecommons/hive/pr#16640': { who: 'hive', text: 'needs a rebase', at: NOW - 60000 } }; + const html = c.stageTrackerRowHtml(item, STAGES, { nowMs: NOW, events, noteTuck: true }); + const found = lines(html); + assert.equal(found.length, 1, html); + assert.match(found[0], /Next move: @author — @author must push a fix; the hive does not edit a person’s PR · needs a rebase/); + assert.doesNotMatch(html, /cue-event-who/); + assert.equal(ages(found[0]), 1); +}); + +test('PR sub-rows under an issue follow the same one-line rule', () => { + const c = load(), { item, events } = screenshotRow(); + // Two covering PRs: the asking one is drawn as a sub-row with its own note. + const other = { kind: 'pr', repo: 'hivecommons/hive', number: 16622, stage: 50, state: 'open', head: 'h2', title: 'mine', + url: 'https://github.com/hivecommons/hive/pull/16622', base_ref: 'v5', stage_actor: { kind: 'hive' } }; + item.linked_prs.push(other); item.mirrored = false; item.stage = 40; + events['hivecommons/hive/pr#16619'] = { who: 'hive', text: 'moved to Needs human decision', at: NOW - 180000 }; + const html = c.stageTrackerRowHtml(item, STAGES, { nowMs: NOW, events, noteTuck: true }); + const sub = html.slice(html.indexOf('data-ham-sub-key="hivecommons/hive/pr#16619"'), html.indexOf('data-ham-sub-key="hivecommons/hive/pr#16622"')); + const found = lines(sub); + assert.equal(found.length, 1, sub); + assert.match(found[0], /Needs human: @clubanderson should decide/); + assert.doesNotMatch(found[0], /moved to Needs human decision/); +}); + +test('stage-note fold rules: restatements of the line or the lit chevron are dropped, new facts kept', () => { + const c = load(); + const item = { kind: 'pr', number: 1, repo: 'r', stage: 85 }; + assert.equal(c.stageTrackerNoteFoldText('moved to Needs human decision', 'Needs human: x', item, STAGES), ''); + assert.equal(c.stageTrackerNoteFoldText('waiting on a decision', 'PR #1 — Needs human: x', item, STAGES), ''); + assert.equal(c.stageTrackerNoteFoldText('Confirm the policy', 'Needs human: Confirm the policy', item, STAGES), ''); + assert.equal(c.stageTrackerNoteFoldText('moved to CI / Review', 'Needs human: x', item, STAGES), 'moved to CI / Review'); + assert.equal(c.stageTrackerNoteFoldText('moved to Needs human decision — why', 'Needs human: x', item, STAGES), 'moved to Needs human decision — why'); + assert.equal(c.stageTrackerNoteFoldText('moved to Needs human decision', 'Needs human: x', { kind: 'pr', number: 1, repo: 'r', stage: 85 }, []), 'moved to Needs human decision', 'no stage table: keep it'); +}); diff --git a/src/pkg/dashboard/static-src/js/tracker-human-attention.js b/src/pkg/dashboard/static-src/js/tracker-human-attention.js index c6e8e127a1..576cfa52d3 100644 --- a/src/pkg/dashboard/static-src/js/tracker-human-attention.js +++ b/src/pkg/dashboard/static-src/js/tracker-human-attention.js @@ -130,29 +130,55 @@ } return `

    ${bodyHtml}
    `; } - function stageTrackerHumanContextHtml(item, stages, nowMs, subRows) { + /* ---- One note line per row ----------------------------------------- + Owner (2026-11-05): "we don't need 2 hive comments — there should + always be only one." A row used to stack its "Needs human: …" line + over the "Hive: moved to …" stage note. Now every candidate is + ranked — needs-human / decision (0) > blocker (1) > next move / + claim (2) > optional delegation (3) > stage-transition note (4) — + and the row renders the winner alone. Same-rank human asks (an + issue's and its PR's) share the line, " · " apart, each with its + View link. A lower line's facts ride along as a trailing clause + only when they say something the row does not already: a stage + note that merely restates the lit chevron ("moved to Needs human + decision" under a strip lit at Needs human decision) is dropped. */ + const STAGE_TRACKER_NOTE_RANK_HUMAN = 0; + const STAGE_TRACKER_NOTE_RANK_BLOCKER = 1; + const STAGE_TRACKER_NOTE_RANK_NEXT = 2; + const STAGE_TRACKER_NOTE_RANK_OPTIONAL = 3; + // Mod-change words (tracker-motion) a "Needs human:" line already says. + const STAGE_TRACKER_NOTE_HUMAN_RESTATES = ['waiting on a person', 'waiting on a decision']; + function stageTrackerNoteRankOf(text) { + const t = String(text || ''); + if (/(^|— )Needs human:|decision context unavailable/.test(t)) return STAGE_TRACKER_NOTE_RANK_HUMAN; + if (/Current blocker:/.test(t)) return STAGE_TRACKER_NOTE_RANK_BLOCKER; + if (/^Optional delegation:/.test(t)) return STAGE_TRACKER_NOTE_RANK_OPTIONAL; + return STAGE_TRACKER_NOTE_RANK_NEXT; + } + // Pure: the candidate human lines for the row, each { body, text, rank }. + function stageTrackerHumanContextEntries(item, stages, nowMs, subRows) { const required = stageTrackerHumanContextOf(item, stages, subRows); - const lines = required.map(entry => { - const it = entry.item; + const entry = (body, text) => ({ body, text, rank: stageTrackerNoteRankOf(text) }); + const lines = required.map(e => { + const it = e.item; const href = it.url || item.url; const view = href ? 'View ' + (it.kind === 'pr' ? 'PR' : 'issue') + ' #' + Number(it.number) : ''; - const body = esc(entry.text) + (view ? ` ${view}` : ''); - return stageTrackerHumanContextLine(item, body, entry.text + (view ? ' · ' + view : ''), nowMs); + return entry(esc(e.text) + (view ? ` ${view}` : ''), e.text + (view ? ' · ' + view : '')); }); - if (lines.length || !item || item.advisory || item.hold || item.state === 'closed') return lines.join(''); + if (lines.length || !item || item.advisory || item.hold || item.state === 'closed') return lines; const stale = item.human_attention && !stageTrackerHumanAttentionOf(item); const staleLinks = item.kind === 'issue' ? (item.linked_prs || []).filter(lp => stageTrackerLinkedPROpen(lp, item) && lp.human_attention && !stageTrackerHumanAttentionOf(stageTrackerLinkedPRItem(item, lp))) : []; if (stale || staleLinks.length) { const refs = staleLinks.length ? staleLinks.map(lp => 'PR #' + lp.number).join(', ') : item.kind === 'pr' ? 'PR #' + item.number : 'Issue #' + item.number; const text = refs + ' · decision context unavailable for the displayed identity/head'; - return stageTrackerHumanContextLine(item, esc(text) + (item.url ? ` · View current item` : ''), text, nowMs); + return [entry(esc(text) + (item.url ? ` · View current item` : ''), text)]; } const linked = item.kind === 'issue' ? stageTrackerLinkedSorted(item, stages) : []; if (linked.length > 1 || item.kind === 'issue' && (item.linked_prs || []).some(lp => - stageTrackerLinkedPROpen(lp, item) && stageTrackerHumanAttentionOf(stageTrackerLinkedPRItem(item, lp)))) return ''; + stageTrackerLinkedPROpen(lp, item) && stageTrackerHumanAttentionOf(stageTrackerLinkedPRItem(item, lp)))) return []; const mods = Array.isArray(item.modifiers) ? item.modifiers : []; - if (mods.some(m => m === 'draft' || m === 'hold' || m === 'merged') || item.superseded_by) return ''; + if (mods.some(m => m === 'draft' || m === 'hold' || m === 'merged') || item.superseded_by) return []; const actor = item.stage_actor; const actorHuman = actor && (actor.kind === 'human' || actor.kind === 'maintainer'); const claimant = item.claimant; @@ -163,10 +189,10 @@ const prNumber = item.kind === 'issue' && (item.linked_pr || ((item.linked_prs || []).length === 1 && item.linked_prs[0].number)); const target = prNumber ? ' on PR #' + prNumber : ''; const text = 'Next move: ' + who + target + (actor.why ? ' — ' + actor.why : ' · action reason unavailable'); - lines.push(stageTrackerHumanContextLine(item, esc(text), text, nowMs)); + lines.push(entry(esc(text), text)); } else if (claimant && claimant.kind === 'person' && claimant.login) { const text = 'Claimed by @' + claimant.login + ' · claim ownership, not a human decision request'; - lines.push(stageTrackerHumanContextLine(item, esc(text), text, nowMs)); + lines.push(entry(esc(text), text)); } if (typeof stageTrackerLeadActionOnRow === 'function' && typeof stageTrackerActionCtx === 'function') { const ctx = stageTrackerActionCtx(item.repo); @@ -176,9 +202,60 @@ const action = stageTrackerLeadActionOnRow(item, ctx, subRows); if (action && (action.id === 'decide:delegate' || action.id === 'decide:delegate-all')) { const text = 'Optional delegation: Let hive decide is available; it does not itself mean human input is required.'; - lines.push(stageTrackerHumanContextLine(item, esc(text), text, nowMs)); + lines.push(entry(esc(text), text)); } } } - return lines.join(''); + return lines; + } + // Pure: the row's current stage as the chevron names it ('' unknown). + function stageTrackerNoteStageName(item, stages) { + if (!item) return ''; + const sg = (Array.isArray(stages) ? stages : []).find(x => Number(x.number) === (Number(item.stage) || 0)); + if (typeof stageTrackerStageName === 'function') return stageTrackerStageName(sg) || stageTrackerStageName({ label: item.stage_label || '', short: '' }); + return sg ? String(sg.short || sg.label || '') : String(item.stage_label || ''); + } + // Pure: the stage note's words worth keeping under a human line, or + // '' when the line (or the lit chevron) already says it. + function stageTrackerNoteFoldText(evText, lineText, item, stages) { + const t = String(evText || '').trim(); + if (!t) return ''; + const line = String(lineText || '').toLowerCase(); + if (line.indexOf(t.toLowerCase()) >= 0) return ''; + if (/needs human:/i.test(line) && STAGE_TRACKER_NOTE_HUMAN_RESTATES.indexOf(t) >= 0) return ''; + const m = /^(?:moved to|fell back to) (.+)$/.exec(t); + if (m) { + const name = stageTrackerNoteStageName(item, stages).toLowerCase(); + const said = m[1].split(' — ')[0].trim().toLowerCase(); + if (name && said === name && m[1].indexOf(' — ') < 0) return ''; + } + return t; + } + // ctx / key (the row's events map and its key) let the human line + // absorb the row's stage note so the row shows one line, not two. + function stageTrackerHumanContextHtml(item, stages, nowMs, subRows, ctx, key) { + let entries = stageTrackerHumanContextEntries(item, stages, nowMs, subRows); + if (!entries.length) return ''; + const best = Math.min.apply(null, entries.map(e => e.rank)); + // "Let hive decide is available" is a control the row shows anyway; + // it only earns the line when nothing else wants it. + if (best < STAGE_TRACKER_NOTE_RANK_OPTIONAL) entries = entries.filter(e => e.rank < STAGE_TRACKER_NOTE_RANK_OPTIONAL); + entries.sort((a, b) => a.rank - b.rank); + let body = entries.map(e => e.body).join(' · '); + let text = entries.map(e => e.text).join(' · '); + const ev = ctx && ctx.events && key ? ctx.events[key] : null; + const fold = ev ? stageTrackerNoteFoldText(ev.text, text, item, stages) : ''; + if (fold) { + const who = ev.who === 'you' ? 'You: ' : ev.who === 'merge' ? 'Merge: ' : ''; + body += ' · ' + esc(who + fold); text += ' · ' + who + fold; + } + return stageTrackerHumanContextLine(item, body, text, nowMs); + } + // Pure: ctx without the row's stage note once the human line has + // taken it (folded or dropped), so the event slot stays empty. + function stageTrackerNoteTakenCtx(ctx, key) { + if (!ctx || !ctx.events || !key || !ctx.events[key]) return ctx; + const events = Object.assign({}, ctx.events); + delete events[key]; + return Object.assign({}, ctx, { events }); } diff --git a/src/pkg/dashboard/static-src/js/tracker-row-layout.js b/src/pkg/dashboard/static-src/js/tracker-row-layout.js index 58c86ab6f9..b4a6b966a6 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row-layout.js +++ b/src/pkg/dashboard/static-src/js/tracker-row-layout.js @@ -248,6 +248,9 @@ `; } + const subKey = stageTrackerItemKey(pr); + const humanNote = typeof stageTrackerHumanContextHtml === 'function' ? stageTrackerHumanContextHtml(pr, stages, nowMs, undefined, ctx, subKey) : ''; + const noteCtx = humanNote && typeof stageTrackerNoteTakenCtx === 'function' ? stageTrackerNoteTakenCtx(ctx, subKey) : ctx; return `
    ${typeof stageTrackerRowToolsHtml === 'function' ? stageTrackerRowToolsHtml(pr) : ''}
    @@ -258,7 +261,7 @@
      ${stageTrackerStripItems(pr, stages, { from: STAGE_TRACKER_PR_COLUMN }, nowMs, ctx)}
    ${stageTrackerSinceHtml(pr, nowMs)}
    - ${typeof stageTrackerHumanContextHtml === 'function' ? stageTrackerHumanContextHtml(pr, stages, nowMs) : ''}${stageTrackerCurrentStageHtml(pr, stages, { from: STAGE_TRACKER_PR_COLUMN })}${typeof stageTrackerPreparationCommentHtml === 'function' ? stageTrackerPreparationCommentHtml(pr, ctx, stageTrackerItemKey(pr)) : typeof stageTrackerEventHtml === 'function' ? stageTrackerEventHtml(stageTrackerItemKey(pr), ctx) : ''}${typeof stageTrackerExecutionHtml === 'function' ? stageTrackerExecutionHtml(pr) : ''} + ${humanNote}${stageTrackerCurrentStageHtml(pr, stages, { from: STAGE_TRACKER_PR_COLUMN })}${typeof stageTrackerPreparationCommentHtml === 'function' ? stageTrackerPreparationCommentHtml(pr, noteCtx, subKey) : typeof stageTrackerEventHtml === 'function' ? stageTrackerEventHtml(subKey, noteCtx) : ''}${typeof stageTrackerExecutionHtml === 'function' ? stageTrackerExecutionHtml(pr) : ''}
    `; } diff --git a/src/pkg/dashboard/static-src/js/tracker-row-render.js b/src/pkg/dashboard/static-src/js/tracker-row-render.js index 6c3b367f0c..8a24fb30e1 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row-render.js +++ b/src/pkg/dashboard/static-src/js/tracker-row-render.js @@ -159,6 +159,11 @@ const prs = typeof stageTrackerRowPRKeys === 'function' ? stageTrackerRowPRKeys(item) : ''; const trainKey = typeof stageTrackerTrainKey === 'function' ? stageTrackerTrainKey(item) : ''; if (typeof stageTrackerPreparationMark === 'function') stageTrackerPreparationMark(shown); + // One note line per row: the human line takes the stage note (folded + // or dropped), so the event slot below the caption renders nothing. + const rowKey = stageTrackerItemKey(item); + const humanNote = typeof stageTrackerHumanContextHtml === 'function' ? stageTrackerHumanContextHtml(item, stages, nowMs, subRows, ctx, rowKey) : ''; + const noteCtx = humanNote && typeof stageTrackerNoteTakenCtx === 'function' ? stageTrackerNoteTakenCtx(ctx, rowKey) : ctx; return `
    ${stageTrackerRowToolsHtml(item)}
    @@ -168,7 +173,7 @@ ${typeof stageTrackerPreparationNodeHtml === 'function' ? stageTrackerPreparationNodeHtml(item, stages, ctx) : ''}
      ${stageTrackerStripItems(shown, stages, range, nowMs, ctx)}
    ${stageTrackerSinceHtml(shown, nowMs)} -
    ${typeof stageTrackerHumanContextHtml === 'function' ? stageTrackerHumanContextHtml(item, stages, nowMs, subRows) : ''}${stageTrackerCurrentStageHtml(shown, stages, range, nowMs)}${typeof stageTrackerPreparationCommentHtml === 'function' ? stageTrackerPreparationCommentHtml(shown, ctx, stageTrackerItemKey(item)) : typeof stageTrackerEventHtml === 'function' ? stageTrackerEventHtml(stageTrackerItemKey(item), ctx) : ''}${typeof stageTrackerExecutionHtml === 'function' ? stageTrackerExecutionHtml(shown) : ''}${typeof stageTrackerReviewNotesHtml === 'function' ? stageTrackerReviewNotesHtml(item, ctx) : ''}${subs} +
    ${humanNote}${stageTrackerCurrentStageHtml(shown, stages, range, nowMs)}${typeof stageTrackerPreparationCommentHtml === 'function' ? stageTrackerPreparationCommentHtml(shown, noteCtx, rowKey) : typeof stageTrackerEventHtml === 'function' ? stageTrackerEventHtml(rowKey, noteCtx) : ''}${typeof stageTrackerExecutionHtml === 'function' ? stageTrackerExecutionHtml(shown) : ''}${typeof stageTrackerReviewNotesHtml === 'function' ? stageTrackerReviewNotesHtml(item, ctx) : ''}${subs} `; } diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 8e44fe5616..69daa60a3a 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -19009,29 +19009,55 @@

    Where to get help

    } return `
    ${bodyHtml}
    `; } - function stageTrackerHumanContextHtml(item, stages, nowMs, subRows) { + /* ---- One note line per row ----------------------------------------- + Owner (2026-11-05): "we don't need 2 hive comments — there should + always be only one." A row used to stack its "Needs human: …" line + over the "Hive: moved to …" stage note. Now every candidate is + ranked — needs-human / decision (0) > blocker (1) > next move / + claim (2) > optional delegation (3) > stage-transition note (4) — + and the row renders the winner alone. Same-rank human asks (an + issue's and its PR's) share the line, " · " apart, each with its + View link. A lower line's facts ride along as a trailing clause + only when they say something the row does not already: a stage + note that merely restates the lit chevron ("moved to Needs human + decision" under a strip lit at Needs human decision) is dropped. */ + const STAGE_TRACKER_NOTE_RANK_HUMAN = 0; + const STAGE_TRACKER_NOTE_RANK_BLOCKER = 1; + const STAGE_TRACKER_NOTE_RANK_NEXT = 2; + const STAGE_TRACKER_NOTE_RANK_OPTIONAL = 3; + // Mod-change words (tracker-motion) a "Needs human:" line already says. + const STAGE_TRACKER_NOTE_HUMAN_RESTATES = ['waiting on a person', 'waiting on a decision']; + function stageTrackerNoteRankOf(text) { + const t = String(text || ''); + if (/(^|— )Needs human:|decision context unavailable/.test(t)) return STAGE_TRACKER_NOTE_RANK_HUMAN; + if (/Current blocker:/.test(t)) return STAGE_TRACKER_NOTE_RANK_BLOCKER; + if (/^Optional delegation:/.test(t)) return STAGE_TRACKER_NOTE_RANK_OPTIONAL; + return STAGE_TRACKER_NOTE_RANK_NEXT; + } + // Pure: the candidate human lines for the row, each { body, text, rank }. + function stageTrackerHumanContextEntries(item, stages, nowMs, subRows) { const required = stageTrackerHumanContextOf(item, stages, subRows); - const lines = required.map(entry => { - const it = entry.item; + const entry = (body, text) => ({ body, text, rank: stageTrackerNoteRankOf(text) }); + const lines = required.map(e => { + const it = e.item; const href = it.url || item.url; const view = href ? 'View ' + (it.kind === 'pr' ? 'PR' : 'issue') + ' #' + Number(it.number) : ''; - const body = esc(entry.text) + (view ? ` ${view}` : ''); - return stageTrackerHumanContextLine(item, body, entry.text + (view ? ' · ' + view : ''), nowMs); + return entry(esc(e.text) + (view ? ` ${view}` : ''), e.text + (view ? ' · ' + view : '')); }); - if (lines.length || !item || item.advisory || item.hold || item.state === 'closed') return lines.join(''); + if (lines.length || !item || item.advisory || item.hold || item.state === 'closed') return lines; const stale = item.human_attention && !stageTrackerHumanAttentionOf(item); const staleLinks = item.kind === 'issue' ? (item.linked_prs || []).filter(lp => stageTrackerLinkedPROpen(lp, item) && lp.human_attention && !stageTrackerHumanAttentionOf(stageTrackerLinkedPRItem(item, lp))) : []; if (stale || staleLinks.length) { const refs = staleLinks.length ? staleLinks.map(lp => 'PR #' + lp.number).join(', ') : item.kind === 'pr' ? 'PR #' + item.number : 'Issue #' + item.number; const text = refs + ' · decision context unavailable for the displayed identity/head'; - return stageTrackerHumanContextLine(item, esc(text) + (item.url ? ` · View current item` : ''), text, nowMs); + return [entry(esc(text) + (item.url ? ` · View current item` : ''), text)]; } const linked = item.kind === 'issue' ? stageTrackerLinkedSorted(item, stages) : []; if (linked.length > 1 || item.kind === 'issue' && (item.linked_prs || []).some(lp => - stageTrackerLinkedPROpen(lp, item) && stageTrackerHumanAttentionOf(stageTrackerLinkedPRItem(item, lp)))) return ''; + stageTrackerLinkedPROpen(lp, item) && stageTrackerHumanAttentionOf(stageTrackerLinkedPRItem(item, lp)))) return []; const mods = Array.isArray(item.modifiers) ? item.modifiers : []; - if (mods.some(m => m === 'draft' || m === 'hold' || m === 'merged') || item.superseded_by) return ''; + if (mods.some(m => m === 'draft' || m === 'hold' || m === 'merged') || item.superseded_by) return []; const actor = item.stage_actor; const actorHuman = actor && (actor.kind === 'human' || actor.kind === 'maintainer'); const claimant = item.claimant; @@ -19042,10 +19068,10 @@

    Where to get help

    const prNumber = item.kind === 'issue' && (item.linked_pr || ((item.linked_prs || []).length === 1 && item.linked_prs[0].number)); const target = prNumber ? ' on PR #' + prNumber : ''; const text = 'Next move: ' + who + target + (actor.why ? ' — ' + actor.why : ' · action reason unavailable'); - lines.push(stageTrackerHumanContextLine(item, esc(text), text, nowMs)); + lines.push(entry(esc(text), text)); } else if (claimant && claimant.kind === 'person' && claimant.login) { const text = 'Claimed by @' + claimant.login + ' · claim ownership, not a human decision request'; - lines.push(stageTrackerHumanContextLine(item, esc(text), text, nowMs)); + lines.push(entry(esc(text), text)); } if (typeof stageTrackerLeadActionOnRow === 'function' && typeof stageTrackerActionCtx === 'function') { const ctx = stageTrackerActionCtx(item.repo); @@ -19055,11 +19081,62 @@

    Where to get help

    const action = stageTrackerLeadActionOnRow(item, ctx, subRows); if (action && (action.id === 'decide:delegate' || action.id === 'decide:delegate-all')) { const text = 'Optional delegation: Let hive decide is available; it does not itself mean human input is required.'; - lines.push(stageTrackerHumanContextLine(item, esc(text), text, nowMs)); + lines.push(entry(esc(text), text)); } } } - return lines.join(''); + return lines; + } + // Pure: the row's current stage as the chevron names it ('' unknown). + function stageTrackerNoteStageName(item, stages) { + if (!item) return ''; + const sg = (Array.isArray(stages) ? stages : []).find(x => Number(x.number) === (Number(item.stage) || 0)); + if (typeof stageTrackerStageName === 'function') return stageTrackerStageName(sg) || stageTrackerStageName({ label: item.stage_label || '', short: '' }); + return sg ? String(sg.short || sg.label || '') : String(item.stage_label || ''); + } + // Pure: the stage note's words worth keeping under a human line, or + // '' when the line (or the lit chevron) already says it. + function stageTrackerNoteFoldText(evText, lineText, item, stages) { + const t = String(evText || '').trim(); + if (!t) return ''; + const line = String(lineText || '').toLowerCase(); + if (line.indexOf(t.toLowerCase()) >= 0) return ''; + if (/needs human:/i.test(line) && STAGE_TRACKER_NOTE_HUMAN_RESTATES.indexOf(t) >= 0) return ''; + const m = /^(?:moved to|fell back to) (.+)$/.exec(t); + if (m) { + const name = stageTrackerNoteStageName(item, stages).toLowerCase(); + const said = m[1].split(' — ')[0].trim().toLowerCase(); + if (name && said === name && m[1].indexOf(' — ') < 0) return ''; + } + return t; + } + // ctx / key (the row's events map and its key) let the human line + // absorb the row's stage note so the row shows one line, not two. + function stageTrackerHumanContextHtml(item, stages, nowMs, subRows, ctx, key) { + let entries = stageTrackerHumanContextEntries(item, stages, nowMs, subRows); + if (!entries.length) return ''; + const best = Math.min.apply(null, entries.map(e => e.rank)); + // "Let hive decide is available" is a control the row shows anyway; + // it only earns the line when nothing else wants it. + if (best < STAGE_TRACKER_NOTE_RANK_OPTIONAL) entries = entries.filter(e => e.rank < STAGE_TRACKER_NOTE_RANK_OPTIONAL); + entries.sort((a, b) => a.rank - b.rank); + let body = entries.map(e => e.body).join(' · '); + let text = entries.map(e => e.text).join(' · '); + const ev = ctx && ctx.events && key ? ctx.events[key] : null; + const fold = ev ? stageTrackerNoteFoldText(ev.text, text, item, stages) : ''; + if (fold) { + const who = ev.who === 'you' ? 'You: ' : ev.who === 'merge' ? 'Merge: ' : ''; + body += ' · ' + esc(who + fold); text += ' · ' + who + fold; + } + return stageTrackerHumanContextLine(item, body, text, nowMs); + } + // Pure: ctx without the row's stage note once the human line has + // taken it (folded or dropped), so the event slot stays empty. + function stageTrackerNoteTakenCtx(ctx, key) { + if (!ctx || !ctx.events || !key || !ctx.events[key]) return ctx; + const events = Object.assign({}, ctx.events); + delete events[key]; + return Object.assign({}, ctx, { events }); } // Ghost strip for a title line: the lead cell (Open..Claimed) carries @@ -19311,6 +19388,9 @@

    Where to get help

    `; } + const subKey = stageTrackerItemKey(pr); + const humanNote = typeof stageTrackerHumanContextHtml === 'function' ? stageTrackerHumanContextHtml(pr, stages, nowMs, undefined, ctx, subKey) : ''; + const noteCtx = humanNote && typeof stageTrackerNoteTakenCtx === 'function' ? stageTrackerNoteTakenCtx(ctx, subKey) : ctx; return `
    ${typeof stageTrackerRowToolsHtml === 'function' ? stageTrackerRowToolsHtml(pr) : ''}
    @@ -19321,7 +19401,7 @@

    Where to get help

      ${stageTrackerStripItems(pr, stages, { from: STAGE_TRACKER_PR_COLUMN }, nowMs, ctx)}
    ${stageTrackerSinceHtml(pr, nowMs)}
    - ${typeof stageTrackerHumanContextHtml === 'function' ? stageTrackerHumanContextHtml(pr, stages, nowMs) : ''}${stageTrackerCurrentStageHtml(pr, stages, { from: STAGE_TRACKER_PR_COLUMN })}${typeof stageTrackerPreparationCommentHtml === 'function' ? stageTrackerPreparationCommentHtml(pr, ctx, stageTrackerItemKey(pr)) : typeof stageTrackerEventHtml === 'function' ? stageTrackerEventHtml(stageTrackerItemKey(pr), ctx) : ''}${typeof stageTrackerExecutionHtml === 'function' ? stageTrackerExecutionHtml(pr) : ''} + ${humanNote}${stageTrackerCurrentStageHtml(pr, stages, { from: STAGE_TRACKER_PR_COLUMN })}${typeof stageTrackerPreparationCommentHtml === 'function' ? stageTrackerPreparationCommentHtml(pr, noteCtx, subKey) : typeof stageTrackerEventHtml === 'function' ? stageTrackerEventHtml(subKey, noteCtx) : ''}${typeof stageTrackerExecutionHtml === 'function' ? stageTrackerExecutionHtml(pr) : ''}
    `; } @@ -19618,6 +19698,11 @@

    Where to get help

    const prs = typeof stageTrackerRowPRKeys === 'function' ? stageTrackerRowPRKeys(item) : ''; const trainKey = typeof stageTrackerTrainKey === 'function' ? stageTrackerTrainKey(item) : ''; if (typeof stageTrackerPreparationMark === 'function') stageTrackerPreparationMark(shown); + // One note line per row: the human line takes the stage note (folded + // or dropped), so the event slot below the caption renders nothing. + const rowKey = stageTrackerItemKey(item); + const humanNote = typeof stageTrackerHumanContextHtml === 'function' ? stageTrackerHumanContextHtml(item, stages, nowMs, subRows, ctx, rowKey) : ''; + const noteCtx = humanNote && typeof stageTrackerNoteTakenCtx === 'function' ? stageTrackerNoteTakenCtx(ctx, rowKey) : ctx; return `
    ${stageTrackerRowToolsHtml(item)}
    @@ -19627,7 +19712,7 @@

    Where to get help

    ${typeof stageTrackerPreparationNodeHtml === 'function' ? stageTrackerPreparationNodeHtml(item, stages, ctx) : ''}
      ${stageTrackerStripItems(shown, stages, range, nowMs, ctx)}
    ${stageTrackerSinceHtml(shown, nowMs)} -
    ${typeof stageTrackerHumanContextHtml === 'function' ? stageTrackerHumanContextHtml(item, stages, nowMs, subRows) : ''}${stageTrackerCurrentStageHtml(shown, stages, range, nowMs)}${typeof stageTrackerPreparationCommentHtml === 'function' ? stageTrackerPreparationCommentHtml(shown, ctx, stageTrackerItemKey(item)) : typeof stageTrackerEventHtml === 'function' ? stageTrackerEventHtml(stageTrackerItemKey(item), ctx) : ''}${typeof stageTrackerExecutionHtml === 'function' ? stageTrackerExecutionHtml(shown) : ''}${typeof stageTrackerReviewNotesHtml === 'function' ? stageTrackerReviewNotesHtml(item, ctx) : ''}${subs} +
    ${humanNote}${stageTrackerCurrentStageHtml(shown, stages, range, nowMs)}${typeof stageTrackerPreparationCommentHtml === 'function' ? stageTrackerPreparationCommentHtml(shown, noteCtx, rowKey) : typeof stageTrackerEventHtml === 'function' ? stageTrackerEventHtml(rowKey, noteCtx) : ''}${typeof stageTrackerExecutionHtml === 'function' ? stageTrackerExecutionHtml(shown) : ''}${typeof stageTrackerReviewNotesHtml === 'function' ? stageTrackerReviewNotesHtml(item, ctx) : ''}${subs} `; }