From 143d64eb0d6c1032b8ae4d2966cc141c012e5c01 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Tue, 27 Oct 2026 15:50:32 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20dashboard:=20order=20tracker=20rows?= =?UTF-8?q?=20attention-first=20within=20each=20column?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Within a column the Hive activity monitor now tiers rows before the existing keys: rows a person must act on now (a shown pill or a human-gated stage) first, plain rows next, hold / draft / closed-issue-anchored rows last; within a tier the longest on the step still comes first, then repo and number. Applies to the Furthest along and Longest waiting sorts and to the PR sub-rows under an issue; the direction arrow flips the age keys but never the tier. The server pre-sort mirrors the tier (stageTrackerAttentionTier in Go and JS) so chat /prs and the hub read the same order. Fixes #14686 Signed-off-by: Andy Anderson --- .../changed-tracker-attention-first-order.md | 1 + src/docs/dashboard-sections.md | 2 +- src/pkg/dashboard/stage_tracker.go | 82 +++++++- .../stage_tracker_attention_order_test.go | 183 ++++++++++++++++++ .../dashboard/stage_tracker_motion_test.go | 9 + .../stage_tracker_repo_grouping_test.go | 1 + src/pkg/dashboard/stage_tracker_ui_test.go | 5 +- src/pkg/dashboard/static/index.html | 47 +++-- 8 files changed, 312 insertions(+), 18 deletions(-) create mode 100644 changelog.d/changed-tracker-attention-first-order.md create mode 100644 src/pkg/dashboard/stage_tracker_attention_order_test.go diff --git a/changelog.d/changed-tracker-attention-first-order.md b/changelog.d/changed-tracker-attention-first-order.md new file mode 100644 index 0000000000..e99e7f56b9 --- /dev/null +++ b/changelog.d/changed-tracker-attention-first-order.md @@ -0,0 +1 @@ +- Hive activity monitor: rows order attention-first within each column — rows a person must act on now (a shown pill or a human-gated stage) first, plain rows next, `hold` / `draft` / closed-issue-anchored rows last — for the *Furthest along* and *Longest waiting* sorts and for the PR sub-rows under an issue; the direction arrow flips the age order but never the tier, and the `GET /api/stage-tracker` payload is pre-sorted the same way so chat `/prs` and the hub agree. diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index 86ae0b77f7..210568fdd0 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -640,7 +640,7 @@ More about the line: A progress strip per open issue and pull request showing which step of the pipeline it is on and who must act next. -Fed by `GET /api/stage-tracker`. Every issue and pull request follows the same pipeline, named once in the column header above the list: `Open → Actionable (010) → Claimed (020) → PR in progress (030/040) → CI / Review (050/060) → Merge gate (080/100) → ✓ merged`. Each entry is a title line over a thin chevron strip. Only the current step is coloured: it is filled amber and carries the step name in words; once the PR is merged the final ✓ chevron is the lit one, in green. Motion is reserved for what is running or needs a hand — the lit chevron falls into one of three buckets (`stageTrackerMotion()` in `index.html`): **static** (steady): Open, Open · on hold (any hold label wins over every other signal), Actionable (010), Claimed (020), PR in progress / Covered by PR (030/040) by a human author, Merged, and any unrecognised stage; **active** (gentle pulse): the hive is acting — 030/040 by a hive or clanker author, 050 review pending, 060 reviewed, 070 fixing, 074 adopted by hive, 080 merge gate, 095 pre-merge soak, 100 merge queue; **needs-human** (slower amber→red breathe): a person must move — 015 triage needed, 045/085 needs decision, 071 needs author, 072 returned to contributor, 090 ready for a human merge, or a `stalled` / `blocked` / `needs-human` / `needs-decision` / `needs-triage` modifier on any stage. Under `prefers-reduced-motion` nothing animates; a needs-human step keeps a steady red tint so it still stands out. Every other step is a low-contrast shape with a small grey glyph (circle, bolt, lock, branch, eye, shield, check) — passed steps a subtle neutral fill, steps ahead a faint outline. Side stages are not extra steps: `070 Fixing` (the author's move; the `needs-rebase` chip next to it says what is being fixed — the stage labeller always parks a needs-rebase PR at 070/071/072, never at CI / Review), `071 Needs author` (human-authored), `072 Returned to contributor` (clanker-authored) and `074 Adopted by hive` light *CI / Review* with their own name (an adopted PR stays on 074 through the hive's pushes going pending, green or red again, and moves on only when *Merge gate* takes it); `085 Needs human decision` (PR-only) and `090 Ready for human merge` light *Merge gate* with their own name (the 085 tooltip says what must be decided); an issue parked on a person wears `045 Needs human decision` and lights *Actionable* (the issue side) with that name — a pre-045 issue still wearing 085 is drawn the same way until the reconciler re-stages it; an actionable issue no maintainer has looked at yet wears `015 Triage needed` (carrying `needs-triage`, or held in the reporter-trust gate's `reporter_triage` bucket — never derived from who filed it) and lights *Actionable* as "Triage needed" (a human's move) — so the Actionable column reads "Actionable", "Triage needed" or "Needs human decision", and the Open column is untouched. An issue carrying a hold-class label (`hold`, `do-not-merge*`, `hive-pause/`) is never parked: it sits at *Open* as "Open · on hold" even beside `needs-human`, and the reconciler removes any 045 the hold caught it with ([#13012](https://github.com/hivecommons/hive/issues/13012)). The lit chevron ends with an ink-coloured icon of whose move it is — person (human), robot (clanker) or hexagon (hive): the claim holder on Claimed, the PR author on PR in progress and Returned to contributor, hive on CI / Review, Adopted by hive and Ready for auto merge, a human on Needs human decision and Ready for human merge. A row at `090 Ready for human merge` always says *why* a person and not the hive merges it (#14658): the lit word ends `· workflow files`, `· tests removed`, `· manual-merge policy`, `· branch protection`, `· merge method`, `· auto-merge off`, `· untrusted author`, `· unauthorized`, `· reviewer deferred` or `· policy` (payload `human_merge_reason`, a `prstage.HumanMergeReason*` code derived from the stage record's lane reason — no second store), the chevron tooltip leads with the one-sentence `human_merge_reason_text` ("Changes .github/workflows/** — the hive never merges workflow changes …; click Merge on GitHub"), the manual-merge word reads `Awaiting human merge · workflow files · approved by @login`, the search / needs-attention headline carries the same tail, and a PR nested under its issue mirrors `human_approver`, `manual_merge`, `human_merge_reason` and `human_merge_reason_text` onto its `linked_prs` entry so the sub-row says the same. `040 Covered by PR` shares the *PR in progress* column with 030; `060 Reviewed`, `080 Awaiting merge admission` and `100 Merge queue` all light *Merge gate* as "Ready for auto merge" (the chevron tooltip says "not yet admitted — " for 060/080 and "admitted, merging" for 100); `095 Pre-merge soak` lights the same column as "Soaking" (hive's move; tooltip "admitted, soaking — Xm left", headline "Pre-merge soak — Xm left" from the payload's `soak_remaining_seconds`, aged from the lane's last sweep), so an admitted PR inside its soak window is no longer drawn as merging; the chevron's own tooltip names the exact stage. Covering pull requests nest under their issue. An issue with no PR yet draws the whole strip like any other row, lit at Open, Actionable or Claimed with the steps ahead faint. Once exactly one PR covers it, issue and PR are a single entry: the issue's `#N title` on the left, `↳ [author icon] #PR title` under the *PR in progress* header on the same title line (the ↳ marks a PR drawn on its issue's row; the PR link's tooltip says so — "linked PR, shown on its issue's row" — and, when two open issues list the same PR, every row but the lowest-numbered issue adds "also under #N"), and one continuous strip — Open, Actionable and Claimed passed, the PR's stage lighting the chevron from PR in progress through CI / Review, Merge gate and ✓; the chip, tooltip and `since` are the PR's. With two or more covering PRs the issue's own strip stops at Claimed — all passed, nothing on the issue line lit. Directly beneath, tighter than the gap between entries, sits one indented sub-row per open covering PR, furthest along first: `[author icon] #N title` at the *PR in progress* column, then that PR's own strip from there on — `PR in progress → CI / Review → Merge gate → ✓` — with its own lit chevron, chip, tooltip and `since`. So an issue with two PRs, one at 030, shows "PR in progress" lit on that sub-row, not on the issue. A PR linked to an open issue in the list has no top-level row of its own; a PR with no linked issue keeps a full-width row and shows the first steps as passed. A PR whose only linked issue is already closed — a superseded PR whose body still says `Fixes #N` after an earlier PR fixed it — keeps its own row with the closed issue in the issue slot: `#N title` as a link, muted and struck through, followed by a small `closed` chip, so the pairing reads at a glance; when the title cannot be resolved the slot says `#N (closed issue)` rather than a bare number (the title comes from the snapshot, or from one cached issue read the cycle makes once per issue — see [Linked issues](dashboard.md#pr-review-and-link-signals)). The *Pull requests* filter flattens the list — every PR as a top-level row; *Issues* and *All* show the nested view. Each row is named once on the left; a covering PR appears under the *PR in progress* header as `[author icon] #N title`. A pull request with no linked issue is named once: `[PR icon] [author icon] #N title` on the left over one continuous strip (first steps passed, its own step lit) and nothing in the *PR in progress* column, which is reserved for covering PRs — so a title never appears twice in a row. Pull requests are never issues here: when a number arrives through both the issues feed and the pulls feed the PR record wins and the issue copy is dropped on the server (pairing is keyed by repository, kind and number), and the *Issues* filter never lists a PR. The author icon is the one coloured legend: hive hexagon in blue, clanker robot in purple, human silhouette in teal (the `author/*` kind, inferred from the snapshot when the label is absent; the login is in the `#N` link's tooltip). The right-hand `since` column, in line with the chevron strip, is how long the item has been on its step (red when `stalled`). A plain *Open* step — no stage label yet and not on hold — also carries that age in its own words, "Open · since 3d" ("since 14h" under two days), taken from the same `stage_since` instant the column draws (falling back to the time the item was opened, which the chevron tooltip then marks "(opened)"); past `STAGE_TRACKER_OPEN_STALE_DAYS` (2) the chevron takes a subtle red tint. *Open · hold* never shows the age. An Open item carrying the `blocked` label is drawn the same way as a hold — "Open · blocked" with a ⛔ glyph in the hold's yellow — but keeps the age ("Open · blocked · since 7h"; a stale blocked item is exactly what should stand out, [#14194](https://github.com/hivecommons/hive/issues/14194)) and its chevron tooltip says why: "blocked on owner/repo#N" when the payload names the blocker (`blocked_on`), else "carries the blocked label"; when an item is both held and blocked, hold wins — it is a human instruction. At most one muted chip sits at the right end of the title line, directly over the strip's ✓ cap (on the last line when the title wraps; a hairline above each entry and a hover tint over the whole entry keep chip and `since` unambiguously with their own row — [#14640](https://github.com/hivecommons/hive/issues/14640)): the most important health modifier (`stalled`, `regressed`, `hold`, `needs-human`, `needs-decision` — shown as "needs human decision" —, `needs-triage` — shown as "triage needed" (amber) on an issue still carrying the `needs-triage` label before the claim (010, 017, 045; at 015 the lit chevron already says so); a `needs-triage` left on a claimed or later issue (020+) is stale, never shown as a chip or stage text, and reported instead as `stale_labels` in the payload with a muted *Stale label* line in the hover tooltip until the stage sweep removes it (hivecommons/hive#14586) —, `needs-rebase`, `blocked`, `draft`) with a `+N` for the rest. Everything else — the reason sentence, who must act, nudges sent, the repository, all flags and the last stage hops — is in the hover tooltip on the item's `#N` link (on a nested sub-row, on its `#N` PR link). Hover text in a row lives only on the `#N` link, the covering-PR link, the title and the lit chevron (its stage, and whose move it is); passed and upcoming chevrons, the kind and author icons, chips and the `since` column have none. Title lines wrap rather than push the strip out of alignment: the issue title stays before the *PR in progress* column (a clear gap always separates it from the PR entry, which starts at the column edge) and the PR title before the chip; hovering a title shows the full text. Rows are sorted furthest-along first by default — a covered issue ranks by its furthest-along PR — then longest on the step first; *Sort* also offers longest waiting, newest and number, and the arrow beside it reverses the order. Every open issue and pull request of the watched repositories is listed — actionable, held, claimed, in progress, covered by a PR, filtered by a `needs-*` label, reporter-triage, draft and exempt-labelled alike; an item without a stage label or journal entry sits at *Open*, and one in a scanner bucket with no label yet is placed from the bucket (claimed → 020, in progress → 030, covered → 040). Filters work on the cached payload in the browser and persist across reloads (the page number does not): kind chips, *Repo*, a search box (`#number` / number / title substring, also matching a covering PR), *Since* (any, over 1 hour / 1 day / 1 week on the current step, or past the stage's configured dwell — stalled items always qualify), *Author* kind, *Needs attention* (anything with a health modifier or on 071 / 072 / 085 / 090), and label chips built from every label present, each with its count: a **🙋 Needs human** facet first (attention-coloured; it matches any item carrying a label of the needs-human set — the server's `needs_human_labels`, the same list as the Projects *Needs human* preset: `stage/045-needs-decision`, `stage/085-needs-decision`, `needs-decision`, `needs-direction`, `needs-spec`, `needs-signal`, `needs-human` and `needs-human/*`, the hold labels, `stage/071-needs-author`, `sentinel-alert`, `needs-triage`; its count is the number of distinct items, not the sum of label counts), then every `stage/NNN-*` label in numerical order, then all other labels alphabetically (case-insensitive). When the row would overflow, the **+N more** button opens an in-app *All labels* dialog listing every label in the same order with counts, a type-to-filter box, the same toggles the chips use and a *Clear* button; a label selected there is promoted into the visible row. Chips of one family OR, families AND; *Needs human* ANDs with the label chips. *Clear filters* shows while anything is narrowed. The list is paged — 25 / 50 / 100 rows, default 50 — with Prev / Next and "showing X–Y of N (M filtered out)" above and below; the header count "N rows · M need attention" is for the filtered set, the **sidebar badge is the row count of the default view** (owner: the tracker counts rows, not items — a covering PR drawn on its issue's row is not a row of its own, and an issue with several PRs already has several), and both come from the same `stageTrackerCountsText()` call so they cannot disagree. When rows sit below the payload's open issues + PRs, the "showing" line's tooltip and the badge's footnote say why — "2 PRs shown on their issue's row" — rather than printing a second total.the chevron's own tooltip names the exact stage. Covering pull requests nest under their issue. An issue with no PR yet draws the whole strip like any other row, lit at Open, Actionable or Claimed with the steps ahead faint. Once exactly one PR covers it, issue and PR are a single entry: the issue's `#N title` on the left, `[author icon] #PR title` under the *PR in progress* header on the same title line, and one continuous strip — Open, Actionable and Claimed passed, the PR's stage lighting the chevron from PR in progress through CI / Review, Merge gate and ✓; the chip, tooltip and `since` are the PR's. With two or more covering PRs the issue's own strip stops at Claimed — all passed, nothing on the issue line lit. Directly beneath, tighter than the gap between entries, sits one indented sub-row per open covering PR, furthest along first: `[author icon] #N title` at the *PR in progress* column, then that PR's own strip from there on — `PR in progress → CI / Review → Merge gate → ✓` — with its own lit chevron, chip, tooltip and `since`. So an issue with two PRs, one at 030, shows "PR in progress" lit on that sub-row, not on the issue. A PR linked to an open issue in the list has no top-level row of its own; a PR with no linked issue keeps a full-width row and shows the first steps as passed. The *Pull requests* filter flattens the list — every PR as a top-level row; *Issues* and *All* show the nested view. Each row is named once on the left; a covering PR appears under the *PR in progress* header as `[author icon] #N title`. A pull request with no linked issue is named once: `[PR icon] [author icon] #N title` on the left over one continuous strip (first steps passed, its own step lit) and nothing in the *PR in progress* column, which is reserved for covering PRs — so a title never appears twice in a row. Pull requests are never issues here: when a number arrives through both the issues feed and the pulls feed the PR record wins and the issue copy is dropped on the server (pairing is keyed by repository, kind and number), and the *Issues* filter never lists a PR. The author icon is the one coloured legend: hive hexagon in blue, clanker robot in purple, human silhouette in teal (the `author/*` kind, inferred from the snapshot when the label is absent; the login is in the `#N` link's tooltip). The right-hand `since` column, in line with the chevron strip, is how long the item has been on its step (red when `stalled`). At most one muted chip sits at the right end of the title line, directly over the strip's ✓ cap (on the last line when the title wraps; a hairline above each entry and a hover tint over the whole entry keep chip and `since` unambiguously with their own row — [#14640](https://github.com/hivecommons/hive/issues/14640)): the most important health modifier (`stalled`, `regressed`, `hold`, `needs-human`, `needs-decision` — shown as "needs human decision" —, `needs-rebase`, `blocked`, `draft`) with a `+N` for the rest. A `regressed` chip is red only when the row is parked on a person (a human-gate modifier or stage 045 / 071 / 072 / 085 / 090); on a hive-driven stage with nothing waiting on a human it draws as a muted dashed `stage ↓` pill, yields the lead slot to any other modifier, keeps the row out of **Needs attention**, and its tooltip ends "the hive is handling it — no action needed; clears on the next forward step". The marker is set by a genuine backward hop (a lapsed claim 020 → 010, a 030 ↔ 020 flicker and a 040 → 010 after a partially-addressing merge are not regressions) and clears on the first forward hop; see "The regressed marker" in `labels-and-control-signals.md`. Everything else — the reason sentence, who must act, nudges sent, the repository, all flags and the last stage hops — is in the hover tooltip on the item's `#N` link (on a nested sub-row, on its `#N` PR link). Hover text in a row lives only on the `#N` link, the covering-PR link, the title and the lit chevron (its stage, and whose move it is); passed and upcoming chevrons, the kind and author icons, chips and the `since` column have none. Title lines wrap rather than push the strip out of alignment: the issue title stays before the *PR in progress* column (a clear gap always separates it from the PR entry, which starts at the column edge) and the PR title before the chip; hovering a title shows the full text. Rows are sorted furthest-along first by default — a covered issue ranks by its furthest-along PR — then longest on the step first; *Sort* also offers longest waiting, newest and number, and the arrow beside it reverses the order. Every open issue and pull request of the watched repositories is listed — actionable, held, claimed, in progress, covered by a PR, filtered by a `needs-*` label, reporter-triage, draft and exempt-labelled alike; an item without a stage label or journal entry sits at *Open*, and one in a scanner bucket with no label yet is placed from the bucket (claimed → 020, in progress → 030, covered → 040). Filters work on the cached payload in the browser and persist across reloads (the page number does not): kind chips, *Repo*, a search box (`#number` / number / title substring, also matching a covering PR), *Since* (any, over 1 hour / 1 day / 1 week on the current step, or past the stage's configured dwell — stalled items always qualify), *Author* kind, *Needs attention* (anything with a health modifier or on 071 / 072 / 085 / 090), and label chips built from every label present, each with its count: a **🙋 Needs human** facet first (attention-coloured; it matches any item carrying a label of the needs-human set — the server's `needs_human_labels`, the same list as the Projects *Needs human* preset: `stage/045-needs-decision`, `stage/085-needs-decision`, `needs-decision`, `needs-direction`, `needs-spec`, `needs-signal`, `needs-human` and `needs-human/*`, the hold labels, `stage/071-needs-author`, `sentinel-alert`, `needs-triage`; its count is the number of distinct items, not the sum of label counts), then every `stage/NNN-*` label in numerical order, then all other labels alphabetically (case-insensitive). When the row would overflow, the **+N more** button opens an in-app *All labels* dialog listing every label in the same order with counts, a type-to-filter box, the same toggles the chips use and a *Clear* button; a label selected there is promoted into the visible row. Chips of one family OR, families AND; *Needs human* ANDs with the label chips. *Clear filters* shows while anything is narrowed. The list is paged — 25 / 50 / 100 rows, default 50 — with Prev / Next and "showing X–Y of N (M filtered out)" above and below; the header reads "N items (I issues / P PRs) · M need attention" — N, I and P are the whole list, the same `openItems` set the Overview tile and its left-menu counter print, so N always equals the tile's **Total open issues + Total open PRs**; a "· X match filters" note follows while a filter is on. The sidebar counter beside **Hive activity monitor** is that same N — total open items, written in the same render pass as the header, so the two cannot drift apart; how many need attention is the warn-coloured header suffix and the counter's hover tooltip (counted over every item, filters or not). When covering pull requests are nested under their issue the "showing X–Y of R" line counts rows and adds "(P nested under their issues)" so R never reads as a different total. The small monospace strip beside the count — `engine enforce · N anomalies` — is the central stage engine ([ADR-0025](adr/0025-central-stage-engine.md)): `engine` names the current `governor.labels.stage.engine.mode` (green `enforce`, neutral `shadow` = paused, nothing written; hover for what the mode does and the derivation count), `anomalies` counts stage moves the engine's admission table did not expect (red when non-zero). The same numbers are `/api/status.stageEngine`; the mode is changed under **Settings → Labels → Central stage engine mode** and the operator notes are in [operator-reference.md](operator-reference.md#central-stage-engine-rollout). "updated Ns ago · cache" says how old the server-built payload is: the spoke rebuilds it at most every `dashboard.stage_tracker.cache_ttl_s` (default `governor.eval_interval_s`) from its existing snapshot and serves it with an `ETag`, so the browser's 30-second poll is a 304 and no request ever reaches GitHub (`/api/gh-rate-limits` lists the caller `dashboard:stage-tracker` with nothing charged). See [Stage labels](labels-and-control-signals.md#stage-labels-stagennn--the-pipeline-state-machine). +Fed by `GET /api/stage-tracker`. Every issue and pull request follows the same pipeline, named once in the column header above the list: `Open → Actionable (010) → Claimed (020) → PR in progress (030/040) → CI / Review (050/060) → Merge gate (080/100) → ✓ merged`. Each entry is a title line over a thin chevron strip. Only the current step is coloured: it is filled amber and carries the step name in words; once the PR is merged the final ✓ chevron is the lit one, in green. Motion is reserved for what is running or needs a hand — the lit chevron falls into one of three buckets (`stageTrackerMotion()` in `index.html`): **static** (steady): Open, Open · on hold (any hold label wins over every other signal), Actionable (010), Claimed (020), PR in progress / Covered by PR (030/040) by a human author, Merged, and any unrecognised stage; **active** (gentle pulse): the hive is acting — 030/040 by a hive or clanker author, 050 review pending, 060 reviewed, 070 fixing, 074 adopted by hive, 080 merge gate, 095 pre-merge soak, 100 merge queue; **needs-human** (slower amber→red breathe): a person must move — 015 triage needed, 045/085 needs decision, 071 needs author, 072 returned to contributor, 090 ready for a human merge, or a `stalled` / `blocked` / `needs-human` / `needs-decision` / `needs-triage` modifier on any stage. Under `prefers-reduced-motion` nothing animates; a needs-human step keeps a steady red tint so it still stands out. Every other step is a low-contrast shape with a small grey glyph (circle, bolt, lock, branch, eye, shield, check) — passed steps a subtle neutral fill, steps ahead a faint outline. Side stages are not extra steps: `070 Fixing` (the author's move; the `needs-rebase` chip next to it says what is being fixed — the stage labeller always parks a needs-rebase PR at 070/071/072, never at CI / Review), `071 Needs author` (human-authored), `072 Returned to contributor` (clanker-authored) and `074 Adopted by hive` light *CI / Review* with their own name (an adopted PR stays on 074 through the hive's pushes going pending, green or red again, and moves on only when *Merge gate* takes it); `085 Needs human decision` (PR-only) and `090 Ready for human merge` light *Merge gate* with their own name (the 085 tooltip says what must be decided); an issue parked on a person wears `045 Needs human decision` and lights *Actionable* (the issue side) with that name — a pre-045 issue still wearing 085 is drawn the same way until the reconciler re-stages it; an actionable issue no maintainer has looked at yet wears `015 Triage needed` (carrying `needs-triage`, or held in the reporter-trust gate's `reporter_triage` bucket — never derived from who filed it) and lights *Actionable* as "Triage needed" (a human's move) — so the Actionable column reads "Actionable", "Triage needed" or "Needs human decision", and the Open column is untouched. An issue carrying a hold-class label (`hold`, `do-not-merge*`, `hive-pause/`) is never parked: it sits at *Open* as "Open · on hold" even beside `needs-human`, and the reconciler removes any 045 the hold caught it with ([#13012](https://github.com/hivecommons/hive/issues/13012)). The lit chevron ends with an ink-coloured icon of whose move it is — person (human), robot (clanker) or hexagon (hive): the claim holder on Claimed, the PR author on PR in progress and Returned to contributor, hive on CI / Review, Adopted by hive and Ready for auto merge, a human on Needs human decision and Ready for human merge. A row at `090 Ready for human merge` always says *why* a person and not the hive merges it (#14658): the lit word ends `· workflow files`, `· tests removed`, `· manual-merge policy`, `· branch protection`, `· merge method`, `· auto-merge off`, `· untrusted author`, `· unauthorized`, `· reviewer deferred` or `· policy` (payload `human_merge_reason`, a `prstage.HumanMergeReason*` code derived from the stage record's lane reason — no second store), the chevron tooltip leads with the one-sentence `human_merge_reason_text` ("Changes .github/workflows/** — the hive never merges workflow changes …; click Merge on GitHub"), the manual-merge word reads `Awaiting human merge · workflow files · approved by @login`, the search / needs-attention headline carries the same tail, and a PR nested under its issue mirrors `human_approver`, `manual_merge`, `human_merge_reason` and `human_merge_reason_text` onto its `linked_prs` entry so the sub-row says the same. `040 Covered by PR` shares the *PR in progress* column with 030; `060 Reviewed`, `080 Awaiting merge admission` and `100 Merge queue` all light *Merge gate* as "Ready for auto merge" (the chevron tooltip says "not yet admitted — " for 060/080 and "admitted, merging" for 100); `095 Pre-merge soak` lights the same column as "Soaking" (hive's move; tooltip "admitted, soaking — Xm left", headline "Pre-merge soak — Xm left" from the payload's `soak_remaining_seconds`, aged from the lane's last sweep), so an admitted PR inside its soak window is no longer drawn as merging; the chevron's own tooltip names the exact stage. Covering pull requests nest under their issue. An issue with no PR yet draws the whole strip like any other row, lit at Open, Actionable or Claimed with the steps ahead faint. Once exactly one PR covers it, issue and PR are a single entry: the issue's `#N title` on the left, `↳ [author icon] #PR title` under the *PR in progress* header on the same title line (the ↳ marks a PR drawn on its issue's row; the PR link's tooltip says so — "linked PR, shown on its issue's row" — and, when two open issues list the same PR, every row but the lowest-numbered issue adds "also under #N"), and one continuous strip — Open, Actionable and Claimed passed, the PR's stage lighting the chevron from PR in progress through CI / Review, Merge gate and ✓; the chip, tooltip and `since` are the PR's. With two or more covering PRs the issue's own strip stops at Claimed — all passed, nothing on the issue line lit. Directly beneath, tighter than the gap between entries, sits one indented sub-row per open covering PR, furthest along first: `[author icon] #N title` at the *PR in progress* column, then that PR's own strip from there on — `PR in progress → CI / Review → Merge gate → ✓` — with its own lit chevron, chip, tooltip and `since`. So an issue with two PRs, one at 030, shows "PR in progress" lit on that sub-row, not on the issue. A PR linked to an open issue in the list has no top-level row of its own; a PR with no linked issue keeps a full-width row and shows the first steps as passed. A PR whose only linked issue is already closed — a superseded PR whose body still says `Fixes #N` after an earlier PR fixed it — keeps its own row with the closed issue in the issue slot: `#N title` as a link, muted and struck through, followed by a small `closed` chip, so the pairing reads at a glance; when the title cannot be resolved the slot says `#N (closed issue)` rather than a bare number (the title comes from the snapshot, or from one cached issue read the cycle makes once per issue — see [Linked issues](dashboard.md#pr-review-and-link-signals)). The *Pull requests* filter flattens the list — every PR as a top-level row; *Issues* and *All* show the nested view. Each row is named once on the left; a covering PR appears under the *PR in progress* header as `[author icon] #N title`. A pull request with no linked issue is named once: `[PR icon] [author icon] #N title` on the left over one continuous strip (first steps passed, its own step lit) and nothing in the *PR in progress* column, which is reserved for covering PRs — so a title never appears twice in a row. Pull requests are never issues here: when a number arrives through both the issues feed and the pulls feed the PR record wins and the issue copy is dropped on the server (pairing is keyed by repository, kind and number), and the *Issues* filter never lists a PR. The author icon is the one coloured legend: hive hexagon in blue, clanker robot in purple, human silhouette in teal (the `author/*` kind, inferred from the snapshot when the label is absent; the login is in the `#N` link's tooltip). The right-hand `since` column, in line with the chevron strip, is how long the item has been on its step (red when `stalled`). A plain *Open* step — no stage label yet and not on hold — also carries that age in its own words, "Open · since 3d" ("since 14h" under two days), taken from the same `stage_since` instant the column draws (falling back to the time the item was opened, which the chevron tooltip then marks "(opened)"); past `STAGE_TRACKER_OPEN_STALE_DAYS` (2) the chevron takes a subtle red tint. *Open · hold* never shows the age. An Open item carrying the `blocked` label is drawn the same way as a hold — "Open · blocked" with a ⛔ glyph in the hold's yellow — but keeps the age ("Open · blocked · since 7h"; a stale blocked item is exactly what should stand out, [#14194](https://github.com/hivecommons/hive/issues/14194)) and its chevron tooltip says why: "blocked on owner/repo#N" when the payload names the blocker (`blocked_on`), else "carries the blocked label"; when an item is both held and blocked, hold wins — it is a human instruction. At most one muted chip sits at the right end of the title line, directly over the strip's ✓ cap (on the last line when the title wraps; a hairline above each entry and a hover tint over the whole entry keep chip and `since` unambiguously with their own row — [#14640](https://github.com/hivecommons/hive/issues/14640)): the most important health modifier (`stalled`, `regressed`, `hold`, `needs-human`, `needs-decision` — shown as "needs human decision" —, `needs-triage` — shown as "triage needed" (amber) on an issue still carrying the `needs-triage` label before the claim (010, 017, 045; at 015 the lit chevron already says so); a `needs-triage` left on a claimed or later issue (020+) is stale, never shown as a chip or stage text, and reported instead as `stale_labels` in the payload with a muted *Stale label* line in the hover tooltip until the stage sweep removes it (hivecommons/hive#14586) —, `needs-rebase`, `blocked`, `draft`) with a `+N` for the rest. Everything else — the reason sentence, who must act, nudges sent, the repository, all flags and the last stage hops — is in the hover tooltip on the item's `#N` link (on a nested sub-row, on its `#N` PR link). Hover text in a row lives only on the `#N` link, the covering-PR link, the title and the lit chevron (its stage, and whose move it is); passed and upcoming chevrons, the kind and author icons, chips and the `since` column have none. Title lines wrap rather than push the strip out of alignment: the issue title stays before the *PR in progress* column (a clear gap always separates it from the PR entry, which starts at the column edge) and the PR title before the chip; hovering a title shows the full text. Rows are sorted furthest-along first by default — a covered issue ranks by its furthest-along PR — then, within a column, attention-first: rows a person must act on now (any shown pill — `stalled`, `unauthorized`, `needs rebase`, `needs human`, … — or a human-gated stage: 045, 071, 072, 085, 090) come first, plain rows next, and rows nobody should act on — `hold` (incl. `do-not-merge/*`), `draft`, and a PR standing in for a closed issue — sink to the bottom of the column; within a tier the longest on the step comes first, then repo and number. Pills the server holds back until the merge gate (`deferred_modifiers`) never promote a row. The same tiering orders the PR sub-rows under an issue, and the server pre-sorts `GET /api/stage-tracker` the same way (stage, tier, wait, repo, number) so chat `/prs` and the hub read the same order. *Sort* also offers longest waiting (tier first, then wait), newest and number (no tiering); the arrow beside it flips the column / age / repo / number keys but never the tier — attention stays on top in both directions, as its tooltip says ("Attention-first within each column; arrow flips age order"). Every open issue and pull request of the watched repositories is listed — actionable, held, claimed, in progress, covered by a PR, filtered by a `needs-*` label, reporter-triage, draft and exempt-labelled alike; an item without a stage label or journal entry sits at *Open*, and one in a scanner bucket with no label yet is placed from the bucket (claimed → 020, in progress → 030, covered → 040). Filters work on the cached payload in the browser and persist across reloads (the page number does not): kind chips, *Repo*, a search box (`#number` / number / title substring, also matching a covering PR), *Since* (any, over 1 hour / 1 day / 1 week on the current step, or past the stage's configured dwell — stalled items always qualify), *Author* kind, *Needs attention* (anything with a health modifier or on 071 / 072 / 085 / 090), and label chips built from every label present, each with its count: a **🙋 Needs human** facet first (attention-coloured; it matches any item carrying a label of the needs-human set — the server's `needs_human_labels`, the same list as the Projects *Needs human* preset: `stage/045-needs-decision`, `stage/085-needs-decision`, `needs-decision`, `needs-direction`, `needs-spec`, `needs-signal`, `needs-human` and `needs-human/*`, the hold labels, `stage/071-needs-author`, `sentinel-alert`, `needs-triage`; its count is the number of distinct items, not the sum of label counts), then every `stage/NNN-*` label in numerical order, then all other labels alphabetically (case-insensitive). When the row would overflow, the **+N more** button opens an in-app *All labels* dialog listing every label in the same order with counts, a type-to-filter box, the same toggles the chips use and a *Clear* button; a label selected there is promoted into the visible row. Chips of one family OR, families AND; *Needs human* ANDs with the label chips. *Clear filters* shows while anything is narrowed. The list is paged — 25 / 50 / 100 rows, default 50 — with Prev / Next and "showing X–Y of N (M filtered out)" above and below; the header count "N rows · M need attention" is for the filtered set, the **sidebar badge is the row count of the default view** (owner: the tracker counts rows, not items — a covering PR drawn on its issue's row is not a row of its own, and an issue with several PRs already has several), and both come from the same `stageTrackerCountsText()` call so they cannot disagree. When rows sit below the payload's open issues + PRs, the "showing" line's tooltip and the badge's footnote say why — "2 PRs shown on their issue's row" — rather than printing a second total.the chevron's own tooltip names the exact stage. Covering pull requests nest under their issue. An issue with no PR yet draws the whole strip like any other row, lit at Open, Actionable or Claimed with the steps ahead faint. Once exactly one PR covers it, issue and PR are a single entry: the issue's `#N title` on the left, `[author icon] #PR title` under the *PR in progress* header on the same title line, and one continuous strip — Open, Actionable and Claimed passed, the PR's stage lighting the chevron from PR in progress through CI / Review, Merge gate and ✓; the chip, tooltip and `since` are the PR's. With two or more covering PRs the issue's own strip stops at Claimed — all passed, nothing on the issue line lit. Directly beneath, tighter than the gap between entries, sits one indented sub-row per open covering PR, furthest along first: `[author icon] #N title` at the *PR in progress* column, then that PR's own strip from there on — `PR in progress → CI / Review → Merge gate → ✓` — with its own lit chevron, chip, tooltip and `since`. So an issue with two PRs, one at 030, shows "PR in progress" lit on that sub-row, not on the issue. A PR linked to an open issue in the list has no top-level row of its own; a PR with no linked issue keeps a full-width row and shows the first steps as passed. The *Pull requests* filter flattens the list — every PR as a top-level row; *Issues* and *All* show the nested view. Each row is named once on the left; a covering PR appears under the *PR in progress* header as `[author icon] #N title`. A pull request with no linked issue is named once: `[PR icon] [author icon] #N title` on the left over one continuous strip (first steps passed, its own step lit) and nothing in the *PR in progress* column, which is reserved for covering PRs — so a title never appears twice in a row. Pull requests are never issues here: when a number arrives through both the issues feed and the pulls feed the PR record wins and the issue copy is dropped on the server (pairing is keyed by repository, kind and number), and the *Issues* filter never lists a PR. The author icon is the one coloured legend: hive hexagon in blue, clanker robot in purple, human silhouette in teal (the `author/*` kind, inferred from the snapshot when the label is absent; the login is in the `#N` link's tooltip). The right-hand `since` column, in line with the chevron strip, is how long the item has been on its step (red when `stalled`). At most one muted chip sits at the right end of the title line, directly over the strip's ✓ cap (on the last line when the title wraps; a hairline above each entry and a hover tint over the whole entry keep chip and `since` unambiguously with their own row — [#14640](https://github.com/hivecommons/hive/issues/14640)): the most important health modifier (`stalled`, `regressed`, `hold`, `needs-human`, `needs-decision` — shown as "needs human decision" —, `needs-rebase`, `blocked`, `draft`) with a `+N` for the rest. A `regressed` chip is red only when the row is parked on a person (a human-gate modifier or stage 045 / 071 / 072 / 085 / 090); on a hive-driven stage with nothing waiting on a human it draws as a muted dashed `stage ↓` pill, yields the lead slot to any other modifier, keeps the row out of **Needs attention**, and its tooltip ends "the hive is handling it — no action needed; clears on the next forward step". The marker is set by a genuine backward hop (a lapsed claim 020 → 010, a 030 ↔ 020 flicker and a 040 → 010 after a partially-addressing merge are not regressions) and clears on the first forward hop; see "The regressed marker" in `labels-and-control-signals.md`. Everything else — the reason sentence, who must act, nudges sent, the repository, all flags and the last stage hops — is in the hover tooltip on the item's `#N` link (on a nested sub-row, on its `#N` PR link). Hover text in a row lives only on the `#N` link, the covering-PR link, the title and the lit chevron (its stage, and whose move it is); passed and upcoming chevrons, the kind and author icons, chips and the `since` column have none. Title lines wrap rather than push the strip out of alignment: the issue title stays before the *PR in progress* column (a clear gap always separates it from the PR entry, which starts at the column edge) and the PR title before the chip; hovering a title shows the full text. Rows are sorted furthest-along first by default — a covered issue ranks by its furthest-along PR — then, within a column, attention-first: rows a person must act on now (any shown pill — `stalled`, `unauthorized`, `needs rebase`, `needs human`, … — or a human-gated stage: 045, 071, 072, 085, 090) come first, plain rows next, and rows nobody should act on — `hold` (incl. `do-not-merge/*`), `draft`, and a PR standing in for a closed issue — sink to the bottom of the column; within a tier the longest on the step comes first, then repo and number. Pills the server holds back until the merge gate (`deferred_modifiers`) never promote a row. The same tiering orders the PR sub-rows under an issue, and the server pre-sorts `GET /api/stage-tracker` the same way (stage, tier, wait, repo, number) so chat `/prs` and the hub read the same order. *Sort* also offers longest waiting (tier first, then wait), newest and number (no tiering); the arrow beside it flips the column / age / repo / number keys but never the tier — attention stays on top in both directions, as its tooltip says ("Attention-first within each column; arrow flips age order"). Every open issue and pull request of the watched repositories is listed — actionable, held, claimed, in progress, covered by a PR, filtered by a `needs-*` label, reporter-triage, draft and exempt-labelled alike; an item without a stage label or journal entry sits at *Open*, and one in a scanner bucket with no label yet is placed from the bucket (claimed → 020, in progress → 030, covered → 040). Filters work on the cached payload in the browser and persist across reloads (the page number does not): kind chips, *Repo*, a search box (`#number` / number / title substring, also matching a covering PR), *Since* (any, over 1 hour / 1 day / 1 week on the current step, or past the stage's configured dwell — stalled items always qualify), *Author* kind, *Needs attention* (anything with a health modifier or on 071 / 072 / 085 / 090), and label chips built from every label present, each with its count: a **🙋 Needs human** facet first (attention-coloured; it matches any item carrying a label of the needs-human set — the server's `needs_human_labels`, the same list as the Projects *Needs human* preset: `stage/045-needs-decision`, `stage/085-needs-decision`, `needs-decision`, `needs-direction`, `needs-spec`, `needs-signal`, `needs-human` and `needs-human/*`, the hold labels, `stage/071-needs-author`, `sentinel-alert`, `needs-triage`; its count is the number of distinct items, not the sum of label counts), then every `stage/NNN-*` label in numerical order, then all other labels alphabetically (case-insensitive). When the row would overflow, the **+N more** button opens an in-app *All labels* dialog listing every label in the same order with counts, a type-to-filter box, the same toggles the chips use and a *Clear* button; a label selected there is promoted into the visible row. Chips of one family OR, families AND; *Needs human* ANDs with the label chips. *Clear filters* shows while anything is narrowed. The list is paged — 25 / 50 / 100 rows, default 50 — with Prev / Next and "showing X–Y of N (M filtered out)" above and below; the header reads "N items (I issues / P PRs) · M need attention" — N, I and P are the whole list, the same `openItems` set the Overview tile and its left-menu counter print, so N always equals the tile's **Total open issues + Total open PRs**; a "· X match filters" note follows while a filter is on. The sidebar counter beside **Hive activity monitor** is that same N — total open items, written in the same render pass as the header, so the two cannot drift apart; how many need attention is the warn-coloured header suffix and the counter's hover tooltip (counted over every item, filters or not). When covering pull requests are nested under their issue the "showing X–Y of R" line counts rows and adds "(P nested under their issues)" so R never reads as a different total. The small monospace strip beside the count — `engine enforce · N anomalies` — is the central stage engine ([ADR-0025](adr/0025-central-stage-engine.md)): `engine` names the current `governor.labels.stage.engine.mode` (green `enforce`, neutral `shadow` = paused, nothing written; hover for what the mode does and the derivation count), `anomalies` counts stage moves the engine's admission table did not expect (red when non-zero). The same numbers are `/api/status.stageEngine`; the mode is changed under **Settings → Labels → Central stage engine mode** and the operator notes are in [operator-reference.md](operator-reference.md#central-stage-engine-rollout). "updated Ns ago · cache" says how old the server-built payload is: the spoke rebuilds it at most every `dashboard.stage_tracker.cache_ttl_s` (default `governor.eval_interval_s`) from its existing snapshot and serves it with an `ETag`, so the browser's 30-second poll is a 304 and no request ever reaches GitHub (`/api/gh-rate-limits` lists the caller `dashboard:stage-tracker` with nothing charged). See [Stage labels](labels-and-control-signals.md#stage-labels-stagennn--the-pipeline-state-machine). **Repo chip.** Each row carries a small monospace chip before the number naming the repository it belongs to (`dibs #456`, `hive #13524`); the chip is tinted per repository from a fixed palette so one repo always looks the same, the configured primary repo is shown muted, and the full `owner/repo` is in the tooltip. Linked PR sub-rows carry the same chip. Clicking a chip sets the **Repo** filter to that repository (click it again, or pick "All repos", to clear). By default the chip appears only when the list spans more than one repository; the ⚙ settings modal's **Repositories** section offers **Show repo chip: always / only when multiple repos / never** (stored under `hive.tracker.repochip`). diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index af9a1ab6fc..2d5483ad0b 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -1373,12 +1373,85 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto } resp.OpenIssues, resp.OpenPRs = stageTrackerOpenCounts(resp.Items) stageTrackerResolveLinkedPRs(resp.Items) - sort.SliceStable(resp.Items, func(i, j int) bool { - a, b := resp.Items[i], resp.Items[j] + sort.SliceStable(resp.Items, stageTrackerLess(resp.Items)) + return resp +} + +// Ordering tiers within a stage (stageTrackerAttentionTier; the dashboard's +// STAGE_TRACKER_TIER_* carry the same values). +const ( + stageTrackerTierAttention = 0 + stageTrackerTierNormal = 1 + stageTrackerTierSunk = 2 +) + +// stageTrackerAttentionStages are the stages that park an item on a person +// (dashboard STAGE_TRACKER_ATTENTION_STAGES): issue needs-decision, PR +// needs-author / returned-to-contributor, PR needs-decision and +// ready-for-human-merge. +var stageTrackerAttentionStages = []int{stagelabels.IssueNeedsDecision.Number(), stagelabels.NeedsAuthor.Number(), stagelabels.ReturnedToContributor.Number(), stagelabels.NeedsDecision.Number(), stagelabels.ReadyForHumanMerge.Number()} + +// stageTrackerHumanMods are the modifiers that park an item on a person +// (dashboard STAGE_TRACKER_HUMAN_MODS). +var stageTrackerHumanMods = []string{modHold, modUnauthorized, modNeedsHuman, modNeedsDecision, modNeedsRebase, modBlocked, modStalled} + +// stageTrackerSunkMods are the modifiers that sink a row to the bottom of +// its stage (dashboard STAGE_TRACKER_SUNK_MODS): a person parked it, or it +// is a draft nobody should act on yet. +var stageTrackerSunkMods = []string{modHold, modDraft} + +// stageTrackerRegressionHandled mirrors the dashboard's +// stageTrackerRegressionHandled: a regressed item with no human-gate +// modifier on a hive-driven stage is the hive's to work through. +func stageTrackerRegressionHandled(it StageTrackerItem) bool { + if !slices.Contains(it.Modifiers, modRegressed) { + return false + } + if slices.ContainsFunc(it.Modifiers, func(m string) bool { return slices.Contains(stageTrackerHumanMods, m) }) { + return false + } + return !slices.Contains(stageTrackerAttentionStages, it.Stage) +} + +// stageTrackerNeedsAttention mirrors the dashboard's +// stageTrackerNeedsAttention: the item shows a pill or sits on a stage +// parked on a person. Only the shown Modifiers count, so a merge-gate pill +// held back until the gate never promotes a row. +func stageTrackerNeedsAttention(it StageTrackerItem) bool { + if stageTrackerRegressionHandled(it) { + return false + } + return len(it.Modifiers) > 0 || slices.Contains(stageTrackerAttentionStages, it.Stage) +} + +// stageTrackerAttentionTier is the item's ordering tier within its stage +// (the dashboard's stageTrackerAttentionTier agrees): rows parked on a +// person first, then the rest, then rows nobody should act on — hold +// (incl. do-not-merge/*) and draft. The direction toggle never flips it. +func stageTrackerAttentionTier(it StageTrackerItem) int { + if slices.ContainsFunc(it.Modifiers, func(m string) bool { return slices.Contains(stageTrackerSunkMods, m) }) { + return stageTrackerTierSunk + } + if stageTrackerNeedsAttention(it) { + return stageTrackerTierAttention + } + return stageTrackerTierNormal +} + +// stageTrackerLess orders the payload: stage descending, then +// attention-first within the stage (stageTrackerAttentionTier), then the +// item that has waited longest, then repo and number — the dashboard's +// default view, so chat and hub consumers read the same order. +func stageTrackerLess(items []StageTrackerItem) func(i, j int) bool { + return func(i, j int) bool { + a, b := items[i], items[j] if a.Stage != b.Stage { return a.Stage > b.Stage } - // Within a stage the item that has waited longest comes first: it is + if ta, tb := stageTrackerAttentionTier(a), stageTrackerAttentionTier(b); ta != tb { + return ta < tb + } + // Within a tier the item that has waited longest comes first: it is // the one most likely to need a human. at, bt := trackerSince(a), trackerSince(b) if at.IsZero() != bt.IsZero() { @@ -1391,8 +1464,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto return a.Repo < b.Repo } return a.Number < b.Number - }) - return resp + } } func trackerSince(it StageTrackerItem) time.Time { diff --git a/src/pkg/dashboard/stage_tracker_attention_order_test.go b/src/pkg/dashboard/stage_tracker_attention_order_test.go new file mode 100644 index 0000000000..9de02cda8e --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_attention_order_test.go @@ -0,0 +1,183 @@ +package dashboard + +import ( + "os/exec" + "slices" + "sort" + "strings" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/stagelabels" +) + +// stageTrackerTierJS is the dashboard's attention-tier helper and the +// constants it reads, for node fixtures that sort rows or sub-rows. The +// caller supplies stageTrackerNeedsAttention and what it needs. +func stageTrackerTierJS(t *testing.T, html string) string { + t.Helper() + return strings.Join([]string{ + jsConstLine(t, html, "STAGE_TRACKER_TIER_ATTENTION"), + jsConstLine(t, html, "STAGE_TRACKER_TIER_NORMAL"), + jsConstLine(t, html, "STAGE_TRACKER_TIER_SUNK"), + jsConstLine(t, html, "STAGE_TRACKER_SUNK_MODS"), + jsFunc(t, html, "stageTrackerAttentionTier"), + }, "\n") +} + +// stageTrackerAttentionTier puts the rows a person must act on first and +// the rows nobody should act on last, and the payload pre-sort applies +// it within a stage ahead of the wait, repo and number keys. +func TestStageTrackerAttentionTier(t *testing.T) { + cases := []struct { + name string + item StageTrackerItem + want int + }{ + {"plain row on a hive stage", StageTrackerItem{Stage: stagelabels.ReviewPending.Number(), Modifiers: []string{}}, stageTrackerTierNormal}, + {"needs-decision stage", StageTrackerItem{Stage: stagelabels.NeedsDecision.Number()}, stageTrackerTierAttention}, + {"ready-for-human-merge stage", StageTrackerItem{Stage: stagelabels.ReadyForHumanMerge.Number()}, stageTrackerTierAttention}, + {"needs-author stage", StageTrackerItem{Stage: stagelabels.NeedsAuthor.Number(), AuthorKind: authorKindHuman}, stageTrackerTierAttention}, + {"returned-to-contributor stage", StageTrackerItem{Stage: stagelabels.ReturnedToContributor.Number()}, stageTrackerTierAttention}, + {"stalled pill", StageTrackerItem{Stage: stagelabels.ReviewPending.Number(), Modifiers: []string{modStalled}}, stageTrackerTierAttention}, + {"unauthorized pill", StageTrackerItem{Stage: stagelabels.AwaitingMergeAdmission.Number(), Modifiers: []string{modUnauthorized}}, stageTrackerTierAttention}, + {"needs-rebase pill", StageTrackerItem{Stage: stagelabels.ReviewPending.Number(), Modifiers: []string{modNeedsRebase}, AuthorKind: authorKindHuman}, stageTrackerTierAttention}, + {"regressed on a hive stage is handled, not attention", StageTrackerItem{Stage: stagelabels.ReviewPending.Number(), Modifiers: []string{modRegressed}}, stageTrackerTierNormal}, + {"regressed onto a human stage", StageTrackerItem{Stage: stagelabels.NeedsDecision.Number(), Modifiers: []string{modRegressed}}, stageTrackerTierAttention}, + {"hold sinks", StageTrackerItem{Stage: stagelabels.ReviewPending.Number(), Modifiers: []string{modHold}}, stageTrackerTierSunk}, + {"hold sinks even on a human stage", StageTrackerItem{Stage: stagelabels.NeedsDecision.Number(), Modifiers: []string{modHold, modNeedsDecision}}, stageTrackerTierSunk}, + {"draft sinks", StageTrackerItem{Stage: 0, Modifiers: []string{modDraft}}, stageTrackerTierSunk}, + {"hold beats stalled", StageTrackerItem{Stage: stagelabels.Fixing.Number(), Modifiers: []string{modStalled, modHold}}, stageTrackerTierSunk}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + if got := stageTrackerAttentionTier(tc.item); got != tc.want { + t.Fatalf("tier = %d, want %d", got, tc.want) + } + }) + } + + // The pre-sort: stage desc, then tier, then longest wait, repo, number. + base := time.Date(2026, 1, 1, 12, 0, 0, 0, time.UTC) + since := func(d time.Duration) *time.Time { ts := base.Add(-d); return &ts } + items := []StageTrackerItem{ + {Repo: "a/b", Number: 1, Stage: 50, StageSince: since(9 * 24 * time.Hour), Modifiers: []string{}}, // oldest plain + {Repo: "a/b", Number: 2, Stage: 50, StageSince: since(time.Hour), Modifiers: []string{modStalled}}, // attention, young + {Repo: "a/b", Number: 3, Stage: 50, StageSince: since(30 * 24 * time.Hour), Modifiers: []string{modHold}}, // sunk, oldest of all + {Repo: "a/b", Number: 4, Stage: 50, StageSince: since(2 * time.Hour), Modifiers: []string{}}, // plain, young + {Repo: "a/b", Number: 5, Stage: 50, StageSince: since(3 * time.Hour), Modifiers: []string{modDraft}}, // sunk + {Repo: "a/b", Number: 6, Stage: 50, StageSince: since(4 * time.Hour), Modifiers: []string{modUnauthorized}}, // attention, older than #2 + {Repo: "a/b", Number: 7, Stage: 80, StageSince: since(time.Minute), Modifiers: []string{}}, // further stage wins over tier + {Repo: "a/b", Number: 8, Stage: 50, StageSince: since(10 * 24 * time.Hour), Modifiers: []string{modRegressed}}, // handled regression = plain, oldest plain + {Repo: "a/b", Number: 9, Stage: 50, StageSince: since(10 * 24 * time.Hour), Modifiers: []string{modNeedsDecision}}, // deferred-shaped pill shown → attention + } + sort.SliceStable(items, stageTrackerLess(items)) + got := make([]int, 0, len(items)) + for _, it := range items { + got = append(got, it.Number) + } + want := []int{7, 9, 6, 2, 8, 1, 4, 3, 5} + if !slices.Equal(got, want) { + t.Fatalf("order = %v, want %v", got, want) + } +} + +// TestStageTrackerAttentionOrderJS drives the dashboard's sort and sub-row +// order under node: attention-first within a column for the furthest and +// waiting sorts, hold / draft / closed-issue rows last, the direction +// toggle flipping only the age keys, newest and number sorts untouched. +func TestStageTrackerAttentionOrderJS(t *testing.T) { + node, err := exec.LookPath("node") + if err != nil { + t.Skip("node not on PATH — tracker attention order was NOT executed by this run") + } + html := indexHTML(t) + script := strings.Join([]string{ + "const window = {};", + jsConstLine(t, html, "STAGE_TRACKER_PAGE_SIZES"), + jsConstLine(t, html, "STAGE_TRACKER_DEFAULT_PAGE_SIZE"), + jsConstLine(t, html, "STAGE_TRACKER_AGE_MS"), + jsConstLine(t, html, "STAGE_TRACKER_ATTENTION_STAGES"), + jsConstLine(t, html, "STAGE_TRACKER_SORTS"), + jsConstLine(t, html, "STAGE_TRACKER_TERMINAL"), + jsConstLine(t, html, "STAGE_TRACKER_PATH"), + jsConstLine(t, html, "STAGE_TRACKER_PR_COLUMN"), + jsConstLine(t, html, "STAGE_TRACKER_MERGE_COLUMN"), + jsConstLine(t, html, "STAGE_TRACKER_NEEDS_DECISION"), + jsConstLine(t, html, "STAGE_TRACKER_ISSUE_NEEDS_DECISION"), + jsConstLine(t, html, "STAGE_TRACKER_ISSUE_DECISION_COLUMN"), + jsConstLine(t, html, "STAGE_TRACKER_TRIAGE_NEEDED"), + jsConstLine(t, html, "STAGE_TRACKER_POSSIBLY_EXISTS"), + jsConstLine(t, html, "STAGE_TRACKER_PRE_MERGE_SOAK"), + jsConstLine(t, html, "STAGE_TRACKER_HUMAN_MODS"), + stageTrackerTierJS(t, html), + jsFunc(t, html, "stageTrackerDefaultFilter"), + "var _stageTrackerFilter = stageTrackerDefaultFilter();", + jsFunc(t, html, "stageTrackerAnchor"), + jsFunc(t, html, "stageTrackerLinkedSorted"), + jsFunc(t, html, "stageTrackerSortKey"), + jsFunc(t, html, "stageTrackerRegressionHandled"), + jsFunc(t, html, "stageTrackerNeedsAttention"), + jsFunc(t, html, "stageTrackerWaitSince"), + jsFunc(t, html, "stageTrackerNormalizeFilter"), + jsFunc(t, html, "stageTrackerSort"), + }, "\n") + ` +const assert = require('assert'); +const now = Date.parse('2026-01-01T12:00:00Z'); +const H = 3600000, D = 24 * H; +const ago = (ms) => new Date(now - ms).toISOString(); +const stages = [{ number: 50, label: 'Review pending' }, { number: 80, label: 'Merge gate' }, { number: 85, label: 'Needs decision' }, { number: 110, label: 'Merged' }]; +const row = (number, over) => Object.assign({ kind: 'pr', repo: 'a/b', number, stage: 50, modifiers: [], created_at: ago(number * D) }, over); +const items = [ + row(1, { stage_since: ago(9 * D) }), // plain, oldest plain + row(2, { stage_since: ago(H), modifiers: ['stalled'] }), // attention, young + row(3, { stage_since: ago(30 * D), modifiers: ['hold'] }), // sunk, oldest of all + row(4, { stage_since: ago(2 * H) }), // plain, young + row(5, { stage_since: ago(3 * H), modifiers: ['draft'] }), // sunk + row(6, { stage_since: ago(4 * H), modifiers: ['unauthorized'] }), // attention, older than #2 + row(7, { stage: 80, stage_since: ago(60000) }), // further column wins over tier + row(8, { stage_since: ago(10 * D), modifiers: ['regressed'] }), // handled regression = plain + row(9, { stage_since: ago(5 * H), closed_issue: { number: 42, state: 'closed' } }), // closed-issue-anchored PR sinks + row(10, { stage_since: ago(20 * D), deferred_modifiers: ['needs-human'] }), // deferred pill never promotes +]; +const nums = (rows) => rows.map(it => it.number); +const F = (over) => Object.assign(stageTrackerDefaultFilter(), over); + +assert.strictEqual(stageTrackerAttentionTier(items[1]), STAGE_TRACKER_TIER_ATTENTION); +assert.strictEqual(stageTrackerAttentionTier(items[0]), STAGE_TRACKER_TIER_NORMAL); +assert.strictEqual(stageTrackerAttentionTier(items[2]), STAGE_TRACKER_TIER_SUNK, 'hold sinks'); +assert.strictEqual(stageTrackerAttentionTier(items[4]), STAGE_TRACKER_TIER_SUNK, 'draft sinks'); +assert.strictEqual(stageTrackerAttentionTier(items[8]), STAGE_TRACKER_TIER_SUNK, 'closed-issue anchor sinks'); +assert.strictEqual(stageTrackerAttentionTier(items[7]), STAGE_TRACKER_TIER_NORMAL, 'a handled regression is not attention'); +assert.strictEqual(stageTrackerAttentionTier(items[9]), STAGE_TRACKER_TIER_NORMAL, 'deferred pills do not promote'); +assert.strictEqual(stageTrackerAttentionTier({ stage: 85, modifiers: [] }), STAGE_TRACKER_TIER_ATTENTION, 'a human-gated stage is attention without a pill'); +assert.strictEqual(stageTrackerAttentionTier({ stage: 85, modifiers: ['hold'] }), STAGE_TRACKER_TIER_SUNK, 'hold sinks even on a human-gated stage'); + +// Furthest: column first, then tier, then oldest on step. +assert.deepStrictEqual(nums(stageTrackerSort(items, stages, F({ sort: 'furthest' }))), [7, 6, 2, 10, 8, 1, 4, 3, 9, 5]); +// Ascending flips the column and age keys but keeps attention on top and sunk rows at the bottom of each column. +assert.deepStrictEqual(nums(stageTrackerSort(items, stages, F({ sort: 'furthest', dir: 'asc' }))), [2, 6, 4, 1, 8, 10, 5, 9, 3, 7]); +// Waiting: tier first, then longest wait. +assert.deepStrictEqual(nums(stageTrackerSort(items, stages, F({ sort: 'waiting' }))), [6, 2, 10, 8, 1, 4, 7, 3, 9, 5]); +assert.deepStrictEqual(nums(stageTrackerSort(items, stages, F({ sort: 'waiting', dir: 'asc' }))), [2, 6, 7, 4, 1, 8, 10, 5, 9, 3]); +// Newest and number ignore the tier. +assert.deepStrictEqual(nums(stageTrackerSort(items, stages, F({ sort: 'newest' }))), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); +assert.deepStrictEqual(nums(stageTrackerSort(items, stages, F({ sort: 'number' }))), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); +assert.deepStrictEqual(nums(stageTrackerSort(items, stages, F({ sort: 'number', dir: 'asc' }))), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); +assert.deepStrictEqual(nums(items), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 'sorting does not mutate the payload'); + +// Sub-rows under an issue tier the same way within a stage. +const issue = { kind: 'issue', repo: 'a/b', number: 99, stage: 50, linked_prs: [ + { number: 201, stage: 50, stage_since: ago(5 * D), modifiers: ['hold'] }, + { number: 202, stage: 50, stage_since: ago(2 * H), modifiers: ['stalled'] }, + { number: 203, stage: 50, stage_since: ago(4 * D), modifiers: [] }, + { number: 204, stage: 80, stage_since: ago(H), modifiers: ['draft'] }, +] }; +assert.deepStrictEqual(nums(stageTrackerLinkedSorted(issue, stages)), [204, 202, 203, 201], 'furthest stage first; within a stage attention, plain, then hold'); +console.log('ok'); +` + cmd := exec.Command(node, "-e", script) + if out, err := cmd.CombinedOutput(); err != nil || !strings.Contains(string(out), "ok") { + t.Fatalf("node tracker attention order fixture failed: %v\n%s", err, out) + } +} diff --git a/src/pkg/dashboard/stage_tracker_motion_test.go b/src/pkg/dashboard/stage_tracker_motion_test.go index 9fccbdeff5..8f8b5a0a31 100644 --- a/src/pkg/dashboard/stage_tracker_motion_test.go +++ b/src/pkg/dashboard/stage_tracker_motion_test.go @@ -271,6 +271,11 @@ func TestStageTrackerMotionDetector(t *testing.T) { jsFunc(t, html, "stageTrackerItemKey"), jsFunc(t, html, "stageTrackerPRKey"), jsFunc(t, html, "stageTrackerLinkedSorted"), + jsConstLine(t, html, "STAGE_TRACKER_ATTENTION_STAGES"), + jsConstLine(t, html, "STAGE_TRACKER_HUMAN_MODS"), + jsFunc(t, html, "stageTrackerRegressionHandled"), + jsFunc(t, html, "stageTrackerNeedsAttention"), + stageTrackerTierJS(t, html), jsFunc(t, html, "stageTrackerColIndex"), jsFunc(t, html, "stageTrackerColMap"), jsFunc(t, html, "stageTrackerColMoves"), @@ -437,6 +442,8 @@ func TestStageTrackerMotionRowStamp(t *testing.T) { jsFunc(t, html, "stageTrackerLinkedTip"), jsConstLine(t, html, "STAGE_TRACKER_LINKED_GLYPH"), jsFunc(t, html, "stageTrackerLinkedSorted"), + jsFunc(t, html, "stageTrackerNeedsAttention"), + stageTrackerTierJS(t, html), jsFunc(t, html, "stageTrackerItemKey"), jsFunc(t, html, "stageTrackerColIndex"), jsFunc(t, html, "stageTrackerColMap"), @@ -547,6 +554,8 @@ func TestStageTrackerMotionPreviewSample(t *testing.T) { jsFunc(t, html, "stageTrackerLinkedTip"), jsConstLine(t, html, "STAGE_TRACKER_LINKED_GLYPH"), jsFunc(t, html, "stageTrackerLinkedSorted"), + jsFunc(t, html, "stageTrackerNeedsAttention"), + stageTrackerTierJS(t, html), jsFunc(t, html, "stageTrackerSortKey"), jsFunc(t, html, "stageTrackerHeadline"), jsFunc(t, html, "stageTrackerAnchor"), diff --git a/src/pkg/dashboard/stage_tracker_repo_grouping_test.go b/src/pkg/dashboard/stage_tracker_repo_grouping_test.go index 229c872c1b..4ffea34dd0 100644 --- a/src/pkg/dashboard/stage_tracker_repo_grouping_test.go +++ b/src/pkg/dashboard/stage_tracker_repo_grouping_test.go @@ -157,6 +157,7 @@ func stageTrackerRepoGroupingHarness(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerLinkedTip"), jsConstLine(t, html, "STAGE_TRACKER_LINKED_GLYPH"), jsFunc(t, html, "stageTrackerLinkedSorted"), + stageTrackerTierJS(t, html), jsFunc(t, html, "stageTrackerSortKey"), jsFunc(t, html, "esc"), jsFunc(t, html, "agentNowAgo"), diff --git a/src/pkg/dashboard/stage_tracker_ui_test.go b/src/pkg/dashboard/stage_tracker_ui_test.go index d901df4d5a..559d9a12f7 100644 --- a/src/pkg/dashboard/stage_tracker_ui_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_test.go @@ -165,6 +165,7 @@ func TestStageTrackerRows(t *testing.T) { jsFunc(t, html, "stageTrackerLinkedTip"), jsConstLine(t, html, "STAGE_TRACKER_LINKED_GLYPH"), jsFunc(t, html, "stageTrackerLinkedSorted"), + stageTrackerTierJS(t, html), jsFunc(t, html, "stageTrackerSortKey"), jsFunc(t, html, "esc"), jsFunc(t, html, "agentNowAgo"), @@ -736,6 +737,7 @@ func TestStageTrackerFilterSortPage(t *testing.T) { "var _stageTrackerFilter = stageTrackerDefaultFilter();", jsFunc(t, html, "stageTrackerAnchor"), jsFunc(t, html, "stageTrackerLinkedSorted"), + stageTrackerTierJS(t, html), jsFunc(t, html, "stageTrackerSortKey"), jsConstLine(t, html, "STAGE_TRACKER_HUMAN_MODS"), jsConstLine(t, html, "STAGE_TRACKER_HANDLED_TEXT"), @@ -842,7 +844,8 @@ assert.deepStrictEqual(stageTrackerNormalizeFilter({ labels: ['Author/Human'] }) // Sorting: furthest along first (then longest on step); waiting; newest; number; direction flips. assert.deepStrictEqual(nums(stageTrackerSort(items, stages, F({ sort: 'furthest' }))), [4, 3, 2, 5, 1]); assert.deepStrictEqual(nums(stageTrackerSort(items, stages, F({ sort: 'furthest', dir: 'asc' }))), [1, 5, 2, 3, 4]); -assert.deepStrictEqual(nums(stageTrackerSort(items, stages, F({ sort: 'waiting' }))), [4, 1, 5, 2, 3], 'longest wait first; an unstaged item waits since it was opened'); +assert.deepStrictEqual(nums(stageTrackerSort(items, stages, F({ sort: 'waiting' }))), [5, 3, 4, 1, 2], 'attention rows (stalled #5, needs-rebase #3) first, then longest wait; an unstaged item waits since it was opened'); +assert.deepStrictEqual(nums(stageTrackerSort(items, stages, F({ sort: 'waiting', dir: 'asc' }))), [3, 5, 2, 1, 4], 'ascending flips the wait order but keeps attention on top'); assert.deepStrictEqual(nums(stageTrackerSort(items, stages, F({ sort: 'newest' }))), [3, 5, 1, 2, 4], 'newest first; equal ages fall back to the higher number'); assert.deepStrictEqual(nums(stageTrackerSort(items, stages, F({ sort: 'number' }))), [5, 4, 3, 2, 1], 'number sort descends by repo then number'); assert.deepStrictEqual(nums(stageTrackerSort(items, stages, F({ sort: 'number', dir: 'asc' }))), [1, 2, 3, 4, 5]); diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 3e87d39a4c..d4dd07baac 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -7055,7 +7055,7 @@

