diff --git a/changelog.d/added-merge-banner-time-and-clock-format.md b/changelog.d/added-merge-banner-time-and-clock-format.md new file mode 100644 index 0000000000..e85079ff04 --- /dev/null +++ b/changelog.d/added-merge-banner-time-and-clock-format.md @@ -0,0 +1 @@ +- The Activity monitor's merge banner now shows the date and time it merged ("11/17 4:12 PM EST") on its head line, in the Display timezone. The time used to sit at the end of the title line, where a long title's ellipsis hid it, and it was the moment the tab noticed the merge rather than the ledger's `merged_at`. Settings → Appearance gains a **Time format** choice (browser locale, 12-hour or 24-hour) that applies to every dashboard time. diff --git a/src/docs/architecture.md b/src/docs/architecture.md index e38933c56a..0194801daa 100644 --- a/src/docs/architecture.md +++ b/src/docs/architecture.md @@ -434,7 +434,9 @@ flowchart LR `nextKickAt`) and formatted in the browser through the shared display-timezone helper. Users can choose **Settings → Appearance → Display timezone**: browser local time (default), the hive server timezone from `/api/status`, - UTC, or an IANA zone. + UTC, or an IANA zone. **Time format** beside it picks the clock for every + dashboard time: the browser locale (default), 12-hour, or 24-hour. Both are + kept per browser in `localStorage`. - `/api/audit` — recent audit entries for read-write users: dashboard config changes, logins, GitHub App setup changes, and agent lifecycle events such as start, stop, launch failure, pause/resume/kick, add/remove, backend changes, and model changes. Entries are kept in memory and, when `/data` exists, appended to `/data/audit.jsonl` with lumberjack rotation (5 MB files, 3 backups, 90 days). - The machine-readable dashboard API reference is [dashboard/openapi.json](../../dashboard/openapi.json). - `/api/events` — Server-Sent Events; the dashboard is pushed a fresh snapshot on diff --git a/src/docs/dashboard-sections/activity-monitor.md b/src/docs/dashboard-sections/activity-monitor.md index dc4db7b00c..2a8f0d6132 100644 --- a/src/docs/dashboard-sections/activity-monitor.md +++ b/src/docs/dashboard-sections/activity-monitor.md @@ -595,7 +595,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 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. +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 by 🐝 hive · 11/17 4:12 PM EST — fix: enable bulk delegation… (adopted, by hive)* — 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. The date and time sit on the head line, where a long title cannot clip them; they are the ledger's `merged_at` when it has the PR (otherwise when the tab noticed the merge), in the Display timezone and Time format chosen under Settings → Appearance. A banner pushed out of the stack stops its countdown. Each banner has **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/dashboard_clock_format_test.go b/src/pkg/dashboard/dashboard_clock_format_test.go new file mode 100644 index 0000000000..c527a96946 --- /dev/null +++ b/src/pkg/dashboard/dashboard_clock_format_test.go @@ -0,0 +1,94 @@ +package dashboard + +import ( + "os/exec" + "strings" + "testing" +) + +func TestDashboardClockFormatControlExists(t *testing.T) { + html := indexHTML(t) + for _, want := range []string{ + "const DASHBOARD_CLOCK_STORAGE_KEY = 'hive-dashboard-clock-format';", + "id=\"dashboard-clock-select\"", + "data-change-action=\"setDashboardClockPreference\"", + "function setDashboardClockPreference(", + "Browser locale (default)", + } { + if !strings.Contains(html, want) { + t.Fatalf("static/index.html missing clock format marker %q", want) + } + } +} + +// TestDashboardClockFormatAndMergeBannerTime runs the shipped date helpers +// (not jsFunc's UTC stand-ins) in America/New_York: the Time format choice +// reaches every formatted time, and the merge banner carries the date and +// time on its head instead of at the end of the clipped title line. +func TestDashboardClockFormatAndMergeBannerTime(t *testing.T) { + node, err := exec.LookPath("node") + if err != nil { + t.Skip("node unavailable: clock format helpers were not executed") + } + html := indexHTML(t) + fn := func(name string) string { + src, ok := jsFuncOptional(html, name) + if !ok { + t.Fatalf("index.html does not define %s()", name) + } + return src + } + script := strings.Join([]string{ + "const assert = require('node:assert/strict');", + // The helpers format in the runner's default locale; pin en-US so + // an en-GB runner's "4:12 pm GMT-5" does not fail the wording. + "const RealDTF = Intl.DateTimeFormat; Intl.DateTimeFormat = function (locales, opts) { return new RealDTF(locales && locales.length ? locales : 'en-US', opts); };", + "const store ={ 'hive-dashboard-display-timezone': 'America/New_York' };", + "const localStorage = { getItem: k => (k in store ? store[k] : null) };", + jsConstLine(t, html, "DASHBOARD_TIMEZONE_STORAGE_KEY"), + jsConstLine(t, html, "DASHBOARD_TIMEZONE_BROWSER"), + jsConstLine(t, html, "DASHBOARD_TIMEZONE_SERVER"), + jsConstLine(t, html, "DASHBOARD_CLOCK_STORAGE_KEY"), + jsConstLine(t, html, "_dashboardDateFormatters"), + "let _dashboardServerTimeZone = '';", + fn("validDashboardTimeZone"), + fn("browserDashboardTimeZone"), + fn("dashboardTimeZonePreference"), + fn("dashboardClockPreference"), + fn("selectedDashboardTimeZone"), + fn("dashboardDateFormatter"), + fn("formatDashboardDateTime"), + fn("stageTrackerMergedByText"), + fn("stageTrackerMergerText"), + fn("stageTrackerMergeBannerNumber"), + fn("stageTrackerMergeBannerText"), + ` +const plain = s => String(s).replace(/[  ]/g, ' '); +const at = Date.UTC(2026, 10, 17, 21, 12); // 4:12 PM EST +const clock = v => { if (v) store[DASHBOARD_CLOCK_STORAGE_KEY] = v; else delete store[DASHBOARD_CLOCK_STORAGE_KEY]; }; + +clock(''); +assert.equal(dashboardClockPreference(), ''); +assert.equal(formatDashboardDateTime(at), '11/17 4:12 PM EST', 'default keeps the caller format'); +const b = { repo: 'o/r', number: 5, title: 'fix: five', lane: 'hive', merged_by: 'hive', at }; +const t = stageTrackerMergeBannerText(b, 0); +assert.equal(t.when, '11/17 4:12 PM EST', 'the banner names date and local time'); +assert.equal(t.meta, '(hive, by hive)', 'the clipped title line no longer carries the time'); +assert.equal(t.text, 'fix: five (hive, by hive) · merged 11/17 4:12 PM EST'); + +clock('24'); +assert.equal(formatDashboardDateTime(at), '11/17 16:12 EST', '24-hour overrides the caller hour12'); +assert.equal(stageTrackerMergeBannerText(b, 0).when, '11/17 16:12 EST'); +assert.match(formatDashboardDateTime(Date.UTC(2026, 10, 18, 5, 0)), /^11\/18 0?0:00 EST$/, 'midnight is 00:00, never 24:00'); + +clock('12'); +assert.equal(plain(formatDashboardDateTime(at, { hour: '2-digit', minute: '2-digit', hourCycle: 'h23' })), '04:12 PM', '12-hour overrides a caller 24-hour cycle'); + +clock('bogus'); +assert.equal(dashboardClockPreference(), '', 'an unknown stored value is ignored'); +`, + }, "\n") + if out, err := runNodeStdin(node, script); err != nil { + t.Fatalf("node: %v\n%s", err, out) + } +} diff --git a/src/pkg/dashboard/dashboard_idle_work_test.go b/src/pkg/dashboard/dashboard_idle_work_test.go index 3483b80e30..4302e4d1a5 100644 --- a/src/pkg/dashboard/dashboard_idle_work_test.go +++ b/src/pkg/dashboard/dashboard_idle_work_test.go @@ -28,10 +28,10 @@ function clearInterval(id) { timers.delete(id); } function visibility(hidden) { document.hidden = hidden; listeners.visibilitychange(); } ` script += jsVarLine(t, html, "DASHBOARD_INTERVALS") + "\n" + html[start:end] - for _, name := range []string{"_dashboardDateFormatters", "DASHBOARD_TIMEZONE_STORAGE_KEY", "DASHBOARD_TIMEZONE_BROWSER", "DASHBOARD_TIMEZONE_SERVER", "_dashboardServerTimeZone"} { + for _, name := range []string{"_dashboardDateFormatters", "DASHBOARD_TIMEZONE_STORAGE_KEY", "DASHBOARD_TIMEZONE_BROWSER", "DASHBOARD_TIMEZONE_SERVER", "DASHBOARD_CLOCK_STORAGE_KEY", "_dashboardServerTimeZone"} { script += jsVarLine(t, html, name) + "\n" } - for _, name := range []string{"dashboardDateFormatter", "selectedDashboardTimeZone", "dashboardTimeZonePreference", "validDashboardTimeZone", "browserDashboardTimeZone", "animateSparklinePart"} { + for _, name := range []string{"dashboardDateFormatter", "selectedDashboardTimeZone", "dashboardTimeZonePreference", "dashboardClockPreference", "validDashboardTimeZone", "browserDashboardTimeZone", "animateSparklinePart"} { script += jsFunc(t, html, name) + "\n" } script += ` diff --git a/src/pkg/dashboard/stage_tracker_cues_test.go b/src/pkg/dashboard/stage_tracker_cues_test.go index 0aeee73a5a..869b3ad293 100644 --- a/src/pkg/dashboard/stage_tracker_cues_test.go +++ b/src/pkg/dashboard/stage_tracker_cues_test.go @@ -674,7 +674,9 @@ assert.strictEqual(odoText(n), '33', 'never backwards'); stageTrackerNoteMerges({ items: [], merged: merged(34, [rec(1, 'hive', 'feat: one'), rec(31, 'clubanderson'), rec(30)]) }); assert.strictEqual(odoText(n), '33', 'held back while the glyph flies'); tick(0); assert.strictEqual(flights().length, 1); -assert.ok(banners.children[0].innerHTML.includes('feat: one (hive, by hive, '), 'the banner carries the ledger title and merger: ' + banners.children[0].innerHTML); +assert.ok(banners.children[0].innerHTML.includes('feat: one (hive, by hive) · merged '), 'the banner carries the ledger title and merger: ' + banners.children[0].innerHTML); +// The time is the ledger's merged_at, not the poll that noticed it, and rides the head line. +assert.ok(banners.children[0].innerHTML.includes('