@celestia-island/hikari 0.55.440 → 0.55.441

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.440",
3
+ "version": "0.55.441",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Hikari UI library, Vue 3 runtime — one design system for Vue 3 and Rust/WASM applications",
@@ -22,6 +22,16 @@
22
22
  opacity var(--duration-normal, 0.3s) ease-in,
23
23
  transform var(--duration-normal, 0.3s) cubic-bezier(0.5, 0, 0.75, 0);
24
24
  position: absolute;
25
+ /* A dying row must not take clicks (or a drag) while it fades: the
26
+ bell's rows carry copy / dismiss / restore buttons — the first
27
+ IN-LIBRARY pop consumer with interactive rows (chest's WorkspaceModal
28
+ already runs `pop` with clickable rows downstream, and gains this
29
+ dead-end for the fade window). The
30
+ primitive's own pin sets `inert` too, but only when layout metrics
31
+ exist — this is the CSS belt that still dead-ends a tap in a
32
+ non-layout environment or when the pin skipped (same relationship
33
+ the surface variant documents below). */
34
+ pointer-events: none;
25
35
  }
26
36
 
27
37
  .hk-list-pop-enter-from {
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Compiled-CSS pins for the pop variant's LEAVE rule (2026-11-20).
3
+ *
4
+ * `HkListTransition.scss` is compiled twice (Vue + the Rust-side
5
+ * vue-mirror) and nothing read the sheet, so a revert of the two
6
+ * properties below stayed green repo-wide (2026-11-20 review, mutation
7
+ * M9: the whole 6616-test suite passed with the rule deleted; only the
8
+ * mirror-drift check noticed, and a two-copy edit defeats that).
9
+ *
10
+ * Pinned like its sibling variant (HkModalBreadcrumb.motion.contract
11
+ * .test.ts pins `.hk-list-surface-leave-active` the same way):
12
+ *
13
+ * - a dying row takes no clicks. The primitive's `inert` pin covers it
14
+ * only when layout metrics exist, so the CSS belt is what still
15
+ * dead-ends a tap in a non-layout environment or when the pin
16
+ * skipped. The bell is the first `pop` consumer whose rows carry
17
+ * buttons (copy / dismiss / restore).
18
+ * - reduced motion really drops the choreography (house pattern).
19
+ */
20
+ import { dirname, join } from "node:path";
21
+ import { fileURLToPath } from "node:url";
22
+
23
+ import { compile } from "sass";
24
+ import { describe, expect, it } from "vitest";
25
+
26
+ const here = dirname(fileURLToPath(import.meta.url));
27
+ const css = compile(join(here, "HkListTransition.scss"), {
28
+ loadPaths: [here, join(here, "..", "styles")],
29
+ style: "expanded",
30
+ }).css;
31
+
32
+ /** Body of the first top-level `selector { … }` block. */
33
+ function rule(cssText: string, selector: string): string {
34
+ const start = cssText.indexOf(`${selector} {`);
35
+ if (start === -1) return "";
36
+ const open = cssText.indexOf("{", start);
37
+ let depth = 0;
38
+ for (let i = open; i < cssText.length; i++) {
39
+ if (cssText[i] === "{") depth += 1;
40
+ else if (cssText[i] === "}") {
41
+ depth -= 1;
42
+ if (depth === 0) return cssText.slice(open + 1, i);
43
+ }
44
+ }
45
+ return "";
46
+ }
47
+
48
+ /** Top-level `@media` block body (brace matched). */
49
+ function mediaBlock(cssText: string, headPrefix: string): string {
50
+ const start = cssText.indexOf(headPrefix);
51
+ if (start === -1) return "";
52
+ const open = cssText.indexOf("{", start);
53
+ let depth = 0;
54
+ for (let i = open; i < cssText.length; i++) {
55
+ if (cssText[i] === "{") depth += 1;
56
+ else if (cssText[i] === "}") {
57
+ depth -= 1;
58
+ if (depth === 0) return cssText.slice(open + 1, i);
59
+ }
60
+ }
61
+ return "";
62
+ }
63
+
64
+ describe("HkListTransition pop variant", () => {
65
+ it("the leaving ghost is out of flow and takes no clicks", () => {
66
+ const leave = rule(css, ".hk-list-pop-leave-active");
67
+ expect(leave, "the pop leave-active rule compiles").not.toBe("");
68
+ // The primitive pins the ghost's box from its pre-patch offsets while
69
+ // this rule lifts it out of flow — the pin's premise.
70
+ expect(leave).toContain("position: absolute");
71
+ // A fading row must not swallow a click meant for what is underneath
72
+ // it (or for the row that just slid up under the cursor).
73
+ expect(leave).toContain("pointer-events: none");
74
+ });
75
+
76
+ it("reduced motion collapses every variant's leave", () => {
77
+ const media = mediaBlock(css, "@media (prefers-reduced-motion: reduce)");
78
+ expect(media, "the reduced-motion block compiles").not.toBe("");
79
+ for (const variant of ["pop", "slide", "fade", "grow", "reveal", "surface"]) {
80
+ expect(media, `${variant} leave collapses`).toContain(
81
+ `.hk-list-${variant}-leave-active`,
82
+ );
83
+ }
84
+ });
85
+ });
@@ -56,6 +56,18 @@ describe("HkNotificationBell composition contract", () => {
56
56
  expect(src).not.toContain("useToast");
57
57
  });
58
58
 
59
+ it("the hold timer is released when the bell goes away", () => {
60
+ const src = body();
61
+ // Round-5 finding, M10: dropping the unmount cleanup stayed green
62
+ // repo-wide. A source pin (the same convention the rest of this file
63
+ // uses): the timer-queue cannot isolate OUR timer from the primitive's
64
+ // transition report, so the structural fact is pinned here, and the
65
+ // behaviour it protects is "no write into a dead instance".
66
+ const unmountPath = src.slice(src.indexOf("onUnmounted("));
67
+ expect(unmountPath, "an unmount hook exists").not.toBe("");
68
+ expect(unmountPath).toContain("clearTimeout(holdTimer)");
69
+ });
70
+
59
71
  it("the journal is the ONLY data source", () => {
60
72
  const src = body();
61
73
  expect(src).toContain("useNotificationCenter");
@@ -63,4 +75,38 @@ describe("HkNotificationBell composition contract", () => {
63
75
  expect(src).not.toContain("sessionStorage");
64
76
  expect(src).not.toContain("localStorage");
65
77
  });
78
+
79
+ it("row add/remove animates through HkListTransition on the animation context", () => {
80
+ const src = body();
81
+ // The rows ride the library's own list choreography primitive — the
82
+ // `pop` variant with FLIP moves — which reports every enter/leave
83
+ // batch to the runtime animation bus itself. No second transition
84
+ // implementation may grow beside it (the same rule that keeps a
85
+ // second notification UI from growing beside the bell).
86
+ //
87
+ // The props are pinned ON THE PRIMITIVE'S OWN OPENING TAG, not as bare
88
+ // substrings: a `toMatch(/\bmove\b/)` over the whole file is satisfied
89
+ // by any unrelated token, and a file-level `not.toContain("appear")`
90
+ // would fail a legitimate `appear={false}` (2026-11-20 review).
91
+ const usage = src.match(/<HkListTransition[\s\S]*?>/);
92
+ expect(usage, "the primitive is used here").toBeTruthy();
93
+ const tag = usage![0];
94
+ expect(tag).toContain('tag="ul"');
95
+ expect(tag).toContain('variant="pop"');
96
+ expect(tag, "FLIP moves for the surviving rows").toMatch(/\bmove\b/);
97
+ // `appear` would replay the whole list's entrance on every open.
98
+ // (jsdom applies no stylesheets, so FLIP/appear have no behavioural
99
+ // observable — this is a deliberate source-level pin, backed by the
100
+ // behaviour test "opening the panel does NOT replay the list's
101
+ // entrance".)
102
+ expect(tag).not.toMatch(/\bappear\b/);
103
+ expect(src).not.toContain("TransitionGroup");
104
+ expect(src).not.toContain("useSurfaceTransition");
105
+ // The list wrap outlives the empty swap — a torn-down group cancels
106
+ // its ghosts mid-flight, so the empty caption must live INSIDE the
107
+ // wrap (after the group), not in a branch that replaces it.
108
+ expect(src.indexOf("hk-notification-center__list-wrap")).toBeLessThan(
109
+ src.indexOf("hk-notification-center__empty"),
110
+ );
111
+ });
66
112
  });
@@ -0,0 +1,127 @@
1
+ import { afterEach, describe, expect, it, vi } from "vitest";
2
+ import { createApp, h, nextTick } from "vue";
3
+
4
+ /**
5
+ * The overlay-scrollbar ATTACH TARGET (2026-11-20 review, mutation M5).
6
+ *
7
+ * The bell owns the desktop flyout's overlay scrollbar because the list
8
+ * keeps native overflow MECHANICS while painting no native bar
9
+ * (`scrollbar-width: none`) — without the engine the list scrolls
10
+ * invisibly (user report 2026-11-19). The engine binds a `scroll`
11
+ * listener and reads/writes `scrollTop` on the element it is given, so
12
+ * attaching to anything but the SCROLLER (the `ul`) yields a thumb bound
13
+ * to a dead target: opening the panel still passes the other test (the
14
+ * tracks render inside the wrap either way), yet tall lists scroll
15
+ * invisibly again.
16
+ *
17
+ * That regression survived the whole behaviour suite, so this file pins
18
+ * the argument itself: the first attach call must receive the list
19
+ * element, with the wrap still riding as the track host.
20
+ *
21
+ * (Repo test convention: raw createApp + document queries, no
22
+ * @vue/test-utils dependency.)
23
+ */
24
+
25
+ const attachSpy = vi.fn();
26
+
27
+ vi.mock("../composables/useOverlayScrollbar", async (importOriginal) => {
28
+ const actual = await importOriginal<typeof import("../composables/useOverlayScrollbar")>();
29
+ return {
30
+ ...actual,
31
+ attachOverlayScrollbars: (el: HTMLElement, opts?: { axis?: string; host?: HTMLElement }) => {
32
+ attachSpy(el, opts);
33
+ return actual.attachOverlayScrollbars(el, opts as never);
34
+ },
35
+ };
36
+ });
37
+
38
+ const { default: HkNotificationBell } = await import("./HkNotificationBell");
39
+ const { recordNotification, resetNotifications } = await import("../runtime/notificationCenter");
40
+ const { setLocale } = await import("../i18n/context");
41
+
42
+ const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
43
+
44
+ function mountBell() {
45
+ const container = document.createElement("div");
46
+ document.body.appendChild(container);
47
+ const app = createApp({ render: () => h(HkNotificationBell) });
48
+ mounts.push({ app, container });
49
+ app.mount(container);
50
+ return container;
51
+ }
52
+
53
+ async function settle() {
54
+ await nextTick();
55
+ await new Promise((r) => setTimeout(r, 80));
56
+ await nextTick();
57
+ }
58
+
59
+ afterEach(() => {
60
+ for (const { app, container } of mounts.splice(0)) {
61
+ app.unmount();
62
+ container.remove();
63
+ }
64
+ document.body
65
+ .querySelectorAll(".hk-popover-scrim, .hk-popover-panel")
66
+ .forEach((el) => el.remove());
67
+ resetNotifications();
68
+ attachSpy.mockClear();
69
+ });
70
+
71
+ describe("bell overlay scrollbar wiring", () => {
72
+ it("attaches to the scrolling list, with the wrap as the track host", async () => {
73
+ await setLocale("en");
74
+ for (let i = 0; i < 12; i++) {
75
+ recordNotification({ id: `t:${i}`, kind: "toast", tone: "error", title: `row ${i}` });
76
+ }
77
+ mountBell();
78
+ await settle();
79
+ document
80
+ .querySelector<HTMLButtonElement>(".hk-notification-bell .hk-icon-button")!
81
+ .dispatchEvent(new MouseEvent("click", { bubbles: true }));
82
+ await settle();
83
+
84
+ expect(attachSpy, "the engine was attached").toHaveBeenCalled();
85
+ const [target, opts] = attachSpy.mock.calls[0];
86
+ // The SCROLLER, not the wrapper: the wrapper merely wraps the viewport
87
+ // and never scrolls — binding the thumb there is the invisible-scroll
88
+ // regression this pin exists for.
89
+ const list = document.querySelector(".hk-notification-center__list")!;
90
+ const wrap = document.querySelector(".hk-notification-center__list-wrap")!;
91
+ expect(target).toBe(list);
92
+ expect((target as HTMLElement).classList.contains("hk-notification-center__list")).toBe(true);
93
+ expect(target).not.toBe(wrap);
94
+ expect(opts?.host ?? null).toBe(wrap);
95
+ });
96
+
97
+ it("keeps ONE engine handle across journal changes on the open panel", async () => {
98
+ // The list stays mounted now (the entry/exit choreography needs it), so
99
+ // the engine must be armed once per open and UPDATED as content moves —
100
+ // a second attach per record would leak a listener set per row.
101
+ await setLocale("en");
102
+ mountBell();
103
+ await settle();
104
+ const bell = () =>
105
+ document.querySelector<HTMLButtonElement>(".hk-notification-bell .hk-icon-button")!;
106
+ bell().dispatchEvent(new MouseEvent("click", { bubbles: true }));
107
+ await settle();
108
+ expect(attachSpy, "the open panel arms the engine even when row-less").toHaveBeenCalledTimes(1);
109
+ const list = document.querySelector(".hk-notification-center__list");
110
+ expect(attachSpy.mock.calls[0][0]).toBe(list);
111
+
112
+ recordNotification({ id: "late", kind: "toast", tone: "error", title: "late arrival" });
113
+ await settle();
114
+ expect(attachSpy, "content changes update the handle, never re-arm it").toHaveBeenCalledTimes(1);
115
+ expect(attachSpy.mock.calls[0][0]).toBe(document.querySelector(".hk-notification-center__list"));
116
+
117
+ // A close/open cycle re-arms against the CURRENT element.
118
+ bell().dispatchEvent(new MouseEvent("click", { bubbles: true }));
119
+ await settle();
120
+ bell().dispatchEvent(new MouseEvent("click", { bubbles: true }));
121
+ await settle();
122
+ expect(attachSpy).toHaveBeenCalledTimes(2);
123
+ expect(attachSpy.mock.calls[1][0]).toBe(
124
+ document.querySelector(".hk-notification-center__list"),
125
+ );
126
+ });
127
+ });
@@ -50,6 +50,18 @@
50
50
  max-height: min(24rem, 55vh);
51
51
  overflow-y: auto;
52
52
  overscroll-behavior: contain;
53
+ /* The list is ALSO the containing block for HkListTransition's leaving
54
+ ghosts (rows leaving under the `pop` variant are lifted to
55
+ `position: absolute` and pinned to their pre-patch box by
56
+ pinLeaveGeometry). Without this the nearest positioned ancestor is
57
+ the track-hosting wrapper OUTSIDE the scroller: the ghost then
58
+ escapes the scroll clip and is pinned in LAYOUT coordinates while
59
+ the viewport is scrolled — a row dismissed from a scrolled list
60
+ painted hundreds of pixels away from where the user saw it (real
61
+ Chrome measurement, 2026-11-20: 629px drift on a 98px viewport).
62
+ With `relative` the ghost lives inside the scroller, is clipped by
63
+ it, and moves with the content. */
64
+ position: relative;
53
65
  /* Native-scrollbar invariant (nativeScrollbar.contract.test.ts): the
54
66
  list keeps native overflow mechanics, the platform bar never
55
67
  paints — overlay scrollbars ride the popup chrome instead. */
@@ -114,4 +114,19 @@ describe("HkNotificationBell scss contract", () => {
114
114
  scss.match(/--hi-icon-button-icon-color:\s*rgb\(var\(--color-text\) \/ 85%\)/g) ?? [],
115
115
  ).toHaveLength(1);
116
116
  });
