@celestia-island/hikari 0.55.353 → 0.55.355

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.353",
3
+ "version": "0.55.355",
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",
@@ -204,6 +204,13 @@ export const HkAdminHeader = defineComponent({
204
204
  // lives OUTSIDE the class expression: the self-sufficiency audit
205
205
  // reads that expression's literals, and prose apostrophes inside it
206
206
  // parse as string boundaries.)
207
+ //
208
+ // Chrome mode is also the caption-band contract: the header IS the
209
+ // window title bar there, so it claims the titlebar layer
210
+ // (.hk-chrome-band) and an open modal's veil paints UNDER it — the
211
+ // drag row and its HkWindowControls stay alive while any HkModal
212
+ // covers the app, the same immunity HkTitleBar gives a real caption
213
+ // strip (styles/admin-tokens.scss, the chrome-band block).
207
214
  return () => (
208
215
  <header
209
216
  class={[
@@ -211,6 +218,7 @@ export const HkAdminHeader = defineComponent({
211
218
  "s-balanced-header",
212
219
  props.compact ? "s-glass-header--compact" : "",
213
220
  props.chrome ? "s-glass-header--chrome" : "",
221
+ props.chrome ? "hk-chrome-band" : "",
214
222
  ]}
215
223
  >
216
224
  <div ref={userTriggerRef} class="s-admin-header-user s-header-wing-start">
@@ -36,7 +36,13 @@
36
36
  // ramping over 0.42s) reads as focus pull, not as a missing layer.
37
37
  .hk-modal-blur-plate {
38
38
  position: fixed;
39
- inset: 0;
39
+ // --hk-chrome-band-inset: the chrome-band contract's stacking-proof
40
+ // leg (see .hk-modal-overlay below). Both fixed plates yield their top
41
+ // edge together, or the band would still blur under a dim-free veil.
42
+ top: var(--hk-chrome-band-inset, 0px);
43
+ right: 0;
44
+ bottom: 0;
45
+ left: 0;
40
46
  // Below the overlay (0) and the content frame (1) inside the root's own
41
47
  // stacking context — the plate is DOM-last but paints first.
42
48
  z-index: -1;
@@ -63,7 +69,19 @@
63
69
 
64
70
  .hk-modal-overlay {
65
71
  position: fixed;
66
- inset: 0;
72
+ // The chrome-band contract's stacking-proof leg: a host caption band
73
+ // (.hk-chrome-band, admin-tokens) claims the titlebar layer by z, but a
74
+ // band trapped inside a z<90000 stacking-context ancestor (#app-style
75
+ // wrappers — chest's theme.scss keeps one for its wallpaper, 2026-11-12
76
+ // field reports) cannot win that z race against this body-level root.
77
+ // The inset is geometry instead: the veil's top edge starts BELOW the
78
+ // band, so the caption row keeps its paint and its pointer events with
79
+ // no z competition at all. 0px default keeps every existing host's
80
+ // full-viewport veil byte-identical.
81
+ top: var(--hk-chrome-band-inset, 0px);
82
+ right: 0;
83
+ bottom: 0;
84
+ left: 0;
67
85
  // Explicit stacking inside the root: the content sibling is ALWAYS above
68
86
  // the overlay regardless of the popup-manager base handed to the root
69
87
  // (fixes the blurred overlay painting over the sheet when the manager
@@ -19,7 +19,7 @@ import { dirname, join } from "node:path";
19
19
  import { fileURLToPath } from "node:url";
20
20
 
21
21
  import { afterEach, describe, expect, it } from "vitest";
22
- import { createApp, h, defineComponent, type VNodeChild } from "vue";
22
+ import { createApp, h, defineComponent, ref, type VNodeChild } from "vue";
23
23
 
24
24
  import HkKanban from "./HkKanban";
25
25
  import HkScrollContainer from "./HkScrollContainer";
@@ -70,6 +70,101 @@ describe("HkScrollContainer dock slots", () => {
70
70
  expect(host.style.getPropertyValue("--hk-scroll-dock-top")).toBe("0px");
71
71
  });
72
72
 
73
+ it("retires the dock band at the scroll end instead of covering the last row", async () => {
74
+ // 2026-11-12 user report: the cruise board's band kept painting over
75
+ // its own flush-parked last row at full scroll. Dock bands share the
76
+ // strength vars but are NOT the `fade` ramp, so they used to sit at
77
+ // their designed full depth forever. The dock path now publishes a
78
+ // BINARY gate: lit while content still hides past the edge, retired
79
+ // (0) once nothing does.
80
+ const instance = ref<{ refresh: () => void } | null>(null);
81
+ const container = document.createElement("div");
82
+ document.body.appendChild(container);
83
+ containers.push(container);
84
+ const app = createApp(defineComponent({
85
+ setup() {
86
+ return () =>
87
+ h(
88
+ HkScrollContainer,
89
+ { ref: instance as never, dockFade: true },
90
+ {
91
+ default: () => h("div", { class: "content" }, "rows"),
92
+ dockBottom: () => h("div", { class: "the-dock" }, "dock"),
93
+ },
94
+ );
95
+ },
96
+ }));
97
+ mounts.push(app);
98
+ const host = (app.mount(container) as unknown as { $el: HTMLElement }).$el;
99
+ const viewport = host.querySelector(".hk-scroll-container-viewport") as HTMLElement;
100
+ const strength = () => host.style.getPropertyValue("--hk-scroll-fade-strength-bottom");
101
+
102
+ const stub = (scrollTop: number) => {
103
+ Object.defineProperty(viewport, "scrollHeight", { value: 400, configurable: true });
104
+ Object.defineProperty(viewport, "clientHeight", { value: 100, configurable: true });
105
+ Object.defineProperty(viewport, "scrollTop", { value: scrollTop, configurable: true });
106
+ };
107
+
108
+ stub(0);
109
+ instance.value?.refresh();
110
+ await Promise.resolve();
111
+ // 300 hidden below the fold: lit at full depth.
112
+ expect(strength()).toBe("1");
113
+
114
+ stub(300);
115
+ viewport.dispatchEvent(new Event("scroll"));
116
+ // The scroll listener re-senses on a scheduled frame; refresh() is the
117
+ // synchronous pass these tests use (the scroll event also proves the
118
+ // listener path does not resurrect the band).
119
+ instance.value?.refresh();
120
+ await Promise.resolve();
121
+ // Parked at the end: nothing left to hide, so the band retires.
122
+ expect(strength()).toBe("0");
123
+ });
124
+
125
+ it("keeps the dock gate's 1px deadband, like the overflow sense", async () => {
126
+ // The gate is `depth <= 1`, the same deadband computeOverflow uses, so
127
+ // a band can never retire while a visible sliver is still hidden, and
128
+ // it can never linger one pixel past the end.
129
+ const instance = ref<{ refresh: () => void } | null>(null);
130
+ const container = document.createElement("div");
131
+ document.body.appendChild(container);
132
+ containers.push(container);
133
+ const app = createApp(defineComponent({
134
+ setup() {
135
+ return () =>
136
+ h(
137
+ HkScrollContainer,
138
+ { ref: instance as never, dockFade: true },
139
+ {
140
+ default: () => h("div", { class: "content" }, "rows"),
141
+ dockBottom: () => h("div", { class: "the-dock" }, "dock"),
142
+ },
143
+ );
144
+ },
145
+ }));
146
+ mounts.push(app);
147
+ const host = (app.mount(container) as unknown as { $el: HTMLElement }).$el;
148
+ const viewport = host.querySelector(".hk-scroll-container-viewport") as HTMLElement;
149
+ const strength = () => host.style.getPropertyValue("--hk-scroll-fade-strength-bottom");
150
+ const stub = (scrollTop: number) => {
151
+ Object.defineProperty(viewport, "scrollHeight", { value: 400, configurable: true });
152
+ Object.defineProperty(viewport, "clientHeight", { value: 100, configurable: true });
153
+ Object.defineProperty(viewport, "scrollTop", { value: scrollTop, configurable: true });
154
+ };
155
+
156
+ // vMax = 400 - 100 = 300; scrollTop 298 leaves EXACTLY 2px hidden.
157
+ stub(298); // 2px still hidden: the band stays lit
158
+ instance.value?.refresh();
159
+ await Promise.resolve();
160
+ expect(strength()).toBe("1");
161
+
162
+ stub(299); // 1px: inside the shared deadband, the band retires
163
+ instance.value?.refresh();
164
+ await Promise.resolve();
165
+ expect(strength()).toBe("0");
166
+ });
167
+
73
168
  it("renders a top dock and fades the top edge instead", () => {
74
169
  const vm = mountDock({
75
170
  default: () => h("div", { class: "content" }, "rows"),
@@ -198,8 +198,19 @@ describe("scroll fade composition contract", () => {
198
198
  ).toBeNull();
199
199
  });
200
200
 
201
- it("routes the dock fades through the same edge vars", () => {
202
- expect(sheet).toContain('--hk-scroll-fade-bottom: var(--hk-scroll-dock-fade, 2rem)');
203
- expect(sheet).toContain('--hk-scroll-fade-top: var(--hk-scroll-dock-fade, 2rem)');
201
+ it("routes the dock fades through the same edge vars, scaled by strength", () => {
202
+ // A dock band is its own size TIMES the published strength: the
203
+ // component's dock path publishes a binary gate (lit while the edge
204
+ // hides content, retired at the end), and a constant band would never
205
+ // retire — it used to paint over the flush-parked last row at full
206
+ // scroll (2026-11-12 user report). The multiplication is the only
207
+ // consumer of that gate, so this pin is what keeps the fix real; the
208
+ // `1` fallback preserves the pre-fix band wherever nothing publishes.
209
+ const scaled = (side: "top" | "bottom") =>
210
+ new RegExp(
211
+ `--hk-scroll-fade-${side}:\\s*calc\\(\\s*var\\(--hk-scroll-dock-fade, 2rem\\)\\s*\\*\\s*var\\(--hk-scroll-fade-strength-${side}, 1\\)\\s*\\)`,
212
+ );
213
+ expect(sheet, "bottom dock band scales by strength").toMatch(scaled("bottom"));
214
+ expect(sheet, "top dock band scales by strength").toMatch(scaled("top"));
204
215
  });
205
216
  });
@@ -378,13 +378,29 @@
378
378
  shared edge therefore deepens with the pull (≤ --space-24) and snaps
379
379
  to the full dock fade only at the scroll end; no shipped consumer
380
380
  combines the two, but a future one should treat that as the
381
- documented shape, not a bug. */
381
+ documented shape, not a bug.
382
+
383
+ The dock band MULTIPLIES its own size by the published strength
384
+ (2026-11-12 user report). Without that factor the band was a constant:
385
+ the component never publishes strengths for a dock-only container (the
386
+ `fade` prop owns that ramp), so the band sat at full depth forever and
387
+ a scroller parked at its END kept painting over its own last row —
388
+ 「拉到最底部仍然有渐变阴影覆盖最后一行」. The dock path now publishes a
389
+ binary gate (lit while the edge hides content, retired at the end), and
390
+ this `calc()` is what turns it into px: at the end the band is 0, so
391
+ the flush-parked row reads in full. The `1` fallback keeps the
392
+ pre-fix full band wherever nothing is published (SSR, no JS pass yet,
393
+ a ride dock — those never stamp the marker). */
382
394
  .hk-scroll-container[data-dock-fade="bottom"] {
383
- --hk-scroll-fade-bottom: var(--hk-scroll-dock-fade, 2rem);
395
+ --hk-scroll-fade-bottom: calc(
396
+ var(--hk-scroll-dock-fade, 2rem) * var(--hk-scroll-fade-strength-bottom, 1)
397
+ );
384
398
  }
385
399
 
386
400
  .hk-scroll-container[data-dock-fade="top"] {
387
- --hk-scroll-fade-top: var(--hk-scroll-dock-fade, 2rem);
401
+ --hk-scroll-fade-top: calc(
402
+ var(--hk-scroll-dock-fade, 2rem) * var(--hk-scroll-fade-strength-top, 1)
403
+ );
388
404
  }
389
405
 
390
406
  /* ── Floating-dock tail clearance (dockTailClearance opt-in) ──────
@@ -920,6 +920,30 @@ export default defineComponent({
920
920
  lastPublishedDir = dir;
921
921
  root.setAttribute("data-dir", dir);
922
922
  }
923
+ } else if (props.dockFade && (slots.dockBottom || slots.dockTop)) {
924
+ // The dir mirror belongs to the `fade` band-slot swap, which is
925
+ // off in this branch: drop a value a previous fade-on pass may
926
+ // have published, so "fade off removes it" holds for dock
927
+ // containers too (F4 in the 2026-11-12 review).
928
+ if (lastPublishedDir !== null) {
929
+ lastPublishedDir = null;
930
+ root.removeAttribute("data-dir");
931
+ }
932
+ // Dock-fed bands share the strength vars but never the `fade`
933
+ // ramp: gate them binary so the band retires at the scroll end
934
+ // instead of covering the flush-parked last row (see
935
+ // publishFadeStrengths' dock note). Depths reuse the same
936
+ // physical-side mapping the fade branch computes.
937
+ publishFadeStrengths(
938
+ root,
939
+ {
940
+ left: hasH() ? (rtl ? hMax - hPos : hPos) : 0,
941
+ right: hasH() ? (rtl ? hPos : hMax - hPos) : 0,
942
+ top: hasV() ? vPos : 0,
943
+ bottom: hasV() ? vMax - vPos : 0,
944
+ },
945
+ true,
946
+ );
923
947
  } else {
924
948
  clearPublishedFade(root);
925
949
  }
@@ -946,13 +970,32 @@ export default defineComponent({
946
970
  * the band's 0..1 depth, so the fade grows with the pull and caps
947
971
  * at the full band. An edge hiding nothing (the same ≤1px deadband
948
972
  * computeOverflow uses) publishes 1 — with its 0px band that is
949
- * invisible, and it keeps dock-fed edges (which share the vars,
950
- * no fade prop → never published) at their designed full band. */
951
- function publishFadeStrengths(root: HTMLElement, hidden: { left: number; right: number; top: number; bottom: number }) {
973
+ * invisible.
974
+ *
975
+ * `dock` mode (2026-11-12 user report): a dock-fed band shares these
976
+ * vars but is NOT the `fade` ramp — it is designed to sit at its
977
+ * full depth while content slides beneath the dock. Publishing the
978
+ * progressive value there made the band permanent, so a scroller
979
+ * parked at its end kept painting over its own last row ("拉到最底部
980
+ * 仍然有渐变阴影覆盖最后一行"). Dock mode therefore publishes a
981
+ * BINARY gate: lit (1) while that edge still hides content, retired
982
+ * (0) once the scroller has nothing left past it. The band then
983
+ * exists exactly while there is something to reveal, and vanishes at
984
+ * the end — for the stream it is the same full-depth band, so the
985
+ * mid-scroll dissolve the 2026-11-11 direction asked for is intact.
986
+ */
987
+ function publishFadeStrengths(
988
+ root: HTMLElement,
989
+ hidden: { left: number; right: number; top: number; bottom: number },
990
+ dock = false,
991
+ ) {
952
992
  const dist = Math.max(0, props.fadeDistance);
953
993
  for (const [side, depth] of Object.entries(hidden) as Array<[keyof typeof hidden, number]>) {
954
- const strength =
955
- depth <= 1 || dist === 0
994
+ const strength = dock
995
+ ? depth <= 1
996
+ ? "0"
997
+ : "1"
998
+ : depth <= 1 || dist === 0
956
999
  ? "1"
957
1000
  : String(Math.min(1, Math.round((depth / dist) * 1000) / 1000));
958
1001
  if (lastFadeStrengths.get(side) !== strength) {
@@ -1,7 +1,7 @@
1
1
  import { afterEach, describe, expect, it, vi } from "vitest";
2
2
  import { createApp, defineComponent, h, nextTick, type App } from "vue";
3
3
 
4
- import { WINDOW_IPC } from "../runtime/windowChrome";
4
+ import { RESIZE_POLL_MS, WINDOW_IPC } from "../runtime/windowChrome";
5
5
 
6
6
  import HkWindowControls, { isApplePlatform } from "./HkWindowControls";
7
7
 
@@ -324,3 +324,168 @@ describe("HkWindowControls window-chrome claim", () => {
324
324
  }
325
325
  });
326
326
  });
327
+
328
+ /**
329
+ * THE 2026-11-12 USER REPORT: "最大化之后这个最大化图标居然没有任何变化" —
330
+ * a maximized window whose caption button kept drawing the square and kept
331
+ * announcing "Maximize".
332
+ *
333
+ * The fake shell below is a CLASS INSTANCE, exactly like Tauri 2's `Window`:
334
+ * its methods live on the prototype and read `this.label`. Detaching one
335
+ * (`const fn = win.isMaximized`) throws — that is the defect the resolver had.
336
+ */
337
+ describe("HkWindowControls maximized glyph (the reported defect)", () => {
338
+ class TauriWindowShell {
339
+ label: string;
340
+ maximized: boolean;
341
+ resizeHandler: (() => void) | null = null;
342
+ resizedSubscribed = 0;
343
+
344
+ constructor(maximized = false) {
345
+ this.label = "main";
346
+ this.maximized = maximized;
347
+ }
348
+
349
+ // Every method reads `this.label` first, exactly like Tauri 2.12 — so a
350
+ // detached call raises the engine's own
351
+ // "Cannot read properties of undefined (reading 'label')".
352
+ minimize(): Promise<void> {
353
+ void this.label;
354
+ return Promise.resolve();
355
+ }
356
+
357
+ toggleMaximize(): Promise<void> {
358
+ void this.label;
359
+ this.maximized = !this.maximized;
360
+ return Promise.resolve();
361
+ }
362
+
363
+ close(): Promise<void> {
364
+ void this.label;
365
+ return Promise.resolve();
366
+ }
367
+
368
+ isMaximized(): Promise<boolean> {
369
+ void this.label;
370
+ return Promise.resolve(this.maximized);
371
+ }
372
+
373
+ onResized(handler: () => void): Promise<() => void> {
374
+ void this.label;
375
+ this.resizedSubscribed += 1;
376
+ this.resizeHandler = handler;
377
+ return Promise.resolve(() => {
378
+ this.resizeHandler = null;
379
+ });
380
+ }
381
+ }
382
+
383
+ function stubShell(maximized = false): TauriWindowShell {
384
+ const shell = new TauriWindowShell(maximized);
385
+ vi.stubGlobal("__TAURI__", { window: { getCurrentWindow: () => shell } });
386
+ return shell;
387
+ }
388
+
389
+ function maximizeButton(container: HTMLElement): HTMLButtonElement {
390
+ const button = container.querySelector<HTMLButtonElement>('[aria-label="Maximize"]');
391
+ if (!button) throw new Error("no maximize button rendered");
392
+ return button;
393
+ }
394
+
395
+ async function settle(): Promise<void> {
396
+ for (let i = 0; i < 8; i += 1) await Promise.resolve();
397
+ await nextTick();
398
+ }
399
+
400
+ it("draws Restore as soon as the shell reports a maximized window", async () => {
401
+ stubShell(true);
402
+ const t = mountControls({ variant: "standard" });
403
+ await settle();
404
+
405
+ expect(t.container.querySelector('[aria-label="Restore"]')).not.toBeNull();
406
+ expect(t.container.querySelector('[aria-label="Maximize"]')).toBeNull();
407
+ t.app.unmount();
408
+ });
409
+
410
+ it("flips the glyph after the user clicks maximize (the reported case)", async () => {
411
+ const shell = stubShell(false);
412
+ const t = mountControls({ variant: "standard" });
413
+ await settle();
414
+
415
+ // Before the click: the square, labelled Maximize.
416
+ expect(t.container.querySelector('[aria-label="Maximize"]')).not.toBeNull();
417
+
418
+ maximizeButton(t.container).click();
419
+ await settle();
420
+
421
+ // The fake shell really toggled, and the DOM followed it.
422
+ expect(shell.maximized).toBe(true);
423
+ const restore = t.container.querySelector('[aria-label="Restore"]');
424
+ expect(restore).not.toBeNull();
425
+ expect(t.container.querySelector('[aria-label="Maximize"]')).toBeNull();
426
+ t.app.unmount();
427
+ });
428
+
429
+ it("follows a resize event that arrives without a click", async () => {
430
+ const shell = stubShell(false);
431
+ const t = mountControls({ variant: "standard" });
432
+ await settle();
433
+ expect(t.container.querySelector('[aria-label="Maximize"]')).not.toBeNull();
434
+
435
+ // The OS maximized the window (double-click the title bar, a snap, a
436
+ // window-manager shortcut): only the resize event announces it.
437
+ shell.maximized = true;
438
+ expect(shell.resizeHandler).not.toBeNull();
439
+ shell.resizeHandler!();
440
+ await settle();
441
+
442
+ expect(t.container.querySelector('[aria-label="Restore"]')).not.toBeNull();
443
+ t.app.unmount();
444
+ });
445
+
446
+ it("keeps the glyph when the shell has no resize event to offer (bounded poll)", async () => {
447
+ vi.useFakeTimers();
448
+ try {
449
+ const shell = stubShell(false);
450
+ // A shell whose subscription silently yields nothing callable: the only
451
+ // way the glyph can follow is the bounded fallback poll.
452
+ (shell as unknown as { onResized: unknown }).onResized = () =>
453
+ Promise.resolve(undefined);
454
+
455
+ const t = mountControls({ variant: "standard" });
456
+ await settle();
457
+ expect(t.container.querySelector('[aria-label="Maximize"]')).not.toBeNull();
458
+
459
+ shell.maximized = true;
460
+ vi.advanceTimersByTime(RESIZE_POLL_MS);
461
+ await settle();
462
+
463
+ expect(t.container.querySelector('[aria-label="Restore"]')).not.toBeNull();
464
+ t.app.unmount();
465
+ } finally {
466
+ vi.useRealTimers();
467
+ }
468
+ });
469
+
470
+ it("stops watching on unmount (no writes, no timers left behind)", async () => {
471
+ vi.useFakeTimers();
472
+ try {
473
+ const shell = stubShell(false);
474
+ (shell as unknown as { onResized: unknown }).onResized = () =>
475
+ Promise.resolve(undefined);
476
+ const t = mountControls({ variant: "standard" });
477
+ await settle();
478
+ const subscribed = shell.resizedSubscribed;
479
+
480
+ t.app.unmount();
481
+ // The fallback poll must die with the component...
482
+ shell.maximized = true;
483
+ vi.advanceTimersByTime(RESIZE_POLL_MS * 10);
484
+ await settle();
485
+ // ...and no re-subscription churn happened behind our back.
486
+ expect(shell.resizedSubscribed).toBe(subscribed);
487
+ } finally {
488
+ vi.useRealTimers();
489
+ }
490
+ });
491
+ });
@@ -2,7 +2,11 @@ import { defineComponent, onMounted, onUnmounted, ref, type PropType } from "vue
2
2
 
3
3
  import { Minus, Square, X, Copy } from "lucide-vue-next";
4
4
 
5
- import { claimWindowChrome, resolveWindowApi } from "../runtime/windowChrome";
5
+ import {
6
+ claimWindowChrome,
7
+ resolveWindowApi,
8
+ watchMaximizedState,
9
+ } from "../runtime/windowChrome";
6
10
 
7
11
  import "./HkWindowControls.scss";
8
12
 
@@ -28,6 +32,16 @@ import "./HkWindowControls.scss";
28
32
  * `.s-glass-header--chrome` is the in-library implementation of the
29
33
  * contract for admin headers, and the chat face sources its
30
34
  * `--chrome` padding from the same tokens.
35
+ * LAYER CONTRACT: the host's caption band must claim the titlebar
36
+ * layer with the `.hk-chrome-band` class (styles/admin-tokens.scss),
37
+ * or the first open HkModal veil dims and deadens the whole drag row
38
+ * — field reports 2026-11-12: the chest settings and display windows
39
+ * covered the bar. HkAdminHeader's chrome mode hangs the class
40
+ * automatically; a hand-rolled band adds it to its own element. The
41
+ * claim needs a clean ancestor chain (no stacking-context wrapper
42
+ * with z<90000 between band and body); a trapped host instead sets
43
+ * `--hk-chrome-band-inset` so the modal veil's top edge starts below
44
+ * the band — the geometry leg, stacking-proof by construction.
31
45
  *
32
46
  * - `flush` — edge-riding squares that fill the host's height (the
33
47
  * host must zero its own right padding so the close button rides
@@ -74,10 +88,14 @@ export const HkWindowControls = defineComponent({
74
88
  },
75
89
  setup(props) {
76
90
  const maximized = ref(false);
77
- let unlisten: (() => void) | null = null;
78
- // Set on unmount: the mount path awaits `onResized()`, and an unmount that
79
- // lands before that promise resolves would otherwise arm a poll interval
80
- // (and keep writing `maximized`) for a component that no longer exists.
91
+ // The ONE read path (runtime/windowChrome): reads the shell now, re-reads on
92
+ // every resize event, and falls back to a bounded poll only when the shell
93
+ // refuses to publish events at all. Never arm this by hand again — the
94
+ // 2026-11-12 report was a hand-rolled path that lost the shell receiver, so
95
+ // the glyph stayed a square on a maximized window.
96
+ let stopWatching: (() => void) | null = null;
97
+ // Set on unmount: the mount path is async, so an unmount that lands before
98
+ // the watcher exists must not leave one armed for a component that is gone.
81
99
  let disposed = false;
82
100
  // Only a mount that actually paints the cluster takes the window chrome
83
101
  // over from the boot bar (boot-chrome.js): the SAME gates the render
@@ -97,36 +115,25 @@ export const HkWindowControls = defineComponent({
97
115
  claimed = true;
98
116
  claimWindowChrome("HkWindowControls");
99
117
  }
100
- // Every shell read is failure-tolerant AND handled: an unhandled
101
- // rejection during boot is treated as fatal by the family's
102
- // `res/fatal-fallback.js` (it raises the full-screen "Application failed
103
- // to load" landing on `unhandledrejection`), and the internals path would
104
- // reproduce it every poll interval.
105
- const refresh = () => {
106
- void win.isMaximized().then(
107
- (value) => {
108
- if (!disposed) maximized.value = value;
109
- },
110
- () => {},
111
- );
112
- };
113
- try {
114
- refresh();
115
- const off = await win.onResized(refresh);
116
- if (disposed) {
117
- off();
118
- return;
119
- }
120
- unlisten = off;
121
- } catch {
122
- /* the window API is optional furniture */
118
+ // The watcher handles every rejection internally: an unhandled rejection
119
+ // during boot is treated as fatal by the family's `res/fatal-fallback.js`
120
+ // (it raises the full-screen "Application failed to load" landing on
121
+ // `unhandledrejection`), and the internals path would reproduce it every
122
+ // poll interval.
123
+ const stop = watchMaximizedState(win, (value) => {
124
+ if (!disposed) maximized.value = value;
125
+ });
126
+ if (disposed) {
127
+ stop();
128
+ return;
123
129
  }
130
+ stopWatching = stop;
124
131
  });
125
132
 
126
133
  onUnmounted(() => {
127
134
  disposed = true;
128
- unlisten?.();
129
- unlisten = null;
135
+ stopWatching?.();
136
+ stopWatching = null;
130
137
  });
131
138
 
132
139
  return () => {
@@ -140,13 +147,21 @@ export const HkWindowControls = defineComponent({
140
147
  if (!win) return null;
141
148
 
142
149
  // Toggle, then re-read the shell state: the glyph must follow the real
143
- // window, not a local guess (the internals path may have no resize event).
150
+ // window, not a local guess. The re-read stays even though the watcher
151
+ // also fires on resize — the shell may publish that event before it has
152
+ // actually flipped its own flag, and the user's click is the one moment a
153
+ // stale glyph is unacceptable. Every step is handled, and a torn-down
154
+ // component never writes.
144
155
  const toggleMaximize = () => {
145
156
  void win
146
157
  .toggleMaximize()
147
158
  .then(() => win.isMaximized())
148
- .then((value) => (maximized.value = value))
149
- .catch(() => {});
159
+ .then(
160
+ (value) => {
161
+ if (!disposed) maximized.value = value;
162
+ },
163
+ () => {},
164
+ );
150
165
  };
151
166
 
152
167
  // A refused shell call must never surface as an unhandled rejection (the