From d86117a4dce2fedf22a3ba8fd66a16f54963971a Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Thu, 29 Oct 2026 13:31:08 -0400 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20tracker:=20row=20actions=20s?= =?UTF-8?q?how=20progress,=20surface=20failures,=20and=20advisory=20Close?= =?UTF-8?q?=20really=20closes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close (read) on an advisory row did nothing: runRowAction mapped every decide:* id through stageTrackerDecisionTarget, which only yields a target for a parked PR or a needs-decision issue, so the advisory's empty target list returned silently - no request, no dialog, no toast (tracker row history: [], no audit entry, no pod log line for 15381). - close-read acts on the advisory row itself; an empty decide target list now toasts a warning instead of returning silently - every mutating row action shows the striped busy chevron with the verb caption, then a terminal 'Closed/Merged · leaving list' caption until the next tracker payload drops the row - server drops operator-closed items from the tracker for HIVE_OPERATOR_CLOSED_GRACE (default 15m) so a stale GitHub list cannot resurrect the row - close on an operator-paused repo is refused (200 status: refused) with the reason and writes nothing; refused/failed/errored actions restore the chevron, toast the reason and note it on the history badge; the ledger records refused answers as failed - Go handler/tracker tests and Node harness progress/failure tests Signed-off-by: Andrew Anderson --- .../fixed-tracker-advisory-close-progress.md | 1 + src/docs/dashboard-sections.md | 2 + src/pkg/dashboard/api_repo_item_decision.go | 36 +++++ .../dashboard/api_repo_item_decision_test.go | 51 +++++++ src/pkg/dashboard/operator_actions.go | 59 ++++++++ src/pkg/dashboard/operator_actions_test.go | 31 ++++ src/pkg/dashboard/stage_tracker.go | 4 + .../stage_tracker_row_actions_test.go | 133 ++++++++++++++++++ .../static-src/js/tracker-actions.js | 65 ++++++++- .../dashboard/static-src/js/tracker-row.js | 4 + src/pkg/dashboard/static/index.html | 69 ++++++++- 11 files changed, 451 insertions(+), 4 deletions(-) create mode 100644 src/changelog.d/fixed-tracker-advisory-close-progress.md diff --git a/src/changelog.d/fixed-tracker-advisory-close-progress.md b/src/changelog.d/fixed-tracker-advisory-close-progress.md new file mode 100644 index 0000000000..19f544d310 --- /dev/null +++ b/src/changelog.d/fixed-tracker-advisory-close-progress.md @@ -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. diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index f93f5102f8..0deec44e11 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -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. diff --git a/src/pkg/dashboard/api_repo_item_decision.go b/src/pkg/dashboard/api_repo_item_decision.go index 05e83d78d8..58e399160f 100644 --- a/src/pkg/dashboard/api_repo_item_decision.go +++ b/src/pkg/dashboard/api_repo_item_decision.go @@ -16,6 +16,7 @@ import ( "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 @@ -303,6 +304,33 @@ func repoItemDecisionResultWith(repoFull string, number int, itemType, decision, 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) != "" { @@ -418,6 +446,14 @@ func (s *Server) handleRepoItemDecision(w http.ResponseWriter, r *http.Request) } 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 diff --git a/src/pkg/dashboard/api_repo_item_decision_test.go b/src/pkg/dashboard/api_repo_item_decision_test.go index 3094798e00..7309a518c5 100644 --- a/src/pkg/dashboard/api_repo_item_decision_test.go +++ b/src/pkg/dashboard/api_repo_item_decision_test.go @@ -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" @@ -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: "\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) + } +} diff --git a/src/pkg/dashboard/operator_actions.go b/src/pkg/dashboard/operator_actions.go index 67a6b09f38..63211b0d64 100644 --- a/src/pkg/dashboard/operator_actions.go +++ b/src/pkg/dashboard/operator_actions.go @@ -103,6 +103,15 @@ const ( // 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 @@ -402,6 +411,17 @@ func operatorActionOutcome(status int, body []byte) (outcome, detail, head strin 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)) @@ -877,6 +897,45 @@ func operatorActionVerdictFromDetail(detail string) (verdict, rule string) { 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) { diff --git a/src/pkg/dashboard/operator_actions_test.go b/src/pkg/dashboard/operator_actions_test.go index 54f90a6b7c..486ac3d91b 100644 --- a/src/pkg/dashboard/operator_actions_test.go +++ b/src/pkg/dashboard/operator_actions_test.go @@ -6,6 +6,7 @@ import ( "net/http/httptest" "os" "path/filepath" + "slices" "strings" "testing" "time" @@ -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"}, } @@ -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) + } +} diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index 0ac1cd0a27..8e0ace1fa9 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -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) diff --git a/src/pkg/dashboard/stage_tracker_row_actions_test.go b/src/pkg/dashboard/stage_tracker_row_actions_test.go index 05ee269064..97fe428579 100644 --- a/src/pkg/dashboard/stage_tracker_row_actions_test.go +++ b/src/pkg/dashboard/stage_tracker_row_actions_test.go @@ -146,6 +146,16 @@ func stageTrackerRowActionsPreamble(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerPendingLive"), jsFunc(t, html, "stageTrackerPendingExpire"), jsFunc(t, html, "stageTrackerPendingSync"), + // Progress + failure surfacing for every mutating action (hivecommons/hive#15436). + jsConstBlock(t, html, "STAGE_TRACKER_TERMINAL_CAPTIONS"), + jsFunc(t, html, "stageTrackerTerminalCaption"), + jsConstBlock(t, html, "STAGE_TRACKER_ACTION_LEDGER_NAME"), + "var _stageTrackerActionFailures = {};", + jsFunc(t, html, "stageTrackerNoteActionFailure"), + jsFunc(t, html, "stageTrackerClearActionFailure"), + jsFunc(t, html, "stageTrackerActionFailureOf"), + jsFunc(t, html, "stageTrackerAdvisoryOf"), + jsFunc(t, html, "stageTrackerNothingToActOn"), jsFunc(t, html, "runRowAction"), jsFunc(t, html, "makeToastSticky"), stageTrackerDomStubJS, @@ -1634,3 +1644,126 @@ assert.ok(visible.startsWith('Let hive decide 2 items'), visible); assert.strictEqual(stageTrackerDelegatePlanView([Object.assign({}, green, { consequences: ['a', 'b', 'c'] })], '').decisions[0].next.length, 2); `) } + +// TestStageTrackerAdvisoryCloseReadProgress (hivecommons/hive#15436, owner: +// "i clicked close and it still shows in list. I should see some progress +// … until the item is closed and is out of the list"): Close (read) on an +// advisory row acts on the row itself (it is not a decision park, so the +// decision-target mapping used to come up empty and the click did +// nothing), the chevron is busy with "Closing…" from the first byte sent, +// reads "Closed · leaving list" once the server answers, and the pending +// state lifts when the next tracker payload no longer lists the row. A +// refused or failed close restores the chevron, toasts the reason and +// puts it on the row's history badge; an empty target list is never silent. +func TestStageTrackerAdvisoryCloseReadProgress(t *testing.T) { + html := indexHTML(t) + runStageTrackerRowActionsScript(t, stageTrackerRowActionsPreamble(t, html)+stageTrackerConfirmOptOutJS(t, html)+"\n"+jsConstBlock(t, html, "STAGE_TRACKER_ICONS")+"\n"+stageTrackerActedJS(t, html)+` +const toasts = []; +global.showToast = (msg, type) => { toasts.push(type + ':' + msg); return null; }; +global.dismissToast = () => {}; +global.setTimeout = fn => fn(); +function stageTrackerProgressToast() { return { update() {}, done(msg, type) { if (msg) toasts.push('summary:' + type + ':' + msg); } }; } +function stageTrackerAfterActions() {} +function stageTrackerDecidePending(pend) { pend.decided = true; } +// hivecommons/hive#15381 as the tracker lists it: stage 0, no modifiers, advisory block. +const adv = { repo: 'hivecommons/hive', kind: 'issue', number: 15381, url: 'u15381', title: 'triage: duplicate and overlapping open issues/PRs to consolidate', stage: 0, caption: 'Advisory for maintainers · nothing found · safe to close', modifiers: [], labels: ['help wanted', 'agent/dedupe', 'triage/advisory'], + advisory: { kind: 'advisory', source: 'label', empty: true, chip: 'Advisory · nothing found · safe to close', caption: 'Advisory for maintainers · nothing found · safe to close' } }; +const plain = { repo: 'hivecommons/hive', kind: 'issue', number: 2, url: 'u2', stage: 10, caption: 'Open', modifiers: [] }; +_stageTracker = { items: [adv, plain] }; +hamPanel.appendChild(hamStubRow('hivecommons/hive/issue#15381')); hamPanel.appendChild(hamStubRow('hivecommons/hive/issue#2')); +const row = k => hamPanel.querySelectorAll('[data-ham-key], [data-ham-sub-key]').find(n => n.getAttribute('data-ham-key') === k); +const acting = k => row(k).classList.contains('cue-acting'); +const caption = k => { const c = row(k).children[0].querySelector(':scope > .cue-acting-cap'); return c ? c.lastChild.nodeValue : ''; }; +const K = 'hivecommons/hive/issue#15381'; + +assert.strictEqual(stageTrackerDecisionTarget(adv), null, 'an advisory is not a decision park'); +assert.deepStrictEqual(stageTrackerActionRequest(adv, 'decide:close-read', {}), { url: '/api/repos/hivecommons/hive/items/15381/decision', body: { decision: 'close-read', comment: '', type: 'issue' } }); +assert.strictEqual(stageTrackerTerminalCaption({ action: 'closed' }), 'Closed · leaving list'); +assert.strictEqual(stageTrackerTerminalCaption({ action: 'held' }), ''); + +const calls = []; let answer = null; let seenBusy = ''; +global.fetch = async (url, init) => { + calls.push({ url, body: JSON.parse(init.body) }); + seenBusy = acting(K) ? caption(K) : ''; + if (answer instanceof Error) throw answer; + return { ok: answer.ok !== false, status: answer.status || 200, json: async () => answer.data }; +}; +(async () => { + // 1. Happy path: confirm → request → busy → terminal caption → gone on the next payload. + answer = { data: { ok: true, status: 'closed', decision: 'close-read', result: { action: 'closed', target: { repo: 'hivecommons/hive', kind: 'issue', number: 15381, url: 'u15381' }, outcome: 'Closed as read (advisory acknowledged).', next: 'Nothing further to do; the row leaves the tracker on its next refresh.' } } }; + let out = await runRowAction('decide:close-read', [adv]); + assert.strictEqual(dialogs.length, 1, 'Close (read) asks once'); assert.strictEqual(dialogs[0].cfg.title, 'Close (read)'); + assert.strictEqual(calls.length, 1, 'the request is sent'); assert.strictEqual(calls[0].url, '/api/repos/hivecommons/hive/items/15381/decision'); assert.strictEqual(calls[0].body.decision, 'close-read'); + assert.strictEqual(seenBusy, 'Closing…', 'the chevron is busy with the verb from the first byte sent'); + assert.strictEqual(out.results[0].ok, true); + assert.strictEqual(acting(K), true, 'still acting after the answer'); + assert.strictEqual(caption(K), 'Closed · leaving list', 'the terminal caption until the row leaves'); + assert.strictEqual(out.pending.length, 1); assert.strictEqual(out.pending[0].decided, true, 'the badge may show again'); + assert.strictEqual(out.toasts.length, 1); assert.strictEqual(out.toasts[0].text.type, 'success'); + // The same payload again (GitHub list lagging) keeps the terminal caption. + stageTrackerPendingExpire({ items: [adv, plain] }, Date.now()); + assert.strictEqual(_stageTrackerPending.length, 1, 'the pending state survives an unchanged payload'); + // The server filtered the closed row out: pending lifts. + stageTrackerPendingExpire({ items: [plain] }, Date.now()); + assert.strictEqual(_stageTrackerPending.length, 0, 'pending lifts once the row is gone'); + assert.strictEqual(stageTrackerActionFailureOf(adv), null, 'no failure noted on success'); + + // 2. Refused (paused repo): 200 with a refused result — chevron restored, toast + badge say why. + calls.length = 0; toasts.length = 0; dialogs.length = 0; + answer = { data: { ok: true, status: 'refused', decision: 'close-read', result: { action: 'refused', target: { repo: 'hivecommons/hive', kind: 'issue', number: 15381 }, outcome: 'Close refused: repo paused — hivecommons/hive is paused by the operator (by clubanderson: freeze).', next: 'Resume the repository to let the dashboard close it, or close it on GitHub yourself.' } } }; + out = await runRowAction('decide:close-read', [adv]); + assert.strictEqual(calls.length, 1); + assert.strictEqual(acting(K), false, 'a refused close does not leave the chevron busy'); + assert.strictEqual(out.toasts[0].text.type, 'warning'); + assert.ok(out.toasts[0].text.outcome.startsWith('Close refused: repo paused'), out.toasts[0].text.outcome); + let f = stageTrackerActionFailureOf(adv); + assert.ok(f && f.state === 'failed' && f.action === 'close-read', JSON.stringify(f)); + let src = stageTrackerActedSource(adv); + assert.strictEqual(src.action.detail, answer.data.result.outcome, 'the badge reads the client-noted failure'); + let tip = stageTrackerActedTip(adv, Date.now()); + assert.ok(tip.split('\n')[0].includes('Close refused: repo paused'), 'hover first line: ' + tip); + assert.ok(tip.includes('Closed (read)') && tip.includes('failed'), tip); + + // 3. GitHub 403: the error toast names it; the badge too. + calls.length = 0; toasts.length = 0; + answer = { ok: false, status: 403, data: { error: 'GitHub 403 Resource not accessible by integration' } }; + out = await runRowAction('decide:close-read', [adv]); + assert.strictEqual(acting(K), false); + assert.strictEqual(out.results[0].ok, false); assert.strictEqual(out.toasts[0].text.type, 'error'); + assert.strictEqual(out.toasts[0].text.head, 'Close (read) failed on hivecommons/hive#15381'); + assert.ok(out.toasts[0].text.outcome.includes('GitHub 403'), out.toasts[0].text.outcome); + tip = stageTrackerActedTip(adv, Date.now()); + assert.ok(tip.split('\n')[0].includes('Close (read) failed: GitHub 403'), tip); + // A newer server record outranks the client note. + const later = { ...adv, last_operator_action: { action: 'close-read', actor: 'clubanderson', at: new Date(Date.now() + 1000).toISOString(), outcome: 'applied', detail: 'closed', state: 'addressed' } }; + assert.strictEqual(stageTrackerActionFailureOf(later), null); + assert.strictEqual(stageTrackerActedSource(later).action.outcome, 'applied'); + + // 4. Network error. + calls.length = 0; toasts.length = 0; + answer = new Error('Failed to fetch'); + out = await runRowAction('decide:close-read', [adv]); + assert.strictEqual(acting(K), false); assert.strictEqual(out.results[0].error, 'Failed to fetch'); + assert.ok(stageTrackerActedTip(adv, Date.now()).includes('Failed to fetch')); + + // 5. Not an advisory / no decision target: never silent. + calls.length = 0; toasts.length = 0; dialogs.length = 0; + out = await runRowAction('decide:close-read', [plain]); + assert.strictEqual(calls.length, 0); assert.strictEqual(dialogs.length, 0); + assert.strictEqual(toasts.length, 1); assert.ok(toasts[0].startsWith('warning:Close (read): nothing to act on'), toasts[0]); + toasts.length = 0; + out = await runRowAction('decide:approve', [plain]); + assert.strictEqual(calls.length, 0); + assert.ok(toasts[0].startsWith('warning:Approve: nothing to act on'), toasts[0]); + + // 6. Generic: close-superseded on a parked PR gets the same terminal caption. + const pr = { repo: 'hivecommons/hive', kind: 'pr', number: 9, url: 'u9', stage: 85, caption: 'Needs human decision', modifiers: ['needs-decision'] }; + _stageTracker = { items: [pr] }; hamPanel.appendChild(hamStubRow('hivecommons/hive/pr#9')); + calls.length = 0; dialogAnswer = ''; + answer = { data: { ok: true, status: 'closed', result: { action: 'closed', target: { repo: 'hivecommons/hive', kind: 'pr', number: 9 }, outcome: 'Closed as superseded.', next: '' } } }; + out = await runRowAction('decide:close-wontfix', [pr]); + assert.strictEqual(calls.length, 1); + assert.strictEqual(caption('hivecommons/hive/pr#9'), 'Closed · leaving list'); +})().catch(e => { console.error(e); process.exit(1); }); +`) +} diff --git a/src/pkg/dashboard/static-src/js/tracker-actions.js b/src/pkg/dashboard/static-src/js/tracker-actions.js index 4f44bf1a60..84f54ea6dd 100644 --- a/src/pkg/dashboard/static-src/js/tracker-actions.js +++ b/src/pkg/dashboard/static-src/js/tracker-actions.js @@ -1094,6 +1094,7 @@ const keys = stageTrackerPendingKeys(it, rows); const pend = stageTrackerSetPending(keys, stageTrackerActingCaption(id, it)); pending.push(pend); + stageTrackerClearActionFailure(it); try { const r = await fetch(req.url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(req.body) }); let data = await r.json().catch(() => ({})); @@ -1117,8 +1118,16 @@ // row's next state (the gate, or "Rebasing · attempt n/2") is // the tracker's to show, so "Approving…" must not linger beside // the ✓ waiting for it (#15103). + if (result.action === 'refused') stageTrackerNoteActionFailure(it, id, result.outcome || 'refused'); if (result.action === STAGE_TRACKER_ACTION_NOOP || result.action === STAGE_TRACKER_ACTION_NO_EFFECT || result.action === 'refused' || result.action === 'approved') stageTrackerClearPending(pend); - else { if (typeof stageTrackerDecidePending === 'function') stageTrackerDecidePending(pend, result, stageTrackerItemByKey(_stageTracker, stageTrackerTargetKey(result.target))); stageTrackerArmPending(pend, result.target); } + else { + if (typeof stageTrackerDecidePending === 'function') stageTrackerDecidePending(pend, result, stageTrackerItemByKey(_stageTracker, stageTrackerTargetKey(result.target))); + // Closed / merged: the terminal caption stays on the chevron + // until the row leaves the list on the next tracker poll. + const terminal = stageTrackerTerminalCaption(result); + if (terminal) { pend.caption = terminal; pend.decided = true; } + stageTrackerArmPending(pend, result.target); + } if (result.action !== STAGE_TRACKER_ACTION_NOOP && result.action !== STAGE_TRACKER_ACTION_NO_EFFECT && typeof stageTrackerNoteOwnerEvent === 'function') stageTrackerNoteOwnerEvent(stageTrackerTargetKey(result.target) || stageTrackerItemKey(it), STAGE_TRACKER_ACTION_WORDS[result.action] || stageTrackerActionLabel(id)); if (items.length <= STAGE_TRACKER_RESULT_TOAST_MAX) toasts.push(stageTrackerResultToast(result, it, { id, rowRef: stageTrackerRefOf(it) })); // An issue decided per PR: one toast per PR as well, each on its @@ -1131,6 +1140,7 @@ const error = e && e.message ? e.message : 'network error'; results.push({ item: it, ok: false, error }); stageTrackerClearPending(pend); + stageTrackerNoteActionFailure(it, id, stageTrackerActionLabel(id) + ' failed: ' + error); if (items.length <= STAGE_TRACKER_RESULT_TOAST_MAX) toasts.push(stageTrackerResultToast(stageTrackerErrorResult(id, it, error), it, { id, rowRef: stageTrackerRefOf(it) })); } } @@ -1544,6 +1554,39 @@ held: 'held', released: 'hold released', rescanned: 'rescanned', 'triage-accepted': 'triage accepted', 'needs-human': 'marked needs-human', rerouted: 'rerouted', [STAGE_TRACKER_ACTION_NOOP]: 'no change', [STAGE_TRACKER_ACTION_NO_EFFECT]: 'no effect yet', }; + // Once the server has answered, a terminal action's caption says so + // until the tracker drops the row ("Closed · leaving list"); the row + // cannot come back meanwhile because the server filters an + // operator-closed item out of its next snapshots (hivecommons/hive#15436). + const STAGE_TRACKER_TERMINAL_CAPTIONS = { closed: 'Closed · leaving list', merged: 'Merged · leaving list' }; + function stageTrackerTerminalCaption(result) { + return STAGE_TRACKER_TERMINAL_CAPTIONS[result && result.action] || ''; + } + // The ledger name of a row action id (the inverse of the badge's + // STAGE_TRACKER_ACTED_OPTION_ID), for a failure noted on the client. + const STAGE_TRACKER_ACTION_LEDGER_NAME = { 'decide:delegate': 'let-hive-decide', 'decide:approve': 'approve', 'decide:direction': 'give-direction', 'decide:close-superseded': 'close-superseded', 'decide:close-wontfix': 'wontfix', 'decide:close-read': 'close-read', 'accept-triage': 'accept-triage', hold: 'hold', release: 'release', 'needs-human': 'mark-needs-human', 'decide:merge-now': 'merge-now', 'decide:queue-merge': 'queue-merge', 'decide:re-author': 're-author', 'decide:adopt': 'adopt', 'decide:adopt-now': 'adopt-now', 'decide:reroute': 'reroute' }; + // A failed or refused action is noted on the row at once, so the + // history badge turns red and its hover's first line names the reason + // — the server's ledger only sees 5xx and refused answers, and a + // network error never reaches it (hivecommons/hive#15436). Keyed by + // item; the next action on the row, or a newer server record, replaces it. + var _stageTrackerActionFailures = {}; + function stageTrackerNoteActionFailure(item, id, why, now) { + const key = stageTrackerItemKey(item); + const at = new Date(typeof now === 'number' ? now : Date.now()).toISOString(); + _stageTrackerActionFailures[key] = { action: STAGE_TRACKER_ACTION_LEDGER_NAME[stageTrackerActionBase(id)] || stageTrackerActionBase(id), actor: (typeof window !== 'undefined' && window._hiveUser) || '', at, outcome: 'failed', detail: why, progress: why, state: 'failed' }; + return _stageTrackerActionFailures[key]; + } + function stageTrackerClearActionFailure(item) { delete _stageTrackerActionFailures[stageTrackerItemKey(item)]; } + // Pure: the client-noted failure for an item when it is newer than the + // server's record (or there is none); null otherwise. + function stageTrackerActionFailureOf(item) { + const f = item ? _stageTrackerActionFailures[stageTrackerItemKey(item)] : null; + if (!f) return null; + const srv = item.last_operator_action; + if (srv && (Date.parse(srv.at || '') || 0) >= (Date.parse(f.at) || 0)) return null; + return f; + } function stageTrackerActingCaption(id, item) { if (id === 'decide:merge-now' && item && stageTrackerNeedsRebase(item)) return 'Rebasing, then merging…'; return STAGE_TRACKER_ACTING_CAPTIONS[stageTrackerActionBase(id)] || 'acting…'; @@ -1761,6 +1804,17 @@ } } } + // Pure: the row's advisory block when it is one (tracker-row.js owns the + // detection for the chevron; here only the server's flag counts). + function stageTrackerAdvisoryOf(item) { + return item && item.kind !== 'pr' && item.advisory && typeof item.advisory === 'object' ? item.advisory : null; + } + // A row action whose target mapping came up empty says so instead of + // returning silently (hivecommons/hive#15436). + function stageTrackerNothingToActOn(id, rows) { + const refs = (rows || []).map(stageTrackerRefOf).filter(Boolean).join(', '); + if (typeof showToast === 'function') showToast(stageTrackerActionLabel(id) + ': nothing to act on' + (refs ? ' — ' + refs + ' is not waiting on that decision' : ''), 'warning'); + } async function runRowAction(action, row) { let items = Array.isArray(row) ? row.slice() : (row ? [row] : []); const id = action; @@ -1800,6 +1854,13 @@ // Adopt now / Reroute act on the PR waiting on its contributor (072 / 071). items = items.map(stageTrackerTakeoverTarget).filter(Boolean); if (!items.length) return { toasts: [], pending: [] }; + } else if (id === 'decide:close-read') { + // Close (read) acts on the advisory row itself: an advisory is not + // a decision park, so it has no decision target + // (hivecommons/hive#15436 — the click used to map to nothing and + // return without a request, a dialog or a toast). + items = items.filter(stageTrackerAdvisoryOf); + if (!items.length) { stageTrackerNothingToActOn(id, rows); return { toasts: [], pending: [] }; } } else if (id.indexOf('decide:') === 0) { // A row decides its parked PR when it has one (the issue's stage is // only mirrored from it); dedupe when the PR row is selected too. @@ -1811,7 +1872,7 @@ // deciding just that PR ("Decide PR #N › Let hive decide"). items = [].concat(...items.map(it => id === 'decide:delegate' ? stageTrackerDelegateTargets(it) : [stageTrackerDecisionTarget(it)])) .filter(t => t && !seen[stageTrackerItemKey(t)] && (seen[stageTrackerItemKey(t)] = true)); - if (!items.length) return { toasts: [], pending: [] }; + if (!items.length) { stageTrackerNothingToActOn(id, rows); return { toasts: [], pending: [] }; } } const payload = await stageTrackerActionPayload(items, id); if (payload == null) return { toasts: [], pending: [], cancelled: true }; diff --git a/src/pkg/dashboard/static-src/js/tracker-row.js b/src/pkg/dashboard/static-src/js/tracker-row.js index 4be085ba19..96a3bfd5a6 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row.js +++ b/src/pkg/dashboard/static-src/js/tracker-row.js @@ -649,6 +649,10 @@ // row drawn over its single covering PR) that PR's; null when none. function stageTrackerActedSource(item) { if (!item) return null; + // A failure this client just saw outranks an older server record + // (hivecommons/hive#15436): the badge goes red at once. + const failed = typeof stageTrackerActionFailureOf === 'function' ? stageTrackerActionFailureOf(item) : null; + if (failed) return { item, action: failed, count: (Number(item.operator_action_count) || 0) + 1 }; if (item.last_operator_action) return { item, action: item.last_operator_action, count: Number(item.operator_action_count) || 1 }; const linked = Array.isArray(item.linked_prs) ? item.linked_prs : []; if (item.kind === 'issue' && linked.length === 1 && linked[0].last_operator_action) { diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 2dee85cc4c..562eaad046 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -16125,6 +16125,10 @@

