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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-tracker-advisory-close-progress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity monitor row actions now show progress and never fail silently (hivecommons/hive#15436). **Close (read)** on an advisory row did nothing — an advisory is not a decision park, so the `decide:*` target mapping came up empty and the click returned without a request, a dialog or a toast. It now acts on the advisory row itself and really closes the issue (acknowledgement comment, closed as completed); an empty target list toasts a warning instead of returning silently. Every mutating row action (close-read, close-superseded, won't-fix, hold, approve, merge, decide) puts the chevron into the striped busy state with the verb as caption from the first byte sent, shows *Closed · leaving list* / *Merged · leaving list* once the server answers, and the server drops an operator-closed item from the tracker for `HIVE_OPERATOR_CLOSED_GRACE` (default 15m) so the row cannot come back before GitHub's list catches up. A close on an operator-paused repo is refused with the reason and writes nothing; refused, failed and network-errored actions restore the chevron, toast the reason and put it on the row's history badge (red, hover's first line), and the ledger records refused answers as `failed` with the one-line why.
2 changes: 2 additions & 0 deletions src/docs/dashboard-sections.md
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,8 @@ Right-clicking a row — or a nested PR sub-row — opens an in-app context menu

The menu is positioned at the pointer, clamped to the viewport, uses `menu` / `menuitem` roles, moves focus with ↑ ↓ Home End, opens the *Decide…* group with → and closes it with ←, and closes on Esc, Tab, click-away, scroll or resize, returning focus to the row. Shift+right-click keeps the browser's own menu. Entries, each shown only when it applies: **Decide…** on a row waiting on a person — a PR wearing the *Needs human decision* pill at 085 on the Merge gate column (the primary case: e.g. two competing `dibs` PRs), an issue row whose one nested PR is parked there (the menu reads *Decide PR #458…* and acts on that PR, since the issue's own stage is only mirrored from it), or an issue parked at 045.

