@celestia-island/hikari 0.55.426 → 0.55.427

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.426",
3
+ "version": "0.55.427",
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",
@@ -35,6 +35,14 @@
35
35
  }
36
36
  }
37
37
 
38
+ /* The list wrapper is the overlay scrollbar's track host (useOverlay
39
+ Scrollbar requires a box wrapping EXACTLY the viewport — the panel body
40
+ also holds the foot, so the list gets its own). No styles of its own:
41
+ the engine's positioning guard promotes it in place. */
42
+ .hk-notification-center__list-wrap {
43
+ position: relative;
44
+ }
45
+
38
46
  .hk-notification-center__list {
39
47
  list-style: none;
40
48
  margin: 0;
@@ -105,14 +113,41 @@
105
113
  }
106
114
  }
107
115
 
108
- .hk-notification-row__icon {
116
+ .hk-notification-row__icon-box {
109
117
  flex: none;
118
+ display: inline-flex;
119
+ align-items: center;
120
+ /* The consolidation badge anchors to this box's corner. */
121
+ position: relative;
122
+ }
123
+
124
+ .hk-notification-row__icon {
110
125
  display: inline-flex;
111
126
  align-items: center;
112
127
  /* Tone ink follows the row's tone class (rules below). */
113
128
  color: rgb(var(--color-text) / 65%);
114
129
  }
115
130
 
131
+ /* Corner tally for consolidated records (2026-11-19): the unread dot's
132
+ primary channel — the same "attention" grammar the bell trigger speaks.
133
+ Sits on the glyph's bottom-end corner like a notification count. */
134
+ .hk-notification-row__icon-count {
135
+ position: absolute;
136
+ inset-inline-end: -7px;
137
+ bottom: -6px;
138
+ min-width: 14px;
139
+ height: 14px;
140
+ padding: 0 3px;
141
+ border-radius: 7px;
142
+ background: var(--hi-color-primary, #7aa2f7);
143
+ color: rgb(255 255 255 / 95%);
144
+ font-size: 9px;
145
+ line-height: 14px;
146
+ font-weight: 600;
147
+ text-align: center;
148
+ font-variant-numeric: tabular-nums;
149
+ }
150
+
116
151
  /* Tone ink on the glyph (the toast family's own --hi-color-<tone>
117
152
  channels, theme-following; fallbacks are the tokenInventory-canonical
118
153
  literals, NOT the toast family's sheet-local ones). */
@@ -341,6 +341,137 @@ describe("panel rows", () => {
341
341
  expect(rows()[0].textContent).toContain("keep me");
342
342
  });
343
343
 
344
+ it("identical messages render ONE row with a corner tally badge", async () => {
345
+ // User direction 2026-11-19: identical messages consolidate into one
346
+ // row; the tone glyph's corner carries the count. The JOURNAL stays
347
+ // 1:1 with its sources (ids are lifecycle keys) — the grouping is a
348
+ // view concern (the record-time merge design was rejected in review:
349
+ // folding discards the incoming id and breaks every id-keyed op).
350
+ await setLocale("en");
351
+ for (const id of ["t:1", "t:2", "t:3"]) {
352
+ recordNotification({ id, kind: "toast", tone: "error", title: "boom" });
353
+ }
354
+ recordNotification({ id: "s:1", kind: "toast", tone: "warning", title: "other" });
355
+ const { entries } = useNotificationCenter();
356
+ // The journal keeps full fidelity — three separate records.
357
+ expect(entries).toHaveLength(4);
358
+ mountBell();
359
+ await settle();
360
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
361
+ await settle();
362
+ // …but the reader sees ONE row per distinct message.
363
+ expect(rows()).toHaveLength(2);
364
+ const boomRow = rows().find((r) => r.textContent?.includes("boom"))!;
365
+ const badge = boomRow.querySelector<HTMLElement>(".hk-notification-row__icon-count");
366
+ expect(badge, "the tally badge renders").toBeTruthy();
367
+ expect(badge!.textContent).toBe("3");
368
+ expect(badge!.getAttribute("title")).toContain("msgs");
369
+ // A single-occurrence record carries NO badge.
370
+ const otherRow = rows().find((r) => r.textContent?.includes("other"))!;
371
+ expect(otherRow.querySelector(".hk-notification-row__icon-count")).toBeNull();
372
+ });
373
+
374
+ it("dismiss on a consolidated row forgets EVERY member of the group", async () => {
375
+ await setLocale("en");
376
+ for (const id of ["t:1", "t:2", "t:3"]) {
377
+ recordNotification({ id, kind: "toast", tone: "error", title: "boom" });
378
+ }
379
+ mountBell();
380
+ await settle();
381
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
382
+ await settle();
383
+ expect(rows()).toHaveLength(1);
384
+ const boomRow = rows()[0]!;
385
+ const dismiss = boomRow.querySelector<HTMLButtonElement>(
386
+ '.hk-notification-row__actions .hk-icon-button[aria-label="Dismiss"]',
387
+ )!;
388
+ dismiss.dispatchEvent(new MouseEvent("click", { bubbles: true }));
389
+ await settle();
390
+ // The whole line goes — not just the newest member.
391
+ expect(useNotificationCenter().entries).toHaveLength(0);
392
+ expect(rows()).toHaveLength(0);
393
+ });
394
+
395
+ it("a toast joining a snoozed emergency's group does NOT dissolve the Restore", async () => {
396
+ // Round-3 S2, proven by probe: the group's FACE is its newest member
397
+ // (the toast), so head-only action gating hid the emergency's only
398
+ // restore affordance while the journal still held the callback — the
399
+ // same loss the record-time merge was rejected for, at the view
400
+ // layer. The actions lane scans members instead.
401
+ await setLocale("en");
402
+ raiseEmergencyAlert({ id: "quota", severity: "warning", title: "quota out" });
403
+ snoozeEmergencyAlert("quota");
404
+ recordNotification({
405
+ id: "toast:same",
406
+ kind: "toast",
407
+ tone: "warning",
408
+ title: "quota out",
409
+ state: "active",
410
+ });
411
+ const { entries } = useNotificationCenter();
412
+ expect(entries).toHaveLength(2);
413
+ mountBell();
414
+ await settle();
415
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
416
+ await settle();
417
+ expect(rows()).toHaveLength(1);
418
+ const row = rows()[0]!;
419
+ // Restore is STILL offered (member scan), and the Hidden chip shows.
420
+ const restore = row.querySelector<HTMLButtonElement>(
421
+ '.hk-notification-row__actions .hk-icon-button[aria-label="Show again"]',
422
+ );
423
+ expect(restore, "the emergency's restore survives the grouping").toBeTruthy();
424
+ expect(row.querySelector(".hk-notification-row__title-state")?.textContent).toContain(
425
+ "Hidden",
426
+ );
427
+ // The tally counts both members.
428
+ expect(row.querySelector(".hk-notification-row__icon-count")?.textContent).toBe("2");
429
+ // And the restore still works through the journal's resummon path.
430
+ restore!.dispatchEvent(new MouseEvent("click", { bubbles: true }));
431
+ await settle();
432
+ expect(
433
+ row.querySelector('.hk-notification-row__actions .hk-icon-button[aria-label="Show again"]'),
434
+ ).toBeFalsy();
435
+ expect(row.classList.contains("is-active")).toBe(true);
436
+ });
437
+
438
+ it("the open panel carries the overlay scrollbar tracks; closing detaches them", async () => {
439
+ // The list keeps native overflow MECHANICS with the suppression pair,
440
+ // so the overlay engine is the only chrome it can ever show (user
441
+ // report 2026-11-19: the list scrolled invisibly). HkPopover attaches
442
+ // its engine in sheet mode only — the bell owns the desktop one.
443
+ await setLocale("en");
444
+ for (let i = 0; i < 30; i++) {
445
+ recordNotification({ id: `t:${i}`, kind: "toast", tone: "error", title: `row ${i}` });
446
+ }
447
+ mountBell();
448
+ await settle();
449
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
450
+ await settle();
451
+ const wrap = document.querySelector(".hk-notification-center__list-wrap");
452
+ expect(wrap, "the dedicated track host exists").toBeTruthy();
453
+ expect(wrap!.querySelectorAll(".hk-scrollbar-track").length).toBeGreaterThan(0);
454
+ // Closing the panel must not leak the engine (document listeners /
455
+ // cron timers ride the handle).
456
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
457
+ await settle();
458
+ expect(document.querySelector(".hk-notification-center__list-wrap")).toBeNull();
459
+
460
+ // Round-2 hole: with the panel OPEN on the empty state the list is
461
+ // not mounted — a record landing NOW mounts it fresh. The signature
462
+ // watcher must attach the engine to the NEW viewport (an update() on
463
+ // a stale handle would leave it scrolling invisibly).
464
+ resetNotifications();
465
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
466
+ await settle();
467
+ expect(document.querySelector(".hk-notification-center__empty")).toBeTruthy();
468
+ recordNotification({ id: "late", kind: "toast", tone: "error", title: "late arrival" });
469
+ await settle();
470
+ const wrap2 = document.querySelector(".hk-notification-center__list-wrap");
471
+ expect(wrap2, "the list mounts under the open panel").toBeTruthy();
472
+ expect(wrap2!.querySelectorAll(".hk-scrollbar-track").length).toBeGreaterThan(0);
473
+ });
474
+
344
475
  it("rows sort newest-first and Clear all empties the journal", async () => {
345
476
  await setLocale("en");
346
477
  const { entries } = useNotificationCenter();
@@ -46,9 +46,13 @@ import {
46
46
  TriangleAlert as AlertTriangle,
47
47
  X,
48
48
  } from "lucide-vue-next";
49
- import { computed, defineComponent, h, ref, watch, type Component } from "vue";
49
+ import { computed, defineComponent, h, nextTick, onUnmounted, ref, watch, type Component } from "vue";
50
50
 
51
51
  import { useChromeActionSize } from "../composables/useChromeActionSize";
52
+ import {
53
+ attachOverlayScrollbars,
54
+ type OverlayScrollbarHandle,
55
+ } from "../composables/useOverlayScrollbar";
52
56
  import { activeLocale, useI18n } from "../i18n/context";
53
57
  import {
54
58
  useNotificationCenter,
@@ -99,6 +103,44 @@ export default defineComponent({
99
103
  const clipboard = useClipboard();
100
104
  const open = ref(false);
101
105
  const anchorRef = ref<HTMLElement | null>(null);
106
+ // The list is the popup's ONE scroll surface on the desktop flyout —
107
+ // it carries the native-suppression pair, so WITHOUT the overlay
108
+ // engine it scrolls invisibly (user report 2026-11-19). HkPopover
109
+ // attaches its own engine only in sheet mode ("desktop popovers size
110
+ // to content"), which is why the bell owns this one. Same shape as
111
+ // HkDrawer: a wrapper that wraps EXACTLY the viewport is the track
112
+ // host, attach on open, detach on close/unmount.
113
+ const listRef = ref<HTMLUListElement | null>(null);
114
+ const listWrapRef = ref<HTMLDivElement | null>(null);
115
+ let listScrollbar: OverlayScrollbarHandle | null = null;
116
+ function detachListScrollbar() {
117
+ listScrollbar?.detach();
118
+ listScrollbar = null;
119
+ }
120
+ /** One sync point for the list's overlay chrome: attach when the
121
+ * viewport exists under an open panel, detach when it does not,
122
+ * update when only the content moved. Re-checks `open` INSIDE the
123
+ * nextTick so a same-flush open→close cannot attach onto a panel
124
+ * that is already on its way out (round-2 flap note). The sheet
125
+ * branch never scrolls the list (overflow: visible — the engine
126
+ * self-hides when content fits), so one unconditional path serves
127
+ * both modalities. */
128
+ function syncListScrollbar() {
129
+ nextTick(() => {
130
+ if (!open.value || !listRef.value) {
131
+ detachListScrollbar();
132
+ return;
133
+ }
134
+ if (!listScrollbar) {
135
+ listScrollbar = attachOverlayScrollbars(listRef.value, {
136
+ axis: "vertical",
137
+ host: listWrapRef.value ?? undefined,
138
+ });
139
+ } else {
140
+ listScrollbar.update();
141
+ }
142
+ });
143
+ }
102
144
 
103
145
  const unread = computed(() => entries.filter((e) => !e.read).length);
104
146
  const sorted = computed(() =>
@@ -110,12 +152,63 @@ export default defineComponent({
110
152
  (a, b) => b.updatedAt - a.updatedAt || entries.indexOf(b) - entries.indexOf(a),
111
153
  ),
112
154
  );
155
+ // Content consolidation (user direction 2026-11-19) lives in the VIEW,
156
+ // deliberately not in the journal: ids are the key every lifecycle op
157
+ // speaks (a source's own re-record, setNotificationState, forget), and
158
+ // a record-time merge would discard the incoming id — a folded source's
159
+ // re-records then count as recurrences forever and its state/forget
160
+ // calls no-op (the round-1 review's S1, proven by probe). Grouping the
161
+ // sorted rows keeps the journal 1:1 with its sources while the reader
162
+ // sees ONE row per distinct message with a tally badge. Newest member
163
+ // is the group's face (time/state/actions); the tally is the member
164
+ // count; dismiss forgets every DISMISSABLE member of the group.
165
+ interface HkNotificationGroup {
166
+ /** Stable content key — the row's vue key, so a new member joining
167
+ * (or the face changing) does not remount the row under the cursor. */
168
+ key: string;
169
+ members: HkNotificationEntry[];
170
+ head: HkNotificationEntry;
171
+ }
172
+ const groups = computed<HkNotificationGroup[]>(() => {
173
+ const out: HkNotificationGroup[] = [];
174
+ const byKey = new Map<string, HkNotificationGroup>();
175
+ for (const e of sorted.value) {
176
+ const key = `${e.tone}\u0000${e.title}\u0000${e.code ?? ""}\u0000${e.detail ?? ""}`;
177
+ const hit = byKey.get(key);
178
+ if (hit) {
179
+ hit.members.push(e);
180
+ } else {
181
+ const group: HkNotificationGroup = { key, members: [e], head: e };
182
+ byKey.set(key, group);
183
+ out.push(group);
184
+ }
185
+ }
186
+ return out;
187
+ });
188
+ // A signature of everything the rendered rows depend on — drives the
189
+ // scrollbar sync (rows appearing/vanishing/changing height all move
190
+ // scrollHeight, which the engine's box ResizeObserver cannot see).
191
+ const rowSignature = computed(() =>
192
+ groups.value
193
+ .map((g) =>
194
+ g.members
195
+ .map((m) => `${m.id}:${m.updatedAt}:${m.state}:${m.read ? 1 : 0}`)
196
+ .join("+"),
197
+ )
198
+ .join("|"),
199
+ );
113
200
 
114
201
  // Open = read receipt. Watching the flag (not wiring it into the
115
202
  // toggle) keeps the receipt honest for sheet-scrim closes too.
116
203
  watch(open, (v) => {
117
204
  if (v) markAllRead();
205
+ syncListScrollbar();
118
206
  });
207
+ // Rows mount/unmount/change while open too (empty↔list swaps, new
208
+ // records, tallies) — every such transition moves scrollHeight, which
209
+ // the engine's box ResizeObserver cannot see.
210
+ watch(rowSignature, () => syncListScrollbar());
211
+ onUnmounted(detachListScrollbar);
119
212
 
120
213
  /** The toast's copy affordance, carried over: same clipboard write
121
214
  * path (useClipboard), but the payload is the journal's own shape —
@@ -129,18 +222,54 @@ export default defineComponent({
129
222
  void clipboard.copy(parts.join("\n"));
130
223
  }
131
224
 
132
- function renderRow(entry: HkNotificationEntry) {
225
+ function renderRow(group: HkNotificationGroup) {
226
+ // The NEWEST member is the group's face — time, code/detail and the
227
+ // tone all answer "what happened most recently".
228
+ const entry = group.head;
133
229
  const Icon = TONE_ICONS[entry.tone] ?? Info;
134
- const isLive = entry.kind === "emergency" && entry.state !== "cleared";
135
- const resummonable = entry.onResummon !== undefined && entry.state === "snoozed";
230
+ // The actions lane is MEMBER-SCANNED, not head-only (round-3 S2,
231
+ // proven by probe): a same-content toast joining a snoozed
232
+ // emergency's group becomes the face, and a head-only read would
233
+ // hide the emergency's ONLY restore affordance while the journal
234
+ // still holds it — exactly the loss the record-time merge was
235
+ // rejected for, at the view layer instead.
236
+ const isLive = group.members.some(
237
+ (m) => m.kind === "emergency" && m.state !== "cleared",
238
+ );
239
+ const restorable = group.members.find(
240
+ (m) => m.onResummon !== undefined && m.state === "snoozed",
241
+ );
242
+ // State chip: the head's own state wins; otherwise any member's
243
+ // Hidden/Resolved state still deserves its chip.
244
+ const chip =
245
+ entry.state === "snoozed" || entry.state === "cleared"
246
+ ? entry
247
+ : group.members.find((m) => m.state === "snoozed" || m.state === "cleared");
248
+ const tally = group.members.length;
136
249
  return (
137
- <li key={entry.id} class={["hk-notification-row", `is-${entry.tone}`, `is-${entry.state}`]}>
250
+ <li key={group.key} class={["hk-notification-row", `is-${entry.tone}`, `is-${entry.state}`]}>
138
251
  {/* The row glyph renders through h(Icon, …): Vue's Component
139
252
  union is not a valid JSX element type, so `<Icon />` is
140
253
  not available here — both this tone glyph and the row
141
254
  actions' RotateCcw go through the render function. */}
142
- <span class="hk-notification-row__icon" aria-hidden="true">
143
- {h(Icon, { size: 14 })}
255
+ <span class="hk-notification-row__icon-box">
256
+ <span class="hk-notification-row__icon" aria-hidden="true">
257
+ {h(Icon, { size: 14 })}
258
+ </span>
259
+ {tally > 1 && (
260
+ // The consolidation tally (user direction 2026-11-19): a
261
+ // corner badge on the tone glyph. It sits OUTSIDE the
262
+ // glyph's aria-hidden box (round-2 a11y note) as real text —
263
+ // screen readers hear the number — and keeps pointer events
264
+ // so the hover naming works.
265
+ <span
266
+ class="hk-notification-row__icon-count"
267
+ title={`${tally} ${t("hikari::toast.msgs", "msgs")}`}
268
+ aria-label={`${tally} ${t("hikari::toast.msgs", "msgs")}`}
269
+ >
270
+ {tally > 99 ? "99+" : tally}
271
+ </span>
272
+ )}
144
273
  </span>
145
274
  <div class="hk-notification-row__body">
146
275
  <div class="hk-notification-row__top">
@@ -150,14 +279,14 @@ export default defineComponent({
150
279
  {/* The state word is a flex:none SIBLING of the clipping
151
280
  title (round-2 review: inside the span, ellipsis ate it
152
281
  first for exactly the long titles where it matters). */}
153
- {(entry.state === "snoozed" || entry.state === "cleared") && (
282
+ {chip && (
154
283
  <span class="hk-notification-row__title-state">
155
284
  {"· "}
156
285
  {t(
157
- entry.state === "snoozed"
286
+ chip.state === "snoozed"
158
287
  ? "hikari::notificationCenter.stateHidden"
159
288
  : "hikari::notificationCenter.stateResolved",
160
- entry.state === "snoozed" ? "Hidden" : "Resolved",
289
+ chip.state === "snoozed" ? "Hidden" : "Resolved",
161
290
  )}
162
291
  </span>
163
292
  )}
@@ -197,17 +326,26 @@ export default defineComponent({
197
326
  size={24}
198
327
  variant="ghost"
199
328
  aria-label={t("hikari::notificationCenter.dismiss", "Dismiss")}
200
- onClick={() => forget(entry.id)}
329
+ onClick={() => {
330
+ // X on a consolidated row dismisses the WHOLE line —
331
+ // every member whose surface allows dismissal (a live
332
+ // emergency episode is never user-dismissable).
333
+ for (const m of group.members) {
334
+ if (!(m.kind === "emergency" && m.state !== "cleared")) {
335
+ forget(m.id);
336
+ }
337
+ }
338
+ }}
201
339
  >
202
340
  {{ icon: () => <X size={14} /> }}
203
341
  </HkIconButton>
204
342
  )}
205
- {resummonable && (
343
+ {restorable && (
206
344
  <HkIconButton
207
345
  size={24}
208
346
  variant="ghost"
209
347
  aria-label={t("hikari::emergencyAlert.restore", "Show again")}
210
- onClick={() => entry.onResummon?.()}
348
+ onClick={() => restorable.onResummon?.()}
211
349
  >
212
350
  {{ icon: () => h(RotateCcw, { size: 14 }) }}
213
351
  </HkIconButton>
@@ -255,9 +393,11 @@ export default defineComponent({
255
393
  </p>
256
394
  ) : (
257
395
  <>
258
- <ul class="hk-notification-center__list" role="list">
259
- {sorted.value.map(renderRow)}
260
- </ul>
396
+ <div class="hk-notification-center__list-wrap" ref={listWrapRef}>
397
+ <ul class="hk-notification-center__list" role="list" ref={listRef}>
398
+ {groups.value.map(renderRow)}
399
+ </ul>
400
+ </div>
261
401
  <div class="hk-notification-center__foot">
262
402
  {/* The wipe glyph reads before the label is parsed —
263
403
  a destructive affordance announced by its icon