Repository navigation
π Activity Monitor: persist the merged count in a server ledger, pin the Merged chip, banner and bee flight on merge - #15150
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
d877863 to
e5c59ae
Compare
There was a problem hiding this comment.
Reviewed (correctness) β no blocking findings; two low advisories.
-
Low β chip can bump before the flight when the server counts a merge one poll ahead of the row leaving.
stageTrackerMergedHoldbackonly subtracts a pending key that is both in_stageTrackerCelebratePendingand inserver.recent(index.html,stageTrackerMergedHoldback). When the hive's own merge lands in the ledger via the audit hook (merged_ledger_server.gorecordMergedAudit) but the row is only dropped by a later poller cycle, poll N already showsall_time+1with no pending key, sostageTrackerMergedCountDrawraises_stageTrackerMergedShownsilently; on poll N+1 the key becomes fresh/pending, the computed count dips by one, and the never-backwards guard hides it β the landing pop then fires on an unchanged number. Cosmetic; the body's "held back until the glyph lands" only holds when the count and the row removal arrive in the same payload. Not worth blocking; noting it so the behaviour is expected. -
Low β first-boot seed qualifies short repo names with
Project.Orgwhen no status snapshot is loaded yet.mergedRepoQualifier(merged_ledger_server.go) falls back toorg + "/" + repowhens.statusis nil, which is the state duringRegisterAPIβmergedLedger()βseedMergedLedger. For a hive tracking repos outside its own org, seeded keys (otherorg-repoβorg/repo) will not match the keys the closed sweep records a moment later (overviewRepoName, the real owner), so the first 24 h look-back can double-count those merges once. One-time and bounded; a follow-up could defer the seed until the first status publish or qualify fromdeps.Configrepo list.
Process: tide reports a merge conflict with v5; needs a rebase before it can land.
β hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Security perspective (read at e5c59ae) β no blocker; one advisory.
Low Β· merged_by is interpolated into popover innerHTML without esc() β src/pkg/dashboard/static/index.html:18517: stageTrackerMergedByText(e.merged_by) (returns 'by @' + by, index.html:18508β18511) is joined into meta and emitted raw at index.html:18519 (<span class="ham-merged-meta">${meta}</span>), while the sibling lane field on the same line is escaped. Not exploitable today β the value comes from safeGetLogin(pr.GetMergedBy()) (src/pkg/github/webhook_item_refresh.go) or the audit actor attr (merged_ledger.go mergedByFromAudit), both GitHub logins restricted to [A-Za-z0-9-] β but the ledger is persisted and re-read from /data/merged-ledger.json (merged_ledger.go newMergedLedger), so the invariant now rests on the file's provenance rather than on the renderer. The banner path is already safe (who lands in t.text, escaped at index.html:18774+ via esc(t.text)).
const meta = [esc(stageTrackerMergedByText(e.merged_by)), e.lane ? esc(e.lane) : '', e.at ? fmtAt(e.at) : ''].filter(Boolean).join(' Β· ');
β hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Intent alignment vs #15147 (read at e5c59ae): all seven expected items are implemented β ledger (merged_ledger.go, 90-day retention, monotone all_time, seed floor), merged{β¦} API block (stage_tracker.go:99), renamed sticky chip + popover, bottom-right banner, glyph flight, dialog-closing Test celebration β and each is covered by the listed tests. No unrelated scope; api-reference.md churn is the citation-line renumbering. Two small notes:
-
Banner "Open on GitHub" can be absent for a live merge (low).
stageTrackerMergeBanner(index.html:18784β18787) only emits the link wheninfo.urlis set, and that comes solely fromserver.recent;_stageTrackerPRTitlekeeps titles only (stageTrackerPRTitles, index.html:18476β18484). On the poller/audit path the row can vanish before the ledger's enriched entry reaches the tab, so the banner the spec calls for ("Show row / Open on GitHub / All merges") loses its middle link. The PR key already carriesowner/name, so a fallback is cheap:const info = Object.assign({ title: _stageTrackerPRTitle[b.key] || '', merged_by: '', lane: '', url: '' }, recent || {}, b); if (!info.url && info.repo && info.repo.indexOf('/') > 0 && info.number > 0 && !info.preview) info.url = `https://github.com/${info.repo}/pull/${info.number}`; -
Advisory β ledger scope is "every merged PR in a configured repo", not "every PR the hive tracked".
sweepClosedRowsfeedsmergedfrom the wholeListClosedSinceresult before thefrontendRepoListsfilter (stage_tracker_closed_sweep.go:149β159), and the comment says this is deliberate. It is a reasonable reading of #15147 Β§1, but it meansall_timewill drift above the PR-throughput counter it was seeded from (hive-observed merges only). Worth a line indocs/dashboard-sections.mdso the two numbers are not expected to agree.
β hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Style / maintainability review (head e5c59ae) β the diff implements every item in #15147 (ledger, merged{} block, chip/popover, sticky bar, banner, flight, glyph setting, test celebration); nothing blocking. Three small coupling / duplication points worth tidying:
-
"hive"attribution literal is now shared across two packages by coincidence.src/pkg/github/webhook_item_refresh.go:121comparesprTerminalMergeAttribution(...) == "hive"against the bare literal returned atprchurn.go:161, andsrc/pkg/dashboard/merged_ledger.go:55separately declaresMergedByHive = "hive"(also matched inmergedByFromAudit). The three only agree by convention; a rename inprchurn.gobreaksMergedByHivesilently. Suggest one exported constant inpkg/githuband alias it:--- a/src/pkg/github/prchurn.go +++ b/src/pkg/github/prchurn.go +// PRMergeAttributionHive is prTerminalMergeAttribution's "the hive merged it" value. +const PRMergeAttributionHive = "hive" ... - return "hive" + return PRMergeAttributionHive --- a/src/pkg/github/webhook_item_refresh.go +++ b/src/pkg/github/webhook_item_refresh.go - snap.MergedByHive = prTerminalMergeAttribution(snap.MergedBy, c.getHiveIdentity(), c.appBotLogin) == "hive" + snap.MergedByHive = prTerminalMergeAttribution(snap.MergedBy, c.getHiveIdentity(), c.appBotLogin) == PRMergeAttributionHive --- a/src/pkg/dashboard/merged_ledger.go +++ b/src/pkg/dashboard/merged_ledger.go - MergedByHive = "hive" + MergedByHive = github.PRMergeAttributionHive
-
Ledger path is a mutable package global that tests overwrite.
merged_ledger.go:40var mergedLedgerPath, read inmerged_ledger_server.go:22, and reassigned inmerged_ledger_test.go:38-39with at.Cleanuprestore. The sibling persistence in this package (PRThroughputCounters,pr_throughput_counters.go:442a.prCountersPath) keeps the path as an instance field instead. AmergedPath stringfield onServer(defaulting to/data/merged-ledger.jsoninsidemergedLedger()) would follow that convention and let the tests stop mutating globals β this package already hast.Parallel()tests, so a global is a race waiting to happen. -
Glyph setting read is duplicated inline.
index.html:19312readslocalStorage.getItem(STAGE_TRACKER_CELEBRATE_GLYPH_KEY)via an inline IIFE inside the settings-sync call, duplicating the read instageTrackerCelebrateGlyph()(:18427). Small helper:function stageTrackerCelebrateGlyphSetting() { try { return stageTrackerCelebrateGlyphId(localStorage.getItem(STAGE_TRACKER_CELEBRATE_GLYPH_KEY)); } catch { return STAGE_TRACKER_CELEBRATE_GLYPH_DEFAULT; } } function stageTrackerCelebrateGlyph() { return STAGE_TRACKER_CELEBRATE_GLYPHS[stageTrackerCelebrateGlyphSetting()]; }then
celebrateGlyph: stageTrackerCelebrateGlyphSetting()at:19312. Same spirit: theHH:MMpadStart formatter is now written three times (:18501,:18515,:18773), and theconst bar = β¦at:18598is fetched only as a truthy guard beforee.target.closest('#activity-monitor-sticky').
β hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88
31b3ae9 to
dec2ac9
Compare
|
@clubanderson is auto-promoted for contributor-lane merging on this PR: the last 5 merged PRs by this author in this hive's repositories have no revert or sentinel-alert evidence. CI, reviewer verdict, diff fences, soak, holds and branch protection still apply. |
β¦ chip Server side of #15096: every tracked PR that reaches merged (hive, human or other bot; audit log, webhook or closed sweep) is recorded in /data/merged-ledger.json, seeded from audit history on first boot, and summarised on /api/stage-tracker as merged{today, total_7d, total_30d, all_time, recent}. Signed-off-by: Andrew Anderson <andy@clubanderson.com>
β¦ht, tests and docs The Activity Monitor's chip is now "Merged" (all-time, with today / this week beneath), pinned at the top of the tracker with the column header strip, hydrated from /api/stage-tracker's merged block so a reload shows the server's number and never goes backwards within a tab, with a popover of recent merges. A merge raises a bee (or +1, hive.tracker.celebrate_glyph) from the row's check cell to the chip when it is in view, else off the top of the screen, and posts a dismissible bottom-right banner with Show row. Test celebration closes the dialog and plays on a row in the viewport. Go tests cover ledger persistence, upsert, retention and cap, today's rollover per zone, seeding, the audit projection, the server hooks and the API shape; node fixture tests cover hydration, the flight target and the banners. Docs and changelog updated. Fixes #15147 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
β¦GitHub backfill on first boot, fixture fixes The ledger's merged.recent now settles a vanished PR row as merged (a human's merge celebrates too); a ledger seeded on this boot makes the first closed sweep look back 30 days over GitHub's closed list so the count backfills beyond the audit log; the popover's date uses the shared dashboard timezone helper; node fixtures fixed (duplicate binding, titles, ledger-settled merges). Refs #15147 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
β¦ banner links without ledger enrichment, one hive attribution constant, docs on ledger scope Refs #15147 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
dec2ac9 to
22c2f40
Compare
|
merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at 22c2f40. |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Fixes #15147
Problem
The Activity Monitor's Merged today chip was accumulated only in the tab (rows vanishing as merged, seeded from the in-memory audit ring): a reload took it from 4 to 0 (and 33 to 4). The celebration also fired where nobody looked β the chip sits in a non-sticky toolbar far above a scrolled viewport and the row effect is a one-shot 2.5 s glow (#15096, CDP comment 6481579497).
Change
Server
pkg/dashboard/merged_ledger.goβ a persistent ledger at/data/merged-ledger.json(memory-only without/data): one entry per merged PR{repo, number, title, url, merged_at, merged_by (hive|login), lane, issue}, deduplicated with blank-filling upsert, 90-day retention, 5000-entry cap, an all-time total that only grows, atomic writes. Seeded once on first boot from the audit log'spr_mergedhistory (files + ring) with the PR throughput counter as the floor, so the count does not restart at zero.pr_mergedhook (hive's own merges and the poller's observed human / bot merges) and by webhook / closed-sweep snapshots of merged PRs (title + merger login within seconds).pkg/githubsnapshots now carrymerged_at,merged_by,merged_by_hive.GET /api/stage-trackeraddsmerged{today, total_7d, total_30d, all_time, recent[β€20], tz, day_start}; "today" rolls at midnight in the spoke's zone (UTC when none).SPA
hive.tracker.celebrate_glyph) rises from the row's β cell (~900 ms, slight arc) to the chip when the chip's box is in the viewport (count bumps, zap on landing) or exits through the top edge otherwise;position: fixed,pointer-events: none, works at any scroll; reduced motion fades in place.Tests β
merged_ledger_test.go(persistence across reload, upsert fill-blanks / earliest time, retention + cap, today per zone incl. midnight rollover, seed floor + once, audit projection, server audit + snapshot recording, API shape); node fixture tests instage_tracker_cues_test.go(TestStageTrackerMergedChipHydrates,TestStageTrackerFlightTargetNode, updated celebrate tests for flight, banners, sticky chip target).Docs β
docs/dashboard-sections.md(Activity Monitor),docs/api-reference.md,changelog.d/fixed-merged-ledger.md.Not in this PR
#14934 still showing PR in progress Β· #14945 an hour after the merge is not a dashboard cache problem: the PR merged into
v6(non-default, so GitHub does not auto-close) and the hive's close-on-merge skipped it asuntrusted_authoralthough the hive merged it. Filed as #15148.