@celestia-island/hikari 0.55.440 → 0.55.442

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.442",
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",
@@ -1,10 +1,11 @@
1
- import { computed, defineComponent, ref, watch, type PropType, type Ref, type SlotsType, type VNode } from "vue";
1
+ import { computed, defineComponent, ref, type PropType, type Ref, type SlotsType, type VNode } from "vue";
2
2
  import { Camera, ExternalLink, Languages, LogOut, Menu } from "lucide-vue-next";
3
3
  import { HBadge, HButton, HSpinner } from "@celestia-island/hikari";
4
4
  import { useI18n } from "../i18n/context";
5
5
  import { CHROME_BAND_DRAG_REGION } from "../runtime/windowChrome";
6
6
  import HkMenu, { type HkMenuItem } from "./HkMenu";
7
7
  import { HkAvatarButton } from "./HkAvatarButton";
8
+ import { useAvatarImage } from "./avatarImage";
8
9
 
9
10
  export interface LocaleOption {
10
11
  code: string;
@@ -154,6 +155,7 @@ export const HkAdminHeader = defineComponent({
154
155
  },
155
156
  setup(props, { emit, slots }) {
156
157
  const { t } = useI18n();
158
+ const menuAvatar = useAvatarImage(() => props.avatarUrl);
157
159
  const userMenuOpen = ref(false);
158
160
  const userTriggerRef = ref<HTMLElement>();
159
161
  const avatarModalOpen = ref(false);
@@ -162,16 +164,12 @@ export const HkAdminHeader = defineComponent({
162
164
  // THIS popup instead of the built-in children cascade — anchored to
163
165
  // the avatar trigger, so the popup opens exactly where the menu was.
164
166
  const localePickerOpen = ref(false);
165
- // The DROPDOWN identity image's own failed-load latch, with the same
166
- // URL-change reset the trigger's latch has inside HkAvatarButton —
167
- // an avatar re-upload or account switch must heal BOTH faces (R2's
168
- // S2 on #909: without the reset, the trigger showed the new image
169
- // while the chip stayed on its letter fallback forever).
170
- const menuAvatarFailed = ref(false);
171
- watch(
172
- () => props.avatarUrl,
173
- () => { menuAvatarFailed.value = false; },
174
- );
167
+ // The DROPDOWN identity image rides the SAME failed-load latch as the
168
+ // trigger (HkAvatarButton) and the avatar primitives — an avatar
169
+ // re-upload or account switch must heal BOTH faces, and one shared
170
+ // implementation is what keeps them from drifting (R2's S2 on #909
171
+ // was the missing reset; R2 on #1429 caught this fourth hand-rolled
172
+ // copy).
175
173
 
176
174
  // The identity cluster is INJECTED, not assumed (2026-10-24): the
177
175
  // trigger renders only when the host actually supplied an identity
@@ -384,12 +382,12 @@ export const HkAdminHeader = defineComponent({
384
382
  // s-user-header profile variant).
385
383
  <div class="s-user-header s-user-header--profile">
386
384
  <span class="s-user-avatar-chip" aria-hidden="true">
387
- {props.avatarUrl && !menuAvatarFailed.value ? (
385
+ {menuAvatar.src.value ? (
388
386
  <img
389
- src={props.avatarUrl}
387
+ src={menuAvatar.src.value}
390
388
  alt=""
391
389
  class="s-user-avatar-img"
392
- onError={() => { menuAvatarFailed.value = true; }}
390
+ onError={menuAvatar.onError}
393
391
  />
394
392
  ) : (
395
393
  <span class="s-user-avatar">
@@ -0,0 +1,107 @@
1
+ import { afterEach, describe, expect, it } from "vitest";
2
+ import { createApp, defineComponent, h, nextTick, ref } from "vue";
3
+
4
+ import HkAvatar from "./HkAvatar";
5
+
6
+ /**
7
+ * HkAvatar — the shared avatar primitive.
8
+ *
9
+ * The 2026-11-20 report: a member row whose stored `/static/avatars/…` URL
10
+ * had gone stale rendered the browser's broken-picture glyph instead of the
11
+ * default letter avatar. The primitive must treat "the URL 404s" exactly like
12
+ * "no URL was ever stored": same letter chip, same centred glyph. The latch
13
+ * is per-URL, so an account switch / fresh upload gets a real retry.
14
+ *
15
+ * (Repo test convention: raw createApp + container queries, no
16
+ * @vue/test-utils dependency.)
17
+ */
18
+
19
+ const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
20
+
21
+ function mount(node: ReturnType<typeof h>) {
22
+ const container = document.createElement("div");
23
+ document.body.appendChild(container);
24
+ const app = createApp({ render: () => node });
25
+ app.mount(container);
26
+ mounts.push({ app, container });
27
+ return container;
28
+ }
29
+
30
+ afterEach(() => {
31
+ for (const { app, container } of mounts.splice(0)) {
32
+ app.unmount();
33
+ container.remove();
34
+ }
35
+ });
36
+
37
+ describe("HkAvatar", () => {
38
+ it("renders the letter fallback when no src is given", () => {
39
+ const c = mount(h(HkAvatar, { name: "yuzu" }));
40
+ expect(c.querySelector(".hk-avatar-fallback")?.textContent).toBe("Y");
41
+ expect(c.querySelector("img")).toBeNull();
42
+ });
43
+
44
+ it("renders the image with the name as alt", () => {
45
+ const c = mount(h(HkAvatar, { name: "yuzu", src: "/static/avatars/y.webp" }));
46
+ const img = c.querySelector("img") as HTMLImageElement | null;
47
+ expect(img).toBeTruthy();
48
+ expect(img!.getAttribute("src")).toBe("/static/avatars/y.webp");
49
+ expect(img!.getAttribute("alt")).toBe("yuzu");
50
+ });
51
+
52
+ it("swaps a broken image for the SAME letter fallback instead of the broken-picture glyph", async () => {
53
+ const c = mount(h(HkAvatar, { name: "demiurge", src: "/static/avatars/gone.webp" }));
54
+ const img = c.querySelector("img") as HTMLImageElement;
55
+ expect(img).toBeTruthy();
56
+ img.dispatchEvent(new Event("error"));
57
+ await nextTick();
58
+ expect(c.querySelector("img"), "a 404 must not leave a broken <img>").toBeNull();
59
+ expect(c.querySelector(".hk-avatar-fallback")?.textContent).toBe("D");
60
+ });
61
+
62
+ it("retries on the same instance when the src changes", async () => {
63
+ // A remount proves nothing (a fresh instance starts unlatched): the host
64
+ // re-renders the avatar with a new URL while it stays mounted, which is
65
+ // the account-switch / avatar-upload path.
66
+ const src = ref("/a.webp");
67
+ const Host = defineComponent({
68
+ setup: () => () => h(HkAvatar, { name: "yuzu", src: src.value }),
69
+ });
70
+ const c = mount(h(Host));
71
+ (c.querySelector("img") as HTMLImageElement).dispatchEvent(new Event("error"));
72
+ await nextTick();
73
+ expect(c.querySelector("img")).toBeNull();
74
+
75
+ src.value = "/b.webp";
76
+ await nextTick();
77
+ await nextTick();
78
+ const retry = c.querySelector("img") as HTMLImageElement | null;
79
+ expect(retry, "the latch reset — the new URL gets a fresh attempt").toBeTruthy();
80
+ expect(retry!.getAttribute("src")).toBe("/b.webp");
81
+ });
82
+
83
+ it("renders the NORMALIZED src, not the raw prop", () => {
84
+ // Pins the BINDING (mirrors the other two call sites): a padded URL
85
+ // must reach the <img> trimmed. A revert to the raw prop renders the
86
+ // padded value and fails this test — a whitespace-ONLY input cannot
87
+ // discriminate, because the guard hides the <img> in both
88
+ // implementations.
89
+ const c = mount(h(HkAvatar, { name: "yuzu", src: " /a.webp " }));
90
+ const img = c.querySelector("img") as HTMLImageElement | null;
91
+ expect(img).toBeTruthy();
92
+ expect(img!.getAttribute("src")).toBe("/a.webp");
93
+ });
94
+
95
+ it("treats a whitespace-only src as absent", () => {
96
+ // The shared latch normalizes the URL; master rendered `<img src=" ">`
97
+ // (a broken glyph) for a padded value.
98
+ const c = mount(h(HkAvatar, { name: "yuzu", src: " " }));
99
+ expect(c.querySelector("img")).toBeNull();
100
+ expect(c.querySelector(".hk-avatar-fallback")?.textContent).toBe("Y");
101
+ });
102
+
103
+ it("falls back to ? when the name is absent", () => {
104
+ const c = mount(h(HkAvatar, {}));
105
+ expect(c.querySelector(".hk-avatar-fallback")?.textContent).toBe("?");
106
+ });
107
+ });
@@ -1,5 +1,6 @@
1
1
  import { computed, defineComponent, type PropType } from "vue";
2
2
  import { useI18n } from "../i18n/context";
3
+ import { useAvatarImage } from "./avatarImage";
3
4
  import "./HkAvatar.scss";
4
5
 
5
6
  export default defineComponent({
@@ -15,11 +16,16 @@ export default defineComponent({
15
16
  "hk-avatar",
16
17
  `hk-avatar-${props.size}`,
17
18
  ]);
19
+ // A stored URL is not a guarantee: the blob can 404 (deleted upload,
20
+ // external provider unreachable, mirror cold). The failed-load latch
21
+ // swaps the broken <img> for the SAME letter chip the absent-src branch
22
+ // renders, so the roster never shows a browser broken-picture glyph.
23
+ const avatar = useAvatarImage(() => props.src);
18
24
 
19
25
  return () => (
20
26
  <div class={cls.value}>
21
- {props.src ? (
22
- <img src={props.src} alt={props.name} />
27
+ {avatar.src.value ? (
28
+ <img src={avatar.src.value} alt={props.name} onError={avatar.onError} />
23
29
  ) : (
24
30
  <span class="hk-avatar-fallback">{props.name?.charAt(0)?.toUpperCase() ?? t("hikari::avatar.fallback", "?")}</span>
25
31
  )}
@@ -182,6 +182,75 @@ describe("HkAdminHeader × HkAvatarButton / identity slot", () => {
182
182
  expect(c.querySelector(".s-admin-header-user")).toBeTruthy();
183
183
  });
184
184
 
185
+ it("renders the NORMALIZED url in the dropdown identity image", () => {
186
+ // Pins the BINDING of the admin-header call site (R3 mutation D): a
187
+ // padded URL must reach the <img> trimmed; a raw-prop revert renders
188
+ // the padded value and fails this test.
189
+ const c = mount(h(HkAdminHeader, { username: "yuzu", avatarUrl: " /a.png ", title: "D" }));
190
+ trigger(c).dispatchEvent(new MouseEvent("click", { bubbles: true }));
191
+ return Promise.resolve().then(async () => {
192
+ await nextTick();
193
+ await nextTick();
194
+ const img = document.body.querySelector(
195
+ ".s-user-header--profile img.s-user-avatar-img",
196
+ ) as HTMLImageElement | null;
197
+ expect(img).toBeTruthy();
198
+ expect(img!.getAttribute("src")).toBe("/a.png");
199
+ });
200
+ });
201
+
202
+ it("treats a whitespace-only avatarUrl as absent — the dropdown <img> never mounts", () => {
203
+ const c = mount(h(HkAdminHeader, { username: "yuzu", avatarUrl: " ", title: "D" }));
204
+ trigger(c).dispatchEvent(new MouseEvent("click", { bubbles: true }));
205
+ return Promise.resolve().then(async () => {
206
+ await nextTick();
207
+ await nextTick();
208
+ expect(
209
+ document.body.querySelector(".s-user-header--profile img.s-user-avatar-img"),
210
+ ).toBeNull();
211
+ expect(
212
+ document.body.querySelector(".s-user-header--profile .s-user-avatar")?.textContent,
213
+ ).toBe("Y");
214
+ });
215
+ });
216
+
217
+ it("heals the dropdown identity image with the shared latch", async () => {
218
+ // The fourth copy R2 caught: HkAdminHeader's in-menu identity image
219
+ // used its own failed-load ref. It must behave exactly like the trigger
220
+ // — an error shows the letter chip, and a URL change retries on the
221
+ // SAME mounted header (account switch / avatar re-upload).
222
+ const url = ref("/a.png");
223
+ const Host = defineComponent({
224
+ setup: () => () => h(HkAdminHeader, { username: "yuzu", avatarUrl: url.value, title: "D" }),
225
+ });
226
+ const c = mount(h(Host));
227
+ trigger(c).dispatchEvent(new MouseEvent("click", { bubbles: true }));
228
+ await nextTick();
229
+ await nextTick();
230
+ const first = document.body.querySelector(
231
+ ".s-user-header--profile img.s-user-avatar-img",
232
+ ) as HTMLImageElement | null;
233
+ expect(first, "the dropdown identity image renders").toBeTruthy();
234
+ first!.dispatchEvent(new Event("error"));
235
+ await nextTick();
236
+ expect(
237
+ document.body.querySelector(".s-user-header--profile img.s-user-avatar-img"),
238
+ "a broken identity image leaves the letter chip, not a broken glyph",
239
+ ).toBeNull();
240
+ expect(
241
+ document.body.querySelector(".s-user-header--profile .s-user-avatar")?.textContent,
242
+ ).toBe("Y");
243
+
244
+ url.value = "/b.png";
245
+ await nextTick();
246
+ await nextTick();
247
+ const retry = document.body.querySelector(
248
+ ".s-user-header--profile img.s-user-avatar-img",
249
+ ) as HTMLImageElement | null;
250
+ expect(retry, "the latch reset — the new URL gets a fresh attempt").toBeTruthy();
251
+ expect(retry!.getAttribute("src")).toBe("/b.png");
252
+ });
253
+
185
254
  it("an identity slot replaces the built-in dropdown block; the pending branch stays built-in", async () => {
186
255
  const opened = h(HkAdminHeader, {
187
256
  username: "yuzu",
@@ -1,4 +1,5 @@
1
- import { defineComponent, ref, watch, type PropType } from "vue";
1
+ import { defineComponent, type PropType } from "vue";
2
+ import { useAvatarImage } from "./avatarImage";
2
3
 
3
4
  /**
4
5
  * HkAvatarButton — the avatar trigger button, ONE component for every
@@ -40,13 +41,9 @@ export const HkAvatarButton = defineComponent({
40
41
  click: (_e: MouseEvent) => true,
41
42
  },
42
43
  setup(props, { emit }) {
43
- const avatarFailed = ref(false);
44
44
  // A new URL deserves a fresh attempt (account switch, avatar upload)
45
- // — the same self-heal the identity chips apply.
46
- watch(
47
- () => props.avatarUrl,
48
- () => { avatarFailed.value = false; },
49
- );
45
+ // — the shared failed-load latch owns the reset (avatarImage.ts).
46
+ const avatar = useAvatarImage(() => props.avatarUrl);
50
47
 
51
48
  return () => (
52
49
  <button
@@ -56,12 +53,12 @@ export const HkAvatarButton = defineComponent({
56
53
  aria-expanded={props.expanded}
57
54
  onClick={(e: MouseEvent) => { emit("click", e); }}
58
55
  >
59
- {props.avatarUrl && !avatarFailed.value ? (
56
+ {avatar.src.value ? (
60
57
  <img
61
- src={props.avatarUrl}
58
+ src={avatar.src.value}
62
59
  alt={props.username}
63
60
  class="s-admin-header-avatar-img"
64
- onError={() => { avatarFailed.value = true; }}
61
+ onError={avatar.onError}
65
62
  />
66
63
  ) : (
67
64
  // Letter fallback on the shared avatar primitive — the same
@@ -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
+ });
@@ -0,0 +1,88 @@
1
+ import { afterEach, describe, expect, it } from "vitest";
2
+ import { createApp, defineComponent, h, nextTick, ref } from "vue";
3
+
4
+ import HkMenuIdentityItem from "./HkMenuIdentityItem";
5
+
6
+ /**
7
+ * HkMenuIdentityItem — the standard menu identity row.
8
+ *
9
+ * Same 2026-11-20 rule as HkAvatar: a stored avatar URL that 404s must fall
10
+ * back to the initial-letter chip, never to the browser's broken-picture
11
+ * glyph, and a new URL on the same instance must retry.
12
+ */
13
+
14
+ const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
15
+
16
+ function mount(node: ReturnType<typeof h>) {
17
+ const container = document.createElement("div");
18
+ document.body.appendChild(container);
19
+ const app = createApp({ render: () => node });
20
+ app.mount(container);
21
+ mounts.push({ app, container });
22
+ return container;
23
+ }
24
+
25
+ afterEach(() => {
26
+ for (const { app, container } of mounts.splice(0)) {
27
+ app.unmount();
28
+ container.remove();
29
+ }
30
+ });
31
+
32
+ describe("HkMenuIdentityItem", () => {
33
+ it("renders the initial fallback when no avatar URL is given", () => {
34
+ const c = mount(h(HkMenuIdentityItem, { name: "yuzu", subtitle: "y@zu" }));
35
+ expect(c.querySelector(".hk-menu-identity-item__fallback")?.textContent).toBe("Y");
36
+ expect(c.querySelector("img")).toBeNull();
37
+ });
38
+
39
+ it("swaps a broken avatar for the initial fallback", async () => {
40
+ const c = mount(h(HkMenuIdentityItem, {
41
+ name: "yuzu",
42
+ subtitle: "y@zu",
43
+ avatarUrl: "/static/avatars/gone.webp",
44
+ }));
45
+ const img = c.querySelector("img") as HTMLImageElement;
46
+ expect(img).toBeTruthy();
47
+ img.dispatchEvent(new Event("error"));
48
+ await nextTick();
49
+ expect(c.querySelector("img")).toBeNull();
50
+ expect(c.querySelector(".hk-menu-identity-item__fallback")?.textContent).toBe("Y");
51
+ });
52
+
53
+ it("renders the NORMALIZED url, not the raw prop", () => {
54
+ // Pins the BINDING, not just the decision (R3 mutation C): a padded
55
+ // URL must reach the <img> trimmed. A revert to the raw prop renders
56
+ // ` /a.webp ` in the src attribute and fails this test (a
57
+ // whitespace-ONLY input cannot discriminate — the guard hides the img
58
+ // in both implementations).
59
+ const c = mount(h(HkMenuIdentityItem, { name: "yuzu", avatarUrl: " /a.webp " }));
60
+ const img = c.querySelector("img.hk-menu-identity-item__img") as HTMLImageElement | null;
61
+ expect(img).toBeTruthy();
62
+ expect(img!.getAttribute("src")).toBe("/a.webp");
63
+ });
64
+
65
+ it("treats a whitespace-only avatarUrl as absent — the <img> never mounts", () => {
66
+ const c = mount(h(HkMenuIdentityItem, { name: "yuzu", avatarUrl: " " }));
67
+ expect(c.querySelector("img.hk-menu-identity-item__img")).toBeNull();
68
+ expect(c.querySelector(".hk-menu-identity-item__fallback")?.textContent).toBe("Y");
69
+ });
70
+
71
+ it("retries when the avatar URL changes on the same instance", async () => {
72
+ const url = ref("/a.webp");
73
+ const Host = defineComponent({
74
+ setup: () => () => h(HkMenuIdentityItem, { name: "yuzu", avatarUrl: url.value }),
75
+ });
76
+ const c = mount(h(Host));
77
+ (c.querySelector("img") as HTMLImageElement).dispatchEvent(new Event("error"));
78
+ await nextTick();
79
+ expect(c.querySelector("img")).toBeNull();
80
+
81
+ url.value = "/b.webp";
82
+ await nextTick();
83
+ await nextTick();
84
+ const retry = c.querySelector("img") as HTMLImageElement | null;
85
+ expect(retry, "the latch reset — the new URL gets a fresh attempt").toBeTruthy();
86
+ expect(retry!.getAttribute("src")).toBe("/b.webp");
87
+ });
88
+ });
@@ -1,4 +1,5 @@
1
1
  import { defineComponent } from "vue";
2
+ import { useAvatarImage } from "./avatarImage";
2
3
  import "./HkMenuIdentityItem.scss";
3
4
 
4
5
  /**
@@ -18,11 +19,19 @@ export default defineComponent({
18
19
  avatarAlt: { type: String, default: "" },
19
20
  },
20
21
  setup(props, { slots }) {
22
+ // Same failed-load latch as HkAvatar: a stored URL that 404s must not
23
+ // leave the browser's broken-picture glyph in the menu header.
24
+ const avatar = useAvatarImage(() => props.avatarUrl);
21
25
  return () => (
22
26
  <div class="hk-menu-identity-item" role="presentation">
23
27
  <div class="hk-menu-identity-item__avatar" aria-hidden="true">
24
- {props.avatarUrl ? (
25
- <img src={props.avatarUrl} alt={props.avatarAlt || props.name} class="hk-menu-identity-item__img" />
28
+ {avatar.src.value ? (
29
+ <img
30
+ src={avatar.src.value}
31
+ alt={props.avatarAlt || props.name}
32
+ class="hk-menu-identity-item__img"
33
+ onError={avatar.onError}
34
+ />
26
35
  ) : (
27
36
  <span class="hk-menu-identity-item__fallback">
28
37
  {(props.name || "?").charAt(0).toUpperCase()}
@@ -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
  });