@celestia-island/hikari 0.55.359 → 0.55.360

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.359",
3
+ "version": "0.55.360",
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",
@@ -60,6 +60,7 @@ vi.mock("./HkMenu", async () => {
60
60
  return { default: HMenuStub };
61
61
  });
62
62
 
63
+ import { CHROME_BAND_DRAG_REGION } from "../runtime/windowChrome";
63
64
  import { HkAdminHeader } from "./HkAdminHeader";
64
65
 
65
66
  /**
@@ -333,3 +334,25 @@ describe("HkAdminHeader", () => {
333
334
  expect(actions?.className).toContain("s-header-wing-end");
334
335
  });
335
336
  });
337
+
338
+ describe("HkAdminHeader chrome face drag region (2026-11-12)", () => {
339
+ // WHY: with chrome on, this header IS the desktop window's caption band (Tauri
340
+ // decorations:false). A bare drag attribute only matches the exact event
341
+ // target, so the wings that tile the header shadowed it — dragging and the
342
+ // double-click maximize never fired. The chrome face must carry hikari's deep
343
+ // contract on the header root; the content face (chrome off) must not.
344
+ it("carries the shared deep drag region when it is the caption band", () => {
345
+ const c = mount(headerNode({ chrome: true }));
346
+ const header = c.querySelector("header")!;
347
+ expect(header.getAttribute("data-tauri-drag-region")).toBe(CHROME_BAND_DRAG_REGION);
348
+ // The LITERAL as well — the constant comparison alone follows a wrong value
349
+ // (mutation evidence: "true" kept this suite green before this pin).
350
+ expect(header.getAttribute("data-tauri-drag-region")).toBe("deep");
351
+ expect(header.classList.contains("hk-chrome-band")).toBe(true);
352
+ });
353
+
354
+ it("leaves the content-face header out of the drag contract", () => {
355
+ const c = mount(headerNode({}));
356
+ expect(c.querySelector("header")!.hasAttribute("data-tauri-drag-region")).toBe(false);
357
+ });
358
+ });
@@ -2,6 +2,7 @@ import { computed, defineComponent, ref, watch, type PropType, type VNode } from
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
+ import { CHROME_BAND_DRAG_REGION } from "../runtime/windowChrome";
5
6
  import HkMenu, { type HkMenuItem } from "./HkMenu";
6
7
  import { HkAvatarButton } from "./HkAvatarButton";
7
8
 
@@ -27,7 +28,13 @@ export const HkAdminHeader = defineComponent({
27
28
  * window-controls chrome contract (.s-glass-header--chrome /
28
29
  * --hk-window-controls-edge-inset) instead of the content inset —
29
30
  * a standard-mode cluster glued to the frame corner is the flush
30
- * variant's look worn by the wrong mode (field report 2026-10-25). */
31
+ * variant's look worn by the wrong mode (field report 2026-10-25).
32
+ * The face also claims the titlebar layer (.hk-chrome-band) and
33
+ * carries hikari's deep drag region (CHROME_BAND_DRAG_REGION): the
34
+ * whole header surface drags and double-click-maximizes under
35
+ * Tauri's injected handler — the header IS the caption band, and its
36
+ * wings/wrappers would otherwise shadow a bare attribute off the
37
+ * event target (2026-11-12 user report). */
31
38
  chrome: { type: Boolean, default: false },
32
39
  actions: { type: Array as PropType<VNode[]>, default: () => [] },
