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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/added-15051-waiting-presence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor waiting-on pills and PR sub-rows show clanker presence with accessible shapes, last-seen details, and the adoption deadline; human authors remain waiting for a reply ([#15051](https://github.com/hivecommons/hive/issues/15051)).
11 changes: 11 additions & 0 deletions src/docs/dashboard-sections.md
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,17 @@ Fed by `GET /api/stage-tracker`. Every issue and pull request follows the same p

**Multi-select.** The checkbox in a row's left gutter selects the row — and the checkbox in a nested PR sub-row's gutter selects that PR on its own, so one or more PRs under an issue can be picked without the issue or each other; **Shift+click** selects the range from the last clicked row (sub-rows are in the range order right after their issue), **Cmd/Ctrl+click** toggles, **Cmd/Ctrl+Shift+click** adds a range to what is selected; with a row focused, **Space** toggles it (Shift+Space extends). Cmd/Ctrl- or Shift-clicking the row itself, away from its links, selects it too. A selection bar appears above the list with the count, **Clear**, and the same actions for the whole selection — *Decide…* (opens the group as a menu, *Let hive decide* first — each selected row gets its own delegated-decision job, see below), **Let hive decide (N selected)** (one click for the whole selection: one delegated-decision job per selected item, each nested PR sub-row by its own number, with one summary toast — "3 sent · 2 decided · 1 no-op", plus "· 1 failed" when any failed — and the per-action confirm / *Don't ask again* of *Let hive decide*), *Hold*, *Release hold*, *Re-evaluate now*, *Mark needs-human…*, *Copy links* — each enabled only when it is valid for every selected row and otherwise greyed with the first reason ("Not applicable to acme/console#12", "Sign in with write access…"). Right-clicking a selected row acts on the whole selection. Bulk actions run one request per row, in list order, under a progress toast ("Hold 2/5 — acme/console#12…"); the result toast lists each failure by row and the successes stand, after which the list and the status snapshot refresh (a hive-wide rescan is sent once per batch). Selection is keyed on the row's item (repository, kind, number), not its node, so the live re-render keeps it; a row that leaves the list — merged, closed, filtered or paged out — leaves the selection.

**Waiting-on presence.** A PR at 071 (Needs author) or 072 (Returned to contributor)
shows a presence shape before the named author in its waiting-on pill, including
covering PR sub-rows. A filled dot means a registered clanker is online, a square
means it is offline, and a hollow ring means no clanker is registered (or presence
is unavailable, explicitly named in the tooltip). Human authors without a clanker
read `human · no clanker`. The tooltip and accessible label give the last heartbeat,
offline age, and the expected adoption time once a current-head nudge has started
that clock. Human PRs always wait for a reply. Named-author Needs-human popovers
repeat the indicator. Presence refreshes with the tracker; only the online dot
breathes, and reduced-motion disables that animation.

**Needs-human decision popover.** Hovering — or, by keyboard, focusing — the *Needs human decision* chevron word on a row (an issue at 045, a PR at 085, an issue whose nested PR is parked there) or a lead *needs-human* / *triage needed* pill opens an in-app popover (no native tooltip on that element) that says, in this order: **what the row is waiting on** — the reviewer's own question when the hive has one (the text the hive's "Needs a decision" comment on the PR prints after *reviewer question:*, read from the same verdict record), else a plain-words sentence for the park reason, plus the blocker in plain words ("A reviewer requested changes on b0f5f80 — needs a new commit. Approving cannot override that."); **what you can do** — one button per applicable action, *Let hive decide* first, then Approve / Give direction / Close as superseded / Close as won't fix / Hold or Release hold (an issue at 015: Accept triage, Hold, Mark needs-human), each disabled with its reason when the row's state or your role rules it out; **who asked and when** ("Asked by a reviewer · 2 hours ago"); then the chevron's stage line. The buttons run the row context menu's code path, so the same result toast and in-flight chevron apply. The popover stays open while the pointer is over it or its trigger, pins on click or focus, and closes on Esc (focus returns to the trigger), click-away, scroll or resize. The text comes from the tracker payload's `decision_needed` (`question`, `asked_by`, `since`, `blocker`, `blocker_reason`, `options[] {action, label, enabled, reason_if_disabled}`), whose `action` ids are the context menu's own (`decide:delegate`, `decide:approve`, …).

**Cue tokens.** The three cues of the legend above (state pill, working spin, decision badge) share one `tracker-cues` CSS block on `.ham-row`: `--cue-state` (what the row waits on — the pill and this popover), `--cue-work` (the hive is working right now — the chevron spin), `--cue-decision` (what people and the hive decided — the ✓ badge). Nothing else blinks; motion stays in the 150–300 ms range.
Expand Down
12 changes: 12 additions & 0 deletions src/docs/labels-and-control-signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,18 @@ When a clanker-authored contributor PR goes red the hive does not just relabel i
stage transitions and simply wait at 071 for a push or a comment: no
nudge, no adoption, no extra comment
([Stage 07x by author kind](#stage-07x-by-author-kind)).
The Activity Monitor exposes the same hub presence on 071 and 072 waiting-on
pills and linked PR sub-rows, even before a nudge. Its `presence` payload names
`login`, `kind` (human/clanker), `state` (online/offline/unknown), `since`,
`last_seen`, and `next` (wait/adopt), with `adopt_at` when a current-head nudge
makes adoption predictable. `available: false` means presence could not be read;
it does not claim that the author has no registered profile. The deadline uses
the adoption engine's clock: online grace from the first nudge, `after_offline`
from the later heartbeat or nudge, or `after_unregistered` from the nudge.
Before the first nudge, after a head change, with adoption disabled or held, and
for human-authored PRs, the pill promises no adoption time. An existing adoption
hold still shows its reason and the owner's Adopt decision when applicable.

3. If the author stays unavailable the hive adopts the PR
(`governor.labels.stage.adoption.enabled`, default `true`). "Unavailable"
is decided against the contributor's **live** presence on the hub at
Expand Down
10 changes: 7 additions & 3 deletions src/pkg/dashboard/stage_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ type StageTrackerItem struct {
// what holds it, and the author's live presence, with the plain-words
// line the row shows instead of a bare "Returned to contributor"
// (hivecommons/hive#14524).
Adoption *StageTrackerAdoption `json:"adoption,omitempty"`
Adoption *StageTrackerAdoption `json:"adoption,omitempty"`
Presence *StageTrackerPersonPresence `json:"presence,omitempty"`
// ClaimantKind is the author kind of whoever holds the live claim on a
// claimed issue (human / clanker / hive), from the worker-claim ledger.
ClaimantKind string `json:"claimant_kind,omitempty"`
Expand Down Expand Up @@ -487,7 +488,8 @@ type StageTrackerLinkedPR struct {
// sub-row can open the same "Needs human" popover.
DecisionNeeded *StageTrackerDecision `json:"decision_needed,omitempty"`
// Adoption mirrors the nested PR's own row field (hivecommons/hive#14524).
Adoption *StageTrackerAdoption `json:"adoption,omitempty"`
Adoption *StageTrackerAdoption `json:"adoption,omitempty"`
Presence *StageTrackerPersonPresence `json:"presence,omitempty"`
// LastOperatorAction / OperatorActionCount mirror the nested PR's own
// row fields so its sub-row wears the ✓ badge too.
LastOperatorAction *StageTrackerOperatorAction `json:"last_operator_action,omitempty"`
Expand Down Expand Up @@ -1543,7 +1545,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto
}
return store.Get(stagelabels.Key(repo, number))
}
presence, maintainerPolicy := s.stageTrackerPresence(), s.stageTrackerMaintainerPolicy()
presence, maintainerPolicy := cachedStageTrackerPresence(s.stageTrackerPresence()), s.stageTrackerMaintainerPolicy()
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
Expand Down Expand Up @@ -1602,6 +1604,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto
}
it.Modifiers = slices.DeleteFunc(it.Modifiers, func(m string) bool { return m == modNeedsTriage })
}
it.Presence = s.stageTrackerPersonPresence(*it, rec, hasRec, presence)
it.Caption, it.Actor = stageTrackerCaption(stage, it.Reason, it.Author, it.Kind, it.Mirrored, rec, hasRec, it.LinkedPR, it.Head)
// Adoption is clanker-only (a human's PR is never adopted), so a
// human-authored 072 row keeps its plain caption.
Expand Down Expand Up @@ -2502,6 +2505,7 @@ func stageTrackerResolveLinkedPRs(items []StageTrackerItem) {
lp.StageSince, lp.Caption = pr.StageSince, pr.Caption
lp.SentinelAlert, lp.SentinelReason, lp.Head = pr.SentinelAlert, pr.SentinelReason, pr.Head
lp.Adoption = pr.Adoption
lp.Presence = pr.Presence
lp.HumanApprover, lp.ManualMerge = pr.HumanApprover, pr.ManualMerge
lp.HumanMergeReason, lp.HumanMergeReasonText = pr.HumanMergeReason, pr.HumanMergeReasonText
lp.BaseRef = pr.BaseRef
Expand Down
115 changes: 115 additions & 0 deletions src/pkg/dashboard/stage_tracker_person_presence.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package dashboard

import (
"strings"
"time"

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

// StageTrackerPersonPresence describes the named author a PR waits on. Unknown
// means no registered clanker, or an unavailable presence source; Kind preserves
// the author classification independently of relay registration.
type StageTrackerPersonPresence struct {
Login string `json:"login"`
State string `json:"state"`
Kind string `json:"kind"`
Since *time.Time `json:"since,omitempty"`
LastSeen *time.Time `json:"last_seen,omitempty"`
Next string `json:"next"`
AdoptAt *time.Time `json:"adopt_at,omitempty"`
// Available distinguishes an unavailable hub from a known absent profile.
Available bool `json:"available"`
}

func (s *Server) stageTrackerPersonPresence(it StageTrackerItem, rec stagelabels.Record, hasRec bool, lookup func(string) (automerge.ContributorPresence, bool)) *StageTrackerPersonPresence {
if it.Kind != "pr" || it.Author == "" || (it.Stage != trackerNumberNeedsAuthor && it.Stage != trackerNumberReturned) {
return nil
}
out := &StageTrackerPersonPresence{Login: it.Author, State: "unknown", Kind: "clanker", Next: "wait"}
if it.AuthorKind == authorKindHuman {
out.Kind = "human"
}
var p automerge.ContributorPresence
if lookup != nil {
p, out.Available = lookup(it.Author)
}
if out.Available && p.Registered {
out.State = "offline"
if p.Online {
out.State = "online"
}
}
if !p.LastSeen.IsZero() {
t := p.LastSeen
out.LastSeen = &t
}
// Offline age is counted from the later heartbeat / current-head nudge,
// just like adoptionDue. Before the first nudge only presence is known.
var start time.Time
if hasRec && rec.NudgeHead == it.Head {
start = rec.NudgeStart()
if !start.IsZero() {
out.Since = &start
}
}
if p.LastSeen.After(start) {
t := p.LastSeen
out.Since = &t
}
if it.AuthorKind != authorKindClanker || it.Stage != trackerNumberReturned || !hasRec {
return out
}
var cfg config.StageLabelsConfig
if s != nil && s.deps != nil && s.deps.Config != nil {
cfg = s.deps.Config.Governor.Labels.Stage
}
if cfg.Adoption.Enabled != nil && !*cfg.Adoption.Enabled {
return out
}
if rec.AdoptionBlocked(it.Head) != "" || stageTrackerPresenceHeld(it.Labels) {
return out
}
policy := automerge.StageLabelPolicy{
GraceOnline: cfg.EffectiveContributorGraceOnline(), GraceOffline: cfg.EffectiveContributorGraceOffline(),
AdoptAfterOffline: cfg.Adoption.EffectiveAfterOffline(), AdoptAfterUnregistered: cfg.Adoption.EffectiveAfterUnregistered(),
}
at, _ := automerge.AdoptionDeadline(rec, it.Head, policy, p, out.Available)
if !at.IsZero() {
out.Next, out.AdoptAt = "adopt", &at
}
return out
}

// Snapshot each login once per tracker response so adoption and the indicator
// cannot disagree when a relay connects during response construction.
func cachedStageTrackerPresence(lookup func(string) (automerge.ContributorPresence, bool)) func(string) (automerge.ContributorPresence, bool) {
if lookup == nil {
return nil
}
type result struct {
p automerge.ContributorPresence
ok bool
}
cache := map[string]result{}
return func(login string) (automerge.ContributorPresence, bool) {
if r, ok := cache[login]; ok {
return r.p, r.ok
}
p, ok := lookup(login)
cache[login] = result{p, ok}
return p, ok
}
}

func stageTrackerPresenceHeld(labels []string) bool {
for _, label := range labels {
label = strings.ToLower(strings.TrimSpace(label))
if label == "hold" || label == "do-not-merge" || label == "do-not-merge/hold" {
return true
}
}
return false
}
Loading
Loading