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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/added-activity-monitor-row-feedback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor: every row action now reports what actually happened in a result toast that stays until the row changes state (shared `result` payload on the decision, delegated-decision, accept-triage, hold, send-to-human and rescan endpoints), rows show an in-flight "acting…" cue from click to state change, each confirm dialog has a "Don't ask again for this action" box (reset from ⚙ → Confirmations) with the sentinel ⚠ line carried into the toast, the lit chevron turns while a hive agent is on the item and a one-line event line says what just happened, and a merge pins the row for a moment while an amber token rises into a new "Merged today" counter (toggle "Celebrate merges"). Requested by @clubanderson.
10 changes: 9 additions & 1 deletion src/docs/dashboard-sections.md

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions src/pkg/dashboard/api_repo_hold.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dashboard

import (
Expand Down Expand Up @@ -27,6 +27,23 @@
HoldLabel string `json:"hold_label"`
Removed []string `json:"removed"`
MinStatusSeq uint64 `json:"minStatusSeq"`
// Result is the shared row-action outcome for the dashboard's toast.
Result *RowActionResult `json:"result,omitempty"`
}

// repoHoldResult reads a hold toggle into the shared row-action result.
func repoHoldResult(repoFull string, number int, itemType string, held bool, label string, removed []string) *RowActionResult {
target := rowActionTarget(repoFull, itemType, number)
if held {
return &RowActionResult{Action: rowActionHeld, Target: target, Outcome: "`" + label + "` applied.",
Next: "Agents leave this item alone until the hold is released; the chevron reads hold on the next refresh."}
}
if len(removed) == 0 {
res := rowActionNoopResult(target, "no hold label was on this item", time.Time{}, "")
return &res
}
return &RowActionResult{Action: rowActionReleased, Target: target, Outcome: "Hold released: `" + strings.Join(removed, "`, `") + "` removed.",
Next: "The hive picks it up on its next pass."}
}