33
40
  /** Signed-in identity. Drives the avatar fallback letter, the
@@ -220,6 +227,7 @@ export const HkAdminHeader = defineComponent({
220
227
  props.chrome ? "s-glass-header--chrome" : "",
221
228
  props.chrome ? "hk-chrome-band" : "",
222
229
  ]}
230
+ data-tauri-drag-region={props.chrome ? CHROME_BAND_DRAG_REGION : undefined}
223
231
  >
224
232
  <div ref={userTriggerRef} class="s-admin-header-user s-header-wing-start">
225
233
  {/* The hamburger rides INSIDE the left wing: the balanced grid
@@ -18,8 +18,8 @@ import { readFileSync } from "node:fs";
18
18
  import { dirname, join } from "node:path";
19
19
  import { fileURLToPath } from "node:url";
20
20
 
21
- import { afterEach, describe, expect, it } from "vitest";
22
- import { createApp, h, defineComponent, ref, type VNodeChild } from "vue";
21
+ import { afterEach, describe, expect, it, vi } from "vitest";
22
+ import { createApp, h, defineComponent, reactive, ref, type VNodeChild } from "vue";
23
23
 
24
24
  import HkKanban from "./HkKanban";
25
25
  import HkScrollContainer from "./HkScrollContainer";
@@ -70,6 +70,104 @@ describe("HkScrollContainer dock slots", () => {
70
70
  expect(host.style.getPropertyValue("--hk-scroll-dock-top")).toBe("0px");
71
71
  });
72
72
 
73
+ it("drops a fade-era data-dir mirror once the gate owns the edges", async () => {
74
+ // The dir mirror belongs to the `fade` band-slot swap (the sheet's RTL
75
+ // rules read it under [data-fade]). When a dock container ALSO had
76
+ // `fade` on for a while and then turns it off, the dock branch takes
77
+ // over - and it must not leave the mirror behind (the cleanup promise
78
+ // is "fade off removes it", which the no-dock tests pin but a dock
79
+ // container exercises through a different branch).
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 props = reactive({ fade: true, dockFade: true });
85
+ const app = createApp(defineComponent({
86
+ setup() {
87
+ return () =>
88
+ h(
89
+ HkScrollContainer,
90
+ { ref: instance as never, ...props },
91
+ {
92
+ default: () => h("div", { class: "content" }, "rows"),
93
+ dockBottom: () => h("div", { class: "the-dock" }, "dock"),
94
+ },
95
+ );
96
+ },
97
+ }));
98
+ mounts.push(app);
99
+ const host = (app.mount(container) as unknown as { $el: HTMLElement }).$el;
100
+ const viewport = host.querySelector(".hk-scroll-container-viewport") as HTMLElement;
101
+ Object.defineProperty(viewport, "scrollHeight", { value: 400, configurable: true });
102
+ Object.defineProperty(viewport, "clientHeight", { value: 100, configurable: true });
103
+ Object.defineProperty(viewport, "scrollTop", { value: 120, configurable: true });
104
+ instance.value?.refresh();
105
+ await Promise.resolve();
106
+ // The fade pass has run, so a mirrored dir exists...
107
+ expect(host.getAttribute("data-dir")).not.toBeNull();
108
+
109
+ // ...and turning `fade` off must drop it (the dock branch cleans up)
110
+ // and re-derive the strengths through the binary gate.
111
+ props.fade = false;
112
+ // Let the wrapper re-render first (the spread only re-reads on the
113
+ // wrapper's own render pass); refresh AFTER the child has the new
114
+ // props, or the fade branch runs one last time and re-stamps the dir.
115
+ await Promise.resolve();
116
+ instance.value?.refresh();
117
+ await Promise.resolve();
118
+ expect(host.getAttribute("data-dir")).toBeNull();
119
+ // 280 still hidden below the fold: the dock gate is lit.
120
+ expect(host.style.getPropertyValue("--hk-scroll-fade-strength-bottom")).toBe("1");
121
+ });
122
+
123
+ it("re-senses when dockFade flips at rest, without a manual refresh", async () => {
124
+ // The re-sense watcher keys on [fade, fadeDistance, dockFade]. This is
125
+ // its only coverage: flipping dockFade at rest with NO manual refresh —
126
+ // the watcher's scheduled frame must re-run the dock branch and clear
127
+ // the stale strength (a manual refresh here would exercise the sense
128
+ // pass and hide a missing key, which the review's mutation proved).
129
+ vi.useFakeTimers();
130
+ try {
131
+ const instance = ref<{ refresh: () => void } | null>(null);
132
+ const container = document.createElement("div");
133
+ document.body.appendChild(container);
134
+ containers.push(container);
135
+ const props = reactive({ dockFade: true });
136
+ const app = createApp(defineComponent({
137
+ setup() {
138
+ return () =>
139
+ h(
140
+ HkScrollContainer,
141
+ { ref: instance as never, ...props },
142
+ {
143
+ default: () => h("div", { class: "content" }, "rows"),
144
+ dockBottom: () => h("div", { class: "the-dock" }, "dock"),
145
+ },
146
+ );
147
+ },
148
+ }));
149
+ mounts.push(app);
150
+ const host = (app.mount(container) as unknown as { $el: HTMLElement }).$el;
151
+ const viewport = host.querySelector(".hk-scroll-container-viewport") as HTMLElement;
152
+ Object.defineProperty(viewport, "scrollHeight", { value: 400, configurable: true });
153
+ Object.defineProperty(viewport, "clientHeight", { value: 100, configurable: true });
154
+ Object.defineProperty(viewport, "scrollTop", { value: 0, configurable: true });
155
+ instance.value?.refresh();
156
+ await vi.advanceTimersByTimeAsync(60);
157
+ // 300 hidden below the fold: the gate is lit at full depth.
158
+ expect(host.style.getPropertyValue("--hk-scroll-fade-strength-bottom")).toBe("1");
159
+
160
+ props.dockFade = false;
161
+ // NO refresh: the watcher's own scheduled update must do the pass.
162
+ await vi.advanceTimersByTimeAsync(60);
163
+ // The dock branch no longer runs, the stale value was cleared and
164
+ // nothing republished it.
165
+ expect(host.style.getPropertyValue("--hk-scroll-fade-strength-bottom")).toBe("");
166
+ } finally {
167
+ vi.useRealTimers();
168
+ }
169
+ });
170
+
73
171
  it("retires the dock band at the scroll end instead of covering the last row", async () => {
74
172
  // 2026-11-12 user report: the cruise board's band kept painting over
75
173
  // its own flush-parked last row at full scroll. Dock bands share the
@@ -86,8 +86,10 @@
86
86
  into a 0..1 number mirrored as --hk-scroll-fade-strength-<side>.
87
87
  Pull the strip and the trailing edge's fade grows from a hard cut
88
88
  through a hint to the full band; scroll back and it recedes. Edges
89
- with nothing hidden read strength 1 (the pre-JS / dock-fade
90
- fallback), which with a 0px band contributes nothing. Physical-side
89
+ with nothing hidden read strength 1 (the pre-JS fallback), which
90
+ with a 0px band contributes nothing. Dock-fed edges are gated
91
+ separately by the dock branch (binary, see the dock-edge-fade
92
+ block). Physical-side
91
93
  names AND a mirrored data-dir: the component resolves the computed
92
94
  direction once and publishes both the depths and the direction
93
95
  attribute from the same pass, so the LTR and RTL state rules
@@ -381,16 +383,19 @@
381
383
  documented shape, not a bug.
382
384
 
383
385
  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 —
386
+ (2026-11-12 user report). Before the dock gate the component published
387
+ no strengths for a dock-only container (the `fade` prop owns that
388
+ ramp), so the band sat at full depth forever and a scroller parked at
389
+ its END kept painting over its own last row —
388
390
  「拉到最底部仍然有渐变阴影覆盖最后一行」. The dock path now publishes a
389
391
  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). */