Where to get help

// row drawn over its single covering PR) that PR's; null when none. function stageTrackerActedSource(item) { if (!item) return null; + // A failure this client just saw outranks an older server record + // (hivecommons/hive#15436): the badge goes red at once. + const failed = typeof stageTrackerActionFailureOf === 'function' ? stageTrackerActionFailureOf(item) : null; + if (failed) return { item, action: failed, count: (Number(item.operator_action_count) || 0) + 1 }; if (item.last_operator_action) return { item, action: item.last_operator_action, count: Number(item.operator_action_count) || 1 }; const linked = Array.isArray(item.linked_prs) ? item.linked_prs : []; if (item.kind === 'issue' && linked.length === 1 && linked[0].last_operator_action) { @@ -19302,6 +19306,7 @@

All labels

const keys = stageTrackerPendingKeys(it, rows); const pend = stageTrackerSetPending(keys, stageTrackerActingCaption(id, it)); pending.push(pend); + stageTrackerClearActionFailure(it); try { const r = await fetch(req.url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(req.body) }); let data = await r.json().catch(() => ({})); @@ -19325,8 +19330,16 @@

All labels

// row's next state (the gate, or "Rebasing · attempt n/2") is // the tracker's to show, so "Approving…" must not linger beside // the ✓ waiting for it (#15103). + if (result.action === 'refused') stageTrackerNoteActionFailure(it, id, result.outcome || 'refused'); if (result.action === STAGE_TRACKER_ACTION_NOOP || result.action === STAGE_TRACKER_ACTION_NO_EFFECT || result.action === 'refused' || result.action === 'approved') stageTrackerClearPending(pend); - else { if (typeof stageTrackerDecidePending === 'function') stageTrackerDecidePending(pend, result, stageTrackerItemByKey(_stageTracker, stageTrackerTargetKey(result.target))); stageTrackerArmPending(pend, result.target); } + else { + if (typeof stageTrackerDecidePending === 'function') stageTrackerDecidePending(pend, result, stageTrackerItemByKey(_stageTracker, stageTrackerTargetKey(result.target))); + // Closed / merged: the terminal caption stays on the chevron + // until the row leaves the list on the next tracker poll. + const terminal = stageTrackerTerminalCaption(result); + if (terminal) { pend.caption = terminal; pend.decided = true; } + stageTrackerArmPending(pend, result.target); + } if (result.action !== STAGE_TRACKER_ACTION_NOOP && result.action !== STAGE_TRACKER_ACTION_NO_EFFECT && typeof stageTrackerNoteOwnerEvent === 'function') stageTrackerNoteOwnerEvent(stageTrackerTargetKey(result.target) || stageTrackerItemKey(it), STAGE_TRACKER_ACTION_WORDS[result.action] || stageTrackerActionLabel(id)); if (items.length <= STAGE_TRACKER_RESULT_TOAST_MAX) toasts.push(stageTrackerResultToast(result, it, { id, rowRef: stageTrackerRefOf(it) })); // An issue decided per PR: one toast per PR as well, each on its @@ -19339,6 +19352,7 @@

