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/added-tracker-inline-lead-action.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The Activity Monitor renders a row's lead action inline — `[Accept triage]`, `[Let hive decide]`, `[Merge now]`, `[Adopt…]` — as a button beside the chips whenever the next move is the viewer's, the same entry the ⋯ menu leads with, with its hint as the hover and greyed with the reason when the viewer lacks write access; a sidelined issue (reporter triage, filtered) now keeps its author kind in the row payload ([#15456](https://github.com/hivecommons/hive/issues/15456)).
1 change: 1 addition & 0 deletions src/docs/dashboard-copy-inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ The new hover, verbatim (title line omitted):
| Confirm: Approve & merge as maintainer | dialog | 76 | 53 | same |
| Confirm: Approve — let hive merge | dialog | 62 | 49 | same |
| ⋯ menu hints (`stageTrackerLeadActions` → `ham-menu-hint`) | ⋯ menu | server consequences (11–31 each) | server consequences (≤ 12 each) | Go budget test |
| `stageTrackerLeadActionHtml` (`tracker-actions.js`) | the row header's inline lead button (chip slot) | — (the lead sat in the ⋯ menu only) | the menu entry's label (1–4), its hint as the hover | `TestStageTrackerLeadActionInline`, `TestStageTrackerMaintainerRowsHaveLeadAction` |
| Toasts (`STAGE_TRACKER_ACTING_CAPTIONS`, acted labels) | toast | 2–4 each | unchanged | — |

## Totals
Expand Down
4 changes: 4 additions & 0 deletions src/docs/dashboard-sections.md
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,10 @@ The *state pill* says where the item is and what it is waiting on (`hold`, `need

Plain words throughout — working / waiting on X / set back by Y / merged — nothing else blinks.

#### The row's lead action, inline

A row whose next move is yours does not hide its answer behind three dots. Beside the chips on the right of the header (and on a nested PR sub-row's own header), the row renders its **lead action** as a real `<button class="ham-lead-act">` — `[Accept triage]` on *New · waiting for a maintainer's triage* and *Triage needed*, `[Merge now]` (or the server's lead answer) on *Ready for human merge*, `[Let hive decide]` on *Needs human decision* and a duplicate's *Needs a pick*, `[Adopt…]` on a returned contributor PR whose adoption is due, `[Close (read)]` on an advisory issue. `stageTrackerLeadAction(item, ctx)` picks it from the same `stageTrackerRowActions(...)` list the ⋯ menu shows: the entry flagged `lead`, else the first *Decide…* option, else Adopt / Adopt now / *Let hive decide — all N PRs*; one button only, everything else stays in ⋯. It carries the menu entry's id, its hint as the hover and its enable/disable reason: a viewer without write access sees it greyed with *Sign in with write access to this repo*, a non-merger sees a merge action greyed with the role reason, never hidden. Clicking runs `runRowAction(action, row)` — the menu's own path, so the busy chevron, the acting caption, the toast and the history badge are the same. A row the server marks as the maintainer's move (`actor: maintainer` or `new.next_mover: maintainer`) that yields no lead is a bug: a development host logs a console warning, and `TestStageTrackerMaintainerRowsHaveLeadAction` runs the real fixtures through the picker.

#### Row actions (right-click, ⋯, Shift+F10)

Right-clicking a row — or a nested PR sub-row — opens an in-app context menu of the actions that fit that item's current state; the ⋯ button in the row's left gutter (every nested PR sub-row has its own gutter with its own checkbox and ⋯) opens the same menu for pointer-free use, and so do **Shift+F10** and the context-menu key while the row or anything in it has focus (every row is a tab stop).
Expand Down
2 changes: 1 addition & 1 deletion src/docs/scale-envelope.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ones to:
2. **Truncation must preserve the prioritization signal, not cut an arbitrary slice.**
This holds today and is easy to assume backwards:
- Issues are sorted by actionable rank tier, then **oldest first** within each tier before any cap is applied
(`RankActionableIssues`, `src/pkg/github/client.go:4809-4819`, descending `AgeMinutes` within each tier).
(`RankActionableIssues`, `src/pkg/github/client.go:4825-4835`, descending `AgeMinutes` within each tier).
- PRs are sorted by **review class then oldest-first within class**
(`SortPullRequestsForReview`, `src/pkg/github/review_priority.go:334`;
fixes → refactors/docs → tests).
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/dashboard/stage_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2319,7 +2319,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto
// The enumeration's sidelined issues: parked in a work-detail
// bucket, the open items the first tracker never showed.
w := it.WorkIssue
addIssue(repoName, github.Issue{Repo: w.Repo, Number: w.Number, Title: w.Title, Author: w.Author, Labels: w.Labels, Assignees: w.Assignees,
addIssue(repoName, github.Issue{Repo: w.Repo, Number: w.Number, Title: w.Title, Author: w.Author, AuthorIsHuman: w.AuthorIsHuman, Labels: w.Labels, Assignees: w.Assignees,
CreatedAt: w.CreatedAt, UpdatedAt: w.UpdatedAt, URL: w.URL, ClaimKind: w.ClaimKind, ClaimedBy: w.ClaimedBy, ClaimHive: w.ClaimHive, LinkedPRs: w.LinkedPRs, ClaimContext: w.ClaimContext, IsTracker: w.IsTracker, Children: w.Children}, w.Bucket, w.Reason, w.TrackerProgress, w.Advisory)
default:
w := it.WorkPR
Expand Down
183 changes: 183 additions & 0 deletions src/pkg/dashboard/stage_tracker_lead_action_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
package dashboard

import (
"encoding/json"
"strings"
"testing"
"time"

"github.com/hivecommons/hive/pkg/github"
"github.com/hivecommons/hive/pkg/stagelabels"
)

// Owner, 2026-10-29, on five "New · waiting for a maintainer's triage" rows:
// "i dont have any way to act on these." The answer existed — Accept triage
// led the ⋯ menu — but three dots are invisible. Every row whose next move
// 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 ⋯.

func TestStageTrackerLeadActionInline(t *testing.T) {
html := indexHTML(t)
for _, want := range []string{
`class="ham-lead-act`,
`e.target.closest('.ham-lead-act[data-ham-act]')`,
`stageTrackerDecisionRun(item, b.dataset.hamAct)`,
`stageTrackerChipsHtml(shown) + (typeof stageTrackerLeadButtonHtml === 'function' ? stageTrackerLeadButtonHtml(item, nowMs) : '')`,
`stageTrackerChipsHtml(pr) + (typeof stageTrackerLeadButtonHtml === 'function' ? stageTrackerLeadButtonHtml(pr, nowMs) : '')`,
`.ham-lead-act[aria-disabled="true"]`,
} {
if !strings.Contains(html, want) {
t.Errorf("index.html lacks %q", want)
}
}
runStageTrackerRowActionsScript(t, stageTrackerRowActionsPreamble(t, html)+`
const BT = String.fromCharCode(96);
const NOW = Date.parse('2026-10-29T18:00:00Z');
const ctx = { user: true, canHold: true, canHuman: true, login: 'octo', nowMs: NOW, governor: { nextKickAt: '2026-10-29T18:10:00Z' } };
const buttons = h => (h.match(/<button\b/g) || []).length;
const labelOf = h => { const m = h.match(/>([^<]*)<\/button>/); return m ? m[1] : ''; };

// The screenshot row: a 000-new issue the reporter-trust gate holds.
const fresh = { repo: 'o/r', kind: 'issue', number: 15437, title: 'Monitoring component', url: 'https://github.com/o/r/issues/15437', stage: 0, stage_slug: '000-new', actor: 'maintainer', modifiers: [], bucket: 'reporter_triage',
caption: 'New · waiting for a maintainer\'s triage (add ' + BT + 'triage/accepted' + BT + '); the hive\'s next pass in 10m',
new: { next_mover: 'maintainer', next_pass_at: '2026-10-29T18:10:00Z', gates: [{ name: 'triage', state: 'next' }, { name: 'actionable', state: 'later' }, { name: 'claimed', state: 'later' }] } };
let lead = stageTrackerLeadAction(fresh, ctx);
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.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);
// Same for 015 Triage needed.
assert.strictEqual(labelOf(stageTrackerLeadActionHtml({ ...fresh, stage: 15, stage_slug: '015-triage-needed', new: null }, ctx)), 'Accept triage');

// Needs human decision: an issue parked at 045 leads with Let hive decide,
// the first Decide… option, carrying the decide target.
const parked = { repo: 'o/r', kind: 'issue', number: 13, title: 'Agents stand down', url: 'https://github.com/o/r/issues/13', stage: 45, actor: 'maintainer', modifiers: ['needs-decision'] };
lead = stageTrackerLeadAction(parked, ctx);
assert.strictEqual(lead.id, 'decide:delegate');
assert.strictEqual(lead.target, parked);
h = stageTrackerLeadActionHtml(parked, ctx);
assert.strictEqual(buttons(h), 1);
assert.strictEqual(labelOf(h), 'Let hive decide');
// A PR at 085 with the server's answers leads with the server's lead option.
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);
assert.strictEqual(labelOf(h), 'Merge now', h);
assert.ok(h.includes('data-ham-act="decide:merge-now"'), h);
// Ready for human merge without a merger role: the merge option is greyed
// with its reason, never hidden.
h = stageTrackerLeadActionHtml(human, { ...ctx, canHuman: false });
assert.strictEqual(buttons(h), 1);
assert.ok(h.includes('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' } };
if (typeof stageTrackerAdoptOffered === 'function') {
lead = stageTrackerLeadAction(returned, ctx);
assert.strictEqual(lead.id, 'decide:adopt');
assert.strictEqual(labelOf(stageTrackerLeadActionHtml(returned, ctx)), 'Adopt…');
}

// Rows that wait on nobody here render no button.
for (const it of [
{ repo: 'o/r', kind: 'issue', number: 8, title: 'Flaky test', url: 'https://github.com/o/r/issues/8', stage: 20, actor: 'hive', modifiers: [] },
{ repo: 'o/r', kind: 'pr', number: 102, title: 'Stabilise', url: 'https://github.com/o/r/pull/102', stage: 95, actor: 'hive', modifiers: [] },
{ ...fresh, new: { ...fresh.new, next_mover: 'hive' }, actor: 'hive' },
{ repo: 'o/r', kind: 'pr', number: 101, title: 'Fix redirect', url: 'https://github.com/o/r/pull/101', stage: 72, actor: 'karibhou', modifiers: [] },
]) {
assert.strictEqual(stageTrackerLeadAction(it, ctx), null, JSON.stringify(it));
assert.strictEqual(stageTrackerLeadActionHtml(it, ctx), '', JSON.stringify(it));
}

// Without write access the button stays, disabled, with the sign-in reason
// as its hover — the menu entry's rule.
h = stageTrackerLeadActionHtml(fresh, { user: false, canHold: false, canHuman: false, nowMs: NOW });
assert.strictEqual(buttons(h), 1);
assert.ok(h.includes('aria-disabled="true"'), h);
assert.ok(h.includes('title="' + STAGE_TRACKER_WHY_WRITE + '"'), h);
h = stageTrackerLeadActionHtml(parked, { user: false, canHold: false, canHuman: false, nowMs: NOW });
assert.ok(h.includes('aria-disabled="true"') && h.includes(STAGE_TRACKER_WHY_WRITE), h);
// A signed-in viewer whose hold permission is still loading (null) is not
// locked out: the server answers 403 either way.
assert.ok(!stageTrackerLeadActionHtml(fresh, { user: true, canHold: null, nowMs: NOW }).includes('aria-disabled'));

// Labels and hints are escaped.
h = stageTrackerLeadActionHtml({ ...human, decision_needed: { question: 'Merge it?', options: [{ action: 'decide:merge-now', label: 'Merge <b>now</b>', enabled: true, consequence: 'a "quoted" hint' }] } }, ctx);
assert.ok(h.includes('&lt;b&gt;') && h.includes('&quot;quoted&quot;'), h);

// The dev warning only speaks on a development host.
let warned = [];
global.console = { warn: m => warned.push(m) };
global.window = { location: { hostname: 'hive.example.org' } };
stageTrackerDevWarn('x');
assert.deepStrictEqual(warned, []);
global.window = { location: { hostname: 'localhost' } };
stageTrackerDevWarn('x');
assert.deepStrictEqual(warned, ['[tracker] x']);
`)
}

// Every row the server marks as the maintainer's move (actor "maintainer"
// or new.next_mover "maintainer") must yield an inline lead action: a row
// that tells the operator what is needed and offers no control is the bug
// this fixes. The rows come from the real pipeline (buildStageTracker over
// the shared fixture plus a 015 issue, a 090 PR and a reporter-trust hold),
// marshalled as the SPA receives them.
func TestStageTrackerMaintainerRowsHaveLeadAction(t *testing.T) {
now := time.Date(2026, 10, 29, 18, 0, 0, 0, time.UTC)
s, store := stageTrackerFixture(t, now)
store.Observe(stagelabels.Key("acme/console", 15), stagelabels.TriageNeeded, "reporter-trust gate")
store.Observe(stagelabels.Key("acme/console", 120), stagelabels.ReadyForHumanMerge, "untrusted-author-role")
opened := now.Add(-28 * time.Minute)
s.statusMu.Lock()
s.status.Governor.NextKickAt = now.Add(10 * time.Minute).UTC().Format(time.RFC3339)
s.status.Repos[0].ActionableIssues = append(s.status.Repos[0].ActionableIssues,
github.Issue{Number: 15, Title: "Needs a maintainer's triage", Author: "onkar717", AuthorIsHuman: true, Labels: []string{"stage/015-triage-needed", "needs-triage"}})
s.status.Repos[0].NonActionableIssues = append(s.status.Repos[0].NonActionableIssues,
github.RepoWorkIssue{Repo: "acme/console", Number: 15437, Title: "Monitoring component", Author: "onkar717", AuthorIsHuman: true, CreatedAt: opened, UpdatedAt: opened, Bucket: "reporter_triage", Reason: "Awaiting maintainer triage label"})
s.status.Repos[0].OpenPrs = append(s.status.Repos[0].OpenPrs,
FrontendPR{PullRequest: github.PullRequest{Number: 120, Title: "Shard nightly", Author: "odttlnt", Labels: []string{"stage/090-ready-for-human-merge", "lgtm", "approved"}}})
s.statusMu.Unlock()
resp := s.buildStageTracker(s.status, store, now)

var rows []StageTrackerItem
for _, it := range resp.Items {
if it.Actor == StageTrackerMoverMaintainer || (it.New != nil && it.New.NextMover == StageTrackerMoverMaintainer) {
rows = append(rows, it)
}
}
want := map[string]bool{"issue#13": false, "issue#15": false, "issue#15437": false, "pr#104": false, "pr#120": false}
for _, it := range rows {
want[it.Kind+"#"+itoa(it.Number)] = true
}
for k, seen := range want {
if !seen {
t.Errorf("fixture row %s is not marked as the maintainer's move; the test lost a case", k)
}
}
raw, err := json.Marshal(rows)
if err != nil {
t.Fatal(err)
}
html := indexHTML(t)
runStageTrackerRowActionsScript(t, stageTrackerRowActionsPreamble(t, html)+`
const rows = `+string(raw)+`;
const ctx = { user: true, canHold: true, canHuman: true, login: 'octo', nowMs: `+itoa(int(now.UnixMilli()))+`, governor: null };
assert.ok(rows.length >= 5, 'fixture rows: ' + rows.length);
const missing = [];
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);
}
assert.deepStrictEqual(missing, [], 'maintainer-moved rows without an enabled lead action');
`)
}
8 changes: 7 additions & 1 deletion src/pkg/dashboard/stage_tracker_new_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestWebhookOpenedItemInsertedIntoTracker(t *testing.T) {
s.statusMu.Unlock()
opened := now.Add(-90 * time.Second)

triage := github.RepoWorkIssue{Repo: "acme/console", Number: 15092, Title: "Add a thing", Author: "kanrenibm", Labels: []string{"enhancement", "help wanted"}, CreatedAt: opened, UpdatedAt: opened, Bucket: "reporter_triage", Reason: "Awaiting maintainer triage label"}
triage := github.RepoWorkIssue{Repo: "acme/console", Number: 15092, Title: "Add a thing", Author: "kanrenibm", AuthorIsHuman: true, Labels: []string{"enhancement", "help wanted"}, CreatedAt: opened, UpdatedAt: opened, Bucket: "reporter_triage", Reason: "Awaiting maintainer triage label"}
n := s.applyWebhookItemSnapshots([]github.WebhookItemSnapshot{
// A contributor's issue the reporter gate has not admitted: the
// classifier offers the reporter_triage row.
Expand Down Expand Up @@ -58,6 +58,12 @@ func TestWebhookOpenedItemInsertedIntoTracker(t *testing.T) {
if it.New.NextMover != StageTrackerMoverMaintainer || !strings.Contains(it.Caption, "New · waiting for a maintainer's triage (add `triage/accepted`)") || it.Actor != StageTrackerMoverMaintainer {
t.Fatalf("#15092 caption %q actor %q new %+v, want the maintainer's triage as next mover", it.Caption, it.Actor, it.New)
}
// A sidelined row keeps the reporter's kind: the work-bucket copy of the
// issue carries AuthorIsHuman, so the row does not read as an unknown
// author just because the gate parked it.
if it.AuthorKind != authorKindHuman {
t.Fatalf("#15092 author_kind = %q, want %q on a reporter_triage row", it.AuthorKind, authorKindHuman)
}
if it.StageSince == nil || !it.StageSince.Equal(opened) {
t.Fatalf("#15092 since = %v, want the opened time %v", it.StageSince, opened)
}
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 @@ -93,6 +93,10 @@ func stageTrackerRowActionsPreamble(t *testing.T, html string) string {
jsConstLine(t, html, "STAGE_TRACKER_BLOCKER_ACTIONS"),
jsFunc(t, html, "stageTrackerBlockerActions"),
jsFunc(t, html, "stageTrackerRowActions"),
jsFunc(t, html, "stageTrackerLeadAction"),
jsFunc(t, html, "stageTrackerMaintainerMoved"),
jsFunc(t, html, "stageTrackerDevWarn"),
jsFunc(t, html, "stageTrackerLeadActionHtml"),
jsFunc(t, html, "stageTrackerMenuTextHtml"),
jsFunc(t, html, "stageTrackerFlatActions"),
jsFunc(t, html, "stageTrackerSelectionActions"),
Expand Down
9 changes: 9 additions & 0 deletions src/pkg/dashboard/static-src/css/tracker.css
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,15 @@
.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 technical background folds behind one collapsed Details. */
.ham-decision-details { margin: var(--sp-2) 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.ham-decision-details > summary { cursor: pointer; color: var(--text-faint); }
Expand Down
Loading
Loading