392
+ this `calc()` is what turns it into px: with `fade` off, the dock
393
+ branch publishes 0 at the end, so the flush-parked row reads in full
394
+ (with `fade` on, the ramp branch owns the edge and the 2026-11-06
395
+ ownership note above still describes that combination). The `1`
396
+ fallback keeps the pre-fix full band wherever nothing is published
397
+ (SSR, no JS pass yet). A ride dock does run the gate but stamps no
398
+ marker, so its published values have no reader. */
394
399
  .hk-scroll-container[data-dock-fade="bottom"] {
395
400
  --hk-scroll-fade-bottom: calc(
396
401
  var(--hk-scroll-dock-fade, 2rem) * var(--hk-scroll-fade-strength-bottom, 1)
@@ -235,7 +235,14 @@ export default defineComponent({
235
235
  * ride-mode dock: that dock lives INSIDE the masked viewport, so the
236
236
  * same band would fade the dock's own bottom edge; and it needs no
237
237
  * dissolve at all, because the air between content and dock is the
238
- * dock's measured height (see `dockMode`). */
238
+ * dock's measured height (see `dockMode`). The band RETIRES at the
239
+ * scroll end (2026-11-12 user report): it is the dock size
240
+ * multiplied by a binary strength this component publishes for
241
+ * dock-fed edges — lit while content still hides past the edge,
242
+ * retired at the sense's own 1px deadband — so a flush-parked last
243
+ * row reads in full instead of sitting under a permanent gradient.
244
+ * With `fade` ALSO on, the ramp branch owns the edges and the
245
+ * sheet's ownership note describes that combination. */
239
246
  dockFade: { type: Boolean, default: true },
240
247
  /** Opt-in tail clearance for FLOATING docks (2026-10-12): a dock that
241
248
  * lives OUTSIDE this container (a shell-level fixed plane — a page's
@@ -1086,7 +1093,7 @@ export default defineComponent({
1086
1093
  // Runtime fade changes re-sense immediately: flipping `fade` on with
1087
1094
  // content already hidden must not wait for a scroll, and a different
1088
1095
  // fadeDistance re-derives every strength without any DOM motion.
1089
- watch(() => [props.fade, props.fadeDistance] as const, () => {
1096
+ watch(() => [props.fade, props.fadeDistance, props.dockFade] as const, () => {
1090
1097
  scheduleUpdate();
1091
1098
  });
1092
1099
 
@@ -7,6 +7,7 @@ import { afterEach, describe, expect, it } from "vitest";
7
7
  import { createApp, h, nextTick, ref } from "vue";
8
8
 
9
9
  import { setLocale } from "../i18n/context";
10
+ import { CHROME_BAND_DRAG_REGION } from "../runtime/windowChrome";
10
11
 
11
12
  import HkTitleBar from "./HkTitleBar";
12
13
 
@@ -251,3 +252,34 @@ describe("HkTitleBar stylesheet contract", () => {
251
252
  expect(scss).not.toMatch(/^\s*--hk-tb-icon-size:/m);
252
253
  });
253
254
  });
255
+
256
+ describe("HkTitleBar caption band drag region (2026-11-12)", () => {
257
+ // WHY: the bar IS the desktop window's caption band, and Tauri's injected
258
+ // drag handler only matches a BARE data-tauri-drag-region on the exact event
259
+ // target — so a band of wrappers/spans left drag (and double-click maximize)
260
+ // dead everywhere except the few pixels the root paints. The whole bar must
261
+ // carry hikari's deep contract instead.
262
+ it("carries the shared deep drag region on the root", () => {
263
+ const c = mount(h(HkTitleBar, { title: "App" }));
264
+ const bar = c.querySelector(".hk-titlebar")!;
265
+ expect(bar.getAttribute("data-tauri-drag-region")).toBe(CHROME_BAND_DRAG_REGION);
266
+ // The LITERAL, not just the imported constant: asserting the constant alone
267
+ // follows a wrong value instead of catching it (a mutation to "true" left
268
+ // this suite green before this pin existed — Tauri needs "deep" for the
269
+ // whole-band surface).
270
+ expect(bar.getAttribute("data-tauri-drag-region")).toBe("deep");
271
+ // The CSS grammar attribute stays: WKWebView drags through app-region.
272
+ expect(bar.hasAttribute("data-drag-region")).toBe(true);
273
+ });
274
+
275
+ it("keeps the caption buttons OUT of the drag region themselves", () => {
276
+ // They are clickables, which Tauri's handler already skips — but the
277
+ // actions row must not carry the attribute either (a future refactor that
278
+ // moved it there would start dragging instead of clicking).
279
+ const c = mount(h(HkTitleBar, { title: "App" }));
280
+ for (const button of c.querySelectorAll(".hk-titlebar-btn")) {
281
+ expect(button.hasAttribute("data-tauri-drag-region")).toBe(false);
282
+ }
283
+ expect(c.querySelector(".hk-titlebar-actions")!.hasAttribute("data-tauri-drag-region")).toBe(false);
284
+ });
285
+ });
@@ -1,6 +1,9 @@
1
1
  import { defineComponent, onBeforeUnmount, onMounted, ref } from "vue";
2
2
  import { useI18n } from "../i18n/context";
3
- import { claimWindowChrome } from "../runtime/windowChrome";
3
+ import {
4
+ CHROME_BAND_DRAG_REGION,
5
+ claimWindowChrome,
6
+ } from "../runtime/windowChrome";
4
7
 
5
8
  import "./HkTitleBar.scss";
6
9
 
@@ -17,6 +20,14 @@ import "./HkTitleBar.scss";
17
20
  * interactive children) — supported by Tauri (WebView2/WKWebView/WebKitGTK)
18
21
  * and Electron alike; no JS drag logic needed.
19
22
  *
23
+ * Tauri's injected drag handler keys off the `data-tauri-drag-region`
24
+ * ATTRIBUTE (the CSS property above only covers WKWebView), and its bare
25
+ * value matches the exact event target only — so the bar carries hikari's
26
+ * `CHROME_BAND_DRAG_REGION` ("deep"): the WHOLE bar surface, not just the
27
+ * pixels the root paints, drags and double-click-maximizes, while the
28
+ * interactive children keep blocking for themselves (the handler skips
29
+ * clickables and honors explicit `"false"`; see runtime/windowChrome).
30
+ *
20
31
  * Text selection is disabled across the bar (captions are chrome, not
21
32
  * content).
22
33
  *
@@ -76,6 +87,7 @@ export default defineComponent({
76
87
  class="hk-titlebar"
77
88
  data-drag-region
78
89
  data-maximized={props.maximized || undefined}
90
+ data-tauri-drag-region={CHROME_BAND_DRAG_REGION}
79
91
  >
80
92
  {slots.left?.() ?? (
81
93
  <span class="hk-titlebar-title">
package/src/index.ts CHANGED
@@ -1070,6 +1070,14 @@ export {
1070
1070
  WINDOW_IPC,
1071
1071
  RESIZE_POLL_MS,
1072
1072
  RESIZE_FALLBACK_TICKS,
1073
+ // Caption-band contracts (2026-11-12): hosts bind their band's
1074
+ // data-tauri-drag-region to CHROME_BAND_DRAG_REGION ("deep" — the bare value
1075
+ // only matches the exact event target, so a band of wrappers never dragged or
1076
+ // double-click-maximized) and publish their band height under
1077
+ // CHROME_BAND_HEIGHT_VAR so hikari's pre-boot bar wears the same height as the
1078
+ // app's caption band instead of a thin default it then replaces.
1079
+ CHROME_BAND_DRAG_REGION,
1080
+ CHROME_BAND_HEIGHT_VAR,
1073
1081
  type WindowApiLike,
1074
1082
  } from "./runtime/windowChrome";
1075
1083
  // THE hyperlink coordination context (runtime/hyperlink.ts): every link
@@ -20,7 +20,16 @@ export declare const BOOT_CHROME_URL: string;
20
20
  export interface BootChromePluginOptions {
21
21
  /** Application name on the left of the bar (default: `document.title`). */
22
22
  title?: string;
23
- /** Bar height in px; `boot-chrome.js` clamps it to 20..64 (default 32). */
23
+ /**
24
+ * Bar height in px; `boot-chrome.js` clamps it to 20..64 (default 32).
25
+ *
26
+ * PINNING this option is the exception, not the rule: a shell whose caption
27
+ * band has a real height should publish that height to `root` as
28
+ * `--hk-chrome-band-h` (hikari's `CHROME_BAND_HEIGHT_VAR`, exported from
29
+ * `runtime/windowChrome`) instead — the bar then wears the app's own band
30
+ * height from the first frame and the host never restates a number. An
31
+ * explicit `height` wins over that contract (it means "pin the bar").
32
+ */
24
33
  height?: number;
25
34
  /** Watchdog delay in ms before the reload affordance appears (default 20000). */
26
35
  hangMs?: number;
@@ -50,6 +50,14 @@ import { fileURLToPath } from "node:url";
50
50
  * in dev (Vite only serves `public/` files otherwise, and the script ships
51
51
  * inside the package instead).
52
52
  *
53
+ * HEIGHT CONTRACT (2026-11-12): the bar also follows a host-published custom
54
+ * property — `--hk-chrome-band-h` on :root (hikari's CHROME_BAND_HEIGHT_VAR,
55
+ * runtime/windowChrome.ts) — so a shell whose caption band has a real height
56
+ * draws the SAME band from the first frame instead of a thin default the band
57
+ * then replaces. Declare it from the host's pre-paint skeleton as a length or a
58
+ * var() chain (`var(--s-header-height, 3rem)`); the bar applies the resolved
59
+ * length. The `height` option still wins when a host wants the bar pinned.
60
+ *
53
61
  * KNOWN PRECONDITIONS (host-side, documented rather than enforced):
54
62
  * - `boot-chrome.js` injects its own `<style>` element, so the host CSP needs
55
63
  * `style-src 'unsafe-inline'` (the Tauri shells in the family allow it).
@@ -27,7 +27,17 @@
27
27
  * data-hk-title application name shown on the left (default: document.title)
28
28
  * data-hk-hang-ms watchdog delay in ms before the reload affordance appears
29
29
  * (default 20000; a non-positive/invalid value = default)
30
- * data-hk-height bar height in px (default 32, clamped to 20..64)
30
+ * data-hk-height bar height in px (default 32, clamped to 20..64). An
31
+ * explicit value PINNS the bar: it wins over the height
32
+ * contract below.
33
+ * height contract the host may publish its caption band height to :root as
34
+ * `--hk-chrome-band-h` (hikari's CHROME_BAND_HEIGHT_VAR,
35
+ * runtime/windowChrome.ts) — a length or a var() chain.
36
+ * The bar wears it verbatim, so the strip matches the
37
+ * app's caption band from the first frame and keeps
38
+ * tracking the app token once its stylesheet lands
39
+ * (2026-11-12: chest's wide 3rem band booted behind a
40
+ * thin 32px strip). Absent → the 32px default, as before.
31
41
  *
32
42
  * HOST API — `window.HkBootChrome`:
33
43
  * setStatus(text) replace the status text (e.g. "connecting…")
@@ -110,13 +120,24 @@
110
120
  var HEIGHT_DEFAULT = 32;
111
121
  var HEIGHT_MIN = 20;
112
122
  var HEIGHT_MAX = 64;
123
+ // hikari's caption-height contract (runtime/windowChrome.ts — a classic
124
+ // script cannot import it, so the name is mirrored here and the parity
125
+ // test in src/res/bootChrome.test.ts pins both spellings).
126
+ var CAPTION_HEIGHT_VAR = "--hk-chrome-band-h";
113
127
  var RETRY_EVERY_MS = 100;
114
128
  var RETRY_BUDGET_MS = 5000;
115
129
  var FADE_MS = 160; // < 200ms: the claim handoff must not delay the app.
116
130
 
117
131
  var currentScript = doc.currentScript;
118
132
  var cfg = (currentScript && currentScript.dataset) || {};
119
- var barHeight = intOption(cfg.hkHeight, HEIGHT_MIN, HEIGHT_MAX) || HEIGHT_DEFAULT;
133
+ // Height precedence: an explicit data-hk-height PIN beats the caption band
134
+ // contract (a host that asked for a fixed bar meant it); the contract beats
135
+ // the thin default. `barHeight` stays the numeric fallback the stylesheet
136
+ // rule carries; `bandHeight` (when set) is the resolved length applied as an
137
+ // inline height and published through `--hk-boot-chrome-h`.
138
+ var pinnedHeight = intOption(cfg.hkHeight, HEIGHT_MIN, HEIGHT_MAX);
139
+ var bandHeight = pinnedHeight === null ? captionBandHeight() : "";
140
+ var barHeight = pinnedHeight || HEIGHT_DEFAULT;
120
141
  var hangMs = intOption(cfg.hkHangMs, 1, 3600000) || HANG_MS_DEFAULT;
121
142
  var appTitle =
122
143
  typeof cfg.hkTitle === "string" && cfg.hkTitle
@@ -142,6 +163,67 @@
142
163
  }
143
164
  }
144
165
 
166
+ /** A plain CSS length (or a bare 0) — the only shape the bar can apply. */
167
+ function isPlainLength(value) {
168
+ return /^\s*(-?\d*\.?\d+(px|rem|em|ex|ch|vh|dvh|svh|lvh|vw|dvw|%)|0)\s*$/i.test(
169
+ value
170
+ );
171
+ }
172
+
173
+ /**
174
+ * Resolve a host's caption-height declaration to one plain length.
175
+ *
176
+ * The contract accepts a length OR a var() chain, but the bar needs a value it
177
+ * can actually apply: a declaration parser may reject var() inside a style
178
+ * property (happy-dom's does; some WebViews did too). Resolution therefore
179
+ * lands on a length, in this order:
180
+ *
181
+ * 1. a plain length is taken as-is;
182
+ * 2. a `var(--name, fallback)` chain resolves to its OWN fallback when the
183
+ * referenced property is not in the cascade yet — which is the normal
184
+ * boot case: the bar exists BEFORE any stylesheet has loaded, so the
185
+ * fallback IS the app's declared height at that instant;
186
+ * 3. anything else (junk, a chain without a fallback) yields "" and the
187
+ * numeric default stays.
188
+ *
189
+ * Tarbar tracking: the applied length is a snapshot, not a live chain. That is
190
+ * deliberate — the bar only lives until the app claims the chrome, and a boot
191
+ * strip that changes height mid-load is worse than one that matches the
192
+ * pre-CSS contract exactly.
193
+ */
194
+ function resolveBandHeight(raw) {
195
+ var value = (raw || "").trim();
196
+ if (!value) return "";
197
+ if (isPlainLength(value)) return value;
198
+ var chain = /^var\(\s*--[A-Za-z0-9_-]+\s*,\s*([^()]+?)\s*\)$/i.exec(value);
199
+ if (chain && isPlainLength(chain[1])) return chain[1].trim();
200
+ return "";
201
+ }
202
+
203
+ /**
204
+ * The host's caption band height, when the contract var is published.
205
+ *
206
+ * Computed first — a real webview substitutes custom properties, so a chain
207
+ * arrives already resolved — then the declared value (the pre-paint skeleton
208
+ * writes it as an inline :root style), which covers engines that do not
209
+ * substitute in getComputedStyle. Both go through resolveBandHeight.
210
+ */
211
+ function captionBandHeight() {
212
+ var computed = safe(function () {
213
+ var cs =
214
+ typeof window.getComputedStyle === "function"
215
+ ? window.getComputedStyle(root)
216
+ : null;
217
+ return cs ? cs.getPropertyValue(CAPTION_HEIGHT_VAR) || "" : "";
218
+ }, "");
219
+ var resolved = resolveBandHeight(computed);
220
+ if (resolved) return resolved;
221
+ var declared = safe(function () {
222
+ return root.style.getPropertyValue(CAPTION_HEIGHT_VAR) || "";
223
+ }, "");
224
+ return resolveBandHeight(declared);
225
+ }
226
+
145
227
  function noop() {}
146
228
 
147
229
  // --------------------------------------------------------------------- copy
@@ -407,8 +489,20 @@
407
489
  }, undefined);