All labels

const error = e && e.message ? e.message : 'network error'; results.push({ item: it, ok: false, error }); stageTrackerClearPending(pend); + stageTrackerNoteActionFailure(it, id, stageTrackerActionLabel(id) + ' failed: ' + error); if (items.length <= STAGE_TRACKER_RESULT_TOAST_MAX) toasts.push(stageTrackerResultToast(stageTrackerErrorResult(id, it, error), it, { id, rowRef: stageTrackerRefOf(it) })); } } @@ -19752,6 +19766,39 @@

All labels

held: 'held', released: 'hold released', rescanned: 'rescanned', 'triage-accepted': 'triage accepted', 'needs-human': 'marked needs-human', rerouted: 'rerouted', [STAGE_TRACKER_ACTION_NOOP]: 'no change', [STAGE_TRACKER_ACTION_NO_EFFECT]: 'no effect yet', }; + // Once the server has answered, a terminal action's caption says so + // until the tracker drops the row ("Closed · leaving list"); the row + // cannot come back meanwhile because the server filters an + // operator-closed item out of its next snapshots (hivecommons/hive#15436). + const STAGE_TRACKER_TERMINAL_CAPTIONS = { closed: 'Closed · leaving list', merged: 'Merged · leaving list' }; + function stageTrackerTerminalCaption(result) { + return STAGE_TRACKER_TERMINAL_CAPTIONS[result && result.action] || ''; + } + // The ledger name of a row action id (the inverse of the badge's + // STAGE_TRACKER_ACTED_OPTION_ID), for a failure noted on the client. + const STAGE_TRACKER_ACTION_LEDGER_NAME = { 'decide:delegate': 'let-hive-decide', 'decide:approve': 'approve', 'decide:direction': 'give-direction', 'decide:close-superseded': 'close-superseded', 'decide:close-wontfix': 'wontfix', 'decide:close-read': 'close-read', 'accept-triage': 'accept-triage', hold: 'hold', release: 'release', 'needs-human': 'mark-needs-human', 'decide:merge-now': 'merge-now', 'decide:queue-merge': 'queue-merge', 'decide:re-author': 're-author', 'decide:adopt': 'adopt', 'decide:adopt-now': 'adopt-now', 'decide:reroute': 'reroute' }; + // A failed or refused action is noted on the row at once, so the + // history badge turns red and its hover's first line names the reason + // — the server's ledger only sees 5xx and refused answers, and a + // network error never reaches it (hivecommons/hive#15436). Keyed by + // item; the next action on the row, or a newer server record, replaces it. + var _stageTrackerActionFailures = {}; + function stageTrackerNoteActionFailure(item, id, why, now) { + const key = stageTrackerItemKey(item); + const at = new Date(typeof now === 'number' ? now : Date.now()).toISOString(); + _stageTrackerActionFailures[key] = { action: STAGE_TRACKER_ACTION_LEDGER_NAME[stageTrackerActionBase(id)] || stageTrackerActionBase(id), actor: (typeof window !== 'undefined' && window._hiveUser) || '', at, outcome: 'failed', detail: why, progress: why, state: 'failed' }; + return _stageTrackerActionFailures[key]; + } + function stageTrackerClearActionFailure(item) { delete _stageTrackerActionFailures[stageTrackerItemKey(item)]; } + // Pure: the client-noted failure for an item when it is newer than the + // server's record (or there is none); null otherwise. + function stageTrackerActionFailureOf(item) { + const f = item ? _stageTrackerActionFailures[stageTrackerItemKey(item)] : null; + if (!f) return null; + const srv = item.last_operator_action; + if (srv && (Date.parse(srv.at || '') || 0) >= (Date.parse(f.at) || 0)) return null; + return f; + } function stageTrackerActingCaption(id, item) { if (id === 'decide:merge-now' && item && stageTrackerNeedsRebase(item)) return 'Rebasing, then merging…'; return STAGE_TRACKER_ACTING_CAPTIONS[stageTrackerActionBase(id)] || 'acting…'; @@ -19969,6 +20016,17 @@

