From f4551549cbce72375cec88b115ed17997b343de0 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2026 02:56:10 -0400 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=8C=B1=20refactor:=20split=20static-s?= =?UTF-8?q?rc/js/tracker-filter.js=20into=204=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- src/docs/dashboard-source-layout.md | 5 +- .../static-src/js/tracker-filter-fetch.js | 164 +++++ .../static-src/js/tracker-filter-render.js | 209 +++++++ .../static-src/js/tracker-filter-state.js | 206 +++++++ .../dashboard/static-src/js/tracker-filter.js | 579 ------------------ src/pkg/dashboard/static-src/manifest.txt | 3 + 6 files changed, 585 insertions(+), 581 deletions(-) create mode 100644 src/pkg/dashboard/static-src/js/tracker-filter-fetch.js create mode 100644 src/pkg/dashboard/static-src/js/tracker-filter-render.js create mode 100644 src/pkg/dashboard/static-src/js/tracker-filter-state.js diff --git a/src/docs/dashboard-source-layout.md b/src/docs/dashboard-source-layout.md index 8407650d9f..5b60594799 100644 --- a/src/docs/dashboard-source-layout.md +++ b/src/docs/dashboard-source-layout.md @@ -76,8 +76,9 @@ Body HTML (`html/`): `auth`, `root-notices`, `chat`, `dialogs`, `sidebar`, JS (`js/`): `boot`, `core`, `feedback`, `sections`, `layout`, `agent-detail`, `sidebar`, `history-sparklines`, `cost-trend`, `stats`, `agent-now`, `tracker-words`, `tracker-row`, `tracker-row-strip`, `tracker-row-acted`, -`tracker-row-layout`, `tracker-motion`, `tracker-filter`, `tracker-actions`, -`tracker-merged`, `tracker-sound`, `agent-cards`, `banners`, +`tracker-row-layout`, `tracker-motion`, `tracker-filter`, +`tracker-filter-state`, `tracker-filter-render`, `tracker-filter-fetch`, +`tracker-actions`, `tracker-merged`, `tracker-sound`, `agent-cards`, `banners`, `governor-view`, `repos`, `overview`, `label-filter`, `pinned-filters`, `repos-render`, `budget`, `backends-tokens`, `cost`, `acmm-lifecycle`, `throughput`, `evidence`, `approvals`, `nous`, `knowledge`, `vault-audit`, diff --git a/src/pkg/dashboard/static-src/js/tracker-filter-fetch.js b/src/pkg/dashboard/static-src/js/tracker-filter-fetch.js new file mode 100644 index 0000000000..ca4dba9b82 --- /dev/null +++ b/src/pkg/dashboard/static-src/js/tracker-filter-fetch.js @@ -0,0 +1,164 @@ + async function fetchStageTracker() { + try { + if (!_stageTrackerSig && !_stageTrackerEtag) stageTrackerLoadGrouping(); + if (!_stageTrackerSig && !_stageTrackerEtag) { stageTrackerLoadFilter(); stageTrackerSoundInit(); } + if (!_stageTrackerSig && !_stageTrackerEtag) stageTrackerApplyUrlFilter(); + const r = await fetch('/api/stage-tracker', _stageTrackerEtag ? { headers: { 'If-None-Match': _stageTrackerEtag } } : undefined); + if (r.status === 304) { + // A 304 carries no body, so take generated_at/source from the headers or the "updated" chip goes amber on a quiet hive. + const at = r.headers.get('X-Hive-Stage-Tracker-Generated-At'); + const src = r.headers.get('X-Hive-Stage-Tracker-Source'); + if (_stageTracker) { + if (at) _stageTracker.generated_at = at; + if (src) _stageTracker.source = src; + } + stageTrackerPollOk(); + stageTrackerTickClock(); + return; + } + if (!r.ok) { stageTrackerPollFailed('HTTP ' + r.status); return; } + _stageTrackerEtag = r.headers.get('ETag') || ''; + const text = await r.text(); + stageTrackerPollOk(); + if (text === _stageTrackerSig) { stageTrackerTickClock(); return; } + _stageTrackerSig = text; + renderStageTracker(JSON.parse(text)); + dashboardSetInterval('stage-tracker-clock', stageTrackerTickClock, STAGE_TRACKER_CLOCK_MS); + } catch (e) { + // Network failure or an aborted body: keep the previous render but + // say so in the "updated" chip instead of letting it read "fresh". + stageTrackerPollFailed('unreachable'); + } + } + + /* ---- Row actions: context menu + multi-select ------------------------- + A right-click (or the ⋯ kebab, Shift+F10, the context-menu key) on a + row opens an in-app menu of the actions that apply to that row's + state. The checkbox in the left gutter selects rows (Shift+click for + a range, Cmd/Ctrl+click to toggle); the selection bar above the list + carries the actions valid for every selected row and greys out the + rest with the reason. Selection is keyed on the row's item key, so + the ~1 s reconcile keeps it; rows that leave the list drop out of it. + Every action goes through an existing dashboard endpoint (hold, + send-to-human, rescan) or the decision endpoint, which records the + same /hive approve|decision a maintainer would — nothing merges. */ + const STAGE_TRACKER_DECISION_STAGES = [45, 85]; + const STAGE_TRACKER_SEL_ACTIONS = ['hold', 'release', 'retry', 'needs-human', 'copy']; + const STAGE_TRACKER_MENU_MARGIN = 4; + const STAGE_TRACKER_MENU_FAIL_LINES = 3; + // One source of plain words for every decision rule / action / reason + // (mirrors pkg/delegatedecision.GlossaryJSON(); stage_tracker_glossary_test.go + // fails when they drift). Rule slugs are never shown bare: use + // stageTrackerPlainWords(slug). hivecommons/hive#14822. + const STAGE_TRACKER_DECISION_GLOSSARY = { + "accept-proposal": {"kind": "action", "plain": "accepted the proposal as written", "detail": "The proposal is accepted as written with its stated defaults."}, + "accept-ratchet": {"kind": "action", "plain": "accepted as a ratchet", "detail": "Accepted as a ratchet: baseline recorded now, failures only on increases."}, + "adopt": {"kind": "action", "plain": "hive takes over finishing this PR", "detail": "Adopt means the hive takes over finishing this PR: it rebases, fixes CI and merges it, keeping the author's commits and sign-off."}, + "adopt-supersede": {"kind": "action", "plain": "close this PR and open a fresh hive-authored PR with the same commits", "detail": "Supersede means the hive closes this PR and opens a fresh hive-authored PR carrying the same commits and sign-off, then finishes it itself."}, + "adopted": {"kind": "action", "plain": "close this PR and open a fresh hive-authored PR with the same commits", "detail": "Supersede means the hive closes this PR and opens a fresh hive-authored PR carrying the same commits and sign-off, then finishes it itself."}, + "adoption-disabled": {"kind": "reason", "plain": "adoption is switched off on this hive", "detail": "Stage adoption is disabled on this hive (governor.labels.stage.adoption), so a request to take a PR over is never carried out."}, + "adoption-executing": {"kind": "reason", "plain": "the adoption engine is carrying it out", "detail": "The decision is recorded and the adoption engine picks it up on its next stage pass (a few minutes): it pushes the commits to a hive branch and opens the hive's copy. Nothing to do yet."}, + "adoption-stalled:contributor-lane:workflow-path": {"kind": "reason", "plain": "the PR edits .github/workflows; the hive's App lacks the `workflows` permission, so it cannot adopt it", "detail": "The PR changes files under .github/workflows. The hive's GitHub App has no `workflows` permission, so the adoption fence refuses to publish those edits from the hive. Grant the App the `workflows` permission and re-run the decision, or have a person rebase and merge it on GitHub, or close it as superseded."}, + "adoption-undone": {"kind": "reason", "plain": "the hive's copy was closed without merging and the adoption was undone", "detail": "The hive opened its copy, but the copy was closed without merging and a fresh one could not be opened, so the adoption was undone and the PR is back in its normal flow. Re-run the decision to adopt it again, or act on GitHub."}, + "adoption/supersede": {"kind": "action", "plain": "close this PR and open a fresh hive-authored PR with the same commits", "detail": "Supersede means the hive closes this PR and opens a fresh hive-authored PR carrying the same commits and sign-off, then finishes it itself."}, + "advisory-in-progress": {"kind": "rule", "plain": "a hive advisory the hive is still working; nothing to decide", "detail": "The issue is a hive advisory whose items are still being worked: the sweep ticks each as it closes or merges and closes the advisory when all are resolved. Nothing is written and nobody is parked on it."}, + "advisory-resolved": {"kind": "rule", "plain": "a hive advisory whose items are all resolved; closed as completed", "detail": "The issue is a hive advisory (a dedupe checklist or triage note) and every item it lists is closed or merged, so nothing is left to read; the hive closes it as completed."}, + "already-fixed": {"kind": "rule", "plain": "the issue was already fixed by a merged PR; closed as superseded", "detail": "The issue this PR fixes is already closed and a merged PR closed it (or a merged PR declares it supersedes this one), so nothing is left to deliver. The hive closes the PR as superseded with a note naming the merging PR; it never adopts it."}, + "approve": {"kind": "action", "plain": "approved for merge", "detail": "The hive approved it; the merge queue merges it once every check passes.", "issue_plain": "approved to proceed — an agent may claim it", "issue_detail": "The hive approved the direction; the issue leaves Needs decision and an agent may claim it. Nothing is merged."}, + "approve-review": {"kind": "action", "plain": "approved for merge", "detail": "The hive approved it; the merge queue merges it once every check passes.", "issue_plain": "approved to proceed — an agent may claim it", "issue_detail": "The hive approved the direction; the issue leaves Needs decision and an agent may claim it. Nothing is merged."}, + "approved": {"kind": "action", "plain": "approved for merge", "detail": "The hive approved it; the merge queue merges it once every check passes.", "issue_plain": "approved to proceed — an agent may claim it", "issue_detail": "The hive approved the direction; the issue leaves Needs decision and an agent may claim it. Nothing is merged."}, + "author-association": {"kind": "reason", "plain": "no merge lane vouches for this PR's author; a maintainer merges", "detail": "The PR is ready, but its author is not a collaborator and holds no trusted or merger tier, so no merge lane vouches for them and the hive never merges it unattended. A maintainer approves it (Approve and let hive merge — hive merges on the next tick once CI is green — or Merge now as maintainer), or trusts the author under 👥 Contributors."}, + "author-online": {"kind": "reason", "plain": "the author's clanker or hive is connected, so hive won't take the PR over", "detail": "Adoption is for authors whose clanker or hive has gone offline; this author's is connected, so the hive leaves the PR with them."}, + "behind": {"kind": "reason", "plain": "the branch is behind the base branch", "detail": "The branch is behind the base branch and must be updated before it can merge."}, + "blocker": {"kind": "reason", "plain": "the hive can't do this itself", "detail": "The item is blocked on something the hive cannot do: a permission the GitHub App lacks, or a step only a person may take. No decision clears it; grant the permission (and re-check) or do the step by hand (hivecommons/hive#15099)."}, + "capability": {"kind": "reason", "plain": "the hive can't do this itself", "detail": "The item is blocked on something the hive cannot do: a permission the GitHub App lacks, or a step only a person may take. No decision clears it; grant the permission (and re-check) or do the step by hand (hivecommons/hive#15099)."}, + "capability-gap": {"kind": "rule", "plain": "the GitHub App lacks a permission; deciding cannot clear it", "detail": "The blocker is a missing GitHub App permission (for example `workflows`). Approving a direction would only re-apply needs-human, so the park stays until the owner grants the permission or a person applies the change."}, + "capability:workflows-permission": {"kind": "reason", "plain": "the PR edits .github/workflows; the hive's App lacks the `workflows` permission, so it cannot adopt it", "detail": "The PR changes files under .github/workflows. The hive's GitHub App has no `workflows` permission, so the adoption fence refuses to publish those edits from the hive. Grant the App the `workflows` permission and re-run the decision, or have a person rebase and merge it on GitHub, or close it as superseded."}, + "changes-requested": {"kind": "reason", "plain": "a reviewer asked for changes; a new commit is needed", "detail": "A reviewer asked for changes on this branch. Approving cannot override that: only a new commit, or a maintainer merging by hand, moves it."}, + "changes_requested": {"kind": "reason", "plain": "a reviewer asked for changes; a new commit is needed", "detail": "A reviewer asked for changes on this branch. Approving cannot override that: only a new commit, or a maintainer merging by hand, moves it."}, + "checks-failing": {"kind": "reason", "plain": "CI is failing on this branch", "detail": "Required checks are failing on this branch; nothing merges until they are green."}, + "ci-failing": {"kind": "reason", "plain": "CI is failing on this branch", "detail": "Required checks are failing on this branch; nothing merges until they are green."}, + "ci-ratchet": {"kind": "rule", "plain": "a CI hygiene gate, landed as a ratchet", "detail": "A new CI hygiene gate lands as a ratchet: it records today's baseline and fails only on increases, so existing work is never blocked."}, + "ci-red": {"kind": "reason", "plain": "CI is failing on this branch", "detail": "Required checks are failing on this branch; nothing merges until they are green."}, + "close": {"kind": "action", "plain": "closed as completed; its items are tracked by the hive", "detail": "The hive closed the advisory as completed: every item it listed is resolved, or the hive's sweep tracks the rest."}, + "close-as-duplicate": {"kind": "action", "plain": "closed as a duplicate", "detail": "Closed because an older item already tracks the same work."}, + "close-completed": {"kind": "action", "plain": "closed as completed; its items are tracked by the hive", "detail": "The hive closed the advisory as completed: every item it listed is resolved, or the hive's sweep tracks the rest."}, + "close-duplicate": {"kind": "action", "plain": "closed as a duplicate", "detail": "Closed because an older item already tracks the same work."}, + "close-not-now": {"kind": "action", "plain": "declined for now; closed as not planned", "detail": "The hive declined the proposal for now and closed it as not planned, with the reason and what evidence would reopen it."}, + "close-superseded": {"kind": "action", "plain": "closed because another PR carries the work", "detail": "Closed because another PR carries the same work; the author is credited there.", "issue_plain": "closed because another issue carries the work", "issue_detail": "Closed because another issue already tracks the same work; the discussion continues there."}, + "closed": {"kind": "action", "plain": "closed because another PR carries the work", "detail": "Closed because another PR carries the same work; the author is credited there.", "issue_plain": "closed because another issue carries the work", "issue_detail": "Closed because another issue already tracks the same work; the discussion continues there."}, + "comment-decision": {"kind": "action", "plain": "recorded the decision on GitHub", "detail": "The hive posted the decision as a `/hive decision` comment, the way a maintainer would."}, + "conflict": {"kind": "reason", "plain": "the branch conflicts with the base branch", "detail": "The branch has merge conflicts with the base branch; it needs a rebase before anything can merge."}, + "conflicting": {"kind": "reason", "plain": "the branch conflicts with the base branch", "detail": "The branch has merge conflicts with the base branch; it needs a rebase before anything can merge."}, + "contributor-lane:author-association": {"kind": "reason", "plain": "no merge lane vouches for this PR's author; a maintainer merges", "detail": "The PR is ready, but its author is not a collaborator and holds no trusted or merger tier, so no merge lane vouches for them and the hive never merges it unattended. A maintainer approves it (Approve and let hive merge — hive merges on the next tick once CI is green — or Merge now as maintainer), or trusts the author under 👥 Contributors."}, + "contributor-lane:changes-requested": {"kind": "reason", "plain": "a reviewer asked for changes; a new commit is needed", "detail": "A reviewer asked for changes on this branch. Approving cannot override that: only a new commit, or a maintainer merging by hand, moves it."}, + "contributor-lane:sentinel-blocked": {"kind": "reason", "plain": "security-sensitive files changed; a maintainer must approve", "detail": "Security-sensitive files changed. The hive never merges until a maintainer reviews and removes the sentinel label."}, + "contributor-lane:workflow-path": {"kind": "reason", "plain": "the PR edits .github/workflows; the hive's App lacks the `workflows` permission, so it cannot adopt it", "detail": "The PR changes files under .github/workflows. The hive's GitHub App has no `workflows` permission, so the adoption fence refuses to publish those edits from the hive. Grant the App the `workflows` permission and re-run the decision, or have a person rebase and merge it on GitHub, or close it as superseded."}, + "contributor-offline": {"kind": "rule", "plain": "the author hasn't been reachable since the nudge", "detail": "The PR's author (or their clanker or hive) has been offline since the hive nudged them, so the hive takes the work over instead of waiting. The decision itself names which: the author's clanker, a connected hive, or the author."}, + "dco": {"kind": "reason", "plain": "a commit is missing its sign-off", "detail": "A commit on the branch is missing its Developer Certificate of Origin sign-off; the author must sign it off."}, + "dco-missing": {"kind": "reason", "plain": "a commit is missing its sign-off", "detail": "A commit on the branch is missing its Developer Certificate of Origin sign-off; the author must sign it off."}, + "dedupe": {"kind": "rule", "plain": "an older issue already tracks this", "detail": "An older issue already tracks the same work; one thread keeps it moving."}, + "default-approve": {"kind": "rule", "plain": "no special rule applies; the hive took its own recommendation", "detail": "No owner rule singles this issue out, so the hive went with its own recommendation — the reversible choice that keeps work moving."}, + "default-release": {"kind": "rule", "plain": "no special rule applies; a green branch is approved", "detail": "No owner rule holds this PR back; its branch is green and a merge is reversible, so it is approved."}, + "design-proposal": {"kind": "rule", "plain": "a proposal with clear acceptance criteria, accepted as written", "detail": "The proposal states concrete acceptance criteria, so it is accepted as written; anything not stated keeps today's behaviour."}, + "directed": {"kind": "action", "plain": "told the author agent what to change", "detail": "The hive recorded direction for the author agent, which pushes a new commit with that change.", "issue_plain": "gave direction on the issue", "issue_detail": "The hive recorded direction on the issue; the agent that claims it works from that direction."}, + "direction": {"kind": "action", "plain": "told the author agent what to change", "detail": "The hive recorded direction for the author agent, which pushes a new commit with that change.", "issue_plain": "gave direction on the issue", "issue_detail": "The hive recorded direction on the issue; the agent that claims it works from that direction."}, + "dirty": {"kind": "reason", "plain": "the branch conflicts with the base branch", "detail": "The branch has merge conflicts with the base branch; it needs a rebase before anything can merge."}, + "effect-unknown": {"kind": "reason", "plain": "the hive did not say why", "detail": "The hive could not tell from the lane reason why the decision has not taken effect."}, + "fix-then-merge": {"kind": "rule", "plain": "the branch isn't mergeable yet", "detail": "The branch cannot merge as it is (conflicts, red CI or a missing sign-off); the hive told the author agent exactly what to fix."}, + "flaky-test": {"kind": "rule", "plain": "a flaky test, quarantined with a retry", "detail": "The failure is a flaky test: it is quarantined with a retry and a separate deflake task is filed, so it blocks nothing."}, + "hive-policy": {"kind": "rule", "plain": "this changes the hive's own rules", "detail": "This changes the hive's own settings, governance or security posture; the hive only recommends and the owner confirms."}, + "hold": {"kind": "reason", "plain": "on hold; the hive does nothing until it is released", "detail": "The PR is on hold. The hive does nothing with it until a person releases the hold.", "issue_detail": "The issue is on hold. No agent claims it until a person releases the hold."}, + "human-changes-requested": {"kind": "reason", "plain": "a reviewer asked for changes; a new commit is needed", "detail": "A reviewer asked for changes on this branch. Approving cannot override that: only a new commit, or a maintainer merging by hand, moves it."}, + "human-merge": {"kind": "reason", "plain": "no merge lane vouches for this PR's author; a maintainer merges", "detail": "The PR is ready, but its author is not a collaborator and holds no trusted or merger tier, so no merge lane vouches for them and the hive never merges it unattended. A maintainer approves it (Approve and let hive merge — hive merges on the next tick once CI is green — or Merge now as maintainer), or trusts the author under 👥 Contributors."}, + "human-only": {"kind": "reason", "plain": "the hive can't do this itself", "detail": "The item is blocked on something the hive cannot do: a permission the GitHub App lacks, or a step only a person may take. No decision clears it; grant the permission (and re-check) or do the step by hand (hivecommons/hive#15099)."}, + "label:needs-human": {"kind": "reason", "plain": "marked needs-human; a person must remove the label", "detail": "The item is marked needs-human: automated fixes ran out or a person flagged it. The hive waits until the label is removed."}, + "labels-add": {"kind": "action", "plain": "added labels", "detail": "The hive added labels to the item."}, + "labels-remove": {"kind": "action", "plain": "removed labels", "detail": "The hive removed labels from the item."}, + "link": {"kind": "action", "plain": "cross-linked a related item", "detail": "The hive left a comment linking a related issue or PR."}, + "llm-delegate": {"kind": "rule", "plain": "decided by the hive's model under the owner's rules", "detail": "No mechanical rule applied, so the hive's model decided under the owner's standing rules; the same safety rails applied."}, + "mergeable-as-is": {"kind": "rule", "plain": "mergeable and green as it is; handed to the merge queue", "detail": "The head is mergeable with green CI, so no adoption is needed: the hive approves it and the merge queue takes it as it is."}, + "needs-human": {"kind": "reason", "plain": "marked needs-human; a person must remove the label", "detail": "The item is marked needs-human: automated fixes ran out or a person flagged it. The hive waits until the label is removed."}, + "no-effect": {"kind": "reason", "plain": "the decision hasn't taken effect", "detail": "The hive recorded this decision, but what it was supposed to cause has not happened within the expected time."}, + "no-new-commit": {"kind": "reason", "plain": "no new commit has been pushed", "detail": "The hive gave direction, but no new commit has been pushed yet."}, + "not-closed-yet": {"kind": "reason", "plain": "the close didn't land", "detail": "The hive decided to close it, but it is still open; the close call did not land."}, + "not-merged-yet": {"kind": "reason", "plain": "the merge queue hasn't merged it", "detail": "The hive approved it but the merge queue has not merged it; its lane reason says what still blocks it."}, + "not-now": {"kind": "action", "plain": "declined for now; closed as not planned", "detail": "The hive declined the proposal for now and closed it as not planned, with the reason and what evidence would reopen it."}, + "one-pr-per-issue": {"kind": "rule", "plain": "two PRs fix the same issue; the merge queue keeps one", "detail": "Two open PRs declare the same closing issue. The merge queue carries one PR per issue — a green head first, then the earlier-opened — and the other closes as superseded with credit."}, + "operator-action": {"kind": "action", "plain": "told the spoke owner what to do; nothing for an agent here", "detail": "The hive named the spoke owner and the one action they take (for example re-authenticate the provider). The item stays parked, gets no approved-direction, and clears when the report stops recurring."}, + "owner-only": {"kind": "rule", "plain": "only the hive owner can do this", "detail": "This needs a secret, token or organization permission that only the hive owner holds; the hive cannot do it for you."}, + "owner_only": {"kind": "rule", "plain": "only the hive owner can do this", "detail": "This needs a secret, token or organization permission that only the hive owner holds; the hive cannot do it for you."}, + "park-label-stuck": {"kind": "reason", "plain": "stage/045-needs-decision is still on the issue; the scanner skips it until that label clears", "detail": "The hive approved the issue and applied approved-direction, but the stage/045-needs-decision park label was never removed, so the scanner still skips the issue. Lift the park (it removes the label through the hive's audited label path) or re-evaluate the issue so the stage engine re-reads it."}, + "prefer-contributor": {"kind": "rule", "plain": "a contributor's PR and a hive PR do the same work", "detail": "A contributor's PR and a hive-authored PR cover the same work; the hive prefers the contributor's when it is mergeable and current."}, + "proposal-approve-evidence": {"kind": "rule", "plain": "a proposal backed by an incident or a repeated class; approved", "detail": "The hive-filed proposal names an incident it would have prevented, or prior instances of the same class fixed one at a time, so its cost is justified and it is approved as proposed."}, + "proposal-not-now": {"kind": "rule", "plain": "a hive-filed proposal with no incident or recurrence behind it; declined for now", "detail": "The proposal shows neither an incident it would have prevented nor a repeated class it would end, so its value is speculative. The hive declines it for now and closes it as not planned; re-propose with evidence."}, + "quarantine-flaky": {"kind": "action", "plain": "quarantined the flaky test", "detail": "The flaky test is quarantined with a retry and a deflake task is filed."}, + "rail-hold": {"kind": "rule", "plain": "the item is on hold", "detail": "The item carries the hold label; the hive never acts on a held item until a person releases the hold."}, + "ready-for-human-merge": {"kind": "reason", "plain": "no merge lane vouches for this PR's author; a maintainer merges", "detail": "The PR is ready, but its author is not a collaborator and holds no trusted or merger tier, so no merge lane vouches for them and the hive never merges it unattended. A maintainer approves it (Approve and let hive merge — hive merges on the next tick once CI is green — or Merge now as maintainer), or trusts the author under 👥 Contributors."}, + "rebase-then-merge": {"kind": "rule", "plain": "only conflicts block it; a rebase then merge", "detail": "Conflicts are the only blocker. The unattended rebase-then-merge path lands with hivecommons/hive#15104; until then the ladder records this rung and moves on."}, + "recommend-only": {"kind": "action", "plain": "recommended only; a person confirms", "detail": "The hive only recommended; the item stays parked until a person confirms."}, + "recommended": {"kind": "action", "plain": "recommended only; a person confirms", "detail": "The hive only recommended; the item stays parked until a person confirms."}, + "red": {"kind": "reason", "plain": "CI is failing on this branch", "detail": "Required checks are failing on this branch; nothing merges until they are green."}, + "refused": {"kind": "action", "plain": "did not decide", "detail": "The hive did not decide this item; its safety rails stopped it (for example, the item is on hold)."}, + "reporter-trust": {"kind": "rule", "plain": "the hold on an unknown reporter is cleared because the fix is sound", "detail": "The PR was held until the reporter's trust was known; its fix is green and mergeable, so the hold is cleared."}, + "request_changes": {"kind": "reason", "plain": "a reviewer asked for changes; a new commit is needed", "detail": "A reviewer asked for changes on this branch. Approving cannot override that: only a new commit, or a maintainer merging by hand, moves it."}, + "requires_human": {"kind": "reason", "plain": "marked needs-human; a person must remove the label", "detail": "The item is marked needs-human: automated fixes ran out or a person flagged it. The hive waits until the label is removed."}, + "return-to-author": {"kind": "rule", "plain": "a person pushed this PR; the hive asked them, not adopted it", "detail": "The PR was pushed by a person (author/human or one of this hive's owners), so the hive never adopts it. It told the author by name what to fix (rebase, sign-off, CI) and relayed the reviewer's question."}, + "return-to-contributor": {"kind": "rule", "plain": "the author's clanker or hive is connected; returned to them with the fix list", "detail": "The author's clanker or hive is connected (or has picked the rework up), so the hive hands the PR back to them with the exact fix list instead of adopting it."}, + "review-backlog": {"kind": "rule", "plain": "the PR closed without merging, so the issue stays open", "detail": "The fixing PR closed unmerged; the issue stays open and is re-triaged rather than auto-closed."}, + "reviewer-verdict:request_changes": {"kind": "reason", "plain": "a reviewer asked for changes; a new commit is needed", "detail": "A reviewer asked for changes on this branch. Approving cannot override that: only a new commit, or a maintainer merging by hand, moves it."}, + "self-decision-read-as-changes": {"kind": "reason", "plain": "hive's own decision comment was read as a reviewer asking for changes", "detail": "The merge queue read the hive's own `/hive decision` comment as a reviewer asking for changes, so the decision blocked the PR it meant to advance (hivecommons/hive#14822). A new commit or a maintainer merge clears it."}, + "selfreport-operator-action": {"kind": "rule", "plain": "a spoke self-report only its operator can fix; not code work", "detail": "The issue is a fleet self-report (expired login, credentials, disk, network, App setup) whose remedy is on the reporting spoke. The hive tells that spoke's owner what to do and keeps it out of the actionable set; no agent is sent to code."}, + "sentinel": {"kind": "reason", "plain": "security-sensitive files changed; a maintainer must approve", "detail": "Security-sensitive files changed. The hive never merges until a maintainer reviews and removes the sentinel label."}, + "sentinel-alert": {"kind": "reason", "plain": "security-sensitive files changed; a maintainer must approve", "detail": "Security-sensitive files changed. The hive never merges until a maintainer reviews and removes the sentinel label."}, + "sentinel-blocked": {"kind": "reason", "plain": "security-sensitive files changed; a maintainer must approve", "detail": "Security-sensitive files changed. The hive never merges until a maintainer reviews and removes the sentinel label."}, + "sentinel-trusted": {"kind": "rule", "plain": "security-sensitive files changed, but the author is trusted", "detail": "Security-sensitive files changed; because the author is trusted the hive approved, but a person must still remove the sentinel label before it merges."}, + "sentinel-untrusted": {"kind": "rule", "plain": "security-sensitive files changed; a maintainer must approve", "detail": "Security-sensitive files changed in a PR from an author without write access; a maintainer must review and approve it."}, + "small-low-risk": {"kind": "rule", "plain": "a small, low-risk change on a green branch", "detail": "The change is small and low-risk (docs, CI pins, text, workflow hygiene) and CI is green, so it is approved."}, + "still-parked": {"kind": "reason", "plain": "the item is still waiting on a person", "detail": "The item is still parked for a person's decision; the recorded decision did not move it."}, + "supersede": {"kind": "action", "plain": "close this PR and open a fresh hive-authored PR with the same commits", "detail": "Supersede means the hive closes this PR and opens a fresh hive-authored PR carrying the same commits and sign-off, then finishes it itself."}, + "supersede-now": {"kind": "action", "plain": "close this PR and open a fresh hive-authored PR with the same commits", "detail": "Supersede means the hive closes this PR and opens a fresh hive-authored PR carrying the same commits and sign-off, then finishes it itself."}, + "superseded": {"kind": "action", "plain": "closed because another PR carries the work", "detail": "Closed because another PR carries the same work; the author is credited there.", "issue_plain": "closed because another issue carries the work", "issue_detail": "Closed because another issue already tracks the same work; the discussion continues there."}, + "untrusted-author": {"kind": "reason", "plain": "no merge lane vouches for this PR's author; a maintainer merges", "detail": "The PR is ready, but its author is not a collaborator and holds no trusted or merger tier, so no merge lane vouches for them and the hive never merges it unattended. A maintainer approves it (Approve and let hive merge — hive merges on the next tick once CI is green — or Merge now as maintainer), or trusts the author under 👥 Contributors."}, + "workflow-path": {"kind": "reason", "plain": "the PR edits .github/workflows; the hive's App lacks the `workflows` permission, so it cannot adopt it", "detail": "The PR changes files under .github/workflows. The hive's GitHub App has no `workflows` permission, so the adoption fence refuses to publish those edits from the hive. Grant the App the `workflows` permission and re-run the decision, or have a person rebase and merge it on GitHub, or close it as superseded."}, + }; diff --git a/src/pkg/dashboard/static-src/js/tracker-filter-render.js b/src/pkg/dashboard/static-src/js/tracker-filter-render.js new file mode 100644 index 0000000000..71a9d7dc71 --- /dev/null +++ b/src/pkg/dashboard/static-src/js/tracker-filter-render.js @@ -0,0 +1,209 @@ + function stageTrackerPagerHtml(page) { + if (page.pages <= 1) return ''; + return ``; + } + + // "updated 12s ago · cache" — re-stamped every STAGE_TRACKER_CLOCK_MS + // without a fetch; amber once the payload is older than two TTLs or + // once the poll itself is failing (pollError = short reason, '' = ok). + // A failing poll also demotes "fresh" to "cache": the payload was built + // for a request long gone, and the server has not answered since. + function stageTrackerUpdatedHtml(d, nowMs, pollError, pollErrorSinceMs) { + const at = Date.parse((d && d.generated_at) || '') || 0; + if (!at) return ''; + const ageMs = Math.max(0, nowMs - at); + const ttlMs = (Number(d.cache_ttl_s) || 0) * 1000; + const failing = !!pollError; + const stale = failing || (ttlMs > 0 && ageMs > 2 * ttlMs); + const source = failing ? 'cache' : (d.source || 'cache'); + const src = source === 'fresh' ? 'built for this request' : 'from the server cache'; + const failTip = failing ? '. Polling is failing (' + pollError + (pollErrorSinceMs ? ', since ' + agentNowClockTime(pollErrorSinceMs, nowMs) : '') + '): the dashboard keeps showing this payload until the server answers again' : ''; + const failTag = failing ? ` · poll failing (${esc(pollError)})` : ''; + return `updated ${esc(stageTrackerShortAgo(ageMs) === 'now' ? Math.floor(ageMs / 1000) + 's' : stageTrackerShortAgo(ageMs))} ago · ${esc(source)}${failTag}`; + } + // The ADR-0025 central stage engine's status strip: mode and admission + // anomalies (governor.labels.stage.engine.mode). Hover text on the + // items only, per the tracker hover rules. + function stageTrackerEngineHtml(d) { + const e = d && d.engine; + if (!e || !e.mode) return ''; + const anomalies = Number(e.anomalies) || 0; + const modeHelp = { shadow: 'shadow: the engine derives and counts but writes nothing (dry run; stage labels are left as found).', enforce: 'enforce: the engine derives and writes; its admission table counts out-of-order transitions.' }[e.mode] || ''; + return `` + + `engine ${esc(e.mode)}` + + `${esc(anomalies)} anomal${anomalies === 1 ? 'y' : 'ies'}` + + ''; + } + function stageTrackerTickClock() { + const el = document.querySelector('#activity-monitor-meta .ham-updated'); + if (!el || !_stageTracker) return; + const wrap = document.createElement('span'); + wrap.innerHTML = stageTrackerUpdatedHtml(_stageTracker, Date.now(), _stageTrackerPollError, _stageTrackerPollErrorSince); + if (wrap.firstChild) el.replaceWith(wrap.firstChild); + } + function stageTrackerPollFailed(reason) { + if (!_stageTrackerPollError) _stageTrackerPollErrorSince = Date.now(); + _stageTrackerPollError = reason; + stageTrackerTickClock(); + } + function stageTrackerPollOk() { + _stageTrackerPollError = ''; + _stageTrackerPollErrorSince = 0; + } + + function renderStageTracker(data) { + if (data && typeof data === 'object') { _stageTracker = data; stageTrackerNoteMerges(data); stageTrackerNoteOpened(data); stageTrackerNoteMoves(data); } + // Row-action feedback rides the payload: a result toast leaves and a + // row stops "acting" once the item it targets reads a new state. + if (data && typeof data === 'object' && typeof stageTrackerResultToastsSync === 'function') { stageTrackerNoteEvents(data); stageTrackerResultToastsSync(data); stageTrackerPendingExpire(data); } + const el = document.getElementById('activity-monitor-panel'); + if (!el) return; + const nowMs = Date.now(); + // Rows under a "Merging" hold the payload already dropped ride along (#15245). + const d = typeof stageTrackerMergingHoldView === 'function' ? stageTrackerMergingHoldView(_stageTracker, _stageTrackerMergingHold, nowMs) : _stageTracker; + if (!d || d.status === 'initializing' || !Array.isArray(d.items)) { + setIfChanged(el, '
Waiting for the first scan…
'); + return; + } + const f = _stageTrackerFilter = stageTrackerNormalizeFilter(_stageTrackerFilter); + const stages = d.stages || []; + const repos = Array.from(new Set(d.items.map(it => it.repo).filter(Boolean))).sort(); + const sel = document.getElementById('activity-monitor-repo'); + if (sel) { + const want = '' + repos.map(r => ``).join(''); + if (sel.innerHTML !== want) sel.innerHTML = want; + } + stageTrackerSyncToolbar(f); + const ctx = { nowMs, stages, moves: _stageTrackerMoves }; + ctx.workers = stageTrackerWorkers(window._lastStatus); + ctx.events = _stageTrackerEvents; + ctx.noteTuck = stageTrackerNoteTuckSetting(); + ctx.sharedPRs = stageTrackerSharedPRs(d.items); + ctx.items = d.items; + // Repo chips ride the setting against how many repos the payload spans. + if (stageTrackerRepoChipOn(stageTrackerRepoChipSetting(), repos.length)) ctx.repoChips = { primary: stageTrackerPrimaryRepo(), active: f.repo }; + const visible = stageTrackerVisible(d.items, f, ctx); + const ordered = stageTrackerTrainContiguous(stageTrackerSort(visible, stages, f)); + const grouping = _stageTrackerGroup === 'repo'; + const page = grouping + ? stageTrackerGroupPage(stageTrackerGroups(ordered, { primary: stageTrackerPrimaryRepo(), collapsed: _stageTrackerCollapsed, stages }), f) + : stageTrackerPage(ordered, f); + if (page.page !== f.page) f.page = page.page; + // Attention is counted over the filtered set, nested PRs included. + const filteredAll = d.items.filter(it => stageTrackerMatches(it, f, ctx)); + const attention = filteredAll.filter(stageTrackerNeedsAttention).length; + // "N filtered out" and the sidebar pill count against the default + // view's rows (stageTrackerRowCount), so drawing a PR on its issue's + // row is never reported as a filter and the pill holds still while + // the kind tabs or chips narrow the list. + const allRows = stageTrackerFilterActive(f) ? stageTrackerRowCount(d.items, ctx) : visible.length; + // The sidebar pill, the header lead and the "of N" line come out of + // one stageTrackerCountsText call per render, so they cannot + // disagree: the pill is the default view's row count (owner: rows, + // not items — a covering PR shares its issue's row); needs-attention + // is the warn-coloured header suffix and the pill's tooltip, counted + // over every item regardless of filter. + const attentionAll = d.items.filter(stageTrackerNeedsAttention).length; + const counts = stageTrackerCountsText(page, allRows, attention, stageTrackerOpenCounts(d), attentionAll, stageTrackerFoldedCount(d.items, ctx)); + setSectionSummary('activity-monitor-section', counts.header.replace(/(\d+) needs? attention/, m => `${m}`)); + const badge = document.getElementById('activity-monitor-sidebar-badge'); + if (badge) { badge.textContent = String(counts.badge); badge.title = counts.badgeTitle; if (counts.badge) badge.removeAttribute('data-zero'); else badge.setAttribute('data-zero', ''); } + stageTrackerRenderWaiting(d, nowMs); + const labelsEl = document.getElementById('activity-monitor-labels'); + if (labelsEl) setIfChanged(labelsEl, stageTrackerLabelsHtml(stageTrackerLabelFacets(d.items, f))); + stageTrackerRenderLabelDialog(); + const meta = document.getElementById('activity-monitor-meta'); + if (meta) setIfChanged(meta, `${esc(counts.showing)}${stageTrackerEngineHtml(d)}${stageTrackerUpdatedHtml(d, nowMs, _stageTrackerPollError, _stageTrackerPollErrorSince)}${stageTrackerPagerHtml(page)}`); + const foot = document.getElementById('activity-monitor-meta-foot'); + if (foot) setIfChanged(foot, page.pages > 1 ? `${esc(counts.showing)}${stageTrackerPagerHtml(page)}` : ''); + const effect = stageTrackerMotionEffect(stageTrackerMotionSetting(), stageTrackerReducedMotion()); + if (!visible.length && !Object.keys(_stageTrackerCelebrating).length) { + _stageTrackerMoves = {}; + stageTrackerSelectionSync(el, []); + const emptyHtml = `
${d.items.length ? 'Nothing matches the current filters.' : 'Nothing open is being tracked right now.'}
`; + // The counter goes back to its toolbar home before the header + // (and its slot) leaves with the rows. + if (el.querySelector('[data-ham-key]')) { + stageTrackerReconcile(el, [], { effect, hidden: document.hidden }); + // Departing rows collapse first; the empty line follows them out. + if (el.querySelector('.ham-leaving')) { setTimeout(() => { if (!el.querySelector('[data-ham-key]')) setIfChanged(el, emptyHtml); }, STAGE_TRACKER_EXIT_MS * 1.5); return; } + } + setIfChanged(el, emptyHtml); + return; + } + // Grouped: header rows keyed group:owner/repo sit between the item + // rows; the reconcile treats them like any keyed row (kept while + // unchanged, collapsed out with their last row). + // A row celebrating its merge is pinned past the payload that + // dropped it (stageTrackerPinnedRows) until its moment is over. + // A merge train's rows carry a header line and a rail (#15117); the + // row renderer sees its neighbours to close the rail on the last one. + const pageItems = stageTrackerAdoptOrphanPRs(page.rows.map(e => grouping ? e.item : e)); + // Every train on the page, so a queue word can name its train when + // there is more than one and each train's rows share a rail accent. + const trains = typeof stageTrackerTrainIndex === 'function' ? stageTrackerTrainIndex(pageItems) : { count: 0, index: {} }; + const itemRow = (it, i) => { + const near = Object.assign({}, ctx, { prevRow: i > 0 && pageItems[i - 1] ? pageItems[i - 1] : null, nextRow: pageItems[i + 1] ? pageItems[i + 1] : null, trains: trains.count, trainIndex: trains.index }); + return { key: stageTrackerItemKey(it), html: stageTrackerRowHtml(it, stages, near) }; + }; + const rowOf = (e, i) => grouping && !e.item + ? { key: e.group.key, html: stageTrackerGroupHeaderHtml(e.group, stages, ctx) } + : itemRow(pageItems[i], i); + const rows = stageTrackerPinnedRows(el, [{ key: STAGE_TRACKER_HEADER_KEY, html: stageTrackerHeaderHtml(stages) }] + .concat(stageTrackerTrainRows(page.rows, rowOf, typeof stageTrackerTrainWhere === 'function' ? stageTrackerTrainWhere(ordered, d.items) : null)), nowMs); + const rec = stageTrackerReconcile(el, rows, { effect, hidden: document.hidden }); + if (rec.deferred) stageTrackerScheduleSettle(); + // Selection is keyed on the row, never baked into its HTML, so a kept + // node stays selected across the refresh and a departed row leaves it. + stageTrackerSelectionSync(el, rows.map(r => r.key)); + if (typeof stageTrackerPendingSync === 'function') stageTrackerPendingSync(el); + stageTrackerCueAgeSync(el, nowMs); + stageTrackerCueTick(); + // Moves play once, on the render that follows the payload; a filter + // or paging re-render of the same payload does not replay them. + if (Object.keys(_stageTrackerMoves).length) { stageTrackerAnimateMoves(el); _stageTrackerMoves = {}; } + } + + // Stateful: reduce the payload to columns, diff against the previous + // one, and keep the moves for the render that follows. + function stageTrackerNoteMoves(d) { + const next = stageTrackerColMap(d && d.items, d && d.stages); + _stageTrackerMoves = stageTrackerColMoves(_stageTrackerCols, next); + _stageTrackerCols = next; + } + + // The endpoint is served from a server-side cache with an ETag; a poll + // that matches it costs one 304 and no re-render. The filter/sort state + // is restored from storage on the first fetch. + // SSE nudges arrive once per status publish and once per webhook + // delivery, uncoalesced: a busy hive sent ~36 a minute, each a refetch + // and a reconcile of the list. The first nudge in a window fetches at + // once; the rest collapse into one trailing fetch when the window ends. + // A nudge that lands while the tab is hidden is remembered and served + // on the next visibilitychange instead. + const STAGE_TRACKER_NUDGE_COALESCE_MS = 2000; + let _stageTrackerNudgeTimer = null; + let _stageTrackerNudgeAt = 0; + let _stageTrackerNudgeSkipped = false; + function stageTrackerNudge(now) { + now = typeof now === 'number' ? now : Date.now(); + if (document.hidden) { _stageTrackerNudgeSkipped = true; return false; } + const wait = _stageTrackerNudgeAt + STAGE_TRACKER_NUDGE_COALESCE_MS - now; + if (wait <= 0) { _stageTrackerNudgeAt = now; fetchStageTracker(); return true; } + if (!_stageTrackerNudgeTimer) { + _stageTrackerNudgeTimer = setTimeout(() => { + _stageTrackerNudgeTimer = null; + _stageTrackerNudgeAt = Date.now(); + if (document.hidden) { _stageTrackerNudgeSkipped = true; return; } + fetchStageTracker(); + }, wait); + } + return false; + } + function stageTrackerResumeIfSkipped() { + if (!_stageTrackerNudgeSkipped) return; + _stageTrackerNudgeSkipped = false; + _stageTrackerNudgeAt = Date.now(); + fetchStageTracker(); + } + diff --git a/src/pkg/dashboard/static-src/js/tracker-filter-state.js b/src/pkg/dashboard/static-src/js/tracker-filter-state.js new file mode 100644 index 0000000000..2464bd9c52 --- /dev/null +++ b/src/pkg/dashboard/static-src/js/tracker-filter-state.js @@ -0,0 +1,206 @@ + function stageTrackerLoadFilter() { + try { _stageTrackerFilter = stageTrackerNormalizeFilter(JSON.parse(localStorage.getItem(STAGE_TRACKER_FILTER_KEY) || 'null')); } catch { _stageTrackerFilter = stageTrackerDefaultFilter(); } + _stageTrackerFilter.page = 1; + } + function stageTrackerSaveFilter() { + try { const f = Object.assign({}, _stageTrackerFilter); delete f.page; localStorage.setItem(STAGE_TRACKER_FILTER_KEY, JSON.stringify(f)); } catch {} + } + // Repo chip / group settings and the per-repo collapsed set (localStorage). + function stageTrackerRepoChipSetting() { + let v = ''; + try { v = localStorage.getItem(STAGE_TRACKER_REPO_CHIP_KEY) || ''; } catch { v = ''; } + return STAGE_TRACKER_REPO_CHIP_MODES.some(m => m.id === v) ? v : STAGE_TRACKER_REPO_CHIP_DEFAULT; + } + function stageTrackerSetRepoChip(id) { + const v = STAGE_TRACKER_REPO_CHIP_MODES.some(m => m.id === id) ? id : STAGE_TRACKER_REPO_CHIP_DEFAULT; + try { localStorage.setItem(STAGE_TRACKER_REPO_CHIP_KEY, v); } catch {} + return v; + } + function stageTrackerGroupSetting() { + let v = ''; + try { v = localStorage.getItem(STAGE_TRACKER_GROUP_KEY) || ''; } catch { v = ''; } + return STAGE_TRACKER_GROUPS.indexOf(v) >= 0 ? v : STAGE_TRACKER_GROUP_DEFAULT; + } + function stageTrackerSetGroup(id) { + const v = STAGE_TRACKER_GROUPS.indexOf(id) >= 0 ? id : STAGE_TRACKER_GROUP_DEFAULT; + try { localStorage.setItem(STAGE_TRACKER_GROUP_KEY, v); } catch {} + return v; + } + function stageTrackerLoadCollapsed() { + try { + const o = JSON.parse(localStorage.getItem(STAGE_TRACKER_GROUP_COLLAPSED_KEY) || '{}'); + if (!o || typeof o !== 'object' || Array.isArray(o)) return {}; + const out = {}; + for (const k of Object.keys(o)) if (o[k]) out[k] = true; + return out; + } catch { return {}; } + } + function stageTrackerSaveCollapsed(c) { + try { localStorage.setItem(STAGE_TRACKER_GROUP_COLLAPSED_KEY, JSON.stringify(c || {})); } catch {} + } + // Pure: the collapsed set with one repo toggled. + function stageTrackerToggleCollapsed(collapsed, repo) { + const out = Object.assign({}, collapsed || {}); + if (out[repo]) delete out[repo]; else out[repo] = true; + return out; + } + function stageTrackerLoadGrouping() { + _stageTrackerGroup = stageTrackerGroupSetting(); + _stageTrackerCollapsed = stageTrackerLoadCollapsed(); + } + function stageTrackerPrimaryRepo() { return (typeof window !== 'undefined' && window._primaryRepo) || ''; } + function hamGroup(value) { + _stageTrackerGroup = stageTrackerSetGroup(value); + _stageTrackerFilter.page = 1; + renderStageTracker(); + stageTrackerRenderSettings(); + } + function hamGroupToggle(repo) { + _stageTrackerCollapsed = stageTrackerToggleCollapsed(_stageTrackerCollapsed, repo); + stageTrackerSaveCollapsed(_stageTrackerCollapsed); + renderStageTracker(); + } + // A row's repo chip: filter to that repo, or back to all when it already is. + function hamRepoChip(repo) { hamFilter('repo', _stageTrackerFilter.repo === repo ? '' : repo); } + function stageTrackerRepoChipChange(value) { + stageTrackerSetRepoChip(value); + renderStageTracker(); + } + + function hamFilter(key, value) { + const f = _stageTrackerFilter; + switch (key) { + case 'kind': f.kind = value || 'all'; break; + case 'repo': f.repo = value || ''; break; + case 'q': f.q = value || ''; break; + case 'age': f.age = value || 'any'; break; + case 'author': f.author = value || 'any'; break; + case 'attention': f.attention = value === 'toggle' ? !f.attention : !!value; break; + case 'acted': f.acted = value || 'any'; break; + case 'sort': f.sort = value || 'furthest'; break; + case 'dir': f.dir = value === 'toggle' ? (f.dir === 'asc' ? 'desc' : 'asc') : value; break; + case 'size': f.size = Number(value) || STAGE_TRACKER_DEFAULT_PAGE_SIZE; break; + case 'label': { const l = String(value || '').toLowerCase(); const i = f.labels.indexOf(l); if (i >= 0) f.labels.splice(i, 1); else if (l) f.labels.push(l); break; } + case 'needsHuman': f.needsHuman = value === 'toggle' ? !f.needsHuman : !!value; break; + case 'onHold': f.onHold = value === 'toggle' ? !f.onHold : !!value; break; + case 'waitingOnYou': f.waitingOnYou = value === 'toggle' ? !f.waitingOnYou : !!value; break; + case 'labelsClear': f.labels = []; f.needsHuman = false; f.onHold = false; break; + case 'page': f.page = value === 'prev' ? f.page - 1 : value === 'next' ? f.page + 1 : Number(value) || 1; break; + case 'reset': { const keep = { sort: f.sort, dir: f.dir, size: f.size }; _stageTrackerFilter = Object.assign(stageTrackerDefaultFilter(), keep); break; } + } + if (key !== 'page') _stageTrackerFilter.page = 1; + _stageTrackerFilter = stageTrackerNormalizeFilter(_stageTrackerFilter); + stageTrackerSaveFilter(); + renderStageTracker(); + } + + // Push the filter state into the toolbar controls (they may have been + // restored from storage or reset). + function stageTrackerSyncToolbar(f) { + document.querySelectorAll('#activity-monitor-toolbar .ham-chip[data-arg0="kind"]').forEach(b => b.setAttribute('aria-pressed', b.dataset.arg1 === f.kind ? 'true' : 'false')); + const setVal = (id, v) => { const el = document.getElementById(id); if (el && el.value !== String(v) && document.activeElement !== el) el.value = String(v); }; + setVal('activity-monitor-q', f.q); + setVal('activity-monitor-age', f.age); + setVal('activity-monitor-author', f.author); + setVal('activity-monitor-acted', f.acted); + setVal('activity-monitor-sort', f.sort); + setVal('activity-monitor-group', _stageTrackerGroup); + setVal('activity-monitor-size', f.size); + const att = document.getElementById('activity-monitor-attention'); + if (att) att.setAttribute('aria-pressed', f.attention ? 'true' : 'false'); + const wait = document.getElementById('activity-monitor-waiting'); + if (wait) wait.setAttribute('aria-pressed', f.waitingOnYou ? 'true' : 'false'); + const dir = document.getElementById('activity-monitor-dir'); + if (dir) { dir.textContent = f.dir === 'asc' ? '↑' : '↓'; dir.setAttribute('title', (f.dir === 'asc' ? 'Ascending — click for descending' : 'Descending — click for ascending') + STAGE_TRACKER_DIR_TIER_NOTE); } + const reset = document.getElementById('activity-monitor-reset'); + if (reset) reset.hidden = !stageTrackerFilterActive(f); + } + + function stageTrackerLabelChipHtml(c) { + return ``; + } + function stageTrackerNeedsHumanChipHtml(nh) { + if (!nh) return ''; + const tip = (nh.on ? 'Remove the Needs human filter. ' : '') + STAGE_TRACKER_NEEDS_HUMAN_TIP; + return ``; + } + function stageTrackerOnHoldChipHtml(oh) { + if (!oh) return ''; + const tip = (oh.on ? 'Remove the On hold filter. ' : '') + STAGE_TRACKER_ON_HOLD_TIP; + return ``; + } + function stageTrackerLabelsHtml(facets) { + if (!facets.chips.length && !facets.needsHuman && !facets.onHold) return ''; + return stageTrackerNeedsHumanChipHtml(facets.needsHuman) + + stageTrackerOnHoldChipHtml(facets.onHold) + + facets.chips.map(stageTrackerLabelChipHtml).join('') + + (facets.hidden ? `` : ''); + } + + // "All labels" dialog: every label with its count, same order as the + // row, a type-to-filter box, the same toggle the chips use and Clear. + // In-app modal (config-overlay recipe), never a native prompt. + function stageTrackerLabelDialogHtml(data) { + return `
${esc(stageTrackerLabelDialogCountText(data))}
` + + (data.needsHuman || data.onHold ? `
${stageTrackerNeedsHumanChipHtml(data.needsHuman)}${stageTrackerOnHoldChipHtml(data.onHold)}
` : '') + + `
${stageTrackerLabelDialogListHtml(data)}
`; + } + function stageTrackerLabelDialogListHtml(data) { + return data.rows.length ? data.rows.map(stageTrackerLabelChipHtml).join('') : `
No label matches “${esc(data.query)}”
`; + } + function stageTrackerLabelDialogCountText(data) { + return (data.rows.length === data.total ? data.total + ' labels' : data.rows.length + ' of ' + data.total + ' labels') + ' · ' + data.selected + ' selected'; + } + // Redraw the open dialog. While the filter box has focus only the list, + // the count, the Clear button and the Needs human chip are patched so a + // poll-driven render never steals the caret. + function stageTrackerRenderLabelDialog() { + const body = document.getElementById('activity-monitor-labels-body'); + if (!body || !_stageTracker || !Array.isArray(_stageTracker.items)) return; + const facets = stageTrackerLabelFacets(_stageTracker.items, _stageTrackerFilter); + const data = stageTrackerLabelDialogData(facets, _stageTrackerLabelQuery); + const q = document.getElementById('activity-monitor-labels-q'); + if (!q || document.activeElement !== q) { setIfChanged(body, stageTrackerLabelDialogHtml(data)); return; } + const list = body.querySelector('.ham-label-dialog-list'); + if (list) setIfChanged(list, stageTrackerLabelDialogListHtml(data)); + const count = body.querySelector('.ham-label-dialog-tools .ham-count'); + if (count && count.textContent !== stageTrackerLabelDialogCountText(data)) count.textContent = stageTrackerLabelDialogCountText(data); + const clear = body.querySelector('.ham-label-dialog-tools .hv-btn'); + if (clear) clear.disabled = !data.selected; + const nh = body.querySelector('.ham-label-dialog-needs-human'); + if (nh) setIfChanged(nh, stageTrackerNeedsHumanChipHtml(data.needsHuman) + stageTrackerOnHoldChipHtml(data.onHold)); + } + var _stageTrackerLabelDialogReturnFocus = null; + function openStageTrackerLabelDialog() { + if (document.getElementById('activity-monitor-labels-overlay')) return; + _stageTrackerLabelDialogReturnFocus = document.activeElement; + const overlay = document.createElement('div'); + overlay.id = 'activity-monitor-labels-overlay'; + overlay.className = 'config-overlay'; + hiveRememberModalOpen(overlay); + overlay.innerHTML = ``; + overlay.addEventListener('click', e => { if (e.target === overlay) closeStageTrackerLabelDialog(); }); + document.body.appendChild(overlay); + stageTrackerRenderLabelDialog(); + const q = document.getElementById('activity-monitor-labels-q'); + if (q) setTimeout(() => q.focus(), 0); + } + function closeStageTrackerLabelDialog() { + const overlay = document.getElementById('activity-monitor-labels-overlay'); + if (overlay) overlay.remove(); + _stageTrackerLabelQuery = ''; + const ret = _stageTrackerLabelDialogReturnFocus; + _stageTrackerLabelDialogReturnFocus = null; + if (ret && ret.focus && document.contains(ret)) setTimeout(() => ret.focus({ preventScroll: true }), 0); + } + function stageTrackerLabelDialogQuery(value) { + _stageTrackerLabelQuery = String(value || ''); + stageTrackerRenderLabelDialog(); + } + diff --git a/src/pkg/dashboard/static-src/js/tracker-filter.js b/src/pkg/dashboard/static-src/js/tracker-filter.js index 5be7032560..a896055370 100644 --- a/src/pkg/dashboard/static-src/js/tracker-filter.js +++ b/src/pkg/dashboard/static-src/js/tracker-filter.js @@ -405,582 +405,3 @@ return { issues: items.filter(it => it && it.kind !== 'pr').length, prs: items.filter(it => it && it.kind === 'pr').length }; } - function stageTrackerLoadFilter() { - try { _stageTrackerFilter = stageTrackerNormalizeFilter(JSON.parse(localStorage.getItem(STAGE_TRACKER_FILTER_KEY) || 'null')); } catch { _stageTrackerFilter = stageTrackerDefaultFilter(); } - _stageTrackerFilter.page = 1; - } - function stageTrackerSaveFilter() { - try { const f = Object.assign({}, _stageTrackerFilter); delete f.page; localStorage.setItem(STAGE_TRACKER_FILTER_KEY, JSON.stringify(f)); } catch {} - } - // Repo chip / group settings and the per-repo collapsed set (localStorage). - function stageTrackerRepoChipSetting() { - let v = ''; - try { v = localStorage.getItem(STAGE_TRACKER_REPO_CHIP_KEY) || ''; } catch { v = ''; } - return STAGE_TRACKER_REPO_CHIP_MODES.some(m => m.id === v) ? v : STAGE_TRACKER_REPO_CHIP_DEFAULT; - } - function stageTrackerSetRepoChip(id) { - const v = STAGE_TRACKER_REPO_CHIP_MODES.some(m => m.id === id) ? id : STAGE_TRACKER_REPO_CHIP_DEFAULT; - try { localStorage.setItem(STAGE_TRACKER_REPO_CHIP_KEY, v); } catch {} - return v; - } - function stageTrackerGroupSetting() { - let v = ''; - try { v = localStorage.getItem(STAGE_TRACKER_GROUP_KEY) || ''; } catch { v = ''; } - return STAGE_TRACKER_GROUPS.indexOf(v) >= 0 ? v : STAGE_TRACKER_GROUP_DEFAULT; - } - function stageTrackerSetGroup(id) { - const v = STAGE_TRACKER_GROUPS.indexOf(id) >= 0 ? id : STAGE_TRACKER_GROUP_DEFAULT; - try { localStorage.setItem(STAGE_TRACKER_GROUP_KEY, v); } catch {} - return v; - } - function stageTrackerLoadCollapsed() { - try { - const o = JSON.parse(localStorage.getItem(STAGE_TRACKER_GROUP_COLLAPSED_KEY) || '{}'); - if (!o || typeof o !== 'object' || Array.isArray(o)) return {}; - const out = {}; - for (const k of Object.keys(o)) if (o[k]) out[k] = true; - return out; - } catch { return {}; } - } - function stageTrackerSaveCollapsed(c) { - try { localStorage.setItem(STAGE_TRACKER_GROUP_COLLAPSED_KEY, JSON.stringify(c || {})); } catch {} - } - // Pure: the collapsed set with one repo toggled. - function stageTrackerToggleCollapsed(collapsed, repo) { - const out = Object.assign({}, collapsed || {}); - if (out[repo]) delete out[repo]; else out[repo] = true; - return out; - } - function stageTrackerLoadGrouping() { - _stageTrackerGroup = stageTrackerGroupSetting(); - _stageTrackerCollapsed = stageTrackerLoadCollapsed(); - } - function stageTrackerPrimaryRepo() { return (typeof window !== 'undefined' && window._primaryRepo) || ''; } - function hamGroup(value) { - _stageTrackerGroup = stageTrackerSetGroup(value); - _stageTrackerFilter.page = 1; - renderStageTracker(); - stageTrackerRenderSettings(); - } - function hamGroupToggle(repo) { - _stageTrackerCollapsed = stageTrackerToggleCollapsed(_stageTrackerCollapsed, repo); - stageTrackerSaveCollapsed(_stageTrackerCollapsed); - renderStageTracker(); - } - // A row's repo chip: filter to that repo, or back to all when it already is. - function hamRepoChip(repo) { hamFilter('repo', _stageTrackerFilter.repo === repo ? '' : repo); } - function stageTrackerRepoChipChange(value) { - stageTrackerSetRepoChip(value); - renderStageTracker(); - } - - function hamFilter(key, value) { - const f = _stageTrackerFilter; - switch (key) { - case 'kind': f.kind = value || 'all'; break; - case 'repo': f.repo = value || ''; break; - case 'q': f.q = value || ''; break; - case 'age': f.age = value || 'any'; break; - case 'author': f.author = value || 'any'; break; - case 'attention': f.attention = value === 'toggle' ? !f.attention : !!value; break; - case 'acted': f.acted = value || 'any'; break; - case 'sort': f.sort = value || 'furthest'; break; - case 'dir': f.dir = value === 'toggle' ? (f.dir === 'asc' ? 'desc' : 'asc') : value; break; - case 'size': f.size = Number(value) || STAGE_TRACKER_DEFAULT_PAGE_SIZE; break; - case 'label': { const l = String(value || '').toLowerCase(); const i = f.labels.indexOf(l); if (i >= 0) f.labels.splice(i, 1); else if (l) f.labels.push(l); break; } - case 'needsHuman': f.needsHuman = value === 'toggle' ? !f.needsHuman : !!value; break; - case 'onHold': f.onHold = value === 'toggle' ? !f.onHold : !!value; break; - case 'waitingOnYou': f.waitingOnYou = value === 'toggle' ? !f.waitingOnYou : !!value; break; - case 'labelsClear': f.labels = []; f.needsHuman = false; f.onHold = false; break; - case 'page': f.page = value === 'prev' ? f.page - 1 : value === 'next' ? f.page + 1 : Number(value) || 1; break; - case 'reset': { const keep = { sort: f.sort, dir: f.dir, size: f.size }; _stageTrackerFilter = Object.assign(stageTrackerDefaultFilter(), keep); break; } - } - if (key !== 'page') _stageTrackerFilter.page = 1; - _stageTrackerFilter = stageTrackerNormalizeFilter(_stageTrackerFilter); - stageTrackerSaveFilter(); - renderStageTracker(); - } - - // Push the filter state into the toolbar controls (they may have been - // restored from storage or reset). - function stageTrackerSyncToolbar(f) { - document.querySelectorAll('#activity-monitor-toolbar .ham-chip[data-arg0="kind"]').forEach(b => b.setAttribute('aria-pressed', b.dataset.arg1 === f.kind ? 'true' : 'false')); - const setVal = (id, v) => { const el = document.getElementById(id); if (el && el.value !== String(v) && document.activeElement !== el) el.value = String(v); }; - setVal('activity-monitor-q', f.q); - setVal('activity-monitor-age', f.age); - setVal('activity-monitor-author', f.author); - setVal('activity-monitor-acted', f.acted); - setVal('activity-monitor-sort', f.sort); - setVal('activity-monitor-group', _stageTrackerGroup); - setVal('activity-monitor-size', f.size); - const att = document.getElementById('activity-monitor-attention'); - if (att) att.setAttribute('aria-pressed', f.attention ? 'true' : 'false'); - const wait = document.getElementById('activity-monitor-waiting'); - if (wait) wait.setAttribute('aria-pressed', f.waitingOnYou ? 'true' : 'false'); - const dir = document.getElementById('activity-monitor-dir'); - if (dir) { dir.textContent = f.dir === 'asc' ? '↑' : '↓'; dir.setAttribute('title', (f.dir === 'asc' ? 'Ascending — click for descending' : 'Descending — click for ascending') + STAGE_TRACKER_DIR_TIER_NOTE); } - const reset = document.getElementById('activity-monitor-reset'); - if (reset) reset.hidden = !stageTrackerFilterActive(f); - } - - function stageTrackerLabelChipHtml(c) { - return ``; - } - function stageTrackerNeedsHumanChipHtml(nh) { - if (!nh) return ''; - const tip = (nh.on ? 'Remove the Needs human filter. ' : '') + STAGE_TRACKER_NEEDS_HUMAN_TIP; - return ``; - } - function stageTrackerOnHoldChipHtml(oh) { - if (!oh) return ''; - const tip = (oh.on ? 'Remove the On hold filter. ' : '') + STAGE_TRACKER_ON_HOLD_TIP; - return ``; - } - function stageTrackerLabelsHtml(facets) { - if (!facets.chips.length && !facets.needsHuman && !facets.onHold) return ''; - return stageTrackerNeedsHumanChipHtml(facets.needsHuman) - + stageTrackerOnHoldChipHtml(facets.onHold) - + facets.chips.map(stageTrackerLabelChipHtml).join('') - + (facets.hidden ? `` : ''); - } - - // "All labels" dialog: every label with its count, same order as the - // row, a type-to-filter box, the same toggle the chips use and Clear. - // In-app modal (config-overlay recipe), never a native prompt. - function stageTrackerLabelDialogHtml(data) { - return `
${esc(stageTrackerLabelDialogCountText(data))}
` - + (data.needsHuman || data.onHold ? `
${stageTrackerNeedsHumanChipHtml(data.needsHuman)}${stageTrackerOnHoldChipHtml(data.onHold)}
` : '') - + `
${stageTrackerLabelDialogListHtml(data)}
`; - } - function stageTrackerLabelDialogListHtml(data) { - return data.rows.length ? data.rows.map(stageTrackerLabelChipHtml).join('') : `
No label matches “${esc(data.query)}”
`; - } - function stageTrackerLabelDialogCountText(data) { - return (data.rows.length === data.total ? data.total + ' labels' : data.rows.length + ' of ' + data.total + ' labels') + ' · ' + data.selected + ' selected'; - } - // Redraw the open dialog. While the filter box has focus only the list, - // the count, the Clear button and the Needs human chip are patched so a - // poll-driven render never steals the caret. - function stageTrackerRenderLabelDialog() { - const body = document.getElementById('activity-monitor-labels-body'); - if (!body || !_stageTracker || !Array.isArray(_stageTracker.items)) return; - const facets = stageTrackerLabelFacets(_stageTracker.items, _stageTrackerFilter); - const data = stageTrackerLabelDialogData(facets, _stageTrackerLabelQuery); - const q = document.getElementById('activity-monitor-labels-q'); - if (!q || document.activeElement !== q) { setIfChanged(body, stageTrackerLabelDialogHtml(data)); return; } - const list = body.querySelector('.ham-label-dialog-list'); - if (list) setIfChanged(list, stageTrackerLabelDialogListHtml(data)); - const count = body.querySelector('.ham-label-dialog-tools .ham-count'); - if (count && count.textContent !== stageTrackerLabelDialogCountText(data)) count.textContent = stageTrackerLabelDialogCountText(data); - const clear = body.querySelector('.ham-label-dialog-tools .hv-btn'); - if (clear) clear.disabled = !data.selected; - const nh = body.querySelector('.ham-label-dialog-needs-human'); - if (nh) setIfChanged(nh, stageTrackerNeedsHumanChipHtml(data.needsHuman) + stageTrackerOnHoldChipHtml(data.onHold)); - } - var _stageTrackerLabelDialogReturnFocus = null; - function openStageTrackerLabelDialog() { - if (document.getElementById('activity-monitor-labels-overlay')) return; - _stageTrackerLabelDialogReturnFocus = document.activeElement; - const overlay = document.createElement('div'); - overlay.id = 'activity-monitor-labels-overlay'; - overlay.className = 'config-overlay'; - hiveRememberModalOpen(overlay); - overlay.innerHTML = ``; - overlay.addEventListener('click', e => { if (e.target === overlay) closeStageTrackerLabelDialog(); }); - document.body.appendChild(overlay); - stageTrackerRenderLabelDialog(); - const q = document.getElementById('activity-monitor-labels-q'); - if (q) setTimeout(() => q.focus(), 0); - } - function closeStageTrackerLabelDialog() { - const overlay = document.getElementById('activity-monitor-labels-overlay'); - if (overlay) overlay.remove(); - _stageTrackerLabelQuery = ''; - const ret = _stageTrackerLabelDialogReturnFocus; - _stageTrackerLabelDialogReturnFocus = null; - if (ret && ret.focus && document.contains(ret)) setTimeout(() => ret.focus({ preventScroll: true }), 0); - } - function stageTrackerLabelDialogQuery(value) { - _stageTrackerLabelQuery = String(value || ''); - stageTrackerRenderLabelDialog(); - } - - function stageTrackerPagerHtml(page) { - if (page.pages <= 1) return ''; - return ``; - } - - // "updated 12s ago · cache" — re-stamped every STAGE_TRACKER_CLOCK_MS - // without a fetch; amber once the payload is older than two TTLs or - // once the poll itself is failing (pollError = short reason, '' = ok). - // A failing poll also demotes "fresh" to "cache": the payload was built - // for a request long gone, and the server has not answered since. - function stageTrackerUpdatedHtml(d, nowMs, pollError, pollErrorSinceMs) { - const at = Date.parse((d && d.generated_at) || '') || 0; - if (!at) return ''; - const ageMs = Math.max(0, nowMs - at); - const ttlMs = (Number(d.cache_ttl_s) || 0) * 1000; - const failing = !!pollError; - const stale = failing || (ttlMs > 0 && ageMs > 2 * ttlMs); - const source = failing ? 'cache' : (d.source || 'cache'); - const src = source === 'fresh' ? 'built for this request' : 'from the server cache'; - const failTip = failing ? '. Polling is failing (' + pollError + (pollErrorSinceMs ? ', since ' + agentNowClockTime(pollErrorSinceMs, nowMs) : '') + '): the dashboard keeps showing this payload until the server answers again' : ''; - const failTag = failing ? ` · poll failing (${esc(pollError)})` : ''; - return `updated ${esc(stageTrackerShortAgo(ageMs) === 'now' ? Math.floor(ageMs / 1000) + 's' : stageTrackerShortAgo(ageMs))} ago · ${esc(source)}${failTag}`; - } - // The ADR-0025 central stage engine's status strip: mode and admission - // anomalies (governor.labels.stage.engine.mode). Hover text on the - // items only, per the tracker hover rules. - function stageTrackerEngineHtml(d) { - const e = d && d.engine; - if (!e || !e.mode) return ''; - const anomalies = Number(e.anomalies) || 0; - const modeHelp = { shadow: 'shadow: the engine derives and counts but writes nothing (dry run; stage labels are left as found).', enforce: 'enforce: the engine derives and writes; its admission table counts out-of-order transitions.' }[e.mode] || ''; - return `` - + `engine ${esc(e.mode)}` - + `${esc(anomalies)} anomal${anomalies === 1 ? 'y' : 'ies'}` - + ''; - } - function stageTrackerTickClock() { - const el = document.querySelector('#activity-monitor-meta .ham-updated'); - if (!el || !_stageTracker) return; - const wrap = document.createElement('span'); - wrap.innerHTML = stageTrackerUpdatedHtml(_stageTracker, Date.now(), _stageTrackerPollError, _stageTrackerPollErrorSince); - if (wrap.firstChild) el.replaceWith(wrap.firstChild); - } - function stageTrackerPollFailed(reason) { - if (!_stageTrackerPollError) _stageTrackerPollErrorSince = Date.now(); - _stageTrackerPollError = reason; - stageTrackerTickClock(); - } - function stageTrackerPollOk() { - _stageTrackerPollError = ''; - _stageTrackerPollErrorSince = 0; - } - - function renderStageTracker(data) { - if (data && typeof data === 'object') { _stageTracker = data; stageTrackerNoteMerges(data); stageTrackerNoteOpened(data); stageTrackerNoteMoves(data); } - // Row-action feedback rides the payload: a result toast leaves and a - // row stops "acting" once the item it targets reads a new state. - if (data && typeof data === 'object' && typeof stageTrackerResultToastsSync === 'function') { stageTrackerNoteEvents(data); stageTrackerResultToastsSync(data); stageTrackerPendingExpire(data); } - const el = document.getElementById('activity-monitor-panel'); - if (!el) return; - const nowMs = Date.now(); - // Rows under a "Merging" hold the payload already dropped ride along (#15245). - const d = typeof stageTrackerMergingHoldView === 'function' ? stageTrackerMergingHoldView(_stageTracker, _stageTrackerMergingHold, nowMs) : _stageTracker; - if (!d || d.status === 'initializing' || !Array.isArray(d.items)) { - setIfChanged(el, '
Waiting for the first scan…
'); - return; - } - const f = _stageTrackerFilter = stageTrackerNormalizeFilter(_stageTrackerFilter); - const stages = d.stages || []; - const repos = Array.from(new Set(d.items.map(it => it.repo).filter(Boolean))).sort(); - const sel = document.getElementById('activity-monitor-repo'); - if (sel) { - const want = '' + repos.map(r => ``).join(''); - if (sel.innerHTML !== want) sel.innerHTML = want; - } - stageTrackerSyncToolbar(f); - const ctx = { nowMs, stages, moves: _stageTrackerMoves }; - ctx.workers = stageTrackerWorkers(window._lastStatus); - ctx.events = _stageTrackerEvents; - ctx.noteTuck = stageTrackerNoteTuckSetting(); - ctx.sharedPRs = stageTrackerSharedPRs(d.items); - ctx.items = d.items; - // Repo chips ride the setting against how many repos the payload spans. - if (stageTrackerRepoChipOn(stageTrackerRepoChipSetting(), repos.length)) ctx.repoChips = { primary: stageTrackerPrimaryRepo(), active: f.repo }; - const visible = stageTrackerVisible(d.items, f, ctx); - const ordered = stageTrackerTrainContiguous(stageTrackerSort(visible, stages, f)); - const grouping = _stageTrackerGroup === 'repo'; - const page = grouping - ? stageTrackerGroupPage(stageTrackerGroups(ordered, { primary: stageTrackerPrimaryRepo(), collapsed: _stageTrackerCollapsed, stages }), f) - : stageTrackerPage(ordered, f); - if (page.page !== f.page) f.page = page.page; - // Attention is counted over the filtered set, nested PRs included. - const filteredAll = d.items.filter(it => stageTrackerMatches(it, f, ctx)); - const attention = filteredAll.filter(stageTrackerNeedsAttention).length; - // "N filtered out" and the sidebar pill count against the default - // view's rows (stageTrackerRowCount), so drawing a PR on its issue's - // row is never reported as a filter and the pill holds still while - // the kind tabs or chips narrow the list. - const allRows = stageTrackerFilterActive(f) ? stageTrackerRowCount(d.items, ctx) : visible.length; - // The sidebar pill, the header lead and the "of N" line come out of - // one stageTrackerCountsText call per render, so they cannot - // disagree: the pill is the default view's row count (owner: rows, - // not items — a covering PR shares its issue's row); needs-attention - // is the warn-coloured header suffix and the pill's tooltip, counted - // over every item regardless of filter. - const attentionAll = d.items.filter(stageTrackerNeedsAttention).length; - const counts = stageTrackerCountsText(page, allRows, attention, stageTrackerOpenCounts(d), attentionAll, stageTrackerFoldedCount(d.items, ctx)); - setSectionSummary('activity-monitor-section', counts.header.replace(/(\d+) needs? attention/, m => `${m}`)); - const badge = document.getElementById('activity-monitor-sidebar-badge'); - if (badge) { badge.textContent = String(counts.badge); badge.title = counts.badgeTitle; if (counts.badge) badge.removeAttribute('data-zero'); else badge.setAttribute('data-zero', ''); } - stageTrackerRenderWaiting(d, nowMs); - const labelsEl = document.getElementById('activity-monitor-labels'); - if (labelsEl) setIfChanged(labelsEl, stageTrackerLabelsHtml(stageTrackerLabelFacets(d.items, f))); - stageTrackerRenderLabelDialog(); - const meta = document.getElementById('activity-monitor-meta'); - if (meta) setIfChanged(meta, `${esc(counts.showing)}${stageTrackerEngineHtml(d)}${stageTrackerUpdatedHtml(d, nowMs, _stageTrackerPollError, _stageTrackerPollErrorSince)}${stageTrackerPagerHtml(page)}`); - const foot = document.getElementById('activity-monitor-meta-foot'); - if (foot) setIfChanged(foot, page.pages > 1 ? `${esc(counts.showing)}${stageTrackerPagerHtml(page)}` : ''); - const effect = stageTrackerMotionEffect(stageTrackerMotionSetting(), stageTrackerReducedMotion()); - if (!visible.length && !Object.keys(_stageTrackerCelebrating).length) { - _stageTrackerMoves = {}; - stageTrackerSelectionSync(el, []); - const emptyHtml = `
${d.items.length ? 'Nothing matches the current filters.' : 'Nothing open is being tracked right now.'}
`; - // The counter goes back to its toolbar home before the header - // (and its slot) leaves with the rows. - if (el.querySelector('[data-ham-key]')) { - stageTrackerReconcile(el, [], { effect, hidden: document.hidden }); - // Departing rows collapse first; the empty line follows them out. - if (el.querySelector('.ham-leaving')) { setTimeout(() => { if (!el.querySelector('[data-ham-key]')) setIfChanged(el, emptyHtml); }, STAGE_TRACKER_EXIT_MS * 1.5); return; } - } - setIfChanged(el, emptyHtml); - return; - } - // Grouped: header rows keyed group:owner/repo sit between the item - // rows; the reconcile treats them like any keyed row (kept while - // unchanged, collapsed out with their last row). - // A row celebrating its merge is pinned past the payload that - // dropped it (stageTrackerPinnedRows) until its moment is over. - // A merge train's rows carry a header line and a rail (#15117); the - // row renderer sees its neighbours to close the rail on the last one. - const pageItems = stageTrackerAdoptOrphanPRs(page.rows.map(e => grouping ? e.item : e)); - // Every train on the page, so a queue word can name its train when - // there is more than one and each train's rows share a rail accent. - const trains = typeof stageTrackerTrainIndex === 'function' ? stageTrackerTrainIndex(pageItems) : { count: 0, index: {} }; - const itemRow = (it, i) => { - const near = Object.assign({}, ctx, { prevRow: i > 0 && pageItems[i - 1] ? pageItems[i - 1] : null, nextRow: pageItems[i + 1] ? pageItems[i + 1] : null, trains: trains.count, trainIndex: trains.index }); - return { key: stageTrackerItemKey(it), html: stageTrackerRowHtml(it, stages, near) }; - }; - const rowOf = (e, i) => grouping && !e.item - ? { key: e.group.key, html: stageTrackerGroupHeaderHtml(e.group, stages, ctx) } - : itemRow(pageItems[i], i); - const rows = stageTrackerPinnedRows(el, [{ key: STAGE_TRACKER_HEADER_KEY, html: stageTrackerHeaderHtml(stages) }] - .concat(stageTrackerTrainRows(page.rows, rowOf, typeof stageTrackerTrainWhere === 'function' ? stageTrackerTrainWhere(ordered, d.items) : null)), nowMs); - const rec = stageTrackerReconcile(el, rows, { effect, hidden: document.hidden }); - if (rec.deferred) stageTrackerScheduleSettle(); - // Selection is keyed on the row, never baked into its HTML, so a kept - // node stays selected across the refresh and a departed row leaves it. - stageTrackerSelectionSync(el, rows.map(r => r.key)); - if (typeof stageTrackerPendingSync === 'function') stageTrackerPendingSync(el); - stageTrackerCueAgeSync(el, nowMs); - stageTrackerCueTick(); - // Moves play once, on the render that follows the payload; a filter - // or paging re-render of the same payload does not replay them. - if (Object.keys(_stageTrackerMoves).length) { stageTrackerAnimateMoves(el); _stageTrackerMoves = {}; } - } - - // Stateful: reduce the payload to columns, diff against the previous - // one, and keep the moves for the render that follows. - function stageTrackerNoteMoves(d) { - const next = stageTrackerColMap(d && d.items, d && d.stages); - _stageTrackerMoves = stageTrackerColMoves(_stageTrackerCols, next); - _stageTrackerCols = next; - } - - // The endpoint is served from a server-side cache with an ETag; a poll - // that matches it costs one 304 and no re-render. The filter/sort state - // is restored from storage on the first fetch. - // SSE nudges arrive once per status publish and once per webhook - // delivery, uncoalesced: a busy hive sent ~36 a minute, each a refetch - // and a reconcile of the list. The first nudge in a window fetches at - // once; the rest collapse into one trailing fetch when the window ends. - // A nudge that lands while the tab is hidden is remembered and served - // on the next visibilitychange instead. - const STAGE_TRACKER_NUDGE_COALESCE_MS = 2000; - let _stageTrackerNudgeTimer = null; - let _stageTrackerNudgeAt = 0; - let _stageTrackerNudgeSkipped = false; - function stageTrackerNudge(now) { - now = typeof now === 'number' ? now : Date.now(); - if (document.hidden) { _stageTrackerNudgeSkipped = true; return false; } - const wait = _stageTrackerNudgeAt + STAGE_TRACKER_NUDGE_COALESCE_MS - now; - if (wait <= 0) { _stageTrackerNudgeAt = now; fetchStageTracker(); return true; } - if (!_stageTrackerNudgeTimer) { - _stageTrackerNudgeTimer = setTimeout(() => { - _stageTrackerNudgeTimer = null; - _stageTrackerNudgeAt = Date.now(); - if (document.hidden) { _stageTrackerNudgeSkipped = true; return; } - fetchStageTracker(); - }, wait); - } - return false; - } - function stageTrackerResumeIfSkipped() { - if (!_stageTrackerNudgeSkipped) return; - _stageTrackerNudgeSkipped = false; - _stageTrackerNudgeAt = Date.now(); - fetchStageTracker(); - } - - async function fetchStageTracker() { - try { - if (!_stageTrackerSig && !_stageTrackerEtag) stageTrackerLoadGrouping(); - if (!_stageTrackerSig && !_stageTrackerEtag) { stageTrackerLoadFilter(); stageTrackerSoundInit(); } - if (!_stageTrackerSig && !_stageTrackerEtag) stageTrackerApplyUrlFilter(); - const r = await fetch('/api/stage-tracker', _stageTrackerEtag ? { headers: { 'If-None-Match': _stageTrackerEtag } } : undefined); - if (r.status === 304) { - // A 304 carries no body, so take generated_at/source from the headers or the "updated" chip goes amber on a quiet hive. - const at = r.headers.get('X-Hive-Stage-Tracker-Generated-At'); - const src = r.headers.get('X-Hive-Stage-Tracker-Source'); - if (_stageTracker) { - if (at) _stageTracker.generated_at = at; - if (src) _stageTracker.source = src; - } - stageTrackerPollOk(); - stageTrackerTickClock(); - return; - } - if (!r.ok) { stageTrackerPollFailed('HTTP ' + r.status); return; } - _stageTrackerEtag = r.headers.get('ETag') || ''; - const text = await r.text(); - stageTrackerPollOk(); - if (text === _stageTrackerSig) { stageTrackerTickClock(); return; } - _stageTrackerSig = text; - renderStageTracker(JSON.parse(text)); - dashboardSetInterval('stage-tracker-clock', stageTrackerTickClock, STAGE_TRACKER_CLOCK_MS); - } catch (e) { - // Network failure or an aborted body: keep the previous render but - // say so in the "updated" chip instead of letting it read "fresh". - stageTrackerPollFailed('unreachable'); - } - } - - /* ---- Row actions: context menu + multi-select ------------------------- - A right-click (or the ⋯ kebab, Shift+F10, the context-menu key) on a - row opens an in-app menu of the actions that apply to that row's - state. The checkbox in the left gutter selects rows (Shift+click for - a range, Cmd/Ctrl+click to toggle); the selection bar above the list - carries the actions valid for every selected row and greys out the - rest with the reason. Selection is keyed on the row's item key, so - the ~1 s reconcile keeps it; rows that leave the list drop out of it. - Every action goes through an existing dashboard endpoint (hold, - send-to-human, rescan) or the decision endpoint, which records the - same /hive approve|decision a maintainer would — nothing merges. */ - const STAGE_TRACKER_DECISION_STAGES = [45, 85]; - const STAGE_TRACKER_SEL_ACTIONS = ['hold', 'release', 'retry', 'needs-human', 'copy']; - const STAGE_TRACKER_MENU_MARGIN = 4; - const STAGE_TRACKER_MENU_FAIL_LINES = 3; - // One source of plain words for every decision rule / action / reason - // (mirrors pkg/delegatedecision.GlossaryJSON(); stage_tracker_glossary_test.go - // fails when they drift). Rule slugs are never shown bare: use - // stageTrackerPlainWords(slug). hivecommons/hive#14822. - const STAGE_TRACKER_DECISION_GLOSSARY = { - "accept-proposal": {"kind": "action", "plain": "accepted the proposal as written", "detail": "The proposal is accepted as written with its stated defaults."}, - "accept-ratchet": {"kind": "action", "plain": "accepted as a ratchet", "detail": "Accepted as a ratchet: baseline recorded now, failures only on increases."}, - "adopt": {"kind": "action", "plain": "hive takes over finishing this PR", "detail": "Adopt means the hive takes over finishing this PR: it rebases, fixes CI and merges it, keeping the author's commits and sign-off."}, - "adopt-supersede": {"kind": "action", "plain": "close this PR and open a fresh hive-authored PR with the same commits", "detail": "Supersede means the hive closes this PR and opens a fresh hive-authored PR carrying the same commits and sign-off, then finishes it itself."}, - "adopted": {"kind": "action", "plain": "close this PR and open a fresh hive-authored PR with the same commits", "detail": "Supersede means the hive closes this PR and opens a fresh hive-authored PR carrying the same commits and sign-off, then finishes it itself."}, - "adoption-disabled": {"kind": "reason", "plain": "adoption is switched off on this hive", "detail": "Stage adoption is disabled on this hive (governor.labels.stage.adoption), so a request to take a PR over is never carried out."}, - "adoption-executing": {"kind": "reason", "plain": "the adoption engine is carrying it out", "detail": "The decision is recorded and the adoption engine picks it up on its next stage pass (a few minutes): it pushes the commits to a hive branch and opens the hive's copy. Nothing to do yet."}, - "adoption-stalled:contributor-lane:workflow-path": {"kind": "reason", "plain": "the PR edits .github/workflows; the hive's App lacks the `workflows` permission, so it cannot adopt it", "detail": "The PR changes files under .github/workflows. The hive's GitHub App has no `workflows` permission, so the adoption fence refuses to publish those edits from the hive. Grant the App the `workflows` permission and re-run the decision, or have a person rebase and merge it on GitHub, or close it as superseded."}, - "adoption-undone": {"kind": "reason", "plain": "the hive's copy was closed without merging and the adoption was undone", "detail": "The hive opened its copy, but the copy was closed without merging and a fresh one could not be opened, so the adoption was undone and the PR is back in its normal flow. Re-run the decision to adopt it again, or act on GitHub."}, - "adoption/supersede": {"kind": "action", "plain": "close this PR and open a fresh hive-authored PR with the same commits", "detail": "Supersede means the hive closes this PR and opens a fresh hive-authored PR carrying the same commits and sign-off, then finishes it itself."}, - "advisory-in-progress": {"kind": "rule", "plain": "a hive advisory the hive is still working; nothing to decide", "detail": "The issue is a hive advisory whose items are still being worked: the sweep ticks each as it closes or merges and closes the advisory when all are resolved. Nothing is written and nobody is parked on it."}, - "advisory-resolved": {"kind": "rule", "plain": "a hive advisory whose items are all resolved; closed as completed", "detail": "The issue is a hive advisory (a dedupe checklist or triage note) and every item it lists is closed or merged, so nothing is left to read; the hive closes it as completed."}, - "already-fixed": {"kind": "rule", "plain": "the issue was already fixed by a merged PR; closed as superseded", "detail": "The issue this PR fixes is already closed and a merged PR closed it (or a merged PR declares it supersedes this one), so nothing is left to deliver. The hive closes the PR as superseded with a note naming the merging PR; it never adopts it."}, - "approve": {"kind": "action", "plain": "approved for merge", "detail": "The hive approved it; the merge queue merges it once every check passes.", "issue_plain": "approved to proceed — an agent may claim it", "issue_detail": "The hive approved the direction; the issue leaves Needs decision and an agent may claim it. Nothing is merged."}, - "approve-review": {"kind": "action", "plain": "approved for merge", "detail": "The hive approved it; the merge queue merges it once every check passes.", "issue_plain": "approved to proceed — an agent may claim it", "issue_detail": "The hive approved the direction; the issue leaves Needs decision and an agent may claim it. Nothing is merged."}, - "approved": {"kind": "action", "plain": "approved for merge", "detail": "The hive approved it; the merge queue merges it once every check passes.", "issue_plain": "approved to proceed — an agent may claim it", "issue_detail": "The hive approved the direction; the issue leaves Needs decision and an agent may claim it. Nothing is merged."}, - "author-association": {"kind": "reason", "plain": "no merge lane vouches for this PR's author; a maintainer merges", "detail": "The PR is ready, but its author is not a collaborator and holds no trusted or merger tier, so no merge lane vouches for them and the hive never merges it unattended. A maintainer approves it (Approve and let hive merge — hive merges on the next tick once CI is green — or Merge now as maintainer), or trusts the author under 👥 Contributors."}, - "author-online": {"kind": "reason", "plain": "the author's clanker or hive is connected, so hive won't take the PR over", "detail": "Adoption is for authors whose clanker or hive has gone offline; this author's is connected, so the hive leaves the PR with them."}, - "behind": {"kind": "reason", "plain": "the branch is behind the base branch", "detail": "The branch is behind the base branch and must be updated before it can merge."}, - "blocker": {"kind": "reason", "plain": "the hive can't do this itself", "detail": "The item is blocked on something the hive cannot do: a permission the GitHub App lacks, or a step only a person may take. No decision clears it; grant the permission (and re-check) or do the step by hand (hivecommons/hive#15099)."}, - "capability": {"kind": "reason", "plain": "the hive can't do this itself", "detail": "The item is blocked on something the hive cannot do: a permission the GitHub App lacks, or a step only a person may take. No decision clears it; grant the permission (and re-check) or do the step by hand (hivecommons/hive#15099)."}, - "capability-gap": {"kind": "rule", "plain": "the GitHub App lacks a permission; deciding cannot clear it", "detail": "The blocker is a missing GitHub App permission (for example `workflows`). Approving a direction would only re-apply needs-human, so the park stays until the owner grants the permission or a person applies the change."}, - "capability:workflows-permission": {"kind": "reason", "plain": "the PR edits .github/workflows; the hive's App lacks the `workflows` permission, so it cannot adopt it", "detail": "The PR changes files under .github/workflows. The hive's GitHub App has no `workflows` permission, so the adoption fence refuses to publish those edits from the hive. Grant the App the `workflows` permission and re-run the decision, or have a person rebase and merge it on GitHub, or close it as superseded."}, - "changes-requested": {"kind": "reason", "plain": "a reviewer asked for changes; a new commit is needed", "detail": "A reviewer asked for changes on this branch. Approving cannot override that: only a new commit, or a maintainer merging by hand, moves it."}, - "changes_requested": {"kind": "reason", "plain": "a reviewer asked for changes; a new commit is needed", "detail": "A reviewer asked for changes on this branch. Approving cannot override that: only a new commit, or a maintainer merging by hand, moves it."}, - "checks-failing": {"kind": "reason", "plain": "CI is failing on this branch", "detail": "Required checks are failing on this branch; nothing merges until they are green."}, - "ci-failing": {"kind": "reason", "plain": "CI is failing on this branch", "detail": "Required checks are failing on this branch; nothing merges until they are green."}, - "ci-ratchet": {"kind": "rule", "plain": "a CI hygiene gate, landed as a ratchet", "detail": "A new CI hygiene gate lands as a ratchet: it records today's baseline and fails only on increases, so existing work is never blocked."}, - "ci-red": {"kind": "reason", "plain": "CI is failing on this branch", "detail": "Required checks are failing on this branch; nothing merges until they are green."}, - "close": {"kind": "action", "plain": "closed as completed; its items are tracked by the hive", "detail": "The hive closed the advisory as completed: every item it listed is resolved, or the hive's sweep tracks the rest."}, - "close-as-duplicate": {"kind": "action", "plain": "closed as a duplicate", "detail": "Closed because an older item already tracks the same work."}, - "close-completed": {"kind": "action", "plain": "closed as completed; its items are tracked by the hive", "detail": "The hive closed the advisory as completed: every item it listed is resolved, or the hive's sweep tracks the rest."}, - "close-duplicate": {"kind": "action", "plain": "closed as a duplicate", "detail": "Closed because an older item already tracks the same work."}, - "close-not-now": {"kind": "action", "plain": "declined for now; closed as not planned", "detail": "The hive declined the proposal for now and closed it as not planned, with the reason and what evidence would reopen it."}, - "close-superseded": {"kind": "action", "plain": "closed because another PR carries the work", "detail": "Closed because another PR carries the same work; the author is credited there.", "issue_plain": "closed because another issue carries the work", "issue_detail": "Closed because another issue already tracks the same work; the discussion continues there."}, - "closed": {"kind": "action", "plain": "closed because another PR carries the work", "detail": "Closed because another PR carries the same work; the author is credited there.", "issue_plain": "closed because another issue carries the work", "issue_detail": "Closed because another issue already tracks the same work; the discussion continues there."}, - "comment-decision": {"kind": "action", "plain": "recorded the decision on GitHub", "detail": "The hive posted the decision as a `/hive decision` comment, the way a maintainer would."}, - "conflict": {"kind": "reason", "plain": "the branch conflicts with the base branch", "detail": "The branch has merge conflicts with the base branch; it needs a rebase before anything can merge."}, - "conflicting": {"kind": "reason", "plain": "the branch conflicts with the base branch", "detail": "The branch has merge conflicts with the base branch; it needs a rebase before anything can merge."}, - "contributor-lane:author-association": {"kind": "reason", "plain": "no merge lane vouches for this PR's author; a maintainer merges", "detail": "The PR is ready, but its author is not a collaborator and holds no trusted or merger tier, so no merge lane vouches for them and the hive never merges it unattended. A maintainer approves it (Approve and let hive merge — hive merges on the next tick once CI is green — or Merge now as maintainer), or trusts the author under 👥 Contributors."}, - "contributor-lane:changes-requested": {"kind": "reason", "plain": "a reviewer asked for changes; a new commit is needed", "detail": "A reviewer asked for changes on this branch. Approving cannot override that: only a new commit, or a maintainer merging by hand, moves it."}, - "contributor-lane:sentinel-blocked": {"kind": "reason", "plain": "security-sensitive files changed; a maintainer must approve", "detail": "Security-sensitive files changed. The hive never merges until a maintainer reviews and removes the sentinel label."}, - "contributor-lane:workflow-path": {"kind": "reason", "plain": "the PR edits .github/workflows; the hive's App lacks the `workflows` permission, so it cannot adopt it", "detail": "The PR changes files under .github/workflows. The hive's GitHub App has no `workflows` permission, so the adoption fence refuses to publish those edits from the hive. Grant the App the `workflows` permission and re-run the decision, or have a person rebase and merge it on GitHub, or close it as superseded."}, - "contributor-offline": {"kind": "rule", "plain": "the author hasn't been reachable since the nudge", "detail": "The PR's author (or their clanker or hive) has been offline since the hive nudged them, so the hive takes the work over instead of waiting. The decision itself names which: the author's clanker, a connected hive, or the author."}, - "dco": {"kind": "reason", "plain": "a commit is missing its sign-off", "detail": "A commit on the branch is missing its Developer Certificate of Origin sign-off; the author must sign it off."}, - "dco-missing": {"kind": "reason", "plain": "a commit is missing its sign-off", "detail": "A commit on the branch is missing its Developer Certificate of Origin sign-off; the author must sign it off."}, - "dedupe": {"kind": "rule", "plain": "an older issue already tracks this", "detail": "An older issue already tracks the same work; one thread keeps it moving."}, - "default-approve": {"kind": "rule", "plain": "no special rule applies; the hive took its own recommendation", "detail": "No owner rule singles this issue out, so the hive went with its own recommendation — the reversible choice that keeps work moving."}, - "default-release": {"kind": "rule", "plain": "no special rule applies; a green branch is approved", "detail": "No owner rule holds this PR back; its branch is green and a merge is reversible, so it is approved."}, - "design-proposal": {"kind": "rule", "plain": "a proposal with clear acceptance criteria, accepted as written", "detail": "The proposal states concrete acceptance criteria, so it is accepted as written; anything not stated keeps today's behaviour."}, - "directed": {"kind": "action", "plain": "told the author agent what to change", "detail": "The hive recorded direction for the author agent, which pushes a new commit with that change.", "issue_plain": "gave direction on the issue", "issue_detail": "The hive recorded direction on the issue; the agent that claims it works from that direction."}, - "direction": {"kind": "action", "plain": "told the author agent what to change", "detail": "The hive recorded direction for the author agent, which pushes a new commit with that change.", "issue_plain": "gave direction on the issue", "issue_detail": "The hive recorded direction on the issue; the agent that claims it works from that direction."}, - "dirty": {"kind": "reason", "plain": "the branch conflicts with the base branch", "detail": "The branch has merge conflicts with the base branch; it needs a rebase before anything can merge."}, - "effect-unknown": {"kind": "reason", "plain": "the hive did not say why", "detail": "The hive could not tell from the lane reason why the decision has not taken effect."}, - "fix-then-merge": {"kind": "rule", "plain": "the branch isn't mergeable yet", "detail": "The branch cannot merge as it is (conflicts, red CI or a missing sign-off); the hive told the author agent exactly what to fix."}, - "flaky-test": {"kind": "rule", "plain": "a flaky test, quarantined with a retry", "detail": "The failure is a flaky test: it is quarantined with a retry and a separate deflake task is filed, so it blocks nothing."}, - "hive-policy": {"kind": "rule", "plain": "this changes the hive's own rules", "detail": "This changes the hive's own settings, governance or security posture; the hive only recommends and the owner confirms."}, - "hold": {"kind": "reason", "plain": "on hold; the hive does nothing until it is released", "detail": "The PR is on hold. The hive does nothing with it until a person releases the hold.", "issue_detail": "The issue is on hold. No agent claims it until a person releases the hold."}, - "human-changes-requested": {"kind": "reason", "plain": "a reviewer asked for changes; a new commit is needed", "detail": "A reviewer asked for changes on this branch. Approving cannot override that: only a new commit, or a maintainer merging by hand, moves it."}, - "human-merge": {"kind": "reason", "plain": "no merge lane vouches for this PR's author; a maintainer merges", "detail": "The PR is ready, but its author is not a collaborator and holds no trusted or merger tier, so no merge lane vouches for them and the hive never merges it unattended. A maintainer approves it (Approve and let hive merge — hive merges on the next tick once CI is green — or Merge now as maintainer), or trusts the author under 👥 Contributors."}, - "human-only": {"kind": "reason", "plain": "the hive can't do this itself", "detail": "The item is blocked on something the hive cannot do: a permission the GitHub App lacks, or a step only a person may take. No decision clears it; grant the permission (and re-check) or do the step by hand (hivecommons/hive#15099)."}, - "label:needs-human": {"kind": "reason", "plain": "marked needs-human; a person must remove the label", "detail": "The item is marked needs-human: automated fixes ran out or a person flagged it. The hive waits until the label is removed."}, - "labels-add": {"kind": "action", "plain": "added labels", "detail": "The hive added labels to the item."}, - "labels-remove": {"kind": "action", "plain": "removed labels", "detail": "The hive removed labels from the item."}, - "link": {"kind": "action", "plain": "cross-linked a related item", "detail": "The hive left a comment linking a related issue or PR."}, - "llm-delegate": {"kind": "rule", "plain": "decided by the hive's model under the owner's rules", "detail": "No mechanical rule applied, so the hive's model decided under the owner's standing rules; the same safety rails applied."}, - "mergeable-as-is": {"kind": "rule", "plain": "mergeable and green as it is; handed to the merge queue", "detail": "The head is mergeable with green CI, so no adoption is needed: the hive approves it and the merge queue takes it as it is."}, - "needs-human": {"kind": "reason", "plain": "marked needs-human; a person must remove the label", "detail": "The item is marked needs-human: automated fixes ran out or a person flagged it. The hive waits until the label is removed."}, - "no-effect": {"kind": "reason", "plain": "the decision hasn't taken effect", "detail": "The hive recorded this decision, but what it was supposed to cause has not happened within the expected time."}, - "no-new-commit": {"kind": "reason", "plain": "no new commit has been pushed", "detail": "The hive gave direction, but no new commit has been pushed yet."}, - "not-closed-yet": {"kind": "reason", "plain": "the close didn't land", "detail": "The hive decided to close it, but it is still open; the close call did not land."}, - "not-merged-yet": {"kind": "reason", "plain": "the merge queue hasn't merged it", "detail": "The hive approved it but the merge queue has not merged it; its lane reason says what still blocks it."}, - "not-now": {"kind": "action", "plain": "declined for now; closed as not planned", "detail": "The hive declined the proposal for now and closed it as not planned, with the reason and what evidence would reopen it."}, - "one-pr-per-issue": {"kind": "rule", "plain": "two PRs fix the same issue; the merge queue keeps one", "detail": "Two open PRs declare the same closing issue. The merge queue carries one PR per issue — a green head first, then the earlier-opened — and the other closes as superseded with credit."}, - "operator-action": {"kind": "action", "plain": "told the spoke owner what to do; nothing for an agent here", "detail": "The hive named the spoke owner and the one action they take (for example re-authenticate the provider). The item stays parked, gets no approved-direction, and clears when the report stops recurring."}, - "owner-only": {"kind": "rule", "plain": "only the hive owner can do this", "detail": "This needs a secret, token or organization permission that only the hive owner holds; the hive cannot do it for you."}, - "owner_only": {"kind": "rule", "plain": "only the hive owner can do this", "detail": "This needs a secret, token or organization permission that only the hive owner holds; the hive cannot do it for you."}, - "park-label-stuck": {"kind": "reason", "plain": "stage/045-needs-decision is still on the issue; the scanner skips it until that label clears", "detail": "The hive approved the issue and applied approved-direction, but the stage/045-needs-decision park label was never removed, so the scanner still skips the issue. Lift the park (it removes the label through the hive's audited label path) or re-evaluate the issue so the stage engine re-reads it."}, - "prefer-contributor": {"kind": "rule", "plain": "a contributor's PR and a hive PR do the same work", "detail": "A contributor's PR and a hive-authored PR cover the same work; the hive prefers the contributor's when it is mergeable and current."}, - "proposal-approve-evidence": {"kind": "rule", "plain": "a proposal backed by an incident or a repeated class; approved", "detail": "The hive-filed proposal names an incident it would have prevented, or prior instances of the same class fixed one at a time, so its cost is justified and it is approved as proposed."}, - "proposal-not-now": {"kind": "rule", "plain": "a hive-filed proposal with no incident or recurrence behind it; declined for now", "detail": "The proposal shows neither an incident it would have prevented nor a repeated class it would end, so its value is speculative. The hive declines it for now and closes it as not planned; re-propose with evidence."}, - "quarantine-flaky": {"kind": "action", "plain": "quarantined the flaky test", "detail": "The flaky test is quarantined with a retry and a deflake task is filed."}, - "rail-hold": {"kind": "rule", "plain": "the item is on hold", "detail": "The item carries the hold label; the hive never acts on a held item until a person releases the hold."}, - "ready-for-human-merge": {"kind": "reason", "plain": "no merge lane vouches for this PR's author; a maintainer merges", "detail": "The PR is ready, but its author is not a collaborator and holds no trusted or merger tier, so no merge lane vouches for them and the hive never merges it unattended. A maintainer approves it (Approve and let hive merge — hive merges on the next tick once CI is green — or Merge now as maintainer), or trusts the author under 👥 Contributors."}, - "rebase-then-merge": {"kind": "rule", "plain": "only conflicts block it; a rebase then merge", "detail": "Conflicts are the only blocker. The unattended rebase-then-merge path lands with hivecommons/hive#15104; until then the ladder records this rung and moves on."}, - "recommend-only": {"kind": "action", "plain": "recommended only; a person confirms", "detail": "The hive only recommended; the item stays parked until a person confirms."}, - "recommended": {"kind": "action", "plain": "recommended only; a person confirms", "detail": "The hive only recommended; the item stays parked until a person confirms."}, - "red": {"kind": "reason", "plain": "CI is failing on this branch", "detail": "Required checks are failing on this branch; nothing merges until they are green."}, - "refused": {"kind": "action", "plain": "did not decide", "detail": "The hive did not decide this item; its safety rails stopped it (for example, the item is on hold)."}, - "reporter-trust": {"kind": "rule", "plain": "the hold on an unknown reporter is cleared because the fix is sound", "detail": "The PR was held until the reporter's trust was known; its fix is green and mergeable, so the hold is cleared."}, - "request_changes": {"kind": "reason", "plain": "a reviewer asked for changes; a new commit is needed", "detail": "A reviewer asked for changes on this branch. Approving cannot override that: only a new commit, or a maintainer merging by hand, moves it."}, - "requires_human": {"kind": "reason", "plain": "marked needs-human; a person must remove the label", "detail": "The item is marked needs-human: automated fixes ran out or a person flagged it. The hive waits until the label is removed."}, - "return-to-author": {"kind": "rule", "plain": "a person pushed this PR; the hive asked them, not adopted it", "detail": "The PR was pushed by a person (author/human or one of this hive's owners), so the hive never adopts it. It told the author by name what to fix (rebase, sign-off, CI) and relayed the reviewer's question."}, - "return-to-contributor": {"kind": "rule", "plain": "the author's clanker or hive is connected; returned to them with the fix list", "detail": "The author's clanker or hive is connected (or has picked the rework up), so the hive hands the PR back to them with the exact fix list instead of adopting it."}, - "review-backlog": {"kind": "rule", "plain": "the PR closed without merging, so the issue stays open", "detail": "The fixing PR closed unmerged; the issue stays open and is re-triaged rather than auto-closed."}, - "reviewer-verdict:request_changes": {"kind": "reason", "plain": "a reviewer asked for changes; a new commit is needed", "detail": "A reviewer asked for changes on this branch. Approving cannot override that: only a new commit, or a maintainer merging by hand, moves it."}, - "self-decision-read-as-changes": {"kind": "reason", "plain": "hive's own decision comment was read as a reviewer asking for changes", "detail": "The merge queue read the hive's own `/hive decision` comment as a reviewer asking for changes, so the decision blocked the PR it meant to advance (hivecommons/hive#14822). A new commit or a maintainer merge clears it."}, - "selfreport-operator-action": {"kind": "rule", "plain": "a spoke self-report only its operator can fix; not code work", "detail": "The issue is a fleet self-report (expired login, credentials, disk, network, App setup) whose remedy is on the reporting spoke. The hive tells that spoke's owner what to do and keeps it out of the actionable set; no agent is sent to code."}, - "sentinel": {"kind": "reason", "plain": "security-sensitive files changed; a maintainer must approve", "detail": "Security-sensitive files changed. The hive never merges until a maintainer reviews and removes the sentinel label."}, - "sentinel-alert": {"kind": "reason", "plain": "security-sensitive files changed; a maintainer must approve", "detail": "Security-sensitive files changed. The hive never merges until a maintainer reviews and removes the sentinel label."}, - "sentinel-blocked": {"kind": "reason", "plain": "security-sensitive files changed; a maintainer must approve", "detail": "Security-sensitive files changed. The hive never merges until a maintainer reviews and removes the sentinel label."}, - "sentinel-trusted": {"kind": "rule", "plain": "security-sensitive files changed, but the author is trusted", "detail": "Security-sensitive files changed; because the author is trusted the hive approved, but a person must still remove the sentinel label before it merges."}, - "sentinel-untrusted": {"kind": "rule", "plain": "security-sensitive files changed; a maintainer must approve", "detail": "Security-sensitive files changed in a PR from an author without write access; a maintainer must review and approve it."}, - "small-low-risk": {"kind": "rule", "plain": "a small, low-risk change on a green branch", "detail": "The change is small and low-risk (docs, CI pins, text, workflow hygiene) and CI is green, so it is approved."}, - "still-parked": {"kind": "reason", "plain": "the item is still waiting on a person", "detail": "The item is still parked for a person's decision; the recorded decision did not move it."}, - "supersede": {"kind": "action", "plain": "close this PR and open a fresh hive-authored PR with the same commits", "detail": "Supersede means the hive closes this PR and opens a fresh hive-authored PR carrying the same commits and sign-off, then finishes it itself."}, - "supersede-now": {"kind": "action", "plain": "close this PR and open a fresh hive-authored PR with the same commits", "detail": "Supersede means the hive closes this PR and opens a fresh hive-authored PR carrying the same commits and sign-off, then finishes it itself."}, - "superseded": {"kind": "action", "plain": "closed because another PR carries the work", "detail": "Closed because another PR carries the same work; the author is credited there.", "issue_plain": "closed because another issue carries the work", "issue_detail": "Closed because another issue already tracks the same work; the discussion continues there."}, - "untrusted-author": {"kind": "reason", "plain": "no merge lane vouches for this PR's author; a maintainer merges", "detail": "The PR is ready, but its author is not a collaborator and holds no trusted or merger tier, so no merge lane vouches for them and the hive never merges it unattended. A maintainer approves it (Approve and let hive merge — hive merges on the next tick once CI is green — or Merge now as maintainer), or trusts the author under 👥 Contributors."}, - "workflow-path": {"kind": "reason", "plain": "the PR edits .github/workflows; the hive's App lacks the `workflows` permission, so it cannot adopt it", "detail": "The PR changes files under .github/workflows. The hive's GitHub App has no `workflows` permission, so the adoption fence refuses to publish those edits from the hive. Grant the App the `workflows` permission and re-run the decision, or have a person rebase and merge it on GitHub, or close it as superseded."}, - }; diff --git a/src/pkg/dashboard/static-src/manifest.txt b/src/pkg/dashboard/static-src/manifest.txt index 2825c2f79e..2a7cd02568 100644 --- a/src/pkg/dashboard/static-src/manifest.txt +++ b/src/pkg/dashboard/static-src/manifest.txt @@ -70,6 +70,9 @@ js/tracker-words.js js/tracker-row.js js/tracker-motion.js js/tracker-filter.js +js/tracker-filter-state.js +js/tracker-filter-render.js +js/tracker-filter-fetch.js js/tracker-actions.js js/tracker-merged.js js/tracker-queue.js From 2648b18ae281d72474cbeb5705129b9b2cc6db66 Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2026 06:57:19 +0000 Subject: [PATCH 2/3] changelog: fragment for #15706 Generated by changelog-fragment-guard from the PR title (#5675). Edit the wording freely, or replace this file with the no-changelog label if the change is not user-visible. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/changed-15706.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/changed-15706.md diff --git a/changelog.d/changed-15706.md b/changelog.d/changed-15706.md new file mode 100644 index 0000000000..ebf67d5604 --- /dev/null +++ b/changelog.d/changed-15706.md @@ -0,0 +1 @@ +- refactor: split static-src/js/tracker-filter.js into 4 files (#15706) From 86f0cad44a24e07910ef92fc6b6ebe49da393ba7 Mon Sep 17 00:00:00 2001 From: architect <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2026 04:26:58 -0400 Subject: [PATCH 3/3] chore: drop changelog fragment for internal refactor Hive-Fix-Attempt: 1/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: architect <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/changed-15706.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 changelog.d/changed-15706.md diff --git a/changelog.d/changed-15706.md b/changelog.d/changed-15706.md deleted file mode 100644 index ebf67d5604..0000000000 --- a/changelog.d/changed-15706.md +++ /dev/null @@ -1 +0,0 @@ -- refactor: split static-src/js/tracker-filter.js into 4 files (#15706)