117
+
118
+ it("the list is its own containing block for the leaving ghosts", () => {
119
+ // HkListTransition lifts a leaving row to `position: absolute` and pins
120
+ // it to its pre-patch box. If the nearest positioned ancestor is the
121
+ // WRAP (outside the scroller), the ghost escapes the list's clip and is
122
+ // pinned in LAYOUT coordinates while the viewport is scrolled — real
123
+ // Chrome measurement (2026-11-20): a row dismissed from a scrolled list
124
+ // painted 629px away from where the user saw it, i.e. no visible fade.
125
+ // `position: relative` makes the ghost live inside the scroller, where
126
+ // it is clipped and moves with the content.
127
+ const listBlock = scss.match(/^\.hk-notification-center__list \{([^}]*)\}/m);
128
+ expect(listBlock, "the list rule exists").toBeTruthy();
129
+ expect(listBlock![1]).toContain("position: relative");
130
+ expect(listBlock![1], "and it stays the scroll container").toContain("overflow-y: auto");
131
+ });
117
132
  });
@@ -5,6 +5,8 @@ import HkNotificationBell from "./HkNotificationBell";
5
5
  import { recordNotification, resetNotifications, useNotificationCenter } from "../runtime/notificationCenter";
6
6
  import { raiseEmergencyAlert, resetEmergencyAlerts, snoozeEmergencyAlert } from "../runtime/useEmergencyAlert";