408
490
 
409
491
  // Publish the bar height so the host can keep its own content below it.
492
+ // The contract value goes out VERBATIM (never re-measured) so the host's
493
+ // offset tracks the same token chain the bar itself wears.
494
+ safe(function () {
495
+ root.style.setProperty(
496
+ "--hk-boot-chrome-h",
497
+ bandHeight || barHeight + "px"
498
+ );
499
+ }, undefined);
500
+
501
+ // Wear the caption band height when the contract delivered one: an inline
502
+ // height beats the stylesheet rule's numeric default, so the strip and the
503
+ // app's caption band read as one band from the very first frame.
410
504
  safe(function () {
411
- root.style.setProperty("--hk-boot-chrome-h", barHeight + "px");
505
+ if (bandHeight) bar.style.height = bandHeight;
412
506
  }, undefined);
413
507
  root.setAttribute("data-hk-boot-chrome", "active");
414
508
 
@@ -4,7 +4,11 @@ import { fileURLToPath } from "node:url";
4
4
 
5
5
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
6
6
 
7
- import { WINDOW_IPC } from "../runtime/windowChrome";
7
+ import {
8
+ CHROME_BAND_DRAG_REGION,
9
+ CHROME_BAND_HEIGHT_VAR,
10
+ WINDOW_IPC,
11
+ } from "../runtime/windowChrome";
8
12
  import { asIndexable } from "../utils/typing";
