diff --git a/changelog.d/fixed-15828-merge-session-countdown.md b/changelog.d/fixed-15828-merge-session-countdown.md new file mode 100644 index 0000000000..d056a69090 --- /dev/null +++ b/changelog.d/fixed-15828-merge-session-countdown.md @@ -0,0 +1 @@ +- Activity monitor merge notifications survive reloads without replaying delivered merges, resolve audit events for vanished rows, and cancel their countdown when evicted from the banner stack. diff --git a/src/docs/dashboard-sections/activity-monitor.md b/src/docs/dashboard-sections/activity-monitor.md index 58017f982d..a54de68fbb 100644 --- a/src/docs/dashboard-sections/activity-monitor.md +++ b/src/docs/dashboard-sections/activity-monitor.md @@ -453,7 +453,7 @@ A thin bar at the top of the tracker — it stays pinned under the card header w **Click the chip** for a popover of the recent merges — number (linked), title, *by hive* / *by @login*, lane, time — and the 30-day total; it is also where a merged row's trace lives once the row has left. When a PR on the list merges its row does **not** simply vanish on the next refresh: it stays pinned for about 3.5 s, its ✓ cell glows amber, the event line reads *Hive: merged #14947 · by hive*, and — in the operator's words — "an animation originates from the item's row where the check mark is and flies up to the top of the browser border; if the Merged pill is visible the animation stops there, if not we just see it go off the screen": a 🐝 (or **+1**, ⚙ → Merges → *Glyph*, `hive.tracker.celebrate_glyph`) rises out of the ✓ cell for ≈2 s on an ease-out with a slight arc, lands on the chip when the chip's box is inside the viewport (the count rolls up like a mileage odometer — each digit that rose slides up through the digits it passes over ≈0.9 s — with a soft scale-pop, and the merge zap, when sound is on, plays as it lands) or exits through the top edge otherwise (the count still rolls). -On a change only the wheels whose digit changed roll (the rightmost always spins a full turn, carry wheels roll too); the others keep their cell. *N today · N this week* roll the same way, drawn plain; a number that falls (today → 0 at midnight), the first draw after a reload (the tab's last values are remembered in `sessionStorage`, so a reload rolls up from them), and reduced motion swap instantly and the drum stays — the odometer look is the resting state, not an effect of the roll ("where is my odometer look and feel?", after #15409 had sized only the flying bee and drawn the roll as a 900 ms overlay over plain text). The pill's width never changes mid-roll (the drum's cells set it). The roll waits for the bee: while a glyph is in the air nothing on the drum moves — not the day/week line, not a total the server has already raised, not a merge over the flight cap — and the moment the last glyph lands (its `animationend`, or a timer at the flight's length when the event never fires) the drum rolls once to the final numbers and the zap plays; several merges in one flight are one roll, not a queue (#15568: "the odometer should roll only after the bee animation finishes so it looks correlated"). It works at any scroll position (`position: fixed`, `pointer-events: none`). At the same moment a **banner** appears at the bottom right — *✓ #15067 merged — fix: enable bulk delegation… (adopted, by hive, 17:42)* — and stays until dismissed or 30 s, stacked (newest at the bottom, at most five) when several merge together, with **Show row** (scrolls to the row and glows it again; once the row has left, says so and opens the list), **Open on GitHub** and **All merges**. +On a change only the wheels whose digit changed roll (the rightmost always spins a full turn, carry wheels roll too); the others keep their cell. *N today · N this week* roll the same way, drawn plain; a number that falls (today → 0 at midnight), the first draw after a reload (the tab's last values are remembered in `sessionStorage`, so a reload rolls up from them), and reduced motion swap instantly and the drum stays — the odometer look is the resting state, not an effect of the roll ("where is my odometer look and feel?", after #15409 had sized only the flying bee and drawn the roll as a 900 ms overlay over plain text). The pill's width never changes mid-roll (the drum's cells set it). The roll waits for the bee: while a glyph is in the air nothing on the drum moves — not the day/week line, not a total the server has already raised, not a merge over the flight cap — and the moment the last glyph lands (its `animationend`, or a timer at the flight's length when the event never fires) the drum rolls once to the final numbers and the zap plays; several merges in one flight are one roll, not a queue (#15568: "the odometer should roll only after the bee animation finishes so it looks correlated"). It works at any scroll position (`position: fixed`, `pointer-events: none`). At the same moment a **banner** appears at the bottom right — *✓ #15067 merged — fix: enable bulk delegation… (adopted, by hive, 17:42)* — and stays until dismissed or for twice the configured `toast_info_s` (30 s at the default), draining a countdown bar along its bottom edge, stacked (newest at the bottom, at most five) when several merge together — a banner pushed out of the stack stops its countdown — with **Show row** (scrolls to the row and glows it again; once the row has left, says so and opens the list), **Open on GitHub** and **All merges**. Merge detection survives a reload: the last observed PR states and the merges already announced are kept in `sessionStorage` (`hive.tracker.merge-session.v1`), so an open → merged transition that straddles a reload is still announced, and each merge is announced exactly once per tab. Several merges in one refresh stagger 200 ms apart with at most three glyphs in flight (the rest bump the count without flying); a merged PR that is filtered out or on another page still counts and still gets its banner. Under reduced motion nothing flies: the glyph fades in place, the count bumps, the row glows, the banners appear without sliding. A PR drawn inline on its issue's row (the usual case — one covering PR, no sub-row) celebrates on that issue row: every row stamps the PR keys it draws (`data-ham-prs`) and the SPA remembers each PR's host row from the last payload, so the flight has somewhere to start from even when the merge also closes the issue. diff --git a/src/pkg/dashboard/nav_count_delta.test.js b/src/pkg/dashboard/nav_count_delta.test.js index 8ae1cd4dec..ce25ebee22 100644 --- a/src/pkg/dashboard/nav_count_delta.test.js +++ b/src/pkg/dashboard/nav_count_delta.test.js @@ -47,6 +47,7 @@ function load() { function fetchBeadSynthStatus() {} function fetchFactHistory() {} function stageTrackerNoteMerges() {} + function stageTrackerReconcileMerges() {} function stageTrackerNoteOpened() {} function stageTrackerNoteMoves() {} function stageTrackerSyncToolbar() {} diff --git a/src/pkg/dashboard/stage_tracker_cues_test.go b/src/pkg/dashboard/stage_tracker_cues_test.go index 5d504617ca..d5c24f5d26 100644 --- a/src/pkg/dashboard/stage_tracker_cues_test.go +++ b/src/pkg/dashboard/stage_tracker_cues_test.go @@ -373,6 +373,10 @@ func stageTrackerCelebrateJS(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerAgoText"), jsFunc(t, html, "stageTrackerAfter"), jsFunc(t, html, "stageTrackerTransient"), + jsConstLine(t, html, "STAGE_TRACKER_MERGE_SESSION_KEY"), + jsConstLine(t, html, "STAGE_TRACKER_MERGE_SESSION_PR_KEY_RE"), + "var _stageTrackerMergeSessionLoaded = false;", + jsFunc(t, html, "stageTrackerReconcileMerges"), jsFunc(t, html, "stageTrackerNoteMerges"), stageTrackerMergingHoldOffJS, jsFunc(t, html, "stageTrackerPRKey"), diff --git a/src/pkg/dashboard/stage_tracker_merge_session_test.go b/src/pkg/dashboard/stage_tracker_merge_session_test.go new file mode 100644 index 0000000000..6c7624c659 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_merge_session_test.go @@ -0,0 +1,92 @@ +package dashboard + +import ( + "strings" + "testing" +) + +// Exercise the real reconcile entry point with a shared sessionStorage but +// reset SPA memory, as a reload would. Delivery enters the detached glyph +// pipeline, which counts and plays the merge sound only after landing. +func TestStageTrackerMergeSessionNode(t *testing.T) { + html := indexHTML(t) + script := stageTrackerCelebrateJS(t, html) + stageTrackerCelebrateFixture + ` +function reload() { + _stageTrackerMergeSessionLoaded = false; + _stageTrackerMergeState = null; + _stageTrackerZapped = {}; +} +stageTrackerReconcileMerges(items(42)); +// Webhook eviction can precede the audit fact, including across a reload. +stageTrackerReconcileMerges({ items: [] }); +assert.strictEqual(banners.children.length, 0, 'absence alone is not a merge'); +reload(); +const merged = { items: [], recently_merged: [{ repo: 'r', number: 42 }] }; +stageTrackerReconcileMerges(merged); +tick(0); +assert.strictEqual(banners.children.length, 1, 'last row absent, short audit repo still resolves after reload'); +assert.strictEqual(_stageTrackerMergeState['o/r/pr#42'], true); +assert.strictEqual(_stageTrackerZapped['o/r/pr#42'], true); +assert.strictEqual(flights().length, 1, 'exactly one delivery to the detached celebration pipeline'); +assert.strictEqual(zaps.length, 0, 'sound waits for the bee to land'); +tick(STAGE_TRACKER_CELEBRATE_FLY_MS * 1.5 + 10); +assert.strictEqual(flights().length, 0, 'bee landed'); +assert.strictEqual(zaps.length, 1, 'exactly one delivery to the celebration/count pipeline'); +stageTrackerReconcileMerges({ items: [], merged: { recent: [{ repo: 'o/r', number: 42 }] } }); +reload(); +stageTrackerReconcileMerges(merged); +tick(0); +assert.strictEqual(banners.children.length, 1, 'reload after delivery does not repeat the banner'); +assert.strictEqual(flights().length, 0, 'reload after delivery does not repeat the bee'); +tick(STAGE_TRACKER_CELEBRATE_FLY_MS * 1.5 + 10); +assert.strictEqual(zaps.length, 1, 'ledger + audit + reload do not repeat the counter tick'); +// Delivered identity outlives the server's recent-history window, even +// if a stale open snapshot resurfaces after another reload. +stageTrackerReconcileMerges({ items: [] }); +reload(); +stageTrackerReconcileMerges(items(42)); +stageTrackerReconcileMerges(payloadMerged(42)); +tick(0); +assert.strictEqual(banners.children.length, 1, 'expired recent history cannot erase delivered identity'); +// A tab's first snapshot is a baseline, not a replay of old merges. +delete session[STAGE_TRACKER_MERGE_SESSION_KEY]; +reload(); +stageTrackerReconcileMerges(payloadMerged(99)); +tick(0); +assert.strictEqual(banners.children.length, 1); +// A corrupt/unavailable browser store must not break normal live delivery. +session[STAGE_TRACKER_MERGE_SESSION_KEY] = '{broken'; +reload(); +stageTrackerReconcileMerges(items(43)); +stageTrackerReconcileMerges(payloadMerged(43)); +tick(0); +assert.strictEqual(banners.children.length, 2); +` + runStageTrackerRowActionsScript(t, script) +} + +func TestStageTrackerMergeBannerCountdownNode(t *testing.T) { + html := indexHTML(t) + runStageTrackerRowActionsScript(t, stageTrackerCelebrateJS(t, html)+stageTrackerCelebrateFixture+` +const ttl = 2468; +stageTrackerMergeBannerMs = () => ttl; +const b = stageTrackerMergeBanner({ key: 'o/r/pr#7', repo: 'o/r', number: 7, at: clock }); +assert.ok(b.querySelector('.toast-bar'), 'merge banner draws the shared countdown'); +assert.strictEqual(b.style.props['--toast-ttl'], ttl + 'ms'); +tick(ttl - 1); +assert.ok(b.parentNode, 'banner remains for its configured lifetime'); +tick(1); +assert.ok(b.classList.contains('merge-banner-out'), 'shared timer dismisses at the bar deadline'); +// No animationend is emitted by the fake DOM: allow the shared +// stageTrackerAfter fallback (1.5 times the 180ms exit animation) to fire. +tick(270); +assert.strictEqual(b.parentNode, null); +const manual = stageTrackerMergeBanner({ key: 'o/r/pr#8', repo: 'o/r', number: 8 }); +assert.ok(manual._countdown.timer); +stageTrackerMergeBannerDismiss(manual); +assert.strictEqual(manual._countdown, null, 'manual dismissal cancels countdown'); +`) + if !strings.Contains(cssRule(t, html, ".merge-banner"), "position: relative;") { + t.Fatal("merge countdown must be positioned within its own banner") + } +} diff --git a/src/pkg/dashboard/stage_tracker_merge_sound_test.go b/src/pkg/dashboard/stage_tracker_merge_sound_test.go index b62bfbcc53..9b7f004a59 100644 --- a/src/pkg/dashboard/stage_tracker_merge_sound_test.go +++ b/src/pkg/dashboard/stage_tracker_merge_sound_test.go @@ -97,7 +97,7 @@ func TestStageTrackerMergeSoundWiring(t *testing.T) { `localStorage.getItem(STAGE_TRACKER_SOUND_KEY) === '1'`, `localStorage.setItem(STAGE_TRACKER_SOUND_KEY, _stageTrackerSoundOn ? '1' : '0')`, `const STAGE_TRACKER_BUZZ_MASTER_GAIN = 0.2;`, - `function stageTrackerMergeState(d)`, + `function stageTrackerMergeState(d, prev)`, `function stageTrackerCarryOpen(prev, next)`, `function stageTrackerNewlyMerged(prev, next)`, `function stageTrackerNoteMerges(d)`, @@ -105,7 +105,7 @@ func TestStageTrackerMergeSoundWiring(t *testing.T) { `function stageTrackerNewlyOpened(prev, next)`, `function stageTrackerNoteOpened(d)`, `function hamSoundToggle()`, - `if (data && typeof data === 'object') { _stageTracker = data; stageTrackerNoteMerges(data); stageTrackerNoteOpened(data); stageTrackerNoteMoves(data); }`, + `if (data && typeof data === 'object') { _stageTracker = data; stageTrackerReconcileMerges(data); stageTrackerNoteOpened(data); stageTrackerNoteMoves(data); }`, `if (stageTrackerSoundGate()) stageTrackerPlayZap(`, `if (stageTrackerSoundGate()) stageTrackerPlayBuzz(`, `function stageTrackerSoundGate() { return !!_stageTrackerSoundOn && !document.hidden; }`, @@ -228,23 +228,23 @@ assert.deepStrictEqual(stageTrackerMergeState({ items: [P(20, 50), { kind: 'pr', { 'a/b/pr#20': false, 'c/b/pr#1': false, 'b/pr#20': true }, 'an ambiguous short name is left alone'); stageTrackerNoteMerges({ items: [P(21, 50)] }); stageTrackerNoteMerges({ items: [], recently_merged: [{ repo: 'b', number: 21 }] }); -assert.deepStrictEqual(plays, [STAGE_TRACKER_SOUND_MAX_PLAYS, 1], 'short-name entry with no item left to resolve it cannot match…'); +assert.deepStrictEqual(plays, [STAGE_TRACKER_SOUND_MAX_PLAYS, 1, 1], 'short-name entry resolves against the last observed row after eviction'); stageTrackerNoteMerges({ items: [P(22, 50)] }); stageTrackerNoteMerges({ items: [P(22, 50)], recently_merged: [{ repo: 'b', number: 22 }] }); -assert.deepStrictEqual(plays, [STAGE_TRACKER_SOUND_MAX_PLAYS, 1, 1], '…but one that arrives while the item is still listed does'); +assert.deepStrictEqual(plays, [STAGE_TRACKER_SOUND_MAX_PLAYS, 1, 1, 1], 'an entry that arrives while the item is still listed also zaps'); // Regression: the PR drops out of items one payload before the audit log // lists its merge (webhook-patched snapshot vs poller). Carried as open, // it still zaps when recently_merged catches up — once. stageTrackerNoteMerges({ items: [P(30, 50), P(31, 60)] }); stageTrackerNoteMerges({ items: [P(31, 60)] }); -assert.deepStrictEqual(plays, [STAGE_TRACKER_SOUND_MAX_PLAYS, 1, 1], 'vanished without a merge entry: nothing yet'); +assert.deepStrictEqual(plays, [STAGE_TRACKER_SOUND_MAX_PLAYS, 1, 1, 1], 'vanished without a merge entry: nothing yet'); assert.strictEqual(_stageTrackerMergeState['a/b/pr#30'], false, 'carried as still open'); stageTrackerNoteMerges({ items: [P(31, 60)], recently_merged: [{ repo: 'a/b', number: 30 }] }); -assert.deepStrictEqual(plays, [STAGE_TRACKER_SOUND_MAX_PLAYS, 1, 1, 1], 'late recently_merged entry zaps'); +assert.deepStrictEqual(plays, [STAGE_TRACKER_SOUND_MAX_PLAYS, 1, 1, 1, 1], 'late recently_merged entry zaps'); stageTrackerNoteMerges({ items: [P(31, 60)], recently_merged: [{ repo: 'a/b', number: 30 }] }); stageTrackerNoteMerges({ items: [P(31, 60)] }); -assert.deepStrictEqual(plays, [STAGE_TRACKER_SOUND_MAX_PLAYS, 1, 1, 1], 'no replay once the entry ages out'); +assert.deepStrictEqual(plays, [STAGE_TRACKER_SOUND_MAX_PLAYS, 1, 1, 1, 1], 'no replay once the entry ages out'); assert.deepStrictEqual(stageTrackerCarryOpen(null, { x: true }), { x: true }); assert.deepStrictEqual(stageTrackerCarryOpen({ a: false, b: true, c: false }, { c: true }), { a: false, c: true }, 'merged keys are not carried, open ones are'); ` diff --git a/src/pkg/dashboard/stage_tracker_motion_test.go b/src/pkg/dashboard/stage_tracker_motion_test.go index 5319d9c6cb..a20c91e16e 100644 --- a/src/pkg/dashboard/stage_tracker_motion_test.go +++ b/src/pkg/dashboard/stage_tracker_motion_test.go @@ -38,7 +38,7 @@ func TestStageTrackerMotionWiring(t *testing.T) { `function stageTrackerNoteMoves(d)`, `function stageTrackerAnimateMoves(root)`, `function stageTrackerMotionEffect(setting, reduced)`, - `stageTrackerNoteMerges(data); stageTrackerNoteOpened(data); stageTrackerNoteMoves(data); }`, + `stageTrackerReconcileMerges(data); stageTrackerNoteOpened(data); stageTrackerNoteMoves(data); }`, `const ctx = { nowMs, stages, moves: _stageTrackerMoves };`, `if (Object.keys(_stageTrackerMoves).length) { stageTrackerAnimateMoves(el); _stageTrackerMoves = {}; }`, `window.matchMedia('(prefers-reduced-motion: reduce)').matches`, diff --git a/src/pkg/dashboard/static-src/js/tracker-filter-render.js b/src/pkg/dashboard/static-src/js/tracker-filter-render.js index 27a0629c86..9d1984c55b 100644 --- a/src/pkg/dashboard/static-src/js/tracker-filter-render.js +++ b/src/pkg/dashboard/static-src/js/tracker-filter-render.js @@ -52,7 +52,7 @@ } function renderStageTracker(data, countRefresh = false) { - if (data && typeof data === 'object') { _stageTracker = data; stageTrackerNoteMerges(data); stageTrackerNoteOpened(data); stageTrackerNoteMoves(data); } + if (data && typeof data === 'object') { _stageTracker = data; stageTrackerReconcileMerges(data); stageTrackerNoteOpened(data); stageTrackerNoteMoves(data); } // Row-action feedback rides the payload: a result toast leaves and a // row stops "acting" once the item it targets reads a new state. if (data && typeof data === 'object' && typeof stageTrackerResultToastsSync === 'function') { stageTrackerNoteEvents(data); stageTrackerResultToastsSync(data); stageTrackerPendingExpire(data); } diff --git a/src/pkg/dashboard/static-src/js/tracker-merged.js b/src/pkg/dashboard/static-src/js/tracker-merged.js index 0efea0491e..6623b87ffb 100644 --- a/src/pkg/dashboard/static-src/js/tracker-merged.js +++ b/src/pkg/dashboard/static-src/js/tracker-merged.js @@ -4,10 +4,17 @@ // Pure: PR key → merged? for one payload. Issues are not tracked. A // recently_merged repo given by its short name is resolved against the // owner/name of the items (any kind, any repo) when exactly one matches. - function stageTrackerMergeState(d) { + function stageTrackerMergeState(d, prev) { const out = {}; if (!d || typeof d !== 'object') return out; const byShort = {}; + // A dropped row (including one from before a reload) still teaches + // the short repo alias used by the audit side list. + for (const key of Object.keys(prev || {})) { + const repo = key.slice(0, key.lastIndexOf('/pr#')); + const slash = repo.lastIndexOf('/'); + if (slash > 0) { const short = repo.slice(slash + 1); byShort[short] = (short in byShort && byShort[short] !== repo) ? '' : repo; } + } for (const it of (Array.isArray(d.items) ? d.items : [])) { if (!it) continue; // Every item of every repo (issues too) teaches the short → full @@ -47,10 +54,40 @@ return Object.keys(next).filter(k => next[k] === true && prev[k] === false).sort(); } + const STAGE_TRACKER_MERGE_SESSION_KEY = 'hive.tracker.merge-session.v1'; + // Shape of a stageTrackerPRKey() key as stored in the session record. + const STAGE_TRACKER_MERGE_SESSION_PR_KEY_RE = /^.+\/pr#[1-9][0-9]*$/; + var _stageTrackerMergeSessionLoaded = false; + // Persist both the last observation and the delivered keys: saving only + // delivered keys loses an open→merged transition across a reload. The + // first visit still seeds history silently rather than replaying it. + function stageTrackerReconcileMerges(d) { + if (!_stageTrackerMergeSessionLoaded) { + _stageTrackerMergeSessionLoaded = true; + try { + const saved = JSON.parse(sessionStorage.getItem(STAGE_TRACKER_MERGE_SESSION_KEY)); + if (saved && saved.state && typeof saved.state === 'object' && !Array.isArray(saved.state)) { + const state = {}, delivered = {}; + for (const key of Object.keys(saved.state)) { + if (!STAGE_TRACKER_MERGE_SESSION_PR_KEY_RE.test(key) || typeof saved.state[key] !== 'boolean') continue; + state[key] = saved.state[key]; + } + for (const key of Object.keys(saved.delivered || {})) { + if (STAGE_TRACKER_MERGE_SESSION_PR_KEY_RE.test(key) && saved.delivered[key] === true) delivered[key] = true; + } + _stageTrackerMergeState = state; + _stageTrackerZapped = delivered; + } + } catch {} // Storage disabled/corrupt: keep the in-memory path. + } + stageTrackerNoteMerges(d); + try { sessionStorage.setItem(STAGE_TRACKER_MERGE_SESSION_KEY, JSON.stringify({ state: _stageTrackerMergeState, delivered: _stageTrackerZapped })); } catch {} + } + function stageTrackerNoteMerges(d) { const nowMs = Date.now(); _stageTrackerMergingHoldMs = stageTrackerMergingHoldMsOf(d, _stageTrackerMergingHoldMs); - const raw = stageTrackerCarryOpen(_stageTrackerMergeState, stageTrackerMergeState(d)); + const raw = stageTrackerCarryOpen(_stageTrackerMergeState, stageTrackerMergeState(d, _stageTrackerMergeState)); // The merge gate's hold (hivecommons/hive#15245, #15808) keeps a // row the payload dropped mid-merge on the board at "Merging" until // the merged fact arrives (then the merge is fresh at once) or the @@ -204,7 +241,7 @@ function stageTrackerMergingHoldRelease() { _stageTrackerMergingHoldTimer = 0; if (!_stageTracker || typeof _stageTracker !== 'object') return; - stageTrackerNoteMerges(_stageTracker); + stageTrackerReconcileMerges(_stageTracker); renderStageTracker(undefined, true); } @@ -945,7 +982,7 @@ if (b.rowKey) el.setAttribute('data-ham-row', b.rowKey); el.innerHTML = `
${num ? `#${esc(num)} ` : ''}merged${info.preview ? ' (test)' : ''}
${esc(t.text)}
`; box.appendChild(el); - while (box.children.length > STAGE_TRACKER_MERGE_BANNER_MAX) box.children[0].remove(); + while (box.children.length > STAGE_TRACKER_MERGE_BANNER_MAX) { toastCountdownCancel(box.children[0]); box.children[0].remove(); } toastCountdownBar(el, stageTrackerMergeBannerMs(), () => stageTrackerMergeBannerDismiss(el)); return el; } diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 4e66b0a24c..788e461254 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -19409,7 +19409,7 @@

All labels

} function renderStageTracker(data, countRefresh = false) { - if (data && typeof data === 'object') { _stageTracker = data; stageTrackerNoteMerges(data); stageTrackerNoteOpened(data); stageTrackerNoteMoves(data); } + if (data && typeof data === 'object') { _stageTracker = data; stageTrackerReconcileMerges(data); stageTrackerNoteOpened(data); stageTrackerNoteMoves(data); } // Row-action feedback rides the payload: a result toast leaves and a // row stops "acting" once the item it targets reads a new state. if (data && typeof data === 'object' && typeof stageTrackerResultToastsSync === 'function') { stageTrackerNoteEvents(data); stageTrackerResultToastsSync(data); stageTrackerPendingExpire(data); } @@ -21982,10 +21982,17 @@

All labels

// Pure: PR key → merged? for one payload. Issues are not tracked. A // recently_merged repo given by its short name is resolved against the // owner/name of the items (any kind, any repo) when exactly one matches. - function stageTrackerMergeState(d) { + function stageTrackerMergeState(d, prev) { const out = {}; if (!d || typeof d !== 'object') return out; const byShort = {}; + // A dropped row (including one from before a reload) still teaches + // the short repo alias used by the audit side list. + for (const key of Object.keys(prev || {})) { + const repo = key.slice(0, key.lastIndexOf('/pr#')); + const slash = repo.lastIndexOf('/'); + if (slash > 0) { const short = repo.slice(slash + 1); byShort[short] = (short in byShort && byShort[short] !== repo) ? '' : repo; } + } for (const it of (Array.isArray(d.items) ? d.items : [])) { if (!it) continue; // Every item of every repo (issues too) teaches the short → full @@ -22025,10 +22032,40 @@

All labels

return Object.keys(next).filter(k => next[k] === true && prev[k] === false).sort(); } + const STAGE_TRACKER_MERGE_SESSION_KEY = 'hive.tracker.merge-session.v1'; + // Shape of a stageTrackerPRKey() key as stored in the session record. + const STAGE_TRACKER_MERGE_SESSION_PR_KEY_RE = /^.+\/pr#[1-9][0-9]*$/; + var _stageTrackerMergeSessionLoaded = false; + // Persist both the last observation and the delivered keys: saving only + // delivered keys loses an open→merged transition across a reload. The + // first visit still seeds history silently rather than replaying it. + function stageTrackerReconcileMerges(d) { + if (!_stageTrackerMergeSessionLoaded) { + _stageTrackerMergeSessionLoaded = true; + try { + const saved = JSON.parse(sessionStorage.getItem(STAGE_TRACKER_MERGE_SESSION_KEY)); + if (saved && saved.state && typeof saved.state === 'object' && !Array.isArray(saved.state)) { + const state = {}, delivered = {}; + for (const key of Object.keys(saved.state)) { + if (!STAGE_TRACKER_MERGE_SESSION_PR_KEY_RE.test(key) || typeof saved.state[key] !== 'boolean') continue; + state[key] = saved.state[key]; + } + for (const key of Object.keys(saved.delivered || {})) { + if (STAGE_TRACKER_MERGE_SESSION_PR_KEY_RE.test(key) && saved.delivered[key] === true) delivered[key] = true; + } + _stageTrackerMergeState = state; + _stageTrackerZapped = delivered; + } + } catch {} // Storage disabled/corrupt: keep the in-memory path. + } + stageTrackerNoteMerges(d); + try { sessionStorage.setItem(STAGE_TRACKER_MERGE_SESSION_KEY, JSON.stringify({ state: _stageTrackerMergeState, delivered: _stageTrackerZapped })); } catch {} + } + function stageTrackerNoteMerges(d) { const nowMs = Date.now(); _stageTrackerMergingHoldMs = stageTrackerMergingHoldMsOf(d, _stageTrackerMergingHoldMs); - const raw = stageTrackerCarryOpen(_stageTrackerMergeState, stageTrackerMergeState(d)); + const raw = stageTrackerCarryOpen(_stageTrackerMergeState, stageTrackerMergeState(d, _stageTrackerMergeState)); // The merge gate's hold (hivecommons/hive#15245, #15808) keeps a // row the payload dropped mid-merge on the board at "Merging" until // the merged fact arrives (then the merge is fresh at once) or the @@ -22182,7 +22219,7 @@

All labels

function stageTrackerMergingHoldRelease() { _stageTrackerMergingHoldTimer = 0; if (!_stageTracker || typeof _stageTracker !== 'object') return; - stageTrackerNoteMerges(_stageTracker); + stageTrackerReconcileMerges(_stageTracker); renderStageTracker(undefined, true); } @@ -22923,7 +22960,7 @@

All labels

if (b.rowKey) el.setAttribute('data-ham-row', b.rowKey); el.innerHTML = `
${num ? `#${esc(num)} ` : ''}merged${info.preview ? ' (test)' : ''}
${esc(t.text)}
`; box.appendChild(el); - while (box.children.length > STAGE_TRACKER_MERGE_BANNER_MAX) box.children[0].remove(); + while (box.children.length > STAGE_TRACKER_MERGE_BANNER_MAX) { toastCountdownCancel(box.children[0]); box.children[0].remove(); } toastCountdownBar(el, stageTrackerMergeBannerMs(), () => stageTrackerMergeBannerDismiss(el)); return el; }