Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-15580-tracker-queue-slot-suffix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity tracker: the lit chevron no longer says "Merge queued · 1st" for a PR whose CI is still running or whose review verdict is pending ([#15580](https://github.com/hivecommons/hive/issues/15580)). The headline is stage-first ("CI / Review"), the merge-train slot becomes a trailing suffix ("· queued 1st once ready") until the PR reaches merge-ready, the gate reason reads "merges first once it is ready", and the server marks such train members `merge_train.provisional: true`.
15 changes: 15 additions & 0 deletions src/pkg/dashboard/stage_tracker_merge_gate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ func stageTrackerTrainQueueJS(t *testing.T, html string) string {
jsFunc(t, html, "stageTrackerOrdinal"),
jsFunc(t, html, "stageTrackerShortLeft"),
jsFunc(t, html, "stageTrackerTrainPlace"),
stageTrackerTrainProvisionalJS(t, html),
jsConstLine(t, html, "STAGE_TRACKER_TRAIN_STALLED_LEAD"),
jsConstLine(t, html, "STAGE_TRACKER_TRAIN_HEAD_STALL_WORD"),
jsFunc(t, html, "stageTrackerTrainStallWhy"),
Expand All @@ -335,6 +336,20 @@ func stageTrackerTrainQueueJS(t *testing.T, html string) string {
}, "\n")
}

// stageTrackerTrainProvisionalJS lifts the provisional-slot words: a train
// member whose own stage is short of the merge gate reads its blocker
// first and its slot as a suffix.
func stageTrackerTrainProvisionalJS(t *testing.T, html string) string {
t.Helper()
return strings.Join([]string{
jsConstLine(t, html, "STAGE_TRACKER_MERGE_READY"),
jsConstLine(t, html, "STAGE_TRACKER_PROVISIONAL_STAGE_WORD"),
jsFunc(t, html, "stageTrackerTrainProvisional"),
jsFunc(t, html, "stageTrackerTrainProvisionalHeadline"),
jsFunc(t, html, "stageTrackerTrainProvisionalSuffix"),
}, "\n")
}

// stageTrackerSoakClockJS lifts the soak-clock helpers the gate pill reads.
func stageTrackerSoakClockJS(t *testing.T, html string) string {
t.Helper()
Expand Down
22 changes: 21 additions & 1 deletion src/pkg/dashboard/stage_tracker_merge_train.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ type StageTrackerMergeTrain struct {
Late bool `json:"late,omitempty"`
Stalled bool `json:"stalled,omitempty"`
StalledS int64 `json:"stalled_s,omitempty"`
// Provisional is true while this member's own stage is still short of
// the merge gate (050 review pending / CI, 060, 070…): the planner has
// ordered it, but the slot is a forecast, not a state. The SPA keeps
// the stage's blocker as the headline and words the slot as a suffix
// ("CI / Review · queued 1st once ready") so the chevron never
// contradicts the caption (hive's own #15577 read "Merge queued · 1st"
// over "check build-and-test still running").
Provisional bool `json:"provisional,omitempty"`
}

// stageTrackerMergeTrainProvisional reports whether a train member at
// stage is holding its queue slot ahead of being merge-ready: anything
// below 080 awaiting merge admission.
func stageTrackerMergeTrainProvisional(stage int) bool {
return stage > 0 && stage < stagelabels.AwaitingMergeAdmission.Number()
}

// Head states a merge train reports on its members (HeadState). The SPA
Expand Down Expand Up @@ -237,7 +252,11 @@ func stageTrackerMergeTrainPostPass(items []StageTrackerItem, opts mergeTrainQue
front.MergeGate.State = MergeGateStateTrainFront
}
if front.MergeGate.Reason == "" {
front.MergeGate.Reason = "1st in the merge queue; merges next (1st of " + strconv.Itoa(sample.Size) + ", overlapping files: " + strings.Join(sample.OverlapFiles, ", ") + ")"
next := "merges next"
if stageTrackerMergeTrainProvisional(front.Stage) {
next = "merges first once it is ready"
}
front.MergeGate.Reason = "1st in the merge queue; " + next + " (1st of " + strconv.Itoa(sample.Size) + ", overlapping files: " + strings.Join(sample.OverlapFiles, ", ") + ")"
}
if front.Stage == stagelabels.AwaitingMergeAdmission.Number() {
front.Caption = stageTrackerMergeTrainFrontCaption(sample)
Expand All @@ -259,6 +278,7 @@ func stageTrackerMergeTrainPostPass(items []StageTrackerItem, opts mergeTrainQue
}
items[i].MergeTrain.Ahead = ahead
items[i].MergeTrain.Members = append([]int(nil), members...)
items[i].MergeTrain.Provisional = stageTrackerMergeTrainProvisional(items[i].Stage)
}
var head *StageTrackerItem
if frontIdx >= 0 {
Expand Down
124 changes: 124 additions & 0 deletions src/pkg/dashboard/stage_tracker_merge_train_provisional_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package dashboard

import (
"strings"
"testing"
"time"

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

// A train's front still at 050 (CI running, no verdict) — hive's own
// #15577 — carries its queue slot as provisional, its gate reason says
// "once it is ready", and the siblings parked behind it at 080 do not.
func TestStageTrackerMergeTrainProvisionalFront(t *testing.T) {
now := time.Date(2026, 10, 30, 0, 0, 0, 0, time.UTC)
s, store := stageTrackerFixture(t, now)
overlap := []string{"tracker-words.js"}
store.Observe(stagelabels.Key("acme/console", 15577), stagelabels.ReviewPending, "required-check-pending:build-and-test")
store.Observe(stagelabels.Key("acme/console", 15578), stagelabels.AwaitingMergeAdmission,
prstage.MergeTrain{State: prstage.MergeTrainStateQueuedBehind, Front: 15577, Position: 2, Size: 2, OverlapFiles: overlap}.Reason())
s.statusMu.Lock()
for n, stage := range map[int]string{15577: "stage/050-review-pending", 15578: "stage/080-awaiting-merge-admission"} {
s.status.Repos[0].OpenPrs = append(s.status.Repos[0].OpenPrs,
FrontendPR{PullRequest: github.PullRequest{Number: n, Title: "Tracker words", Author: "someone", BaseRef: "v5", Labels: []string{stage}}})
}
s.statusMu.Unlock()
resp := s.buildStageTracker(s.status, store, now)
var front, rider *StageTrackerItem
for i := range resp.Items {
switch resp.Items[i].Number {
case 15577:
front = &resp.Items[i]
case 15578:
rider = &resp.Items[i]
}
}
if front == nil || front.MergeTrain == nil || rider == nil || rider.MergeTrain == nil {
t.Fatalf("expected both rows to carry merge_train: front=%+v rider=%+v", front, rider)
}
if !front.MergeTrain.Provisional {
t.Errorf("front at 050 should carry merge_train.provisional: %+v", front.MergeTrain)
}
if front.MergeGate == nil || !strings.Contains(front.MergeGate.Reason, "once it is ready") || strings.Contains(front.MergeGate.Reason, "merges next") {
t.Errorf("provisional front's gate reason should say once it is ready, not merges next: %+v", front.MergeGate)
}
if rider.MergeTrain.Provisional {
t.Errorf("rider at 080 is merge-ready; its slot is not provisional: %+v", rider.MergeTrain)
}
if !stageTrackerMergeTrainProvisional(stagelabels.Reviewed.Number()) || stageTrackerMergeTrainProvisional(stagelabels.AwaitingMergeAdmission.Number()) || stageTrackerMergeTrainProvisional(0) {
t.Errorf("provisional is every stage between 0 and 080, exclusive")
}
}

// Ratchet (hive's own #15577: the chevron read "Merge queued · 1st" while
// the caption said "check build-and-test still running"): for every
// stage × queue state the chevron headline — the gate chip's word, else
// the train word — names the same blocker class as the stage: a row
// short of the merge gate reads its stage's blocker first with the slot
// as a trailing suffix; a merge-ready row reads its place in the queue.
func TestStageTrackerQueueSlotHeadlineAgreesWithStage(t *testing.T) {
html := indexHTML(t)
runStageTrackerRowActionsScript(t, "function esc(s) { return String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\"/g, '&quot;'); }\nconst assert = require('assert');\n"+
jsConstLine(t, html, "STAGE_TRACKER_TERMINAL")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_PRE_MERGE_SOAK")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_ACTIVE_WORD")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_MERGE_GATE_WORD")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_TRAIN_ICON_PATH")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_TRAIN_ICON_TITLE")+"\n"+
jsFunc(t, html, "stageTrackerTrainIconHtml")+"\n"+
jsConstBlock(t, html, "STAGE_TRACKER_GATE_REASON_WORDS")+"\n"+
jsConstBlock(t, html, "STAGE_TRACKER_ICONS")+"\n"+
jsFunc(t, html, "stageTrackerIcon")+"\n"+
jsFunc(t, html, "stageTrackerAgoText")+"\n"+
jsFunc(t, html, "stageTrackerSoakLeft")+"\n"+
jsFunc(t, html, "stageTrackerMergeGateStateOf")+"\n"+
jsFunc(t, html, "stageTrackerGateReasonText")+"\n"+
stageTrackerMergeGateInfoJS(t, html)+"\n"+
jsFunc(t, html, "stageTrackerMergeGateWordHtml")+"\n"+`
const now = Date.parse('2026-10-30T00:01:00Z');
const stages = [10, 20, 30, 50, 60, 70, 71, 72, 74, 80, 85, 90, 95, 100];
const caption = 'Review swarm requested; waiting for a verdict on the current head — check build-and-test still running';
// The blocker class a headline names: 'queue' when it leads with the merge
// queue, 'stage' otherwise. A stage short of the gate must read 'stage'.
const classOf = s => /^Merge queue/.test(String(s || '')) ? 'queue' : 'stage';
for (const stage of stages) for (const state of ['front', 'queued-behind']) for (const flag of [true, false, undefined]) {
const pos = state === 'front' ? 1 : 2;
const mt = { id: 'v5#15577', state, front: 15577, head_number: 15577, position: pos, size: 2, length: 2, head_state: stage < 80 ? 'ci' : 'ready', head_reason: stage < 80 ? 'waiting for CI' : '' };
if (flag !== undefined) mt.provisional = flag;
const item = { repo: 'hivecommons/hive', number: 15577, kind: 'pr', title: 't', stage, modifiers: [], reason: stage === 50 ? 'required-check-pending:build-and-test' : '', caption, merge_train: mt, merge_gate: { state, reason: '1st in the merge queue', last_sweep_at: '2026-10-30T00:00:30Z' } };
const label = 'stage ' + stage + ' / ' + state + ' / provisional=' + flag;
// The server's flag wins; without it the stage decides.
const provisional = flag === undefined ? stage < 80 : flag;
const want = provisional ? 'stage' : 'queue';
const word = stageTrackerTrainWord(item);
assert.strictEqual(classOf(word), want, label + ' train word: ' + JSON.stringify(word));
const info = stageTrackerMergeGateInfo(item, now);
assert.ok(info && info.word, label + ' chip: ' + JSON.stringify(info));
assert.strictEqual(classOf(info.word), want, label + ' chip word: ' + JSON.stringify(info.word));
const chip = stageTrackerMergeGateWordHtml(item, now).replace(/<[^>]+>/g, '');
assert.strictEqual(classOf(chip), want, label + ' chip html: ' + JSON.stringify(chip));
if (provisional) {
// Blocker first, slot as a suffix — never the slot alone.
assert.ok(/queued (1st|2nd) once ready$/.test(word), label + ' suffix: ' + JSON.stringify(word));
assert.strictEqual(info.detail, 'queued ' + (pos === 1 ? '1st' : '2nd') + ' once ready', label + ' detail');
assert.ok(!/merges next/.test(info.tip), label + ' hover promises merges next: ' + info.tip);
assert.ok(info.until === 0, label + ' no ETA countdown ahead of readiness');
} else {
assert.ok(/^Merge queued · (1st|2nd)$/.test(word), label + ' place word: ' + JSON.stringify(word));
}
}
// hive's own #15577 exactly: 050, front, CI running — the chevron leads with CI / Review.
const own = { repo: 'hivecommons/hive', number: 15577, kind: 'pr', stage: 50, modifiers: [], reason: 'required-check-pending:build-and-test', caption,
merge_train: { id: 'v5#15577', state: 'front', front: 15577, position: 1, size: 2, head_number: 15577, head_state: 'ci', head_reason: 'waiting for CI', provisional: true },
merge_gate: { state: 'front', reason: '1st in the merge queue; merges first once it is ready (1st of 2, overlapping files: tracker-words.js)' } };
assert.strictEqual(stageTrackerTrainWord(own), 'CI / Review · queued 1st once ready');
const ownInfo = stageTrackerMergeGateInfo(own, now);
assert.strictEqual(ownInfo.word, 'CI / Review');
assert.strictEqual(ownInfo.detail, 'queued 1st once ready');
assert.ok(/CI in progress/.test(ownInfo.tip), ownInfo.tip);
assert.ok(/merges first once it is ready/.test(ownInfo.tip), ownInfo.tip);
`)
}
8 changes: 6 additions & 2 deletions src/pkg/dashboard/stage_tracker_merge_train_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ func TestStageTrackerMergeTrainSPA(t *testing.T) {
jsFunc(t, html, "stageTrackerOrdinal"),
jsFunc(t, html, "stageTrackerShortLeft"),
jsFunc(t, html, "stageTrackerTrainPlace"),
stageTrackerTrainProvisionalJS(t, html),
jsConstLine(t, html, "STAGE_TRACKER_TRAIN_STALLED_LEAD"),
jsConstLine(t, html, "STAGE_TRACKER_TRAIN_HEAD_STALL_WORD"),
jsFunc(t, html, "stageTrackerTrainStallWhy"),
Expand Down Expand Up @@ -332,10 +333,13 @@ for (const [pos, w] of [[11, '11th'], [12, '12th'], [13, '13th'], [21, '21st'],
// whatever stage the lane holds the head at (hive #15400 at 050 lit CI / Review).
for (const st of ['front', 'queued-behind', 'rebasing', 'rebase-exhausted']) for (const stage of [50, 60, 70, 74, 80, 95]) assert.strictEqual(stageTrackerAnchor(stage, stages, 'pr', mk(2, stage, { state: st, position: 1 })), 80, st + ' at ' + stage);
assert.strictEqual(stageTrackerAnchor(50, stages, 'pr', other), 50, 'no train: stage rules as before');
// The 1st-in-train head at 050 lights its word in the Merge queue column.
// The 1st-in-train head at 050 lights the Merge queue column, but its
// word leads with the stage's blocker — the slot is provisional until
// CI and the verdict are in (hive #15577 read "Merge queued · 1st" over
// a caption saying build-and-test was still running).
const headAt50 = mk(15400, 50, { state: 'front', position: 1 });
assert.strictEqual(lit(headAt50).number, 80);
assert.strictEqual(lit(headAt50).short, 'Merge queued · 1st');
assert.strictEqual(lit(headAt50).short, 'CI / Review · queued 1st once ready');
const grouped = stageTrackerTrainContiguous(sorted).map(it => it.number);
assert.deepStrictEqual(grouped, [15074, 15085, 15087, 15097, 15100, 1]);
// Header line before the run, once; rail classes on members, last closes it.
Expand Down
48 changes: 48 additions & 0 deletions src/pkg/dashboard/static-src/js/tracker-words.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,43 @@
const mt = item && item.merge_train;
return mt && typeof mt === 'object' && mt.state ? mt : null;
}
// The first merge-ready stage (080 awaiting merge admission). A train
// member below it holds a provisional slot: the planner has ordered
// it, but CI / the review verdict / the fixer still stand in front.
const STAGE_TRACKER_MERGE_READY = 80;
// The blocker headline for a provisional train member, by stage —
// the same words the stage column shows (stageTrackerShort in Go), so
// the chevron and the caption name one blocker (hive's own #15577 read
// "Merge queued · 1st" while its caption said "check build-and-test
// still running"). Keys below STAGE_TRACKER_MERGE_READY only.
const STAGE_TRACKER_PROVISIONAL_STAGE_WORD = { 10: 'Actionable', 20: 'Claimed', 30: 'PR in progress', 40: 'Covered by PR', 45: 'Needs human decision', 50: 'CI / Review', 60: 'Review passed', 70: 'Fixing', 71: 'Needs author', 72: 'Returned to contributor', 74: 'Adopted by hive' };
// Pure: true when the row's queue slot is a forecast — the server says
// so (merge_train.provisional), or, from an older server, the row's
// own stage is short of the merge gate.
function stageTrackerTrainProvisional(item) {
const mt = stageTrackerTrain(item);
if (!mt) return false;
if (mt.provisional === true) return true;
if (mt.provisional === false) return false;
const stage = Number(item.stage) || 0;
return stage > 0 && stage < STAGE_TRACKER_MERGE_READY;
}
// Pure: the provisional member's headline — its stage's blocker word.
function stageTrackerTrainProvisionalHeadline(item) {
const stage = Number(item && item.stage) || 0;
// Guarded: test harnesses lift this function without the active-word table.
const active = typeof STAGE_TRACKER_ACTIVE_WORD !== 'undefined' ? STAGE_TRACKER_ACTIVE_WORD[stage] : '';
return STAGE_TRACKER_PROVISIONAL_STAGE_WORD[stage] || active || STAGE_TRACKER_PROVISIONAL_STAGE_WORD[50];
}
// Pure: the trailing slot words for a provisional member — "queued 1st
// once ready" — never the headline.
function stageTrackerTrainProvisionalSuffix(item) {
const mt = stageTrackerTrain(item);
if (!mt) return '';
const p = stageTrackerTrainPlace(mt);
const pos = mt.state === STAGE_TRACKER_TRAIN_STATE_FRONT ? 1 : (p.pos || 2);
return 'queued ' + stageTrackerOrdinal(pos) + ' once ready';
}
function stageTrackerOrdinal(n) {
n = Number(n) || 0;
const r100 = n % 100, r10 = n % 10;
Expand Down Expand Up @@ -237,6 +274,8 @@
function stageTrackerTrainWord(item) {
const mt = stageTrackerTrain(item);
if (!mt) return '';
// A slot held ahead of readiness reads blocker first, slot second.
if ((mt.state === STAGE_TRACKER_TRAIN_STATE_FRONT || mt.state === STAGE_TRACKER_TRAIN_STATE_QUEUED) && stageTrackerTrainProvisional(item)) return stageTrackerTrainProvisionalHeadline(item) + ' · ' + stageTrackerTrainProvisionalSuffix(item);
const stalled = stageTrackerTrainStalledWord(mt);
if (stalled && (mt.state === STAGE_TRACKER_TRAIN_STATE_FRONT || mt.state === STAGE_TRACKER_TRAIN_STATE_QUEUED)) return stalled;
const p = stageTrackerTrainPlace(mt);
Expand Down Expand Up @@ -821,6 +860,15 @@
// The sweep is the spinning ⬡ and a "Checking now…" tooltip line.
const trainSrc = stageTrackerTrain(src) ? src : (stageTrackerTrain(item) ? item : null);
const mt = trainSrc ? stageTrackerTrain(trainSrc) : null;
// A provisional slot (the member's own stage is short of the gate):
// the chip's headline is the stage's blocker, the slot a muted
// trailing detail, and the hover leads with what blocks it.
if (mt && (state === STAGE_TRACKER_TRAIN_STATE_FRONT || state === STAGE_TRACKER_TRAIN_STATE_QUEUED) && stageTrackerTrainProvisional(trainSrc)) {
const blocker = stageTrackerReviewPassedDetail(laneReason || mg.reason) || String((trainSrc && trainSrc.caption) || '').split(/ — /)[0].trim();
const headline = stageTrackerTrainProvisionalHeadline(trainSrc);
const tip = headline + (blocker ? ' — ' + blocker : '') + '. ' + stageTrackerTrainQueueTip(mt, nowMs).replace(/ · merges next/, ' · merges first once it is ready') + (mg.sweep_running ? ' Checking now…' : '') + lastSeen;
return { state, word: headline, detail: stageTrackerTrainProvisionalSuffix(trainSrc), tip, cue: 'waiting', until: 0, train: mt, stalled: false, provisional: true };
}
if (mt && (state === STAGE_TRACKER_TRAIN_STATE_FRONT || state === STAGE_TRACKER_TRAIN_STATE_QUEUED || state === STAGE_TRACKER_TRAIN_STATE_REBASING || state === STAGE_TRACKER_TRAIN_STATE_EXHAUSTED)) {
const trainWord = stageTrackerTrainWord(trainSrc) || STAGE_TRACKER_TRAIN_STATE_WORD[STAGE_TRACKER_TRAIN_STATE_QUEUED];
const queued = state === STAGE_TRACKER_TRAIN_STATE_FRONT || state === STAGE_TRACKER_TRAIN_STATE_QUEUED;
Expand Down
Loading
Loading