All labels

} } } + // Pure: the row's advisory block when it is one (tracker-row.js owns the + // detection for the chevron; here only the server's flag counts). + function stageTrackerAdvisoryOf(item) { + return item && item.kind !== 'pr' && item.advisory && typeof item.advisory === 'object' ? item.advisory : null; + } + // A row action whose target mapping came up empty says so instead of + // returning silently (hivecommons/hive#15436). + function stageTrackerNothingToActOn(id, rows) { + const refs = (rows || []).map(stageTrackerRefOf).filter(Boolean).join(', '); + if (typeof showToast === 'function') showToast(stageTrackerActionLabel(id) + ': nothing to act on' + (refs ? ' — ' + refs + ' is not waiting on that decision' : ''), 'warning'); + } async function runRowAction(action, row) { let items = Array.isArray(row) ? row.slice() : (row ? [row] : []); const id = action; @@ -20008,6 +20066,13 @@

All labels

// Adopt now / Reroute act on the PR waiting on its contributor (072 / 071). items = items.map(stageTrackerTakeoverTarget).filter(Boolean); if (!items.length) return { toasts: [], pending: [] }; + } else if (id === 'decide:close-read') { + // Close (read) acts on the advisory row itself: an advisory is not + // a decision park, so it has no decision target + // (hivecommons/hive#15436 — the click used to map to nothing and + // return without a request, a dialog or a toast). + items = items.filter(stageTrackerAdvisoryOf); + if (!items.length) { stageTrackerNothingToActOn(id, rows); return { toasts: [], pending: [] }; } } else if (id.indexOf('decide:') === 0) { // A row decides its parked PR when it has one (the issue's stage is // only mirrored from it); dedupe when the PR row is selected too. @@ -20019,7 +20084,7 @@

