Repository navigation
🐛 Activity Monitor: celebrate externally merged PRs with bee + toast naming the merger - #16659
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
|
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. @clubanderson this PR is held at Failing checks:
Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path. Review findings from Read the diff against the tree at What I verified
Info, not a defect: closed PR keys now stay in |
|
CI diagnosis (from the hive; it can't push to a human-authored branch, so this needs to be applied by the author)
Fix in pick(/function stageTrackerPrimaryRepo\(\) \{[^\n]*\n/, 'stageTrackerPrimaryRepo'),
+ pick(/function stageTrackerMergerText\(by\) \{[\s\S]*?\n \}\n/, 'stageTrackerMergerText'),
+ pick(/function stageTrackerMergedByOf\(key, d\) \{[\s\S]*?\n \}\n/, 'stageTrackerMergedByOf'),
pick(/function stageTrackerMergeBannerText\(b, nowMs\) \{[\s\S]*?\n \}\n/, 'stageTrackerMergeBannerText'),
🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
The red runtime-tests / build-and-test lanes are caused by this diff, and the fix is small.
What fails: Dashboard helper tests subtests 217–222 (stage_tracker_merge_banner_countdown.test.js) with stageTrackerMergedByOf is not defined and stageTrackerMergerText is not defined (job 126827365954).
Mechanism: that harness builds its own sandbox from a hand-picked list of functions (stage_tracker_merge_banner_countdown.test.js:58-80) and stubs stageTrackerMergedByText at line 62. This PR adds two new calls inside functions the harness does extract:
static-src/js/tracker-merged.js:1186—stageTrackerMergeBannerTextnow callsstageTrackerMergerText(b.merged_by)static-src/js/tracker-merged.js:1205—stageTrackerMergeBannernow callsstageTrackerMergedByOf(b.key, …)wheninfo.merged_byis empty and!b.preview
Neither helper is picked or stubbed in the harness, so new Function(...) throws at the first banner. (The Go-side stage_tracker_cues_test.go:46-47 does pull them in via jsFunc, which is why only the node lane fails.)
Suggested fix: add pick(/function stageTrackerMergerText\(by\) \{[\s\S]*?\n \}\n/, …) and pick(/function stageTrackerMergedByOf\(key, d\) \{[\s\S]*?\n \}\n/, …) to the harness list (or a one-line stub for each next to the stageTrackerMergedByText stub at line 62). The stageTrackerMergedByOf body also reads _stageTrackerTerminalFacts, which it already guards with typeof … !== 'undefined', so no further globals are needed.
I did not review the rest of the XL diff (ledger / webhook cache / Go tracker changes) in this pass; this comment is limited to the CI failure.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
…naming the merger
An approved PR merged by hand (gh pr merge --admin --squash) vanished
from the tracker with no bee fly-off and no merge toast, while the
hive's own merges celebrated.
Root cause: recently_merged carried only audit pr_merged lines, which
the hive writes synchronously for its own merges but which an external
merge gets only after the PR poller's settle scan (minutes) — the row
was already gone. Worse, webhookItemHint for issue_comment/issues on a
PR never read issue.pull_request.merged_at, so a bot comment seconds
after the merge produced a closed-unmerged snapshot: the SPA toasted
"closed" and deleted the PR's open observation, forfeiting the
celebration for good.
Fix: recently_merged is the union of audit lines and the merged ledger
(webhook/closed-sweep merges by anyone), deduped, each carrying
merged_by; issue hints read merged_at; a closed snapshot never outranks
a merge in recently_closed. The SPA keeps a closed key comparable so a
later merge still celebrates, and the banner head names the merger
("merged by @clubanderson" / "merged by 🐝 hive"). Closed-not-merged
keeps the quiet toast. Go + node tests cover both exits.
Fixes #16658
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
…rness The countdown harness lifts stageTrackerMergeBanner out of index.html by regex but did not lift the new stageTrackerMergerText/stageTrackerMergedByOf it now calls, so runtime-tests failed with ReferenceError. Lift them, and add unit cases for the merger text (@login / 🐝 hive) and repo-scoped merged_by resolution. Fixes #16658 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
fe0e43a to
daf7824
Compare
There was a problem hiding this comment.
Read the server side against the tree at daf7824, then the client. The server half looks correct to me; one client regression worth fixing before this lands.
Server — looks correct.
MergedLedger.Since(src/pkg/dashboard/merged_ledger.go:404-421)breaks on the first entry beforesince; that is safe becauseRecordcallssortLocked()on every write (merged_ledger.go:213-214), soentriesis always ascending byMergedAt.Hasreadsl.index, whichsortLocked/pruneLockedboth rebuild.noteClosedSnapshotslooks upledger.Has(qualify(snap.Repo), …)(stage_tracker_recently_closed.go:43) andrecordMergedSnapshotswrites withqualify(snap.Repo)too (merged_ledger_server.go:107), so the key forms agree.applyWebhookItemSnapshotsordersrecordMergedSnapshots→forgetClosedSnapshots→noteClosedSnapshots(webhook_tracker_refresh.go:399-401), so a merged snapshot both withdraws a stale closed listing and blocks a new one in the same pass.webhookItemHintnow readsissue.pull_request.merged_at(src/pkg/github/webhook_cache.go:745-746);p.Issue.PullRequestis a*json.RawMessage(webhook_cache.go:529), whichwebhookIssuePullRequestMergedhandles.
Client — one regression (medium): the "closed" toast now repeats on every reload within the 30‑minute window.
src/pkg/dashboard/static-src/js/tracker-merged.js:123keeps the closed key asfalsein_stageTrackerMergeStateinstead of deleting it (intended, so closed→merged can still flipfalse→true).- That state is persisted:
stageTrackerReconcileMergeswrites{ state: _stageTrackerMergeState, delivered: _stageTrackerZapped }to sessionStorage (tracker-merged.js:100) and restoresstateon the next load (tracker-merged.js:82-93). - But the repeat guard
_stageTrackerClosedNotedis a plain in-memory object (tracker-merged.js:172) and is not in that record — it is reset to{}on reload. stageTrackerNewlyClosed(tracker-merged.js:276-287) then seesprevState[key] === false,rawState[key] !== true, not initems,noted[key]unset, andd.recently_closedstill lists the PR (server keeps it forstageTrackerMergedWindow= 30 min,stage_tracker.go:154) → the key is returned again andstageTrackerClosedToastfires again.
Before this PR delete next[k] meant the key was absent from the persisted state, so prevState[key] !== false short-circuited the check after a reload. Net effect: for 30 minutes after any non-merge close, every F5 on the tracker re-toasts "#N closed · reason". The merge path already solves this exact problem for merges by persisting delivered (_stageTrackerZapped); the simplest fix is to persist _stageTrackerClosedNoted in the same session record (and restore it alongside delivered), or to also treat a _stageTrackerZapped-style delivered set for closes. TestStageTrackerExternalMergeCelebrateNode does not exercise a reload, so it does not catch this — a case that seeds sessionStorage with state[key]=false and asserts zero closed toasts would fail today and pass with the fix.
Everything else in the client diff (stageTrackerMergerText, stageTrackerMergedByOf, banner head) read fine; the d.recently_merged ∪ d.merged.recent lookup correctly falls back to short-vs-qualified repo matching.
The PR body's claims match the diff; no scope beyond #16658.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at daf7824. |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Fixes #16658
Problem
An approved PR row (#16644, merged by @clubanderson via
gh pr merge --admin --squash) disappeared from the Activity Monitor with no bee fly-off and no merge toast. Rows hive merges itself celebrate every time.Root cause
recently_mergedwas built only from auditpr_mergedlines. Hive's own merge writes one synchronously in the pass that evicts the row; an external merge's line arrives minutes later via the PR poller's settle scan, after the row has already gone.webhookItemHintforissue_comment/issueson a PR never readissue.pull_request.merged_at, so github-actions' comment 10 s after the merge produced a closed-unmerged snapshot →recently_closed→ the SPA toasted "closed" anddeleted the PR's open observation; the merge fact arriving later was no longer a false→true transition.recently_mergednamed no merger.Fix
Server
stageTrackerMergedSince: auditpr_mergedlines ∪ merged ledger (MergedLedger.Since), deduped (incl. short-vs-qualified repo), each entry withmerged_by.webhookItemHint: issue hints readissue.pull_request.merged_at.noteClosedSnapshotsskips a PR the ledger holds merged; newforgetClosedSnapshotswithdraws a closed listing a later merged snapshot contradicts (wired inapplyWebhookItemSnapshots).Client (
tracker-merged.js)falseinstead of being deleted, so closed→merged still celebrates once.#16644 merged by @clubanderson/#16645 merged by 🐝 hive(stageTrackerMergerText,stageTrackerMergedByOffall back torecently_merged/merged.recent/ terminal facts).#N closed · reasontoast.Tests
TestStageTrackerRecentlyMergedAnyMerger,TestStageTrackerClosedSnapshotNeverOutranksMerge,TestWebhookItemHintIssueCommentOnMergedPR.TestStageTrackerExternalMergeCelebrateNode— hive-merged and externally-merged ⇒ bee + banner naming the merger; closed ⇒ quiet toast, no bee/banner; closed-then-merged ⇒ exactly one celebration.Changelog:
changelog.d/fixed-merge-celebration-external.md.