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-needs-human-reason-on-row.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor rows parked on a person now state why on the row itself: the hive-note line reads `#N — Needs human: <blocker> — <ask> · requested by … · lead: <first enabled option> ▸ · @author is pushing it in #PR`, the issue's decision column keeps `Blocked · App lacks workflows permission 👤` while a covering PR drives the strip, the `needs human` pill carries the full reason and reveals the line on click, the 085 chevron reads `Needs human · <short reason>` (e.g. "edits CI workflows"), an issue blocked only by its PR's pending decision reads `decision on #PR`, the first enabled blocker option leads when the server disables "Let hive decide" (shown muted with its reason), and the "owed — blocked: …" caption double space is gone ([#16623](https://github.com/hivecommons/hive/issues/16623)).
7 changes: 7 additions & 0 deletions src/pkg/dashboard/stage_tracker_caption.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,13 @@ func humanizeStageReason(reason string) string {
if stageengine.ReasonIsPartialCover(r) {
return "the PR references it without closing it (partial)"
}
// "blocked: App lacks workflows permission" (derive_issue.go, a
// structured blocker's short text): already prose. The generic replacer
// below would turn its ": " into ": " (hivecommons/docs#612 read
// "owed — blocked: App lacks…").
if rest, ok := strings.CutPrefix(r, "blocked: "); ok {
return "blocked: " + strings.TrimSpace(rest)
}
if clause, ok := humanizeCoverReason(r); ok {
return clause
}
Expand Down
66 changes: 66 additions & 0 deletions src/pkg/dashboard/stage_tracker_human_attention.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,69 @@ test('adoption absence is not a refusal; ownership policy and actual capability
assert.equal(c.stageTrackerAdoptionChipText(item), word);
}
});

// hivecommons/docs#612 / rationguard#480: the row states why a human is
// needed in its own note line — blocker first, the ask's first sentence, who
// asked, the lead move, and who is pushing a covering PR.
function needsHumanContext() {
const c = load();
for (const name of ['STAGE_TRACKER_NEEDS_HUMAN_SHORT', 'STAGE_TRACKER_NEEDS_HUMAN_SHORT_MAX', 'STAGE_TRACKER_NEEDS_HUMAN_WORD']) {
const text = source('tracker-words-core');
const m = text.match(new RegExp('const ' + name + ' = [\\s\\S]*?;\\n'));
assert.ok(m, name);
vm.runInContext(m[0], c);
}
vm.runInContext(fn('tracker-words-core', 'stageTrackerNeedsHumanShort'), c);
c.stageTrackerLeadActionOnRow = item => item.blocker ? { id: 'open:app-settings', label: 'Grant the App workflows: write' } : (item.decision_needed ? { id: 'decide:delegate', label: 'Let hive decide' } : null);
return c;
}
const why612 = "Hive can't do this one: the GitHub App has no `workflows` permission, so it cannot push changes to .github/workflows/*. Options: (a) grant the App workflows: write, (b) apply by hand.";
function issue612() {
const pr620 = { kind: 'pr', repo: 'hivecommons/docs', number: 620, stage: 50, state: 'open', head: 'h620', author: 'bob', author_kind: 'human',
title: 'ci: opt in', url: 'https://github.com/hivecommons/docs/pull/620', stage_actor: { kind: 'hive' } };
return { kind: 'issue', repo: 'hivecommons/docs', number: 612, stage: 45, state: 'open', modifiers: ['needs-human'], needs_human: true,
title: 'Opt docs refresh into hive', url: 'https://github.com/hivecommons/docs/issues/612', linked_pr: 620, linked_prs: [pr620],
human_attention: { kind: 'issue', number: 612, reason: why612, asked_by: 'the hive' },
blocker: { kind: 'capability:workflows-permission', short: 'App lacks workflows permission' },
decision_needed: { question: 'Grant the permission or close as partial?', options: [{ action: 'decide:delegate', enabled: false, reason_if_disabled: 'No decision grants the App the permission' }] } };
}

test('covered issue on a capability blocker names the blocker, the ask, the asker, the lead move and who is pushing the PR', () => {
const c = needsHumanContext();
const html = c.stageTrackerRowHtml(issue612(), [], { nowMs: 1 });
assert.match(html, /#612 — Needs human: App lacks workflows permission — Hive can&#39;t do this one: the GitHub App has no `workflows` permission, so it cannot push changes to \.github\/workflows\/\*\./);
assert.match(html, /· requested by the hive · lead: Grant the App workflows: write ▸ · @bob is pushing it in #620/);
assert.doesNotMatch(html, /Options: \(a\)/, 'only the first sentence of the ask rides on the row');
// The line is unchanged when the strip is the issue's own.
const alone = issue612(); alone.linked_prs = []; delete alone.linked_pr;
assert.doesNotMatch(c.stageTrackerHumanContextHtml(alone, [], 1), /is pushing it/);
assert.match(c.stageTrackerHumanContextHtml(alone, [], 1), /App lacks workflows permission/);
// A hive-authored covering PR is not "pushed by" anyone on the line.
const hive = issue612(); hive.linked_prs[0].author_kind = 'hive'; hive.linked_prs[0].author = 'hive-bot';
assert.doesNotMatch(c.stageTrackerHumanContextHtml(hive, [], 1), /is pushing it/);
});

test('085 PR without human_attention still states the decision question from decision_needed', () => {
const c = needsHumanContext();
const item = { kind: 'pr', repo: 'hivecommons/rationguard', number: 480, stage: 85, state: 'open', head: 'h480', modifiers: ['needs-decision'],
title: 'ci: pin runners', url: 'https://github.com/hivecommons/rationguard/pull/480', human_reason: 'workflow path',
stage_actor: { kind: 'human', why: 'a human decision is owed — workflow path', human_reason: 'workflow path' },
decision_needed: { question: 'The hive never merges this by itself (it edits CI workflow files). Approve it for a maintainer to merge, give direction, or close it?',
blocker: 'The hive never merges this by itself. After approval, a maintainer merges.', asked_by: 'the hive' } };
const ask = c.stageTrackerNeedsHumanAsk(item);
assert.ok(ask && ask.synthetic, JSON.stringify(ask));
assert.equal(ask.reason, item.decision_needed.question);
const html = c.stageTrackerHumanContextHtml(item, [], 1);
assert.match(html, /Needs human: edits CI workflows — The hive never merges this by itself \(it edits CI workflow files\)\./);
assert.match(html, /Approve it for a maintainer to merge, give direction, or close it\?/, 'the full question stays on the line');
assert.match(html, /· asked by the hive/);
assert.doesNotMatch(html, /lead: Let hive decide/, 'the optional delegation is not the person\'s move');
// Human attention from the server wins over the synthesized ask; a parked
// stage with no evidence synthesizes nothing.
assert.equal(c.stageTrackerNeedsHumanAsk({ ...item, human_attention: { kind: 'pr', number: 480, head: 'h480', reason: 'x' } }), null);
assert.equal(c.stageTrackerNeedsHumanAsk({ ...item, decision_needed: null, stage_actor: { kind: 'hive' } }), null);
for (const mutate of [it => { it.state = 'closed'; }, it => { it.modifiers = ['draft']; }, it => { it.hold = { by: 'owner' }; }]) {
const changed = plain(item); mutate(changed);
assert.equal(c.stageTrackerNeedsHumanAsk(changed), null);
}
});
153 changes: 153 additions & 0 deletions src/pkg/dashboard/stage_tracker_needs_human_reason_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
package dashboard

import (
"strings"
"testing"
)

// A row parked on a person states WHY on the row itself — not only in a
// tooltip. hivecommons/docs#612: an issue at 045 with a capability blocker,
// covered by a human-authored PR, read a bare muted "needs human" and "Let
// hive decide ▸" once the PR's strip took over. rationguard#480: a PR at 085
// read only "Needs human decision" though the server knew the reason
// ("workflow path"), and its issue #431 wore "blocked" purely because the PR
// waited on that decision.

const stageTrackerNeedsHumanFixture = `
const appURL = 'https://github.com/organizations/hivecommons/settings/installations/1';
const why612 = "Hive can't do this one: the GitHub App has no ` + "`workflows`" + ` permission, so it cannot push changes to .github/workflows/*. Options: (a) grant the App workflows: write, (b) apply the patch by hand, (c) close as partially addressed, (d) keep waiting.";
const decision612 = { question: 'Grant the App workflows permission, apply the patch by hand, or close as partially addressed?', asked_by: 'the hive', since: '2026-10-20T19:33:00Z',
blocker: why612, blocker_reason: 'capability:workflows-permission',
options: [
{ action: 'open:app-settings', label: 'Grant the App workflows: write', enabled: true, url: appURL },
{ action: 'blocker:recheck', label: 'Re-check permissions', enabled: true },
{ action: 'blocker:patch', label: 'Prepare the patch for a person to push', enabled: false, reason_if_disabled: 'No human-authorised push identity is configured.' },
{ action: 'blocker:close-partial', label: 'Mark partially addressed and close', enabled: true },
{ action: 'blocker:wait', label: 'Keep waiting', enabled: true },
{ action: 'decide:delegate', label: 'Let hive decide', enabled: false, reason_if_disabled: 'No decision grants the App the permission; a maintainer must act in GitHub.' },
{ action: 'hold', label: 'Hold', enabled: true },
] };
const pr620 = { repo: 'hivecommons/docs', kind: 'pr', number: 620, title: 'ci: opt docs refresh into hive', url: 'https://github.com/hivecommons/docs/pull/620',
stage: 50, stage_since: '2026-10-21T09:00:00Z', state: 'open', head: 'h620', author: 'bob', author_kind: 'human', caption: 'In review',
linked_issues: [{ number: 612, state: 'open', via: 'closes' }] };
const issue612 = { repo: 'hivecommons/docs', kind: 'issue', number: 612, title: 'Opt docs refresh into hive', url: 'https://github.com/hivecommons/docs/issues/612',
stage: 45, stage_since: '2026-10-20T19:33:00Z', state: 'open', modifiers: ['needs-human'], needs_human: true,
reason: 'blocked: App lacks workflows permission', caption: 'A human decision is owed — blocked: App lacks workflows permission',
human_attention: { kind: 'issue', number: 612, reason: why612, asked_by: 'the hive' },
blocker: { kind: 'capability:workflows-permission', short: 'App lacks workflows permission', permission: 'workflows', since: '2026-10-20T19:33:00Z',
detail: 'needs-human: the .github/workflows/hive-docs-refresh.yml opt-in + add-paths change must be applied by a maintainer; App token lacks workflows permission' },
decision_needed: decision612, linked_pr: 620, linked_prs: [pr620] };
const decision480 = { question: 'The hive never merges this by itself (it edits CI workflow files). Approve it for a maintainer to merge, give direction, or close it?', asked_by: 'the hive', since: '2026-10-22T08:00:00Z',
blocker: 'The hive never merges this by itself. After approval, a maintainer merges.',
options: [ { action: 'decide:delegate', label: 'Let hive decide', enabled: true }, { action: 'decide:approve', label: 'Approve', enabled: true } ] };
const pr480 = { repo: 'hivecommons/rationguard', kind: 'pr', number: 480, title: 'ci: pin workflow runners', url: 'https://github.com/hivecommons/rationguard/pull/480',
stage: 85, stage_since: '2026-10-22T08:00:00Z', state: 'open', head: 'h480', author: 'hive-bot', author_kind: 'hive', base_ref: 'main', modifiers: ['needs-decision'],
caption: 'A human decision is owed — workflow path', human_reason: 'workflow path',
stage_actor: { kind: 'human', why: 'a human decision is owed — workflow path', human_reason: 'workflow path' },
decision_needed: decision480, linked_issues: [{ number: 431, state: 'open', via: 'closes' }] };
const issue431 = { repo: 'hivecommons/rationguard', kind: 'issue', number: 431, title: 'Pin workflow runners', url: 'https://github.com/hivecommons/rationguard/issues/431',
stage: 40, stage_since: '2026-10-21T08:00:00Z', state: 'open', modifiers: ['blocked'], caption: 'PR open', linked_pr: 480,
// The live payload's linked entry carried no modifiers of its own, so the issue's "blocked" led the pill.
linked_prs: [(({ modifiers, ...rest }) => rest)(pr480)] };
`

func TestStageTrackerNeedsHumanReasonOnRow(t *testing.T) {
html := indexHTML(t)
runStageTrackerRowActionsScript(t, stageTrackerRowsPreludeJS(t, html)+"\n"+
jsFunc(t, html, "stageTrackerHumanAttentionOf")+"\n"+
jsFunc(t, html, "stageTrackerNeedsHumanAsk")+"\n"+
stageTrackerRowsFixtureJS+stageTrackerNeedsHumanFixture+`
// Short reasons: the known map first, then the clause after "—".
assert.strictEqual(stageTrackerNeedsHumanShort(issue612), 'App lacks workflows permission');
assert.strictEqual(stageTrackerNeedsHumanShort(pr480), 'edits CI workflows');
assert.strictEqual(stageTrackerNeedsHumanWord(pr480), 'Needs human · edits CI workflows');
assert.strictEqual(stageTrackerNeedsHumanShort({ stage: 85, stage_actor: { kind: 'human', why: 'a human decision is owed — the reviewer asked for a design note. Then more.' } }), 'the reviewer asked for a design note');
assert.strictEqual(stageTrackerNeedsHumanWord({ stage: 85, modifiers: ['needs-decision'] }), '');

// rationguard#480: the 085 chevron names the reason, not a bare "Needs human decision".
let row = stageTrackerRowHtml(pr480, stages, ctx);
assert.ok(text(strip(row)).includes('Needs human · edits CI workflows'), 'the 085 caption carries the short reason: ' + text(strip(row)));
const detour = (/<span class="ham-detour(?: ham-has-holder)?">([^<]*)</.exec(strip(row)) || [])[1];
assert.strictEqual(detour, 'Needs human · edits CI workflows', 'the visible chevron word, not "Needs human decision"');

// rationguard#431: "blocked" only because its PR waits at 085 reads "decision on #480".
row = stageTrackerRowHtml(issue431, stages, ctx);
const pill431 = /<[a-z]+ class="ham-badge ham-badge-mod ham-mod-blocked[^"]*"[^>]*>([\s\S]*?)<\/[a-z]+>/.exec(row);
assert.ok(pill431, row);
assert.strictEqual(text(pill431[1]), 'decision on #480');
assert.ok(pill431[0].includes('Blocked only because PR #480 waits on a human decision'), pill431[0]);
// A real blocked-on dependency keeps its own words.
assert.strictEqual(stageTrackerBlockedForDecisionPR(Object.assign({}, issue431, { blocked_on: ['#7'] })), null);
assert.strictEqual(stageTrackerBlockedForDecisionPR(Object.assign({}, issue431, { linked_prs: [Object.assign({}, pr480, { stage: 50, modifiers: [], decision_needed: null })] })), null);

// docs#612: the covering human PR drives the strip, yet the issue's decision
// column still names the blocker with the person glyph, and the pill is a
// button carrying the full reason that reveals the row's note line.
row = stageTrackerRowHtml(issue612, stages, ctx);
assert.ok(row.includes('ham-blocker-note'), 'the done decision column keeps the blocker: ' + row);
assert.ok(text(strip(row)).includes('Blocked · App lacks workflows permission'), text(strip(row)));
assert.ok(/<li class="ham-seg done[^"]*ham-blocker-note[^"]*"[\s\S]*?aria-label="Next move: human"/.test(strip(row)), 'the blocker note wears the person glyph');
const pill612 = /<button type="button" class="ham-badge ham-badge-mod ham-mod-needs-human ham-needs-human-pill"[^>]*>/.exec(row);
assert.ok(pill612, 'the needs-human pill is a button: ' + row);
assert.ok(pill612[0].includes('data-action="stageTrackerNeedsHumanReveal"') && pill612[0].includes('data-arg0="hivecommons/docs/issue#612"'), pill612[0]);
assert.ok(pill612[0].includes('title="Hive can&#39;t do this one: the GitHub App has no'), 'the hover is the full reason: ' + pill612[0]);
// Without a blocker there is no note, and a hive-owned row stays plain.
const plain = stageTrackerRowHtml(Object.assign({}, issue612, { blocker: null, needs_human: false, human_attention: null, decision_needed: null, modifiers: [] }), stages, ctx);
assert.ok(!plain.includes('ham-blocker-note') && !plain.includes('ham-needs-human-pill'), plain);
`)
}

func TestStageTrackerNeedsHumanLeadAction(t *testing.T) {
html := indexHTML(t)
runStageTrackerRowActionsScript(t, stageTrackerRowActionsPreamble(t, html)+"\n"+stageTrackerNeedsHumanFixture+`
const ctx = { user: true, canHold: true, canHuman: true, rows: [issue612] };
// The server ruled delegation out: the lead is the first enabled blocker
// option, and "Let hive decide" stands beside it muted with the reason.
const lead = stageTrackerLeadAction(issue612, ctx);
assert.ok(lead, 'a lead');
assert.strictEqual(lead.id, 'open:app-settings', JSON.stringify(lead));
assert.strictEqual(lead.label, 'Grant the App workflows: write');
assert.strictEqual(lead.enabled, true);
assert.strictEqual(lead.url, appURL);
const pills = stageTrackerLeadActionsOnRow(issue612, ctx, []);
assert.deepStrictEqual(pills.map(a => a.id), ['open:app-settings', 'decide:delegate'], JSON.stringify(pills));
assert.strictEqual(pills[1].enabled, false);
assert.ok(pills[1].why.includes('No decision grants the App the permission'), pills[1].why);
const htmlOut = stageTrackerLeadActionHtml(issue612, ctx, []);
assert.ok(/<button[^>]*class="ham-lead-act ham-act-primary"[^>]*data-ham-act="open:app-settings"[^>]*>Grant the App workflows: write<\/button>/.test(htmlOut), htmlOut);
assert.ok(/<button[^>]*class="ham-lead-act ham-act-secondary"[^>]*data-ham-act="decide:delegate"[^>]*aria-disabled="true"[^>]*title="No decision grants the App the permission[^"]*"[^>]*>Let hive decide<\/button>/.test(htmlOut), htmlOut);
// The Decide… submenu honours the server's reason too.
const del = stageTrackerDecideOptions(issue612, ctx).find(o => o.id === 'decide:delegate');
assert.strictEqual(del.enabled, false);
assert.ok(del.why.includes('No decision grants'), del.why);
// With the link gone, the next enabled, non-destructive option leads.
const noLink = Object.assign({}, issue612, { decision_needed: Object.assign({}, decision612, { options: decision612.options.filter(o => o.action !== 'open:app-settings') }) });
assert.strictEqual(stageTrackerLeadAction(noLink, ctx).id, 'blocker:recheck');
// A row whose server lets the hive decide keeps delegate as its lead.
assert.strictEqual(stageTrackerLeadAction(pr480, ctx).id, 'decide:delegate');
`)
}

func TestStageTrackerNeedsHumanCaptionSpacing(t *testing.T) {
// derive_issue.go emits "blocked: <short>"; the generic replacer used to
// double the space ("owed — blocked: App lacks…").
if got, want := humanizeStageReason("blocked: App lacks workflows permission"), "blocked: App lacks workflows permission"; got != want {
t.Errorf("humanizeStageReason = %q, want %q", got, want)
}
if got := humanizeStageReason("blocked: App lacks workflows permission"); strings.Contains(got, " ") {
t.Errorf("humanizeStageReason kept a double space: %q", got)
}
}

func TestStageTrackerNeedsHumanWiredInPage(t *testing.T) {
html := indexHTML(t)
for _, want := range []string{
`function stageTrackerNeedsHumanReveal(rowKey)`,
`.ham-seg.done.ham-blocker-note { color: var(--amber); opacity: 1; }`,
`.ham-needs-human-pill { cursor: pointer; font: inherit; }`,
} {
if !strings.Contains(html, want) {
t.Errorf("index.html missing %q", want)
}
}
}
1 change: 1 addition & 0 deletions src/pkg/dashboard/stage_tracker_row_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func stageTrackerRowActionsPreamble(t *testing.T, html string) string {
jsFunc(t, html, "stageTrackerParkedNestedPRs"),
jsFunc(t, html, "stageTrackerDecisionTarget"),
jsFunc(t, html, "stageTrackerDelegateTargets"),
jsFunc(t, html, "stageTrackerServerDelegate"),
jsFunc(t, html, "stageTrackerDecideOptions"),
jsFunc(t, html, "stageTrackerSupersederOptions"),
jsFunc(t, html, "stageTrackerSupersederDefault"),
Expand Down
8 changes: 8 additions & 0 deletions src/pkg/dashboard/stage_tracker_ui_prelude_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ func stageTrackerRowsPreludeJS(t *testing.T, html string) string {
jsFunc(t, html, "stageTrackerHopName"),
jsFunc(t, html, "stageTrackerTrailText"),
jsFunc(t, html, "stageTrackerTooltip"),
jsConstLine(t, html, "STAGE_TRACKER_BLOCKED_WORD"),
jsFunc(t, html, "stageTrackerBlockerWord"),
jsConstBlock(t, html, "STAGE_TRACKER_NEEDS_HUMAN_SHORT"),
jsConstLine(t, html, "STAGE_TRACKER_NEEDS_HUMAN_SHORT_MAX"),
jsConstLine(t, html, "STAGE_TRACKER_NEEDS_HUMAN_WORD"),
jsFunc(t, html, "stageTrackerNeedsHumanShort"),
jsFunc(t, html, "stageTrackerNeedsHumanWord"),
jsFunc(t, html, "stageTrackerBlockedForDecisionPR"),
jsFunc(t, html, "stageTrackerChipsHtml"),
jsFunc(t, html, "stageTrackerHeadColsHtml"),
jsFunc(t, html, "stageTrackerSinceHtml"),
Expand Down
Loading
Loading