7
7
  import { setLocale } from "../i18n/context";
8
+ import { setReducedMotion } from "../runtime/animationBus";
9
+ import { setCssAnimationsEnabled } from "../animation/registerAnimations";
8
10
 
9
11
  /**
10
12
  * HkNotificationBell behavior tests:
@@ -19,6 +21,11 @@ import { setLocale } from "../i18n/context";
19
21
  * - a snoozed emergency entry shows the Hidden state chip and its
20
22
  * restore button unsnoozes through the journal's resummon path
21
23
  * - Clear all (icon + label) empties the journal
24
+ * - row add/remove animates through HkListTransition (user direction
25
+ * 2026-11-20): a dismissed row lingers as a pinned pop ghost and then
26
+ * resolves; clear-all fades every row while the empty caption coexists;
27
+ * a record landing on the open panel pops in; the foot keeps its
28
+ * empty-hides rule
22
29
  *
23
30
  * (Repo test convention: raw createApp + document queries, no
24
31
  * @vue/test-utils dependency.)
@@ -37,7 +44,10 @@ function mountBell() {
37
44
 
38
45
  async function settle() {
39
46
  await nextTick();
40
- await new Promise((r) => setTimeout(r, 30));
47
+ // 80ms: list rows now resolve their enter/leave through HkListTransition,
48
+ // which removes a leaving element only after Vue's double-rAF class swap
49
+ // plus the (zero-duration in jsdom) finish — 30ms raced that window.
50
+ await new Promise((r) => setTimeout(r, 80));
41
51
  await nextTick();
42
52
  }
43
53
 
@@ -133,6 +143,10 @@ describe("panel rows", () => {
133
143
  expect(row.querySelector(".hk-notification-row__detail-text")?.textContent).toBe("充值后立即可用");
134
144
  expect(row.querySelector(".hk-notification-row__code")?.textContent).toBe("QUOTA_EXHAUSTED");
135
145
  expect(row.querySelector(".hk-notification-row__time")).toBeTruthy();
146
+ // The empty caption is gated on a row-less journal — with rows on
147
+ // screen it must not render beside them (the persistent wrap makes
148
+ // "always render it" a one-character mutation away).
149
+ expect(document.querySelector(".hk-notification-center__empty")).toBeNull();
136
150
  });
137
151
 
138
152
  it("error AND warning rows carry the toast's copy button; the payload is the FULL record", async () => {
@@ -510,10 +524,11 @@ describe("panel rows", () => {
510
524
  await settle();
511
525
  expect(document.querySelector(".hk-notification-center__list-wrap")).toBeNull();
512
526
 
513
- // Round-2 hole: with the panel OPEN on the empty state the list is
514
- // not mounted — a record landing NOW mounts it fresh. The signature
515
- // watcher must attach the engine to the NEW viewport (an update() on
516
- // a stale handle would leave it scrolling invisibly).
527
+ // Reopening on a row-less journal (the list stays mounted now — see
528
+ // the motion section): the engine must (re)attach to the CURRENT
529
+ // viewport. An update() on the stale handle would leave the list
530
+ // scrolling invisibly again. (The attach TARGET itself is pinned in
531
+ // HkNotificationBell.scrollTarget.test.tsx.)
517
532
  resetNotifications();
518
533
  bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
519
534
  await settle();
@@ -521,8 +536,14 @@ describe("panel rows", () => {
521
536
  recordNotification({ id: "late", kind: "toast", tone: "error", title: "late arrival" });
522
537
  await settle();
523
538
  const wrap2 = document.querySelector(".hk-notification-center__list-wrap");
524
- expect(wrap2, "the list mounts under the open panel").toBeTruthy();
539
+ expect(wrap2, "the list is mounted under the open panel").toBeTruthy();
525
540
  expect(wrap2!.querySelectorAll(".hk-scrollbar-track").length).toBeGreaterThan(0);
541
+ // The semantics the persistent wrap must never cost us (2026-11-20
542
+ // review M7): `list-style: none` strips list semantics in
543
+ // Safari/VoiceOver, so the explicit role is load-bearing.
544
+ expect(
545
+ document.querySelector(".hk-notification-center__list")!.getAttribute("role"),
546
+ ).toBe("list");
526
547
  });
527
548
 
528
549
  it("rows sort newest-first and Clear all empties the journal", async () => {
@@ -555,4 +576,388 @@ describe("panel rows", () => {
555
576
  expect(document.querySelector(".hk-notification-center__empty")).toBeTruthy();
556
577
  expect(rows()).toHaveLength(0);
557
578
  });
579
+
580
+ // ── row motion (user direction 2026-11-20) ──────────────────────────
581
+ // Rows ride HkListTransition: add pops in, remove fades out as a pinned
582
+ // ghost while siblings FLIP-glide. jsdom applies no stylesheets, so the
583
+ // classes + the primitive's own inline pins ARE the observable contract.
584
+
585
+ it("a dismissed row fades out through the list transition, then resolves", async () => {
586
+ await setLocale("en");
587
+ recordNotification({ id: "a", kind: "toast", tone: "error", title: "keep me" });
588
+ recordNotification({ id: "b", kind: "toast", tone: "warning", title: "drop me" });
589
+ mountBell();
590
+ await settle();
591
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
592
+ await settle();
593
+ const dismiss = rows()
594
+ .find((r) => r.textContent?.includes("drop me"))!
595
+ .querySelector<HTMLButtonElement>(
596
+ '.hk-notification-row__actions .hk-icon-button[aria-label="Dismiss"]',
597
+ )!;
598
+ dismiss.dispatchEvent(new MouseEvent("click", { bubbles: true }));
599
+ await nextTick();
600
+ // The leaving row rides HkListTransition's pop leave (the ghost
601
+ // pin/absolute-lift branch is geometry-gated and covered by the
602
+ // primitive's own stubbed-layout suite; jsdom has no layout, so the
603
+ // observable contract here is the leave machinery itself).
604
+ const ghost = rows().find((r) => r.textContent?.includes("drop me"));
605
+ expect(ghost, "the ghost lingers for the fade").toBeTruthy();
606
+ expect(ghost!.className).toContain("hk-list-pop-leave-active");
607
+ await settle();
608
+ expect(rows(), "the ghost resolved, one row remains").toHaveLength(1);
609
+ expect(rows()[0].textContent).toContain("keep me");
610
+ });
611
+
612
+ it("motion-collapsed hosts skip the hold and get the caption at once", async () => {
613
+ // Round-5/round-6 findings: deleting the skip stayed green repo-wide.
614
+ // All three arms must be exercised INDEPENDENTLY — `setReducedMotion`
615
+ // also flips the CSS attribute (animationBus.ts), so a "bus parked"
616
+ // case alone never reaches `isAnimationParked()`, and the media query
617
+ // arm is a separate host class (a host that never wired
618
+ // useReducedMotion at boot).
619
+ await setLocale("en");
620
+ const originalMatchMedia = window.matchMedia;
621
+ let mmMatches = false;
622
+ window.matchMedia = ((query: string) => ({
623
+ matches: mmMatches && query.includes("prefers-reduced-motion"),
624
+ media: query,
625
+ onchange: null,
626
+ addEventListener: () => {},
627
+ removeEventListener: () => {},
628
+ addListener: () => {},
629
+ removeListener: () => {},
630
+ dispatchEvent: () => false,
631
+ })) as unknown as typeof window.matchMedia;
632
+ const cases: Array<[string, () => void, () => void]> = [
633
+ ["bus parked", () => setReducedMotion(true), () => setReducedMotion(false)],
634
+ [
635
+ "global CSS switch off",
636
+ () => setCssAnimationsEnabled(false),
637
+ () => setCssAnimationsEnabled(true),
638
+ ],
639
+ // The two flags can diverge: a host re-enabling the attribute while
640
+ // the bus stays parked reaches the park read on its own.
641
+ [
642
+ "bus parked with the attribute re-enabled",
643
+ () => {
644
+ setReducedMotion(true);
645
+ setCssAnimationsEnabled(true);
646
+ },
647
+ () => setReducedMotion(false),
648
+ ],
649
+ [
650
+ "OS reduced-motion query",
651
+ () => {
652
+ mmMatches = true;
653
+ },
654
+ () => {
655
+ mmMatches = false;
656
+ },
657
+ ],
658
+ ];
659
+ try {
660
+ for (const [label, collapse, restore] of cases) {
661
+ recordNotification({
662
+ id: `${label}:a`,
663
+ kind: "toast",
664
+ tone: "error",
665
+ title: `row ${label}`,
666
+ });
667
+ mountBell();
668
+ await settle();
669
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
670
+ await settle();
671
+ Object.defineProperty(
672
+ document.querySelector(".hk-notification-center__list")!,
673
+ "offsetHeight",
674
+ { value: 96, configurable: true },
675
+ );
676
+ collapse();
677
+ resetNotifications();
678
+ await nextTick();
679
+ // No hold (the CSS has already collapsed the transition) …
680
+ expect(
681
+ document.querySelector<HTMLElement>(".hk-notification-center__list")!.style.minHeight,
682
+ `${label}: the hold is skipped`,
683
+ ).toBe("");
684
+ // … and the caption is handed over in the SAME tick.
685
+ expect(
686
+ document.querySelector(".hk-notification-center__empty"),
687
+ `${label}: caption available immediately`,
688
+ ).toBeTruthy();
689
+ restore();
690
+ setReducedMotion(false);
691
+ setCssAnimationsEnabled(true);
692
+ for (const m of mounts.splice(0)) {
693
+ m.app.unmount();
694
+ m.container.remove();
695
+ }
696
+ document.body
697
+ .querySelectorAll(".hk-popover-scrim, .hk-popover-panel")
698
+ .forEach((el) => el.remove());
699
+ }
700
+ } finally {
701
+ // A failing assertion must not leave the global switches flipped for
702
+ // the rest of the file (the cascade would mask the real signal).
703
+ setReducedMotion(false);
704
+ setCssAnimationsEnabled(true);
705
+ window.matchMedia = originalMatchMedia;
706
+ }
707
+ });
708
+
709
+ it("a same-id re-record that replaces the row still holds the height", async () => {
710
+ // Closing review F3: the journal upserts BY ID, so a poller rewriting an
711
+ // entry's content changes the row's identity in place — one key out,
712
+ // one key in, the COUNT unchanged. A count-keyed hold would skip it and
713
+ // crop the bottom ghost exactly then.
714
+ await setLocale("en");
715
+ recordNotification({ id: "poll", kind: "toast", tone: "error", title: "before" });
716
+ mountBell();
717
+ await settle();
718
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
719
+ await settle();
720
+ Object.defineProperty(document.querySelector(".hk-notification-center__list")!, "offsetHeight", {
721
+ value: 88,
722
+ configurable: true,
723
+ });
724
+ recordNotification({ id: "poll", kind: "toast", tone: "error", title: "after" });
725
+ await nextTick();
726
+ expect(
727
+ document.querySelector<HTMLElement>(".hk-notification-center__list")!.style.minHeight,
728
+ "a content-key replacement holds too",
729
+ ).toBe("88px");
730
+ expect(document.querySelector(".hk-notification-center__empty")).toBeNull();
731
+ });
732
+
733
+ it("an arrival during the hold does not crop the ghosts still fading", async () => {
734
+ // Closing review M7: the arrival path must not release a hold while an
735
+ // earlier batch is still leaving — the release is what crops the ghost.
736
+ await setLocale("en");
737
+ recordNotification({ id: "a", kind: "toast", tone: "error", title: "one" });
738
+ recordNotification({ id: "b", kind: "toast", tone: "warning", title: "two" });
739
+ mountBell();
740
+ await settle();
741
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
742
+ await settle();
743
+ Object.defineProperty(document.querySelector(".hk-notification-center__list")!, "offsetHeight", {
744
+ value: 48,
745
+ configurable: true,
746
+ });
747
+ rows()
748
+ .find((r) => r.textContent?.includes("one"))!
749
+ .querySelector<HTMLButtonElement>(
750
+ '.hk-notification-row__actions .hk-icon-button[aria-label="Dismiss"]',
751
+ )!
752
+ .dispatchEvent(new MouseEvent("click", { bubbles: true }));
753
+ await nextTick();
754
+ expect(
755
+ document.querySelector<HTMLElement>(".hk-notification-center__list")!.style.minHeight,
756
+ ).toBe("48px");
757
+ // A new record lands INSIDE the window, while the ghost is still fading.
758
+ expect(document.querySelector('[class*="-leave-active"]'), "a ghost is in flight").toBeTruthy();
759
+ recordNotification({ id: "c", kind: "toast", tone: "error", title: "three" });
760
+ await nextTick();
761
+ expect(
762
+ document.querySelector<HTMLElement>(".hk-notification-center__list")!.style.minHeight,
763
+ "the in-flight ghost keeps its window",
764
+ ).toBe("48px");
765
+ });
766
+
767
+ it("the row-less list is hidden from AT only while the caption carries the message", async () => {
768
+ // Closing review M13: `aria-hidden` on the empty list is what stops AT
769
+ // announcing "list, 0 items" beside "No notifications yet" — and it
770
+ // must never be set while rows are on screen.
771
+ await setLocale("en");
772
+ recordNotification({ id: "a", kind: "toast", tone: "error", title: "one" });
773
+ mountBell();
774
+ await settle();
775
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
776
+ await settle();
777
+ const list = () => document.querySelector(".hk-notification-center__list")!;
778
+ expect(list().getAttribute("aria-hidden"), "rows on screen: not hidden").toBeNull();
779
+ resetNotifications();
780
+ await new Promise((r) => setTimeout(r, 400));
781
+ await nextTick();
782
+ expect(document.querySelector(".hk-notification-center__empty")).toBeTruthy();
783
+ expect(list().getAttribute("aria-hidden"), "caption showing: hidden").toBe("true");
784
+ });
785
+
786
+ it("closing mid-hold leaves no stale height behind for the next open", async () => {
787
+ // Closing review F5: closing unmounts the panel body, so a surviving
788
+ // hold would greet the next open as a blank panel at the old height
789
+ // with the caption still suppressed.
790
+ await setLocale("en");
791
+ recordNotification({ id: "a", kind: "toast", tone: "error", title: "one" });
792
+ mountBell();
793
+ await settle();
794
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
795
+ await settle();
796
+ Object.defineProperty(document.querySelector(".hk-notification-center__list")!, "offsetHeight", {
797
+ value: 64,
798
+ configurable: true,
799
+ });
800
+ resetNotifications();
801
+ await nextTick();
802
+ expect(
803
+ document.querySelector<HTMLElement>(".hk-notification-center__list")!.style.minHeight,
804
+ ).toBe("64px");
805
+ // Close (inside the window) and reopen at once.
806
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
807
+ await settle();
808
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
809
+ await settle();
810
+ const list = document.querySelector<HTMLElement>(".hk-notification-center__list")!;
811
+ expect(list, "the list is back").toBeTruthy();
812
+ expect(list.style.minHeight, "no stale hold").toBe("");
813
+ expect(document.querySelector(".hk-notification-center__empty")).toBeTruthy();
814
+ });
815
+
816
+ it("a PARTIAL dismiss holds the list height too (the bottom ghost is not cropped)", async () => {
817
+ // Round-4 finding, S1: the hold is not an empty-state nicety. A pinned
818
+ // ghost sits at its pre-patch offset inside the scroller, so ANY shrink
819
+ // crops the bottom-most one — dismiss the last row of three and the
820
+ // fade was invisible. (happy-dom has no layout, so the pre-patch height
821
+ // read is stubbed; the real-browser behaviour is recorded in the PR.)
822
+ await setLocale("en");
823
+ recordNotification({ id: "a", kind: "toast", tone: "error", title: "one" });
824
+ recordNotification({ id: "b", kind: "toast", tone: "warning", title: "two" });
825
+ recordNotification({ id: "c", kind: "toast", tone: "error", title: "three" });
826
+ mountBell();
827
+ await settle();
828
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
829
+ await settle();
830
+ Object.defineProperty(document.querySelector(".hk-notification-center__list")!, "offsetHeight", {
831
+ value: 72,
832
+ configurable: true,
833
+ });
834
+ // Rows sort newest-first, so the BOTTOM row is the oldest record —
835
+ // that is the one the hold exists for (its ghost sits at the old
836
+ // content bottom and would be cropped the moment the box shrinks).
837
+ const last = rows().find((r) => r.textContent?.includes("one"))!;
838
+ last.querySelector<HTMLButtonElement>(
839
+ '.hk-notification-row__actions .hk-icon-button[aria-label="Dismiss"]',
840
+ )!.dispatchEvent(new MouseEvent("click", { bubbles: true }));
841
+ await nextTick();
842
+ // Rows remain (partial) — the ghost of the dismissed row still carries
843
+ // the row class during its leave, so count the LIVE ones.
844
+ const live = rows().filter((r) => !r.className.includes("-leave-active"));
845
+ expect(live).toHaveLength(2);
846
+ expect(
847
+ document.querySelector<HTMLElement>(".hk-notification-center__list")!.style.minHeight,
848
+ ).toBe("72px");
849
+ // No caption during the window: the journal is not empty.
850
+ expect(document.querySelector(".hk-notification-center__empty")).toBeNull();
851
+ await new Promise((r) => setTimeout(r, 400));
852
+ await nextTick();
853
+ expect(
854
+ document.querySelector<HTMLElement>(".hk-notification-center__list")!.style.minHeight,
855
+ ).toBe("");
856
+ expect(document.querySelector(".hk-notification-center__empty")).toBeNull();
857
+ });
858
+
859
+ it("clear-all fades every row, then the empty caption takes over", async () => {
860
+ // The whole list leaving at once is the case the persistent wrap and
861
+ // the hold window exist for: a branch swap would unmount the
862
+ // TransitionGroup and cancel every ghost mid-flight (a snap instead
863
+ // of a fade). The caption must NOT mount beside the ghosts — it would
864
+ // paint under the first departing row and read "No notifications yet"
865
+ // through a fading notification (2026-11-20 review, S2).
866
+ await setLocale("en");
867
+ recordNotification({ id: "a", kind: "toast", tone: "error", title: "one" });
868
+ recordNotification({ id: "b", kind: "toast", tone: "warning", title: "two" });
869
+ mountBell();
870
+ await settle();
871
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
872
+ await settle();
873
+ const clearBtn = Array.from(
874
+ document.querySelectorAll<HTMLButtonElement>(".hk-notification-center__foot .hk-btn"),
875
+ ).find((b) => b.textContent?.includes("Clear all"))!;
876
+ // happy-dom has no layout, so the hold's pre-patch height read needs a
877
+ // stub — otherwise lastListHeight stays 0 and the window below is
878
+ // unobservable here (the real-browser behaviour is measured in the
879
+ // PR record; jsdom can only pin the resulting style/caption gates).
880
+ Object.defineProperty(document.querySelector(".hk-notification-center__list")!, "offsetHeight", {
881
+ value: 120,
882
+ configurable: true,
883
+ });
884
+ clearBtn.dispatchEvent(new MouseEvent("click", { bubbles: true }));
885
+ await nextTick();
886
+ expect(document.querySelectorAll(".hk-list-pop-leave-active")).toHaveLength(2);
887
+ // During the fade: ghosts only — no caption, and the list holds its
888
+ // last height so the ghosts are not clipped by a collapsed scroller.
889
+ expect(document.querySelector(".hk-notification-center__empty")).toBeNull();
890
+ expect(
891
+ document.querySelector<HTMLElement>(".hk-notification-center__list")!.style.minHeight,
892
+ "the EXACT pre-patch height is held (a wrong-measurement mutation must red)",
893
+ ).toBe("120px");
894
+ // The foot keeps its empty-hides rule (unchanged semantics).
895
+ expect(document.querySelector(".hk-notification-center__foot")).toBeNull();
896
+ await settle();
897
+ expect(rows()).toHaveLength(0);
898
+ // After the leave window (LEAVE_MS = 320, slower than settle()'s 80ms)
899
+ // the caption takes over and the hold releases.
900
+ await new Promise((r) => setTimeout(r, 400));
901
+ await nextTick();
902
+ expect(document.querySelector(".hk-notification-center__empty")).toBeTruthy();
903
+ expect(
904
+ document.querySelector<HTMLElement>(".hk-notification-center__list")!.style.minHeight,
905
+ ).toBe("");
906
+ });
907
+
908
+ it("a record landing on the open panel pops in through the list transition", async () => {
909
+ await setLocale("en");
910
+ recordNotification({ id: "a", kind: "toast", tone: "error", title: "first" });
911
+ mountBell();
912
+ await settle();
913
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
914
+ await settle();
915
+ recordNotification({ id: "b", kind: "toast", tone: "warning", title: "second" });
916
+ await nextTick();
917
+ const fresh = rows().find((r) => r.textContent?.includes("second"));
918
+ expect(fresh, "the new row rendered").toBeTruthy();
919
+ expect(fresh!.className).toContain("hk-list-pop-enter-active");
920
+ await settle();
921
+ // Settled: the entrance classes resolved and the row stays.
922
+ const settledRow = rows().find((r) => r.textContent?.includes("second"));
923
+ expect(settledRow).toBeTruthy();
924
+ expect(settledRow!.className).not.toContain("hk-list-pop-enter");
925
+ });
926
+
927
+ it("the first row into an empty open panel enters (0→1 through the primitive)", async () => {
928
+ // The mirror of the leave pins: with the caption gone the very first
929
+ // record must still ARRIVE through the choreography rather than
930
+ // appearing already-settled.
931
+ await setLocale("en");
932
+ mountBell();
933
+ await settle();
934
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
935
+ await settle();
936
+ expect(document.querySelector(".hk-notification-center__empty")).toBeTruthy();
937
+ recordNotification({ id: "first", kind: "toast", tone: "error", title: "the first one" });
938
+ await nextTick();
939
+ expect(document.querySelector(".hk-notification-center__empty")).toBeNull();
940
+ const row = rows()[0];
941
+ expect(row, "the row rendered").toBeTruthy();
942
+ expect(row.className).toContain("hk-list-pop-enter-active");
943
+ await settle();
944
+ expect(rows()).toHaveLength(1);
945
+ });
946
+
947
+ it("opening the panel does NOT replay the list's entrance (appear stays off)", async () => {
948
+ // `appear` would re-animate every row on every open — the panel is
949
+ // opened constantly, so that would be noise, not feedback. Pinned
950
+ // behaviourally (2026-11-20 review M6): the initial rows must mount
951
+ // already settled.
952
+ await setLocale("en");
953
+ recordNotification({ id: "a", kind: "toast", tone: "error", title: "one" });
954
+ recordNotification({ id: "b", kind: "toast", tone: "warning", title: "two" });
955
+ mountBell();
956
+ await settle();
957
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
958
+ await nextTick();
959
+ for (const row of rows()) {
960
+ expect(row.className).not.toContain("hk-list-pop-enter");
961
+ }
962
+ });
558
963
  });
@@ -32,6 +32,32 @@
32
32
  * clips its text, so the clipboard is the only place the whole thing
33
33
  * still exists.
34
34
  *
35
+ * Motion (user direction 2026-11-20): list rows pop in and out through
36
+ * HkListTransition — the library's own list choreography primitive (the
37
+ * one HkModalBreadcrumb, HkTagInput, HkPasswordSurface, HkAffixPicker and
38
+ * HkWaterfall actually render; HkJsonTree/HkLocalizedInput/HkCrossfade
39
+ * only document the same contract, they do not use it) — which reports
40
+ * every enter/leave batch to the runtime animation context
41
+ * (reportTransition on the frame bus) and whose own reduced-motion /
42
+ * global-CSS-switch rules collapse the motion. `pop` is that primitive's
43
+ * fade-and-settle list signature; `move` lets the remaining rows
44
+ * FLIP-glide into the space a dismissed one frees. No bespoke row
45
+ * transition lives here (contract test pins this).
46
+ *
47
+ * Three structural consequences of riding it:
48
+ * - the list wrap stays mounted across the empty swap, because a
49
+ * torn-down TransitionGroup cancels its leaving ghosts mid-flight;
50
+ * - when a row's KEY disappears (a change of the visible content, which
51
+ * includes a same-id rewrite) the list holds its pre-patch height for
52
+ * the leave window. A leaving row is lifted to `position: absolute`
53
+ * inside the list (which is the scroll container), so as soon as the
54
+ * box shrinks by one row the bottom-most ghost falls outside the
55
+ * scrollport and is cropped — the empty case is only the extreme.
56
+ * Measured in real Chrome, 2026-11-20;
57
+ * - the empty caption mounts only after that window, and the hold is
58
+ * skipped entirely when motion is collapsed (reduced-motion media
59
+ * query, the bus park flag, or the global CSS-animation attribute).
60
+ *
35
61
  * Renders nothing extra while the journal is empty beyond the bell
36
62
  * itself — an empty notification center still shows its (disabled-
37
63
  * looking) trigger so the host chrome never reflows on first use.
@@ -59,9 +85,12 @@ import {
59
85
  type HkNotificationEntry,
60
86
  type HkNotificationTone,
61
87
  } from "../runtime/notificationCenter";
88
+ import { isCssAnimationsEnabled } from "../animation/registerAnimations";
89
+ import { isAnimationParked } from "../runtime/animationBus";
62
90
  import { useClipboard } from "../runtime/useClipboard";
63
91
  import HkIconButton from "./HkIconButton";
64
92
  import HkButton from "./HkButton";
93
+ import HkListTransition from "./HkListTransition";
65
94
  import HkPopover from "./HkPopover";
66
95
  import "./HkNotificationBell.scss";
67
96
 
@@ -110,7 +139,10 @@ export default defineComponent({
110
139
  // to content"), which is why the bell owns this one. Same shape as
111
140
  // HkDrawer: a wrapper that wraps EXACTLY the viewport is the track
112
141
  // host, attach on open, detach on close/unmount.
113
- const listRef = ref<HTMLUListElement | null>(null);
142
+ // The ul itself is rendered BY HkListTransition (the row enter/exit
143
+ // choreography, motion section below), so the viewport element is
144
+ // resolved off the component instance's $el instead of a direct ref.
145
+ const listHostRef = ref<{ $el?: Element } | null>(null);
114
146
  const listWrapRef = ref<HTMLDivElement | null>(null);
115
147
  let listScrollbar: OverlayScrollbarHandle | null = null;
116
148
  function detachListScrollbar() {
@@ -127,12 +159,13 @@ export default defineComponent({
127
159
  * both modalities. */