All labels

// deciding just that PR ("Decide PR #N › Let hive decide"). items = [].concat(...items.map(it => id === 'decide:delegate' ? stageTrackerDelegateTargets(it) : [stageTrackerDecisionTarget(it)])) .filter(t => t && !seen[stageTrackerItemKey(t)] && (seen[stageTrackerItemKey(t)] = true)); - if (!items.length) return { toasts: [], pending: [] }; + if (!items.length) { stageTrackerNothingToActOn(id, rows); return { toasts: [], pending: [] }; } } const payload = await stageTrackerActionPayload(items, id); if (payload == null) return { toasts: [], pending: [], cancelled: true }; From d206859def5e369f92a4b8f7f6dbd2e0fc7a4755 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Thu, 29 Oct 2026 13:45:52 -0400 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8C=B1=20move=20changelog=20fragment?= =?UTF-8?q?=20to=20changelog.d/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andrew Anderson --- .../fixed-tracker-advisory-close-progress.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {src/changelog.d => changelog.d}/fixed-tracker-advisory-close-progress.md (100%) diff --git a/src/changelog.d/fixed-tracker-advisory-close-progress.md b/changelog.d/fixed-tracker-advisory-close-progress.md similarity index 100% rename from src/changelog.d/fixed-tracker-advisory-close-progress.md rename to changelog.d/fixed-tracker-advisory-close-progress.md