Hive activity moni - + @@ -13870,6 +13870,14 @@

Where to get help

// labels follow when at least two items carry them. const STAGE_TRACKER_LABEL_FAMILIES = ['stage/', 'needs-', 'author/', 'role/', 'hold', 'on-hold', 'do-not-merge', 'hive-pause/']; const STAGE_TRACKER_SORTS = ['furthest', 'waiting', 'newest', 'number']; + // Attention tiers within a column (stageTrackerAttentionTier; same + // values as Go): the pills that sink a row, and the direction button's + // note that the arrow never flips the tier. + const STAGE_TRACKER_TIER_ATTENTION = 0; + const STAGE_TRACKER_TIER_NORMAL = 1; + const STAGE_TRACKER_TIER_SUNK = 2; + const STAGE_TRACKER_SUNK_MODS = ['hold', 'draft']; + const STAGE_TRACKER_DIR_TIER_NOTE = ' · Attention-first within each column; arrow flips age order'; // Repo chip + group-by-repo. The chip before an item's number names its // repo (short name; owner/repo in the tooltip; click = the Repo filter) // and is shown always / only when the payload spans several repos @@ -14351,11 +14359,12 @@

Where to get help

`; } - // Covering PRs of an issue, furthest along first. + // Covering PRs of an issue, furthest along first, attention-first + // within a stage (stageTrackerAttentionTier), then longest on step. function stageTrackerLinkedSorted(item, stages) { const linked = Array.isArray(item.linked_prs) ? item.linked_prs.slice() : (item.linked_pr ? [{ number: item.linked_pr }] : []); const sinceOf = lp => Date.parse(lp.stage_since || '') || Infinity; - return linked.sort((x, y) => (stageTrackerAnchor(y.stage, stages, 'pr') - stageTrackerAnchor(x.stage, stages, 'pr')) || (sinceOf(x) - sinceOf(y)) || ((x.number || 0) - (y.number || 0))); + return linked.sort((x, y) => (stageTrackerAnchor(y.stage, stages, 'pr') - stageTrackerAnchor(x.stage, stages, 'pr')) || (stageTrackerAttentionTier(x) - stageTrackerAttentionTier(y)) || (sinceOf(x) - sinceOf(y)) || ((x.number || 0) - (y.number || 0))); } // List order: furthest along the strip first — a covered issue counts as @@ -14989,6 +14998,18 @@

Where to get help

return mods.length > 0 || STAGE_TRACKER_ATTENTION_STAGES.indexOf(n) >= 0; } + // Ordering tier of a row within its column (mirrors Go + // stageTrackerAttentionTier): rows parked on a person first, then the + // rest, then rows nobody should act on — hold (incl. do-not-merge/*), + // draft, and a PR standing in for a closed issue. Only the pills a row + // shows count (deferred_modifiers never promote it); the direction + // toggle leaves the tier order alone. + function stageTrackerAttentionTier(row) { + const mods = Array.isArray(row.modifiers) ? row.modifiers : []; + if (STAGE_TRACKER_SUNK_MODS.some(m => mods.indexOf(m) >= 0) || (row.closed_issue && Number(row.closed_issue.number) > 0)) return STAGE_TRACKER_TIER_SUNK; + return stageTrackerNeedsAttention(row) ? STAGE_TRACKER_TIER_ATTENTION : STAGE_TRACKER_TIER_NORMAL; + } + // The instant an item's current wait began: when it entered its step, // else when it was opened (an item with no step yet is waiting since then). function stageTrackerWaitSince(item) { @@ -15114,22 +15135,26 @@

Where to get help

// Order rows. 'furthest' is the strip order (furthest along first, then // longest on step); 'waiting' is longest wait first; 'newest' is most - // recently opened first; 'number' is repo then number. dir 'asc' reverses. + // recently opened first; 'number' is repo then number. Under 'furthest' + // and 'waiting' rows tier attention-first within a column + // (stageTrackerAttentionTier); dir 'asc' reverses the strip / age / + // repo / number keys but never the tier. function stageTrackerSort(rows, stages, f) { f = stageTrackerNormalizeFilter(f); const byRepoNumber = (x, y) => ((x.repo || '').localeCompare(y.repo || '')) || ((x.number || 0) - (y.number || 0)); + const sign = f.dir === 'asc' ? -1 : 1; + const byTier = (x, y) => stageTrackerAttentionTier(x) - stageTrackerAttentionTier(y); let cmp; switch (f.sort) { - case 'waiting': cmp = (x, y) => ((stageTrackerWaitSince(x) || Infinity) - (stageTrackerWaitSince(y) || Infinity)) || byRepoNumber(x, y); break; - case 'newest': cmp = (x, y) => ((Date.parse(y.created_at || '') || 0) - (Date.parse(x.created_at || '') || 0)) || byRepoNumber(y, x); break; - case 'number': cmp = (x, y) => byRepoNumber(y, x); break; + case 'waiting': cmp = (x, y) => byTier(x, y) || sign * (((stageTrackerWaitSince(x) || Infinity) - (stageTrackerWaitSince(y) || Infinity)) || byRepoNumber(x, y)); break; + case 'newest': cmp = (x, y) => sign * (((Date.parse(y.created_at || '') || 0) - (Date.parse(x.created_at || '') || 0)) || byRepoNumber(y, x)); break; + case 'number': cmp = (x, y) => sign * byRepoNumber(y, x); break; default: { const keyOf = it => stageTrackerSortKey(it, stages); - cmp = (x, y) => { const a = keyOf(x), b = keyOf(y); return (b.anchor - a.anchor) || (a.since - b.since) || byRepoNumber(x, y); }; + cmp = (x, y) => { const a = keyOf(x), b = keyOf(y); return sign * (b.anchor - a.anchor) || byTier(x, y) || sign * ((a.since - b.since) || byRepoNumber(x, y)); }; } } - const out = (rows || []).slice().sort(cmp); - return f.dir === 'asc' ? out.reverse() : out; + return (rows || []).slice().sort(cmp); } // One page of rows plus the numbers the "showing X–Y of N" line needs. @@ -15323,7 +15348,7 @@

Where to get help

const att = document.getElementById('activity-monitor-attention'); if (att) att.setAttribute('aria-pressed', f.attention ? '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'); } + 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); }