@celestia-island/hikari 0.55.354 → 0.55.356

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.354",
3
+ "version": "0.55.356",
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",
@@ -138,6 +138,10 @@ describe("HkFab speed dial", () => {
138
138
  let minis = d.root.querySelectorAll<HTMLButtonElement>(".hk-fab-mini");
139
139
  expect(minis.length).toBe(2);
140
140
  expect(minis[0].getAttribute("aria-hidden")).toBe("true");
141
+ // The mini action's label is its own visible caption; a native title
142
+ // would only repeat it on hover (duplicated-tooltip sweep).
143
+ expect(minis[0].hasAttribute("title")).toBe(false);
144
+ expect(minis[0].querySelector(".hk-fab-mini-label")?.textContent).toBe("Alpha");
141
145
 
142
146
  d.button.click();
143
147
  await nextTick();
@@ -178,7 +178,9 @@ export default defineComponent({
178
178
  tabindex={isOpen.value ? 0 : -1}
179
179
  aria-hidden={isOpen.value ? "false" : "true"}
180
180
  disabled={props.disabled}
181
- title={action.label}
181
+ // No native `title`: the mini action renders its label as
182
+ // visible text and aria-label already names the button, so
183
+ // a title would only repeat the text on screen.
182
184
  aria-label={action.label ?? action.key}
183
185
  onClick={() => onActionClick(action)}
184
186
  >
@@ -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) {
@@ -50,6 +50,9 @@ describe("HkTagDotRow", () => {
50
50
  const redDot = red.querySelector(".hk-tag-dot__dot") as HTMLElement;
51
51
  expect(redDot.style.getPropertyValue("--hk-tag-color")).toBe("#e5484d");
52
52
  expect(red.querySelector(".hk-tag-dot__label")?.textContent).toBe("Red");
53
+ // No native tooltip repeating the caption: the label is already
54
+ // visible, and the accessible name rides aria-label.
55
+ expect(red.hasAttribute("title")).toBe(false);
53
56
  expect(red.getAttribute("aria-pressed")).toBe("false");
54
57
  expect(red.hasAttribute("data-active")).toBe(false);
55
58
 
@@ -52,7 +52,10 @@ export default defineComponent({
52
52
  disabled={tag.disabled}
53
53
  aria-pressed={tag.active ? "true" : "false"}
54
54
  aria-label={tag.label ?? tag.key}
55
- title={tag.label}
55
+ // No native `title`: the caption span already shows the label, so
56
+ // a title would only repeat the text the user is reading (the
57
+ // duplicated-tooltip defect). The accessible name rides
58
+ // aria-label, which also covers the labelless (dot-only) case.
56
59
  onClick={() => emit("toggle", tag.key)}
57
60
  >
58
61
  <span class="hk-tag-dot__dot" style={{ "--hk-tag-color": tag.color }} />
@@ -323,6 +323,9 @@ describe("HkToast live-region semantics", () => {
323
323
  const button = item.querySelector<HTMLButtonElement>(".hk-toast-action");
324
324
  expect(button).not.toBeNull();
325
325
  expect(button!.textContent).toBe("Undo");
326
+ // The label is the button's own text; a native title would just repeat
327
+ // it on hover (the duplicated-tooltip defect this wave removes).
328
+ expect(button!.hasAttribute("title")).toBe(false);
326
329
 
327
330
  button!.click();
328
331
  await settle();
@@ -160,7 +160,9 @@ const HkToastItem = defineComponent({
160
160
  {props.toast.action && (
161
161
  <button
162
162
  class="hk-toast-action"
163
- title={props.toast.action.label}
163
+ // No native `title`: the button's own text IS the action
164
+ // label, so a title would only repeat what is already on
165
+ // screen (the duplicated-tooltip defect).
164
166
  onClick={(e: MouseEvent) => {
165
167
  e.stopPropagation();
166
168
  handleAction();
@@ -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
 
@@ -84,10 +88,14 @@ export const HkWindowControls = defineComponent({
84
88
  },
85
89
  setup(props) {
86
90
  const maximized = ref(false);
87
- let unlisten: (() => void) | null = null;
88
- // Set on unmount: the mount path awaits `onResized()`, and an unmount that
89
- // lands before that promise resolves would otherwise arm a poll interval
90
- // (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.
91
99
  let disposed = false;
92
100
  // Only a mount that actually paints the cluster takes the window chrome
93
101
  // over from the boot bar (boot-chrome.js): the SAME gates the render
@@ -107,36 +115,25 @@ export const HkWindowControls = defineComponent({
107
115
  claimed = true;
108
116
  claimWindowChrome("HkWindowControls");
109
117
  }
110
- // Every shell read is failure-tolerant AND handled: an unhandled
111
- // rejection during boot is treated as fatal by the family's
112
- // `res/fatal-fallback.js` (it raises the full-screen "Application failed
113
- // to load" landing on `unhandledrejection`), and the internals path would
114
- // reproduce it every poll interval.
115
- const refresh = () => {
116
- void win.isMaximized().then(
117
- (value) => {
118
- if (!disposed) maximized.value = value;
119
- },
120
- () => {},
121
- );
122
- };
123
- try {
124
- refresh();
125
- const off = await win.onResized(refresh);
126
- if (disposed) {
127
- off();
128
- return;
129
- }
130
- unlisten = off;
131
- } catch {
132
- /* 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;
133
129
  }
130
+ stopWatching = stop;
134
131
  });
135
132
 
136
133
  onUnmounted(() => {
137
134
  disposed = true;
138
- unlisten?.();
139
- unlisten = null;
135
+ stopWatching?.();
136
+ stopWatching = null;
140
137
  });
141
138
 
142
139
  return () => {
@@ -150,13 +147,21 @@ export const HkWindowControls = defineComponent({
150
147
  if (!win) return null;
151
148
 
152
149
  // Toggle, then re-read the shell state: the glyph must follow the real
153
- // 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.
154
155
  const toggleMaximize = () => {
155
156
  void win
156
157
  .toggleMaximize()
157
158
  .then(() => win.isMaximized())
158
- .then((value) => (maximized.value = value))
159
- .catch(() => {});
159
+ .then(
160
+ (value) => {
161
+ if (!disposed) maximized.value = value;
162
+ },
163
+ () => {},
164
+ );
160
165
  };
161
166
 
162
167
  // A refused shell call must never surface as an unhandled rejection (the