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-lead-delegate-inline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor: a row parked on a human decision now shows "Let hive decide" inline beside the server's lead (e.g. "Re-author") instead of hiding it under ⋯ → Decide…, and inline action pills are filled buttons with a ā–ø glyph and a consequence tooltip so they no longer pass for record pills like "adopted from #N".
5 changes: 5 additions & 0 deletions src/pkg/dashboard/stage_tracker_decided_ui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ assert.strictEqual(stageTrackerLinkedSupersededText({ adopted_by: 9, adopted_by_
assert.strictEqual(stageTrackerLinkedSupersededText({}, null), '');
assert.strictEqual(stageTrackerLinkedSupersededTip({ superseded_by: 9 }), 'Hive re-authored this PR as #9 with the same commits and sign-off. This PR closes as superseded when #9 merges.');
assert.strictEqual(stageTrackerLinkedSupersededTip({ adopted_by: 9, state: 'closed' }), 'Hive re-authored this PR as #9 with the same commits and sign-off. This PR is closed as superseded.');
// A record pill ("↳ adopted from #N") is a muted ham-badge, never the
// filled inline-action class — the two must not look alike (hive#16456).
{ const chip = stageTrackerAdoptedFromChipHtml({ adopted_from: { number: 16398, url: 'https://github.com/o/r/pull/16398' } }, 0);
assert.ok(chip.includes('class="ham-badge ham-adopted-from"'), chip);
assert.ok(!chip.includes('ham-lead-act') && !chip.includes('<button'), 'a record is not a button: ' + chip); }
assert.strictEqual(stageTrackerSupersededOriginalClause(9, 'open'), ' #9 is superseded and still open; it closes when this merges.');
assert.strictEqual(stageTrackerSupersededOriginalClause(9, 'closed'), ' #9 is closed as superseded.');
assert.strictEqual(stageTrackerSupersededOriginalClause(9, ''), '');
Expand Down
66 changes: 59 additions & 7 deletions src/pkg/dashboard/stage_tracker_lead_action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import (
// is the viewer's now renders its lead action as a real button in the chip
// slot: the ⋯ menu's `lead` entry, else the first Decide… option, else
// Adopt; the same id, hint and enable/disable reason, run down the same
// runRowAction path. One button only; everything else stays in ⋯.
// runRowAction path. One button only — plus "Let hive decide" beside the
// server's lead on a row parked on a human decision; everything else
// stays in ⋯.

func TestStageTrackerLeadActionInline(t *testing.T) {
html := indexHTML(t)
Expand All @@ -27,6 +29,10 @@ func TestStageTrackerLeadActionInline(t *testing.T) {
`stageTrackerChipsHtml(shown) + (typeof stageTrackerLeadButtonHtml === 'function' ? stageTrackerLeadButtonHtml(item, nowMs, subRows) : '')`,
`stageTrackerChipsHtml(pr) + (typeof stageTrackerLeadButtonHtml === 'function' ? stageTrackerLeadButtonHtml(pr, nowMs) : '')`,
`.ham-lead-act[aria-disabled="true"]`,
`.ham-lead-act::after { content: 'ā–ø';`,
`.ham-lead-act.ham-act-secondary {`,
`.ham-lead-act.ham-menu-danger { --ham-act-fill: var(--red);`,
`.ham-lead-act[aria-disabled="true"]::after { content: none; }`,
} {
if !strings.Contains(html, want) {
t.Errorf("index.html lacks %q", want)
Expand All @@ -48,7 +54,7 @@ assert.strictEqual(lead.id, 'accept-triage');
let h = stageTrackerLeadActionHtml(fresh, ctx);
assert.strictEqual(buttons(h), 1, 'one inline button only: ' + h);
assert.strictEqual(labelOf(h), 'Accept triage');
assert.ok(h.startsWith('<button type="button" class="ham-lead-act" data-ham-act="accept-triage"'), h);
assert.ok(h.startsWith('<button type="button" class="ham-lead-act ham-act-primary" data-ham-act="accept-triage"'), h);
assert.ok(!h.includes('aria-disabled'), 'enabled for a writer');
assert.ok(h.includes('title="adds &#96;triage/accepted&#96; as @octo; the hive takes it on its next pass (ā‰ˆ10 min)"'), 'the menu entry\'s hint is the hover: ' + h);
assert.ok(h.includes('aria-label="Accept triage — o/r#15437"'), h);
Expand All @@ -68,14 +74,55 @@ assert.strictEqual(labelOf(h), 'Let hive decide');
const human = { repo: 'o/r', kind: 'pr', number: 104, title: 'Hand-made', url: 'https://github.com/o/r/pull/104', stage: 85, actor: 'maintainer', modifiers: ['needs-decision'],
decision_needed: { question: 'Merge it?', options: [{ action: 'decide:merge-now', label: 'Merge now', enabled: true, consequence: 'merges as you' }, { action: 'decide:delegate', label: 'Let hive decide', enabled: true }] } };
h = stageTrackerLeadActionHtml(human, ctx);
assert.strictEqual(buttons(h), 1);
// Parked on a human decision: the server's lead AND "Let hive decide" stand
// inline, lead first (hivecommons/hive#16265 / #16456: a row showed only
// "Re-author"; the owner asked where "Let hive decide" went).
assert.strictEqual(buttons(h), 2, 'lead + Let hive decide inline: ' + h);
assert.strictEqual(labelOf(h), 'Merge now', h);
assert.ok(h.includes('data-ham-act="decide:merge-now"'), h);
assert.ok(h.indexOf('data-ham-act="decide:merge-now"') < h.indexOf('data-ham-act="decide:delegate"'), 'lead first: ' + h);
assert.ok(h.includes('class="ham-lead-act ham-act-secondary" data-ham-act="decide:delegate"'), 'delegate wears the pill, neutral-filled: ' + h);
assert.ok(h.includes('data-ham-act="decide:delegate" title="The hive decides for you under its policy and rails; recorded as your decision with an audit marker."'), 'delegate explains itself on hover, not "delegate": ' + h);
assert.ok(h.includes('>Let hive decide</button>'), h);
let leads = stageTrackerLeadActionsOnRow(human, ctx);
assert.strictEqual(leads.length, 2);
assert.strictEqual(leads[1].id, 'decide:delegate');
assert.strictEqual(leads[1].target, human, 'delegate carries the decide target');
assert.strictEqual(leads[1].enabled, true);
// The parked issue whose lead already is delegate: one pill, never two.
assert.strictEqual(stageTrackerLeadActionsOnRow(parked, ctx).length, 1);
// A Re-author lead (the #16456 row): both pills, delegate disabled with its
// reason for a reader.
const reauthor = { ...human, number: 16456, decision_needed: { question: 'Changes requested', options: [{ action: 'decide:re-author', label: 'Re-author', enabled: true, lead: true }, { action: 'decide:delegate', label: 'Let hive decide', enabled: true }] } };
h = stageTrackerLeadActionHtml(reauthor, ctx);
assert.strictEqual(buttons(h), 2, h);
assert.strictEqual(labelOf(h), 'Re-author', h);
assert.ok(h.includes('data-ham-act="decide:delegate"'), h);
// Owner on that row: "Re-author" read as a record of what happened — the
// action pills and the record pills ("adopted from #N", the base branch)
// wore the same outline. Inline actions are <button>s with the filled
// action class (primary / secondary / danger), never the record class;
// a record pill never carries the action class. The server's
// consequence is the lead's hover text; a lead without one gets the
// client's clause for its verb.
assert.ok(h.includes('<button type="button" class="ham-lead-act ham-act-primary" data-ham-act="decide:re-author" title="The hive opens a fresh PR for the same issue from the current base and closes this one as superseded."'), 'lead: filled primary button with the consequence tooltip: ' + h);
assert.ok(!h.includes('ham-badge'), 'action pills never wear the record class: ' + h);
assert.strictEqual((h.match(/<button type="button" class="ham-lead-act ham-act-(primary|secondary)"/g) || []).length, 2, h);
const withConsequence = { ...reauthor, decision_needed: { question: 'Changes requested', options: [{ action: 'decide:re-author', label: 'Re-author', enabled: true, lead: true, consequence: 'Hive opens a fresh PR for the issue and closes this one as superseded' }, { action: 'decide:delegate', label: 'Let hive decide', enabled: true }] } };
assert.ok(stageTrackerLeadActionHtml(withConsequence, ctx).includes('title="Hive opens a fresh PR for the issue and closes this one as superseded"'), 'the server consequence wins');
const closeLead = { ...human, decision_needed: { question: 'Superseded?', options: [{ action: 'decide:close-superseded', label: 'Close as superseded by #9', enabled: true, lead: true }, { action: 'decide:delegate', label: 'Let hive decide', enabled: true }] } };
h = stageTrackerLeadActionHtml(closeLead, ctx);
assert.ok(h.includes('class="ham-lead-act ham-menu-danger" data-ham-act="decide:close-superseded"'), 'a destructive lead fills red: ' + h);
assert.ok(h.includes('class="ham-lead-act ham-act-secondary" data-ham-act="decide:delegate"'), h);
h = stageTrackerLeadActionHtml(reauthor, { ...ctx, user: false, canHold: false });
assert.strictEqual(buttons(h), 2, h);
assert.ok((h.match(/aria-disabled="true"/g) || []).length === 2, 'both greyed for a reader: ' + h);
// Ready for human merge without a merger role: the merge option is greyed
// with its reason, never hidden.
// with its reason, never hidden; delegate stays enabled beside it.
h = stageTrackerLeadActionHtml(human, { ...ctx, canHuman: false });
assert.strictEqual(buttons(h), 1);
assert.ok(h.includes('aria-disabled="true"'), h);
assert.strictEqual(buttons(h), 2);
assert.ok(h.includes('data-ham-act="decide:merge-now" aria-disabled="true"'), h);
assert.ok(!h.includes('data-ham-act="decide:delegate" aria-disabled="true"'), h);

// A returned contributor PR whose adoption is due leads with Adopt.
const returned = { repo: 'o/r', kind: 'pr', number: 101, title: 'Fix redirect', url: 'https://github.com/o/r/pull/101', stage: 72, actor: 'karibhou', modifiers: [], adoption: { due: true, action: 'decide:adopt' } };
Expand Down Expand Up @@ -205,7 +252,12 @@ for (const it of rows) {
const lead = stageTrackerLeadAction(it, ctx);
if (!lead || !lead.enabled) missing.push(it.kind + '#' + it.number + ' (' + it.caption + ') → ' + JSON.stringify(lead));
const h = stageTrackerLeadActionHtml(it, ctx);
assert.strictEqual((h.match(/<button\b/g) || []).length, 1, 'one button on ' + it.kind + '#' + it.number + ': ' + h);
// One pill — two on a row parked on a human decision (a Decide… target)
// whose lead is not itself "Let hive decide" (the delegate pill stands
// beside it). A triage row's accept-triage stays alone.
const human = !!stageTrackerDecisionTarget(it) && !!(it.decision_needed && it.decision_needed.question) && lead && lead.id !== 'decide:delegate';
assert.strictEqual((h.match(/<button\b/g) || []).length, human ? 2 : 1, (human ? 'lead + delegate' : 'one button') + ' on ' + it.kind + '#' + it.number + ': ' + h);
if (human) assert.ok(h.indexOf('data-ham-act="decide:delegate"') > h.indexOf('data-ham-act="' + lead.id + '"'), 'lead first on ' + it.kind + '#' + it.number);
}
assert.deepStrictEqual(missing, [], 'maintainer-moved rows without an enabled lead action');
`)
Expand Down
4 changes: 4 additions & 0 deletions src/pkg/dashboard/stage_tracker_row_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func stageTrackerRowActionsPreamble(t *testing.T, html string) string {
jsConstLine(t, html, "STAGE_TRACKER_GROUP_KEY_PREFIX"),
jsConstLine(t, html, "STAGE_TRACKER_DECISION_STAGES"),
jsConstLine(t, html, "STAGE_TRACKER_SEL_ACTIONS"),
jsConstLine(t, html, "STAGE_TRACKER_ACTION_CONSEQUENCES"),
jsConstLine(t, html, "STAGE_TRACKER_MENU_MARGIN"),
jsConstLine(t, html, "STAGE_TRACKER_MENU_FAIL_LINES"),
jsConstBlock(t, html, "STAGE_TRACKER_DECISION_GLOSSARY"),
Expand Down Expand Up @@ -100,7 +101,10 @@ func stageTrackerRowActionsPreamble(t *testing.T, html string) string {
jsFunc(t, html, "stageTrackerPRListedOwnRow"),
jsFunc(t, html, "stageTrackerPRDrawnUnderOther"),
jsFunc(t, html, "stageTrackerLeadActionOnRow"),
jsFunc(t, html, "stageTrackerLeadCompanion"),
jsFunc(t, html, "stageTrackerLeadActionsOnRow"),
jsFunc(t, html, "stageTrackerLeadActionHtml"),
jsFunc(t, html, "stageTrackerLeadPillHtml"),
jsFunc(t, html, "stageTrackerMenuTextHtml"),
jsFunc(t, html, "stageTrackerFlatActions"),
jsFunc(t, html, "stageTrackerSelectionActions"),
Expand Down
24 changes: 15 additions & 9 deletions src/pkg/dashboard/static-src/css/tracker.css
Original file line number Diff line number Diff line change
Expand Up @@ -765,15 +765,21 @@
.ham-decision-act[aria-disabled="true"] { color: var(--text-faint); border-style: dashed; cursor: default; opacity: 0.6; }
.ham-decision-act[aria-disabled="true"]:hover { background: transparent; border-color: var(--line-subtle); }
.ham-decision-act.ham-decision-more { color: var(--text-muted); }
/* The row's inline lead action (the ⋯ menu's lead entry, in sight): a
small primary pill in the chip slot, the popover lead's recipe, the
row's cue colour; dashed and faint with its reason when the viewer
may not take it. */
.ham-lead-act { padding: 0 var(--sp-3); border: var(--line-width) solid var(--cue-state, var(--accent)); border-radius: var(--r-pill); background: color-mix(in srgb, var(--cue-state, var(--accent)) 10%, transparent); color: var(--cue-state, var(--accent)); font: inherit; font-size: var(--fs-xs); font-weight: var(--fw-semibold); line-height: 1.4; cursor: pointer; white-space: nowrap; }
.ham-lead-act:hover, .ham-lead-act:focus-visible { background: color-mix(in srgb, var(--cue-state, var(--accent)) 22%, transparent); outline: none; }
.ham-lead-act:focus-visible { box-shadow: 0 0 0 var(--line-width) var(--accent); }
.ham-lead-act.ham-menu-danger { color: var(--red); border-color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); }
.ham-lead-act[aria-disabled="true"] { color: var(--text-faint); border-color: var(--line-subtle); border-style: dashed; background: transparent; cursor: default; opacity: 0.7; }
/* The row's inline action pills (the ⋯ menu's lead entry, and "Let hive
decide" beside it on a row parked on a human decision): real buttons
that must not pass for the record pills in the same slot ("adopted
from #N", the base branch — muted outlines, no hover). So: a filled
chip, a trailing ā–ø glyph, pointer cursor, hover lift and focus ring.
Primary (the lead) fills amber; secondary (delegate) fills neutral;
danger (a server-led close) fills red. Dashed, faint and glyph-less
with its reason when the viewer may not take it. */
.ham-lead-act { --ham-act-fill: var(--amber); --ham-act-ink: var(--bg); display: inline-flex; align-items: center; gap: var(--sp-1); padding: 0 var(--sp-3); border: var(--line-width) solid var(--ham-act-fill); border-radius: var(--r-pill); background: var(--ham-act-fill); color: var(--ham-act-ink); font: inherit; font-size: var(--fs-xs); font-weight: var(--fw-semibold); line-height: 1.5; cursor: pointer; white-space: nowrap; transition: filter 120ms ease, box-shadow 120ms ease; }
.ham-lead-act::after { content: 'ā–ø'; opacity: 0.85; }
.ham-lead-act.ham-act-secondary { --ham-act-fill: var(--panel-strong); --ham-act-ink: var(--text); border-color: var(--line-strong); }
.ham-lead-act.ham-menu-danger { --ham-act-fill: var(--red); --ham-act-ink: var(--bg); }
.ham-lead-act:hover, .ham-lead-act:focus-visible { filter: brightness(1.12); outline: none; box-shadow: 0 0 0 var(--line-width) var(--bg), 0 0 0 calc(var(--line-width) * 3) var(--ham-act-fill); }
.ham-lead-act[aria-disabled="true"] { --ham-act-fill: transparent; --ham-act-ink: var(--text-faint); border-color: var(--line-subtle); border-style: dashed; background: transparent; cursor: default; opacity: 0.7; filter: none; box-shadow: none; }
.ham-lead-act[aria-disabled="true"]::after { content: none; }
/* Busy (Let hive decide gathering its preview) also sets aria-disabled, so this
compound rule sits after the disabled one and wins: the working colour, not faint/dashed. */
.ham-lead-act[aria-busy="true"][aria-disabled="true"] { cursor: progress; opacity: 1; border-style: solid; border-color: var(--cue-work); background: color-mix(in srgb, var(--cue-work) 10%, transparent); color: var(--cue-work); }
Expand Down
Loading
Loading