9
13
 
10
14
  /**
@@ -124,6 +128,7 @@ beforeEach(() => {
124
128
  document.documentElement.removeAttribute("data-mode");
125
129
  document.documentElement.removeAttribute("data-hk-boot-chrome");
126
130
  document.documentElement.style.removeProperty("--hk-boot-chrome-h");
131
+ document.documentElement.style.removeProperty(CHROME_BAND_HEIGHT_VAR);
127
132
  clearGlobal("HkBootChrome");
128
133
  clearGlobal("__TAURI__");
129
134
  clearGlobal("__TAURI_INTERNALS__");
@@ -619,6 +624,108 @@ describe("boot-chrome.js teardown (S3-1)", () => {
619
624
  });
620
625
  });
621
626
 
627
+ describe("boot-chrome.js caption band height contract (2026-11-12)", () => {
628
+ // WHY: the app's caption band is a real band (chest's 3rem-class header), and
629
+ // the pre-boot bar used to draw a thin 32px strip the band then replaced —
630
+ // two different heights inside one window, user-visible on every start. The
631
+ // host publishes its band height to :root; the bar wears it verbatim so the
632
+ // strip matches from the first frame AND keeps tracking the app token.
633
+
634
+ function published(): string {
635
+ return document.documentElement.style.getPropertyValue("--hk-boot-chrome-h");
636
+ }
637
+
638
+ /** The height the bar actually wears (inline, beats the rule's default). */
639
+ function worn(): string {
640
+ return (bar() as HTMLElement).style.height;
641
+ }
642
+
643
+ function declareBandHeight(value: string): void {
644
+ document.documentElement.style.setProperty(CHROME_BAND_HEIGHT_VAR, value);
645
+ }
646
+
647
+ it("resolves a var() chain to its fallback — the boot strip's real height", () => {
648
+ setGlobal("__TAURI_INTERNALS__", { invoke: vi.fn(() => Promise.resolve(false)) });
649
+ // The pre-paint skeleton (chest's theme-loader.js) publishes a CHAIN, not a
650
+ // resolved number. The bar exists BEFORE any stylesheet loads, so the
651
+ // referenced token is not in the cascade yet and the chain's own fallback
652
+ // IS the app's declared band height at that instant.
653
+ declareBandHeight("var(--s-header-height, 3rem)");
654
+ runBootChrome();
655
+
656
+ expect(worn()).toBe("3rem");
657
+ expect(published()).toBe("3rem");
658
+ });
659
+
660
+ it("prefers a resolvable chain over the numeric default", () => {
661
+ setGlobal("__TAURI_INTERNALS__", { invoke: vi.fn(() => Promise.resolve(false)) });
662
+ declareBandHeight("var(--chest-caption-height, 40px)");
663
+ runBootChrome();
664
+
665
+ expect(worn()).toBe("40px");
666
+ expect(published()).toBe("40px");
667
+ });
668
+
669
+ it("falls back to the numeric default for a chain with no resolvable length", () => {
670
+ setGlobal("__TAURI_INTERNALS__", { invoke: vi.fn(() => Promise.resolve(false)) });
671
+ // No fallback: nothing the boot strip can wear before the cascade exists.
672
+ declareBandHeight("var(--s-header-height)");
673
+ runBootChrome();
674
+
675
+ expect(worn()).toBe("");
676
+ expect(published()).toBe("32px");
677
+ });
678
+
679
+ it("accepts a plain length and clamps nothing away (host owns its band)", () => {
680
+ setGlobal("__TAURI_INTERNALS__", { invoke: vi.fn(() => Promise.resolve(false)) });
681
+ declareBandHeight("56px");
682
+ runBootChrome();
683
+
684
+ expect(worn()).toBe("56px");
685
+ expect(published()).toBe("56px");
686
+ });
687
+
688
+ it("lets an explicit data-hk-height pin beat the band contract", () => {
689
+ setGlobal("__TAURI_INTERNALS__", { invoke: vi.fn(() => Promise.resolve(false)) });
690
+ declareBandHeight("56px");
691
+ runBootChrome({ height: 36 });
692
+
693
+ expect(published()).toBe("36px");
694
+ expect(styleSheet()).toContain("height:36px");
695
+ // A pinned bar must not be overwritten by the contract.
696
+ expect(worn()).toBe("");
697
+ });
698
+
699
+ it("ignores a junk contract value instead of shipping a broken height", () => {
700
+ setGlobal("__TAURI_INTERNALS__", { invoke: vi.fn(() => Promise.resolve(false)) });
701
+ declareBandHeight("banana");
702
+ runBootChrome();
703
+
704
+ // No local height, and the published offset stays the numeric default —
705
+ // a junk value must not reach either (host offset consumers read this).
706
+ expect(worn()).toBe("");
707
+ expect(published()).toBe("32px");
708
+ });
709
+
710
+ it("ignores an empty contract value", () => {
711
+ setGlobal("__TAURI_INTERNALS__", { invoke: vi.fn(() => Promise.resolve(false)) });
712
+ declareBandHeight(" ");
713
+ runBootChrome();
714
+
715
+ expect(published()).toBe("32px");
716
+ });
717
+
718
+ it("pins the contract name on both sides of the classic-script boundary", () => {
719
+ // boot-chrome.js cannot import the TS constant; this is the anti-drift gate.
720
+ expect(CHROME_BAND_HEIGHT_VAR).toBe("--hk-chrome-band-h");
721
+ expect(SOURCE).toContain(`"${CHROME_BAND_HEIGHT_VAR}"`);
722
+ });
723
+
724
+ it("pins the deep drag-region value the caption bands carry", () => {
725
+ expect(CHROME_BAND_DRAG_REGION).toBe("deep");
726
+ });
727
+ });
728
+
622
729
  describe("boot-chrome.js ↔ runtime/windowChrome parity", () => {
623
730
  // The boot bar (classic script) and the Vue components (TS) must wire the
624
731
  // SAME shell commands in the SAME order. The components import WINDOW_IPC;
@@ -147,6 +147,12 @@ export {
147
147
  WINDOW_IPC,
148
148
  RESIZE_POLL_MS,
149
149
  RESIZE_FALLBACK_TICKS,
150
+ // The caption-band contracts (2026-11-12): hosts bind their band's drag
151
+ // region to this value and publish their band height under this var, so the
152
+ // "deep" semantics and the boot-strip height agreement live upstream instead
153
+ // of being re-spelled by every host.
154
+ CHROME_BAND_DRAG_REGION,
155
+ CHROME_BAND_HEIGHT_VAR,
150
156
  type WindowApiLike,
151
157
  } from "./windowChrome";
152
158
  export {
@@ -54,6 +54,16 @@
54
54
  *
55
55
  * Hosts that paint their OWN title bar (instead of HkTitleBar /
56
56
  * HkWindowControls) call `claimWindowChrome(by)` directly.
57
+ *
58
+ * 4. `CHROME_BAND_DRAG_REGION` — the drag-region attribute value caption
59
+ * band roots carry, so the band's WHOLE surface (not just the pixels the
60
+ * band element itself paints) drags and double-click-maximizes under
61
+ * Tauri's injected drag handler. See the constant's doc for the exact
62
+ * self/deep/false semantics the handler implements.
63
+ *
64
+ * 5. `CHROME_BAND_HEIGHT_VAR` — the custom property a host publishes so the
65
+ * pre-boot bar wears the app's caption band height from the first frame
66
+ * instead of a thin default the band then replaces.
57
67
  */
58
68
 
59
69
  import { type HostWindow } from "../utils/typing";
@@ -64,6 +74,55 @@ export const CHROME_CLAIM_EVENT = "hk:chrome-claim";
64
74
  /** `<html>` attribute marking the app as the chrome owner. */
65
75
  export const CHROME_OWNER_ATTR = "data-hk-chrome";
66
76
 
77
+ /**
78
+ * The `data-tauri-drag-region` attribute value that promotes a WHOLE caption
79
+ * band — the band AND its non-interactive descendants — to a drag/maximize
80
+ * surface (2026-11-12 user report, the chest desktop window).
81
+ *
82
+ * Tauri's injected drag handler (`tauri` 2.12 `src/window/scripts/drag.js`)
83
+ * walks the event's composed path and decides per element:
84
+ *
85
+ * - bare attr / `"true"` — SELF-only: the drag region matches only when the
86
+ * event target IS that exact element;
87
+ * - `"deep"` — any descendant of the element triggers, and the walk stops at
88
+ * the first match UNLESS a clickable element (a/button/input/select/
89
+ * textarea/label/summary, an editing host, a tabindexed node or an
90
+ * interactive role) without the attribute sits in the path — those block;
91
+ * an element explicitly carrying `"false"` blocks too;
92
+ * - `"false"` — drag blocked here and for every ancestor.
93
+ *
94
+ * A caption band is never one element: wings, wrappers and text spans tile the
95
+ * whole strip, so a BARE attribute on the band matches only the pixels the band
96
+ * element itself paints — its own children shadow it, and dragging plus the
97
+ * double-click maximize (`internal_toggle_maximize`, already allowed by
98
+ * `core:window:default`) never fire even though the attribute is visibly
99
+ * there. Caption band roots therefore take the value from THIS constant —
100
+ * `HkTitleBar`, the chrome face of `HkAdminHeader`, and every host band —
101
+ * instead of a local literal, so the semantics stay reviewable in one place.
102
+ * Interactive children need no opt-out: the clickables block themselves, and
103
+ * `HkWindowControls` already carries the explicit `"false"`.
104
+ */
105
+ export const CHROME_BAND_DRAG_REGION = "deep";
106
+
107
+ /**
108
+ * The CSS custom property that publishes a host's caption band height to the
109
+ * pre-boot window bar (`src/res/boot-chrome.js`).
110
+ *
111
+ * The boot strip exists BEFORE the app bundle, so it cannot read the app's
112
+ * stylesheet tokens directly; the host declares its band height to :root from
113
+ * its pre-paint skeleton (an inline `:root` style or a static stylesheet) —
114
+ * a plain length (`"48px"`, `"3rem"`) or a var() chain
115
+ * (`"var(--s-header-height, 3rem)"`). The bar wears the value verbatim, so it
116
+ * matches the app's caption band from the first frame AND keeps tracking the
117
+ * token once the real stylesheet lands (2026-11-12 user report: chest's wide
118
+ * 3rem band booted behind a thin 32px strip). Without the var — or when the
119
+ * plugin's explicit `height` option is set — the bar keeps its thin default.
120
+ * The name is mirrored as a string literal inside `res/boot-chrome.js` (a
121
+ * classic script, no imports); the parity test in `src/res/bootChrome.test.ts`
122
+ * fails if either side drifts.
123
+ */
124
+ export const CHROME_BAND_HEIGHT_VAR = "--hk-chrome-band-h";
125
+
67
126
  /**
68
127
  * The Tauri 2.12 IPC command names, in ONE place.
69
128
  *