diff --git a/changelog.d/added-15784-stage-tracker-push-progress.md b/changelog.d/added-15784-stage-tracker-push-progress.md new file mode 100644 index 0000000000..6ba8a2e21b --- /dev/null +++ b/changelog.d/added-15784-stage-tracker-push-progress.md @@ -0,0 +1 @@ +- The activity monitor shows push progress on every PR row in the CI / Review column ([#15784](https://github.com/hivecommons/hive/issues/15784)): the stage record keeps `waiting_push_since` / `last_push_at` / `last_push_sha`, booked from the `pull_request` synchronize / `push` webhook re-read with the enumerate head change as fallback. A 071 / 072 pill ends with the wait's age ("waiting on 👤 @user to push · 38m", muted-amber past `dashboard.stage_tracker.waiting_push_stale_h`, default 4); once a push lands the chevron returns to the column's own word (the 👤 clears — the ball is back with the hive) and the gray pill names the push ("@user pushed abc1234 · 2m" linking to the commit, "adopted from @x's #N · pushed 2m ago" on adopted rows, "pushed abc1234 · 2m" on plain CI / Review rows) while CI / the re-review for that head still run; the hive line reads "push seen 2m ago → CI/re-review queued". diff --git a/src/docs/operator-reference.md b/src/docs/operator-reference.md index c5a4c1d3f6..454868de16 100644 --- a/src/docs/operator-reference.md +++ b/src/docs/operator-reference.md @@ -856,7 +856,20 @@ GitHub calls (hivecommons/hive#15280). Push detection needs the head saved by a nudge: a never-nudged 071 row has only a stage-entry time, so a push cannot produce `· re-review pending` and may appear as `· acknowledged` from PR activity instead. The stage engine still routes the new head to -050 on its next sweep (hivecommons/hive#15286). When the +050 on its next sweep (hivecommons/hive#15286). Every PR row in the CI / +Review column also carries push progress (hivecommons/hive#15784): the +stage record keeps `waiting_push_since`, `last_push_at` and `last_push_sha`, +booked from the `pull_request` synchronize / `push` webhook re-read and, as +a fallback, from the head change the next enumerate sees. While a 071 / 072 +row waits the pill ends with the wait's age (`waiting on 👤 @user to push · +38m`), muted-amber once past `dashboard.stage_tracker.waiting_push_stale_h` +(default `4`; `0` keeps the default, negative disables the tone). Once a +push lands and CI / the re-review for that head still run, the chevron +returns to the column's own word — stage only, the 👤 clears because the +ball is back with the hive — and the gray pill names the push: `@user +pushed abc1234 · 2m` (links to the commit), `adopted from @x's #N · pushed +2m ago` on an adopted row, `pushed abc1234 · 2m` on a plain CI / Review +row; the hive line reads `push seen 2m ago → CI/re-review queued`. When the PR allows maintainer edits (`adoption.in_place`, default on) the hive adopts it in place: `stage/074-adopted-by-hive`, the PR's own branch filed in `ci-failing.json` as the hive's (`adopted: true`) for the scanner's red-PR @@ -2002,6 +2015,7 @@ dashboard: webhook_refresh_debounce_ms: 2000 webhook_refresh_replay_window_s: 1800 # re-apply re-reads to snapshots published meanwhile closed_sweep_interval_s: 300 # list items closed since the last look and evict rows still shown; -1 disables + waiting_push_stale_h: 4 # hours without a push on a CI / Review row before the pill's age turns muted-amber ``` ## `HIVE_GITHUB_TOKEN` permissions diff --git a/src/docs/webhooks.md b/src/docs/webhooks.md index 965747ffe6..fe4a46d49b 100644 --- a/src/docs/webhooks.md +++ b/src/docs/webhooks.md @@ -121,6 +121,7 @@ These are the acceptance criteria of #13373 and the tests that hold them. | `dashboard.stage_tracker.webhook_refresh_debounce_ms` | `2000` | debounce of the single-item re-read a delivery queues | | `dashboard.stage_tracker.webhook_refresh_replay_window_s` | `1800` | how long a re-read is remembered and re-applied to every status snapshot the governor publishes, so a cycle that enumerated before the close cannot re-list the item | | `dashboard.stage_tracker.closed_sweep_interval_s` | `300` | how often (driven by status publishes) each repo's items closed since the last look are listed (one call per repo) and rows still shown are evicted; negative disables | +| `dashboard.stage_tracker.waiting_push_stale_h` | `4` | hours a CI / Review row may go without a push (booked from the `pull_request` synchronize / `push` re-read, enumerate as fallback) before its pill's age takes the muted-amber tone; negative disables | | health window | `2 × governor.eval_interval_s` (10 min at the defaults) | how recent the newest verified delivery must be for webhooks to count as healthy | | recovery hysteresis | `WebhookRecoveryHealthyWindows` = `2` | consecutive healthy windows required before the cadence returns to webhook mode after a degradation | diff --git a/src/pkg/config/config.go b/src/pkg/config/config.go index dde3ac632e..8bf32c7127 100644 --- a/src/pkg/config/config.go +++ b/src/pkg/config/config.go @@ -4961,6 +4961,28 @@ type DashboardStageTrackerConfig struct { // refused. Each status publish starts a sweep when one is due. 0 // means the default (300); a negative value disables it. ClosedSweepIntervalS int `yaml:"closed_sweep_interval_s,omitempty" json:"closed_sweep_interval_s,omitempty"` + // WaitingPushStaleH is how many hours a PR row in the CI / Review + // column may wait for its author to push before the waiting-on pill's + // age takes the muted-stale tone (hivecommons/hive#15784). 0 means the + // default (4); a negative value never marks the wait stale. + WaitingPushStaleH int `yaml:"waiting_push_stale_h,omitempty" json:"waiting_push_stale_h,omitempty"` +} + +// defaultStageTrackerWaitingPushStale is the default +// dashboard.stage_tracker.waiting_push_stale_h. +const defaultStageTrackerWaitingPushStale = 4 * time.Hour + +// StageTrackerWaitingPushStale is the effective +// dashboard.stage_tracker.waiting_push_stale_h as a duration; 0 means a +// wait is never marked stale. +func (c *Config) StageTrackerWaitingPushStale() time.Duration { + if c == nil || c.Dashboard.StageTracker.WaitingPushStaleH == 0 { + return defaultStageTrackerWaitingPushStale + } + if c.Dashboard.StageTracker.WaitingPushStaleH < 0 { + return 0 + } + return time.Duration(c.Dashboard.StageTracker.WaitingPushStaleH) * time.Hour } // defaultStageTrackerClosedSweepInterval is the default diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index abe2885f0b..5ce05339a6 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -511,6 +511,11 @@ type StageTrackerItem struct { // in_progress or pushed, with the evidence (hivecommons/hive#15280, // stage_tracker_rework.go). Rework *StageTrackerRework `json:"rework,omitempty"` + // Push is, on a PR row in the CI / Review column, the push the hive + // waits on or the one that just landed, so the gray pill can say + // "waiting on @zoe to push · 38m" or "@zoe pushed abc1234 · 2m" + // (hivecommons/hive#15784, stage_tracker_push.go). + Push *StageTrackerPush `json:"push,omitempty"` // Takeover is, on a 072 / 071 clanker PR, the operator's Adopt now / // Reroute offer and any pending reroute or forced adoption // (hivecommons/hive#15038, stage_tracker_takeover.go). @@ -708,6 +713,8 @@ type StageTrackerLinkedPR struct { Presence *StageTrackerPresence `json:"presence,omitempty"` // Rework mirrors the nested PR's own row field (hivecommons/hive#15280). Rework *StageTrackerRework `json:"rework,omitempty"` + // Push mirrors the nested PR's own row field (hivecommons/hive#15784). + Push *StageTrackerPush `json:"push,omitempty"` // Takeover mirrors the nested PR's own row field (hivecommons/hive#15038). Takeover *StageTrackerTakeover `json:"takeover,omitempty"` // Supersedes mirrors the nested PR's own row field. diff --git a/src/pkg/dashboard/stage_tracker_actor.go b/src/pkg/dashboard/stage_tracker_actor.go index 5b757000d9..ae19674c58 100644 --- a/src/pkg/dashboard/stage_tracker_actor.go +++ b/src/pkg/dashboard/stage_tracker_actor.go @@ -183,6 +183,12 @@ func stageTrackerStageActor(it StageTrackerItem, workers map[string]stageTracker case stagelabels.Reviewed: return set(StageActorHive, "", "approved; a required check is still pending") case stagelabels.Fixing, stagelabels.NeedsAuthor, stagelabels.ReturnedToContributor: + // The author's push landed and CI / the re-review for it still + // run: the ball is back with the hive, the person glyph goes + // (hivecommons/hive#15784). + if it.Push != nil && it.Push.State == pushStatePushed { + return set(StageActorHive, "", stageTrackerPushWhy(it.Push)) + } return stageTrackerAuthorStageActor(a, it, stage, workers, now) case stagelabels.AdoptedByHive: if w, ok := stageTrackerWorkerOn(workers, it.Repo, it.Number); ok { diff --git a/src/pkg/dashboard/stage_tracker_build.go b/src/pkg/dashboard/stage_tracker_build.go index f1dd6abfa4..e35072aa5c 100644 --- a/src/pkg/dashboard/stage_tracker_build.go +++ b/src/pkg/dashboard/stage_tracker_build.go @@ -91,6 +91,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto isClankerOwner := stageTrackerIsClankerOwner() adoptionClock := s.stageTrackerAdoptionClock() rerouteCandidates := s.stageTrackerRerouteCandidates() + pushStaleAfter := s.stageTrackerWaitingPushStale() finish := func(it *StageTrackerItem, labels []string, stage stagelabels.Stage, rec stagelabels.Record, hasRec bool, draft bool) { // "Needs human decision" is read from the item's current labels, not // a store record that outlived them: once the park label is gone @@ -191,7 +192,24 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto it.Caption = stageTrackerAdoptionCaption(it.Caption, it.Adoption) } } - if login := stageTrackerWaitingOn(*it, stage); login != "" { + it.Push = stageTrackerPushFor(*it, stage, rec, hasRec, pushStaleAfter, now) + pushed := it.Push != nil && it.Push.State == pushStatePushed + if pushed { + // The ball is back with the hive: the row says what the push + // queued, and its note ages from the push (a new hive line). + it.Caption = stageTrackerPushCaption(it.Push, now) + if it.NoteChangedAt == nil || it.Push.Since.After(*it.NoteChangedAt) { + at := *it.Push.Since + it.NoteChangedAt = &at + } + } + // A pushed row no longer waits on its author: no presence marker, + // no rework pickup word, no adoption clock — the pill names the + // push instead. + if pushed { + it.Adoption = nil + } + if login := stageTrackerWaitingOn(*it, stage); login != "" && !pushed { it.Presence = stageTrackerPresenceFor(*it, login, stage, rec, hasRec, presence, adoptionClock, now) it.Rework = stageTrackerReworkFor(*it, login, stage, rec, hasRec, fixWork, now) } diff --git a/src/pkg/dashboard/stage_tracker_links.go b/src/pkg/dashboard/stage_tracker_links.go index 993f253a22..873c96d995 100644 --- a/src/pkg/dashboard/stage_tracker_links.go +++ b/src/pkg/dashboard/stage_tracker_links.go @@ -326,6 +326,7 @@ func stageTrackerResolveLinkedPRs(items []StageTrackerItem, open func(repo strin lp.Adoption = pr.Adoption lp.Presence = pr.Presence lp.Rework = pr.Rework + lp.Push = pr.Push lp.Takeover = pr.Takeover lp.Supersedes = pr.Supersedes lp.Lineage = pr.Lineage diff --git a/src/pkg/dashboard/stage_tracker_push.go b/src/pkg/dashboard/stage_tracker_push.go new file mode 100644 index 0000000000..ad5bef8575 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_push.go @@ -0,0 +1,169 @@ +package dashboard + +import ( + "strings" + "time" + + "github.com/hivecommons/hive/pkg/config" + "github.com/hivecommons/hive/pkg/stagelabels" +) + +// Push progress on a CI / Review row (hivecommons/hive#15784). A PR whose +// author must push read "waiting on @zoe to push · acknowledged" and +// "Needs @zoe" until the next sweep re-staged it — nothing said the person +// had pushed, or how long the hive had been waiting. The row's `push` +// field answers from the stage record alone: when the waiting-on-push +// state began (Record.WaitingPushSince) and the last head change seen +// while the row sat in the column (Record.LastPushAt / LastPushSha, booked +// by the webhook re-read of a synchronize delivery or by the enumerate +// that followed). The chevron keeps the stage; the gray pill carries the +// who and the push; the hive caption says what is queued. + +// Push states on the wire. +const ( + // pushStateWaiting: the hive waits for the author's push; `since` is + // when the wait began. + pushStateWaiting = "waiting" + // pushStatePushed: a head landed; CI and the re-review for it are + // still running. `since` is when it landed. + pushStatePushed = "pushed" + + // pushNextCI / pushNextReReview name what the push queued. + pushNextCI = "ci" + pushNextReReview = "re-review" +) + +// StageTrackerPush is the `push` field of a PR row in the CI / Review column. +type StageTrackerPush struct { + // State is waiting (no push since the wait began) or pushed. + State string `json:"state"` + // Login is the PR author: whose push the hive waits on, or who pushed. + Login string `json:"login,omitempty"` + // Since is when the state began: the wait's start, or the push. + Since *time.Time `json:"since,omitempty"` + // Sha is the pushed head; URL links to the commit on GitHub. + Sha string `json:"sha,omitempty"` + URL string `json:"url,omitempty"` + // Next is what the push queued: ci or re-review. + Next string `json:"next,omitempty"` + // Stale is set on a wait older than dashboard.stage_tracker.waiting_push_stale_h. + Stale bool `json:"stale,omitempty"` +} + +// stageTrackerPushFor derives the `push` field for a PR row at stage. rec +// is the row's stage record; staleAfter is the configured wait threshold +// (0: never stale). +func stageTrackerPushFor(it StageTrackerItem, stage stagelabels.Stage, rec stagelabels.Record, hasRec bool, staleAfter time.Duration, now time.Time) *StageTrackerPush { + if it.Kind != "pr" || !hasRec || !stage.TracksPush() { + return nil + } + login := strings.TrimSpace(it.Author) + if rec.PushedSinceWaiting() && stageTrackerPushSettling(stage, rec) { + at := rec.LastPushAt + if at.After(now) { + at = now + } + return &StageTrackerPush{ + State: pushStatePushed, + Login: login, + Since: &at, + Sha: rec.LastPushSha, + URL: stageTrackerCommitURL(it, rec.LastPushSha), + Next: stageTrackerPushNext(stage, rec.Reason), + } + } + if !stage.WaitsOnPush() || rec.WaitingPushSince.IsZero() { + return nil + } + since := rec.WaitingPushSince + if since.After(now) { + since = now + } + return &StageTrackerPush{ + State: pushStateWaiting, + Login: login, + Since: &since, + Stale: staleAfter > 0 && now.Sub(since) >= staleAfter, + } +} + +// stageTrackerPushSettling reports whether CI or the re-review for the +// pushed head is still ahead: the sweep has not re-staged the row off its +// waiting stage yet, has not seen the head at all, the item waits on the +// hive (checks running, verdict pending), or the hive itself is working +// the head (070 / 074). Once the head is seen, settled and nothing waits +// on the hive, the push is old news and the pill goes. +func stageTrackerPushSettling(stage stagelabels.Stage, rec stagelabels.Record) bool { + switch { + case stage.WaitsOnPush(), stage == stagelabels.Fixing, stage == stagelabels.AdoptedByHive: + return true + case rec.WaitingOnHive: + return true + case !strings.EqualFold(rec.ActivityHead, rec.LastPushSha): + return true + } + return false +} + +// stageTrackerPushNext names what the push queued: a re-review when the +// row was returned for review findings, CI otherwise. +func stageTrackerPushNext(stage stagelabels.Stage, reason string) string { + lower := strings.ToLower(reason) + if strings.Contains(lower, "changes") || strings.Contains(lower, "review") { + return pushNextReReview + } + if stage == stagelabels.ReviewPending { + return pushNextReReview + } + return pushNextCI +} + +// stageTrackerCommitURL is the GitHub page of sha on the row's repository, +// derived from the PR URL ("https://github.com/o/r/pull/N"); "" when the +// URL is not shaped like that. +func stageTrackerCommitURL(it StageTrackerItem, sha string) string { + if sha == "" { + return "" + } + i := strings.Index(it.URL, "/pull/") + if i < 0 { + return "" + } + return it.URL[:i] + "/commit/" + sha +} + +// stageTrackerPushCaption is the hive line for a pushed row: "push seen 2m +// ago → CI/re-review queued". "" when the row carries no push. +func stageTrackerPushCaption(p *StageTrackerPush, now time.Time) string { + if p == nil || p.State != pushStatePushed || p.Since == nil { + return "" + } + ago := shortDuration(now.Sub(*p.Since)) + if ago == "0s" { + return "push seen just now → CI/re-review queued" + } + return "push seen " + ago + " ago → CI/re-review queued" +} + +// stageTrackerPushWhy is the next-move line for a pushed row: who pushed +// and what the hive runs on the new head. +func stageTrackerPushWhy(p *StageTrackerPush) string { + who := "the author" + if p.Login != "" { + who = "@" + p.Login + } + what := "CI runs on the new head" + if p.Next == pushNextReReview { + what = "the re-review is queued for the new head" + } + return who + " pushed " + shortSHA(p.Sha) + " — " + what +} + +// stageTrackerWaitingPushStale is dashboard.stage_tracker.waiting_push_stale_h +// as the server reads it (the config default when no config is wired). +func (s *Server) stageTrackerWaitingPushStale() time.Duration { + if s != nil && s.deps != nil && s.deps.Config != nil { + return s.deps.Config.StageTrackerWaitingPushStale() + } + return (*config.Config)(nil).StageTrackerWaitingPushStale() +} diff --git a/src/pkg/dashboard/stage_tracker_push_test.go b/src/pkg/dashboard/stage_tracker_push_test.go new file mode 100644 index 0000000000..6a60021e64 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_push_test.go @@ -0,0 +1,322 @@ +package dashboard + +import ( + "encoding/json" + "strings" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/config" + "github.com/hivecommons/hive/pkg/github" + "github.com/hivecommons/hive/pkg/github/automerge" + "github.com/hivecommons/hive/pkg/stagelabels" +) + +// hivecommons/hive#15784: a PR row in the CI / Review column carries `push` +// — the wait for the author's push (with its age and a stale mark) or the +// push that just landed (sha, commit link, what it queued) — from the +// stage record alone. The chevron keeps the stage; the pill carries the +// push; the hive caption says what is queued. + +func TestStageTrackerPushFor(t *testing.T) { + now := time.Date(2026, 10, 30, 10, 0, 0, 0, time.UTC) + it := StageTrackerItem{Kind: "pr", Repo: "hivecommons/hive", Number: 42, Author: "zoe", Head: "bbb2222", URL: "https://github.com/hivecommons/hive/pull/42"} + waiting := stagelabels.Record{Stage: stagelabels.NeedsAuthor, WaitingPushSince: now.Add(-38 * time.Minute), ActivityHead: "aaa1111"} + pushedAt := now.Add(-2 * time.Minute) + pushed := stagelabels.Record{Stage: stagelabels.NeedsAuthor, Reason: "changes-requested", WaitingPushSince: now.Add(-38 * time.Minute), ActivityHead: "aaa1111", LastPushAt: pushedAt, LastPushSha: "bbb2222"} + cases := []struct { + name string + it StageTrackerItem + stage stagelabels.Stage + rec stagelabels.Record + hasRec bool + stale time.Duration + wantNil bool + state string + since time.Time + sha string + url string + next string + isStale bool + }{ + {name: "issue row", it: StageTrackerItem{Kind: "issue", Number: 1}, stage: stagelabels.NeedsAuthor, rec: waiting, hasRec: true, wantNil: true}, + {name: "no record", it: it, stage: stagelabels.NeedsAuthor, wantNil: true}, + {name: "outside the column", it: it, stage: stagelabels.AwaitingMergeAdmission, rec: pushed, hasRec: true, wantNil: true}, + {name: "050 with nothing pushed has no pill", it: it, stage: stagelabels.ReviewPending, rec: stagelabels.Record{Stage: stagelabels.ReviewPending, ActivityHead: "bbb2222"}, hasRec: true, wantNil: true}, + {name: "waiting, fresh", it: it, stage: stagelabels.NeedsAuthor, rec: waiting, hasRec: true, stale: 4 * time.Hour, state: "waiting", since: now.Add(-38 * time.Minute)}, + {name: "waiting past the stale threshold", it: it, stage: stagelabels.ReturnedToContributor, rec: stagelabels.Record{Stage: stagelabels.ReturnedToContributor, WaitingPushSince: now.Add(-5 * time.Hour)}, hasRec: true, stale: 4 * time.Hour, state: "waiting", since: now.Add(-5 * time.Hour), isStale: true}, + {name: "stale disabled", it: it, stage: stagelabels.NeedsAuthor, rec: stagelabels.Record{Stage: stagelabels.NeedsAuthor, WaitingPushSince: now.Add(-50 * time.Hour)}, hasRec: true, stale: 0, state: "waiting", since: now.Add(-50 * time.Hour)}, + {name: "pushed while still 071 (sweep not yet through)", it: it, stage: stagelabels.NeedsAuthor, rec: pushed, hasRec: true, stale: 4 * time.Hour, state: "pushed", since: pushedAt, sha: "bbb2222", url: "https://github.com/hivecommons/hive/commit/bbb2222", next: "re-review"}, + {name: "pushed, re-staged to 050, checks running", it: it, stage: stagelabels.ReviewPending, rec: stagelabels.Record{Stage: stagelabels.ReviewPending, Reason: "ci-pending", ActivityHead: "bbb2222", LastPushAt: pushedAt, LastPushSha: "bbb2222", WaitingOnHive: true}, hasRec: true, state: "pushed", since: pushedAt, sha: "bbb2222", url: "https://github.com/hivecommons/hive/commit/bbb2222", next: "re-review"}, + {name: "pushed on an adopted row, hive working it", it: it, stage: stagelabels.AdoptedByHive, rec: stagelabels.Record{Stage: stagelabels.AdoptedByHive, Reason: "adopted:ci-red", ActivityHead: "bbb2222", LastPushAt: pushedAt, LastPushSha: "bbb2222"}, hasRec: true, state: "pushed", since: pushedAt, sha: "bbb2222", url: "https://github.com/hivecommons/hive/commit/bbb2222", next: "ci"}, + {name: "pushed, enumerate has not seen the head yet", it: it, stage: stagelabels.Reviewed, rec: stagelabels.Record{Stage: stagelabels.Reviewed, Reason: "approved:ci-pending", ActivityHead: "aaa1111", LastPushAt: pushedAt, LastPushSha: "bbb2222"}, hasRec: true, state: "pushed", since: pushedAt, sha: "bbb2222", url: "https://github.com/hivecommons/hive/commit/bbb2222", next: "ci"}, + {name: "pushed head settled: the pill goes", it: it, stage: stagelabels.Reviewed, rec: stagelabels.Record{Stage: stagelabels.Reviewed, Reason: "approved", ActivityHead: "bbb2222", LastPushAt: pushedAt, LastPushSha: "bbb2222"}, hasRec: true, wantNil: true}, + {name: "push before the wait began is history", it: it, stage: stagelabels.NeedsAuthor, rec: stagelabels.Record{Stage: stagelabels.NeedsAuthor, WaitingPushSince: now.Add(-10 * time.Minute), LastPushAt: now.Add(-20 * time.Minute), LastPushSha: "aaa1111"}, hasRec: true, stale: 4 * time.Hour, state: "waiting", since: now.Add(-10 * time.Minute)}, + {name: "no commit link without a PR URL", it: StageTrackerItem{Kind: "pr", Number: 42, Author: "zoe", Head: "bbb2222"}, stage: stagelabels.NeedsAuthor, rec: pushed, hasRec: true, state: "pushed", since: pushedAt, sha: "bbb2222", next: "re-review"}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + got := stageTrackerPushFor(tc.it, tc.stage, tc.rec, tc.hasRec, tc.stale, now) + if tc.wantNil { + if got != nil { + t.Fatalf("want nil, got %+v", got) + } + return + } + if got == nil { + t.Fatal("want a push field, got nil") + } + if got.State != tc.state || got.Login != tc.it.Author || got.Sha != tc.sha || got.URL != tc.url || got.Next != tc.next || got.Stale != tc.isStale { + t.Fatalf("push = %+v", got) + } + if got.Since == nil || !got.Since.Equal(tc.since) { + t.Fatalf("since = %v, want %v", got.Since, tc.since) + } + }) + } + // The hive line names the push's age; nothing for a wait. + if c := stageTrackerPushCaption(stageTrackerPushFor(it, stagelabels.NeedsAuthor, pushed, true, 0, now), now); c != "push seen 2m ago → CI/re-review queued" { + t.Fatalf("caption = %q", c) + } + if c := stageTrackerPushCaption(stageTrackerPushFor(it, stagelabels.NeedsAuthor, waiting, true, 0, now), now); c != "" { + t.Fatalf("waiting caption = %q", c) + } +} + +// Through the tracker, with the webhook re-read booking the push: the 071 +// row drops its presence marker and rework word, carries the push, and +// its hive note dates from the push; a plain 050 row with the same push +// carries it too; the nested copy under the issue mirrors it. +func TestStageTrackerPushPayload(t *testing.T) { + now := time.Date(2026, 10, 30, 10, 0, 0, 0, time.UTC) + s := newTestServer() + clock := now.Add(-3 * time.Hour) + store := stagelabels.NewStore("", func() time.Time { return clock }) + s.stageStore = store + s.presenceLookup = func(string) (automerge.ContributorPresence, bool) { + return automerge.ContributorPresence{Registered: true, Online: true, LastSeen: now}, true + } + cfg := &config.Config{} + cfg.Dashboard.StageTracker.WaitingPushStaleH = 2 + s.deps = &Dependencies{Config: cfg} + k71, k50, k72 := stagelabels.Key("hivecommons/hive", 14990), stagelabels.Key("hivecommons/hive", 14992), stagelabels.Key("hivecommons/hive", 14993) + store.Observe(k72, stagelabels.ReturnedToContributor, "check-failing:ci") + store.NoteActivity(k72, stagelabels.Activity{Head: "eee", Comments: -1, Reviews: -1}) + store.Observe(k50, stagelabels.ReviewPending, "ci-pending") + store.NoteActivity(k50, stagelabels.Activity{Head: "ccc", Comments: -1, Reviews: -1, WaitingOnHive: true}) + clock = now.Add(-time.Hour) + store.Observe(k71, stagelabels.NeedsAuthor, "changes-requested") + store.NoteActivity(k71, stagelabels.Activity{Head: "aaa", Comments: -1, Reviews: -1}) + clock = now + status := minimalPayload() + status.HiveID = "hive" + status.Repos = []FrontendRepo{{ + Name: "hive", Full: "hivecommons/hive", + OpenPrs: []any{ + FrontendPR{PullRequest: github.PullRequest{Number: 14990, Title: "Docs", Author: "zoe", HeadSHA: "aaa", URL: "https://github.com/hivecommons/hive/pull/14990", UpdatedAt: now.Add(-4 * time.Hour), Labels: []string{"stage/071-needs-author", "author/human"}}}, + FrontendPR{PullRequest: github.PullRequest{Number: 14992, Title: "Other", Author: "zoe", HeadSHA: "ccc", URL: "https://github.com/hivecommons/hive/pull/14992", Labels: []string{"stage/050-review-pending"}}}, + FrontendPR{PullRequest: github.PullRequest{Number: 14993, Title: "Clanker", Author: "kai", HeadSHA: "eee", URL: "https://github.com/hivecommons/hive/pull/14993", Labels: []string{"stage/072-returned-to-contributor", "author/clanker"}}}, + }, + }} + s.UpdateStatus(status) + + // Before any push: the 071 and 072 rows wait (the 072 one past the + // 2 h knob), the 050 row carries nothing. + tr := s.buildStageTracker(s.status, store, now) + if p := trackerItem(t, tr, "pr", 14990).Push; p == nil || p.State != "waiting" || p.Login != "zoe" || p.Stale || p.Since == nil || !p.Since.Equal(now.Add(-time.Hour)) { + t.Fatalf("071 before push = %+v", p) + } + if p := trackerItem(t, tr, "pr", 14993).Push; p == nil || p.State != "waiting" || !p.Stale { + t.Fatalf("072 before push = %+v (want stale past the 2h knob)", p) + } + if it := trackerItem(t, tr, "pr", 14990); it.Presence == nil || it.Rework == nil { + t.Fatalf("071 before push must keep its presence and rework: %+v %+v", it.Presence, it.Rework) + } + if p := trackerItem(t, tr, "pr", 14992).Push; p != nil { + t.Fatalf("050 before push = %+v", p) + } + + // The synchronize re-reads land: new heads on 14990 and 14992, the + // same head on 14993. + fetched := now.Add(-2 * time.Minute) + if n := s.notePushedSnapshots([]github.WebhookItemSnapshot{ + {Repo: "hivecommons/hive", Number: 14990, IsPR: true, State: "open", Title: "Docs", HeadSHA: "bbb", FetchedAt: fetched}, + {Repo: "hivecommons/hive", Number: 14992, IsPR: true, State: "open", Title: "Other", HeadSHA: "ddd", FetchedAt: fetched}, + {Repo: "hivecommons/hive", Number: 14993, IsPR: true, State: "open", Title: "Clanker", HeadSHA: "eee", FetchedAt: fetched}, + {Repo: "hivecommons/hive", Number: 7, IsPR: false, State: "open", Title: "An issue"}, + }); n != 2 { + t.Fatalf("booked %d pushes, want 2", n) + } + tr = s.buildStageTracker(s.status, store, now) + it := trackerItem(t, tr, "pr", 14990) + p := it.Push + if p == nil || p.State != "pushed" || p.Login != "zoe" || p.Sha != "bbb" || p.URL != "https://github.com/hivecommons/hive/commit/bbb" || p.Next != "re-review" || p.Since == nil || !p.Since.Equal(fetched) { + t.Fatalf("071 after push = %+v", p) + } + if it.Presence != nil || it.Rework != nil || it.Adoption != nil { + t.Fatalf("a pushed row no longer waits on its author: presence=%+v rework=%+v adoption=%+v", it.Presence, it.Rework, it.Adoption) + } + if it.StageActor == nil || it.StageActor.Kind != StageActorHive || !strings.Contains(it.StageActor.Why, "@zoe pushed ") { + t.Fatalf("a pushed 071 row is the hive's again: actor=%+v", it.StageActor) + } + if it.Caption != "push seen 2m ago → CI/re-review queued" || it.NoteChangedAt == nil || !it.NoteChangedAt.Equal(fetched) { + t.Fatalf("071 caption = %q note_changed_at = %v", it.Caption, it.NoteChangedAt) + } + if p := trackerItem(t, tr, "pr", 14992).Push; p == nil || p.State != "pushed" || p.Sha != "ddd" || p.Next != "re-review" { + t.Fatalf("050 after push = %+v", p) + } + if p := trackerItem(t, tr, "pr", 14993).Push; p == nil || p.State != "waiting" { + t.Fatalf("072 re-read of the same head must keep waiting: %+v", p) + } + raw, _ := json.Marshal(it) + for _, want := range []string{`"push":{`, `"state":"pushed"`, `"login":"zoe"`, `"sha":"bbb"`, `"url":"https://github.com/hivecommons/hive/commit/bbb"`, `"next":"re-review"`, `"since":"2026-10-30T09:58:00Z"`} { + if !strings.Contains(string(raw), want) { + t.Errorf("payload lacks %s: %s", want, raw) + } + } +} + +func TestStageTrackerWaitingPushStaleKnob(t *testing.T) { + cfg := &config.Config{} + if (*config.Config)(nil).StageTrackerWaitingPushStale() != 4*time.Hour || cfg.StageTrackerWaitingPushStale() != 4*time.Hour { + t.Fatal("default dashboard.stage_tracker.waiting_push_stale_h is 4 hours") + } + cfg.Dashboard.StageTracker.WaitingPushStaleH = -1 + if cfg.StageTrackerWaitingPushStale() != 0 { + t.Fatal("a negative waiting_push_stale_h disables the stale mark") + } + cfg.Dashboard.StageTracker.WaitingPushStaleH = 6 + if cfg.StageTrackerWaitingPushStale() != 6*time.Hour { + t.Fatal("waiting_push_stale_h is read in hours") + } + s := newTestServer() + if s.stageTrackerWaitingPushStale() != 4*time.Hour { + t.Fatal("a server without config uses the default") + } + s.deps = &Dependencies{Config: cfg} + if s.stageTrackerWaitingPushStale() != 6*time.Hour { + t.Fatal("the server reads the configured knob") + } +} + +// stageTrackerPushJS lifts the SPA's push-progress helpers (the pill, the +// lineage suffix, the hover line) for the node harnesses. +func stageTrackerPushJS(t *testing.T, html string) string { + t.Helper() + return strings.Join([]string{ + jsConstLine(t, html, "STAGE_TRACKER_PUSH_NEXT"), + jsFunc(t, html, "stageTrackerPushOf"), + jsFunc(t, html, "stageTrackerPushedBack"), + jsFunc(t, html, "stageTrackerPushAge"), + jsFunc(t, html, "stageTrackerPushSha"), + jsFunc(t, html, "stageTrackerPushWaitHtml"), + jsFunc(t, html, "stageTrackerPushChipText"), + jsFunc(t, html, "stageTrackerPushOnLineage"), + jsFunc(t, html, "stageTrackerPushLineageSuffix"), + jsFunc(t, html, "stageTrackerPushTip"), + jsFunc(t, html, "stageTrackerPushChipHtml"), + }, "\n") +} + +// TestStageTrackerPushJS: the SPA fed the live `push` shape. Waiting: the +// presence pill ends with the wait's age, amber once stale. Pushed: the +// presence pill gives way to "@zoe pushed abc1234 · 2m" linking to the +// commit; on an adopted row the lineage chip says "· pushed 2m ago" +// instead and no pill of its own is drawn; the hover line names what the +// push queued. Without the field nothing changes. +func TestStageTrackerPushJS(t *testing.T) { + html := indexHTML(t) + script := strings.Join([]string{ + stageTrackerRowActionsPreamble(t, html), + jsFunc(t, html, "stageTrackerAdoptionTip"), + jsFunc(t, html, "stageTrackerAdoptOffered"), + jsFunc(t, html, "stageTrackerAdoptionChipText"), + jsFunc(t, html, "stageTrackerAdoptionChipHtml"), + jsFunc(t, html, "stageTrackerDecisionOf"), + jsFunc(t, html, "stageTrackerDecisionTriggerHtml"), + jsFunc(t, html, "stageTrackerDecisionPopHtml"), + stageTrackerPresenceJS(t, html), + jsFunc(t, html, "stageTrackerAgoText"), + jsFunc(t, html, "stageTrackerLineageText"), + jsConstBlock(t, html, "STAGE_TRACKER_LINEAGE_REASON_TIP"), + stageTrackerPushJS(t, html), + ` +const NOW = Date.parse('2026-10-28T14:32:00Z'); +Date.now = () => NOW; +const iso = ms => new Date(ms).toISOString(); +const MIN = 60000, HOUR = 60 * MIN; +const base = { kind: 'pr', repo: 'hivecommons/hive', number: 15780, stage: 71, author: 'zoe', author_kind: 'human', url: 'https://github.com/hivecommons/hive/pull/15780', + presence: { login: 'zoe', state: 'online', kind: 'human', since: iso(NOW - 38 * MIN), last_seen: iso(NOW - 2 * MIN), next: 'wait' } }; +const w = (push) => Object.assign({}, base, { push }); +const waiting = w({ state: 'waiting', login: 'zoe', since: iso(NOW - 38 * MIN) }); +const stale = w({ state: 'waiting', login: 'zoe', since: iso(NOW - 5 * HOUR), stale: true }); +const pushed = w({ state: 'pushed', login: 'zoe', since: iso(NOW - 2 * MIN), sha: 'abc1234def', url: 'https://github.com/hivecommons/hive/commit/abc1234def', next: 'ci' }); +const rereview = w({ state: 'pushed', login: 'zoe', since: iso(NOW - 2 * MIN), sha: 'abc1234def', url: 'https://github.com/hivecommons/hive/commit/abc1234def', next: 're-review' }); + +// Without the field the pill is exactly what it was. +assert.strictEqual(stageTrackerPushOf(base), null); +assert.strictEqual(stageTrackerPushedBack(base), false); +assert.strictEqual(stageTrackerPushWaitHtml(base, NOW), ''); +assert.strictEqual(stageTrackerPushChipHtml(base, NOW), ''); +assert.strictEqual(stageTrackerPushTip(base, NOW), ''); +assert.ok(/>waiting on 38m'); +assert.strictEqual(stageTrackerPushWaitHtml(stale, NOW), ' · 5h'); +const wchip = stageTrackerPresenceChipHtml(waiting); +assert.ok(/@zoe to push · 38m<\/span><\/span>$/.test(wchip), wchip); +assert.ok(wchip.includes('waiting for @zoe to push since 38m ago ('), wchip); +assert.strictEqual(stageTrackerPushChipHtml(waiting, NOW), '', 'no second pill while waiting'); +assert.match(stageTrackerPushTip(stale, NOW), /^waiting for @zoe to push since 5h ago \(.*\) · no push for a long time$/); + +// Pushed: the ball is back with the hive — the pill names the push and links the commit. +assert.strictEqual(stageTrackerPushedBack(pushed), true); +assert.strictEqual(stageTrackerPushChipText(pushed, NOW), '@zoe pushed abc1234 · 2m'); +const pchip = stageTrackerPushChipHtml(pushed, NOW); +assert.match(pchip, /^@zoe pushed abc1234 · 2m<\/a>$/); +assert.match(stageTrackerPushTip(rereview, NOW), / · re-review queued$/); +assert.strictEqual(stageTrackerPushWaitHtml(pushed, NOW), ''); +// No URL: a span, same words. +assert.strictEqual(stageTrackerPushChipHtml(w({ state: 'pushed', since: iso(NOW - 2 * MIN), sha: 'abc1234' }), NOW).replace(/ title="[^"]*" aria-label="[^"]*"/, ''), 'pushed abc1234 · 2m'); + +// Adopted row: the lineage chip carries the push; no pill of its own. +const adopted = Object.assign({}, pushed, { stage: 74, lineage: { kind: 'adopted', from_number: 15516, from_author: 'karibhou', at: iso(NOW - 3 * HOUR) } }); +assert.strictEqual(stageTrackerLineageText(Object.assign({}, adopted, { push: null }), NOW), "adopted from @karibhou's #15516 · 3h"); +assert.strictEqual(stageTrackerLineageText(adopted, NOW), "adopted from @karibhou's #15516 · pushed 2m ago"); +assert.strictEqual(stageTrackerPushChipHtml(adopted, NOW), ''); +// A superseded lineage is not the adopted kind: the pill stays. +const sup = Object.assign({}, pushed, { lineage: { kind: 'superseded', to_number: 9, at: iso(NOW - HOUR) } }); +assert.strictEqual(stageTrackerLineageText(sup, NOW), 'superseded by #9 · 1h'); +assert.ok(stageTrackerPushChipHtml(sup, NOW).includes('@zoe pushed abc1234')); +// Issues never carry it. +assert.strictEqual(stageTrackerPushOf(Object.assign({}, pushed, { kind: 'issue' })), null); +`}, "\n") + runStageTrackerRowActionsScript(t, script) +} + +// TestStageTrackerPushChevronJS: on a 071 / 072 row the chevron reads +// "Needs @zoe 👤" while the hive waits; once the push lands it returns to +// the column's own word — stage only, the pill carries the push. +func TestStageTrackerPushChevronJS(t *testing.T) { + html := indexHTML(t) + runStageTrackerRowActionsScript(t, stageTrackerRowsPreludeJS(t, html)+"\n"+stageTrackerActorIconJS(t, html)+"\n"+stageTrackerPushJS(t, html)+stageTrackerRowsFixtureJS+` +Date.now = () => now; +const litWord = (html) => text((/
  • ]*>([\s\S]*?)<\/li>/.exec(strip(html)) || ['', ''])[1]); +const since = new Date(now - 3 * 3600000).toISOString(); +const row = (extra) => stageTrackerRowHtml(Object.assign({ repo: 'hivecommons/hive', number: 8, kind: 'pr', title: 'docs', url: 'https://x/8', stage: 71, stage_since: since, caption: 'Needs author', author: 'zoe', author_kind: 'human', stage_actor: { kind: 'human', login: 'zoe', why: '@zoe must act' } }, extra || {}), stages, ctx); +const waiting = row({ push: { state: 'waiting', login: 'zoe', since } }); +assert.ok(/^Needs @zoe\b/.test(litWord(waiting)), litWord(waiting)); +const pushed = row({ stage_actor: { kind: 'hive', why: '@zoe pushed abc1234 — CI runs on the new head' }, push: { state: 'pushed', login: 'zoe', since: new Date(now - 120000).toISOString(), sha: 'abc1234', url: 'https://x/commit/abc1234', next: 'ci' } }); +assert.ok(/^CI \/ Review\b/.test(litWord(pushed)), litWord(pushed)); +assert.ok(!/ham-actor-ico[^>]*aria-label="Next move: human"/.test(pushed), 'the hive carries it: no person glyph on the chevron'); +assert.ok(!/Needs @zoe/.test(litWord(pushed)), litWord(pushed)); +assert.ok(pushed.includes('>@zoe pushed abc1234 · 2m'), pushed); +assert.ok(pushed.includes('Push: @zoe pushed abc1234 2m ago'), 'hover line'); +// 072 the same. +const back = row({ stage: 72, caption: 'Returned to contributor', push: { state: 'pushed', login: 'zoe', since: new Date(now - 120000).toISOString(), sha: 'abc1234', next: 're-review' } }); +assert.ok(/^CI \/ Review\b/.test(litWord(back)), litWord(back)); +console.log('push chevron ok'); +`) +} diff --git a/src/pkg/dashboard/static-src/css/tracker.css b/src/pkg/dashboard/static-src/css/tracker.css index ed0b5f71c7..616d5e5325 100644 --- a/src/pkg/dashboard/static-src/css/tracker.css +++ b/src/pkg/dashboard/static-src/css/tracker.css @@ -269,6 +269,12 @@ .ham-badge-overlap { color: var(--text-faint); border-color: var(--line-subtle); } /* Waiting-on pill without an adoption clock (071, 072 before the nudge, a human's PR): muted, hive PR 15051. */ .ham-badge-waiting { color: var(--text-faint); border-color: var(--line-subtle); } + /* Push progress on the waiting-on pill (hive PR 15784): the wait's age + rides last; past dashboard.stage_tracker.waiting_push_stale_h it takes + the muted warning tone. "@zoe pushed abc1234 · 2m" links to the commit. */ + .ham-push-stale { color: color-mix(in srgb, var(--status-warn) 70%, var(--text-faint)); } + .ham-badge-push { text-decoration: none; } + .ham-badge-push:hover { color: var(--text-muted); } /* Presence indicator on a waiting-on pill (hive PR 15051): who the row waits on, drawn as the same glyphs the stage chevrons use — a person for a human (nothing more: a human has no presence to report) or the diff --git a/src/pkg/dashboard/static-src/js/tracker-row.js b/src/pkg/dashboard/static-src/js/tracker-row.js index 02a5af7967..fc87a969c9 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row.js +++ b/src/pkg/dashboard/static-src/js/tracker-row.js @@ -58,7 +58,11 @@ const anchor = stageTrackerAnchor(cur, stages, item.via_pr ? 'pr' : item.kind, item); const terminal = anchor >= STAGE_TRACKER_TERMINAL; const sentinelLane = stageTrackerSentinelInLane(item); - const detour = (!terminal && STAGE_TRACKER_PATH.indexOf(cur) < 0 && cur !== STAGE_TRACKER_TRIAGE_NEEDED && cur !== STAGE_TRACKER_POSSIBLY_EXISTS && cur !== 40 && cur !== 60 && cur !== STAGE_TRACKER_PRE_MERGE_SOAK && cur !== 100) + // A 071 / 072 row whose author has pushed is back with the hive: the + // chevron reads the column's own word ("CI / Review"), not "Needs + // @author" (hivecommons/hive#15784). Guarded: the harnesses load by name. + const pushedBack = (cur === 71 || cur === 72) && typeof stageTrackerPushedBack === 'function' && stageTrackerPushedBack(item); + const detour = (!terminal && !pushedBack && STAGE_TRACKER_PATH.indexOf(cur) < 0 && cur !== STAGE_TRACKER_TRIAGE_NEEDED && cur !== STAGE_TRACKER_POSSIBLY_EXISTS && cur !== 40 && cur !== 60 && cur !== STAGE_TRACKER_PRE_MERGE_SOAK && cur !== 100) ? { text: sentinelLane ? STAGE_TRACKER_SENTINEL_WORD : (cur === STAGE_TRACKER_HUMAN_GATED && typeof stageTrackerTrainWord === 'function' && stageTrackerTrainWord(item)) || (cur === STAGE_TRACKER_READY_FOR_HUMAN_MERGE && item.manual_merge ? stageTrackerManualMergeWord(item) : (cur === STAGE_TRACKER_HUMAN_GATED && stageTrackerUnauthorizedWord(item)) || (typeof stageTrackerBlockerWord === 'function' && cur === STAGE_TRACKER_ISSUE_NEEDS_DECISION && stageTrackerBlockerWord(item)) || ((cur === STAGE_TRACKER_ADOPTED_BY_HIVE || (cur === STAGE_TRACKER_HUMAN_GATED && item.adopted_by_state)) && stageTrackerAdoptedWord(item)) || (cur === STAGE_TRACKER_READY_FOR_HUMAN_MERGE && stageTrackerReadyForHumanWord(item, STAGE_TRACKER_ACTIVE_WORD[cur] || curStage.short || curStage.label || String(cur))) || (STAGE_TRACKER_ACTIVE_WORD[cur] || curStage.short || curStage.label || String(cur))), sentinel: sentinelLane } : null; if (detour && cur === 70 && !detour.sentinel && typeof stageTrackerFixingWord === 'function') detour.text = stageTrackerFixingWord(item, detour.text); if (detour && (cur === 71 || cur === 72) && typeof stageTrackerReturnedWord === 'function') { @@ -548,6 +552,8 @@ if (presence) lines.push('Presence: ' + presence); const rework = typeof stageTrackerReworkTip === 'function' ? stageTrackerReworkTip(item, nowMs) : ''; if (rework) lines.push('Rework: ' + rework); + const push = typeof stageTrackerPushTip === 'function' ? stageTrackerPushTip(item, nowMs) : ''; + if (push) lines.push('Push: ' + push); if (mods.length) lines.push('Flags: ' + mods.map(m => STAGE_TRACKER_MOD_TEXT[m] || m).join(', ')); const stale = stageTrackerStaleLabelsText(item); if (stale) lines.push(stale); @@ -612,7 +618,7 @@ } function stageTrackerChipsHtml(item) { - const sentinel = stageTrackerSentinelChipHtml(item) + (typeof stageTrackerAdoptionChipHtml === 'function' ? stageTrackerAdoptionChipHtml(item) : '') + (typeof stageTrackerPresenceChipHtml === 'function' ? stageTrackerPresenceChipHtml(item) : '') + (typeof stageTrackerReroutePillHtml === 'function' ? stageTrackerReroutePillHtml(item) : '') + (typeof stageTrackerSupersedesChipHtml === 'function' ? stageTrackerSupersedesChipHtml(item, Date.now()) : '') + (typeof stageTrackerOverlapBadgeHtml === 'function' ? stageTrackerOverlapBadgeHtml(item) : ''); + const sentinel = stageTrackerSentinelChipHtml(item) + (typeof stageTrackerAdoptionChipHtml === 'function' ? stageTrackerAdoptionChipHtml(item) : '') + (typeof stageTrackerPresenceChipHtml === 'function' ? stageTrackerPresenceChipHtml(item) : '') + (typeof stageTrackerPushChipHtml === 'function' ? stageTrackerPushChipHtml(item, Date.now()) : '') + (typeof stageTrackerReroutePillHtml === 'function' ? stageTrackerReroutePillHtml(item) : '') + (typeof stageTrackerSupersedesChipHtml === 'function' ? stageTrackerSupersedesChipHtml(item, Date.now()) : '') + (typeof stageTrackerOverlapBadgeHtml === 'function' ? stageTrackerOverlapBadgeHtml(item) : ''); const mods = (Array.isArray(item.modifiers) ? item.modifiers.slice() : []) .sort((x, y) => STAGE_TRACKER_MOD_PRIORITY.indexOf(x) - STAGE_TRACKER_MOD_PRIORITY.indexOf(y)); if (!mods.length) return sentinel; @@ -949,7 +955,7 @@ stage: lp.stage || 0, stage_since: lp.stage_since || '', stage_slug: lp.stage_slug || '', modifiers: lp.modifiers || [], deferred_modifiers: lp.deferred_modifiers || [], caption: lp.caption || '', reason: lp.reason || '', human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', base_ref: lp.base_ref || '', decision_needed: lp.decision_needed || null, adoption: lp.adoption || null, takeover: lp.takeover || null, superseded: !!lp.superseded, supersedes: lp.supersedes || null, parent: Number(issue.number) || 0, siblings: open.map(x => Number(x.number) || 0), - last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || null, + last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, push: lp.push || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || null, decided: lp.decided || null, adopted_by: Number(lp.adopted_by) || 0, adopted_by_state: lp.adopted_by_state || '', adopted_from: lp.adopted_from || null, lineage: lp.lineage || null, state: lp.state || '', superseded_by: Number(lp.superseded_by) || 0 }; } // Pure: whether a linked PR is still open (not merged / closed / @@ -995,7 +1001,10 @@ const l = item && item.lineage; if (!l || !l.kind) return ''; const ago = stageTrackerAgoText(Date.parse(l.at || ''), nowMs).replace(/ ago$/, ''); - const tail = ago ? ' · ' + ago : ''; + // Once the head moves the chip says so instead of the adoption's age: + // "adopted from @x's #N · pushed 2m ago" (hivecommons/hive#15784). + const pushed = typeof stageTrackerPushLineageSuffix === 'function' ? stageTrackerPushLineageSuffix(item, nowMs) : ''; + const tail = pushed || (ago ? ' · ' + ago : ''); if (l.kind === 'superseded') return Number(l.to_number) > 0 ? 'superseded by #' + Number(l.to_number) + tail : ''; if (!(Number(l.from_number) > 0)) return ''; const whose = l.from_author ? '@' + l.from_author + "'s " : ''; @@ -1323,7 +1332,7 @@ const who = (lp.author_kind || 'hive') + (lp.author ? ' · @' + lp.author : ''); prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRPillsHtml(stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)), (lp.lineage && typeof stageTrackerLineageChipHtml === 'function' ? stageTrackerLineageChipHtml(lp, nowMs) : '') || (typeof stageTrackerAdoptedFromChipHtml === 'function' ? stageTrackerAdoptedFromChipHtml(lp, nowMs) : '') || null, lp.base_ref)]; shown = Object.assign({}, item, { via_pr: true, stage: stageTrackerLeadStage(lp), stage_since: lp.stage_since || item.stage_since, modifiers: lp.modifiers || item.modifiers, deferred_modifiers: lp.deferred_modifiers || item.deferred_modifiers || [], caption: lp.caption || item.caption, reason: lp.reason || item.reason, - human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', decision_needed: lp.decision_needed || null, hold: lp.hold || null, adoption: lp.adoption || null, stage_actor: lp.stage_actor || item.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || null, decided: lp.decided || item.decided || null }); + human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', decision_needed: lp.decision_needed || null, hold: lp.hold || null, adoption: lp.adoption || null, stage_actor: lp.stage_actor || item.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, push: lp.push || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || null, decided: lp.decided || item.decided || null }); } else if (linked.length) { // Several covering PRs: the issue strip ends at Claimed, all passed // and nothing lit; one sub-row per PR carries the live chevron. diff --git a/src/pkg/dashboard/static-src/js/tracker-words.js b/src/pkg/dashboard/static-src/js/tracker-words.js index 20e7692e34..8b42569f31 100644 --- a/src/pkg/dashboard/static-src/js/tracker-words.js +++ b/src/pkg/dashboard/static-src/js/tracker-words.js @@ -216,8 +216,94 @@ const p = stageTrackerPresenceOf(item); if (!p || stageTrackerAdoptionTip(item)) return ''; const ptip = stageTrackerPresenceTip(item, Date.now()); - const tip = typeof stageTrackerReworkJoinTip === 'function' ? stageTrackerReworkJoinTip(ptip, item, Date.now()) : ptip; - return `${stageTrackerPresenceInPillHtml(item, stageTrackerPresenceChipText(item))}`; + const rtip = typeof stageTrackerReworkJoinTip === 'function' ? stageTrackerReworkJoinTip(ptip, item, Date.now()) : ptip; + // The wait's age rides last on the pill, muted-amber once stale + // (hivecommons/hive#15784). Guarded: the harnesses load by name. + const wait = typeof stageTrackerPushWaitHtml === 'function' ? stageTrackerPushWaitHtml(item, Date.now()) : ''; + const wtip = typeof stageTrackerPushTip === 'function' ? stageTrackerPushTip(item, Date.now()) : ''; + const tip = wtip ? rtip + ' · ' + wtip : rtip; + return `${stageTrackerPresenceInPillHtml(item, stageTrackerPresenceChipText(item))}${wait}`; + } + + // Push progress on a CI / Review row (`push`: {state, login, since, sha, + // url, next, stale} — hivecommons/hive#15784). The chevron keeps the + // stage; the gray pill carries the push: + // waiting — the hive waits for the author's push; the pill ends with + // the wait's age ("waiting on @zoe to push · 38m"), amber + // once past dashboard.stage_tracker.waiting_push_stale_h. + // pushed — a head landed and CI / the re-review for it still run: + // "@zoe pushed abc1234 · 2m" (links to the commit); on an + // adopted row the lineage chip says "· pushed 2m ago" + // instead. The presence marker goes: the ball is back with + // the hive. + const STAGE_TRACKER_PUSH_NEXT = { ci: 'CI running', 're-review': 're-review queued' }; + function stageTrackerPushOf(item) { + const p = item && item.kind === 'pr' ? item.push : null; + if (!p || (p.state !== 'waiting' && p.state !== 'pushed')) return null; + return p; + } + // Pure: whether the author's push has landed — the row is the hive's again. + function stageTrackerPushedBack(item) { + const p = stageTrackerPushOf(item); + return !!(p && p.state === 'pushed'); + } + // Pure: the short age of the state ("38m", "2h"); '' without a time. + function stageTrackerPushAge(p, nowMs) { + const at = Date.parse((p && p.since) || ''); + return at > 0 ? stageTrackerAgoText(at, nowMs).replace(/ ago$/, '') : ''; + } + function stageTrackerPushSha(p) { + return String((p && p.sha) || '').slice(0, 7); + } + // " · 38m" for the waiting pill, the age wrapped so a stale wait can take + // the muted-amber tone; '' unless the row waits. + function stageTrackerPushWaitHtml(item, nowMs) { + const p = stageTrackerPushOf(item); + if (!p || p.state !== 'waiting') return ''; + const age = stageTrackerPushAge(p, nowMs); + if (!age) return ''; + return ' · ' + esc(age) + ''; + } + // Pure: "@zoe pushed abc1234 · 2m"; '' unless the push landed. + function stageTrackerPushChipText(item, nowMs) { + const p = stageTrackerPushOf(item); + if (!p || p.state !== 'pushed') return ''; + const sha = stageTrackerPushSha(p); + const age = stageTrackerPushAge(p, nowMs); + return (p.login ? '@' + p.login + ' ' : '') + 'pushed' + (sha ? ' ' + sha : '') + (age ? ' · ' + age : ''); + } + // Pure: whether the row's lineage chip (adopted / rebased copy) carries + // the push instead of a pill of its own. + function stageTrackerPushOnLineage(item) { + const l = item && item.lineage; + return !!(l && l.kind && l.kind !== 'superseded' && Number(l.from_number) > 0); + } + // Pure: " · pushed 2m ago" for the lineage chip; '' unless pushed. + function stageTrackerPushLineageSuffix(item, nowMs) { + const p = stageTrackerPushOf(item); + if (!p || p.state !== 'pushed' || !stageTrackerPushOnLineage(item)) return ''; + const at = Date.parse(p.since || ''); + const ago = at > 0 ? stageTrackerAgoText(at, nowMs) : ''; + return ' · pushed' + (ago ? ' ' + ago : ''); + } + // Pure: the hover line — how long the hive has waited, or what the push queued. + function stageTrackerPushTip(item, nowMs) { + const p = stageTrackerPushOf(item); + if (!p) return ''; + const at = Date.parse(p.since || ''); + const when = at > 0 ? stageTrackerAgoText(at, nowMs) + ' (' + agentNowClockTime(at, nowMs) + ')' : ''; + const who = p.login ? '@' + p.login : 'the author'; + if (p.state === 'waiting') return 'waiting for ' + who + ' to push' + (when ? ' since ' + when : '') + (p.stale ? ' · no push for a long time' : ''); + const next = STAGE_TRACKER_PUSH_NEXT[p.next] || STAGE_TRACKER_PUSH_NEXT.ci; + return who + ' pushed' + (stageTrackerPushSha(p) ? ' ' + stageTrackerPushSha(p) : '') + (when ? ' ' + when : '') + ' · ' + next; + } + function stageTrackerPushChipHtml(item, nowMs) { + const text = stageTrackerPushChipText(item, nowMs); + if (!text || stageTrackerPushOnLineage(item)) return ''; + const p = stageTrackerPushOf(item); + const tip = stageTrackerPushTip(item, nowMs); + const attrs = `class="ham-badge ham-badge-waiting ham-badge-push" title="${esc(tip)}" aria-label="${esc(tip)}"`; + return p.url ? `${esc(text)}` : `${esc(text)}`; } // Rework pickup on a returned PR (`rework`: {state, actor, requested_at, diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index bc2b8b0576..71cf574000 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -1598,6 +1598,12 @@ .ham-badge-overlap { color: var(--text-faint); border-color: var(--line-subtle); } /* Waiting-on pill without an adoption clock (071, 072 before the nudge, a human's PR): muted, hive PR 15051. */ .ham-badge-waiting { color: var(--text-faint); border-color: var(--line-subtle); } + /* Push progress on the waiting-on pill (hive PR 15784): the wait's age + rides last; past dashboard.stage_tracker.waiting_push_stale_h it takes + the muted warning tone. "@zoe pushed abc1234 · 2m" links to the commit. */ + .ham-push-stale { color: color-mix(in srgb, var(--status-warn) 70%, var(--text-faint)); } + .ham-badge-push { text-decoration: none; } + .ham-badge-push:hover { color: var(--text-muted); } /* Presence indicator on a waiting-on pill (hive PR 15051): who the row waits on, drawn as the same glyphs the stage chevrons use — a person for a human (nothing more: a human has no presence to report) or the @@ -16033,8 +16039,94 @@

    Where to get help

    const p = stageTrackerPresenceOf(item); if (!p || stageTrackerAdoptionTip(item)) return ''; const ptip = stageTrackerPresenceTip(item, Date.now()); - const tip = typeof stageTrackerReworkJoinTip === 'function' ? stageTrackerReworkJoinTip(ptip, item, Date.now()) : ptip; - return `${stageTrackerPresenceInPillHtml(item, stageTrackerPresenceChipText(item))}`; + const rtip = typeof stageTrackerReworkJoinTip === 'function' ? stageTrackerReworkJoinTip(ptip, item, Date.now()) : ptip; + // The wait's age rides last on the pill, muted-amber once stale + // (hivecommons/hive#15784). Guarded: the harnesses load by name. + const wait = typeof stageTrackerPushWaitHtml === 'function' ? stageTrackerPushWaitHtml(item, Date.now()) : ''; + const wtip = typeof stageTrackerPushTip === 'function' ? stageTrackerPushTip(item, Date.now()) : ''; + const tip = wtip ? rtip + ' · ' + wtip : rtip; + return `${stageTrackerPresenceInPillHtml(item, stageTrackerPresenceChipText(item))}${wait}`; + } + + // Push progress on a CI / Review row (`push`: {state, login, since, sha, + // url, next, stale} — hivecommons/hive#15784). The chevron keeps the + // stage; the gray pill carries the push: + // waiting — the hive waits for the author's push; the pill ends with + // the wait's age ("waiting on @zoe to push · 38m"), amber + // once past dashboard.stage_tracker.waiting_push_stale_h. + // pushed — a head landed and CI / the re-review for it still run: + // "@zoe pushed abc1234 · 2m" (links to the commit); on an + // adopted row the lineage chip says "· pushed 2m ago" + // instead. The presence marker goes: the ball is back with + // the hive. + const STAGE_TRACKER_PUSH_NEXT = { ci: 'CI running', 're-review': 're-review queued' }; + function stageTrackerPushOf(item) { + const p = item && item.kind === 'pr' ? item.push : null; + if (!p || (p.state !== 'waiting' && p.state !== 'pushed')) return null; + return p; + } + // Pure: whether the author's push has landed — the row is the hive's again. + function stageTrackerPushedBack(item) { + const p = stageTrackerPushOf(item); + return !!(p && p.state === 'pushed'); + } + // Pure: the short age of the state ("38m", "2h"); '' without a time. + function stageTrackerPushAge(p, nowMs) { + const at = Date.parse((p && p.since) || ''); + return at > 0 ? stageTrackerAgoText(at, nowMs).replace(/ ago$/, '') : ''; + } + function stageTrackerPushSha(p) { + return String((p && p.sha) || '').slice(0, 7); + } + // " · 38m" for the waiting pill, the age wrapped so a stale wait can take + // the muted-amber tone; '' unless the row waits. + function stageTrackerPushWaitHtml(item, nowMs) { + const p = stageTrackerPushOf(item); + if (!p || p.state !== 'waiting') return ''; + const age = stageTrackerPushAge(p, nowMs); + if (!age) return ''; + return ' · ' + esc(age) + ''; + } + // Pure: "@zoe pushed abc1234 · 2m"; '' unless the push landed. + function stageTrackerPushChipText(item, nowMs) { + const p = stageTrackerPushOf(item); + if (!p || p.state !== 'pushed') return ''; + const sha = stageTrackerPushSha(p); + const age = stageTrackerPushAge(p, nowMs); + return (p.login ? '@' + p.login + ' ' : '') + 'pushed' + (sha ? ' ' + sha : '') + (age ? ' · ' + age : ''); + } + // Pure: whether the row's lineage chip (adopted / rebased copy) carries + // the push instead of a pill of its own. + function stageTrackerPushOnLineage(item) { + const l = item && item.lineage; + return !!(l && l.kind && l.kind !== 'superseded' && Number(l.from_number) > 0); + } + // Pure: " · pushed 2m ago" for the lineage chip; '' unless pushed. + function stageTrackerPushLineageSuffix(item, nowMs) { + const p = stageTrackerPushOf(item); + if (!p || p.state !== 'pushed' || !stageTrackerPushOnLineage(item)) return ''; + const at = Date.parse(p.since || ''); + const ago = at > 0 ? stageTrackerAgoText(at, nowMs) : ''; + return ' · pushed' + (ago ? ' ' + ago : ''); + } + // Pure: the hover line — how long the hive has waited, or what the push queued. + function stageTrackerPushTip(item, nowMs) { + const p = stageTrackerPushOf(item); + if (!p) return ''; + const at = Date.parse(p.since || ''); + const when = at > 0 ? stageTrackerAgoText(at, nowMs) + ' (' + agentNowClockTime(at, nowMs) + ')' : ''; + const who = p.login ? '@' + p.login : 'the author'; + if (p.state === 'waiting') return 'waiting for ' + who + ' to push' + (when ? ' since ' + when : '') + (p.stale ? ' · no push for a long time' : ''); + const next = STAGE_TRACKER_PUSH_NEXT[p.next] || STAGE_TRACKER_PUSH_NEXT.ci; + return who + ' pushed' + (stageTrackerPushSha(p) ? ' ' + stageTrackerPushSha(p) : '') + (when ? ' ' + when : '') + ' · ' + next; + } + function stageTrackerPushChipHtml(item, nowMs) { + const text = stageTrackerPushChipText(item, nowMs); + if (!text || stageTrackerPushOnLineage(item)) return ''; + const p = stageTrackerPushOf(item); + const tip = stageTrackerPushTip(item, nowMs); + const attrs = `class="ham-badge ham-badge-waiting ham-badge-push" title="${esc(tip)}" aria-label="${esc(tip)}"`; + return p.url ? `${esc(text)}` : `${esc(text)}`; } // Rework pickup on a returned PR (`rework`: {state, actor, requested_at, @@ -16277,7 +16369,11 @@

    Where to get help

    const anchor = stageTrackerAnchor(cur, stages, item.via_pr ? 'pr' : item.kind, item); const terminal = anchor >= STAGE_TRACKER_TERMINAL; const sentinelLane = stageTrackerSentinelInLane(item); - const detour = (!terminal && STAGE_TRACKER_PATH.indexOf(cur) < 0 && cur !== STAGE_TRACKER_TRIAGE_NEEDED && cur !== STAGE_TRACKER_POSSIBLY_EXISTS && cur !== 40 && cur !== 60 && cur !== STAGE_TRACKER_PRE_MERGE_SOAK && cur !== 100) + // A 071 / 072 row whose author has pushed is back with the hive: the + // chevron reads the column's own word ("CI / Review"), not "Needs + // @author" (hivecommons/hive#15784). Guarded: the harnesses load by name. + const pushedBack = (cur === 71 || cur === 72) && typeof stageTrackerPushedBack === 'function' && stageTrackerPushedBack(item); + const detour = (!terminal && !pushedBack && STAGE_TRACKER_PATH.indexOf(cur) < 0 && cur !== STAGE_TRACKER_TRIAGE_NEEDED && cur !== STAGE_TRACKER_POSSIBLY_EXISTS && cur !== 40 && cur !== 60 && cur !== STAGE_TRACKER_PRE_MERGE_SOAK && cur !== 100) ? { text: sentinelLane ? STAGE_TRACKER_SENTINEL_WORD : (cur === STAGE_TRACKER_HUMAN_GATED && typeof stageTrackerTrainWord === 'function' && stageTrackerTrainWord(item)) || (cur === STAGE_TRACKER_READY_FOR_HUMAN_MERGE && item.manual_merge ? stageTrackerManualMergeWord(item) : (cur === STAGE_TRACKER_HUMAN_GATED && stageTrackerUnauthorizedWord(item)) || (typeof stageTrackerBlockerWord === 'function' && cur === STAGE_TRACKER_ISSUE_NEEDS_DECISION && stageTrackerBlockerWord(item)) || ((cur === STAGE_TRACKER_ADOPTED_BY_HIVE || (cur === STAGE_TRACKER_HUMAN_GATED && item.adopted_by_state)) && stageTrackerAdoptedWord(item)) || (cur === STAGE_TRACKER_READY_FOR_HUMAN_MERGE && stageTrackerReadyForHumanWord(item, STAGE_TRACKER_ACTIVE_WORD[cur] || curStage.short || curStage.label || String(cur))) || (STAGE_TRACKER_ACTIVE_WORD[cur] || curStage.short || curStage.label || String(cur))), sentinel: sentinelLane } : null; if (detour && cur === 70 && !detour.sentinel && typeof stageTrackerFixingWord === 'function') detour.text = stageTrackerFixingWord(item, detour.text); if (detour && (cur === 71 || cur === 72) && typeof stageTrackerReturnedWord === 'function') { @@ -16767,6 +16863,8 @@

    Where to get help

    if (presence) lines.push('Presence: ' + presence); const rework = typeof stageTrackerReworkTip === 'function' ? stageTrackerReworkTip(item, nowMs) : ''; if (rework) lines.push('Rework: ' + rework); + const push = typeof stageTrackerPushTip === 'function' ? stageTrackerPushTip(item, nowMs) : ''; + if (push) lines.push('Push: ' + push); if (mods.length) lines.push('Flags: ' + mods.map(m => STAGE_TRACKER_MOD_TEXT[m] || m).join(', ')); const stale = stageTrackerStaleLabelsText(item); if (stale) lines.push(stale); @@ -16831,7 +16929,7 @@

    Where to get help

    } function stageTrackerChipsHtml(item) { - const sentinel = stageTrackerSentinelChipHtml(item) + (typeof stageTrackerAdoptionChipHtml === 'function' ? stageTrackerAdoptionChipHtml(item) : '') + (typeof stageTrackerPresenceChipHtml === 'function' ? stageTrackerPresenceChipHtml(item) : '') + (typeof stageTrackerReroutePillHtml === 'function' ? stageTrackerReroutePillHtml(item) : '') + (typeof stageTrackerSupersedesChipHtml === 'function' ? stageTrackerSupersedesChipHtml(item, Date.now()) : '') + (typeof stageTrackerOverlapBadgeHtml === 'function' ? stageTrackerOverlapBadgeHtml(item) : ''); + const sentinel = stageTrackerSentinelChipHtml(item) + (typeof stageTrackerAdoptionChipHtml === 'function' ? stageTrackerAdoptionChipHtml(item) : '') + (typeof stageTrackerPresenceChipHtml === 'function' ? stageTrackerPresenceChipHtml(item) : '') + (typeof stageTrackerPushChipHtml === 'function' ? stageTrackerPushChipHtml(item, Date.now()) : '') + (typeof stageTrackerReroutePillHtml === 'function' ? stageTrackerReroutePillHtml(item) : '') + (typeof stageTrackerSupersedesChipHtml === 'function' ? stageTrackerSupersedesChipHtml(item, Date.now()) : '') + (typeof stageTrackerOverlapBadgeHtml === 'function' ? stageTrackerOverlapBadgeHtml(item) : ''); const mods = (Array.isArray(item.modifiers) ? item.modifiers.slice() : []) .sort((x, y) => STAGE_TRACKER_MOD_PRIORITY.indexOf(x) - STAGE_TRACKER_MOD_PRIORITY.indexOf(y)); if (!mods.length) return sentinel; @@ -17168,7 +17266,7 @@

    Where to get help

    stage: lp.stage || 0, stage_since: lp.stage_since || '', stage_slug: lp.stage_slug || '', modifiers: lp.modifiers || [], deferred_modifiers: lp.deferred_modifiers || [], caption: lp.caption || '', reason: lp.reason || '', human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', base_ref: lp.base_ref || '', decision_needed: lp.decision_needed || null, adoption: lp.adoption || null, takeover: lp.takeover || null, superseded: !!lp.superseded, supersedes: lp.supersedes || null, parent: Number(issue.number) || 0, siblings: open.map(x => Number(x.number) || 0), - last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || null, + last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, push: lp.push || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || null, decided: lp.decided || null, adopted_by: Number(lp.adopted_by) || 0, adopted_by_state: lp.adopted_by_state || '', adopted_from: lp.adopted_from || null, lineage: lp.lineage || null, state: lp.state || '', superseded_by: Number(lp.superseded_by) || 0 }; } // Pure: whether a linked PR is still open (not merged / closed / @@ -17214,7 +17312,10 @@

    Where to get help

    const l = item && item.lineage; if (!l || !l.kind) return ''; const ago = stageTrackerAgoText(Date.parse(l.at || ''), nowMs).replace(/ ago$/, ''); - const tail = ago ? ' · ' + ago : ''; + // Once the head moves the chip says so instead of the adoption's age: + // "adopted from @x's #N · pushed 2m ago" (hivecommons/hive#15784). + const pushed = typeof stageTrackerPushLineageSuffix === 'function' ? stageTrackerPushLineageSuffix(item, nowMs) : ''; + const tail = pushed || (ago ? ' · ' + ago : ''); if (l.kind === 'superseded') return Number(l.to_number) > 0 ? 'superseded by #' + Number(l.to_number) + tail : ''; if (!(Number(l.from_number) > 0)) return ''; const whose = l.from_author ? '@' + l.from_author + "'s " : ''; @@ -17542,7 +17643,7 @@

    Where to get help

    const who = (lp.author_kind || 'hive') + (lp.author ? ' · @' + lp.author : ''); prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRPillsHtml(stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)), (lp.lineage && typeof stageTrackerLineageChipHtml === 'function' ? stageTrackerLineageChipHtml(lp, nowMs) : '') || (typeof stageTrackerAdoptedFromChipHtml === 'function' ? stageTrackerAdoptedFromChipHtml(lp, nowMs) : '') || null, lp.base_ref)]; shown = Object.assign({}, item, { via_pr: true, stage: stageTrackerLeadStage(lp), stage_since: lp.stage_since || item.stage_since, modifiers: lp.modifiers || item.modifiers, deferred_modifiers: lp.deferred_modifiers || item.deferred_modifiers || [], caption: lp.caption || item.caption, reason: lp.reason || item.reason, - human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', decision_needed: lp.decision_needed || null, hold: lp.hold || null, adoption: lp.adoption || null, stage_actor: lp.stage_actor || item.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || null, decided: lp.decided || item.decided || null }); + human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', decision_needed: lp.decision_needed || null, hold: lp.hold || null, adoption: lp.adoption || null, stage_actor: lp.stage_actor || item.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, push: lp.push || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || null, decided: lp.decided || item.decided || null }); } else if (linked.length) { // Several covering PRs: the issue strip ends at Claimed, all passed // and nothing lit; one sub-row per PR carries the live chevron. diff --git a/src/pkg/dashboard/webhook_tracker_refresh.go b/src/pkg/dashboard/webhook_tracker_refresh.go index 2bd5ef64c2..74d042e218 100644 --- a/src/pkg/dashboard/webhook_tracker_refresh.go +++ b/src/pkg/dashboard/webhook_tracker_refresh.go @@ -8,6 +8,7 @@ import ( "github.com/hivecommons/hive/pkg/config" "github.com/hivecommons/hive/pkg/github" + "github.com/hivecommons/hive/pkg/stagelabels" ) // webhookTrackerRefresh is the activity-monitor half of a GitHub webhook @@ -352,6 +353,7 @@ func (s *Server) applyWebhookItemSnapshots(snaps []github.WebhookItemSnapshot) i return 0 } s.recordMergedSnapshots(snaps) + s.notePushedSnapshots(snaps) if s.deps != nil && s.deps.ApplyWebhookItems != nil { s.deps.ApplyWebhookItems(snaps) } @@ -404,6 +406,28 @@ func (s *Server) applyWebhookItemSnapshots(snaps []github.WebhookItemSnapshot) i return changed } +// notePushedSnapshots books the head each open PR re-read reports on its +// stage record (stagelabels.Store.NotePush) so a `pull_request` synchronize +// delivery shows as "pushed abc1234" on the activity monitor at once, ahead +// of the enumerate that re-stages the PR (hivecommons/hive#15784). Reads +// whose head the store already knows change nothing; the store decides. +func (s *Server) notePushedSnapshots(snaps []github.WebhookItemSnapshot) int { + store := s.stageStoreOrShared() + if store == nil { + return 0 + } + booked := 0 + for _, snap := range snaps { + if !snap.IsPR || !snap.Open() || snap.HeadSHA == "" { + continue + } + if store.NotePush(stagelabels.Key(snap.Repo, snap.Number), snap.HeadSHA, snap.FetchedAt) { + booked++ + } + } + return booked +} + // snapshotOlderThanListed reports whether the listed copy of the snapshot's // item carries a later updated_at than the read: the read is stale. func snapshotOlderThanListed(repo FrontendRepo, snap github.WebhookItemSnapshot) bool { diff --git a/src/pkg/stagelabels/push_test.go b/src/pkg/stagelabels/push_test.go new file mode 100644 index 0000000000..5742958e83 --- /dev/null +++ b/src/pkg/stagelabels/push_test.go @@ -0,0 +1,135 @@ +package stagelabels + +import ( + "path/filepath" + "testing" + "time" +) + +// TestStoreNotePushWebhook: the webhook re-read of a synchronize delivery +// books a push once the record knows a head, ignores the head it already +// knows, and is dropped by a fresh waiting-on-push state +// (hivecommons/hive#15784). +func TestStoreNotePushWebhook(t *testing.T) { + now := time.Date(2026, 10, 30, 9, 0, 0, 0, time.UTC) + s := NewStore(filepath.Join(t.TempDir(), "stage.json"), func() time.Time { return now }) + key := Key("acme/widget", 15516) + if s.NotePush(key, "bbb2222", now) { + t.Fatal("NotePush must not create a record") + } + s.Observe(key, NeedsAuthor, "ci-red") + rec, _ := s.Get(key) + if !rec.WaitingPushSince.Equal(now) { + t.Fatalf("entering 071 must start the waiting clock, got %+v", rec) + } + if s.NotePush(key, "aaa1111", now) { + t.Fatal("a head the store has never seen is the initial head, not a push") + } + s.NoteActivity(key, Activity{Head: "aaa1111", Comments: -1, Reviews: -1}) + if s.NotePush(key, "AAA1111", now) { + t.Fatal("the known head is not a push") + } + pushAt := now.Add(2 * time.Minute) + now = now.Add(3 * time.Minute) + s.dirty = false + if !s.NotePush(key, " bbb2222 ", pushAt) { + t.Fatal("a new head is a push") + } + rec, _ = s.Get(key) + if rec.LastPushSha != "bbb2222" || !rec.LastPushAt.Equal(pushAt) || !rec.PushedSinceWaiting() || !s.dirty { + t.Fatalf("push not booked: %+v dirty=%v", rec, s.dirty) + } + if s.NotePush(key, "bbb2222", now) { + t.Fatal("the same push twice is one push") + } + // A future instant reads as now. + s.NotePush(key, "ccc3333", now.Add(time.Hour)) + if rec, _ := s.Get(key); !rec.LastPushAt.Equal(now) || rec.LastPushSha != "ccc3333" { + t.Fatalf("future push instant must clamp to now: %+v", rec) + } + // The sweep re-stages the PR to 070 on the pushed head: the push stays + // on record, the waiting clock stops. + s.Observe(key, ReviewPending, "ci-pending") + s.NoteActivity(key, Activity{Head: "ccc3333", Comments: -1, Reviews: -1}) + rec, _ = s.Get(key) + if rec.LastPushSha != "ccc3333" || !rec.WaitingPushSince.IsZero() || !rec.PushedSinceWaiting() { + t.Fatalf("leaving 071 for 070 must keep the push and stop the clock: %+v", rec) + } + // Admission leaves the CI / Review column: nothing to show any more. + s.Observe(key, AwaitingMergeAdmission, "green") + if rec, _ := s.Get(key); rec.LastPushSha != "" || !rec.LastPushAt.IsZero() { + t.Fatalf("leaving the column must drop the push: %+v", rec) + } + if s.NotePush(key, "ddd4444", now) { + t.Fatal("a push outside the CI / Review column is not tracked") + } +} + +// TestStoreNotePushEnumerateFallback: with no webhook, the head change the +// next enumerate observes books the push; the same head seen again does +// not; a head the sweep still routes back to the author starts a new +// waiting-on-push state instead. +func TestStoreNotePushEnumerateFallback(t *testing.T) { + now := time.Date(2026, 10, 30, 9, 0, 0, 0, time.UTC) + s := NewStore(filepath.Join(t.TempDir(), "stage.json"), func() time.Time { return now }) + key := Key("acme/widget", 15517) + s.Observe(key, ReviewPending, "ci-pending") + s.NoteActivity(key, Activity{Head: "aaa1111", Comments: -1, Reviews: -1}) + if rec, _ := s.Get(key); rec.LastPushSha != "" { + t.Fatalf("the first head is not a push: %+v", rec) + } + seen := now.Add(5 * time.Minute) + now = now.Add(6 * time.Minute) + s.Observe(key, ReviewPending, "ci-pending") + s.NoteActivity(key, Activity{Head: "bbb2222", At: seen, Comments: -1, Reviews: -1}) + rec, _ := s.Get(key) + if rec.LastPushSha != "bbb2222" || !rec.LastPushAt.Equal(seen) { + t.Fatalf("enumerate head change must book the push: %+v", rec) + } + s.Observe(key, ReviewPending, "ci-pending") + s.NoteActivity(key, Activity{Head: "bbb2222", Comments: -1, Reviews: -1}) + if rec, _ := s.Get(key); !rec.LastPushAt.Equal(seen) { + t.Fatalf("re-seeing the pushed head must not move the push: %+v", rec) + } + // The webhook announced ccc3333 first; the enumerate that follows must + // not book it a second time. + webhookAt := now + now = now.Add(time.Minute) + s.NotePush(key, "ccc3333", webhookAt) + s.Observe(key, ReviewPending, "ci-pending") + s.NoteActivity(key, Activity{Head: "ccc3333", Comments: -1, Reviews: -1}) + if rec, _ := s.Get(key); !rec.LastPushAt.Equal(webhookAt) { + t.Fatalf("enumerate after the webhook must keep the webhook's instant: %+v", rec) + } + // CI went red on ccc3333: 071. The waiting clock starts, the push is + // history. + s.Observe(key, NeedsAuthor, "ci-red") + rec, _ = s.Get(key) + if !rec.WaitingPushSince.Equal(now) || rec.LastPushSha != "" || rec.PushedSinceWaiting() { + t.Fatalf("entering 071 must reset the push state: %+v", rec) + } + // The author pushes ddd4444, the sweep evaluates it and still says 071: + // a new waiting-on state on the new head, not a push in progress. + s.NotePush(key, "ddd4444", now) + if rec, _ := s.Get(key); !rec.PushedSinceWaiting() { + t.Fatalf("webhook push while waiting must read as pushed: %+v", rec) + } + later := now.Add(10 * time.Minute) + now = later + s.Observe(key, NeedsAuthor, "ci-red") + s.NoteActivity(key, Activity{Head: "ddd4444", Comments: -1, Reviews: -1}) + rec, _ = s.Get(key) + if !rec.WaitingPushSince.Equal(later) || rec.LastPushSha != "" || rec.PushedSinceWaiting() { + t.Fatalf("a head still routed to the author must start a new waiting state: %+v", rec) + } + if err := s.Save(); err != nil { + t.Fatal(err) + } + reloaded := NewStore(s.path, func() time.Time { return now }) + if err := reloaded.Load(); err != nil { + t.Fatal(err) + } + if rec, ok := reloaded.Get(key); !ok || !rec.WaitingPushSince.Equal(later) { + t.Fatalf("waiting clock must survive a reload: %+v ok=%v", rec, ok) + } +} diff --git a/src/pkg/stagelabels/stagelabels.go b/src/pkg/stagelabels/stagelabels.go index ee6f36e62e..fc99af8529 100644 --- a/src/pkg/stagelabels/stagelabels.go +++ b/src/pkg/stagelabels/stagelabels.go @@ -279,6 +279,24 @@ var Table = []Definition{ {Stage: MergeQueue, Number: MergeQueueNumber, Slug: "merge-queue", Description: "Lane admitted and soak complete: merge-eligible, waiting for tide / the merge window", Dwell: 3 * time.Hour, PR: true}, } +// WaitsOnPush reports whether s is a stage where the hive waits for the +// author (or their clanker) to push: 071 needs-author and 072 +// returned-to-contributor (hivecommons/hive#15784). +func (s Stage) WaitsOnPush() bool { + return s == NeedsAuthor || s == ReturnedToContributor +} + +// TracksPush reports whether s sits in the CI / Review column, where a head +// change is progress the dashboard shows as "pushed" until CI and the +// re-review for that head settle (hivecommons/hive#15784). +func (s Stage) TracksPush() bool { + switch s { + case ReviewPending, Reviewed, Fixing, NeedsAuthor, ReturnedToContributor, AdoptedByHive: + return true + } + return false +} + // FixingStageFor is the "author must act" stage for a red or blocked PR by // who wrote it: the hive's own PR (selfAuthored, or author/hive) goes to 070 // fixing — a hive agent reworks it; an author/clanker PR goes to 072 diff --git a/src/pkg/stagelabels/store.go b/src/pkg/stagelabels/store.go index 932ab9129a..9b8db788d9 100644 --- a/src/pkg/stagelabels/store.go +++ b/src/pkg/stagelabels/store.go @@ -324,6 +324,20 @@ type Record struct { // HiveHeldWarned is set once the hive-side alert for an item held by // the hive past its dwell has been logged; activity resets it. HiveHeldWarned bool `json:"hive_held_warned,omitempty"` + // WaitingPushSince is when the current waiting-on-push state began + // (hivecommons/hive#15784): entry to 071 / 072, or a head the sweep + // evaluated and still routed back to the author. The dashboard ages + // the "waiting on @author to push" pill from it. Zero outside those + // stages. + WaitingPushSince time.Time `json:"waiting_push_since,omitempty"` + // LastPushAt / LastPushSha record the last head change seen while the + // item sat in the CI / Review column: from the webhook re-read of a + // `pull_request` synchronize delivery (NotePush) or, as the fallback, + // from the head change the next enumerate observed (NoteActivity). A + // new waiting-on-push state clears them; leaving the column clears + // them too. + LastPushAt time.Time `json:"last_push_at,omitempty"` + LastPushSha string `json:"last_push_sha,omitempty"` // LabelsSuppressed is set when the write-back gate kept the stage // labels off the item on GitHub (a contributor PR without the opt-in // label): the stage lives in this record only, so a label-less item @@ -651,6 +665,7 @@ func (s *Store) ObserveProgress(key string, stage Stage, reason string, progress next.StallCommented = false next.EntryCommented = false tr.Changed = true + next.notePushStageChange(now) } else if ReasonClass(prev.Reason) != ReasonClass(reason) { next.ReasonChangedAt = now } @@ -763,6 +778,18 @@ func (s *Store) NoteActivity(key string, a Activity) (changed bool) { if changed && at.After(r.LastActivityAt) { r.LastActivityAt = at } + if a.Head != "" && r.ActivityHead != "" && a.Head != r.ActivityHead { + // The enumerate fallback for a push no webhook announced + // (hivecommons/hive#15784). A head the sweep evaluated and still + // routed back to the author starts a fresh waiting-on-push state. + switch { + case r.Stage.WaitsOnPush(): + r.WaitingPushSince = at + r.LastPushAt, r.LastPushSha = time.Time{}, "" + case a.Head != r.LastPushSha: + r.LastPushAt, r.LastPushSha = at, a.Head + } + } if changed { r.HiveHeldWarned = false } @@ -784,6 +811,66 @@ func (s *Store) NoteActivity(key string, a Activity) (changed bool) { return changed } +// notePushStageChange keeps the push-progress fields in step with a stage +// change (hivecommons/hive#15784): entering 071 / 072 starts a fresh +// waiting-on-push state (a push before it is history), leaving them keeps +// the push on record so the row can say "pushed abc1234" while CI and the +// re-review run, and leaving the CI / Review column drops it all. +func (r *Record) notePushStageChange(now time.Time) { + switch { + case r.Stage.WaitsOnPush(): + r.WaitingPushSince = now + r.LastPushAt, r.LastPushSha = time.Time{}, "" + case r.Stage.TracksPush(): + r.WaitingPushSince = time.Time{} + default: + r.WaitingPushSince = time.Time{} + r.LastPushAt, r.LastPushSha = time.Time{}, "" + } +} + +// NotePush records that key's head moved to sha at the given instant, as a +// webhook re-read of a `pull_request` synchronize delivery saw it +// (hivecommons/hive#15784). It reports whether a push was booked: a head the +// store already knows (the enumerate's ActivityHead, or the last push) is +// not one, and nothing is booked for a record whose head was never seen +// — a first read cannot tell a push from the initial head. A zero or +// future instant reads as now. +func (s *Store) NotePush(key, sha string, at time.Time) bool { + sha = strings.TrimSpace(sha) + if sha == "" { + return false + } + s.mu.Lock() + defer s.mu.Unlock() + r, ok := s.items[key] + if !ok || !r.Stage.TracksPush() { + return false + } + known := r.ActivityHead + if r.LastPushSha != "" { + known = r.LastPushSha + } + if known == "" || strings.EqualFold(sha, known) { + return false + } + now := s.now() + if at.IsZero() || at.After(now) { + at = now + } + r.LastPushAt, r.LastPushSha = at, sha + s.items[key] = r + s.dirty = true + return true +} + +// PushedSinceWaiting reports whether a push landed after the current +// waiting-on-push state began: the ball is back with the hive even if the +// sweep has not re-staged the item yet. +func (r Record) PushedSinceWaiting() bool { + return !r.LastPushAt.IsZero() && !r.LastPushAt.Before(r.WaitingPushSince) +} + // CountOwnComments records that the hive itself posted n comments on key, // so the next observed comment count does not read as outside activity. // The credit sits on top of the last count NoteActivity stored, so it must