@celestia-island/hikari 0.55.478 → 0.55.479

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.478",
3
+ "version": "0.55.479",
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",
@@ -61,6 +61,16 @@ function mount(node: ReturnType<typeof h>) {
61
61
  return container;
62
62
  }
63
63
 
64
+ /** Mount and let the post-mount viewport pass run: the shell's mobile
65
+ * (drawer) / desktop (inline sidebar) split is decided one tick AFTER mount
66
+ * so the first client pass can match the server's viewport-less one
67
+ * (2026-11-24 — see HkFaceShell's mounted gate). */
68
+ async function mountSettled(node: ReturnType<typeof h>) {
69
+ const el = mount(node);
70
+ await nextTick();
71
+ return el;
72
+ }
73
+
64
74
  afterEach(() => {
65
75
  for (const { app, container } of mounts.splice(0)) {
66
76
  app.unmount();
@@ -230,6 +240,11 @@ describe("HkAdminShell", () => {
230
240
  { navTitle: "Navigation" },
231
241
  { header: () => null, sidebar: NAV, content: CONTENT },
232
242
  ));
243
+ // The viewport decides ONE TICK AFTER MOUNT (2026-11-24): the shell's
244
+ // first pass must agree with the server's (which has no viewport), so
245
+ // the phone/drawer split settles post-mount. See HkFaceShell's
246
+ // mounted gate.
247
+ await nextTick();
233
248
  expect(narrow.querySelector("aside .nav-mock")).toBeNull();
234
249
 
235
250
  // Custom 768: the same 900px reads as desktop (inline sidebar).
@@ -237,6 +252,7 @@ describe("HkAdminShell", () => {
237
252
  { navTitle: "Navigation", mobileBreakpoint: 768 },
238
253
  { header: () => null, sidebar: NAV, content: CONTENT },
239
254
  ));
255
+ await nextTick();
240
256
  expect(wide.querySelector("aside .nav-mock")).toBeTruthy();
241
257
  });
242
258
 
@@ -330,10 +346,13 @@ describe("HkAdminShell", () => {
330
346
  // scene) loses the side gutters on phones; vertical clearance
331
347
  // survives. Asserted via longhands — see the note above.
332
348
  setWidth(390);
333
- const mobileShell = mount(shellNode(
349
+ const mobileShell = await mountSettled(shellNode(
334
350
  { navTitle: "Navigation", contentPadding: "2rem", contentBleedOnMobile: true },
335
351
  { header: () => null, sidebar: NAV, content: CONTENT },
336
352
  ));
353
+ // Viewport-derived layout settles one tick after mount (the shell's
354
+ // mounted gate exists to agree with the server's viewport-less pass).
355
+ await nextTick();
337
356
  const inner = paddingInner(mobileShell);
338
357
  expect(inner?.style.paddingTop).toBe("2rem");
339
358
  expect(inner?.style.paddingBottom).toBe("2rem");
@@ -342,10 +361,11 @@ describe("HkAdminShell", () => {
342
361
 
343
362
  // Multi-value shorthand keeps per-side meaning: vertical survives,
344
363
  // horizontal is zeroed (never the inverted "1rem 2rem 0").
345
- const multi = mount(shellNode(
364
+ const multi = await mountSettled(shellNode(
346
365
  { navTitle: "Navigation", contentPadding: "1rem 2rem", contentBleedOnMobile: true },
347
366
  { header: () => null, sidebar: NAV, content: CONTENT },
348
367
  ));
368
+ await nextTick();
349
369
  const multiInner = paddingInner(multi);
350
370
  expect(multiInner?.style.paddingTop).toBe("1rem");
351
371
  expect(multiInner?.style.paddingBottom).toBe("1rem");
@@ -358,10 +378,11 @@ describe("HkAdminShell", () => {
358
378
  // values the bottom track defaults to the top one, which makes the
359
379
  // correct and the transposed string identical (round-1 verification
360
380
  // mutation (e) survived on exactly that hole).
361
- const triple = mount(shellNode(
381
+ const triple = await mountSettled(shellNode(
362
382
  { navTitle: "Navigation", contentPadding: "1rem 2rem 3rem", contentBleedOnMobile: true },
363
383
  { header: () => null, sidebar: NAV, content: CONTENT },
364
384
  ));
385
+ await nextTick();
365
386
  const tripleInner = paddingInner(triple);
366
387
  expect(tripleInner?.style.paddingTop).toBe("1rem");
367
388
  expect(tripleInner?.style.paddingBottom).toBe("3rem");
@@ -374,10 +395,11 @@ describe("HkAdminShell", () => {
374
395
  // slot is invisible to the shorter cases (round-2 verification
375
396
  // mutated "1rem 2rem 3rem 4rem" into "1rem 0 3rem 2rem" and the suite
376
397
  // stayed green).
377
- const quad = mount(shellNode(
398
+ const quad = await mountSettled(shellNode(
378
399
  { navTitle: "Navigation", contentPadding: "1rem 2rem 3rem 4rem", contentBleedOnMobile: true },
379
400
  { header: () => null, sidebar: NAV, content: CONTENT },
380
401
  ));
402
+ await nextTick();
381
403
  const quadInner = paddingInner(quad);
382
404
  expect(quadInner?.style.paddingTop).toBe("1rem");
383
405
  expect(quadInner?.style.paddingBottom).toBe("3rem");
@@ -392,7 +414,7 @@ describe("HkAdminShell", () => {
392
414
  // the shell as it shipped). happy-dom stores calc() values, so the
393
415
  // longhands are readable here; it cannot round-trip var()/min(), which
394
416
  // is why calc() is the probe.
395
- const fn = mount(shellNode(
417
+ const fn = await mountSettled(shellNode(
396
418
  { navTitle: "Navigation", contentPadding: "calc(1rem + 2px) 1rem", contentBleedOnMobile: true },
397
419
  { header: () => null, sidebar: NAV, content: CONTENT },
398
420
  ));
@@ -406,7 +428,7 @@ describe("HkAdminShell", () => {
406
428
  // single-level check): a bare `clamp()` cannot be the probe because
407
429
  // happy-dom rejects it outright, so the function rides in the second
408
430
  // track of a plain length.
409
- const nested = mount(shellNode(
431
+ const nested = await mountSettled(shellNode(
410
432
  { navTitle: "Navigation", contentPadding: "5rem clamp(1rem, min(2vw, 3px), 4rem)", contentBleedOnMobile: true },
411
433
  { header: () => null, sidebar: NAV, content: CONTENT },
412
434
  ));
@@ -417,7 +439,7 @@ describe("HkAdminShell", () => {
417
439
  expect(nestedInner?.style.paddingRight).toBe("0px");
418
440
 
419
441
  // …and so is a space directly after the opening parenthesis.
420
- const spacedFn = mount(shellNode(
442
+ const spacedFn = await mountSettled(shellNode(
421
443
  { navTitle: "Navigation", contentPadding: "calc( 1rem + 2px ) 1rem", contentBleedOnMobile: true },
422
444
  { header: () => null, sidebar: NAV, content: CONTENT },
423
445
  ));
@@ -433,7 +455,7 @@ describe("HkAdminShell", () => {
433
455
  // behaves the same way; it is pinned in HkAdminShell.padding.test.ts
434
456
  // because happy-dom refuses to store a comment-bearing value at all.)
435
457
  for (const keyword of ["inherit", "unset"]) {
436
- const wide = mount(shellNode(
458
+ const wide = await mountSettled(shellNode(
437
459
  { navTitle: "Navigation", contentPadding: keyword, contentBleedOnMobile: true },
438
460
  { header: () => null, sidebar: NAV, content: CONTENT },
439
461
  ));
@@ -444,7 +466,7 @@ describe("HkAdminShell", () => {
444
466
  // around a shorthand is not a track of its own ("\t1rem 2rem" must
445
467
  // read exactly like "1rem 2rem", never like a three-track value).
446
468
  for (const padded of ["1rem\t2rem", "1rem\n2rem", " 1rem 2rem ", "\t1rem 2rem"]) {
447
- const ws = mount(shellNode(
469
+ const ws = await mountSettled(shellNode(
448
470
  { navTitle: "Navigation", contentPadding: padded, contentBleedOnMobile: true },
449
471
  { header: () => null, sidebar: NAV, content: CONTENT },
450
472
  ));
@@ -457,7 +479,7 @@ describe("HkAdminShell", () => {
457
479
 
458
480
  // Nothing to strip: an empty value passes through untouched, it does
459
481
  // NOT become a zero padding of its own.
460
- const blank = mount(shellNode(
482
+ const blank = await mountSettled(shellNode(
461
483
  { navTitle: "Navigation", contentPadding: "", contentBleedOnMobile: true },
462
484
  { header: () => null, sidebar: NAV, content: CONTENT },
463
485
  ));
@@ -478,7 +500,7 @@ describe("HkAdminShell", () => {
478
500
  // The shell's own default padding (1.5rem) is what a consumer that
479
501
  // passes nothing actually gets — pinned here because this file
480
502
  // otherwise only ever exercises explicit values.
481
- const defaulted = mount(shellNode(
503
+ const defaulted = await mountSettled(shellNode(
482
504
  { navTitle: "Navigation", contentBleedOnMobile: true },
483
505
  { header: () => null, sidebar: NAV, content: CONTENT },
484
506
  ));
@@ -502,7 +524,7 @@ describe("HkAdminShell", () => {
502
524
  // …and a custom breakpoint moves it: the padding gate must read the
503
525
  // same `isDesktop` the layout does, not the 1024 default (round 3
504
526
  // mutated it to a hardcoded 1024 and the suite stayed green).
505
- const narrow = mount(shellNode(
527
+ const narrow = await mountSettled(shellNode(
506
528
  { navTitle: "Navigation", contentPadding: "2rem", contentBleedOnMobile: true, mobileBreakpoint: 768 },
507
529
  { header: () => null, sidebar: NAV, content: CONTENT },
508
530
  ));
@@ -520,7 +542,7 @@ describe("HkAdminShell", () => {
520
542
  // move the padding gate too. Round 3 mutated the gate to saturate at
521
543
  // 1024 and only a downward custom breakpoint was covered, so the
522
544
  // mirror image survived.
523
- const tablet = mount(shellNode(
545
+ const tablet = await mountSettled(shellNode(
524
546
  { navTitle: "Navigation", contentPadding: "2rem", contentBleedOnMobile: true, mobileBreakpoint: 1440 },
525
547
  { header: () => null, sidebar: NAV, content: CONTENT },
526
548
  ));
@@ -1,5 +1,6 @@
1
1
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
2
  import { createApp, defineComponent, h, ref, type VNode } from "vue";
3
+ import { renderToString } from "@vue/server-renderer";
3
4
 
4
5
  // Same stub shape as HkFaceShell.test.tsx: HDrawer teleports and
5
6
  // animates; the desktop rail contract is testable without the overlay
@@ -951,6 +952,72 @@ describe("rail group fold survives the crossfade generations (#43)", () => {
951
952
  expect(groupToggle(backGen).getAttribute("aria-expanded")).toBe("true");
952
953
  });
953
954
 
955
+ it("renders the DESKTOP layout on the server even when the viewport is a phone", async () => {
956
+ // 2026-11-24 user report: a phone showed a 248px inline sidebar and a
957
+ // 94px content column. Root cause was this shape — the server has no
958
+ // viewport, so it emitted the desktop layout, the client's first pass
959
+ // wanted the drawer, the structures differ, Vue kept the SERVER DOM and
960
+ // the drawer never appeared. The mounted gate keeps both first passes
961
+ // on the desktop layout; SSR therefore stays viewport-agnostic (a
962
+ // server render at phone width must NOT produce a drawer).
963
+ // MUT:mut-drop-gate (removing the mounted gate turns this RED).
964
+ window.innerWidth = 390;
965
+ const app = createApp({
966
+ render: () =>
967
+ h(
968
+ HkFaceShell,
969
+ { sidebarCollapsible: true } as Record<string, unknown>,
970
+ { sidebar: () => h("div", { class: "nav-stub" }, "nav") },
971
+ ),
972
+ });
973
+ const html = await renderToString(app);
974
+ expect(html, "SSR emits the desktop aside").toContain("data-shell-sidebar");
975
+ expect(html, "SSR never emits the drawer").not.toContain("drawer-stub");
976
+ // The pre-hydration CSS guard keys on this marker; if it stopped being
977
+ // emitted the guard would silently stop working on every phone while
978
+ // every assertion above stayed green (review round 2).
979
+ expect(html, "SSR stamps the booting marker the guard keys on").toContain(
980
+ "data-shell-booting",
981
+ );
982
+ });
983
+
984
+ it("never keeps a narrow-breakpoint host's sidebar hidden after mount", async () => {
985
+ // The pre-hydration CSS guard is scoped to `[data-shell-booting]`, which
986
+ // the shell REMOVES on mount. Without that bound, a host whose
987
+ // `mobileBreakpoint` prop is narrower than the stylesheet's 768px would
988
+ // have CSS hide the sidebar forever while its JS called the same
989
+ // viewport desktop — no sidebar and no drawer (review round 1 of #1535).
990
+ window.innerWidth = 700;
991
+ const c = mountShell({ sidebarCollapsible: true, mobileBreakpoint: 640 } as Record<string, unknown>);
992
+ await vi.advanceTimersByTimeAsync(0);
993
+ expect(
994
+ c.container.querySelector(".s-admin-shell")?.hasAttribute("data-shell-booting"),
995
+ "the booting marker must not outlive mount",
996
+ ).toBe(false);
997
+ expect(c.aside(), "the prop is authoritative once mounted").toBeTruthy();
998
+ window.innerWidth = 1280;
999
+ });
1000
+
1001
+ it("switches a phone to the drawer after mount, and drops the inline sidebar", async () => {
1002
+ // The POST-MOUNT STATE of the same contract: once mounted, the real
1003
+ // viewport decides — a phone gets the drawer as its ONLY nav surface and
1004
+ // the squeezed inline sidebar is gone from the body. This is a state
1005
+ // assertion, not the regression oracle: pre-fix a client-only mount at
1006
+ // 390px already produced the drawer (the bug lived in the SSR/client
1007
+ // disagreement, which the SSR test above pins and mutations.)
1008
+ window.innerWidth = 390;
1009
+ const c = mountShell({ sidebarCollapsible: true });
1010
+ await vi.advanceTimersByTimeAsync(0);
1011
+ expect(c.aside(), "no inline sidebar on a phone after mount").toBeFalsy();
1012
+ c.openDrawer();
1013
+ await vi.advanceTimersByTimeAsync(0);
1014
+ expect(
1015
+ c.container.querySelector(".drawer-stub-body"),
1016
+ "the drawer is the phone's nav surface",
1017
+ ).toBeTruthy();
1018
+ window.innerWidth = 1280;
1019
+ });
1020
+
954
1021
  it("shares the fold with the mobile drawer's menu (the provide sits above BOTH slots)", async () => {
955
1022
  // The rail is not the only slot consumer: under the breakpoint the same
956
1023
  // sidebar slot renders inside the drawer. The store is provided from
@@ -1,4 +1,4 @@
1
- import { computed, defineComponent, provide, ref, watch, type PropType, type SlotsType, type VNode } from "vue";
1
+ import { computed, defineComponent, onMounted, provide, ref, watch, type PropType, type SlotsType, type VNode } from "vue";
2
2
  import { HkCrossfade, HDrawer, HScrollContainer, useBreakpoint } from "@celestia-island/hikari";
3
3
  import { useI18n } from "../i18n/context";
4
4
  import { useActionBarCenter } from "../composables/useActionBar";
@@ -379,7 +379,31 @@ export const HkFaceShell = defineComponent({
379
379
  setup(props, { slots, emit }) {
380
380
  const { t } = useI18n();
381
381
  const { width: viewportWidth } = useBreakpoint();
382
- const isDesktop = computed(() => viewportWidth.value >= props.mobileBreakpoint);
382
+ // SSR-BLIND BREAKPOINT (2026-11-24 user report, phone screenshot): the
383
+ // server has no viewport, so it rendered the DESKTOP layout while a
384
+ // phone's first client pass wanted the drawer. The structures differ
385
+ // (inline aside vs HDrawer), Vue reports a hydration mismatch and keeps
386
+ // the SERVER DOM — so the phone kept a 248px inline sidebar squeezing
387
+ // the content to one word per line, and the drawer never appeared. This
388
+ // is the same root as hikari#1531.
389
+ //
390
+ // The gate makes both first passes identical (desktop, what SSR emits)
391
+ // and lets the viewport answer AFTER mount — the family's established
392
+ // pattern for viewport-derived values (`useChromeActionSize` in
393
+ // HkFilterTrigger, the family's own `mounted`-guarded chrome size).
394
+ // Pre-mount the squeezed inline sidebar is kept off a phone's screen by
395
+ // CSS (see the media rule in HkSidebarRail.scss), so the flash the gate
396
+ // would otherwise cost never reaches the user. That CSS keys on
397
+ // `[data-shell-booting]` — the marker below — so it can NEVER outlive
398
+ // the pre-mount window and fight a host whose `mobileBreakpoint` is
399
+ // narrower than the stylesheet's breakpoint.
400
+ const mounted = ref(false);
401
+ onMounted(() => {
402
+ mounted.value = true;
403
+ });
404
+ const isDesktop = computed(
405
+ () => !mounted.value || viewportWidth.value >= props.mobileBreakpoint,
406
+ );
383
407
  const sidebarOpen = ref(false);
384
408
  // ── the header's CENTRE channel, read from the bar above ─────────
385
409
  // This shell provides NO bar of its own (whoever provides, provides
@@ -545,7 +569,7 @@ export const HkFaceShell = defineComponent({
545
569
  }
546
570
 
547
571
  return () => (
548
- <div class="s-admin-shell">
572
+ <div class="s-admin-shell" data-shell-booting={mounted.value ? undefined : true}>
549
573
  {slots.header && (
550
574
  <div style={{ flexShrink: 0 }}>
551
575
  {slots.header({
@@ -578,6 +602,7 @@ export const HkFaceShell = defineComponent({
578
602
  <aside
579
603
  ref={railHostRef}
580
604
  class="hk-sidebar-rail-host"
605
+ data-shell-sidebar
581
606
  // STATE marker only (hosts/tests read "the rail layout is
582
607
  // active"): the rail DENSITY dress itself rides the swap's
583
608
  // generation inside the clip, so it can freeze on the
@@ -649,6 +674,7 @@ export const HkFaceShell = defineComponent({
649
674
  </aside>
650
675
  ) : (
651
676
  <aside
677
+ data-shell-sidebar
652
678
  style={{
653
679
  width: props.sidebarWidth,
654
680
  flexShrink: 0,
@@ -1,5 +1,5 @@
1
1
  import { afterEach, describe, expect, it } from "vitest";
2
- import { createApp, h } from "vue";
2
+ import { createApp, h, nextTick, reactive } from "vue";
3
3
  import { readFileSync } from "node:fs";
4
4
  import { dirname, join } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
@@ -389,3 +389,80 @@ describe("HkPillToggleGroup track geometry contract", () => {
389
389
  expect(phoneDecls.has("max-width"), "no max-width in the phone block").toBe(false);
390
390
  });
391
391
  });
392
+
393
+ // ── Fade re-sensing on content mutations (the 2026-11-24 report): the
394
+ // option set collapsing from several pills to one must retire the edge
395
+ // fade the wide layout earned, without a scroll and without the strip's
396
+ // own box resizing. The strip's MutationObserver funnels the mutations
397
+ // that can move scrollWidth into sense(). happy-dom performs no layout,
398
+ // so the stubbed strip geometry IS the new layout — the DOM mutation
399
+ // only has to TRIGGER the re-sense, which is the contract under test.
400
+ describe("HkPillToggleGroup fade re-sensing", () => {
401
+ // Mutation matrix (PR #1534 independent review rounds; ids match that run
402
+ // ledger): MUT:strip-childlist-only — reverting the strip observer to
403
+ // childList-only reds the characterData test below while the collapse test
404
+ // keeps its green (that path is childList, which the mutation isolates
405
+ // rather than breaks); MUT:strip-callback-neutered — a no-op observer
406
+ // callback reds both tests, so sensing runs through the observer and never
407
+ // through an accident of the stubbed geometry.
408
+ /** Drain the mutation microtask: the strip callback is `sense` directly
409
+ * (no rAF hop), so the macrotask tick alone delivers it — the trailing
410
+ * frames only keep the flush shape uniform with the scroller's
411
+ * rAF-coalesced pass. */
412
+ async function flushSensing(): Promise<void> {
413
+ await new Promise<void>((r) => setTimeout(r, 0));
414
+ await new Promise<void>((r) => requestAnimationFrame(() => r()));
415
+ await new Promise<void>((r) => requestAnimationFrame(() => r()));
416
+ }
417
+
418
+ function stubStripGeometry(strip: HTMLElement, scrollWidth: number, clientWidth: number): void {
419
+ Object.defineProperty(strip, "scrollWidth", { configurable: true, get: () => scrollWidth });
420
+ Object.defineProperty(strip, "clientWidth", { configurable: true, get: () => clientWidth });
421
+ Object.defineProperty(strip, "scrollLeft", { configurable: true, get: () => 0 });
422
+ }
423
+
424
+ it("retires the end fade when the option set collapses to one pill", async () => {
425
+ const options = reactive([
426
+ { value: "chat", label: "Chat" },
427
+ { value: "draw", label: "Draw" },
428
+ ]);
429
+ const c = mount(h(HkPillToggleGroup, { label: "P", options, selected: new Set<string>() }));
430
+ // The composable wires scroll/wheel/MO sensors in a watch on the
431
+ // strip ref — flush the mount queue so the wiring has run before any
432
+ // stubbed geometry or dispatched event.
433
+ await nextTick();
434
+ const strip = c.querySelector<HTMLElement>(".hk-pill-group")!;
435
+ stubStripGeometry(strip, 400, 120);
436
+ strip.dispatchEvent(new Event("scroll"));
437
+ expect(strip.getAttribute("data-h-overflow")).toBe("end");
438
+
439
+ // The surviving layout fits (the stub IS that layout); the childList
440
+ // mutation from the patch is the only trigger the new state arrives
441
+ // through.
442
+ stubStripGeometry(strip, 80, 120);
443
+ options.splice(1);
444
+ await nextTick();
445
+ await flushSensing();
446
+ expect(strip.hasAttribute("data-h-overflow")).toBe(false);
447
+ });
448
+
449
+ it("lights the fade when a label is rewritten in place (characterData only)", async () => {
450
+ const options = reactive([{ value: "chat", label: "Chat" }]);
451
+ const c = mount(h(HkPillToggleGroup, { label: "P", options, selected: new Set<string>() }));
452
+ // Same wiring flush as above: the sensors must already be attached
453
+ // when the mutation lands, or the test exercises nothing.
454
+ await nextTick();
455
+ const strip = c.querySelector<HTMLElement>(".hk-pill-group")!;
456
+ stubStripGeometry(strip, 80, 120);
457
+ strip.dispatchEvent(new Event("scroll"));
458
+ expect(strip.hasAttribute("data-h-overflow")).toBe(false);
459
+
460
+ stubStripGeometry(strip, 400, 120);
461
+ // A relabeled pill adds no child and removes none — the text node
462
+ // mutation alone must re-sense.
463
+ const pill = strip.querySelectorAll<HTMLButtonElement>(".hk-pill-group-pill")[0]!;
464
+ (pill.firstChild as Text).data = "Conversation with a much longer title";
465
+ await flushSensing();
466
+ expect(strip.getAttribute("data-h-overflow")).toBe("end");
467
+ });
468
+ });
@@ -183,6 +183,91 @@ describe("HkScrollContainer overflow sensing", () => {
183
183
  });
184
184
  });
185
185
 
186
+ // ── Content mutation re-sensing (the 2026-11-24 fade-staleness report):
187
+ // a content-only change — the option set collapsing from several buttons
188
+ // to one, a label rewritten, a row toggled hidden — moves scroll extent
189
+ // without resizing the viewport box (no ResizeObserver callback) and
190
+ // usually without moving the offset (no scroll event). The overflow
191
+ // mirror and the fade strengths must re-sense anyway: the viewport
192
+ // MutationObserver funnels those mutations into the same pass. happy-dom
193
+ // performs no layout, so the stubbed geometry IS the new layout — the
194
+ // mutation only has to TRIGGER the re-sense, which is the contract under
195
+ // test; no refresh() call and no scroll event may be involved. ──
196
+ describe("HkScrollContainer content mutation re-sensing", () => {
197
+ // Mutation matrix (PR #1534 independent review rounds; ids match that run
198
+ // ledger): MUT:detach-sensor — removing startContentSensing() from
199
+ // onMounted reds all four tests in this group ("expected 'end' to be
200
+ // 'none'" and twins); MUT:neuter-callback — an attached observer with a
201
+ // no-op callback reds the same four, so the funnel and not merely the
202
+ // attachment is load-bearing; MUT:widening-style — adding "style" to the
203
+ // attributeFilter keeps them green, the documented performance trade
204
+ // (deliberately not test-pinned).
205
+ /** Drain the mutation microtask, then two frames: the MO callback
206
+ * schedules the sensing pass, the bus delivers it on the next frame. */
207
+ async function flushSensing(): Promise<void> {
208
+ await new Promise<void>((r) => setTimeout(r, 0));
209
+ await new Promise<void>((r) => requestAnimationFrame(() => r()));
210
+ await new Promise<void>((r) => requestAnimationFrame(() => r()));
211
+ }
212
+
213
+ it("retires a lit end fade when the content shrinks without scroll or resize", async () => {
214
+ const m = mountScroller({ axis: "horizontal", fade: true });
215
+ stubGeometry(m.viewport, { scrollWidth: 300, clientWidth: 100, scrollLeft: 0 });
216
+ m.instance?.refresh();
217
+ expect(m.root.getAttribute("data-h-overflow")).toBe("end");
218
+
219
+ // The strip collapses to a fitting layout (the stub IS the new
220
+ // layout), and the DOM actually changes — the mutation is the only
221
+ // trigger the new state can arrive through.
222
+ stubGeometry(m.viewport, { scrollWidth: 50, clientWidth: 100, scrollLeft: 0 });
223
+ m.viewport.querySelector(".slot-marker")!.remove();
224
+ await flushSensing();
225
+ expect(m.root.getAttribute("data-h-overflow")).toBe("none");
226
+ });
227
+
228
+ it("re-derives the fade strengths on the same mutation (the reported defect)", async () => {
229
+ const m = mountScroller({ axis: "horizontal", fade: true });
230
+ stubGeometry(m.viewport, { scrollWidth: 300, clientWidth: 100, scrollLeft: 48 });
231
+ m.instance?.refresh();
232
+ // Mid-pull: the start edge sits at half depth (48/96)...
233
+ expect(m.root.style.getPropertyValue("--hk-scroll-fade-strength-left")).toBe("0.5");
234
+
235
+ // ...then everything fits again — the strength must re-derive from
236
+ // the new geometry or the mask keeps dissolving a button that is
237
+ // fully visible.
238
+ stubGeometry(m.viewport, { scrollWidth: 50, clientWidth: 100, scrollLeft: 0 });
239
+ m.viewport.querySelector(".slot-marker")!.remove();
240
+ await flushSensing();
241
+ expect(m.root.style.getPropertyValue("--hk-scroll-fade-strength-left")).toBe("1");
242
+ });
243
+
244
+ it("re-senses when only a text node changes (relabeled option)", async () => {
245
+ const m = mountScroller({ axis: "horizontal" });
246
+ stubGeometry(m.viewport, { scrollWidth: 50, clientWidth: 100, scrollLeft: 0 });
247
+ m.instance?.refresh();
248
+ expect(m.root.getAttribute("data-h-overflow")).toBe("none");
249
+
250
+ stubGeometry(m.viewport, { scrollWidth: 300, clientWidth: 100, scrollLeft: 0 });
251
+ // A characterData mutation — a label rewritten in place adds no
252
+ // child and removes none.
253
+ (m.viewport.querySelector(".slot-marker")!.firstChild as Text).data = "much longer label";
254
+ await flushSensing();
255
+ expect(m.root.getAttribute("data-h-overflow")).toBe("end");
256
+ });
257
+
258
+ it("re-senses when only a class attribute flips (visibility change)", async () => {
259
+ const m = mountScroller({ axis: "horizontal" });
260
+ stubGeometry(m.viewport, { scrollWidth: 50, clientWidth: 100, scrollLeft: 0 });
261
+ m.instance?.refresh();
262
+ expect(m.root.getAttribute("data-h-overflow")).toBe("none");
263
+
264
+ stubGeometry(m.viewport, { scrollWidth: 300, clientWidth: 100, scrollLeft: 0 });
265
+ m.viewport.querySelector(".slot-marker")!.classList.add("wide-mode");
266
+ await flushSensing();
267
+ expect(m.root.getAttribute("data-h-overflow")).toBe("end");
268
+ });
269
+ });
270
+
186
271
  // ── Progressive fade strengths (fadeDistance, 2026-11-06): while `fade`
187
272
  // is on the container mirrors the hidden-content depth past each edge as
188
273
  // a 0..1 band scale on the root's inline style — pull the strip and the
@@ -876,7 +876,8 @@ export default defineComponent({
876
876
  * the per-edge fade strengths (hidden-content depth saturating over
877
877
  * fadeDistance); while `overflowGlow` is on, derive the glow's
878
878
  * physical edges from the same verdicts. Runs on every scheduled
879
- * update (scroll, resize, content resize via the aligner).
879
+ * update (scroll, resize, content resize via the aligner, content
880
+ * mutations via the viewport MutationObserver).
880
881
  *
881
882
  * Anchor parking runs FIRST (when opted in): it writes the scroll
882
883
  * offset, and every geometry read below must see the post-park state —
@@ -1101,6 +1102,59 @@ export default defineComponent({
1101
1102
  }
1102
1103
  }
1103
1104
 
1105
+ // ── Content mutation sensing (always on) ───────────────────────────
1106
+ // A content-only change — an option list replaced, a tab strip
1107
+ // collapsing from several buttons to one, a label rewritten, a row
1108
+ // toggled hidden — moves scrollWidth/scrollHeight WITHOUT resizing
1109
+ // the viewport box (the viewport ResizeObserver never fires) and
1110
+ // usually WITHOUT moving the scroll offset (no scroll event runs).
1111
+ // None of the sensors above see it, so the overflow mirror and the
1112
+ // fade strengths sat stale until the user happened to scroll or
1113
+ // resize — the reported defect: a strip that shrank to a single
1114
+ // button kept the end-edge fade the wide layout had earned, because
1115
+ // the last gradient computation ran against the OLD content width
1116
+ // and nothing ever re-sensed. The align="center" aligner RO covered
1117
+ // only the aligner's own box (horizontal center mode); align="start"
1118
+ // strips and vertical containers had NO trigger at all. A viewport
1119
+ // MutationObserver funnels the DOM mutations that can move the
1120
+ // scroll extent into the same rAF-coalesced, write-only-on-change
1121
+ // pass — one batched geometry read per frame during mutation
1122
+ // storms, exactly the cost a scroll event already pays. The
1123
+ // attribute filter is the display-relevant closed set: class and
1124
+ // hidden flip visibility/size; `style` is deliberately NOT observed
1125
+ // (a per-frame inline-style writer inside the content would sense
1126
+ // every frame for no geometry change a style write can cause on its
1127
+ // own) — which makes a style-driven resize this filter's one blind
1128
+ // spot, and the reason the exposed refresh() keeps existing.
1129
+ // Unconditional, because every extent-derived mirror of this
1130
+ // container (data-h/v-overflow, fade strengths, dock gates, the
1131
+ // anchor's extent re-park) went stale the same way; backTop is
1132
+ // offset-derived and cannot go stale from a content change, but it
1133
+ // re-reads harmlessly on the same pass.
1134
+ let contentMO: MutationObserver | null = null;
1135
+
1136
+ /** Attach the content mutation sensor (see the block comment). */
1137
+ function startContentSensing() {
1138
+ const vp = viewportRef.value;
1139
+ if (!vp || contentMO) return;
1140
+ contentMO = new MutationObserver(scheduleUpdate);
1141
+ contentMO.observe(vp, {
1142
+ childList: true,
1143
+ subtree: true,
1144
+ characterData: true,
1145
+ attributes: true,
1146
+ attributeFilter: ["class", "hidden"],
1147
+ });
1148
+ }
1149
+
1150
+ /** Drop the content sensor: teardown only — the sensed state is
1151
+ * live geometry, cleared nowhere (the DOM subtree dies with the
1152
+ * root, and a re-mount re-senses from scratch on mount). */
1153
+ function stopContentSensing() {
1154
+ contentMO?.disconnect();
1155
+ contentMO = null;
1156
+ }
1157
+
1104
1158
  // Runtime prop swaps: attach/detach the mutation sensor, and
1105
1159
  // re-sense immediately either way (turning the hint on with a
1106
1160
  // selection already beyond the band must not wait for a scroll;
@@ -1268,6 +1322,8 @@ export default defineComponent({
1268
1322
  ro = new ResizeObserver(scheduleUpdate);
1269
1323
  ro.observe(vp);
1270
1324
 
1325
+ startContentSensing();
1326
+
1271
1327
  syncAlignObserver();
1272
1328
 
1273
1329
  if (props.autoFollow && autoFollowContent.value) {
@@ -1297,6 +1353,7 @@ export default defineComponent({
1297
1353
  stopApproach();
1298
1354
  selectionMO?.disconnect();
1299
1355
  selectionMO = null;
1356
+ stopContentSensing();
1300
1357
  scheduled?.disconnect();
1301
1358
  settleHandle?.disconnect();
1302
1359
  settleHandle = null;
@@ -1394,9 +1451,11 @@ export default defineComponent({
1394
1451
  }
1395
1452
 
1396
1453
  /** Re-run the scrollbar + overflow sensing pass. Public escape
1397
- * hatch for content mutations the observers cannot see (e.g. the
1398
- * slot's own children resizing without the aligner box changing,
1399
- * or non-align consumers swapping content). */
1454
+ * hatch for extent changes no observer reports: a font swap or an
1455
+ * image load resizing content without any DOM mutation, and the
1456
+ * mutation filter's deliberate blind spot — a style-driven resize
1457
+ * (`style` is not observed, so a host that drives layout through
1458
+ * inline style calls this after the write). */
1400
1459
  function refresh(): void {
1401
1460
  overlay?.update();
1402
1461
  update();
@@ -346,3 +346,26 @@
346
346
  transition: none;
347
347
  }
348
348
  }
349
+
350
+
351
+ /* PRE-HYDRATION PHONE GUARD (2026-11-24).
352
+ *
353
+ * The shell decides desktop-vs-drawer from the viewport, and the server has
354
+ * none — so the emitted HTML carries the DESKTOP layout (an inline 224/248px
355
+ * sidebar) while a phone's first client pass wants the drawer. The mounted
356
+ * gate in HkFaceShell keeps the two first passes identical and flips after
357
+ * mount; this rule covers the window BEFORE that flip so a phone never paints
358
+ * a squeezed content column (measured: 94px of text at 390px viewport, one
359
+ * word per line).
360
+ *
361
+ * `[data-shell-booting]` is what bounds it: the shell stamps that marker on
362
+ * every pre-mount pass (SSR included) and REMOVES it on mount, so the rule
363
+ * stops applying the instant the JS layout becomes authoritative. Without
364
+ * that bound a host whose `mobileBreakpoint` prop is NARROWER than this
365
+ * stylesheet's breakpoint would have its sidebar hidden by CSS forever while
366
+ * its JS called the same viewport desktop — no sidebar AND no drawer. */
367
+ @media (width <= 767px) {
368
+ .s-admin-shell[data-shell-booting] > .s-admin-shell-body > [data-shell-sidebar] {
369
+ display: none;
370
+ }
371
+ }