**Progress and failure, for every action that writes** ([#15436](https://github.com/hivecommons/hive/issues/15436): Close (read) on an advisory did nothing visible — the row is not a decision park, so the click mapped to no target and returned without a request, a dialog or a toast). Close (read) now acts on the advisory row itself; any `decide:*` click whose target list comes up empty says so in a warning toast. The moment a mutating action is sent — close-read, close-superseded, won't-fix, hold, approve, merge, decide — the clicked row's chevron takes the striped busy state with the verb as its caption (*Closing…*, *Holding…*, *Approving…*); when the server answers that the item is closed or merged the caption turns terminal (*Closed · leaving list*, *Merged · leaving list*) and stays until the next tracker payload no longer lists the row. The server guarantees that payload: an item whose newest operator-ledger action is a `close-*` that applied is dropped from the tracker for `HIVE_OPERATOR_CLOSED_GRACE` (default 15m) while GitHub's list catches up, so the row cannot be resurrected between the click and the close being visible. A close on a repo the operator has paused is refused with a 200 `status: refused` result (*Close refused: repo paused — …*) and writes nothing. A refused, failed (GitHub 4xx/5xx) or network-errored action restores the chevron at once, toasts the reason, and notes it on the row's history badge (red; the hover's first line is the reason) until a newer server record replaces it — the ledger itself records refused and 5xx answers as `failed` with the one-line why.

**PR-scoped actions on nested PRs** ([#15009](https://github.com/hivecommons/hive/issues/15009): one issue, two PRs — [#15017](https://github.com/hivecommons/hive/pull/15017) *Ready for human merge · untrusted author* and [#15020](https://github.com/hivecommons/hive/pull/15020) *Needs human decision* — and no way to decide one without the other): every nested PR sub-row carries its own ⋯ menu, and its *Decide…* (Let hive decide, Approve, Close as superseded by…, Won't fix…, Give direction…), *Hold* / *Release hold* and the rest act on **that PR** — `runRowAction(action, row)` receives the PR's own row object (number, repo, head), never the parent issue's, and the needs-human popover opened from a sub-row's chevron does the same.

A PR waiting for a person to merge it (*Ready for human merge*, a `human_merge_reason` such as an untrusted author) counts as parked for this purpose. When an issue has two or more open nested PRs the issue row's menu no longer offers a single *Decide…* that would silently pick one: it offers **Let hive decide — all N PRs** (hint *per PR*), which asks the server to decide each PR on its own (see [Let hive decide](#let-hive-decide)); the issue's own *Decide…* stays only when the issue itself is parked at 045.
Expand Down
36 changes: 36 additions & 0 deletions src/pkg/dashboard/api_repo_item_decision.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dashboard

import (
Expand All @@ -16,6 +16,7 @@
"github.com/hivecommons/hive/pkg/rebasemerge"
"github.com/hivecommons/hive/pkg/review"
"github.com/hivecommons/hive/pkg/stagelabels"
"github.com/hivecommons/hive/pkg/writeback"
)

// Activity-monitor row decisions (hivecommons/hive#13479 follow-up). The
Expand Down Expand Up @@ -303,6 +304,33 @@
return out
}

// repoWritesPaused reports whether repoFull is operator-paused, with the
// pause's provenance in words: the write-back gate's view when the gate is
// installed, else the config's own record.
func (s *Server) repoWritesPaused(repoFull string) (string, bool) {
if g := s.writebackGateRef(); g != nil {
if info, paused := g.RepoPaused(repoFull); paused {
return writeback.RepoPausedDetail(repoFull, info), true
}
}
if s.deps == nil || s.deps.Config == nil {
return "", false
}
rp, paused := s.deps.Config.RepoPauseFor(repoFull)
if !paused {
return "", false
}
return writeback.RepoPausedDetail(repoFull, writeback.RepoPauseInfo{By: rp.By, Reason: rp.Reason}), true
}

// repoItemCloseRefusedResult is the row result for a close the hive would
// not write: Outcome is the one line the toast and the badge show.
func repoItemCloseRefusedResult(repoFull string, number int, itemType, detail string) *RowActionResult {
return &RowActionResult{Action: rowActionRefused, Target: rowActionTarget(repoFull, itemType, number),
Outcome: "Close refused: repo paused — " + detail + ".",
Next: "Resume the repository to let the dashboard close it, or close it on GitHub yourself."}
}

func renderRepoItemDecisionCloseComment(verb, user, comment, supersededBy string) string {
by := "an operator"
if strings.TrimSpace(user) != "" {
Expand Down Expand Up @@ -418,6 +446,14 @@
}
supersededBy = ref
}
// A paused repo takes no hive writes, operator-initiated or not
// (hivecommons/hive#15436): a 200 with a refused result, so the
// row's toast and history badge say why instead of "HTTP 409".
if detail, paused := s.repoWritesPaused(repoFull); paused {
jsonStatusResponse(w, http.StatusOK, repoItemDecisionResponse{OK: true, Repo: repoFull, Number: number, Decision: decision, Status: rowActionRefused,
Result: repoItemCloseRefusedResult(repoFull, number, itemType, detail)})
return
}
if err := gh.CreateIssueComment(ctx, repoFull, number, renderRepoItemDecisionCloseComment(verb, user, comment, supersededBy)); err != nil {
jsonError(w, err.Error(), http.StatusBadGateway)
return
Expand Down
51 changes: 51 additions & 0 deletions src/pkg/dashboard/api_repo_item_decision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"testing"
"time"

"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/github"
"github.com/hivecommons/hive/pkg/review"
"github.com/hivecommons/hive/pkg/stagelabels"
Expand Down Expand Up @@ -713,3 +714,53 @@ func TestRepoItemApproveResultWording(t *testing.T) {
t.Fatalf("legacy = %+v", got)
}
}

// The real hivecommons/hive#15381 shape (a dedupe-checklist advisory: the
// triage/advisory label, a "Decision required: no" body, bot author) closes
// as completed with the acknowledgement comment; on a paused repo the same
// request is a 200 refused result whose Outcome says why, and nothing is
// written (hivecommons/hive#15436).
func TestRepoItemDecisionCloseReadAdvisoryFixtureAndPausedRefusal(t *testing.T) {
mock := &repoItemDecisionMock{
issueLabels: []string{"help wanted", "agent/dedupe", "triage/advisory"},
issueTitle: "triage: duplicate and overlapping open issues/PRs to consolidate",
issueBody: "<!-- hive:dedupe-checklist repo=hivecommons/hive -->\nDecision required: no\n\n## Summary\n\nTriage pass over the 28 open issues and 12 open PRs. Found 0 near-duplicate pairs.",
}
srv := newRepoItemDecisionServer(t, mock)

w := postRepoItemDecision(t, srv, 7, "writer", `{"decision":"close-read","type":"issue"}`)
if w.Code != http.StatusOK {
t.Fatalf("close-read: code=%d body=%s", w.Code, w.Body.String())
}
var resp repoItemDecisionResponse
_ = json.Unmarshal(w.Body.Bytes(), &resp)
if resp.Status != "closed" || resp.Result == nil || resp.Result.Action != rowActionClosed {
t.Fatalf("resp = %+v", resp)
}
if len(mock.comments) != 1 || !strings.Contains(mock.comments[0], "Closed as read (advisory acknowledged) by @writer") {
t.Fatalf("comments = %v", mock.comments)
}
if len(mock.edits) != 1 || mock.edits[0]["state"] != "closed" || mock.edits[0]["state_reason"] != issueStateReasonCompleted {
t.Fatalf("edits = %v", mock.edits)
}

// Paused repo: refused with a reason, nothing posted.
mock.comments, mock.edits = nil, nil
srv.deps.Config.Project.PausedRepos = []config.RepoPause{{Repo: "testrepo", By: "clubanderson", Reason: "release freeze"}}
t.Cleanup(func() { srv.deps.Config.Project.PausedRepos = nil })
w = postRepoItemDecision(t, srv, 7, "writer", `{"decision":"close-read","type":"issue"}`)
if w.Code != http.StatusOK {
t.Fatalf("paused close-read: code=%d body=%s", w.Code, w.Body.String())
}
resp = repoItemDecisionResponse{}
_ = json.Unmarshal(w.Body.Bytes(), &resp)
if resp.Status != rowActionRefused || resp.Result == nil || resp.Result.Action != rowActionRefused {
t.Fatalf("paused resp = %+v", resp)
}
if !strings.HasPrefix(resp.Result.Outcome, "Close refused: repo paused") || !strings.Contains(resp.Result.Outcome, "release freeze") {
t.Fatalf("outcome = %q, want the pause and its reason", resp.Result.Outcome)
}
if len(mock.comments)+len(mock.edits) != 0 {
t.Fatalf("a refused close must write nothing: comments=%v edits=%v", mock.comments, mock.edits)
}
}
59 changes: 59 additions & 0 deletions src/pkg/dashboard/operator_actions.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dashboard

import (
Expand Down Expand Up @@ -103,6 +103,15 @@
// HIVE_OPERATOR_ACTION_STUCK_AFTER (Go duration) overrides how long a
// recorded action may sit at the same stage before the badge turns amber.
operatorActionStuckAfterEnv = "HIVE_OPERATOR_ACTION_STUCK_AFTER"
// operatorActionClosedDetail is the /decision status word a close
// answers with; an item whose newest action applied it leaves the
// tracker at once (stageTrackerDropOperatorClosed).
operatorActionClosedDetail = "closed"
operatorActionClosedGraceDefault = 15 * time.Minute
// HIVE_OPERATOR_CLOSED_GRACE (Go duration) overrides how long a row the
// operator closed from the dashboard is kept off the tracker while
// GitHub's list catches up.
operatorActionClosedGraceEnv = "HIVE_OPERATOR_CLOSED_GRACE"
)

// operatorActionsPath is where the ledger persists; tests point it at a
Expand Down Expand Up @@ -402,6 +411,17 @@
return operatorActionOutcomeNoOp, "already accepted", head, true
}
detail = str("status")
// A 200 that refused the action (a paused repo, an unreachable
// head) is a failure on the ledger, with the result's one-line why
// as the detail (hivecommons/hive#15436).
if detail == rowActionRefused {
if res, ok := resp["result"].(map[string]any); ok {
if why, _ := res["outcome"].(string); strings.TrimSpace(why) != "" {
detail = strings.TrimSpace(why)
}
}
return operatorActionOutcomeFailed, detail, head, true
}
if detail == "" {
if released, ok := resp["released"].([]any); ok && len(released) > 0 {
parts := make([]string, 0, len(released))
Expand Down Expand Up @@ -877,6 +897,45 @@
return strings.TrimSpace(verdict), rule
}

func operatorActionClosedGrace() time.Duration {
if raw := strings.TrimSpace(os.Getenv(operatorActionClosedGraceEnv)); raw != "" {
if d, err := time.ParseDuration(raw); err == nil && d > 0 {
return d
}
}
return operatorActionClosedGraceDefault
}

// operatorClosedActions are the row actions whose applied outcome is a
// closed issue or PR.
var operatorClosedActions = []string{operatorActionCloseSuperseded, operatorActionWontFix, operatorActionCloseRead}

// operatorActionClosedItem reports whether the item's newest recorded
// action closed it from the dashboard within grace of now: GitHub's list
// (and the poller's snapshot of it) lags the close by up to a poll, and
// the owner who just clicked Close must not see the row come back
// (hivecommons/hive#15436). Past the grace a row still listed open is
// real — reopened, or the close never landed — and shows again.
func operatorActionClosedItem(it StageTrackerItem, now time.Time, grace time.Duration) bool {
a := it.LastOperatorAction
if a == nil || a.Outcome != operatorActionOutcomeApplied || a.Detail != operatorActionClosedDetail || !slices.Contains(operatorClosedActions, a.Action) {
return false
}
return !a.At.IsZero() && now.Sub(a.At) < grace
}

// stageTrackerDropOperatorClosed removes the items operatorActionClosedItem
// matches, keeping order. Run after applyOperatorActions.
func stageTrackerDropOperatorClosed(items []StageTrackerItem, now time.Time, grace time.Duration) []StageTrackerItem {
out := items[:0]
for _, it := range items {
if !operatorActionClosedItem(it, now, grace) {
out = append(out, it)
}
}
return out
}

// applyOperatorActions stamps last_operator_action / operator_action_count
// onto every tracker item with a record.
func (s *Server) applyOperatorActions(items []StageTrackerItem, now time.Time) {
Expand Down
31 changes: 31 additions & 0 deletions src/pkg/dashboard/operator_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http/httptest"
"os"
"path/filepath"
"slices"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -101,6 +102,8 @@ func TestOperatorActionOutcome(t *testing.T) {
{202, `{"status":"running"}`, operatorActionOutcomePending, "running", "", true, "delegated async"},
{409, `{"error":"not parked"}`, operatorActionOutcomeNoOp, "not parked", "", true, "conflict"},
{502, `{"error":"github down"}`, operatorActionOutcomeFailed, "github down", "", true, "upstream"},
{200, `{"ok":true,"status":"refused","result":{"action":"refused","outcome":"Close refused: repo paused — o/r is paused by the operator."}}`, operatorActionOutcomeFailed, "Close refused: repo paused — o/r is paused by the operator.", "", true, "refused close (#15436)"},
{200, `{"ok":true,"status":"closed","result":{"action":"closed"}}`, operatorActionOutcomeApplied, "closed", "", true, "closed"},
{400, `{"error":"bad"}`, "", "", "", false, "rejected input"},
{403, ``, "", "", "", false, "forbidden"},
}
Expand Down Expand Up @@ -460,3 +463,31 @@ func TestOperatorActionExecutionForReadsRecord(t *testing.T) {
t.Fatalf("escalation for another head leaked: %+v", got)
}
}

// An item the operator just closed from the dashboard leaves the tracker
// at once (hivecommons/hive#15436), for the grace window only, and only
// when the close actually applied.
func TestStageTrackerDropOperatorClosed(t *testing.T) {
now := time.Date(2026, 10, 29, 17, 20, 0, 0, time.UTC)
grace := 15 * time.Minute
act := func(action, outcome, detail string, ago time.Duration) *StageTrackerOperatorAction {
return &StageTrackerOperatorAction{Action: action, Outcome: outcome, Detail: detail, At: now.Add(-ago)}
}
items := []StageTrackerItem{
{Repo: "o/r", Number: 1, Kind: "issue"},
{Repo: "o/r", Number: 2, Kind: "issue", LastOperatorAction: act(operatorActionCloseRead, operatorActionOutcomeApplied, operatorActionClosedDetail, time.Minute)},
{Repo: "o/r", Number: 3, Kind: "pr", LastOperatorAction: act(operatorActionCloseSuperseded, operatorActionOutcomeApplied, operatorActionClosedDetail, 2*time.Minute)},
{Repo: "o/r", Number: 4, Kind: "issue", LastOperatorAction: act(operatorActionWontFix, operatorActionOutcomeApplied, operatorActionClosedDetail, grace+time.Second)},
{Repo: "o/r", Number: 5, Kind: "issue", LastOperatorAction: act(operatorActionCloseRead, operatorActionOutcomeFailed, "Close refused: repo paused", time.Minute)},
{Repo: "o/r", Number: 6, Kind: "issue", LastOperatorAction: act(operatorActionApprove, operatorActionOutcomeApplied, "unparked", time.Minute)},
}
got := stageTrackerDropOperatorClosed(items, now, grace)
var nums []int
for _, it := range got {
nums = append(nums, it.Number)
}
want := []int{1, 4, 5, 6}
if !slices.Equal(nums, want) {
t.Fatalf("kept %v, want %v (just-closed rows 2 and 3 must leave; a refused close, an old close and a non-close stay)", nums, want)
}
}
4 changes: 4 additions & 0 deletions src/pkg/dashboard/stage_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2333,6 +2333,10 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto
stageTrackerMergeTrainStallWarnings(&s.mergeTrains, resp.Items, now)
stageTrackerLineageFillAuthors(resp.Items)
s.applyOperatorActions(resp.Items, now)
// A row the operator just closed from the dashboard leaves at once,
// before GitHub's list catches up (hivecommons/hive#15436).
resp.Items = stageTrackerDropOperatorClosed(resp.Items, now, operatorActionClosedGrace())
resp.OpenIssues, resp.OpenPRs = stageTrackerOpenCounts(resp.Items)
s.applyDecidedProjection(resp.Items, now)
applyRebaseAttempts(resp.Items)
s.applyRebaseMergeFollowThrough(resp.Items, now)
Expand Down
Loading
Loading