128
160
  function syncListScrollbar() {
129
161
  nextTick(() => {
130
- if (!open.value || !listRef.value) {
162
+ const listEl = listHostRef.value?.$el as HTMLUListElement | undefined;
163
+ if (!open.value || !listEl) {
131
164
  detachListScrollbar();
132
165
  return;
133
166
  }
134
167
  if (!listScrollbar) {
135
- listScrollbar = attachOverlayScrollbars(listRef.value, {
168
+ listScrollbar = attachOverlayScrollbars(listEl, {
136
169
  axis: "vertical",
137
170
  host: listWrapRef.value ?? undefined,
138
171
  });
@@ -198,10 +231,122 @@ export default defineComponent({
198
231
  .join("|"),
199
232
  );
200
233
 
234
+ // ── the empty handover (motion, user direction 2026-11-20) ──────
235
+ // The list is the scroll container AND the containing block of the
236
+ // leaving ghosts (pinLeaveGeometry pins them `position: absolute`
237
+ // inside it — see HkNotificationBell.scss). A ghost is therefore
238
+ // clipped by the list and scrolls with its content, which is what
239
+ // keeps the fade where the user saw the row. The price: the content
240
+ // box shrinks by the leaving row the moment it lifts, so the
241
+ // BOTTOM-most ghost falls outside the scrollport and is cropped for
242
+ // its whole fade — measured in real Chrome (2026-11-20), the
243
+ // last-row dismiss, the bottom-row dismiss and Clear-all all
244
+ // vanished instantly. So every shrink holds the pre-patch height for
245
+ // the leave window (the ghosts play inside it); only when the list
246
+ // ends up empty does the handover go on to the caption, and that
247
+ // caption must NOT ride the same patch — it would paint under the
248
+ // first departing ghost and read as "No notifications yet" through a
249
+ // fading row.
250
+ //
251
+ // LEAVE_MS mirrors HkListTransition's own REPORT_MS: the slowest
252
+ // pop enter/leave runs --duration-normal (0.3s).
253
+ const LEAVE_MS = 320;
254
+ const listHoldHeight = ref<number | null>(null);
255
+ let holdTimer: ReturnType<typeof setTimeout> | null = null;
256
+ /** Reduced motion, the bus park flag, or the GLOBAL CSS switch — any
257
+ * of them ends the choreography in a frame, so the hold would only
258
+ * leave a blank, caption-less box behind. All three are checked: the
259
+ * attribute is writable directly through the exported
260
+ * `setCssAnimationsEnabled` (a documented performance-suspension
261
+ * path), which never touches the bus park flag — the house precedents
262
+ * (HkTransitionContainer, HkJsonTree) read the attribute for exactly
263
+ * this reason (2026-11-20 review, S2). */
264
+ function motionCollapsed(): boolean {
265
+ if (!isCssAnimationsEnabled() || isAnimationParked()) return true;
266
+ return (
267
+ typeof window !== "undefined" &&
268
+ typeof window.matchMedia === "function" &&
269
+ window.matchMedia("(prefers-reduced-motion: reduce)").matches
270
+ );
271
+ }
272
+ // The hold is keyed on ROW IDENTITY, not on the count: a re-record that
273
+ // rewrites an existing entry's content key removes one row and adds
274
+ // another in the SAME patch (the journal upserts by id — pollers call
275
+ // it every cycle), so a count-based trigger would silently skip the
276
+ // hold exactly when the bottom row is the one replaced (2026-11-20
277
+ // closing review, F3).
278
+ let prevKeys: string[] = groups.value.map((g) => g.key);
279
+ /** Any ghost still mid-leave? A held list must not be released while
280
+ * one is in flight — the release is what crops it (F4). */
281
+ function hasFadingGhost(): boolean {
282
+ const listEl = listHostRef.value?.$el as HTMLElement | undefined;
283
+ return listEl ? listEl.querySelector('[class*="-leave-active"]') !== null : false;
284
+ }
285
+ function releaseHold() {
286
+ if (holdTimer) {
287
+ clearTimeout(holdTimer);
288
+ holdTimer = null;
289
+ }
290
+ listHoldHeight.value = null;
291
+ }
292
+ function armHoldWindow() {
293
+ if (holdTimer) clearTimeout(holdTimer);
294
+ holdTimer = setTimeout(() => {
295
+ listHoldHeight.value = null;
296
+ holdTimer = null;
297
+ }, LEAVE_MS);
298
+ }
299
+ watch(
300
+ () => groups.value.map((g) => g.key).join("\u0001"),
301
+ () => {
302
+ const keys = groups.value.map((g) => g.key);
303
+ const previous = prevKeys;
304
+ prevKeys = keys;
305
+ // Removed = a key that was here is gone (a replacement counts).
306
+ const removed = previous.some((k) => !keys.includes(k));
307
+ if (removed) {
308
+ // The hold is not an empty-state nicety — it is what keeps the
309
+ // BOTTOM-most departing row visible: its pinned ghost sits at the
310
+ // pre-patch offset inside the scroller, so the moment the box
311
+ // shrinks the ghost falls outside the scrollport and is clipped
312
+ // for its whole fade. Measured in real Chrome, 2026-11-20.
313
+ if (motionCollapsed()) {
314
+ releaseHold();
315
+ return;
316
+ }
317
+ // Measured in the pre-flush watcher: the DOM still holds the
318
+ // rows, so the value lands in the same patch that starts the
319
+ // leaves.
320
+ const listEl = listHostRef.value?.$el as HTMLElement | undefined;
321
+ const measured = listEl?.offsetHeight ?? 0;
322
+ if (measured > 0) listHoldHeight.value = measured;
323
+ armHoldWindow();
324
+ return;
325
+ }
326
+ // No removal: an arrival (or a reorder). Keep holding only while
327
+ // an earlier batch is still fading; otherwise release at once so
328
+ // the new row animates into a natural-height list.
329
+ if (hasFadingGhost() && listHoldHeight.value !== null) {
330
+ armHoldWindow();
331
+ return;
332
+ }
333
+ releaseHold();
334
+ },
335
+ );
336
+ /** The caption waits for the handover: no rows AND no hold window. */
337
+ const showEmptyCaption = computed(
338
+ () => groups.value.length === 0 && listHoldHeight.value === null,
339
+ );
340
+
201
341
  // Open = read receipt. Watching the flag (not wiring it into the
202
342
  // toggle) keeps the receipt honest for sheet-scrim closes too.
203
343
  watch(open, (v) => {
204
344
  if (v) markAllRead();
345
+ // Closing unmounts the panel body (ghosts go with it), so a hold that
346
+ // survived the close would re-mount a row-less list at the stale
347
+ // height with the caption still suppressed — a blank panel for the
348
+ // rest of the window (2026-11-20 closing review, F5).
349
+ releaseHold();
205
350
  syncListScrollbar();
206
351
  });
207
352
  // Rows mount/unmount/change while open too (empty↔list swaps, new
@@ -209,6 +354,12 @@ export default defineComponent({
209
354
  // the engine's box ResizeObserver cannot see.
210
355
  watch(rowSignature, () => syncListScrollbar());
211
356
  onUnmounted(detachListScrollbar);
357
+ onUnmounted(() => {
358
+ if (holdTimer) {
359
+ clearTimeout(holdTimer);
360
+ holdTimer = null;
361
+ }
362
+ });
212
363
 
213
364
  /** The toast's copy affordance, carried over: same clipboard write
214
365
  * path (useClipboard), but the payload is the journal's own shape —
@@ -396,27 +547,50 @@ export default defineComponent({
396
547
  title={label}
397
548
  >
398
549
  <div class="hk-notification-center">
399
- {sorted.value.length === 0 ? (
400
- <p class="hk-notification-center__empty">
401
- {t("hikari::notificationCenter.empty", "No notifications yet")}
402
- </p>
403
- ) : (
404
- <>
405
- <div class="hk-notification-center__list-wrap" ref={listWrapRef}>
406
- <ul class="hk-notification-center__list" role="list" ref={listRef}>
407
- {groups.value.map(renderRow)}
408
- </ul>
409
- </div>
410
- <div class="hk-notification-center__foot">
411
- {/* The wipe glyph reads before the label is parsed —
412
- a destructive affordance announced by its icon
413
- (user direction 2026-11-19), from the same lucide
414
- family the row glyphs already speak. */}
415
- <HkButton variant="ghost" size="sm" icon="Trash2" onClick={() => reset()}>
416
- {t("hikari::notificationCenter.clearAll", "Clear all")}
417
- </HkButton>
418
- </div>
419
- </>
550
+ {/* The list wrap stays MOUNTED while the panel is open — the
551
+ empty caption lives inside it, beside the (row-less) list.
552
+ Tearing the TransitionGroup down on the empty swap would
553
+ cancel the leave choreography mid-flight (Vue runs child
554
+ leave transitions only while the group itself stays
555
+ mounted), so "Clear all" and a last-row dismiss would snap
556
+ instead of fading. The foot keeps its empty-hides rule. */}
557
+ <div class="hk-notification-center__list-wrap" ref={listWrapRef}>
558
+ <HkListTransition
559
+ tag="ul"
560
+ variant="pop"
561
+ move
562
+ class="hk-notification-center__list"
563
+ {...{
564
+ role: "list",
565
+ // While the caption carries the message the (row-less)
566
+ // list must not be announced as an empty list beside it.
567
+ "aria-hidden": showEmptyCaption.value ? "true" : undefined,
568
+ }}
569
+ style={
570
+ listHoldHeight.value === null
571
+ ? undefined
572
+ : { minHeight: `${listHoldHeight.value}px` }
573
+ }
574
+ ref={listHostRef}
575
+ >
576
+ {groups.value.map(renderRow)}
577
+ </HkListTransition>
578
+ {showEmptyCaption.value && (
579
+ <p class="hk-notification-center__empty">
580
+ {t("hikari::notificationCenter.empty", "No notifications yet")}
581
+ </p>
582
+ )}
583
+ </div>
584
+ {groups.value.length > 0 && (
585
+ <div class="hk-notification-center__foot">
586
+ {/* The wipe glyph reads before the label is parsed —
587
+ a destructive affordance announced by its icon
588
+ (user direction 2026-11-19), from the same lucide
589
+ family the row glyphs already speak. */}
590
+ <HkButton variant="ghost" size="sm" icon="Trash2" onClick={() => reset()}>
591
+ {t("hikari::notificationCenter.clearAll", "Clear all")}
592
+ </HkButton>
593
+ </div>
420
594
  )}
421
595
  </div>
422
596
  </HkPopover>