diff --git a/changelog.d/fixed-16617-review-activity.md b/changelog.d/fixed-16617-review-activity.md new file mode 100644 index 0000000000..a2edad58bc --- /dev/null +++ b/changelog.d/fixed-16617-review-activity.md @@ -0,0 +1 @@ +- The Activity Monitor preserves settled review and CI verdicts on the current head as observations age, and review tooltips list each perspective’s verdict and finding with the observation age ([#16617](https://github.com/hivecommons/hive/issues/16617)). diff --git a/src/docs/api-reference/dashboard-misc.md b/src/docs/api-reference/dashboard-misc.md index 63173e935a..3ed4656839 100644 --- a/src/docs/api-reference/dashboard-misc.md +++ b/src/docs/api-reference/dashboard-misc.md @@ -6,6 +6,10 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f `GET /api/stage-tracker` adds independent PR `ci_activity`, `review_activity` and `code_activity` observations, also copied to `linked_prs[]`. Each is `{head, state, caption, actor?, source, observed_at?, since?, blocker?, url?, active?}`. +`review_activity` additionally carries `perspectives_done?`, `perspectives_total?` +and `perspectives?: [{name, verdict, summary}]` — the latest current-head bundle +verdict per perspective (dissent outranks approval), with `summary` the first +finding when one was reported. These are display evidence, **not merge authorization**. An absent timestamp means unknown freshness; a different head invalidates the observation. CI is classified only against the resolved required set from the existing diff --git a/src/docs/streaming-the-activity-monitor.md b/src/docs/streaming-the-activity-monitor.md index c7dd5a8cde..9ebfe0e6aa 100644 --- a/src/docs/streaming-the-activity-monitor.md +++ b/src/docs/streaming-the-activity-monitor.md @@ -37,7 +37,10 @@ recorded assignment/transition, never an invented return date. Track tooltips disclose the head, evidence source, observation time, state time and blocker where known. A `?` means stale or missing observation time; -unknown activity has no spinner. Review assignment is read from dispatch, not +unknown activity has no spinner. A settled verdict on the current head +(approved, findings, passing, failing) does not go stale: its caption stays +and the tooltip adds an "observed Nm ago · stale" age, while only motion +states (running, reviewing, queued, ...) fall back to "activity unknown". Review assignment is read from dispatch, not the PR author, claimant, scanner or Prow approval labels. Verified current-head review evidence and the current aggregate supply approval/findings; missing reviewer identity is left unknown. An assignment is not proof of execution, diff --git a/src/pkg/dashboard/stage_tracker_activity.go b/src/pkg/dashboard/stage_tracker_activity.go index a0ffe9a757..82f49fcc87 100644 --- a/src/pkg/dashboard/stage_tracker_activity.go +++ b/src/pkg/dashboard/stage_tracker_activity.go @@ -43,8 +43,18 @@ type StageTrackerActivity struct { // the swarm's expected set for this PR (configured perspectives plus any // extra one dispatched or reported for the head), Done the ones with a // verdict for the current head. - PerspectivesDone int `json:"perspectives_done,omitempty"` - PerspectivesTotal int `json:"perspectives_total,omitempty"` + PerspectivesDone int `json:"perspectives_done,omitempty"` + PerspectivesTotal int `json:"perspectives_total,omitempty"` + Perspectives []StageTrackerPerspective `json:"perspectives,omitempty"` +} + +// StageTrackerPerspective describes the latest bundle verdict for one perspective +// on the current head, preserving dissent across reviewers. Summary is the +// first finding, when one was reported. +type StageTrackerPerspective struct { + Name string `json:"name"` + Verdict string `json:"verdict"` + Summary string `json:"summary"` } const trackerActivityFreshWindow = 2 * time.Minute @@ -468,12 +478,25 @@ func trackerHeadMatches(repo string, number int, head, observedRepo string, obse return number == observedNumber && head != "" && strings.EqualFold(head, observedHead) && strings.EqualFold(repo, observedRepo) } +// trackerPrefersVerdict reports whether candidate should replace previous as +// the current verdict: dissent beats approval, otherwise the newest wins. +func trackerPrefersVerdict(previous, candidate evidence.Verdict) bool { + previousApproves, candidateApproves := previous.Verdict == "approve", candidate.Verdict == "approve" + if previousApproves != candidateApproves { + return previousApproves + } + return candidate.RecordedAt.After(previous.RecordedAt) +} + +// trackerLatestBundleVerdicts keeps one verdict per reviewer (perspective, +// backend, model): the newest recording, with dissent breaking exact ties. func trackerLatestBundleVerdicts(bundle *evidence.Bundle) []evidence.Verdict { latest := map[string]evidence.Verdict{} for _, verdict := range bundle.Verdicts { key := verdict.Perspective + "\x00" + verdict.Backend + "\x00" + verdict.Model - if previous, ok := latest[key]; !ok || verdict.RecordedAt.After(previous.RecordedAt) || - (verdict.RecordedAt.Equal(previous.RecordedAt) && previous.Verdict == "approve" && verdict.Verdict != "approve") { + previous, ok := latest[key] + if !ok || verdict.RecordedAt.After(previous.RecordedAt) || + (verdict.RecordedAt.Equal(previous.RecordedAt) && trackerPrefersVerdict(previous, verdict)) { latest[key] = verdict } } @@ -489,6 +512,36 @@ func trackerLatestBundleVerdicts(bundle *evidence.Bundle) []evidence.Verdict { return out } +func trackerReviewPerspectives(bundle *evidence.Bundle) []StageTrackerPerspective { + latest := map[string]evidence.Verdict{} + for _, verdict := range trackerLatestBundleVerdicts(bundle) { + if verdict.Perspective == "" { + continue + } + previous, ok := latest[verdict.Perspective] + // Each backend/model has its own current verdict. An approval by + // another reviewer must not hide dissent that still blocks the head. + if !ok || trackerPrefersVerdict(previous, verdict) { + 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 +} + func trackerBundleApproves(bundle *evidence.Bundle, agg *review.Aggregate) bool { latest := trackerLatestBundleVerdicts(bundle) if len(latest) == 0 || len(agg.Perspectives) == 0 { @@ -557,6 +610,27 @@ func trackerAssignedCodeWorker(status *StatusPayload, repo string, number int, h return nil } +// trackerPerspectiveFindingLine renders a dissenting perspective as +// " ✗|requires human[: ]" for the review caption, or "" for +// anything else. The tracker-row-strip.js perspectiveLine() mirror rebuilds +// this exact string to avoid repeating the finding; keep the two in step. +func trackerPerspectiveFindingLine(perspective StageTrackerPerspective) string { + var mark string + switch perspective.Verdict { + case "changes_requested", "reject": + mark = "✗" + case "requires_human": + mark = "requires human" + default: + return "" + } + line := perspective.Name + " " + mark + if perspective.Summary != "" { + line += ": " + perspective.Summary + } + return line +} + 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") if agg != nil && !trackerHeadMatches(pr.Repo, pr.Number, pr.HeadSHA, agg.Repo, agg.Number, agg.HeadSHA) { @@ -565,6 +639,7 @@ func stageTrackerReviewActivity(pr github.PullRequest, bundle *evidence.Bundle, 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 @@ -689,6 +764,15 @@ func stageTrackerReviewActivity(pr github.PullRequest, bundle *evidence.Bundle, break } } + if out.State == "changes_requested" || out.State == "human_decision" { + for _, perspective := range out.Perspectives { + if line := trackerPerspectiveFindingLine(perspective); line != "" { + out.Caption += " · " + line + break + } + } + } + return out } diff --git a/src/pkg/dashboard/stage_tracker_activity.test.js b/src/pkg/dashboard/stage_tracker_activity.test.js index d1ecb62285..e648a8c1c5 100644 --- a/src/pkg/dashboard/stage_tracker_activity.test.js +++ b/src/pkg/dashboard/stage_tracker_activity.test.js @@ -13,7 +13,8 @@ function fn(source, name) { assert.ok(match, name); return match[0]; } -const esc = text => String(text).replaceAll('&', '&').replaceAll('<', '<').replaceAll('"', '"'); +// Mirrors production esc(): newlines flatten to spaces. +const esc = text => String(text).replaceAll('&', '&').replaceAll('<', '<').replaceAll('"', '"').replaceAll('\n', ' '); const globals = ` const STAGE_TRACKER_PATH = [0, 10, 20, 30, 50, 80]; const STAGE_TRACKER_TERMINAL = 110; @@ -561,7 +562,7 @@ test('old-head or stale observations cannot fabricate running/completion, but do } else { assert.match(cells.ci, /active ham-current[^]*CI \?\/\? · running { + for (const [kind, state, caption] of [ + ['review', 'approved', 'Review approved'], + ['review', 'changes_requested', 'Review findings · correctness ✗: handle the stale verdict'], + ['review', 'human_decision', 'Review findings · needs owner sign-off'], + ['ci', 'passing', 'CI green'], + ['ci', 'failing', 'CI failing · build red'], + ]) { + for (const observed of [new Date(now - 15 * 60000).toISOString(), undefined, 'invalid', new Date(now + 60000).toISOString()]) { + const a = { ...activity(state, caption), observed_at: observed }; + const item = { kind: 'pr', head: 'head', [kind + '_activity']: a }; + const html = track(item, kind, {}, false, now); + assert.match(html, /data-display-state="known"/); + assert.ok(html.includes(caption), state + ': caption preserved'); + assert.doesNotMatch(html, /activity unknown|last observed|data-motion/); + if (observed === undefined || observed === 'invalid') assert.match(html, /observation time unknown/); + else if (Date.parse(observed) > now) assert.match(html, /observation time in future/); + else assert.match(html, /observed 15m ago/); + item.head = 'new-head'; + const pushed = track(item, kind, {}, false, now); + assert.match(pushed, /data-display-state="unknown"/); + assert.doesNotMatch(pushed, /data-verdict=|correctness|build red/); + } + } +}); + +test('motion needs a fresh observation even when the backend active flag is cached', () => { + for (const [kind, state] of [['review', 'reviewing'], ['review', 'adjudicating'], ['review', 'assigned'], ['review', 'unassigned'], ['review', 'waiting_ci'], ['ci', 'running'], ['ci', 'queued'], ['ci', 'waiting_ci']]) { + for (const observed of [new Date(now - 15 * 60000).toISOString(), undefined, new Date(now + 60000).toISOString()]) { + const item = { kind: 'pr', head: 'head', [kind + '_activity']: { ...activity(state, 'Work observed', true), observed_at: observed } }; + const html = track(item, kind, {}, false, now); + assert.match(html, /data-display-state="unknown"/); + assert.match(html, /activity unknown/); + assert.doesNotMatch(html, /data-motion/); + } + } +}); + +test('review tooltip lists escaped perspective verdicts before current-head provenance', () => { + const summary = ' & check the current head'; + const caption = 'Review findings · correctness ✗: ' + summary; + const item = { kind: 'pr', head: 'head', review_activity: { + ...activity('changes_requested', caption), source: 'verified-review-bundle', + observed_at: new Date(now - 15 * 60000).toISOString(), blocker: summary, + perspectives: [ + { name: 'correctness', verdict: 'changes_requested', summary }, + { name: 'security', verdict: 'approve', summary: '' }, + { name: 'quality', verdict: 'reject', summary: 'explain the edge case' }, + ], + } }; + const html = track(item, 'review', {}, false, now); + const tip = html.match(/role="tooltip">([^]*?)<\/span>/)[1]; + assert.ok(tip.includes(esc(caption) + '
correctness ✗: ' + esc(summary))); + assert.match(tip, /
security ✓
quality ✗: explain the edge case
head head · verified-review-bundle · observed 15m ago/); + assert.doesNotMatch(html, / { + const a = { ...activity('human_decision', 'Review findings · needs owner sign-off'), + observed_at: new Date(now - 15 * 60000).toISOString(), + perspectives: [{ name: 'correctness', verdict: 'requires_human', summary: 'Choose whether to keep the API break' }] }; + const item = { kind: 'pr', head: 'head', review_activity: a }; + for (const state of ['human_decision', 'changes_requested']) { + a.state = state; + const html = track(item, 'review', {}, false, now); + assert.match(html, /correctness requires human: Choose whether to keep the API break
correctness requires human: Choose whether to keep the API break
head/); + assert.doesNotMatch(html, /activity unknown|last observed/); + } + for (const state of ['reviewing', 'unknown']) { + a.state = state; + a.caption = 'Review activity unknown'; + const html = track(item, 'review', {}, false, now); + assert.match(html, /data-display-state="unknown"/); + assert.doesNotMatch(html, /correctness|API break|requires human/); + } +}); + +test('a settled failing CI verdict preserves fresh motion from other running checks', () => { + const item = { kind: 'pr', head: 'head', ci_activity: { + ...activity('failing', 'CI failing · build red · other checks still running', true), + checks_failed: 1, checks_total: 2, checks_failing: ['build'], + } }; + const fresh = track(item, 'ci', {}, false, now); + assert.match(fresh, /data-activity-state="failing"/); + assert.match(fresh, /data-display-state="known"/); + assert.match(fresh, /data-motion="active"/); + const stale = track(item, 'ci', {}, false, now + 15 * 60000); + assert.match(stale, /data-activity-state="failing"/); + assert.match(stale, /data-display-state="known"/); + assert.match(stale, /observed 15m ago/); + assert.doesNotMatch(stale, /data-motion|activity unknown|last observed/); +}); + test('#16615: CI green on the pushed head + re-review owed by the hive → Review lit with the head, CI a green ring', () => { const head = 'd88928e16f21ab6e653e5d06f137926bc0db1c0d'; const fresh = (state, extra = {}) => ({ head, state, caption: state, source: 'github-check-runs', observed_at: new Date(now).toISOString(), ...extra }); diff --git a/src/pkg/dashboard/stage_tracker_activity_test.go b/src/pkg/dashboard/stage_tracker_activity_test.go index 08bdac2323..a18b645800 100644 --- a/src/pkg/dashboard/stage_tracker_activity_test.go +++ b/src/pkg/dashboard/stage_tracker_activity_test.go @@ -1,8 +1,10 @@ package dashboard import ( + "encoding/json" "fmt" "os/exec" + "reflect" "strings" "testing" "time" @@ -513,6 +515,61 @@ func TestStageTrackerActivityReviewPerspectiveCounts(t *testing.T) { } } +func TestStageTrackerReviewPerspectiveDetails(t *testing.T) { + now := time.Date(2026, 11, 4, 3, 0, 0, 0, time.UTC) + observed := now.Add(-15 * time.Minute) + pr := github.PullRequest{Repo: "org/repo", Number: 7, HeadSHA: "head"} + bundle := &evidence.Bundle{Repo: pr.Repo, Number: pr.Number, HeadSHA: pr.HeadSHA, UpdatedAt: observed, + Verdicts: []evidence.Verdict{ + {Perspective: "security", Verdict: "approve", RecordedAt: observed}, + {Perspective: "correctness", Backend: "old", Verdict: "approve", RecordedAt: observed.Add(-time.Minute)}, + {Perspective: "correctness", Backend: "new", Verdict: "changes_requested", RecordedAt: observed, + Findings: []evidence.Finding{{Summary: "do not discard the settled verdict"}}}, + {Perspective: "quality", Verdict: "changes_requested", RecordedAt: observed.Add(-time.Minute), + Findings: []evidence.Finding{{Summary: "superseded finding"}}}, + {Perspective: "quality", Verdict: "approve", RecordedAt: observed}, + {Verdict: "reject", RecordedAt: observed}, + }} + want := []StageTrackerPerspective{ + {Name: "correctness", Verdict: "changes_requested", Summary: "do not discard the settled verdict"}, + {Name: "quality", Verdict: "approve"}, + {Name: "security", Verdict: "approve"}, + } + for _, verdict := range []review.Verdict{"changes_requested", "requires_human"} { + agg := &review.Aggregate{Repo: pr.Repo, Number: pr.Number, HeadSHA: pr.HeadSHA, Verdict: verdict} + got := stageTrackerReviewActivity(pr, bundle, agg, review.DispatchState{}, nil, now) + if !reflect.DeepEqual(got.Perspectives, want) || !strings.Contains(got.Caption, "correctness ✗: do not discard the settled verdict") || got.Active { + t.Fatalf("settled review lost its current-head perspective details: %+v", got) + } + data, err := json.Marshal(got) + if err != nil || !strings.Contains(string(data), `"perspectives":[{"name":"correctness","verdict":"changes_requested","summary":"do not discard the settled verdict"}`) { + t.Fatalf("perspective wire fields missing: %s, %v", data, err) + } + } + bundle.Verdicts[2].Verdict = "requires_human" + agg := &review.Aggregate{Repo: pr.Repo, Number: pr.Number, HeadSHA: pr.HeadSHA, Verdict: "requires_human"} + got := stageTrackerReviewActivity(pr, bundle, agg, review.DispatchState{}, nil, now) + if got.State != "human_decision" || !strings.Contains(got.Caption, "correctness requires human: do not discard the settled verdict") || got.Perspectives[0].Verdict != "requires_human" { + t.Fatalf("human perspective was not explained: %+v", got) + } + bundle.Verdicts[2].Verdict = "changes_requested" + // Approval from another backend must not replace still-current dissent. + bundle.Verdicts = append(bundle.Verdicts, evidence.Verdict{Perspective: "correctness", Backend: "z", Verdict: "approve", RecordedAt: observed.Add(time.Minute)}) + if got := trackerReviewPerspectives(bundle); !reflect.DeepEqual(got, want) { + t.Fatalf("newer approval from another backend hid a finding: %+v", got) + } + for _, other := range []github.PullRequest{ + {Repo: pr.Repo, Number: pr.Number, HeadSHA: "new-head"}, + {Repo: "other/repo", Number: pr.Number, HeadSHA: pr.HeadSHA}, + {Repo: pr.Repo, Number: 8, HeadSHA: pr.HeadSHA}, + } { + got := stageTrackerReviewActivity(other, bundle, nil, review.DispatchState{}, nil, now) + if got.State != "unknown" || len(got.Perspectives) != 0 || strings.Contains(got.Caption, "correctness") { + t.Fatalf("unrelated review details leaked: %+v", got) + } + } +} + func TestStageTrackerActivityCIPartialRingIsRunning(t *testing.T) { now := time.Date(2026, 11, 4, 18, 0, 0, 0, time.UTC) name := func(i int) string { return fmt.Sprintf("check-%02d", i) } diff --git a/src/pkg/dashboard/stage_tracker_motion_test.go b/src/pkg/dashboard/stage_tracker_motion_test.go index 4ad60b083d..4f8c10c132 100644 --- a/src/pkg/dashboard/stage_tracker_motion_test.go +++ b/src/pkg/dashboard/stage_tracker_motion_test.go @@ -217,10 +217,7 @@ assert.strictEqual(stageTrackerAnimateMove(strip, 4, 4, 'wash'), false, 'no colu assert.deepStrictEqual(trace, []); assert.strictEqual(timers.length, 0); ` - cmd := exec.Command(node, "-e", script) - if out, err := cmd.CombinedOutput(); err != nil { - t.Fatalf("node movement sequence fixture failed: %v\n%s", err, out) - } + runMotionScript(t, node, script, "motion_sequence.js", "movement sequence") } func tokensCSS(t *testing.T) string { @@ -371,10 +368,7 @@ assert.strictEqual(stageTrackerMotionEffect('bogus', false), 'wash'); assert.deepStrictEqual(STAGE_TRACKER_MOTIONS.map(m => m.id), ['none', 'puck', 'ripple', 'ghost', 'comet', 'bump', 'wash']); assert.deepStrictEqual(STAGE_TRACKER_MOTIONS.map(m => m.key), ['', 'A', 'B', 'C', 'D', 'E', 'F']); ` - cmd := exec.Command(node, "-e", script) - if out, err := cmd.CombinedOutput(); err != nil { - t.Fatalf("node movement detector fixture failed: %v\n%s", err, out) - } + runMotionScript(t, node, script, "motion_detector.js", "movement detector") } // TestStageTrackerMotionRowStamp runs the real row builder: the moved strip's @@ -496,10 +490,7 @@ assert.deepStrictEqual(ols(stageTrackerRowHtml(next[2], stages, ctx)), [''], 'an assert.deepStrictEqual(ols(stageTrackerRowHtml(next[1], stages, ctx)), ['', ' data-ham-prev-col="4" data-ham-col="6"', ''], 'only the nested PR that moved is stamped (sub-rows sort furthest first)'); assert.deepStrictEqual(ols(stageTrackerRowHtml(next[0], stages, { nowMs: now })), [''], 'no moves in ctx → no stamp'); ` - // Over stdin: the lifted harness is past Linux's -e argument limit. - if out, err := runNodeStdin(node, script); err != nil { - t.Fatalf("node row stamp fixture failed: %v\n%s", err, out) - } + runMotionScript(t, node, script, "motion_row_stamp.js", "row stamp") } // The settings-modal preview is one real tracker row, rebuilt in place on @@ -699,15 +690,22 @@ assert.deepStrictEqual(animated, [[claimed, review, 'wash'], [review, claimed, ' // a re-render after clicks picks up where the preview left off assert.strictEqual(activeShort(stageTrackerMotionSectionHtml('wash', stages)), 'CI + Review'); ` - // The lifted strip exceeds Linux's single-argument limit, so the script - // goes through a file rather than -e. - path := filepath.Join(t.TempDir(), "motion_preview_sample.js") + runMotionScript(t, node, script, "motion_preview_sample.js", "motion preview sample") +} + +// runMotionScript writes script to a temp file and runs it with node. The +// lifted dashboard functions push the concatenated source past Linux's +// single-argument limit (E2BIG), so the script goes through a file rather +// than -e. +func runMotionScript(t *testing.T, node, script, name, label string) { + t.Helper() + path := filepath.Join(t.TempDir(), name) if err := os.WriteFile(path, []byte(script), 0o600); err != nil { t.Fatal(err) } cmd := exec.Command(node, path) if out, err := cmd.CombinedOutput(); err != nil { - t.Fatalf("node motion preview sample fixture failed: %v\n%s", err, out) + t.Fatalf("node %s fixture failed: %v\n%s", label, err, out) } } @@ -906,8 +904,5 @@ assert.notStrictEqual(stageTrackerRowSrcKey(R(1, 4, '2m').html), R(1, 4).html); assert.strictEqual(stageTrackerRowHasMove(R(1, 4, '1m', [2, 4]).html), true); assert.strictEqual(stageTrackerRowHasMove(R(1, 4).html), false); ` - cmd := exec.Command(node, "-e", script) - if out, err := cmd.CombinedOutput(); err != nil { - t.Fatalf("node reconcile fixture failed: %v\n%s", err, out) - } + runMotionScript(t, node, script, "motion_reconcile.js", "reconcile") } 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..14ede90889 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row-strip.js +++ b/src/pkg/dashboard/static-src/js/tracker-row-strip.js @@ -260,7 +260,7 @@ // a finding, pending and decided are words in their colour on the muted // field — only a running track is filled (hivecommons/hive#16540); not // started = the empty chevron with the glyph alone. Freshness gates only - // the pulse. + // the pulse and certainty of motion; settled current-head verdicts persist. function stageTrackerActivityTrackHtml(item, kind, sg, blank, nowMs, opts) { if (blank) return ``; const name = kind === 'ci' ? 'CI' : 'Review'; @@ -273,8 +273,24 @@ 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; + // Only settled verdicts outlive the freshness window; every other + // state (running, queued, unassigned, waiting_ci, ...) implies motion. + const settledState = ['approved', 'changes_requested', 'human_decision', 'passing', 'failing', 'skipped', 'missing'].includes(state); + const fresh = Number.isFinite(observed) && !stale; + const known = matches && state !== 'unknown' && (settledState || fresh); + const active = known && fresh && a.active; + const perspectives = known && kind === 'review' && Array.isArray(a.perspectives) ? a.perspectives : []; + // Mirrors trackerPerspectiveFindingLine in stage_tracker_activity.go: + // the dedupe below is an exact string match, so glyph and separator + // changes must land on both sides. + const perspectiveMark = verdict => verdict === 'approve' ? '✓' : ['changes_requested', 'reject'].includes(verdict) ? '✗' : verdict === 'requires_human' ? 'requires human' : verdict || '?'; + const perspectiveLine = p => String(p.name || 'Perspective') + ' ' + perspectiveMark(p.verdict) + (p.summary ? ': ' + p.summary : ''); + // A repair projection can rewrite the generic caption; keep its first + // finding visible without changing the backend's settled verdict. + if (['changes_requested', 'human_decision'].includes(state)) { + const firstFinding = perspectives.find(p => ['changes_requested', 'reject', 'requires_human'].includes(p.verdict)); + if (firstFinding && !caption.includes(perspectiveLine(firstFinding))) caption += ' · ' + perspectiveLine(firstFinding); + } if (matches && !known && state !== 'unknown') caption = name + ' activity unknown · last observed ' + state + ' · ' + caption; const ownsPR = item.kind === 'pr' || item.via_pr; const text = typeof stageTrackerTrackWord === 'function' ? stageTrackerTrackWord(item, kind, current) : (matches ? a.caption || name + ' ' + state : ''); @@ -298,9 +314,11 @@ 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 age = Math.max(0, Math.floor((clock - observed) / 60000)); + const ago = age < 1 ? 'just now' : age < 60 ? age + 'm ago' : age < 1440 ? Math.floor(age / 60) + 'h ago' : Math.floor(age / 1440) + 'd ago'; + const freshness = !Number.isFinite(observed) ? 'observation time unknown' : observed > clock ? 'observation time in future · ' + new Date(observed).toISOString() : 'observed ' + ago + (stale ? ' · stale' : '') + ' · ' + new Date(observed).toISOString(); const since = matches && a.since && Number.isFinite(Date.parse(a.since)) ? ' · since ' + new Date(a.since).toISOString() : ''; - let blocker = matches && a.blocker ? ' · ' + a.blocker : ''; + let blocker = matches && a.blocker && !caption.includes(a.blocker) ? ' · ' + a.blocker : ''; // A sign-off ask: the tooltip carries the question itself (who should // decide what, and why — "workflow change from a fork") when the // review evidence did not already quote it. @@ -309,7 +327,8 @@ // 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 perspectiveLines = perspectives.map(perspectiveLine); + let tip = [caption + blocker + detail, ...perspectiveLines, 'head ' + (item.head || 'unknown') + ' · ' + source + ' · ' + freshness + since].join('\n'); 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 : ''; @@ -343,7 +362,8 @@ (lead ? ' · hive is waiting on ' + lead.waitingOn + (lead.newHead && sha7 ? ' for new head ' + sha7 : '') : ''); const tipID = 'ham-track-tip-' + [item.repo || '', item.kind || '', item.number || 0, kind].map(x => encodeURIComponent(String(x))).join('-'); const copy = `${evidenceLink}${personIco}`; - return `
  • ${copy}${esc(fullTip)}${decided ? `${decided}` : ''}
  • `; + const tipHtml = fullTip.split('\n').map(esc).join('
    '); + return `
  • ${copy}${tipHtml}${decided ? `${decided}` : ''}
  • `; } // Chevrons for one item. range bounds the columns the item owns (an @@ -558,7 +578,11 @@ 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' : ''); + // A settled verdict on the current head does not go stale: age it + // the way the chevron tooltip does ("observed 15m ago · stale"). + const age = Math.max(0, Math.floor((clock - observed) / 60000)); + const ago = age < 1 ? 'just now' : age < 60 ? age + 'm ago' : age < 1440 ? Math.floor(age / 60) + 'h ago' : Math.floor(age / 1440) + 'd ago'; + return (a.caption || name + ' unknown') + (!Number.isFinite(observed) ? ' · observation time unknown' : observed > clock ? ' · observation time in future' : !fresh ? ' · observed ' + ago + ' · stale' : ''); }).join(' · ') : ''; return `

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

    `; } diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index a09cf5b522..1694221b4e 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -18173,7 +18173,7 @@

    Where to get help

    // a finding, pending and decided are words in their colour on the muted // field — only a running track is filled (hivecommons/hive#16540); not // started = the empty chevron with the glyph alone. Freshness gates only - // the pulse. + // the pulse and certainty of motion; settled current-head verdicts persist. function stageTrackerActivityTrackHtml(item, kind, sg, blank, nowMs, opts) { if (blank) return ``; const name = kind === 'ci' ? 'CI' : 'Review'; @@ -18186,8 +18186,24 @@

    Where to get help

    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; + // Only settled verdicts outlive the freshness window; every other + // state (running, queued, unassigned, waiting_ci, ...) implies motion. + const settledState = ['approved', 'changes_requested', 'human_decision', 'passing', 'failing', 'skipped', 'missing'].includes(state); + const fresh = Number.isFinite(observed) && !stale; + const known = matches && state !== 'unknown' && (settledState || fresh); + const active = known && fresh && a.active; + const perspectives = known && kind === 'review' && Array.isArray(a.perspectives) ? a.perspectives : []; + // Mirrors trackerPerspectiveFindingLine in stage_tracker_activity.go: + // the dedupe below is an exact string match, so glyph and separator + // changes must land on both sides. + const perspectiveMark = verdict => verdict === 'approve' ? '✓' : ['changes_requested', 'reject'].includes(verdict) ? '✗' : verdict === 'requires_human' ? 'requires human' : verdict || '?'; + const perspectiveLine = p => String(p.name || 'Perspective') + ' ' + perspectiveMark(p.verdict) + (p.summary ? ': ' + p.summary : ''); + // A repair projection can rewrite the generic caption; keep its first + // finding visible without changing the backend's settled verdict. + if (['changes_requested', 'human_decision'].includes(state)) { + const firstFinding = perspectives.find(p => ['changes_requested', 'reject', 'requires_human'].includes(p.verdict)); + if (firstFinding && !caption.includes(perspectiveLine(firstFinding))) caption += ' · ' + perspectiveLine(firstFinding); + } if (matches && !known && state !== 'unknown') caption = name + ' activity unknown · last observed ' + state + ' · ' + caption; const ownsPR = item.kind === 'pr' || item.via_pr; const text = typeof stageTrackerTrackWord === 'function' ? stageTrackerTrackWord(item, kind, current) : (matches ? a.caption || name + ' ' + state : ''); @@ -18211,9 +18227,11 @@

    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 age = Math.max(0, Math.floor((clock - observed) / 60000)); + const ago = age < 1 ? 'just now' : age < 60 ? age + 'm ago' : age < 1440 ? Math.floor(age / 60) + 'h ago' : Math.floor(age / 1440) + 'd ago'; + const freshness = !Number.isFinite(observed) ? 'observation time unknown' : observed > clock ? 'observation time in future · ' + new Date(observed).toISOString() : 'observed ' + ago + (stale ? ' · stale' : '') + ' · ' + new Date(observed).toISOString(); const since = matches && a.since && Number.isFinite(Date.parse(a.since)) ? ' · since ' + new Date(a.since).toISOString() : ''; - let blocker = matches && a.blocker ? ' · ' + a.blocker : ''; + let blocker = matches && a.blocker && !caption.includes(a.blocker) ? ' · ' + a.blocker : ''; // A sign-off ask: the tooltip carries the question itself (who should // decide what, and why — "workflow change from a fork") when the // review evidence did not already quote it. @@ -18222,7 +18240,8 @@

    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 perspectiveLines = perspectives.map(perspectiveLine); + let tip = [caption + blocker + detail, ...perspectiveLines, 'head ' + (item.head || 'unknown') + ' · ' + source + ' · ' + freshness + since].join('\n'); 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 : ''; @@ -18256,7 +18275,8 @@

    Where to get help

    (lead ? ' · hive is waiting on ' + lead.waitingOn + (lead.newHead && sha7 ? ' for new head ' + sha7 : '') : ''); const tipID = 'ham-track-tip-' + [item.repo || '', item.kind || '', item.number || 0, kind].map(x => encodeURIComponent(String(x))).join('-'); const copy = `${evidenceLink}${personIco}`; - return `
  • ${copy}${esc(fullTip)}${decided ? `${decided}` : ''}
  • `; + const tipHtml = fullTip.split('\n').map(esc).join('
    '); + return `
  • ${copy}${tipHtml}${decided ? `${decided}` : ''}
  • `; } // Chevrons for one item. range bounds the columns the item owns (an @@ -18471,7 +18491,11 @@

    Where to get help

    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' : ''); + // A settled verdict on the current head does not go stale: age it + // the way the chevron tooltip does ("observed 15m ago · stale"). + const age = Math.max(0, Math.floor((clock - observed) / 60000)); + const ago = age < 1 ? 'just now' : age < 60 ? age + 'm ago' : age < 1440 ? Math.floor(age / 60) + 'h ago' : Math.floor(age / 1440) + 'd ago'; + return (a.caption || name + ' unknown') + (!Number.isFinite(observed) ? ' · observation time unknown' : observed > clock ? ' · observation time in future' : !fresh ? ' · observed ' + ago + ' · stale' : ''); }).join(' · ') : ''; return `

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

    `; }