From 2a89b93381b7e59c8e0bd8d9cf6a469dd14e2074 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Wed, 4 Nov 2026 15:03:20 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(dashboard):=20Review=20and?= =?UTF-8?q?=20CI=20chevrons=20state=20what=20the=20head=20waits=20on,=20ne?= =?UTF-8?q?ver=20"activity=20unknown"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A Review track with no verdict and no reviewer in flight now derives a concrete statement from the PR's lifecycle and its CI track (stage_tracker_review_fallback.go): closed/merged, draft, waiting for CI, not started (+ who is next), or — only when nothing was fetched for the head — "no data for head yet · refreshing". The UI drops the "activity unknown · last observed …" prefix: settled verdicts stay known as observations age (dated in the tooltip), and a settled review explains itself — who decided, how long ago, each perspective's verdict with its first finding (perspectives field, dissent preserved). An aggregate approval the verified bundle does not back reads "evidence not verified" instead of unknown. Fixture invariant: no CI/Review tooltip contains "activity unknown" / "CI unknown" / "Review unknown". Supersedes #16634. Fixes #16617 Fixes #16661 Signed-off-by: Andrew Anderson --- .../fixed-review-track-never-unknown.md | 1 + .../dashboard-sections/activity-monitor.md | 1 + src/pkg/dashboard/stage_tracker_activity.go | 35 ++- .../dashboard/stage_tracker_activity.test.js | 54 ++++- .../dashboard/stage_tracker_activity_test.go | 10 +- .../stage_tracker_actor_icon_test.go | 2 +- src/pkg/dashboard/stage_tracker_build.go | 4 +- .../dashboard/stage_tracker_claimant_test.go | 2 +- .../stage_tracker_review_fallback.go | 199 ++++++++++++++++++ .../stage_tracker_review_fallback_test.go | 120 +++++++++++ .../stage_tracker_ui_prelude_test.go | 7 + .../dashboard/stage_tracker_ui_rows_test.go | 8 +- .../static-src/js/tracker-row-strip.js | 44 +++- src/pkg/dashboard/static/index.html | 44 +++- 14 files changed, 493 insertions(+), 38 deletions(-) create mode 100644 changelog.d/fixed-review-track-never-unknown.md create mode 100644 src/pkg/dashboard/stage_tracker_review_fallback.go create mode 100644 src/pkg/dashboard/stage_tracker_review_fallback_test.go diff --git a/changelog.d/fixed-review-track-never-unknown.md b/changelog.d/fixed-review-track-never-unknown.md new file mode 100644 index 0000000000..03de9b5792 --- /dev/null +++ b/changelog.d/fixed-review-track-never-unknown.md @@ -0,0 +1 @@ +- The Activity Monitor's Review and CI chevrons never say "activity unknown": with no verdict and no reviewer in flight the tooltip states what the head waits on (closed, draft, waiting for CI, not started and who is next, or no data for the head yet · refreshing), a settled verdict names who decided, how long ago and each perspective's verdict with its first finding, and settled verdicts stay known as observations age. diff --git a/src/docs/dashboard-sections/activity-monitor.md b/src/docs/dashboard-sections/activity-monitor.md index e183c196de..194b097007 100644 --- a/src/docs/dashboard-sections/activity-monitor.md +++ b/src/docs/dashboard-sections/activity-monitor.md @@ -439,6 +439,7 @@ An *active* chevron is filled amber and carries words; an inactive one is its ic 2. **CI and Review resolve first.** A track is active only while it genuinely runs on the current head (a check-run in progress or queued, a ring not yet full; a reviewer running or queued). If either runs, the PR is waiting on it: the stage chevron (PR in progress, Merge queue …) renders settled-current — filled but still, icon only, its words in the tooltip — and nothing else is active. 3. **CI + Review is the only pair.** Two chevrons are active together only when both tracks run at once; every other combination is exactly one active chevron. The stage chevron is the ≥ 1 fallback: active only when no track is in motion. 4. **The PR in progress chevron speaks the PR's lifecycle** — draft, pushed, rebasing, *Unassigned · next: scanner*, *Waiting for @author · fix owed* — never a CI or review verdict. *CI failing*, *CI 4/11 · 1 failing* and *changes requested* are the CI and Review chevrons' words; the PR in progress tooltip keeps the red reason as detail. +5. **The CI and Review tooltips state what the track waits on — never "activity unknown".** With no verdict and no reviewer in flight the spoke derives the Review statement from what it already knows, in this order: the PR is merged or closed (*Review · n/a (closed)*), it is a draft (*Review · draft, not requested*), CI on the head has not finished (*Review · waiting for CI*), CI is done and nobody started (*Review · not started · hive reviewer next*, or *· needs reviewer* when the repo has no hive reviewer lane). A settled verdict explains itself — *Changes requested by the hive reviewer: 1 perspective posted findings … · 12m ago · quality ✓ · security ✗: token logged* — and stays known as its observation ages. The one no-data wording, *Review · no data for head f269349 yet · refreshing* (CI: *CI · no checks observed for head … yet · refreshing*), appears only when the spoke has fetched nothing for the head, and names the next step. #### The row's lead action, inline diff --git a/src/pkg/dashboard/stage_tracker_activity.go b/src/pkg/dashboard/stage_tracker_activity.go index a0ffe9a757..0302221485 100644 --- a/src/pkg/dashboard/stage_tracker_activity.go +++ b/src/pkg/dashboard/stage_tracker_activity.go @@ -45,6 +45,18 @@ type StageTrackerActivity struct { // verdict for the current head. PerspectivesDone int `json:"perspectives_done,omitempty"` PerspectivesTotal int `json:"perspectives_total,omitempty"` + // Perspectives lists each perspective's latest verdict on the head + // (dissent preserved) so the tooltip can explain a settled review + // (hivecommons/hive#16617). + Perspectives []StageTrackerPerspective `json:"perspectives,omitempty"` +} + +// StageTrackerPerspective is one perspective's current verdict on the head +// with its first finding, when it reported one. +type StageTrackerPerspective struct { + Name string `json:"name"` + Verdict string `json:"verdict"` + Summary string `json:"summary,omitempty"` } const trackerActivityFreshWindow = 2 * time.Minute @@ -54,7 +66,7 @@ func trackerUnknownActivity(head, caption string) *StageTrackerActivity { } func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerActivity { - out := trackerUnknownActivity(pr.HeadSHA, "CI unknown · no check results observed for this head yet") + out := trackerUnknownActivity(pr.HeadSHA, stageTrackerCINoDataCaption(pr.HeadSHA)) out.Detail = "hive has not yet seen which checks branch protection requires, or any check run or commit status for the PR's current commit." a := pr.CIActivity if a == nil || pr.HeadSHA == "" || !strings.EqualFold(a.Head, pr.HeadSHA) { @@ -558,13 +570,21 @@ func trackerAssignedCodeWorker(status *StatusPayload, repo string, number int, h } func stageTrackerReviewActivity(pr github.PullRequest, bundle *evidence.Bundle, agg *review.Aggregate, dispatch review.DispatchState, status *StatusPayload, now time.Time) *StageTrackerActivity { - out := trackerUnknownActivity(pr.HeadSHA, "Review unknown · current-head evidence unavailable") + out := trackerUnknownActivity(pr.HeadSHA, stageTrackerReviewNoDataCaption(pr.HeadSHA)) + unverifiedApproval := false + defer func() { + if unverifiedApproval && out.State == "unknown" { + out.State, out.Caption = reviewStateUnverified, "Review · aggregate approves · evidence not verified" + out.Detail = "The review aggregate approves this head but the verified evidence bundle does not establish it (a perspective is missing or dissents, or merge eligibility is withheld); the approval does not count until the evidence agrees." + } + }() if agg != nil && !trackerHeadMatches(pr.Repo, pr.Number, pr.HeadSHA, agg.Repo, agg.Number, agg.HeadSHA) { agg = nil } qualify := stageTrackerRepoQualifier(status) if bundle != nil && trackerHeadMatches(pr.Repo, pr.Number, pr.HeadSHA, bundle.Repo, bundle.Number, bundle.HeadSHA) { out.Source, out.ObservedAt = "verified-review-bundle", timePtr(bundle.UpdatedAt) + out.Perspectives = trackerReviewPerspectives(bundle) for _, verdict := range trackerLatestBundleVerdicts(bundle) { if !verdict.RecordedAt.IsZero() && (out.Since == nil || verdict.RecordedAt.After(*out.Since)) { at := verdict.RecordedAt @@ -582,7 +602,13 @@ func stageTrackerReviewActivity(pr github.PullRequest, bundle *evidence.Bundle, if agg.MergeEligible && trackerBundleApproves(bundle, agg) { out.State, out.Caption = "approved", "Review approved" } else { - out.Caption = "Review unknown · bundle and aggregate do not establish approval" + // The aggregate approves but the verified bundle does + // not back it (a dissenting or missing perspective, or + // merge eligibility withheld). Not an approval and not + // "unknown": the statement is that the evidence does + // not verify it. A later wait or dispatch on the head + // still takes over below. + unverifiedApproval = true } case "changes_requested", "reject": out.State, out.Caption = "changes_requested", "Review findings · awaiting author" @@ -603,6 +629,9 @@ func stageTrackerReviewActivity(pr github.PullRequest, bundle *evidence.Bundle, } } } + if detail := stageTrackerReviewVerdictDetail(out, bundle); detail != "" && out.Detail == "" { + out.Detail = detail + } if out.State != "unknown" && agg != nil { var confirmed time.Time for _, recent := range dispatch.Recent { diff --git a/src/pkg/dashboard/stage_tracker_activity.test.js b/src/pkg/dashboard/stage_tracker_activity.test.js index d1ecb62285..730012d0de 100644 --- a/src/pkg/dashboard/stage_tracker_activity.test.js +++ b/src/pkg/dashboard/stage_tracker_activity.test.js @@ -707,10 +707,11 @@ function stageTrackerIcon(n, cls) { return ''; } assert.equal((administration.match(/data-motion="active"/g) || []).length, 2, 'cached generic PR administration cannot animate coding'); }); -test('stale activity is visibly unknown in the tooltip, never pulses, and still reads in words', () => { +test('stale activity is dated in the tooltip, never pulses, still reads in words, and never says "activity unknown"', () => { const item = { kind: 'pr', head: 'head', review_activity: { ...activity('reviewing', 'Review working · reviewer', true), actor: 'reviewer', perspectives_done: 1, perspectives_total: 5 } }; const html = track(item, 'review', {}, false, now + 300000); - assert.match(html, /activity unknown · last observed reviewing/); + assert.doesNotMatch(html, /activity unknown/, 'hivecommons/hive#16661'); + assert.match(html, /stale · 2026-11-02T21:00:00\.000Z \(5m ago\)/); assert.doesNotMatch(html, /data-motion/); assert.match(html, /data-display-state="unknown"/); assert.match(html, /ham-activity-track active"[^]*ham-chevron-copy ham-track-state">Review 1\/5 · reviewer reviewing { + const head = 'f269349abcdef'; + const text = cell => cell.match(/aria-describedby="[^"]+">([^]*?)]*>/g, ''); + const cls = cell => cell.match(/class="ham-seg ham-activity-track ([a-z -]+?)(?: ham-current)?"/)[1]; + const tip = cell => (/role="tooltip">([^]*?)<\/span>/.exec(cell) || [])[1].replace(/<[^>]*>/g, ''); + const derived = (state, caption, extra = {}) => ({ head, state, caption, source: 'derived-from-pr-state', observed_at: new Date(now).toISOString(), ...extra }); + const row = (review, stage, column) => track({ kind: 'pr', head, stage, display_column: column, number: 16650, review_activity: review, + ci_activity: { head, state: 'running', caption: 'CI 3/11 · running', active: true, checks_passed: 3, checks_total: 11, source: 'github-check-runs', observed_at: new Date(now).toISOString() } }, + 'review', { state: stage === 50 ? 'active' : 'todo' }, false, now); + // 040 with CI running: Review is an inactive neutral icon; the tooltip says why. + const waiting = row(derived('waiting_ci', 'Review · waiting for CI'), 40, 40); + assert.equal(cls(waiting), 'todo'); assert.equal(text(waiting), ''); + assert.match(tip(waiting), /Review: Review · waiting for CI · head f269349/); + assert.doesNotMatch(tip(waiting), /unknown/); + // 050 with nobody started yet: the stage's own column carries the statement. + const notStarted = row(derived('not_started', 'Review · not started · hive reviewer next'), 50, 50); + assert.equal(cls(notStarted), 'active'); assert.equal(text(notStarted), 'Review · not started · hive reviewer next'); + for (const [state, caption] of [['not_requested', 'Review · draft, not requested'], ['closed', 'Review · n/a (closed)'], ['unverified', 'Review · aggregate approves · evidence not verified']]) { + const cell = row(derived(state, caption), 40, 40); + assert.equal(text(cell), '', state + ' is not motion'); + assert.match(tip(cell), new RegExp('Review: ' + caption.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')), state); + assert.doesNotMatch(tip(cell), /activity unknown|Review unknown/); + } + // No evidence at all: the head and the next step, not "unknown"; a legacy + // "Review unknown · reason" caption from an older spoke is rewritten the same way. + const none = row(undefined, 40, 40); + assert.match(tip(none), /Review: Review · no data for head f269349 yet · refreshing/); + assert.doesNotMatch(tip(none), /Review unknown|activity unknown/); + const legacy = row({ head, state: 'unknown', caption: 'Review unknown · current-head evidence unavailable', source: 'unavailable' }, 40, 40); + assert.match(tip(legacy), /Review · no data for head f269349 yet · refreshing · current-head evidence unavailable/); + assert.doesNotMatch(tip(legacy), /Review unknown|activity unknown/); + // A settled verdict explains itself in the tooltip: who, how long ago, and + // each perspective's verdict with its first finding (hivecommons/hive#16617), + // and it stays known as the observation ages. + const settled = row({ head, state: 'changes_requested', caption: 'Review findings · awaiting author', source: 'verified-review-bundle', perspectives_done: 5, perspectives_total: 5, + observed_at: new Date(now - 12 * 60000).toISOString(), since: new Date(now - 12 * 60000).toISOString(), + detail: 'Changes requested by the hive reviewer: 1 perspective posted findings on this head; the fix is owed before a re-review.', + perspectives: [{ name: 'quality', verdict: 'approve' }, { name: 'security', verdict: 'changes_requested', summary: 'token logged' }] }, 40, 40); + assert.equal(cls(settled), 'failing'); assert.equal(text(settled), ''); + assert.match(settled, /data-display-state="known"/, 'a settled verdict stays known past the freshness window'); + assert.match(tip(settled), /Changes requested by the hive reviewer: 1 perspective posted findings[^]*· 12m ago · quality ✓ · security ✗: token logged · head f269349/); + assert.doesNotMatch(tip(settled), /activity unknown/); +}); diff --git a/src/pkg/dashboard/stage_tracker_activity_test.go b/src/pkg/dashboard/stage_tracker_activity_test.go index 08bdac2323..154611699e 100644 --- a/src/pkg/dashboard/stage_tracker_activity_test.go +++ b/src/pkg/dashboard/stage_tracker_activity_test.go @@ -232,11 +232,13 @@ func TestStageTrackerActivityApprovalRequiresConsistentBundle(t *testing.T) { {Perspective: "quality", Backend: "backend", Model: "model", Verdict: "approve", RecordedAt: now}, {Perspective: "security", Backend: "backend", Model: "model", Verdict: "changes_requested", RecordedAt: now}, }} - if got := stageTrackerReviewActivity(pr, bundle, agg, dispatch, status, now); got.State != "unknown" { + // Neither an approval nor "unknown": the words say the evidence does + // not verify the aggregate (hivecommons/hive#16661). + if got := stageTrackerReviewActivity(pr, bundle, agg, dispatch, status, now); got.State != reviewStateUnverified || !strings.Contains(got.Caption, "evidence not verified") { t.Fatalf("conflicting bundle became approval: %+v", got) } bundle.Verdicts = bundle.Verdicts[:1] - if got := stageTrackerReviewActivity(pr, bundle, agg, dispatch, status, now); got.State != "unknown" { + if got := stageTrackerReviewActivity(pr, bundle, agg, dispatch, status, now); got.State != reviewStateUnverified { t.Fatalf("missing perspective became approval: %+v", got) } bundle.Verdicts = append(bundle.Verdicts, evidence.Verdict{ @@ -249,7 +251,7 @@ func TestStageTrackerActivityApprovalRequiresConsistentBundle(t *testing.T) { } bundle.Verdicts = append(bundle.Verdicts, evidence.Verdict{ Perspective: "security", Backend: "backend", Model: "model", Verdict: "reject", RecordedAt: now}) - if got := stageTrackerReviewActivity(pr, bundle, agg, dispatch, status, now); got.State != "unknown" { + if got := stageTrackerReviewActivity(pr, bundle, agg, dispatch, status, now); got.State != reviewStateUnverified { t.Fatalf("equal-time conflicting verdict became approval: %+v", got) } agg.HeadSHA = "old-head" @@ -397,7 +399,7 @@ func TestStageTrackerActivityCICaptionsReadInPlainLanguage(t *testing.T) { if got := stageTrackerCIActivity(ci(done("build"), chk("lint", "completed", "failure"), done("test")), now); got.State != "failing" || got.Active { t.Fatalf("settled red head must not read as running: %+v", got) } - if got := stageTrackerCIActivity(github.PullRequest{Repo: pr.Repo, Number: pr.Number, HeadSHA: pr.HeadSHA}, now); got.Caption != "CI unknown · no check results observed for this head yet" || got.Detail == "" { + if got := stageTrackerCIActivity(github.PullRequest{Repo: pr.Repo, Number: pr.Number, HeadSHA: pr.HeadSHA}, now); got.Caption != "CI · no checks observed for head head yet · refreshing" || got.Detail == "" { t.Fatalf("no-evidence caption: %+v", got) } } diff --git a/src/pkg/dashboard/stage_tracker_actor_icon_test.go b/src/pkg/dashboard/stage_tracker_actor_icon_test.go index a78b335558..cbafb2f13e 100644 --- a/src/pkg/dashboard/stage_tracker_actor_icon_test.go +++ b/src/pkg/dashboard/stage_tracker_actor_icon_test.go @@ -81,7 +81,7 @@ assert.strictEqual(litTitle(row), ''); // The server word wins over the heuristic: a hive stage with none → no icon. row = stageTrackerRowHtml(pr(506, { stage: 50, caption: 'CI running', stage_actor: { kind: 'none', why: 'CI is still running' } }), stages, ctx); assert.strictEqual(actorSvg(row).length, 0, strip(row)); -assert.ok(strip(row).includes('CI unknown') && strip(row).includes('Review unknown'), 'missing evidence remains unknown in both tracks'); +assert.ok(strip(row).includes('CI · no data for head') && strip(row).includes('Review · no data for head') && !strip(row).includes('activity unknown'), 'missing evidence names the head and the refresh in both tracks, never "unknown"'); assert.strictEqual(litTitle(row), '', 'an aggregate stage alone does not fabricate a reviewer or working chevron'); // An issue riding its one covering PR takes the PR's actor. diff --git a/src/pkg/dashboard/stage_tracker_build.go b/src/pkg/dashboard/stage_tracker_build.go index 4da5dbebd6..a72bd60589 100644 --- a/src/pkg/dashboard/stage_tracker_build.go +++ b/src/pkg/dashboard/stage_tracker_build.go @@ -475,6 +475,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto it.ReviewActivity = stageTrackerReviewActivity(activityPR, bundle, currentAggregate, dispatchState, status, now) stageTrackerCountPerspectives(it.ReviewActivity, activityPR, bundle, currentAggregate, dispatchState, stageTrackerRepoQualifier(status), expectedPerspectives) stageTrackerReviewPendingState(it.ReviewActivity, it.Stage, it.StageSince) + stageTrackerReviewFallbackState(it.ReviewActivity, stageTrackerReviewFallbackInputsFor(&it, pr, len(expectedPerspectives) > 0)) stageTrackerLeadApproveForSignOff(&it) if stageTrackerClaimantStage(it.Kind, it.Stage) { var worker *stageTrackerWorker @@ -533,7 +534,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto // A push projection can advance the head ahead of the cached PR list. // Never leave old-head approval/check verdicts on the projected item. if it.CIActivity == nil || !strings.EqualFold(it.CIActivity.Head, it.Head) { - it.CIActivity = trackerUnknownActivity(it.Head, "CI unknown · no check results observed for this head yet") + it.CIActivity = trackerUnknownActivity(it.Head, stageTrackerCINoDataCaption(it.Head)) } if it.ReviewActivity == nil || !strings.EqualFold(it.ReviewActivity.Head, it.Head) { currentPR := github.PullRequest{Repo: activityItem.Repo, Number: it.Number, HeadSHA: it.Head, Author: it.Author} @@ -551,6 +552,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto it.ReviewActivity = stageTrackerReviewActivity(currentPR, bundle, currentAggregate, dispatchState, status, now) stageTrackerCountPerspectives(it.ReviewActivity, currentPR, bundle, currentAggregate, dispatchState, stageTrackerRepoQualifier(status), expectedPerspectives) stageTrackerReviewPendingState(it.ReviewActivity, it.Stage, it.StageSince) + stageTrackerReviewFallbackState(it.ReviewActivity, stageTrackerReviewFallbackInputsFor(it, currentPR, len(expectedPerspectives) > 0)) } activityItem.CIActivity, activityItem.ReviewActivity = it.CIActivity, it.ReviewActivity stageTrackerApplyCodeActivity(&activityItem, dispatchState, status, now) diff --git a/src/pkg/dashboard/stage_tracker_claimant_test.go b/src/pkg/dashboard/stage_tracker_claimant_test.go index 7e328d4833..cb9e75034d 100644 --- a/src/pkg/dashboard/stage_tracker_claimant_test.go +++ b/src/pkg/dashboard/stage_tracker_claimant_test.go @@ -210,7 +210,7 @@ const covered = stageTrackerRowHtml(issue(9, { stage: 40, caption: 'Covered by P ] }), stages, ctx); const subWords = strips(covered).slice(1).map(s => text((/
  • ]*>([\s\S]*?)<\/li>/.exec(s) || ['', ''])[1])); assert.deepStrictEqual(subWords, ['Remediating · fixer', ''], JSON.stringify(subWords)); -assert.ok(subs(covered)[1].includes('CI unknown') && subs(covered)[1].includes('Review unknown'), 'the PR owner is not an assigned reviewer'); +assert.ok(subs(covered)[1].includes('CI · no data for head') && subs(covered)[1].includes('Review · no data for head'), 'the PR owner is not an assigned reviewer'); assert.ok(subs(covered)[1].includes('Held by: @alice'), 'ownership stays available without implying review activity'); console.log('claimant chevron ok'); `) diff --git a/src/pkg/dashboard/stage_tracker_review_fallback.go b/src/pkg/dashboard/stage_tracker_review_fallback.go new file mode 100644 index 0000000000..248e56963a --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_review_fallback.go @@ -0,0 +1,199 @@ +package dashboard + +import ( + "fmt" + "slices" + "strings" + + "github.com/hivecommons/hive/pkg/evidence" + "github.com/hivecommons/hive/pkg/github" +) + +// Review-track states the fallback derivation produces for a head with no +// verdict and no reviewer in flight (hivecommons/hive#16661). Each names +// what the row waits on, so the tooltip never reads "activity unknown". +const ( + reviewStateWaitingCI = "waiting_ci" + reviewStateNotStarted = "not_started" + reviewStateNotRequested = "not_requested" + reviewStateClosed = "closed" + reviewStateUnverified = "unverified" + reviewSourceDerived = "derived-from-pr-state" +) + +// stageTrackerReviewFallbackInputs is what the fallback can consult besides +// the review evidence itself: the PR's lifecycle, its CI track on the same +// head and whether a hive reviewer lane is configured for the repo. +type stageTrackerReviewFallbackInputs struct { + Head string + Draft bool + Closed bool + Merged bool + CI *StageTrackerActivity + ReviewerLane bool +} + +func stageTrackerReviewFallbackInputsFor(it *StageTrackerItem, pr github.PullRequest, reviewerLane bool) stageTrackerReviewFallbackInputs { + in := stageTrackerReviewFallbackInputs{Head: it.Head, CI: it.CIActivity, ReviewerLane: reviewerLane} + in.Draft = pr.Draft || slices.Contains(it.Modifiers, modDraft) + in.Merged = !pr.MergedAt.IsZero() + in.Closed = in.Merged || !pr.ClosedAt.IsZero() || strings.EqualFold(pr.State, "closed") + return in +} + +// stageTrackerReviewFallbackState replaces a Review track still "unknown" +// after the verdict, dispatch and review-pending derivations with the +// concrete statement the data supports, in this order: the PR is closed or +// merged (review is moot), it is a draft (review not requested), CI on the +// head has not finished (the reviewer waits for it), CI is done but no +// reviewer started (who is next), or nothing at all has been fetched for +// the head — the one case that may still read as no data, and it says the +// next poll refreshes it (hivecommons/hive#16661). +func stageTrackerReviewFallbackState(out *StageTrackerActivity, in stageTrackerReviewFallbackInputs) { + if out == nil || out.State != "unknown" { + return + } + sha7 := stageTrackerShortSHA(in.Head) + if sha7 == "" { + sha7 = "unknown" + } + out.Source = reviewSourceDerived + switch { + case in.Merged: + out.State, out.Caption = reviewStateClosed, "Review · n/a (merged)" + out.Detail = "The PR merged; no further review is requested for this head." + case in.Closed: + out.State, out.Caption = reviewStateClosed, "Review · n/a (closed)" + out.Detail = "The PR is closed; no review is requested for this head." + case in.Draft: + out.State, out.Caption = reviewStateNotRequested, "Review · draft, not requested" + out.Detail = "Review is requested when the author marks the draft ready for review." + default: + ci := stageTrackerReviewFallbackCI(in) + switch ci { + case "running": + out.State, out.Caption = reviewStateWaitingCI, "Review · waiting for CI" + out.Detail = fmt.Sprintf("No review has started on %s: the reviewer is requested once CI reports on this commit.", sha7) + case "done": + next := "needs reviewer" + out.Detail = fmt.Sprintf("CI has reported on %s and no reviewer has picked the head up; this repo has no hive reviewer lane, so a person must review.", sha7) + if in.ReviewerLane { + next = "hive reviewer next" + out.Detail = fmt.Sprintf("CI has reported on %s and no reviewer has picked the head up yet; the hive reviewer is next in line.", sha7) + } + out.State, out.Caption = reviewStateNotStarted, "Review · not started · "+next + default: + out.Caption = stageTrackerReviewNoDataCaption(in.Head) + out.Detail = "The spoke has not fetched checks or reviews for this commit yet; the next poll refreshes it." + out.Source = "unavailable" + } + } +} + +// stageTrackerReviewFallbackCI classifies the CI track on the same head: +// "running" (checks queued, running or not all reported), "done" (a pass, +// a failure or a skip) or "" when nothing has been observed for the head. +func stageTrackerReviewFallbackCI(in stageTrackerReviewFallbackInputs) string { + ci := in.CI + if ci == nil || in.Head == "" || !strings.EqualFold(ci.Head, in.Head) { + return "" + } + switch ci.State { + case "passing", "failing", "skipped": + return "done" + case "running", "queued", "missing": + return "running" + } + if ci.ChecksTotal > 0 { + if ci.ChecksPassed+ci.ChecksFailed < ci.ChecksTotal { + return "running" + } + return "done" + } + return "" +} + +// stageTrackerReviewVerdictDetail is the tooltip sentence behind a settled +// verdict on the head: who decided and on how many perspectives, so the +// inactive icon still explains itself. The age rides on since/observed_at +// (the UI renders "12m ago"); the sentence itself is stable across polls. +func stageTrackerReviewVerdictDetail(out *StageTrackerActivity, bundle *evidence.Bundle) string { + if out == nil || bundle == nil { + return "" + } + verdicts := trackerLatestBundleVerdicts(bundle) + by := "the hive reviewer" + n := len(verdicts) + switch out.State { + case "approved": + return fmt.Sprintf("Approved by %s on %s for this head.", by, plural(n, "perspective")) + case "changes_requested": + return fmt.Sprintf("Changes requested by %s: %s posted findings on this head; the fix is owed before a re-review.", by, plural(reviewFindingCount(verdicts), "perspective")) + case "human_decision": + return fmt.Sprintf("%s posted on this head; the review asks a person to decide.", plural(n, "perspective")) + } + return "" +} + +func reviewFindingCount(verdicts []evidence.Verdict) int { + n := 0 + for _, v := range verdicts { + if v.Verdict == "changes_requested" || v.Verdict == "reject" || v.Verdict == "requires_human" { + n++ + } + } + return n +} + +// trackerReviewPerspectives folds the bundle's latest verdicts to one per +// perspective. A blocking verdict outranks an approval from another +// backend on the same perspective, so dissent that still holds the head +// is not hidden; among equals the newest wins. +func trackerReviewPerspectives(bundle *evidence.Bundle) []StageTrackerPerspective { + latest := map[string]evidence.Verdict{} + blocking := func(v string) bool { return v != "approve" } + for _, verdict := range trackerLatestBundleVerdicts(bundle) { + if verdict.Perspective == "" { + continue + } + previous, ok := latest[verdict.Perspective] + if !ok || (!blocking(previous.Verdict) && blocking(verdict.Verdict)) || + (blocking(previous.Verdict) == blocking(verdict.Verdict) && verdict.RecordedAt.After(previous.RecordedAt)) { + latest[verdict.Perspective] = verdict + } + } + names := make([]string, 0, len(latest)) + for name := range latest { + names = append(names, name) + } + slices.Sort(names) + out := make([]StageTrackerPerspective, 0, len(names)) + for _, name := range names { + v := latest[name] + p := StageTrackerPerspective{Name: name, Verdict: v.Verdict} + if len(v.Findings) > 0 { + p.Summary = v.Findings[0].Summary + } + out = append(out, p) + } + return out +} + +// stageTrackerCINoDataCaption is the CI track's words when no check result +// has been observed for the head: the head and the next step, never +// "unknown" (hivecommons/hive#16661). +func stageTrackerCINoDataCaption(head string) string { + sha7 := stageTrackerShortSHA(head) + if sha7 == "" { + sha7 = "unknown" + } + return "CI · no checks observed for head " + sha7 + " yet · refreshing" +} + +func stageTrackerReviewNoDataCaption(head string) string { + sha7 := stageTrackerShortSHA(head) + if sha7 == "" { + sha7 = "unknown" + } + return "Review · no data for head " + sha7 + " yet · refreshing" +} diff --git a/src/pkg/dashboard/stage_tracker_review_fallback_test.go b/src/pkg/dashboard/stage_tracker_review_fallback_test.go new file mode 100644 index 0000000000..1e01d593ed --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_review_fallback_test.go @@ -0,0 +1,120 @@ +package dashboard + +import ( + "strings" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/evidence" + "github.com/hivecommons/hive/pkg/github" +) + +// hivecommons/hive#16661: a Review track with no verdict and no reviewer in +// flight states what it waits on, derived from the PR's own lifecycle and +// its CI track — one case per evidence source, never "activity unknown". +func TestStageTrackerReviewFallbackStateDerivesAConcreteStatement(t *testing.T) { + head := "f269349abcdef0123456789" + ci := func(state string, passed, failed, total int) *StageTrackerActivity { + return &StageTrackerActivity{Head: head, State: state, ChecksPassed: passed, ChecksFailed: failed, ChecksTotal: total} + } + cases := []struct { + name string + in stageTrackerReviewFallbackInputs + state string + caption string + source string + }{ + {"merged PR", stageTrackerReviewFallbackInputs{Head: head, Merged: true, Closed: true, Draft: true, CI: ci("running", 1, 0, 5)}, reviewStateClosed, "Review · n/a (merged)", reviewSourceDerived}, + {"closed PR", stageTrackerReviewFallbackInputs{Head: head, Closed: true, Draft: true, CI: ci("passing", 5, 0, 5)}, reviewStateClosed, "Review · n/a (closed)", reviewSourceDerived}, + {"draft outranks CI", stageTrackerReviewFallbackInputs{Head: head, Draft: true, CI: ci("running", 1, 0, 5)}, reviewStateNotRequested, "Review · draft, not requested", reviewSourceDerived}, + {"CI running", stageTrackerReviewFallbackInputs{Head: head, CI: ci("running", 3, 0, 11)}, reviewStateWaitingCI, "Review · waiting for CI", reviewSourceDerived}, + {"CI queued", stageTrackerReviewFallbackInputs{Head: head, CI: ci("queued", 0, 0, 11)}, reviewStateWaitingCI, "Review · waiting for CI", reviewSourceDerived}, + {"checks not all reported", stageTrackerReviewFallbackInputs{Head: head, CI: ci("missing", 7, 0, 11)}, reviewStateWaitingCI, "Review · waiting for CI", reviewSourceDerived}, + {"partial ring without a word", stageTrackerReviewFallbackInputs{Head: head, CI: ci("unknown", 13, 0, 19)}, reviewStateWaitingCI, "Review · waiting for CI", reviewSourceDerived}, + {"CI passed, hive reviewer lane", stageTrackerReviewFallbackInputs{Head: head, CI: ci("passing", 11, 0, 11), ReviewerLane: true}, reviewStateNotStarted, "Review · not started · hive reviewer next", reviewSourceDerived}, + {"CI failed, no reviewer lane", stageTrackerReviewFallbackInputs{Head: head, CI: ci("failing", 10, 1, 11)}, reviewStateNotStarted, "Review · not started · needs reviewer", reviewSourceDerived}, + {"CI skipped counts as done", stageTrackerReviewFallbackInputs{Head: head, CI: ci("skipped", 0, 0, 0), ReviewerLane: true}, reviewStateNotStarted, "Review · not started · hive reviewer next", reviewSourceDerived}, + {"full ring without a word counts as done", stageTrackerReviewFallbackInputs{Head: head, CI: ci("unknown", 19, 0, 19), ReviewerLane: true}, reviewStateNotStarted, "Review · not started · hive reviewer next", reviewSourceDerived}, + {"nothing fetched for the head", stageTrackerReviewFallbackInputs{Head: head, CI: ci("unknown", 0, 0, 0)}, "unknown", "Review · no data for head f269349 yet · refreshing", "unavailable"}, + {"CI from another head is no evidence", stageTrackerReviewFallbackInputs{Head: head, CI: &StageTrackerActivity{Head: "old", State: "passing"}}, "unknown", "Review · no data for head f269349 yet · refreshing", "unavailable"}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + out := trackerUnknownActivity(head, stageTrackerReviewNoDataCaption(head)) + stageTrackerReviewFallbackState(out, tc.in) + if out.State != tc.state || out.Caption != tc.caption || out.Source != tc.source { + t.Fatalf("got %s %q (%s), want %s %q (%s)", out.State, out.Caption, out.Source, tc.state, tc.caption, tc.source) + } + if out.Detail == "" || strings.Contains(out.Detail, "unknown") && tc.state != "unknown" { + t.Fatalf("detail must explain the wait: %q", out.Detail) + } + if out.Active { + t.Fatalf("a derived wait is not motion: %+v", out) + } + }) + } + // A settled or in-flight track is left alone. + for _, state := range []string{"approved", "changes_requested", "human_decision", "reviewing", "assigned", "unassigned", reviewStateUnverified} { + out := &StageTrackerActivity{Head: head, State: state, Caption: "kept"} + stageTrackerReviewFallbackState(out, stageTrackerReviewFallbackInputs{Head: head, Merged: true}) + if out.State != state || out.Caption != "kept" { + t.Fatalf("%s was rewritten: %+v", state, out) + } + } +} + +func TestStageTrackerReviewFallbackInputsReadThePR(t *testing.T) { + now := time.Date(2026, 11, 4, 19, 0, 0, 0, time.UTC) + it := &StageTrackerItem{Head: "abc", Modifiers: []string{modDraft}, CIActivity: &StageTrackerActivity{Head: "abc", State: "passing"}} + in := stageTrackerReviewFallbackInputsFor(it, github.PullRequest{HeadSHA: "abc"}, true) + if !in.Draft || in.Closed || in.Merged || in.CI != it.CIActivity || !in.ReviewerLane || in.Head != "abc" { + t.Fatalf("draft modifier not read: %+v", in) + } + in = stageTrackerReviewFallbackInputsFor(&StageTrackerItem{Head: "abc"}, github.PullRequest{HeadSHA: "abc", MergedAt: now, ClosedAt: now, State: "closed"}, false) + if !in.Merged || !in.Closed || in.Draft { + t.Fatalf("merged PR not read: %+v", in) + } + in = stageTrackerReviewFallbackInputsFor(&StageTrackerItem{Head: "abc"}, github.PullRequest{HeadSHA: "abc", State: "closed"}, false) + if in.Merged || !in.Closed { + t.Fatalf("closed state not read: %+v", in) + } +} + +func TestStageTrackerCINoDataCaptionNamesTheHead(t *testing.T) { + if got := stageTrackerCINoDataCaption("f269349abcdef"); got != "CI · no checks observed for head f269349 yet · refreshing" { + t.Fatalf("caption = %q", got) + } + if got := stageTrackerCINoDataCaption(""); !strings.Contains(got, "head unknown") || strings.Contains(got, "CI unknown") { + t.Fatalf("caption = %q", got) + } +} + +// hivecommons/hive#16617: one entry per perspective, a blocking verdict on +// the same perspective outranking another backend's approval, newest among +// equals; the first finding rides as the summary. +func TestTrackerReviewPerspectivesPreserveDissent(t *testing.T) { + now := time.Date(2026, 11, 4, 19, 0, 0, 0, time.UTC) + bundle := &evidence.Bundle{Verdicts: []evidence.Verdict{ + {Perspective: "security", Backend: "a", Model: "m", Verdict: "changes_requested", RecordedAt: now.Add(-2 * time.Minute), Findings: []evidence.Finding{{Summary: "token logged"}}}, + {Perspective: "security", Backend: "b", Model: "m", Verdict: "approve", RecordedAt: now}, + {Perspective: "quality", Backend: "a", Model: "m", Verdict: "approve", RecordedAt: now.Add(-3 * time.Minute)}, + {Perspective: "quality", Backend: "a", Model: "m", Verdict: "approve", RecordedAt: now}, + {Perspective: "", Backend: "a", Model: "m", Verdict: "approve", RecordedAt: now}, + }} + got := trackerReviewPerspectives(bundle) + if len(got) != 2 || got[0].Name != "quality" || got[0].Verdict != "approve" || got[0].Summary != "" || + got[1].Name != "security" || got[1].Verdict != "changes_requested" || got[1].Summary != "token logged" { + t.Fatalf("perspectives = %+v", got) + } + out := &StageTrackerActivity{State: "changes_requested"} + if d := stageTrackerReviewVerdictDetail(out, bundle); !strings.Contains(d, "Changes requested by the hive reviewer") || !strings.Contains(d, "1 perspective posted findings") { + t.Fatalf("detail = %q", d) + } + out.State = "approved" + if d := stageTrackerReviewVerdictDetail(out, bundle); !strings.Contains(d, "Approved by the hive reviewer on") { + t.Fatalf("detail = %q", d) + } + if d := stageTrackerReviewVerdictDetail(out, nil); d != "" { + t.Fatalf("no bundle, no detail: %q", d) + } +} diff --git a/src/pkg/dashboard/stage_tracker_ui_prelude_test.go b/src/pkg/dashboard/stage_tracker_ui_prelude_test.go index 6b356f2428..d907760cad 100644 --- a/src/pkg/dashboard/stage_tracker_ui_prelude_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_prelude_test.go @@ -247,11 +247,18 @@ const onlyTracksPair = (item, s, i) => { assert.ok(!/\b(CI failing|CI \d+\/\d+|Changes requested)\b/.test(words), 'fixture ' + (item.repo || '') + '#' + item.number + ' strip ' + i + ' stage chevron speaks a track verdict: ' + words); }); }; +// hivecommons/hive#16661: a CI / Review tooltip states what the track waits +// on; "activity unknown" / "CI unknown" / "Review unknown" never appear. +const neverActivityUnknown = (item, s, i) => Array.from(s.matchAll(/
  • /g)).forEach(m => { + const tip = ((/role="tooltip">([\s\S]*?)<\/span>/.exec(m[0]) || [])[1] || '').replace(/<[^>]+>/g, ''); + assert.ok(!/activity unknown|\b(?:CI|Review) unknown\b/.test(tip), 'fixture ' + (item.repo || '') + '#' + item.number + ' strip ' + i + ' track tooltip says unknown: ' + tip); +}); const atMostTwoLit = (item, row) => row.split('aria-label="Pipeline progress"').slice(1).forEach((s, i) => { assert.ok(litChevrons(s) <= 2, 'fixture ' + (item.repo || '') + '#' + item.number + ' strip ' + i + ' lights ' + litChevrons(s) + ' chevrons: ' + s); onlyTracksPair(item, s, i); if (s.includes('aria-current="step"')) assert.ok(filledChevrons(s) >= 1, 'fixture ' + (item.repo || '') + '#' + item.number + ' strip ' + i + ' has no filled chevron: ' + s); wordsOnlyWhenActive(item, s); + neverActivityUnknown(item, s, i); }); const rawRowHtml = stageTrackerRowHtml; stageTrackerRowHtml = (item, stages, ctx) => { rebaseCoherent(item); const row = rawRowHtml(item, stages, ctx); atMostTwoLit(item, row); return row; }; diff --git a/src/pkg/dashboard/stage_tracker_ui_rows_test.go b/src/pkg/dashboard/stage_tracker_ui_rows_test.go index d103b14159..ebe18ab855 100644 --- a/src/pkg/dashboard/stage_tracker_ui_rows_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_rows_test.go @@ -332,7 +332,7 @@ assert.ok(row.includes('ham-mod-needs-decision">needs human decision') && assert.ok(row.includes('data-track="ci"') && row.includes('data-track="review"') && !row.includes('ham-actor-ico'), 'a native stage cannot identify the actual reviewer: ' + row); assert.ok(!row.includes('ham-author-ico ham-actor') && !row.includes('ham-actor-ico ham-author-'), 'actor icon must not carry the author colour classes: ' + row); row = stageTrackerRowHtml({ repo: 'acme/console', number: 108, kind: 'pr', stage: 72, author_kind: 'clanker' }, stages, ctx); -assert.ok(row.includes('Review unknown') && row.includes('CI unknown'), 'legacy author waits do not fabricate observed activity: ' + row); +assert.ok(row.includes('Review · no data for head') && row.includes('CI · no data for head') && !row.includes('activity unknown'), 'legacy author waits do not fabricate observed activity: ' + row); // 071 needs-author: the owner wait returns to PR in progress without pretending coding. row = stageTrackerRowHtml({ repo: 'acme/console', number: 109, kind: 'pr', stage: 71, author: 'sam', author_kind: 'human', history: [{number:50,slug:'review-pending'},{number:71,slug:'needs-author',from:50}] }, stages, ctx); assert.deepStrictEqual(segStates(row), [D, D, D, 'active detoured', T, T, 'todo cap']); @@ -563,7 +563,7 @@ for (const [st, word, actor] of [[50, 'CI / Review', 'hive'], [60, 'Review passe const r = stageTrackerRowHtml({ repo: 'acme/console', number: 500 + st, kind: 'pr', stage: st, author_kind: 'clanker' }, stages, ctx); if ([50, 60, 70, 71, 72, 74].includes(st)) { assert.ok(r.includes('data-track="ci"') && r.includes('data-track="review"'), 'pre-gate tracks remain separate at ' + st); - assert.ok(r.includes('CI unknown') && r.includes('Review unknown'), 'legacy labels alone cannot supply activity at ' + st); + assert.ok(r.includes('CI · no data for head') && r.includes('Review · no data for head'), 'legacy labels alone cannot supply activity at ' + st); continue; } const m = /aria-current="step">]*>]*>[\s\S]*?<\/svg>([^<]*)<\/span><\/span>]*aria-label="Next move: ([a-z]+)"[^>]*>/.exec(r); @@ -660,9 +660,9 @@ expectTitles(row, ['a.ham-ref', 'span.ham-title', 'a.ham-pr-ref'], 'issue with o assert.ok(/]*title="The one PR Author: hive · @hive-bot · linked PR, shown on its issue's row"/.test(row), 'the PR link also explains the shared row: ' + row); // tracker-cues: with no agent on the item the chevron is static (waiting); // the pulse and the "Working now" lead need a worker in ctx.workers. -assert.ok(row.includes('CI unknown') && row.includes('Review unknown') && !strip(row).includes('data-motion='), 'a stage label alone supplies no activity: ' + row); +assert.ok(row.includes('CI · no data for head') && row.includes('Review · no data for head') && !strip(row).includes('data-motion='), 'a stage label alone supplies no activity: ' + row); row = stageTrackerRowHtml(g[1], stages, Object.assign({}, ctx, { workers: { 'g/r#21': { agent: 'scout', action: 'agent_comment_created', at: new Date(now - 120000).toISOString() } } })); -assert.ok(row.includes('Review unknown') && !strip(row).includes('data-motion='), 'a generic commenter is not a current-head reviewer: ' + row); +assert.ok(row.includes('Review · no data for head') && !strip(row).includes('data-motion='), 'a generic commenter is not a current-head reviewer: ' + row); assert.ok(/class="ham-row cue-working"/.test(row), 'the row carries the working cue: ' + row); assert.ok(!/
  • ]*title="Claimed"/.test(stageTrackerRowHtml(g[0], stages, ctx)), 'Claimed is static: no data-motion'); // Issue with two PRs: #N link + title on the issue line, nothing lit there; 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 3740621d3a..e2834b73b3 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row-strip.js +++ b/src/pkg/dashboard/static-src/js/tracker-row-strip.js @@ -112,6 +112,10 @@ case 'adjudicating': return count + ' · ' + (actor ? actor + ' adjudicating' : 'adjudicating'); case 'assigned': return count + ' · ' + (actor ? actor + ' queued' : 'queued') + stageTrackerQueueAheadWord(a); case 'unassigned': return count + ' · queued' + stageTrackerQueueAheadWord(a); + // Derived from the PR's own state when no reviewer has touched the + // head (stage_tracker_review_fallback.go): the words are the + // statement itself (hivecommons/hive#16661). + case 'waiting_ci': case 'not_started': case 'not_requested': case 'closed': case 'unverified': return a.caption || count; default: return count + ' · ' + (newHead ? reReview : total && done ? 'perspectives' : 'queued'); } } @@ -266,16 +270,29 @@ const name = kind === 'ci' ? 'CI' : 'Review'; const a = item && item[kind + '_activity']; const matches = a && item.head && a.head === item.head; - let caption = matches ? a.caption || name + ' unknown' : name + ' unknown'; + // No evidence for the head is still a statement with a next step — + // never "activity unknown" (hivecommons/hive#16661). + const noData = name + ' · no data for head ' + (item.head ? String(item.head).slice(0, 7) : 'unknown') + ' yet · refreshing'; + let caption = matches ? a.caption || noData : noData; + // A legacy "CI unknown · reason" caption keeps its reason behind the statement. + caption = caption.replace(/^(CI|Review) unknown(?= ·|$)/, noData); const observed = matches && a.observed_at ? Date.parse(a.observed_at) : NaN; const activityFreshMS = 2 * 60 * 1000; const clock = Number(nowMs) || Date.now(); + // "12m ago" beside a timestamp (kept local: harnesses lift this function alone). + const agoWord = (atMs, nowMs) => { const mins = Math.floor((nowMs - atMs) / 60000); return !Number.isFinite(mins) || mins < 1 ? 'just now' : mins < 60 ? mins + 'm ago' : mins < 1440 ? Math.floor(mins / 60) + 'h ago' : Math.floor(mins / 1440) + 'd ago'; }; const stale = Number.isFinite(observed) && (clock - observed > activityFreshMS || observed > clock); const current = sg.state === 'active'; const state = matches ? a.state || 'unknown' : 'unknown'; - const known = matches && state !== 'unknown' && Number.isFinite(observed) && !stale; - const active = known && a.active; - if (matches && !known && state !== 'unknown') caption = name + ' activity unknown · last observed ' + state + ' · ' + caption; + // A settled verdict on the head stays known as its observation + // ages; only motion needs a fresh observation (hivecommons/hive#16617). + const settledState = ['approved', 'changes_requested', 'human_decision', 'passing', 'failing', 'skipped', 'missing', 'waiting_ci', 'not_started', 'not_requested', 'closed', 'unverified'].includes(state); + const fresh = Number.isFinite(observed) && !stale; + const known = matches && state !== 'unknown' && (settledState || fresh); + const active = known && fresh && a.active; + const perspectives = matches && kind === 'review' && Array.isArray(a.perspectives) ? a.perspectives : []; + const perspectiveMark = v => v === 'approve' ? '✓' : ['changes_requested', 'reject'].includes(v) ? '✗' : v === 'requires_human' ? 'requires human' : String(v || '?'); + const perspectiveLine = p => String(p.name || 'perspective') + ' ' + perspectiveMark(p.verdict) + (p.summary ? ': ' + p.summary : ''); const ownsPR = item.kind === 'pr' || item.via_pr; const text = typeof stageTrackerTrackWord === 'function' ? stageTrackerTrackWord(item, kind, current) : (matches ? a.caption || name + ' ' + state : ''); const finished = matches && (state === 'passing' || state === 'approved'); @@ -298,7 +315,7 @@ const humanAction = approvalPending > 0 ? STAGE_TRACKER_WORKFLOW_APPROVAL_TIP : kind === 'review' && state === 'human_decision' ? 'Needs a person\'s decision' : ''; const personIco = stalled && humanAction ? stageTrackerIcon('human', 'ham-ico ham-actor-ico', humanAction) : ''; const source = matches ? a.source || 'unavailable' : 'unavailable'; - const freshness = !Number.isFinite(observed) ? 'observation time unknown' : (stale ? 'stale · ' : 'observed · ') + new Date(observed).toISOString(); + const freshness = !Number.isFinite(observed) ? 'observation time unknown' : (stale ? 'stale · ' : 'observed · ') + new Date(observed).toISOString() + ' (' + agoWord(observed, clock) + ')'; const since = matches && a.since && Number.isFinite(Date.parse(a.since)) ? ' · since ' + new Date(a.since).toISOString() : ''; let blocker = matches && a.blocker ? ' · ' + a.blocker : ''; // A sign-off ask: the tooltip carries the question itself (who should @@ -309,12 +326,15 @@ // The backend's plain-language sentence behind the caption rides in // the tooltip only; the chevron clamps the caption. const detail = matches && a.detail ? ' · ' + a.detail : ''; - let tip = caption + blocker + detail + ' · head ' + (item.head || 'unknown') + ' · ' + source + ' · ' + freshness + since; + const sinceAgo = matches && a.since && Number.isFinite(Date.parse(a.since)) && settledState ? ' · ' + agoWord(Date.parse(a.since), clock) : ''; + let tip = caption + blocker + detail + sinceAgo + (perspectives.length ? ' · ' + perspectives.map(perspectiveLine).join(' · ') : '') + ' · head ' + (item.head || 'unknown') + ' · ' + source + ' · ' + freshness + since; const code = item.code_activity; const codeNote = code && code.head === item.head && Number(item.display_column) === 50 && ((kind === 'review' && code.state === 'waiting_fixer') || (kind === 'ci' && code.state === 'waiting_ci')) ? code.caption : ''; if (codeNote) tip += ' · code source ' + (code.source || 'unavailable') + ' · observed ' + (code.observed_at || 'unknown') + ' · since ' + (code.since || 'unknown') + (code.blocker ? ' · ' + code.blocker : ''); - const contextWord = kind === 'review' && sg.state === 'active' && !codeNote && sg.detour ? sg.detour.text : ''; + // The detour's words ride along, minus the code lane's "activity unknown" + // (the Review tooltip states what is observed, hivecommons/hive#16661). + const contextWord = kind === 'review' && sg.state === 'active' && !codeNote && sg.detour ? String(sg.detour.text || '').replace(/ · activity unknown$/, ' · no fix work observed yet').replace(/^Code activity unknown$/, 'no code work observed yet') : ''; let decided = kind === 'review' && sg.state === 'active' && item.decided && typeof stageTrackerMergeGateWordHtml === 'function' ? stageTrackerMergeGateWordHtml(item, nowMs) : ''; const codeObserved = Date.parse(code && code.observed_at || ''); const codeFresh = code && code.head === item.head && code.source === 'fix-dispatch+successful-edit+verified-git-worktree' && code.active && code.state === 'fixing' && Number.isFinite(codeObserved) && codeObserved <= clock && clock - codeObserved <= activityFreshMS; @@ -336,7 +356,7 @@ const evidenceLink = ownsPR && evidenceURL ? `${icon}${word}` : icon + word; const routeState = (sg.state || 'todo') + (sg.detour ? ' detoured' : ''); const hold = item.hold; - const fullTip = (current ? 'Current pipeline phase · ' : '') + name + ': ' + (text ? text + ' · ' : '') + tip + + const fullTip = (current ? 'Current pipeline phase · ' : '') + name + ': ' + (text && text !== caption ? text + ' · ' : '') + tip + (matches && a.actor ? ' · actor ' + a.actor : '') + (codeNote || contextWord ? ' · ' + (codeNote || contextWord) : '') + (hold ? ' · ' + (hold.pill || 'Held by @' + hold.by) + (hold.reason ? ' · ' + hold.reason : '') : '') + @@ -552,13 +572,15 @@ const tracks = (item.kind === 'pr' || item.via_pr) && item.head ? ['ci', 'review'].map(kind => { const a = item[kind + '_activity']; const name = kind === 'ci' ? 'CI' : 'Review'; - if (!a || a.head !== item.head) return name + ' unknown'; + const noData = name + ' · no data for head ' + String(item.head).slice(0, 7) + ' yet · refreshing'; + if (!a || a.head !== item.head) return noData; const observed = Date.parse(a.observed_at || ''); const activityFreshMS = 2 * 60 * 1000; const clock = Number(nowMs) || Date.now(); const fresh = Number.isFinite(observed) && observed <= clock && clock - observed <= activityFreshMS; - if ((a.active || ['running', 'reviewing', 'adjudicating'].includes(a.state)) && !fresh) return name + ' activity unknown · last observed ' + (a.state || 'unknown'); - return (a.caption || name + ' unknown') + (!Number.isFinite(observed) ? ' · observation time unknown' : !fresh ? ' · stale observation' : ''); + const agoWord = (atMs, nowMs) => { const mins = Math.floor((nowMs - atMs) / 60000); return !Number.isFinite(mins) || mins < 1 ? 'just now' : mins < 60 ? mins + 'm ago' : mins < 1440 ? Math.floor(mins / 60) + 'h ago' : Math.floor(mins / 1440) + 'd ago'; }; + const moving = a.active || ['running', 'reviewing', 'adjudicating'].includes(a.state); + return (a.caption || noData).replace(/^(CI|Review) unknown(?= ·|$)/, noData) + (!Number.isFinite(observed) ? ' · observation time unknown' : !fresh ? ' · last observed ' + agoWord(observed, clock) + (moving ? ' · refreshing' : '') : ''); }).join(' · ') : ''; return `

    ${esc(text + (tracks ? ' · ' + tracks : ''))}

    `; } diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index a09cf5b522..5bc4dc9c22 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -18025,6 +18025,10 @@

    Where to get help

    case 'adjudicating': return count + ' · ' + (actor ? actor + ' adjudicating' : 'adjudicating'); case 'assigned': return count + ' · ' + (actor ? actor + ' queued' : 'queued') + stageTrackerQueueAheadWord(a); case 'unassigned': return count + ' · queued' + stageTrackerQueueAheadWord(a); + // Derived from the PR's own state when no reviewer has touched the + // head (stage_tracker_review_fallback.go): the words are the + // statement itself (hivecommons/hive#16661). + case 'waiting_ci': case 'not_started': case 'not_requested': case 'closed': case 'unverified': return a.caption || count; default: return count + ' · ' + (newHead ? reReview : total && done ? 'perspectives' : 'queued'); } } @@ -18179,16 +18183,29 @@

    Where to get help

    const name = kind === 'ci' ? 'CI' : 'Review'; const a = item && item[kind + '_activity']; const matches = a && item.head && a.head === item.head; - let caption = matches ? a.caption || name + ' unknown' : name + ' unknown'; + // No evidence for the head is still a statement with a next step — + // never "activity unknown" (hivecommons/hive#16661). + const noData = name + ' · no data for head ' + (item.head ? String(item.head).slice(0, 7) : 'unknown') + ' yet · refreshing'; + let caption = matches ? a.caption || noData : noData; + // A legacy "CI unknown · reason" caption keeps its reason behind the statement. + caption = caption.replace(/^(CI|Review) unknown(?= ·|$)/, noData); const observed = matches && a.observed_at ? Date.parse(a.observed_at) : NaN; const activityFreshMS = 2 * 60 * 1000; const clock = Number(nowMs) || Date.now(); + // "12m ago" beside a timestamp (kept local: harnesses lift this function alone). + const agoWord = (atMs, nowMs) => { const mins = Math.floor((nowMs - atMs) / 60000); return !Number.isFinite(mins) || mins < 1 ? 'just now' : mins < 60 ? mins + 'm ago' : mins < 1440 ? Math.floor(mins / 60) + 'h ago' : Math.floor(mins / 1440) + 'd ago'; }; const stale = Number.isFinite(observed) && (clock - observed > activityFreshMS || observed > clock); const current = sg.state === 'active'; const state = matches ? a.state || 'unknown' : 'unknown'; - const known = matches && state !== 'unknown' && Number.isFinite(observed) && !stale; - const active = known && a.active; - if (matches && !known && state !== 'unknown') caption = name + ' activity unknown · last observed ' + state + ' · ' + caption; + // A settled verdict on the head stays known as its observation + // ages; only motion needs a fresh observation (hivecommons/hive#16617). + const settledState = ['approved', 'changes_requested', 'human_decision', 'passing', 'failing', 'skipped', 'missing', 'waiting_ci', 'not_started', 'not_requested', 'closed', 'unverified'].includes(state); + const fresh = Number.isFinite(observed) && !stale; + const known = matches && state !== 'unknown' && (settledState || fresh); + const active = known && fresh && a.active; + const perspectives = matches && kind === 'review' && Array.isArray(a.perspectives) ? a.perspectives : []; + const perspectiveMark = v => v === 'approve' ? '✓' : ['changes_requested', 'reject'].includes(v) ? '✗' : v === 'requires_human' ? 'requires human' : String(v || '?'); + const perspectiveLine = p => String(p.name || 'perspective') + ' ' + perspectiveMark(p.verdict) + (p.summary ? ': ' + p.summary : ''); const ownsPR = item.kind === 'pr' || item.via_pr; const text = typeof stageTrackerTrackWord === 'function' ? stageTrackerTrackWord(item, kind, current) : (matches ? a.caption || name + ' ' + state : ''); const finished = matches && (state === 'passing' || state === 'approved'); @@ -18211,7 +18228,7 @@

    Where to get help

    const humanAction = approvalPending > 0 ? STAGE_TRACKER_WORKFLOW_APPROVAL_TIP : kind === 'review' && state === 'human_decision' ? 'Needs a person\'s decision' : ''; const personIco = stalled && humanAction ? stageTrackerIcon('human', 'ham-ico ham-actor-ico', humanAction) : ''; const source = matches ? a.source || 'unavailable' : 'unavailable'; - const freshness = !Number.isFinite(observed) ? 'observation time unknown' : (stale ? 'stale · ' : 'observed · ') + new Date(observed).toISOString(); + const freshness = !Number.isFinite(observed) ? 'observation time unknown' : (stale ? 'stale · ' : 'observed · ') + new Date(observed).toISOString() + ' (' + agoWord(observed, clock) + ')'; const since = matches && a.since && Number.isFinite(Date.parse(a.since)) ? ' · since ' + new Date(a.since).toISOString() : ''; let blocker = matches && a.blocker ? ' · ' + a.blocker : ''; // A sign-off ask: the tooltip carries the question itself (who should @@ -18222,12 +18239,15 @@

    Where to get help

    // The backend's plain-language sentence behind the caption rides in // the tooltip only; the chevron clamps the caption. const detail = matches && a.detail ? ' · ' + a.detail : ''; - let tip = caption + blocker + detail + ' · head ' + (item.head || 'unknown') + ' · ' + source + ' · ' + freshness + since; + const sinceAgo = matches && a.since && Number.isFinite(Date.parse(a.since)) && settledState ? ' · ' + agoWord(Date.parse(a.since), clock) : ''; + let tip = caption + blocker + detail + sinceAgo + (perspectives.length ? ' · ' + perspectives.map(perspectiveLine).join(' · ') : '') + ' · head ' + (item.head || 'unknown') + ' · ' + source + ' · ' + freshness + since; const code = item.code_activity; const codeNote = code && code.head === item.head && Number(item.display_column) === 50 && ((kind === 'review' && code.state === 'waiting_fixer') || (kind === 'ci' && code.state === 'waiting_ci')) ? code.caption : ''; if (codeNote) tip += ' · code source ' + (code.source || 'unavailable') + ' · observed ' + (code.observed_at || 'unknown') + ' · since ' + (code.since || 'unknown') + (code.blocker ? ' · ' + code.blocker : ''); - const contextWord = kind === 'review' && sg.state === 'active' && !codeNote && sg.detour ? sg.detour.text : ''; + // The detour's words ride along, minus the code lane's "activity unknown" + // (the Review tooltip states what is observed, hivecommons/hive#16661). + const contextWord = kind === 'review' && sg.state === 'active' && !codeNote && sg.detour ? String(sg.detour.text || '').replace(/ · activity unknown$/, ' · no fix work observed yet').replace(/^Code activity unknown$/, 'no code work observed yet') : ''; let decided = kind === 'review' && sg.state === 'active' && item.decided && typeof stageTrackerMergeGateWordHtml === 'function' ? stageTrackerMergeGateWordHtml(item, nowMs) : ''; const codeObserved = Date.parse(code && code.observed_at || ''); const codeFresh = code && code.head === item.head && code.source === 'fix-dispatch+successful-edit+verified-git-worktree' && code.active && code.state === 'fixing' && Number.isFinite(codeObserved) && codeObserved <= clock && clock - codeObserved <= activityFreshMS; @@ -18249,7 +18269,7 @@

    Where to get help

    const evidenceLink = ownsPR && evidenceURL ? `${icon}${word}` : icon + word; const routeState = (sg.state || 'todo') + (sg.detour ? ' detoured' : ''); const hold = item.hold; - const fullTip = (current ? 'Current pipeline phase · ' : '') + name + ': ' + (text ? text + ' · ' : '') + tip + + const fullTip = (current ? 'Current pipeline phase · ' : '') + name + ': ' + (text && text !== caption ? text + ' · ' : '') + tip + (matches && a.actor ? ' · actor ' + a.actor : '') + (codeNote || contextWord ? ' · ' + (codeNote || contextWord) : '') + (hold ? ' · ' + (hold.pill || 'Held by @' + hold.by) + (hold.reason ? ' · ' + hold.reason : '') : '') + @@ -18465,13 +18485,15 @@

    Where to get help

    const tracks = (item.kind === 'pr' || item.via_pr) && item.head ? ['ci', 'review'].map(kind => { const a = item[kind + '_activity']; const name = kind === 'ci' ? 'CI' : 'Review'; - if (!a || a.head !== item.head) return name + ' unknown'; + const noData = name + ' · no data for head ' + String(item.head).slice(0, 7) + ' yet · refreshing'; + if (!a || a.head !== item.head) return noData; const observed = Date.parse(a.observed_at || ''); const activityFreshMS = 2 * 60 * 1000; const clock = Number(nowMs) || Date.now(); const fresh = Number.isFinite(observed) && observed <= clock && clock - observed <= activityFreshMS; - if ((a.active || ['running', 'reviewing', 'adjudicating'].includes(a.state)) && !fresh) return name + ' activity unknown · last observed ' + (a.state || 'unknown'); - return (a.caption || name + ' unknown') + (!Number.isFinite(observed) ? ' · observation time unknown' : !fresh ? ' · stale observation' : ''); + const agoWord = (atMs, nowMs) => { const mins = Math.floor((nowMs - atMs) / 60000); return !Number.isFinite(mins) || mins < 1 ? 'just now' : mins < 60 ? mins + 'm ago' : mins < 1440 ? Math.floor(mins / 60) + 'h ago' : Math.floor(mins / 1440) + 'd ago'; }; + const moving = a.active || ['running', 'reviewing', 'adjudicating'].includes(a.state); + return (a.caption || noData).replace(/^(CI|Review) unknown(?= ·|$)/, noData) + (!Number.isFinite(observed) ? ' · observation time unknown' : !fresh ? ' · last observed ' + agoWord(observed, clock) + (moving ? ' · refreshing' : '') : ''); }).join(' · ') : ''; return `

    ${esc(text + (tracks ? ' · ' + tracks : ''))}

    `; }