diff --git a/changelog.d/fixed-merged-odometer-after-bee.md b/changelog.d/fixed-merged-odometer-after-bee.md new file mode 100644 index 0000000000..4fd583cd85 --- /dev/null +++ b/changelog.d/fixed-merged-odometer-after-bee.md @@ -0,0 +1 @@ +- Dashboard: the Merged pill's odometer now rolls only after the celebration bee lands — the day/week line, a total the server had already raised, and merges over the flight cap no longer move the drum while a glyph is in the air; several merges in one flight are a single roll to the final value after the last landing, reduced motion sets both at once (#15568). diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index 156fc26c7b..4cb8b77a78 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -1153,7 +1153,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). 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 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**. 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/stage_tracker_cues_test.go b/src/pkg/dashboard/stage_tracker_cues_test.go index ce4f30d495..6e02bd7b9b 100644 --- a/src/pkg/dashboard/stage_tracker_cues_test.go +++ b/src/pkg/dashboard/stage_tracker_cues_test.go @@ -310,6 +310,7 @@ func stageTrackerCelebrateJS(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerMergedLastParse"), jsFunc(t, html, "stageTrackerMergedLastLoad"), jsFunc(t, html, "stageTrackerMergedLastSave"), + jsFunc(t, html, "stageTrackerMergedInFlight"), jsFunc(t, html, "stageTrackerMergedCountDraw"), jsFunc(t, html, "stageTrackerMergedPopDraw"), jsFunc(t, html, "hamMergedToggle"), @@ -451,10 +452,10 @@ tick(0); assert.strictEqual(flights().length, 1, 'first glyph at once'); tick(STAGE_TRACKER_CELEBRATE_STAGGER_MS); assert.strictEqual(flights().length, 2, 'second 200 ms later'); tick(STAGE_TRACKER_CELEBRATE_STAGGER_MS); assert.strictEqual(flights().length, 3); tick(STAGE_TRACKER_CELEBRATE_STAGGER_MS); assert.strictEqual(flights().length, 3, 'capped at ' + STAGE_TRACKER_CELEBRATE_MAX_FLIGHTS + ' flights'); -assert.strictEqual(odoText(n), '2', 'the capped one bumped without flying'); +assert.strictEqual(odoText(n), '1', 'the capped ones wait for the glyphs in the air (issue 15568)'); assert.strictEqual(banners.children.length, STAGE_TRACKER_MERGE_BANNER_MAX, 'banners stack, oldest dropped past the cap'); tick(STAGE_TRACKER_CELEBRATE_FLY_MS * 1.5 + 1); -assert.strictEqual(flights().length, 0); assert.strictEqual(odoText(n), '6'); assert.deepStrictEqual(zaps, [], 'muted'); +assert.strictEqual(flights().length, 0); assert.strictEqual(odoText(n), '6', 'one draw to the final value once the last glyph lands'); assert.deepStrictEqual(zaps, [], 'muted'); tick(STAGE_TRACKER_MERGE_BANNER_MS); assert.strictEqual(banners.children.length, 0, 'banners leave on their own after ' + STAGE_TRACKER_MERGE_BANNER_MS + ' ms'); @@ -750,6 +751,78 @@ tick(STAGE_TRACKER_ODOMETER_MS + 100); assert.strictEqual(rolling(n2).length, 0) `) } +// TestStageTrackerOdometerAfterBeeNode (hivecommons/hive issue 15568): the +// drum rolls after the bee lands, never under it. While a glyph is in the +// air neither the total nor the day/week line moves — not for the payload +// that brought the merge (its today/week already rose), not for a later +// poll whose all_time the server raised, not for a merge over the flight +// cap. The glyph's animationend (or stageTrackerAfter's timer) draws once, +// to the final values, and zaps; several merges in one flight are one +// roll after the last landing. Reduced motion lands instantly; the first +// render sets the drum directly. +func TestStageTrackerOdometerAfterBeeNode(t *testing.T) { + html := indexHTML(t) + runStageTrackerRowActionsScript(t, stageTrackerCelebrateJS(t, html)+stageTrackerCelebrateFixture+` +const drum = e => e.children[0]; +const cols = e => drum(e).children.filter(c => c.classList.contains('ham-odo-col')); +const rolling = e => cols(e).filter(c => c.classList.contains('ham-odo-roll')); +const srv = (all, today, week, ...recent) => ({ all_time: all, today, total_7d: week, total_30d: week, recent: recent.map(x => ({ repo: 'o/r', number: x, merged_at: new Date(clock).toISOString() })) }); +// First render: the server's numbers, drawn at rest — no bee, no roll. +stageTrackerNoteMerges({ items: [{ repo: 'o/r', kind: 'pr', number: 1, stage: 50 }], merged: srv(9127, 3, 40) }); +assert.strictEqual(odoText(n), '9127'); assert.strictEqual(rolling(n).length, 0, 'first draw: set directly'); assert.strictEqual(odoText(sub), '3 today · 40 this week'); assert.strictEqual(rolling(sub).length, 0); +// #1 merges; the same payload carries the server's raised numbers. +panel.appendChild(row('o/r/pr#1')); +stageTrackerNoteMerges({ items: [], recently_merged: [{ repo: 'o/r', number: 1, merged_at: new Date(clock).toISOString() }], merged: srv(9128, 4, 41, 1) }); +tick(0); +assert.strictEqual(flights().length, 1, 'the bee is in the air'); +assert.strictEqual(odoText(n), '9127', 'the total waits for it'); assert.strictEqual(rolling(n).length, 0); +assert.strictEqual(odoText(sub), '3 today · 40 this week', 'so does the day/week line (it used to roll here)'); assert.strictEqual(rolling(sub).length, 0); +assert.deepStrictEqual(zaps, []); +// A poll mid-flight: the server counted a merge elsewhere too. Still nothing moves. +tick(STAGE_TRACKER_CELEBRATE_FLY_MS / 2); +stageTrackerNoteMerges({ items: [], merged: srv(9129, 5, 42, 1, 2) }); +assert.strictEqual(odoText(n), '9127', 'a raised server total does not roll under the bee'); assert.strictEqual(rolling(n).length, 0); assert.strictEqual(rolling(sub).length, 0); +assert.ok(chip.title.startsWith('Merged: 9128 all time'), 'the tooltip may already know: ' + chip.title); +// The bee lands (animationend): one roll, to the final numbers, and the zap. +flights()[0]._ev.animationend(); +assert.strictEqual(flights().length, 0); +assert.strictEqual(odoText(n), '9129', 'the landing draws the final total'); assert.strictEqual(rolling(n).length, 1, 'and rolls it — one roll 7 → 9, not two queued'); +assert.deepStrictEqual(cols(n)[3].children[0].children.slice(0, 3).map(c => c.textContent), ['7', '8', '9']); +assert.strictEqual(odoText(sub), '5 today · 42 this week'); assert.strictEqual(rolling(sub).length, 2); +assert.deepStrictEqual(zaps, [1], 'zap with the roll'); assert.ok(chip.classList.contains('cue-tick'), 'pop with the roll'); +assert.strictEqual(drum(n).style.props['--odo-ms'], STAGE_TRACKER_ODOMETER_MS + 'ms', 'the roll itself is unchanged'); +tick(STAGE_TRACKER_ODOMETER_MS + 100); assert.strictEqual(rolling(n).length, 0); +// Two merges in one flight: the first landing is folded into the second — one roll, one zap. +zaps.length = 0; chip.classList.remove('cue-tick'); +panel.appendChild(row('o/r/pr#3')); panel.appendChild(row('o/r/pr#4')); +stageTrackerNoteMerges({ items: [{ repo: 'o/r', kind: 'pr', number: 3, stage: 50 }, { repo: 'o/r', kind: 'pr', number: 4, stage: 50 }], merged: srv(9129, 5, 42, 1, 2) }); +stageTrackerNoteMerges({ items: [], recently_merged: [3, 4].map(x => ({ repo: 'o/r', number: x, merged_at: new Date(clock).toISOString() })), merged: srv(9131, 7, 44, 1, 2, 3, 4) }); +tick(STAGE_TRACKER_CELEBRATE_STAGGER_MS); +assert.strictEqual(flights().length, 2); +flights()[0]._ev.animationend(); +assert.strictEqual(flights().length, 1); assert.strictEqual(odoText(n), '9129', 'the first landing waits for the second bee'); assert.strictEqual(rolling(n).length, 0); assert.deepStrictEqual(zaps, [], 'no zap yet'); +flights()[0]._ev.animationend(); +assert.strictEqual(odoText(n), '9131', 'the last landing rolls straight to the final value'); assert.strictEqual(rolling(n).length, 2, 'tens and units'); assert.deepStrictEqual(zaps, [1], 'one zap'); +assert.deepStrictEqual(cols(n)[3].children[0].children.slice(0, 3).map(c => c.textContent), ['9', '0', '1'], 'one roll 9 → 1, not two queued'); +tick(STAGE_TRACKER_ODOMETER_MS + 100); +// No animationend at all: stageTrackerAfter's timer at the flight length lands it. +panel.appendChild(row('o/r/pr#5')); +stageTrackerNoteMerges({ items: [{ repo: 'o/r', kind: 'pr', number: 5, stage: 50 }], merged: srv(9131, 7, 44, 1, 2, 3, 4) }); +stageTrackerNoteMerges({ items: [], recently_merged: [{ repo: 'o/r', number: 5, merged_at: new Date(clock).toISOString() }], merged: srv(9132, 8, 45, 1, 2, 3, 4, 5) }); +tick(STAGE_TRACKER_CELEBRATE_FLY_MS); assert.strictEqual(odoText(n), '9131', 'still held at the flight\'s nominal end'); +tick(STAGE_TRACKER_CELEBRATE_FLY_MS / 2 + 1); assert.strictEqual(odoText(n), '9132', 'the fallback timer lands it'); assert.strictEqual(rolling(n).length, 1); +tick(STAGE_TRACKER_ODOMETER_MS + 100); +// Reduced motion: the glyph fades, the drum is set the instant it is gone. +reduced = true; panel.appendChild(row('o/r/pr#6')); +stageTrackerNoteMerges({ items: [{ repo: 'o/r', kind: 'pr', number: 6, stage: 50 }], merged: srv(9132, 8, 45, 1, 2, 3, 4, 5) }); +stageTrackerNoteMerges({ items: [], recently_merged: [{ repo: 'o/r', number: 6, merged_at: new Date(clock).toISOString() }], merged: srv(9133, 9, 46, 1, 2, 3, 4, 5, 6) }); +tick(0); assert.strictEqual(odoText(n), '9132', 'held while the glyph fades'); +flights()[0]._ev.animationend(); +assert.strictEqual(odoText(n), '9133'); assert.strictEqual(rolling(n).length, 0, 'reduced motion: set, not rolled'); +console.log('ok'); +`) +} + // TestStageTrackerFlightTargetNode: the operator's spec for the flight — // from the ✓ cell to the Merged chip when the chip is inside the viewport, // otherwise up and out through the top edge; the glyph is configurable; diff --git a/src/pkg/dashboard/static-src/js/tracker-merged.js b/src/pkg/dashboard/static-src/js/tracker-merged.js index 41473ce17d..bca14d786d 100644 --- a/src/pkg/dashboard/static-src/js/tracker-merged.js +++ b/src/pkg/dashboard/static-src/js/tracker-merged.js @@ -240,7 +240,14 @@ overlay that existed for 900 ms over plain text. The counter is now a drum at rest, always (stageTrackerOdometerRest / stageTrackerOdometerDraw): a wheel per digit, the day/week line the - same columns drawn plain; the pill's bee is --ham-merged-bee. */ + same columns drawn plain; the pill's bee is --ham-merged-bee. + Owner (2026-10-29, hivecommons/hive issue 15568): "the odometer + should roll only after the bee animation finishes so it looks + correlated" — the day/week line rolled on arrival, a total the + server had already raised rolled at once, and merges over the + flight cap bumped under other bees. Now a glyph in the air holds + the whole drum (stageTrackerMergedInFlight); the last landing draws + once, to the final numbers, and only then the roll (and the zap). */ const STAGE_TRACKER_CELEBRATE_KEY = 'hive.tracker.celebrate'; const STAGE_TRACKER_MERGED_LAST_KEY = 'hive.tracker.merged.last'; const STAGE_TRACKER_CELEBRATE_GLYPH_KEY = 'hive.tracker.celebrate_glyph'; @@ -558,6 +565,13 @@ function stageTrackerMergedLastSave(n, sub) { try { sessionStorage.setItem(STAGE_TRACKER_MERGED_LAST_KEY, JSON.stringify({ n: String(n), sub: String(sub) })); } catch {} } + // Stateful: whether a celebration glyph is in the air or about to be + // (stageTrackerCelebrateMerges staggers the launches; a merge is + // pending from the payload that brought it). The drum and the zap + // wait on this; the flight's own end — its animationend, or + // stageTrackerAfter's timer at STAGE_TRACKER_CELEBRATE_FLY_MS when the + // event never fires — is what clears it. + function stageTrackerMergedInFlight() { return _stageTrackerFlights > 0 || Object.keys(_stageTrackerCelebratePending).length > 0; } function stageTrackerMergedCountDraw(tick) { const chip = stageTrackerMergedChip(); const now = Date.now(); @@ -570,16 +584,25 @@ const n = chip.querySelector('.ham-merged-n'), sub = chip.querySelector('.ham-merged-sub'); // First draw of this page: roll up from what the tab showed before // the reload, when that is behind the number we have now. - if (n && n.getAttribute('data-odo-value') == null) { + const first = !n || n.getAttribute('data-odo-value') == null; + if (n && first) { const last = stageTrackerMergedLastLoad(); if (last) { stageTrackerOdometerSeed(n, last.n, shown); stageTrackerOdometerSeed(sub, last.sub, txt.sub); } } - stageTrackerOdometerSet(n, shown); - stageTrackerOdometerSet(sub, txt.sub, STAGE_TRACKER_ODOMETER_SUB_MS); - if (shown > 0) stageTrackerMergedLastSave(shown, txt.sub); + // A glyph in the air owns the drum (issue 15568): neither number + // moves under a flight — not the day/week line, not a total the + // server already raised, not a merge over the flight cap. The last + // landing (stageTrackerCelebrateTick) draws once, to the final + // values, so the bee lands and then the drum rolls. + const hold = !first && stageTrackerMergedInFlight(); + if (!hold) { + stageTrackerOdometerSet(n, shown); + stageTrackerOdometerSet(sub, txt.sub, STAGE_TRACKER_ODOMETER_SUB_MS); + if (shown > 0) stageTrackerMergedLastSave(shown, txt.sub); + } const title = txt.title.replace(/^Merged: \d+ all time/, `Merged: ${shown} all time`); if (chip.title !== title) chip.title = title; - if (tick) { + if (tick && !hold) { chip.classList.remove('cue-tick'); void chip.offsetWidth; stageTrackerTransient(chip, 'cue-tick', 320); const live = document.getElementById('activity-monitor-merged-live'); if (live) live.textContent = `Merged: ${shown} all time, ${txt.sub}`; @@ -622,7 +645,8 @@ if (pop && !pop.hidden) { hamMergedToggle(false); const chip = stageTrackerMergedChip(); if (chip && chip.focus) chip.focus(); } }); // The glyph has landed (or left the screen, or faded): count the PR, - // pop the chip, zap. + // pop the chip, zap — once the last glyph is down; a landing while + // others still fly is folded into theirs (issue 15568). function stageTrackerCelebrateTick(key, preview) { delete _stageTrackerCelebratePending[key]; const i = String(key).indexOf('/pr#'); @@ -632,7 +656,7 @@ if (!known && !_stageTrackerMerged.local[key]) _stageTrackerMerged.local[key] = { repo, number, at: Date.now(), title: _stageTrackerPRTitle[key] || '' }; } stageTrackerMergedCountDraw(true); - if (stageTrackerSoundGate()) stageTrackerPlayZap(1); + if (!stageTrackerMergedInFlight() && stageTrackerSoundGate()) stageTrackerPlayZap(1); } var _stageTrackerCelebrating = {}; var _stageTrackerFlights = 0; diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index ce1d887fe3..b8800b6057 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -20858,7 +20858,14 @@