From 1a25e2b91b5c6a6b1b55650c58375e07aff31297 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Wed, 4 Nov 2026 11:42:54 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Activity=20Monitor:=20state=20wh?= =?UTF-8?q?y=20a=20human=20is=20needed=20on=20the=20row=20itself?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A row flagged needs-human renders its reason in the hive-note line (blocker short + first sentence of the ask + asker + lead option + who is pushing a covering PR), keeps the Blocked · 👤 word in the issue's decision column when a PR strip drives the row, turns the needs-human pill into a reveal button with the full reason as hover, captions the 085 chevron 'Needs human · ' from a small map of known reasons, reads 'decision on #PR' on an issue blocked only by its PR's pending decision, leads with the first enabled blocker option when the server disables decide:delegate (rendered muted with reason_if_disabled), and drops the double space in the 'owed — blocked: …' caption. Fixes #16623 Signed-off-by: Andrew Anderson --- .../fixed-needs-human-reason-on-row.md | 1 + src/pkg/dashboard/stage_tracker_caption.go | 7 + .../stage_tracker_human_attention.test.js | 66 +++++ .../stage_tracker_needs_human_reason_test.go | 153 ++++++++++++ .../stage_tracker_row_actions_test.go | 1 + .../stage_tracker_ui_prelude_test.go | 8 + src/pkg/dashboard/static-src/css/tracker.css | 6 + .../static-src/js/tracker-actions.js | 22 +- .../static-src/js/tracker-human-attention.js | 91 ++++++- .../dashboard/static-src/js/tracker-motion.js | 14 ++ .../static-src/js/tracker-row-strip.js | 48 +++- .../dashboard/static-src/js/tracker-row.js | 16 +- .../static-src/js/tracker-words-core.js | 38 +++ src/pkg/dashboard/static/index.html | 235 ++++++++++++++++-- 14 files changed, 674 insertions(+), 32 deletions(-) create mode 100644 changelog.d/fixed-needs-human-reason-on-row.md create mode 100644 src/pkg/dashboard/stage_tracker_needs_human_reason_test.go diff --git a/changelog.d/fixed-needs-human-reason-on-row.md b/changelog.d/fixed-needs-human-reason-on-row.md new file mode 100644 index 0000000000..c111bdc0fa --- /dev/null +++ b/changelog.d/fixed-needs-human-reason-on-row.md @@ -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: — · requested by … · lead: ▸ · @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 · ` (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)). diff --git a/src/pkg/dashboard/stage_tracker_caption.go b/src/pkg/dashboard/stage_tracker_caption.go index 9ab5b632b6..3168e11912 100644 --- a/src/pkg/dashboard/stage_tracker_caption.go +++ b/src/pkg/dashboard/stage_tracker_caption.go @@ -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 } diff --git a/src/pkg/dashboard/stage_tracker_human_attention.test.js b/src/pkg/dashboard/stage_tracker_human_attention.test.js index 9b11628d07..c70e5660b8 100644 --- a/src/pkg/dashboard/stage_tracker_human_attention.test.js +++ b/src/pkg/dashboard/stage_tracker_human_attention.test.js @@ -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'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); + } +}); diff --git a/src/pkg/dashboard/stage_tracker_needs_human_reason_test.go b/src/pkg/dashboard/stage_tracker_needs_human_reason_test.go new file mode 100644 index 0000000000..37c3e36679 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_needs_human_reason_test.go @@ -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 = (/([^<]*)]*>([\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(/
  • ]*>/.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'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(/]*class="ham-lead-act ham-act-primary"[^>]*data-ham-act="open:app-settings"[^>]*>Grant the App workflows: write<\/button>/.test(htmlOut), htmlOut); +assert.ok(/]*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: "; 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) + } + } +} diff --git a/src/pkg/dashboard/stage_tracker_row_actions_test.go b/src/pkg/dashboard/stage_tracker_row_actions_test.go index 492f564f85..19ec78f7e4 100644 --- a/src/pkg/dashboard/stage_tracker_row_actions_test.go +++ b/src/pkg/dashboard/stage_tracker_row_actions_test.go @@ -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"), diff --git a/src/pkg/dashboard/stage_tracker_ui_prelude_test.go b/src/pkg/dashboard/stage_tracker_ui_prelude_test.go index e5ac270858..0bd1189921 100644 --- a/src/pkg/dashboard/stage_tracker_ui_prelude_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_prelude_test.go @@ -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"), diff --git a/src/pkg/dashboard/static-src/css/tracker.css b/src/pkg/dashboard/static-src/css/tracker.css index 35f3b1bb75..88b7c0a5ba 100644 --- a/src/pkg/dashboard/static-src/css/tracker.css +++ b/src/pkg/dashboard/static-src/css/tracker.css @@ -355,6 +355,12 @@ done-style step that keeps its word (stage_tracker_remediation.go). */ .ham-seg.active.ham-remediation-unassigned { background: color-mix(in srgb, var(--amber) 70%, var(--red)); } .ham-seg.done.ham-fix-pushed { color: var(--green); } +/* A done decision column that still names the blocker a person must + clear while a covering PR drives the strip (hivecommons/docs#612). */ +.ham-seg.done.ham-blocker-note { color: var(--amber); opacity: 1; } +/* The "needs human" pill is a button: click scrolls to the Needs human line. */ +.ham-needs-human-pill { cursor: pointer; font: inherit; } +.ham-needs-human-pill:hover, .ham-needs-human-pill:focus-visible { text-decoration: underline; } .ham-seg.todo { background: transparent; color: var(--text-faint); box-shadow: inset 0 0 0 var(--line-width) var(--line-subtle); opacity: 0.5; } .ham-seg.blank { visibility: hidden; } .ham-sub { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: var(--sp-2); margin-top: var(--sp-3); position: relative; } diff --git a/src/pkg/dashboard/static-src/js/tracker-actions.js b/src/pkg/dashboard/static-src/js/tracker-actions.js index bb735ff525..7752bc80bb 100644 --- a/src/pkg/dashboard/static-src/js/tracker-actions.js +++ b/src/pkg/dashboard/static-src/js/tracker-actions.js @@ -261,7 +261,11 @@ const out = []; // First: the hive decides as the owner's delegate (policy + rails on // the server; recorded as a human decision with an audit marker). - out.push({ id: 'decide:delegate', label: 'Let hive decide', hint: 'delegate', enabled, why }); + // The server may rule delegation out for this row (a capability gap + // no decision closes — hivecommons/docs#612); its reason wins. + const served = stageTrackerServerDelegate(item); + const delegateOff = !!served && served.enabled === false; + out.push({ id: 'decide:delegate', label: 'Let hive decide', hint: 'delegate', enabled: enabled && !delegateOff, why: delegateOff ? (served.reason_if_disabled || 'The hive cannot decide this one') : why }); if (item.kind === 'pr') { out.push({ id: 'decide:approve', label: 'Approve (/lgtm + /approve)', enabled, why }); out.push({ id: 'decide:close-superseded', label: 'Close as superseded by…', enabled, why, danger: true }); @@ -275,6 +279,11 @@ out.push({ id: 'decide:close-wontfix', label: "Close as won't-fix…", enabled, why, danger: true }); return out; } + // Pure: the server's decide:delegate option on the row, or null. + function stageTrackerServerDelegate(item) { + const opts = item && item.decision_needed && Array.isArray(item.decision_needed.options) ? item.decision_needed.options : []; + return opts.find(o => o && o.action === 'decide:delegate') || null; + } // Pure: the operator note for labels the row's stage has outrun // (stale_labels: a needs-triage still on a claimed issue, which the // reconciler removes on its next pass — hivecommons/hive#14586). '' when none. @@ -487,6 +496,15 @@ if (lead) return lead; const decide = actions.find(a => a.id === 'decide'); const safe = decide && Array.isArray(decide.submenu) ? decide.submenu.filter(x => x && !x.danger) : []; + // The server ruled delegation out (a capability gap): the first + // enabled, non-destructive blocker option leads instead — the + // person's actual move (open App settings, re-check permissions), + // not a greyed "Let hive decide" (hivecommons/docs#612). + const served = stageTrackerServerDelegate(item); + if (served && served.enabled === false) { + const b = stageTrackerBlockerActions(item, ctx).find(x => x.enabled && !x.danger); + if (b) return Object.assign({}, b, { target: (decide && decide.target) || { kind: item.kind, number: item.number, repo: item.repo } }); + } if (safe.length) { const o = safe.find(x => x.enabled) || safe[0]; const enabled = !!decide.enabled && !!o.enabled; @@ -570,7 +588,7 @@ function stageTrackerLeadCompanion(item, ctx, lead) { if (!item || !lead || lead.passive || lead.id === 'decide:delegate') return null; const dec = typeof stageTrackerDecisionOf === 'function' ? stageTrackerDecisionOf(item) : null; - const human = !!(dec && dec.item && dec.item.decision_needed) || (item.stage_actor && item.stage_actor.kind === 'human') || (Number(item.stage) || 0) === 85; + const human = !!(dec && dec.item && dec.item.decision_needed) || !!item.decision_needed || (item.stage_actor && item.stage_actor.kind === 'human') || (Number(item.stage) || 0) === 85; if (!human) return null; const decide = stageTrackerRowActions(item, ctx).find(a => a.id === 'decide'); const o = decide && Array.isArray(decide.submenu) ? decide.submenu.find(x => x && x.id === 'decide:delegate') : null; 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 fed814653d..c6e8e127a1 100644 --- a/src/pkg/dashboard/static-src/js/tracker-human-attention.js +++ b/src/pkg/dashboard/static-src/js/tracker-human-attention.js @@ -11,28 +11,99 @@ if (a.kind === 'pr' && String(a.head || '') !== String(item.head || '')) return null; return a; } - function stageTrackerHumanAttentionLine(item) { - const a = stageTrackerHumanAttentionOf(item); + // Pure: the decision a row carries itself when the server supplies no + // human_attention — a 045 issue or 085 PR with decision_needed, or a + // needs-human flag with a blocker (hivecommons/docs#612, rationguard#480). + // Same shape as human_attention ({reason, asked_by, question, synthetic}) + // so the note line reads the same either way. null when the row is not + // parked on a person, or when human_attention already says it. + function stageTrackerNeedsHumanAsk(item) { + if (!item || item.advisory || item.hold || item.state === 'closed' || Number(item.stage) >= STAGE_TRACKER_TERMINAL + || item.superseded_by || item.adopted_by) return null; + const mods = Array.isArray(item.modifiers) ? item.modifiers : []; + if (mods.some(m => m === 'draft' || m === 'hold' || m === 'merged')) return null; + if (stageTrackerHumanAttentionOf(item)) return null; + const n = Number(item.stage) || 0; + const flagged = item.needs_human === true || mods.indexOf('needs-human') >= 0 || mods.indexOf('needs-decision') >= 0 + || n === (typeof STAGE_TRACKER_NEEDS_DECISION === 'number' ? STAGE_TRACKER_NEEDS_DECISION : 85) + || n === (typeof STAGE_TRACKER_ISSUE_NEEDS_DECISION === 'number' ? STAGE_TRACKER_ISSUE_NEEDS_DECISION : 45); + if (!flagged) return null; + const d = item.decision_needed || {}; + const b = item.blocker || {}; + const actor = item.stage_actor || {}; + const question = String(d.question || '').trim(); + const why = String(actor.why || '').trim(); + const whyClause = why.indexOf(' — ') >= 0 ? why.slice(why.indexOf(' — ') + 3).trim() : ''; + // Only evidence the server put on the row counts — a parked stage + // alone synthesizes nothing (the row may be mid-refresh or hive-owned). + const reason = question || String(b.detail || '').trim() || String(d.blocker || '').trim() || String(b.short || '').trim() || (actor.kind === 'human' ? whyClause : ''); + if (!reason) return null; + return { kind: item.kind, number: Number(item.number) || 0, reason, question, asked_by: String(d.asked_by || actor.login && actor.kind === 'hive' && 'the hive' || '').trim() || 'the hive', synthetic: true }; + } + // Pure: "Needs human: — ", the + // short reason first so the row names the blocker before explaining it. + // A reason that already starts with the short form is not repeated. + // whole: keep the whole reason (a decision question is the ask itself). + function stageTrackerNeedsHumanReasonText(item, reason, whole) { + const full = String(reason || '').trim(); + const short = typeof stageTrackerNeedsHumanShort === 'function' ? stageTrackerNeedsHumanShort(item) : ''; + if (!short || full.toLowerCase().indexOf(short.toLowerCase()) === 0) return full; + const m = whole ? null : full.match(/^[\s\S]*?[.!?](?=\s|$)/); + const first = m ? m[0].trim() : full; + return first ? short + ' — ' + first : short; + } + // Pure: the label of the row's lead action, when a lifted copy has one + // (tracker-actions). '' without one, or when the lead is the optional + // delegation itself — that is not what the person is asked to do. + function stageTrackerNeedsHumanLeadLabel(item, subRows) { + if (typeof stageTrackerLeadActionOnRow !== 'function' || typeof stageTrackerActionCtx !== 'function') return ''; + const ctx = stageTrackerActionCtx(item.repo); + if (!ctx) return ''; + ctx.rows = typeof _stageTrackerRows !== 'undefined' ? _stageTrackerRows : null; + const action = stageTrackerLeadActionOnRow(item, ctx, subRows); + if (!action || !action.label || action.id === 'decide:delegate' || action.id === 'decide:delegate-all') return ''; + return String(action.label).replace(/\s*[▸›]\s*$/, ''); + } + // Pure: the one open covering PR a person other than the hive is pushing + // for this issue, when exactly one covers it. null otherwise. + function stageTrackerNeedsHumanPusher(item) { + if (!item || item.kind !== 'issue') return null; + if (typeof stageTrackerLinkedPROpen !== 'function') return null; + const open = (Array.isArray(item.linked_prs) ? item.linked_prs : []).filter(lp => lp && stageTrackerLinkedPROpen(lp, item)); + if (open.length !== 1) return null; + const lp = open[0]; + const human = (lp.author_kind || '') === 'human' || (lp.author_kind || '') === 'maintainer'; + return human && lp.author ? lp : null; + } + function stageTrackerHumanAttentionLine(item, subRows) { + const a = stageTrackerHumanAttentionOf(item) || stageTrackerNeedsHumanAsk(item); if (!a) return ''; - const reason = String(a.reason || '').trim() || 'Human decision required; reason unavailable'; + const reason = stageTrackerNeedsHumanReasonText(item, String(a.reason || '').trim() || 'Human decision required; reason unavailable', !!(a.synthetic && a.question)); const parts = ['Needs human: ' + reason]; if (a.owner) parts.push('next move: @' + a.owner); - if (a.asked_by) parts.push('requested by ' + a.asked_by); + if (a.asked_by) parts.push((a.synthetic ? 'asked by ' : 'requested by ') + a.asked_by); + const lead = stageTrackerNeedsHumanLeadLabel(item, subRows); + if (lead) parts.push('lead: ' + lead + ' â–¸'); + const pusher = stageTrackerNeedsHumanPusher(item); + if (pusher) parts.push('@' + pusher.author + ' is pushing it in #' + Number(pusher.number)); return parts.join(' · '); } - function stageTrackerHumanRequirementText(item) { + function stageTrackerHumanRequirementText(item, subRows) { if (!item || item.advisory || item.hold || item.state === 'closed' || Number(item.stage) >= STAGE_TRACKER_TERMINAL || item.superseded_by || item.adopted_by || (item.modifiers || []).some(m => m === 'draft' || m === 'hold' || m === 'merged')) return ''; - const human = stageTrackerHumanAttentionLine(item); + const human = stageTrackerHumanAttentionLine(item, subRows); const d = item && item.decided; const review = d && d.current_blocker && String(d.head || '') === String(item.head || '') ? 'Current blocker: ' + d.current_blocker + ' · operator approval recorded separately, not review approval or merge readiness' : ''; return [human, review].filter(Boolean).join(' · '); } - function stageTrackerHumanContextOf(item, stages) { + function stageTrackerHumanContextOf(item, stages, subRows) { if (!item) return []; - const own = stageTrackerHumanRequirementText(item); - const out = own ? [{ item, text: own }] : []; + const own = stageTrackerHumanRequirementText(item, subRows); + // An issue's own ask is prefixed with its number, like a PR's line, + // so a row whose strip a covering PR drives still names the asker. + const asks = item.kind === 'issue' && !!(stageTrackerHumanAttentionOf(item) || stageTrackerNeedsHumanAsk(item)); + const out = own ? [{ item, text: (asks ? '#' + Number(item.number) + ' — ' : '') + own }] : []; if (item.kind !== 'issue') return out; // Include external drawn_under references, but never walk RFC ancestry // or assign one child's requirement to the issue / its other PRs. @@ -60,7 +131,7 @@ return `
    ${bodyHtml}
    `; } function stageTrackerHumanContextHtml(item, stages, nowMs, subRows) { - const required = stageTrackerHumanContextOf(item, stages); + const required = stageTrackerHumanContextOf(item, stages, subRows); const lines = required.map(entry => { const it = entry.item; const href = it.url || item.url; diff --git a/src/pkg/dashboard/static-src/js/tracker-motion.js b/src/pkg/dashboard/static-src/js/tracker-motion.js index febe3c886d..e0f2e36b4e 100644 --- a/src/pkg/dashboard/static-src/js/tracker-motion.js +++ b/src/pkg/dashboard/static-src/js/tracker-motion.js @@ -293,6 +293,20 @@ stageTrackerNoteEventSet(key, stageTrackerNoteToggled(ev, nowMs, stageTrackerNoteTuckSetting())); stageTrackerNoteSync(document.getElementById('activity-monitor-panel'), nowMs); } + // The row's "needs human" pill: bring its "Needs human: …" line into + // view, untucked. rowKey: the row's data-ham-key. + function stageTrackerNeedsHumanReveal(rowKey) { + const panel = document.getElementById('activity-monitor-panel'); + if (!panel || !rowKey) return; + const rows = panel.querySelectorAll('.ham-row[data-ham-key]'); + let row = null; + for (const r of rows) if (r.getAttribute('data-ham-key') === String(rowKey)) { row = r; break; } + if (!row) return; + const line = row.querySelector('.ham-human-context[data-cue-key]'); + if (!line) return; + if (line.classList.contains('cue-event-tucked')) stageTrackerNoteToggle(line.getAttribute('data-cue-key')); + if (typeof line.scrollIntoView === 'function') line.scrollIntoView({ block: 'nearest' }); + } // Hidden tab: stop the clock on every open line; visible again: give // back the hidden time and re-arm. function stageTrackerNoteVisibility(hidden, nowMs) { diff --git a/src/pkg/dashboard/static-src/js/tracker-row-strip.js b/src/pkg/dashboard/static-src/js/tracker-row-strip.js index a57190b1bb..87bc10364a 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row-strip.js +++ b/src/pkg/dashboard/static-src/js/tracker-row-strip.js @@ -333,7 +333,10 @@ const to = range && range.to != null ? range.to : Infinity; const actorKind = stageTrackerActorKind(item); const humanIcon = actorKind === 'human' || actorKind === 'maintainer'; - const humanRequired = typeof stageTrackerHumanAttentionOf !== 'function' || !!stageTrackerHumanAttentionOf(item); + // A current requirement from the server (human_attention), or a + // decision the row carries itself (045 / 085 with decision_needed, + // which the server leaves out of human_attention past the gate). + const humanRequired = typeof stageTrackerHumanAttentionOf !== 'function' || !!stageTrackerHumanAttentionOf(item) || (typeof stageTrackerNeedsHumanAsk === 'function' && !!stageTrackerNeedsHumanAsk(item)); const actorIco = actorKind && (!humanIcon || humanRequired) ? stageTrackerIcon(actorKind, 'ham-ico ham-actor-ico', 'Next move: ' + actorKind) : ''; const actorTip = stageTrackerActorTip(item); // Guarded: test harnesses lift this function by name without stageTrackerHumanReason. @@ -390,7 +393,8 @@ const sentinel = !!(sg.detour && sg.detour.sentinel); const sentinelSuffix = !!(sg.detour && sg.detour.sentinelSuffix); const fixPushed = sg.number === 30 && sg.state === 'done' && remediation === 'fix_pushed'; - const cls = ['ham-seg', sg.state, sg.cap ? 'cap' : '', sg.state === 'active' && !sg.cap && waitingOnTracks ? 'ham-settled-current' : '', fixPushed ? 'ham-fix-pushed' : '', sg.state === 'active' && sg.number === 30 && remediation ? 'ham-remediation-' + remediation : '', sg.cap && sg.terminal ? 'merged' : '', sg.detour ? 'detoured' : '', sg.hold ? 'ham-open-hold' : '', sg.blocked ? 'ham-open-blocked' : '', sg.draft ? 'ham-open-draft' : '', sg.isNew ? 'ham-open-new' : '', sg.advisory ? 'ham-open-advisory' : '', sg.openSince && sg.openSince.stale ? 'ham-open-stale' : '', sentinel || sentinelSuffix ? 'ham-sentinel' : ''].filter(Boolean).join(' '); + const blockerNote = sg.state === 'done' && sg.blockerNote ? String(sg.blockerNote) : ''; + const cls = ['ham-seg', sg.state, sg.cap ? 'cap' : '', sg.state === 'active' && !sg.cap && waitingOnTracks ? 'ham-settled-current' : '', fixPushed ? 'ham-fix-pushed' : '', blockerNote ? 'ham-blocker-note' : '', sg.state === 'active' && sg.number === 30 && remediation ? 'ham-remediation-' + remediation : '', sg.cap && sg.terminal ? 'merged' : '', sg.detour ? 'detoured' : '', sg.hold ? 'ham-open-hold' : '', sg.blocked ? 'ham-open-blocked' : '', sg.draft ? 'ham-open-draft' : '', sg.isNew ? 'ham-open-new' : '', sg.advisory ? 'ham-open-advisory' : '', sg.openSince && sg.openSince.stale ? 'ham-open-stale' : '', sentinel || sentinelSuffix ? 'ham-sentinel' : ''].filter(Boolean).join(' '); const active = sg.state === 'active'; let tip = ''; let gateCaption = ''; @@ -478,6 +482,14 @@ // Inactive = icon only (hivecommons/hive#16599): the pushed fix is // the green glyph; its caption rides the tooltip. inner = `${stageTrackerIcon(sg.number, 'ham-ico')}${esc(pushedTip)}`; + } else if (blockerNote) { + // The issue's own column keeps the blocker in view while the + // covering PR's strip runs (hivecommons/docs#612): the word, the + // person glyph, and the blocker's detail as the hover. + const b = item.blocker || {}; + const noteTip = [blockerNote, b.detail, item.human_attention && item.human_attention.reason].filter(Boolean).join(' — '); + const tipID = 'ham-chevron-tip-' + [item.repo || '', item.kind || '', item.number || 0, sg.number].map(x => encodeURIComponent(String(x))).join('-'); + inner = `${stageTrackerIcon(sg.number, 'ham-ico')}${esc(blockerNote)}${stageTrackerIcon('human', 'ham-ico ham-actor-ico', 'Next move: human')}${esc(noteTip)}`; } else inner = stageTrackerIcon(sg.number, 'ham-ico'); return `
  • ${inner}
  • `; }).join(''); @@ -693,6 +705,23 @@ return lines.join('\n'); } + // Pure: the one open covering PR an issue's `blocked` pill stands for + // when nothing else blocks the issue — no structured blocker, no + // blocked_on dependencies, no blocked-on-PR marker, no re-check + // deadline — and that PR is parked on a human decision (085). The + // pill then reads "decision on #N" rather than a bare "blocked" + // (rationguard#431 under #480). null otherwise. + function stageTrackerBlockedForDecisionPR(item) { + if (!item || item.kind !== 'issue' || item.blocker) return null; + if (Array.isArray(item.blocked_on) && item.blocked_on.length) return null; + if (typeof stageTrackerBlockedOnPR === 'function' && stageTrackerBlockedOnPR(item)) return null; + if (/^blocked until /i.test(String(item.bucket_reason || ''))) return null; + const open = (Array.isArray(item.linked_prs) ? item.linked_prs : []).filter(lp => lp && (typeof stageTrackerLinkedPROpen !== 'function' || stageTrackerLinkedPROpen(lp, item))); + if (open.length !== 1) return null; + const lp = open[0]; + const parked = Number(lp.stage) === STAGE_TRACKER_NEEDS_DECISION || (Array.isArray(lp.modifiers) && lp.modifiers.indexOf('needs-decision') >= 0) || !!(lp.decision_needed && lp.decision_needed.question); + return parked ? lp : null; + } function stageTrackerChipsHtml(item) { const sentinel = stageTrackerSentinelChipHtml(item) + (typeof stageTrackerPreparationChipHtml === 'function' ? stageTrackerPreparationChipHtml(item) : '') + (typeof stageTrackerAdoptionChipHtml === 'function' ? stageTrackerAdoptionChipHtml(item) : '') + (typeof stageTrackerPresenceChipHtml === 'function' ? stageTrackerPresenceChipHtml(item) : '') + (typeof stageTrackerPushChipHtml === 'function' ? stageTrackerPushChipHtml(item, Date.now()) : '') + (typeof stageTrackerReroutePillHtml === 'function' ? stageTrackerReroutePillHtml(item) : '') + (typeof stageTrackerSupersedesChipHtml === 'function' ? stageTrackerSupersedesChipHtml(item, Date.now()) : '') + (typeof stageTrackerOverlapBadgeHtml === 'function' ? stageTrackerOverlapBadgeHtml(item) : ''); const mods = (Array.isArray(item.modifiers) ? item.modifiers.slice() : []) @@ -712,8 +741,10 @@ // A row the scheduler withholds for open GitHub "blocked by" dependencies names them (hivecommons/hive#14765); // one blocked on a PR (hive:blocked-on marker) names it and links to it (hivecommons/hive#14952). const blockedPR = mods[0] === 'blocked' ? stageTrackerBlockedOnPR(item) : null; + const decisionPR = mods[0] === 'blocked' && !blockedPR ? stageTrackerBlockedForDecisionPR(item) : null; if (mods[0] === 'blocked' && Array.isArray(item.blocked_on) && item.blocked_on.length) text = stageTrackerBlockedTip(item); else if (blockedPR) text = 'blocked on ' + blockedPR.short; + else if (decisionPR) text = 'decision on #' + Number(decisionPR.number); // A blocked row with a hive:recheck-after deadline ("blocked until ") names when the sweep re-checks it. const recheck = mods[0] === 'blocked' ? /^blocked until (\S+)/i.exec(String(item.bucket_reason || '')) : null; const recheckMs = recheck ? Date.parse(recheck[1]) : NaN; @@ -725,7 +756,14 @@ // the regressed pill explains itself; a blocked pill names what it waits on; // failing all three, a draft pill does. const anyBlockedPR = mods.indexOf('blocked') >= 0 ? stageTrackerBlockedOnPR(item) : null; + // A needs-human pill's hover is the full ask (hivecommons/docs#612 + // showed a bare muted "needs human" with no reason anywhere on the row). + const askable = mods[0] === 'needs-human' || mods[0] === 'needs-decision'; + const ask = (askable && typeof stageTrackerHumanAttentionOf === 'function' && stageTrackerHumanAttentionOf(item)) + || (askable && typeof stageTrackerNeedsHumanAsk === 'function' && stageTrackerNeedsHumanAsk(item)) || null; const tip = (mods.indexOf('unauthorized') >= 0 && String(item.unauthorized || '').trim()) || regressed + || (decisionPR ? 'Blocked only because PR #' + Number(decisionPR.number) + ' waits on a human decision' + (decisionPR.decision_needed && decisionPR.decision_needed.question ? ' — ' + decisionPR.decision_needed.question : '') : '') + || (ask ? ask.reason : '') || (holdPill && typeof stageTrackerHoldTip === 'function' ? stageTrackerHoldTip(item, Date.now()) : '') || (mods.indexOf('blocked') >= 0 && Array.isArray(item.blocked_on) && item.blocked_on.length ? 'Withheld from the scanner until ' + item.blocked_on.join(', ') + (item.blocked_on.length > 1 ? ' close' : ' closes') : '') || (anyBlockedPR ? anyBlockedPR.tip : '') @@ -738,8 +776,12 @@ // popover (what to decide, who asked, the applicable actions) instead // of a native tooltip. // A hive-set hold is a decision too (release or keep): its pill opens the same popover. - const decision = (mods[0] === 'needs-human' || mods[0] === 'needs-decision' || (holdPill && item.hold && item.hold.by === 'hive')) && typeof stageTrackerDecisionOf === 'function' ? stageTrackerDecisionOf(item) : null; + const decision = (mods[0] === 'needs-human' || mods[0] === 'needs-decision' || decisionPR || (holdPill && item.hold && item.hold.by === 'hive')) && typeof stageTrackerDecisionOf === 'function' ? stageTrackerDecisionOf(item) : null; if (decision) return sentinel + stageTrackerDecisionTriggerHtml(decision, inner, tip, 'ham-badge ham-badge-mod ' + cls); + // No popover to open (the ask is the issue's own while a covering + // PR drives the strip): the pill is a button that reveals the row's + // "Needs human: …" note line and carries the full reason as its hover. + if (ask && typeof stageTrackerItemKey === 'function') return sentinel + ``; return sentinel + `${inner}`; } diff --git a/src/pkg/dashboard/static-src/js/tracker-row.js b/src/pkg/dashboard/static-src/js/tracker-row.js index b47b42ebe0..609e076a22 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row.js +++ b/src/pkg/dashboard/static-src/js/tracker-row.js @@ -19,6 +19,15 @@ const detour = (!terminal && !pushedBack && STAGE_TRACKER_PATH.indexOf(cur) < 0 && cur !== STAGE_TRACKER_TRIAGE_NEEDED && cur !== STAGE_TRACKER_POSSIBLY_EXISTS && cur !== 40 && cur !== 60 && cur !== STAGE_TRACKER_PRE_MERGE_SOAK && cur !== 100) ? { text: sentinelLane ? STAGE_TRACKER_SENTINEL_WORD : (cur === STAGE_TRACKER_HUMAN_GATED && typeof stageTrackerTrainWord === 'function' && stageTrackerTrainWord(item)) || (cur === STAGE_TRACKER_READY_FOR_HUMAN_MERGE && item.manual_merge ? stageTrackerManualMergeWord(item) : (cur === STAGE_TRACKER_HUMAN_GATED && stageTrackerUnauthorizedWord(item)) || (typeof stageTrackerBlockerWord === 'function' && cur === STAGE_TRACKER_ISSUE_NEEDS_DECISION && stageTrackerBlockerWord(item)) || ((cur === STAGE_TRACKER_ADOPTED_BY_HIVE || (cur === STAGE_TRACKER_HUMAN_GATED && item.adopted_by_state)) && stageTrackerAdoptedWord(item)) || (cur === STAGE_TRACKER_READY_FOR_HUMAN_MERGE && stageTrackerReadyForHumanWord(item, STAGE_TRACKER_ACTIVE_WORD[cur] || curStage.short || curStage.label || String(cur))) || (STAGE_TRACKER_ACTIVE_WORD[cur] || curStage.short || curStage.label || String(cur))), sentinel: sentinelLane } : null; if (detour && cur === 70 && !detour.sentinel && typeof stageTrackerFixingWord === 'function') detour.text = stageTrackerFixingWord(item, detour.text); + // A bare "Needs human decision" (045 / 085) says why in the chevron + // itself — "Needs human · edits CI workflows" — when a short reason + // is known (rationguard#480: "what does 'needs human' mean?"). A + // word already carrying its why (Blocked · …, Waiting for @x · …, + // the train, the sentinel) stands. + if (detour && (cur === STAGE_TRACKER_NEEDS_DECISION || cur === STAGE_TRACKER_ISSUE_NEEDS_DECISION) && !detour.sentinel && detour.text === STAGE_TRACKER_ACTIVE_WORD[cur] && typeof stageTrackerNeedsHumanWord === 'function') { + const nh = stageTrackerNeedsHumanWord(item); + if (nh) detour.text = nh; + } if (detour && (cur === 71 || cur === 72) && typeof stageTrackerReturnedWord === 'function') { detour.text = stageTrackerReturnedWord(item, detour.text); detour.sentinelSuffix = stageTrackerSentinelAsSuffix(item); @@ -88,7 +97,12 @@ const os = stageTrackerOpenSince(item); if (os.ms) { word += ' · since ' + stageTrackerShortAgo(nowMs - os.ms); openSince = Object.assign({ stale: !openDraft && nowMs - os.ms > STAGE_TRACKER_OPEN_STALE_DAYS * 86400000 }, os); } } - return { number: n, code: n ? String(n).padStart(3, '0') : '', short: word, label: (typeof stageTrackerStageName === 'function' && (stageTrackerStageName(tipStage) || stageTrackerStageName(st))) || tipStage.label || st.label || String(n), description: tipStage.description || st.description || '', state, terminal: false, detour: n === anchor ? detour : null, hold: openHold, blocked: openBlocked, draft: openDraft, isNew: openNew && !advisory, advisory: !!advisory, openSince }; + // An issue parked on a blocker whose strip a human's covering PR + // drives (via_pr): the issue's own column keeps the blocker in + // view — "Blocked · App lacks workflows permission 👤" — rather + // than reading as a passed step (hivecommons/docs#612 under #620). + const blockerNote = state === 'done' && n === STAGE_TRACKER_ISSUE_DECISION_COLUMN && item.via_pr && item.kind === 'issue' && item.blocker && typeof stageTrackerBlockerWord === 'function' && (item.needs_human === true || (typeof stageTrackerItemNeedsHuman === 'function' && stageTrackerItemNeedsHuman(item))) ? stageTrackerBlockerWord(item) : ''; + return { number: n, code: n ? String(n).padStart(3, '0') : '', short: word, blockerNote, label: (typeof stageTrackerStageName === 'function' && (stageTrackerStageName(tipStage) || stageTrackerStageName(st))) || tipStage.label || st.label || String(n), description: tipStage.description || st.description || '', state, terminal: false, detour: n === anchor ? detour : null, hold: openHold, blocked: openBlocked, draft: openDraft, isNew: openNew && !advisory, advisory: !!advisory, openSince }; }); segs.push({ number: STAGE_TRACKER_TERMINAL, code: '', short: 'Merged', label: 'Merged', description: 'Merged — the pipeline is complete', state: terminal ? 'active' : 'todo', terminal, cap: true, detour: null }); return segs; diff --git a/src/pkg/dashboard/static-src/js/tracker-words-core.js b/src/pkg/dashboard/static-src/js/tracker-words-core.js index f4eb979adf..fa4bd49384 100644 --- a/src/pkg/dashboard/static-src/js/tracker-words-core.js +++ b/src/pkg/dashboard/static-src/js/tracker-words-core.js @@ -88,6 +88,44 @@ const short = String((b && b.short) || '').trim(); return short ? STAGE_TRACKER_BLOCKED_WORD + ' · ' + short : ''; } + // Why a person is needed, in a few words, for the row itself to say + // (hivecommons/docs#612, rationguard#480: "it's not clear reading the + // row why a human is needed"). The structured blocker's short text + // first; else the server's reason key (stage_actor.human_reason, the + // human-merge reason, the clause after "—" in stage_actor.why) through + // a small map of known reasons; else that clause's first sentence. + const STAGE_TRACKER_NEEDS_HUMAN_SHORT = { + 'workflow path': 'edits CI workflows', + 'hive signoff attribution': 'hive signoff attribution', + 'high-risk review': 'high-risk review', + 'optional check failing': 'optional check failing', + 'capability:workflows-permission': 'App lacks workflows permission', + }; + const STAGE_TRACKER_NEEDS_HUMAN_SHORT_MAX = 48; + const STAGE_TRACKER_NEEDS_HUMAN_WORD = 'Needs human'; + function stageTrackerNeedsHumanShort(item) { + if (!item) return ''; + const b = item.blocker; + if (b && String(b.short || '').trim()) return String(b.short).trim(); + if (b && STAGE_TRACKER_NEEDS_HUMAN_SHORT[String(b.kind || '').trim()]) return STAGE_TRACKER_NEEDS_HUMAN_SHORT[String(b.kind || '').trim()]; + const sa = item.stage_actor || {}; + const afterDash = s => { const t = String(s || ''); const i = t.indexOf(' — '); return i >= 0 ? t.slice(i + 3) : ''; }; + const keys = [sa.human_reason, item.human_merge_reason, afterDash(sa.why), afterDash(item.caption), item.reason]; + for (const k of keys) { + const key = String(k || '').replace(/\s+/g, ' ').trim().toLowerCase(); + if (key && STAGE_TRACKER_NEEDS_HUMAN_SHORT[key]) return STAGE_TRACKER_NEEDS_HUMAN_SHORT[key]; + } + const clause = String(afterDash(sa.why) || sa.human_reason || '').replace(/\s+/g, ' ').trim().split(/[;.](?:\s|$)/)[0].trim(); + if (!clause) return ''; + return clause.length > STAGE_TRACKER_NEEDS_HUMAN_SHORT_MAX ? clause.slice(0, STAGE_TRACKER_NEEDS_HUMAN_SHORT_MAX - 1).replace(/\s+\S*$/, '') + '…' : clause; + } + // The lit 045 / 085 chevron's caption: "Needs human · edits CI + // workflows" rather than a bare "Needs human decision". '' when no + // short reason is known (the plain stage word stands). + function stageTrackerNeedsHumanWord(item) { + const short = stageTrackerNeedsHumanShort(item); + return short ? STAGE_TRACKER_NEEDS_HUMAN_WORD + ' · ' + short : ''; + } // A decomposed parent at 010 (server `open_children` > 0, hive#16481) // reads "Tracking · 3/4" (children known) or "Tracking · 1 open child", // never "Actionable": the scanner leaves it to its children, so the diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 7a018174c7..8e44fe5616 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -1695,6 +1695,12 @@ done-style step that keeps its word (stage_tracker_remediation.go). */ .ham-seg.active.ham-remediation-unassigned { background: color-mix(in srgb, var(--amber) 70%, var(--red)); } .ham-seg.done.ham-fix-pushed { color: var(--green); } +/* A done decision column that still names the blocker a person must + clear while a covering PR drives the strip (hivecommons/docs#612). */ +.ham-seg.done.ham-blocker-note { color: var(--amber); opacity: 1; } +/* The "needs human" pill is a button: click scrolls to the Needs human line. */ +.ham-needs-human-pill { cursor: pointer; font: inherit; } +.ham-needs-human-pill:hover, .ham-needs-human-pill:focus-visible { text-decoration: underline; } .ham-seg.todo { background: transparent; color: var(--text-faint); box-shadow: inset 0 0 0 var(--line-width) var(--line-subtle); opacity: 0.5; } .ham-seg.blank { visibility: hidden; } .ham-sub { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: var(--sp-2); margin-top: var(--sp-3); position: relative; } @@ -15468,6 +15474,44 @@

    Where to get help

    const short = String((b && b.short) || '').trim(); return short ? STAGE_TRACKER_BLOCKED_WORD + ' · ' + short : ''; } + // Why a person is needed, in a few words, for the row itself to say + // (hivecommons/docs#612, rationguard#480: "it's not clear reading the + // row why a human is needed"). The structured blocker's short text + // first; else the server's reason key (stage_actor.human_reason, the + // human-merge reason, the clause after "—" in stage_actor.why) through + // a small map of known reasons; else that clause's first sentence. + const STAGE_TRACKER_NEEDS_HUMAN_SHORT = { + 'workflow path': 'edits CI workflows', + 'hive signoff attribution': 'hive signoff attribution', + 'high-risk review': 'high-risk review', + 'optional check failing': 'optional check failing', + 'capability:workflows-permission': 'App lacks workflows permission', + }; + const STAGE_TRACKER_NEEDS_HUMAN_SHORT_MAX = 48; + const STAGE_TRACKER_NEEDS_HUMAN_WORD = 'Needs human'; + function stageTrackerNeedsHumanShort(item) { + if (!item) return ''; + const b = item.blocker; + if (b && String(b.short || '').trim()) return String(b.short).trim(); + if (b && STAGE_TRACKER_NEEDS_HUMAN_SHORT[String(b.kind || '').trim()]) return STAGE_TRACKER_NEEDS_HUMAN_SHORT[String(b.kind || '').trim()]; + const sa = item.stage_actor || {}; + const afterDash = s => { const t = String(s || ''); const i = t.indexOf(' — '); return i >= 0 ? t.slice(i + 3) : ''; }; + const keys = [sa.human_reason, item.human_merge_reason, afterDash(sa.why), afterDash(item.caption), item.reason]; + for (const k of keys) { + const key = String(k || '').replace(/\s+/g, ' ').trim().toLowerCase(); + if (key && STAGE_TRACKER_NEEDS_HUMAN_SHORT[key]) return STAGE_TRACKER_NEEDS_HUMAN_SHORT[key]; + } + const clause = String(afterDash(sa.why) || sa.human_reason || '').replace(/\s+/g, ' ').trim().split(/[;.](?:\s|$)/)[0].trim(); + if (!clause) return ''; + return clause.length > STAGE_TRACKER_NEEDS_HUMAN_SHORT_MAX ? clause.slice(0, STAGE_TRACKER_NEEDS_HUMAN_SHORT_MAX - 1).replace(/\s+\S*$/, '') + '…' : clause; + } + // The lit 045 / 085 chevron's caption: "Needs human · edits CI + // workflows" rather than a bare "Needs human decision". '' when no + // short reason is known (the plain stage word stands). + function stageTrackerNeedsHumanWord(item) { + const short = stageTrackerNeedsHumanShort(item); + return short ? STAGE_TRACKER_NEEDS_HUMAN_WORD + ' · ' + short : ''; + } // A decomposed parent at 010 (server `open_children` > 0, hive#16481) // reads "Tracking · 3/4" (children known) or "Tracking · 1 open child", // never "Actionable": the scanner leaves it to its children, so the @@ -17478,6 +17522,15 @@

    Where to get help

    const detour = (!terminal && !pushedBack && STAGE_TRACKER_PATH.indexOf(cur) < 0 && cur !== STAGE_TRACKER_TRIAGE_NEEDED && cur !== STAGE_TRACKER_POSSIBLY_EXISTS && cur !== 40 && cur !== 60 && cur !== STAGE_TRACKER_PRE_MERGE_SOAK && cur !== 100) ? { text: sentinelLane ? STAGE_TRACKER_SENTINEL_WORD : (cur === STAGE_TRACKER_HUMAN_GATED && typeof stageTrackerTrainWord === 'function' && stageTrackerTrainWord(item)) || (cur === STAGE_TRACKER_READY_FOR_HUMAN_MERGE && item.manual_merge ? stageTrackerManualMergeWord(item) : (cur === STAGE_TRACKER_HUMAN_GATED && stageTrackerUnauthorizedWord(item)) || (typeof stageTrackerBlockerWord === 'function' && cur === STAGE_TRACKER_ISSUE_NEEDS_DECISION && stageTrackerBlockerWord(item)) || ((cur === STAGE_TRACKER_ADOPTED_BY_HIVE || (cur === STAGE_TRACKER_HUMAN_GATED && item.adopted_by_state)) && stageTrackerAdoptedWord(item)) || (cur === STAGE_TRACKER_READY_FOR_HUMAN_MERGE && stageTrackerReadyForHumanWord(item, STAGE_TRACKER_ACTIVE_WORD[cur] || curStage.short || curStage.label || String(cur))) || (STAGE_TRACKER_ACTIVE_WORD[cur] || curStage.short || curStage.label || String(cur))), sentinel: sentinelLane } : null; if (detour && cur === 70 && !detour.sentinel && typeof stageTrackerFixingWord === 'function') detour.text = stageTrackerFixingWord(item, detour.text); + // A bare "Needs human decision" (045 / 085) says why in the chevron + // itself — "Needs human · edits CI workflows" — when a short reason + // is known (rationguard#480: "what does 'needs human' mean?"). A + // word already carrying its why (Blocked · …, Waiting for @x · …, + // the train, the sentinel) stands. + if (detour && (cur === STAGE_TRACKER_NEEDS_DECISION || cur === STAGE_TRACKER_ISSUE_NEEDS_DECISION) && !detour.sentinel && detour.text === STAGE_TRACKER_ACTIVE_WORD[cur] && typeof stageTrackerNeedsHumanWord === 'function') { + const nh = stageTrackerNeedsHumanWord(item); + if (nh) detour.text = nh; + } if (detour && (cur === 71 || cur === 72) && typeof stageTrackerReturnedWord === 'function') { detour.text = stageTrackerReturnedWord(item, detour.text); detour.sentinelSuffix = stageTrackerSentinelAsSuffix(item); @@ -17547,7 +17600,12 @@

    Where to get help

    const os = stageTrackerOpenSince(item); if (os.ms) { word += ' · since ' + stageTrackerShortAgo(nowMs - os.ms); openSince = Object.assign({ stale: !openDraft && nowMs - os.ms > STAGE_TRACKER_OPEN_STALE_DAYS * 86400000 }, os); } } - return { number: n, code: n ? String(n).padStart(3, '0') : '', short: word, label: (typeof stageTrackerStageName === 'function' && (stageTrackerStageName(tipStage) || stageTrackerStageName(st))) || tipStage.label || st.label || String(n), description: tipStage.description || st.description || '', state, terminal: false, detour: n === anchor ? detour : null, hold: openHold, blocked: openBlocked, draft: openDraft, isNew: openNew && !advisory, advisory: !!advisory, openSince }; + // An issue parked on a blocker whose strip a human's covering PR + // drives (via_pr): the issue's own column keeps the blocker in + // view — "Blocked · App lacks workflows permission 👤" — rather + // than reading as a passed step (hivecommons/docs#612 under #620). + const blockerNote = state === 'done' && n === STAGE_TRACKER_ISSUE_DECISION_COLUMN && item.via_pr && item.kind === 'issue' && item.blocker && typeof stageTrackerBlockerWord === 'function' && (item.needs_human === true || (typeof stageTrackerItemNeedsHuman === 'function' && stageTrackerItemNeedsHuman(item))) ? stageTrackerBlockerWord(item) : ''; + return { number: n, code: n ? String(n).padStart(3, '0') : '', short: word, blockerNote, label: (typeof stageTrackerStageName === 'function' && (stageTrackerStageName(tipStage) || stageTrackerStageName(st))) || tipStage.label || st.label || String(n), description: tipStage.description || st.description || '', state, terminal: false, detour: n === anchor ? detour : null, hold: openHold, blocked: openBlocked, draft: openDraft, isNew: openNew && !advisory, advisory: !!advisory, openSince }; }); segs.push({ number: STAGE_TRACKER_TERMINAL, code: '', short: 'Merged', label: 'Merged', description: 'Merged — the pipeline is complete', state: terminal ? 'active' : 'todo', terminal, cap: true, detour: null }); return segs; @@ -18141,7 +18199,10 @@

    Where to get help

    const to = range && range.to != null ? range.to : Infinity; const actorKind = stageTrackerActorKind(item); const humanIcon = actorKind === 'human' || actorKind === 'maintainer'; - const humanRequired = typeof stageTrackerHumanAttentionOf !== 'function' || !!stageTrackerHumanAttentionOf(item); + // A current requirement from the server (human_attention), or a + // decision the row carries itself (045 / 085 with decision_needed, + // which the server leaves out of human_attention past the gate). + const humanRequired = typeof stageTrackerHumanAttentionOf !== 'function' || !!stageTrackerHumanAttentionOf(item) || (typeof stageTrackerNeedsHumanAsk === 'function' && !!stageTrackerNeedsHumanAsk(item)); const actorIco = actorKind && (!humanIcon || humanRequired) ? stageTrackerIcon(actorKind, 'ham-ico ham-actor-ico', 'Next move: ' + actorKind) : ''; const actorTip = stageTrackerActorTip(item); // Guarded: test harnesses lift this function by name without stageTrackerHumanReason. @@ -18198,7 +18259,8 @@

    Where to get help

    const sentinel = !!(sg.detour && sg.detour.sentinel); const sentinelSuffix = !!(sg.detour && sg.detour.sentinelSuffix); const fixPushed = sg.number === 30 && sg.state === 'done' && remediation === 'fix_pushed'; - const cls = ['ham-seg', sg.state, sg.cap ? 'cap' : '', sg.state === 'active' && !sg.cap && waitingOnTracks ? 'ham-settled-current' : '', fixPushed ? 'ham-fix-pushed' : '', sg.state === 'active' && sg.number === 30 && remediation ? 'ham-remediation-' + remediation : '', sg.cap && sg.terminal ? 'merged' : '', sg.detour ? 'detoured' : '', sg.hold ? 'ham-open-hold' : '', sg.blocked ? 'ham-open-blocked' : '', sg.draft ? 'ham-open-draft' : '', sg.isNew ? 'ham-open-new' : '', sg.advisory ? 'ham-open-advisory' : '', sg.openSince && sg.openSince.stale ? 'ham-open-stale' : '', sentinel || sentinelSuffix ? 'ham-sentinel' : ''].filter(Boolean).join(' '); + const blockerNote = sg.state === 'done' && sg.blockerNote ? String(sg.blockerNote) : ''; + const cls = ['ham-seg', sg.state, sg.cap ? 'cap' : '', sg.state === 'active' && !sg.cap && waitingOnTracks ? 'ham-settled-current' : '', fixPushed ? 'ham-fix-pushed' : '', blockerNote ? 'ham-blocker-note' : '', sg.state === 'active' && sg.number === 30 && remediation ? 'ham-remediation-' + remediation : '', sg.cap && sg.terminal ? 'merged' : '', sg.detour ? 'detoured' : '', sg.hold ? 'ham-open-hold' : '', sg.blocked ? 'ham-open-blocked' : '', sg.draft ? 'ham-open-draft' : '', sg.isNew ? 'ham-open-new' : '', sg.advisory ? 'ham-open-advisory' : '', sg.openSince && sg.openSince.stale ? 'ham-open-stale' : '', sentinel || sentinelSuffix ? 'ham-sentinel' : ''].filter(Boolean).join(' '); const active = sg.state === 'active'; let tip = ''; let gateCaption = ''; @@ -18286,6 +18348,14 @@

    Where to get help

    // Inactive = icon only (hivecommons/hive#16599): the pushed fix is // the green glyph; its caption rides the tooltip. inner = `${stageTrackerIcon(sg.number, 'ham-ico')}${esc(pushedTip)}`; + } else if (blockerNote) { + // The issue's own column keeps the blocker in view while the + // covering PR's strip runs (hivecommons/docs#612): the word, the + // person glyph, and the blocker's detail as the hover. + const b = item.blocker || {}; + const noteTip = [blockerNote, b.detail, item.human_attention && item.human_attention.reason].filter(Boolean).join(' — '); + const tipID = 'ham-chevron-tip-' + [item.repo || '', item.kind || '', item.number || 0, sg.number].map(x => encodeURIComponent(String(x))).join('-'); + inner = `${stageTrackerIcon(sg.number, 'ham-ico')}${esc(blockerNote)}${stageTrackerIcon('human', 'ham-ico ham-actor-ico', 'Next move: human')}${esc(noteTip)}`; } else inner = stageTrackerIcon(sg.number, 'ham-ico'); return `
  • ${inner}
  • `; }).join(''); @@ -18501,6 +18571,23 @@

    Where to get help

    return lines.join('\n'); } + // Pure: the one open covering PR an issue's `blocked` pill stands for + // when nothing else blocks the issue — no structured blocker, no + // blocked_on dependencies, no blocked-on-PR marker, no re-check + // deadline — and that PR is parked on a human decision (085). The + // pill then reads "decision on #N" rather than a bare "blocked" + // (rationguard#431 under #480). null otherwise. + function stageTrackerBlockedForDecisionPR(item) { + if (!item || item.kind !== 'issue' || item.blocker) return null; + if (Array.isArray(item.blocked_on) && item.blocked_on.length) return null; + if (typeof stageTrackerBlockedOnPR === 'function' && stageTrackerBlockedOnPR(item)) return null; + if (/^blocked until /i.test(String(item.bucket_reason || ''))) return null; + const open = (Array.isArray(item.linked_prs) ? item.linked_prs : []).filter(lp => lp && (typeof stageTrackerLinkedPROpen !== 'function' || stageTrackerLinkedPROpen(lp, item))); + if (open.length !== 1) return null; + const lp = open[0]; + const parked = Number(lp.stage) === STAGE_TRACKER_NEEDS_DECISION || (Array.isArray(lp.modifiers) && lp.modifiers.indexOf('needs-decision') >= 0) || !!(lp.decision_needed && lp.decision_needed.question); + return parked ? lp : null; + } function stageTrackerChipsHtml(item) { const sentinel = stageTrackerSentinelChipHtml(item) + (typeof stageTrackerPreparationChipHtml === 'function' ? stageTrackerPreparationChipHtml(item) : '') + (typeof stageTrackerAdoptionChipHtml === 'function' ? stageTrackerAdoptionChipHtml(item) : '') + (typeof stageTrackerPresenceChipHtml === 'function' ? stageTrackerPresenceChipHtml(item) : '') + (typeof stageTrackerPushChipHtml === 'function' ? stageTrackerPushChipHtml(item, Date.now()) : '') + (typeof stageTrackerReroutePillHtml === 'function' ? stageTrackerReroutePillHtml(item) : '') + (typeof stageTrackerSupersedesChipHtml === 'function' ? stageTrackerSupersedesChipHtml(item, Date.now()) : '') + (typeof stageTrackerOverlapBadgeHtml === 'function' ? stageTrackerOverlapBadgeHtml(item) : ''); const mods = (Array.isArray(item.modifiers) ? item.modifiers.slice() : []) @@ -18520,8 +18607,10 @@

    Where to get help

    // A row the scheduler withholds for open GitHub "blocked by" dependencies names them (hivecommons/hive#14765); // one blocked on a PR (hive:blocked-on marker) names it and links to it (hivecommons/hive#14952). const blockedPR = mods[0] === 'blocked' ? stageTrackerBlockedOnPR(item) : null; + const decisionPR = mods[0] === 'blocked' && !blockedPR ? stageTrackerBlockedForDecisionPR(item) : null; if (mods[0] === 'blocked' && Array.isArray(item.blocked_on) && item.blocked_on.length) text = stageTrackerBlockedTip(item); else if (blockedPR) text = 'blocked on ' + blockedPR.short; + else if (decisionPR) text = 'decision on #' + Number(decisionPR.number); // A blocked row with a hive:recheck-after deadline ("blocked until ") names when the sweep re-checks it. const recheck = mods[0] === 'blocked' ? /^blocked until (\S+)/i.exec(String(item.bucket_reason || '')) : null; const recheckMs = recheck ? Date.parse(recheck[1]) : NaN; @@ -18533,7 +18622,14 @@

    Where to get help

    // the regressed pill explains itself; a blocked pill names what it waits on; // failing all three, a draft pill does. const anyBlockedPR = mods.indexOf('blocked') >= 0 ? stageTrackerBlockedOnPR(item) : null; + // A needs-human pill's hover is the full ask (hivecommons/docs#612 + // showed a bare muted "needs human" with no reason anywhere on the row). + const askable = mods[0] === 'needs-human' || mods[0] === 'needs-decision'; + const ask = (askable && typeof stageTrackerHumanAttentionOf === 'function' && stageTrackerHumanAttentionOf(item)) + || (askable && typeof stageTrackerNeedsHumanAsk === 'function' && stageTrackerNeedsHumanAsk(item)) || null; const tip = (mods.indexOf('unauthorized') >= 0 && String(item.unauthorized || '').trim()) || regressed + || (decisionPR ? 'Blocked only because PR #' + Number(decisionPR.number) + ' waits on a human decision' + (decisionPR.decision_needed && decisionPR.decision_needed.question ? ' — ' + decisionPR.decision_needed.question : '') : '') + || (ask ? ask.reason : '') || (holdPill && typeof stageTrackerHoldTip === 'function' ? stageTrackerHoldTip(item, Date.now()) : '') || (mods.indexOf('blocked') >= 0 && Array.isArray(item.blocked_on) && item.blocked_on.length ? 'Withheld from the scanner until ' + item.blocked_on.join(', ') + (item.blocked_on.length > 1 ? ' close' : ' closes') : '') || (anyBlockedPR ? anyBlockedPR.tip : '') @@ -18546,8 +18642,12 @@

    Where to get help

    // popover (what to decide, who asked, the applicable actions) instead // of a native tooltip. // A hive-set hold is a decision too (release or keep): its pill opens the same popover. - const decision = (mods[0] === 'needs-human' || mods[0] === 'needs-decision' || (holdPill && item.hold && item.hold.by === 'hive')) && typeof stageTrackerDecisionOf === 'function' ? stageTrackerDecisionOf(item) : null; + const decision = (mods[0] === 'needs-human' || mods[0] === 'needs-decision' || decisionPR || (holdPill && item.hold && item.hold.by === 'hive')) && typeof stageTrackerDecisionOf === 'function' ? stageTrackerDecisionOf(item) : null; if (decision) return sentinel + stageTrackerDecisionTriggerHtml(decision, inner, tip, 'ham-badge ham-badge-mod ' + cls); + // No popover to open (the ask is the issue's own while a covering + // PR drives the strip): the pill is a button that reveals the row's + // "Needs human: …" note line and carries the full reason as its hover. + if (ask && typeof stageTrackerItemKey === 'function') return sentinel + ``; return sentinel + `${inner}`; } @@ -18790,28 +18890,99 @@

    Where to get help

    if (a.kind === 'pr' && String(a.head || '') !== String(item.head || '')) return null; return a; } - function stageTrackerHumanAttentionLine(item) { - const a = stageTrackerHumanAttentionOf(item); + // Pure: the decision a row carries itself when the server supplies no + // human_attention — a 045 issue or 085 PR with decision_needed, or a + // needs-human flag with a blocker (hivecommons/docs#612, rationguard#480). + // Same shape as human_attention ({reason, asked_by, question, synthetic}) + // so the note line reads the same either way. null when the row is not + // parked on a person, or when human_attention already says it. + function stageTrackerNeedsHumanAsk(item) { + if (!item || item.advisory || item.hold || item.state === 'closed' || Number(item.stage) >= STAGE_TRACKER_TERMINAL + || item.superseded_by || item.adopted_by) return null; + const mods = Array.isArray(item.modifiers) ? item.modifiers : []; + if (mods.some(m => m === 'draft' || m === 'hold' || m === 'merged')) return null; + if (stageTrackerHumanAttentionOf(item)) return null; + const n = Number(item.stage) || 0; + const flagged = item.needs_human === true || mods.indexOf('needs-human') >= 0 || mods.indexOf('needs-decision') >= 0 + || n === (typeof STAGE_TRACKER_NEEDS_DECISION === 'number' ? STAGE_TRACKER_NEEDS_DECISION : 85) + || n === (typeof STAGE_TRACKER_ISSUE_NEEDS_DECISION === 'number' ? STAGE_TRACKER_ISSUE_NEEDS_DECISION : 45); + if (!flagged) return null; + const d = item.decision_needed || {}; + const b = item.blocker || {}; + const actor = item.stage_actor || {}; + const question = String(d.question || '').trim(); + const why = String(actor.why || '').trim(); + const whyClause = why.indexOf(' — ') >= 0 ? why.slice(why.indexOf(' — ') + 3).trim() : ''; + // Only evidence the server put on the row counts — a parked stage + // alone synthesizes nothing (the row may be mid-refresh or hive-owned). + const reason = question || String(b.detail || '').trim() || String(d.blocker || '').trim() || String(b.short || '').trim() || (actor.kind === 'human' ? whyClause : ''); + if (!reason) return null; + return { kind: item.kind, number: Number(item.number) || 0, reason, question, asked_by: String(d.asked_by || actor.login && actor.kind === 'hive' && 'the hive' || '').trim() || 'the hive', synthetic: true }; + } + // Pure: "Needs human: — ", the + // short reason first so the row names the blocker before explaining it. + // A reason that already starts with the short form is not repeated. + // whole: keep the whole reason (a decision question is the ask itself). + function stageTrackerNeedsHumanReasonText(item, reason, whole) { + const full = String(reason || '').trim(); + const short = typeof stageTrackerNeedsHumanShort === 'function' ? stageTrackerNeedsHumanShort(item) : ''; + if (!short || full.toLowerCase().indexOf(short.toLowerCase()) === 0) return full; + const m = whole ? null : full.match(/^[\s\S]*?[.!?](?=\s|$)/); + const first = m ? m[0].trim() : full; + return first ? short + ' — ' + first : short; + } + // Pure: the label of the row's lead action, when a lifted copy has one + // (tracker-actions). '' without one, or when the lead is the optional + // delegation itself — that is not what the person is asked to do. + function stageTrackerNeedsHumanLeadLabel(item, subRows) { + if (typeof stageTrackerLeadActionOnRow !== 'function' || typeof stageTrackerActionCtx !== 'function') return ''; + const ctx = stageTrackerActionCtx(item.repo); + if (!ctx) return ''; + ctx.rows = typeof _stageTrackerRows !== 'undefined' ? _stageTrackerRows : null; + const action = stageTrackerLeadActionOnRow(item, ctx, subRows); + if (!action || !action.label || action.id === 'decide:delegate' || action.id === 'decide:delegate-all') return ''; + return String(action.label).replace(/\s*[▸›]\s*$/, ''); + } + // Pure: the one open covering PR a person other than the hive is pushing + // for this issue, when exactly one covers it. null otherwise. + function stageTrackerNeedsHumanPusher(item) { + if (!item || item.kind !== 'issue') return null; + if (typeof stageTrackerLinkedPROpen !== 'function') return null; + const open = (Array.isArray(item.linked_prs) ? item.linked_prs : []).filter(lp => lp && stageTrackerLinkedPROpen(lp, item)); + if (open.length !== 1) return null; + const lp = open[0]; + const human = (lp.author_kind || '') === 'human' || (lp.author_kind || '') === 'maintainer'; + return human && lp.author ? lp : null; + } + function stageTrackerHumanAttentionLine(item, subRows) { + const a = stageTrackerHumanAttentionOf(item) || stageTrackerNeedsHumanAsk(item); if (!a) return ''; - const reason = String(a.reason || '').trim() || 'Human decision required; reason unavailable'; + const reason = stageTrackerNeedsHumanReasonText(item, String(a.reason || '').trim() || 'Human decision required; reason unavailable', !!(a.synthetic && a.question)); const parts = ['Needs human: ' + reason]; if (a.owner) parts.push('next move: @' + a.owner); - if (a.asked_by) parts.push('requested by ' + a.asked_by); + if (a.asked_by) parts.push((a.synthetic ? 'asked by ' : 'requested by ') + a.asked_by); + const lead = stageTrackerNeedsHumanLeadLabel(item, subRows); + if (lead) parts.push('lead: ' + lead + ' ▸'); + const pusher = stageTrackerNeedsHumanPusher(item); + if (pusher) parts.push('@' + pusher.author + ' is pushing it in #' + Number(pusher.number)); return parts.join(' · '); } - function stageTrackerHumanRequirementText(item) { + function stageTrackerHumanRequirementText(item, subRows) { if (!item || item.advisory || item.hold || item.state === 'closed' || Number(item.stage) >= STAGE_TRACKER_TERMINAL || item.superseded_by || item.adopted_by || (item.modifiers || []).some(m => m === 'draft' || m === 'hold' || m === 'merged')) return ''; - const human = stageTrackerHumanAttentionLine(item); + const human = stageTrackerHumanAttentionLine(item, subRows); const d = item && item.decided; const review = d && d.current_blocker && String(d.head || '') === String(item.head || '') ? 'Current blocker: ' + d.current_blocker + ' · operator approval recorded separately, not review approval or merge readiness' : ''; return [human, review].filter(Boolean).join(' · '); } - function stageTrackerHumanContextOf(item, stages) { + function stageTrackerHumanContextOf(item, stages, subRows) { if (!item) return []; - const own = stageTrackerHumanRequirementText(item); - const out = own ? [{ item, text: own }] : []; + const own = stageTrackerHumanRequirementText(item, subRows); + // An issue's own ask is prefixed with its number, like a PR's line, + // so a row whose strip a covering PR drives still names the asker. + const asks = item.kind === 'issue' && !!(stageTrackerHumanAttentionOf(item) || stageTrackerNeedsHumanAsk(item)); + const out = own ? [{ item, text: (asks ? '#' + Number(item.number) + ' — ' : '') + own }] : []; if (item.kind !== 'issue') return out; // Include external drawn_under references, but never walk RFC ancestry // or assign one child's requirement to the issue / its other PRs. @@ -18839,7 +19010,7 @@

    Where to get help

    return `
    ${bodyHtml}
    `; } function stageTrackerHumanContextHtml(item, stages, nowMs, subRows) { - const required = stageTrackerHumanContextOf(item, stages); + const required = stageTrackerHumanContextOf(item, stages, subRows); const lines = required.map(entry => { const it = entry.item; const href = it.url || item.url; @@ -19766,6 +19937,20 @@

    Where to get help

    stageTrackerNoteEventSet(key, stageTrackerNoteToggled(ev, nowMs, stageTrackerNoteTuckSetting())); stageTrackerNoteSync(document.getElementById('activity-monitor-panel'), nowMs); } + // The row's "needs human" pill: bring its "Needs human: …" line into + // view, untucked. rowKey: the row's data-ham-key. + function stageTrackerNeedsHumanReveal(rowKey) { + const panel = document.getElementById('activity-monitor-panel'); + if (!panel || !rowKey) return; + const rows = panel.querySelectorAll('.ham-row[data-ham-key]'); + let row = null; + for (const r of rows) if (r.getAttribute('data-ham-key') === String(rowKey)) { row = r; break; } + if (!row) return; + const line = row.querySelector('.ham-human-context[data-cue-key]'); + if (!line) return; + if (line.classList.contains('cue-event-tucked')) stageTrackerNoteToggle(line.getAttribute('data-cue-key')); + if (typeof line.scrollIntoView === 'function') line.scrollIntoView({ block: 'nearest' }); + } // Hidden tab: stop the clock on every open line; visible again: give // back the hidden time and re-arm. function stageTrackerNoteVisibility(hidden, nowMs) { @@ -22138,7 +22323,11 @@

    All labels

    const out = []; // First: the hive decides as the owner's delegate (policy + rails on // the server; recorded as a human decision with an audit marker). - out.push({ id: 'decide:delegate', label: 'Let hive decide', hint: 'delegate', enabled, why }); + // The server may rule delegation out for this row (a capability gap + // no decision closes — hivecommons/docs#612); its reason wins. + const served = stageTrackerServerDelegate(item); + const delegateOff = !!served && served.enabled === false; + out.push({ id: 'decide:delegate', label: 'Let hive decide', hint: 'delegate', enabled: enabled && !delegateOff, why: delegateOff ? (served.reason_if_disabled || 'The hive cannot decide this one') : why }); if (item.kind === 'pr') { out.push({ id: 'decide:approve', label: 'Approve (/lgtm + /approve)', enabled, why }); out.push({ id: 'decide:close-superseded', label: 'Close as superseded by…', enabled, why, danger: true }); @@ -22152,6 +22341,11 @@

    All labels

    out.push({ id: 'decide:close-wontfix', label: "Close as won't-fix…", enabled, why, danger: true }); return out; } + // Pure: the server's decide:delegate option on the row, or null. + function stageTrackerServerDelegate(item) { + const opts = item && item.decision_needed && Array.isArray(item.decision_needed.options) ? item.decision_needed.options : []; + return opts.find(o => o && o.action === 'decide:delegate') || null; + } // Pure: the operator note for labels the row's stage has outrun // (stale_labels: a needs-triage still on a claimed issue, which the // reconciler removes on its next pass — hivecommons/hive#14586). '' when none. @@ -22364,6 +22558,15 @@

    All labels

    if (lead) return lead; const decide = actions.find(a => a.id === 'decide'); const safe = decide && Array.isArray(decide.submenu) ? decide.submenu.filter(x => x && !x.danger) : []; + // The server ruled delegation out (a capability gap): the first + // enabled, non-destructive blocker option leads instead — the + // person's actual move (open App settings, re-check permissions), + // not a greyed "Let hive decide" (hivecommons/docs#612). + const served = stageTrackerServerDelegate(item); + if (served && served.enabled === false) { + const b = stageTrackerBlockerActions(item, ctx).find(x => x.enabled && !x.danger); + if (b) return Object.assign({}, b, { target: (decide && decide.target) || { kind: item.kind, number: item.number, repo: item.repo } }); + } if (safe.length) { const o = safe.find(x => x.enabled) || safe[0]; const enabled = !!decide.enabled && !!o.enabled; @@ -22447,7 +22650,7 @@

    All labels

    function stageTrackerLeadCompanion(item, ctx, lead) { if (!item || !lead || lead.passive || lead.id === 'decide:delegate') return null; const dec = typeof stageTrackerDecisionOf === 'function' ? stageTrackerDecisionOf(item) : null; - const human = !!(dec && dec.item && dec.item.decision_needed) || (item.stage_actor && item.stage_actor.kind === 'human') || (Number(item.stage) || 0) === 85; + const human = !!(dec && dec.item && dec.item.decision_needed) || !!item.decision_needed || (item.stage_actor && item.stage_actor.kind === 'human') || (Number(item.stage) || 0) === 85; if (!human) return null; const decide = stageTrackerRowActions(item, ctx).find(a => a.id === 'decide'); const o = decide && Array.isArray(decide.submenu) ? decide.submenu.find(x => x && x.id === 'decide:delegate') : null;