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|${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 `${stageTrackerStripItems(pr, stages, { from: STAGE_TRACKER_PR_COLUMN }, nowMs, ctx)}
${stageTrackerSinceHtml(pr, nowMs)}
${stageTrackerStripItems(shown, stages, range, nowMs, ctx)}
${stageTrackerSinceHtml(shown, nowMs)}
- Where to get help
}
return `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 `Where to get help
${stageTrackerStripItems(pr, stages, { from: STAGE_TRACKER_PR_COLUMN }, nowMs, ctx)}
${stageTrackerSinceHtml(pr, nowMs)}
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 `Where to get help
${typeof stageTrackerPreparationNodeHtml === 'function' ? stageTrackerPreparationNodeHtml(item, stages, ctx) : ''}
${stageTrackerStripItems(shown, stages, range, nowMs, ctx)}
${stageTrackerSinceHtml(shown, nowMs)}
-