type repoHoldPermissionCacheEntry struct {
Expand Down Expand Up @@ -652,5 +669,6 @@
HoldLabel: canonical,
Removed: removed,
MinStatusSeq: minStatusSeq,
Result: repoHoldResult(repoFull, number, itemType, body.Held, canonical, removed),
})
}
3 changes: 3 additions & 0 deletions src/pkg/dashboard/api_repo_hold_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ func TestRepoItemHoldToggleUpdatesStatusSnapshotAndReturnsFloor(t *testing.T) {
if resp.MinStatusSeq != 4 {
t.Fatalf("minStatusSeq = %d, want 4", resp.MinStatusSeq)
}
if resp.Result == nil || resp.Result.Action != rowActionHeld || resp.Result.Target.Number != 7 || resp.Result.Target.Kind != rowActionTargetIssue || resp.Result.Next == "" {
t.Fatalf("result = %+v", resp.Result)
}
if srv.status.StatusSeq != 4 {
t.Fatalf("statusSeq = %d, want bumped snapshot seq 4", srv.status.StatusSeq)
}
Expand Down
12 changes: 12 additions & 0 deletions src/pkg/dashboard/api_repo_item_accept_triage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"
"strconv"
"strings"
"time"

"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/github"
Expand Down Expand Up @@ -40,6 +41,8 @@ type repoAcceptTriageResponse struct {
Removed []string `json:"removed"`
AlreadyAccepted bool `json:"alreadyAccepted"`
MinStatusSeq uint64 `json:"minStatusSeq"`
// Result is the shared row-action outcome for the dashboard's toast.
Result *RowActionResult `json:"result,omitempty"`
}

// acceptTriageLabels returns the triage label to add and the awaiting labels
Expand Down Expand Up @@ -168,6 +171,9 @@ func (s *Server) handleRepoItemAcceptTriage(w http.ResponseWriter, r *http.Reque
out := repoAcceptTriageResponse{OK: true, Repo: repoFull, Number: number, AcceptLabel: accept, Added: []string{}, Removed: []string{}}
if len(add) == 0 && len(remove) == 0 {
out.AlreadyAccepted = true
res := rowActionNoopResult(rowActionTarget(repoFull, rowActionTargetIssue, number), "triage was already accepted (`"+accept+"` is on)", time.Time{}, "")
res.Next = "The reporter-trust gate admits the issue on its next poll."
out.Result = &res
jsonResponse(w, out)
return
}
Expand All @@ -191,6 +197,12 @@ func (s *Server) handleRepoItemAcceptTriage(w http.ResponseWriter, r *http.Reque
out.Removed = remove
s.auditFromRequest(r, acceptTriageAuditAction, auditDetail("repo", repoFull, "number", strconv.Itoa(number), "added", strings.Join(add, ","), "removed", strings.Join(remove, ",")), "")
out.MinStatusSeq = s.applyAcceptTriageToStatus(repoFull, number, add, remove)
outcome := "Triage accepted: `" + accept + "` added"
if len(remove) > 0 {
outcome += ", `" + strings.Join(remove, "`, `") + "` removed"
}
out.Result = &RowActionResult{Action: rowActionTriaged, Target: rowActionTarget(repoFull, rowActionTargetIssue, number), Outcome: outcome + ".",
Next: "The reporter-trust gate admits the issue on its next poll; the stage engine records 015 → 010."}
jsonResponse(w, out)
}

Expand Down
8 changes: 8 additions & 0 deletions src/pkg/dashboard/api_repo_item_accept_triage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ func TestRepoItemAcceptTriageIdempotentAndIssuesOnly(t *testing.T) {
if !resp.AlreadyAccepted || len(mock.added)+len(mock.removed)+len(mock.created) != 0 {
t.Fatalf("already accepted must be a no-op: resp=%+v added=%v removed=%v created=%v", resp, mock.added, mock.removed, mock.created)
}
if resp.Result == nil || resp.Result.Action != rowActionNoop || !strings.HasPrefix(resp.Result.Outcome, "No change — ") {
t.Fatalf("no-op result = %+v", resp.Result)
}
for _, entry := range srv.GetAudit().Recent(10) {
if entry.Action == acceptTriageAuditAction {
t.Fatal("a no-op must not be audited as a write")
Expand All @@ -192,6 +195,11 @@ func TestRepoItemAcceptTriageIdempotentAndIssuesOnly(t *testing.T) {
if len(mock.added) != 0 || strings.Join(mock.removed, ",") != "needs-triage" {
t.Fatalf("lingering awaiting: added=%v removed=%v", mock.added, mock.removed)
}
resp = repoAcceptTriageResponse{}
_ = json.Unmarshal(w.Body.Bytes(), &resp)
if resp.Result == nil || resp.Result.Action != rowActionTriaged || resp.Result.Target.Kind != rowActionTargetIssue {
t.Fatalf("result = %+v", resp.Result)
}

// A pull request has no triage state.
mock.isPullRequest = true
Expand Down
56 changes: 56 additions & 0 deletions src/pkg/dashboard/api_repo_item_decide_delegated.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dashboard

import (
Expand Down Expand Up @@ -87,6 +87,9 @@
Notes []string `json:"notes,omitempty"`
Error string `json:"error,omitempty"`
Marker string `json:"marker,omitempty"`
// Result is the shared row-action outcome (what was decided, on which
// item, what happens next), added for the dashboard's result toast.
Result *RowActionResult `json:"result,omitempty"`
}

type delegatedDecisionJobs struct {
Expand Down Expand Up @@ -252,11 +255,35 @@
return
}
d, deciderNotes := s.decideDelegated(ctx, in)
// The same rule firing again on an item the hive already decided would
// only repeat the comment: report it as a no-op instead of writing.
if prior, ok := s.delegatedPriorDecision(ctx, repoFull, number, d.Rule); ok {
kind := rowActionTargetIssue
if in.Kind == delegatedecision.KindPR {
kind = rowActionTargetPR
}
blocked := strings.TrimSpace(req.Caption)
if blocked == "" {
blocked = strings.TrimSpace(req.Reason)
}
res := rowActionNoopResult(rowActionTarget(repoFull, kind, number), "hive already recorded this decision (rule `"+d.Rule+"`)", prior, blocked)
s.delegatedJobs.finish(key, func(j *delegatedDecisionJob) {
j.Decision = &d
j.Notes = append(deciderNotes, "already applied; nothing written")
j.Result = &res
j.Status = delegatedJobStatusDone
})
s.audit.LogRecord(user, auditRepoItemDecisionDelegated, auditDetail("repo", repoFull, "number", strconv.Itoa(number), "type", itemType,
"verdict", string(d.Verdict), "rule", d.Rule, "actions", "", "noop", "already-applied", "policy", delegatedecision.PolicyName, "decision", d.Text), "", repoFull, number)
return
}
notes, execErr := s.executeDelegatedDecision(ctx, in, d, user, mergerRole)
notes = append(deciderNotes, notes...)
result := delegatedRowActionResult(in, d, notes)
s.delegatedJobs.finish(key, func(j *delegatedDecisionJob) {
j.Decision = &d
j.Notes = notes
j.Result = &result
if execErr != nil {
j.Status = delegatedJobStatusFailed
j.Error = execErr.Error()
Expand All @@ -281,6 +308,35 @@
s.audit.LogRecord(user, action, detail, "", repoFull, number)
}

// delegatedPriorDecision reports when the hive last recorded a delegated
// decision under the same rule on the item (the marker plus the rule tag
// CommentBody writes), so a repeat click is answered as a no-op. A comment
// listing failure reads as "no prior decision": deciding twice is the
// cheaper mistake.
func (s *Server) delegatedPriorDecision(ctx context.Context, repoFull string, number int, rule string) (time.Time, bool) {
if rule == "" || s.deps == nil || s.deps.GHClient == nil || s.deps.GHClient.GoGitHub() == nil {
return time.Time{}, false
}
owner, repoName, _ := strings.Cut(repoFull, "/")
comments, _, err := s.deps.GHClient.GoGitHub().Issues.ListComments(ctx, owner, repoName, number, &gh.IssueListCommentsOptions{ListOptions: gh.ListOptions{PerPage: delegatedDecisionGatherLimit}})
if err != nil {
return time.Time{}, false
}
tag := "(rule `" + rule + "`)"
var at time.Time
found := false
for _, c := range comments {
body := c.GetBody()
if !delegatedecision.IsDelegatedComment(body) || !strings.Contains(body, tag) {
continue
}
if t := c.GetCreatedAt().Time; !found || t.After(at) {
at, found = t, true
}
}
return at, found
}

// gatherDelegatedInput reads what the decider needs from GitHub.
func (s *Server) gatherDelegatedInput(ctx context.Context, repoFull string, number int, itemType string, req delegatedDecisionRequest) (delegatedecision.Input, error) {
client := s.deps.GHClient
Expand Down
32 changes: 32 additions & 0 deletions src/pkg/dashboard/api_repo_item_decide_delegated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func TestDelegatedDecisionIssueDefaultApproveUnparksWithMarker(t *testing.T) {
if job.Marker != "<!-- hive:delegated-decision by=h1 policy=owner-delegate -->" {
t.Fatalf("marker = %q", job.Marker)
}
// The shared row-action result says what hive decided, on what, and
// what happens next (the dashboard's persistent toast).
if job.Result == nil || job.Result.Action != rowActionApproved || job.Result.Rule != "default-approve" || job.Result.Target.Kind != rowActionTargetIssue || job.Result.Target.Number != 7 || job.Result.Outcome == "" || job.Result.Next == "" {
t.Fatalf("result = %+v", job.Result)
}
// The `/hive decision` comment with the marker lands first, then the
// un-park reply the sweep would post; approved-direction and
// triage/accepted are written; nothing closes.
Expand Down Expand Up @@ -322,3 +327,30 @@ func TestDelegatedSupersedeRefusedWhenAdoptionDisabled(t *testing.T) {
t.Fatalf("request label queued despite disabled adoption: %v", mock.added)
}
}

// TestDelegatedDecisionRepeatIsNoop (owner request): clicking "Let hive
// decide" again after the same rule already decided the item records
// nothing new and says so plainly, with when the decision was first
// recorded and what still blocks the item.
func TestDelegatedDecisionRepeatIsNoop(t *testing.T) {
mock := &repoItemDecisionMock{issueLabels: []string{"bug", "stage/045-needs-decision"}}
mock.priorComments = []string{delegatedecision.CommentBody(delegatedecision.Decision{Verdict: delegatedecision.VerdictApprove, Rule: "default-approve", Rationale: "r"}, "h1", "writer")}
srv := newDelegatedServer(t, mock)
w := postDelegated(t, srv, 7, "writer", `{"type":"issue","reason":"requires_human"}`, nil)
if w.Code != http.StatusOK {
t.Fatalf("code=%d body=%s", w.Code, w.Body.String())
}
job := decodeDelegatedJob(t, w)
if job.Result == nil || job.Result.Action != rowActionNoop {
t.Fatalf("result = %+v", job.Result)
}
if !strings.HasPrefix(job.Result.Outcome, "No change — hive already recorded this decision") || !strings.Contains(job.Result.Outcome, "2026-10-28T12:01:00Z") {
t.Fatalf("outcome = %q", job.Result.Outcome)
}
if job.Result.AppliedAt == nil || !strings.Contains(job.Result.Next, "blocked") {
t.Fatalf("next = %q applied_at = %v", job.Result.Next, job.Result.AppliedAt)
}
if len(mock.comments) != 0 || len(mock.added) != 0 {
t.Fatalf("a repeat must write nothing: comments=%v added=%v", mock.comments, mock.added)
}
}
53 changes: 50 additions & 3 deletions src/pkg/dashboard/api_repo_item_decision.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,50 @@ type repoItemDecisionResponse struct {
// on the spot, when it did.
Released []string `json:"released,omitempty"`
Stage string `json:"stage,omitempty"`
// Result is the shared row-action outcome for the dashboard's toast.
Result *RowActionResult `json:"result,omitempty"`
}

// repoItemDecisionResult reads a recorded human decision into the shared
// row-action result.
func repoItemDecisionResult(repoFull string, number int, itemType, decision, comment, supersededBy, label string, released []string) *RowActionResult {
out := &RowActionResult{Target: rowActionTarget(repoFull, itemType, number)}
switch decision {
case repoItemDecisionApprove:
out.Action = rowActionApproved
if itemType == "pr" {
out.Outcome = "`/lgtm` + `/approve` posted"
if len(released) > 0 {
out.Outcome += " (released: " + strings.Join(released, ", ") + ")"
}
out.Outcome += "."
out.Next = "The merge gate takes it from here; the dashboard merges nothing."
} else {
out.Outcome = "`/hive approve` recorded; parking labels lifted, `" + label + "` applied."
out.Next = "The hive un-parks the issue and carries on; nothing is merged."
}
case repoItemDecisionDirection:
out.Action = rowActionDirected
out.Outcome = "Direction recorded as `/hive decision`: " + strings.TrimSuffix(strings.TrimSpace(comment), ".") + "."
if itemType == "pr" {
out.Next = "The author agent pushes a new head; the row moves when it lands."
} else {
out.Next = "The hive carries on with that direction; nothing is merged."
}
case repoItemDecisionCloseSuperseded:
out.Action = rowActionClosed
if supersededBy != "" {
out.Outcome = "Closed as superseded by " + supersededBy + "."
} else {
out.Outcome = "Closed as superseded."
}
out.Next = "Nothing further to do; the row leaves the tracker on its next refresh."
case repoItemDecisionCloseWontFix:
out.Action = rowActionClosed
out.Outcome = "Closed as won't fix (not planned)."
out.Next = "Nothing further to do; the row leaves the tracker on its next refresh."
}
return out
}

func renderRepoItemDecisionCloseComment(verb, user, comment, supersededBy string) string {
Expand Down Expand Up @@ -214,7 +258,8 @@ func (s *Server) handleRepoItemDecision(w http.ResponseWriter, r *http.Request)
action = auditRepoItemDecisionDirection
}
s.audit.LogRecord(user, action, auditDetail("repo", repoFull, "number", numStr, "decision", event.Decision), "", repoFull, number)
jsonResponse(w, repoItemDecisionResponse{OK: true, Repo: repoFull, Number: number, Decision: decision, Status: "unparked", Label: ghpkg.HumanAckLabel})
jsonResponse(w, repoItemDecisionResponse{OK: true, Repo: repoFull, Number: number, Decision: decision, Status: "unparked", Label: ghpkg.HumanAckLabel,
Result: repoItemDecisionResult(repoFull, number, itemType, decision, comment, "", ghpkg.HumanAckLabel, nil)})
case repoItemDecisionCloseSuperseded, repoItemDecisionCloseWontFix:
verb := "won't fix"
supersededBy := ""
Expand Down Expand Up @@ -257,7 +302,8 @@ func (s *Server) handleRepoItemDecision(w http.ResponseWriter, r *http.Request)
}
}
s.audit.LogRecord(user, auditRepoItemDecisionClose, auditDetail("repo", repoFull, "number", numStr, "type", itemType, "reason", verb, "superseded_by", supersededBy), "", repoFull, number)
jsonResponse(w, repoItemDecisionResponse{OK: true, Repo: repoFull, Number: number, Decision: decision, Status: "closed", Label: label})
jsonResponse(w, repoItemDecisionResponse{OK: true, Repo: repoFull, Number: number, Decision: decision, Status: "closed", Label: label,
Result: repoItemDecisionResult(repoFull, number, itemType, decision, comment, supersededBy, label, nil)})
default:
jsonError(w, "unknown decision; want approve, direction, close-superseded or close-wontfix", http.StatusBadRequest)
}
Expand Down Expand Up @@ -312,7 +358,8 @@ func (s *Server) handlePullRequestDecision(ctx context.Context, w http.ResponseW
// The row's park was just answered: serve the re-derived stage on the
// next tracker read instead of the cached 085.
s.invalidateStageTrackerForWebhook()
jsonResponse(w, repoItemDecisionResponse{OK: true, Repo: repoFull, Number: number, Decision: decision, Status: status, Released: released, Stage: stage})
jsonResponse(w, repoItemDecisionResponse{OK: true, Repo: repoFull, Number: number, Decision: decision, Status: status, Released: released, Stage: stage,
Result: repoItemDecisionResult(repoFull, number, "pr", decision, comment, "", "", released)})
}

// repoItemApprovalReleased names what a PR approval released, for the
Expand Down
9 changes: 8 additions & 1 deletion src/pkg/dashboard/api_repo_item_decision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ type repoItemDecisionMock struct {
prMergeState string
prRedCI bool
prNoCI bool
// priorComments are the comment bodies GET /comments lists (a prior
// delegated decision makes a repeat click a no-op).
priorComments []string
}

func newRepoItemDecisionServer(t *testing.T, m *repoItemDecisionMock) *Server {
Expand Down Expand Up @@ -85,7 +88,11 @@ func newRepoItemDecisionServer(t *testing.T, m *repoItemDecisionMock) *Server {
case r.Method == http.MethodGet && strings.Contains(path, "/timeline"):
_, _ = io.WriteString(w, `[]`)
case r.Method == http.MethodGet && strings.HasSuffix(path, "/comments"):
_, _ = io.WriteString(w, `[]`)
prior := make([]map[string]any, 0, len(m.priorComments))
for i, body := range m.priorComments {
prior = append(prior, map[string]any{"id": i + 1, "body": body, "created_at": "2026-10-28T12:01:00Z"})
}
_ = json.NewEncoder(w).Encode(prior)
case r.Method == http.MethodPost && strings.HasSuffix(path, "/comments"):
var c map[string]string
_ = json.NewDecoder(r.Body).Decode(&c)
Expand Down
26 changes: 26 additions & 0 deletions src/pkg/dashboard/api_repos_rescan.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dashboard

import (
Expand Down Expand Up @@ -39,6 +39,29 @@
Repos int `json:"repos"`
ScannedAt string `json:"scanned_at,omitempty"`
RetryAfterS int `json:"retry_after_s,omitempty"`
// Result is the shared row-action outcome for the dashboard's toast; the
// rescan is hive-wide, so Target is left for the caller to fill.
Result *RowActionResult `json:"result,omitempty"`
}

// reposRescanRowResult reads a rescan outcome into the shared row-action
// result. A debounced or in-progress answer is a no-op, not an error.
func reposRescanRowResult(r ReposRescanResult) *RowActionResult {
switch r.Status {
case "rescanned":
return &RowActionResult{Action: rowActionRescanned, Outcome: "Rescanned " + strconv.Itoa(r.Repos) + " repositories: " + strconv.Itoa(r.Issues) + " open issues, " + strconv.Itoa(r.PRs) + " open PRs.",
Next: "The tracker re-reads every row from this scan; stages move on the next refresh."}
case "in-progress":
res := rowActionNoopResult(RowActionTarget{}, "a rescan is already running", time.Time{}, "")
res.Next = "Its results land on the next refresh."
return &res
case "debounced":
at, _ := time.Parse(time.RFC3339, r.ScannedAt)
res := rowActionNoopResult(RowActionTarget{}, "a rescan finished moments ago", at, "")
res.Next = "The data is that fresh; another rescan is allowed in " + strconv.Itoa(r.RetryAfterS) + "s."
return &res
}
return nil
}

// handleReposRescan re-enumerates the watched repositories' open issues and
Expand Down Expand Up @@ -71,6 +94,7 @@
s.repoRescanMu.Unlock()
last.Status = "in-progress"
last.RetryAfterS = 0
last.Result = reposRescanRowResult(last)
jsonResponse(w, last)
return
}
Expand All @@ -80,6 +104,7 @@
s.repoRescanMu.Unlock()
last.Status = "debounced"
last.RetryAfterS = int(math.Ceil((repoRescanDebounce - age).Seconds()))
last.Result = reposRescanRowResult(last)
jsonResponse(w, last)
return
}
Expand Down Expand Up @@ -124,6 +149,7 @@
result.Repos = len(s.deps.Config.Project.Repos)
}

result.Result = reposRescanRowResult(result)
s.repoRescanMu.Lock()
s.repoRescanAt = time.Now()
s.repoRescanLast = result
Expand Down
Loading
Loading