@vitrinka/web 0.5.2 → 0.6.0

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +73 -3
  2. package/README.md +70 -18
  3. package/build/hud.iife.js +150 -28
  4. package/build/protocol/index.d.ts +10 -0
  5. package/build/recorder/capture/click.js +2 -2
  6. package/build/recorder/capture/nav.js +1 -1
  7. package/build/recorder/capture/redact.d.ts +10 -2
  8. package/build/recorder/capture/redact.js +53 -3
  9. package/build/recorder/config.d.ts +10 -0
  10. package/build/recorder/config.js +1 -0
  11. package/build/recorder/flight.d.ts +5 -0
  12. package/build/recorder/flight.js +5 -2
  13. package/build/recorder/hud/Hud.js +206 -31
  14. package/build/recorder/hud/NotesSheet.d.ts +24 -0
  15. package/build/recorder/hud/NotesSheet.js +147 -0
  16. package/build/recorder/hud/RecorderPill.d.ts +34 -12
  17. package/build/recorder/hud/RecorderPill.js +52 -14
  18. package/build/recorder/hud/Sheet.d.ts +18 -15
  19. package/build/recorder/hud/Sheet.js +13 -13
  20. package/build/recorder/hud/controller.d.ts +81 -4
  21. package/build/recorder/hud/drop.d.ts +26 -0
  22. package/build/recorder/hud/drop.js +35 -0
  23. package/build/recorder/hud/icons.d.ts +6 -0
  24. package/build/recorder/hud/icons.js +12 -0
  25. package/build/recorder/hud/notes-rows.d.ts +39 -0
  26. package/build/recorder/hud/notes-rows.js +49 -0
  27. package/build/recorder/hud/resize.d.ts +6 -3
  28. package/build/recorder/hud/resize.js +8 -4
  29. package/build/recorder/hud/styles.d.ts +1 -19
  30. package/build/recorder/hud/styles.js +62 -19
  31. package/build/recorder/index.d.ts +8 -0
  32. package/build/recorder/index.js +1 -0
  33. package/build/recorder/page-controller.js +13 -7
  34. package/build/recorder/queue.d.ts +22 -1
  35. package/build/recorder/queue.js +84 -5
  36. package/build/recorder/recents.d.ts +20 -4
  37. package/build/recorder/recents.js +41 -6
  38. package/build/recorder/report.js +3 -11
  39. package/build/recorder/session.d.ts +25 -6
  40. package/build/recorder/session.js +53 -11
  41. package/build/recorder/version.d.ts +2 -2
  42. package/build/recorder/version.js +1 -1
  43. package/package.json +1 -1
@@ -0,0 +1,147 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * The notes sheet (recorder HUD polish D5/D12): this recording's notes and
4
+ * annotations in the board annotation island's anatomy, ported onto the
5
+ * HUD's tokens — a LIST face (№ · kind · age kicker, text, state dot; a
6
+ * filter; ← → ↑ ↓ walk, ↵ opens) and a SPLIT face (the № rail beside the
7
+ * open note: its versions, an edit box, ↳ reference). An edit is a new note
8
+ * that replaces the newest version (D6); a reference opens the note composer
9
+ * with the note as a ↳ chip (D7). Rows come from `noteRows` (notes-rows.ts).
10
+ */
11
+ import { useEffect, useRef, useState } from 'react';
12
+ import { AnnotateIcon, CheckIcon, CloseIcon, PencilIcon, ReplyIcon } from './icons';
13
+ import { filterRows, walkRows } from './notes-rows';
14
+ import { fmtAgo } from './status';
15
+ const FILTERS = [
16
+ { value: 'all', label: 'all' },
17
+ { value: 'regions', label: 'regions' },
18
+ { value: 'notes', label: 'notes' },
19
+ ];
20
+ function kicker(r, now) {
21
+ const edited = r.versions.length > 1 ? ' · edited' : '';
22
+ return `№${r.number} · ${r.region ? 'region' : 'note'} · ${fmtAgo(now - r.at)}${edited}`;
23
+ }
24
+ export function NotesSheet({ className, origin, rows, now, onEdit, onReference, onClose }) {
25
+ const [filter, setFilter] = useState('all');
26
+ const [focused, setFocused] = useState(null);
27
+ const [open, setOpen] = useState(null);
28
+ const [edit, setEdit] = useState('');
29
+ const list = useRef(null);
30
+ const visible = filterRows(rows, filter);
31
+ // The one tabbable row: the focused one while the filter shows it, else the first.
32
+ const tabCid = visible.some((r) => r.cid === focused) ? focused : (visible[0]?.cid ?? null);
33
+ const row = open ? rows.find((r) => r.cid === open) : undefined;
34
+ // Opening a note puts its newest text in the edit box — only when ANOTHER
35
+ // note opens: a sent edit of this one must not reset the box under the hand.
36
+ const openText = row?.text ?? '';
37
+ const opened = useRef(null);
38
+ useEffect(() => {
39
+ if (opened.current === open)
40
+ return;
41
+ opened.current = open;
42
+ setEdit(openText);
43
+ }, [open, openText]);
44
+ const walk = (e) => {
45
+ // Esc steps back from an open note, else closes the sheet — from any control in it.
46
+ if (e.key === 'Escape') {
47
+ e.preventDefault();
48
+ e.stopPropagation();
49
+ if (open)
50
+ setOpen(null);
51
+ else
52
+ onClose();
53
+ return;
54
+ }
55
+ const step = e.key === 'ArrowDown' || e.key === 'ArrowRight' ? 1 : e.key === 'ArrowUp' || e.key === 'ArrowLeft' ? -1 : 0;
56
+ if (!step)
57
+ return;
58
+ if (e.target instanceof HTMLTextAreaElement)
59
+ return;
60
+ e.preventDefault();
61
+ const next = walkRows(visible, open ?? focused, step);
62
+ if (open)
63
+ setOpen(next);
64
+ else {
65
+ setFocused(next);
66
+ if (next)
67
+ list.current?.querySelector(`[data-cid="${next}"]`)?.focus();
68
+ }
69
+ };
70
+ const save = () => {
71
+ if (!row)
72
+ return;
73
+ const text = edit.trim();
74
+ if (!text || text === row.text)
75
+ return;
76
+ onEdit(row, text);
77
+ };
78
+ if (row) {
79
+ return (_jsxs("div", { className: `pop notes split ${className}`, style: { transformOrigin: origin }, role: "dialog", "aria-label": `Note №${row.number}`, onKeyDown: walk, children: [_jsxs("div", { className: "pop-head", children: [_jsxs("span", { className: "n-head", children: [_jsx("button", { type: "button", className: "n-word", "aria-label": "Back to the list", onClick: () => setOpen(null), children: "\u2039" }), _jsx("span", { className: "n-kick", children: kicker(row, now) })] }), _jsxs("span", { className: "n-acts", children: [_jsxs("button", { type: "button", className: "n-word", onClick: () => onReference(row), children: [_jsx(ReplyIcon, {}), " reference"] }), _jsx("button", { type: "button", className: "closeb", "aria-label": "Close", onClick: onClose, children: _jsx(CloseIcon, {}) })] })] }), _jsxs("div", { className: "n-split", children: [_jsxs("nav", { className: "n-rail", "aria-label": "Notes", children: [_jsxs("button", { type: "button", className: "n-word", onClick: () => setOpen(null), children: ["all ", rows.length] }), visible.map((r) => (_jsxs("button", { type: "button", className: r.cid === row.cid ? 'n-th on' : 'n-th', "aria-current": r.cid === row.cid || undefined, "aria-label": `№${r.number}`, onClick: () => setOpen(r.cid), children: [r.region ? _jsx(AnnotateIcon, {}) : _jsx(PencilIcon, {}), _jsx("b", { children: r.number })] }, r.cid)))] }), _jsxs("div", { className: "n-body", children: [_jsxs("div", { className: "n-meta", children: [row.region && row.w !== undefined && row.h !== undefined ? `Region ${row.w}×${row.h} · ` : '', row.route || '/'] }), row.versions.map((v, i) => (_jsxs("div", { className: i === row.versions.length - 1 ? 'n-ver' : 'n-ver old', children: [_jsxs("span", { className: "n-kick", children: ["v", i + 1, " \u00B7 ", fmtAgo(now - v.at), i === row.versions.length - 1 ? ' · current' : ''] }), v.text || '(no text)'] }, v.cid))), _jsx("textarea", { className: "n-edit", "aria-label": `Edit note №${row.number}`, value: edit, onChange: (e) => setEdit(e.target.value), onKeyDown: (e) => {
80
+ if (e.key === 'Enter' && !e.shiftKey && !e.nativeEvent.isComposing) {
81
+ e.preventDefault();
82
+ save();
83
+ }
84
+ else if (e.key === 'Escape') {
85
+ e.preventDefault();
86
+ e.stopPropagation();
87
+ setOpen(null);
88
+ }
89
+ } }), _jsxs("div", { className: "row nodest", children: [_jsxs("span", { className: "ctx", children: ["\u21A9 save as v", row.versions.length + 1, " \u00B7 esc back"] }), _jsxs("button", { type: "button", className: "sendb", "aria-disabled": !edit.trim() || edit.trim() === row.text || undefined, onClick: save, children: [_jsx(CheckIcon, {}), " Save edit"] })] })] })] })] }));
90
+ }
91
+ return (_jsxs("div", { className: `pop notes ${className}`, style: { transformOrigin: origin }, role: "dialog", "aria-label": "Notes", onKeyDown: walk, children: [_jsxs("div", { className: "pop-head", children: [_jsxs("span", { className: "n-title", children: ["Notes ", _jsx("span", { className: "n-count", children: rows.length })] }), _jsx("button", { type: "button", className: "closeb", "aria-label": "Close", onClick: onClose, children: _jsx(CloseIcon, {}) })] }), _jsx("div", { className: "n-filter", role: "group", "aria-label": "Show", children: FILTERS.map((f) => (_jsxs("button", { type: "button", "aria-pressed": filter === f.value, onClick: () => setFilter(f.value), children: [f.label, " ", filterRows(rows, f.value).length] }, f.value))) }), visible.length === 0 ? (_jsx("p", { className: "n-empty", children: rows.length === 0 ? 'Notes and annotations you send while recording show here.' : `No ${filter} yet.` })) : (_jsx("div", { ref: list, className: "n-list", role: "list", "aria-label": "Notes", children: visible.map((r) => (_jsx("div", { role: "listitem", className: r.cid === focused ? 'n-row on' : 'n-row', children: _jsxs("button", { type: "button", className: "n-open", "data-cid": r.cid, tabIndex: r.cid === tabCid ? 0 : -1, "aria-label": `${kicker(r, now)} — ${r.text}`, onFocus: () => setFocused(r.cid), onClick: () => setOpen(r.cid), children: [_jsx("span", { className: r.region ? 'n-face' : 'n-face note', children: r.region ? _jsx(AnnotateIcon, {}) : _jsx(PencilIcon, {}) }), _jsxs("span", { className: "n-lines", children: [_jsx("span", { className: "n-kick", children: kicker(r, now) }), _jsx("span", { className: "n-text", children: r.text || '(no text)' })] }), _jsx("i", { className: r.queued ? 'n-dot queued' : r.versions.length > 1 ? 'n-dot edited' : 'n-dot sent', "aria-hidden": "true" })] }) }, r.cid))) }))] }));
92
+ }
93
+ /** The notes sheet's CSS (appended to HUD_CSS): the island's grammar on the HUD's tokens. */
94
+ export const NOTES_CSS = `
95
+ .pop.notes { width:min(calc(400px * var(--s)), calc(100vw - 24px)); padding:0 0 8px; overflow:hidden; }
96
+ .pop.notes.split { width:min(calc(460px * var(--s)), calc(100vw - 24px)); }
97
+ .notes .pop-head { height:44px; padding:0 8px 0 16px; }
98
+ .n-title { font-weight:700; font-size:calc(var(--fs) + 2.5px); letter-spacing:-.02em; color:var(--fg); }
99
+ .n-count, .n-kick { font:500 var(--fs-s)/1.4 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing:.06em; text-transform:uppercase; color:var(--fg-3); }
100
+ .n-count { margin-left:6px; }
101
+ .n-head, .n-acts { display:flex; align-items:center; gap:6px; min-width:0; }
102
+ .n-head .n-kick { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
103
+ .n-word { all:unset; cursor:pointer; display:inline-flex; align-items:center; gap:4px; padding:5px 7px; border-radius:6px;
104
+ font:500 var(--fs-s)/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing:.06em; text-transform:uppercase; color:var(--fg-2); }
105
+ .n-word:focus-visible { outline:2px solid var(--rec); outline-offset:-2px; }
106
+ @media (hover: hover) { .n-word:hover { color:var(--fg); background:var(--ink-2); } }
107
+ .n-filter { display:flex; gap:4px; padding:0 12px 8px; }
108
+ .n-filter button { all:unset; cursor:pointer; padding:4px 9px; border-radius:999px; font-size:calc(var(--fs) - .5px); font-weight:600; color:var(--fg-3); }
109
+ .n-filter button[aria-pressed="true"] { background:var(--ink-3); color:var(--fg); }
110
+ .n-filter button:focus-visible { outline:2px solid var(--rec); outline-offset:-2px; }
111
+ .n-list { max-height:min(60vh, calc(360px * var(--s))); overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin; }
112
+ .n-row { position:relative; }
113
+ .n-row + .n-row { border-top:1px solid rgba(255,255,255,.07); }
114
+ .n-row.on::before { content:""; position:absolute; left:6px; top:50%; width:4px; height:4px; margin-top:-2px; border-radius:9px; background:var(--rec); }
115
+ .n-open { all:unset; box-sizing:border-box; cursor:pointer; width:100%; display:grid; grid-template-columns:calc(44px * var(--s)) minmax(0,1fr) 8px;
116
+ gap:12px; align-items:center; padding:10px 16px; }
117
+ .n-open:focus-visible { outline:2px solid var(--rec); outline-offset:-2px; border-radius:8px; }
118
+ @media (hover: hover) { .n-open:hover { background:rgba(255,255,255,.04); } }
119
+ .n-face { display:grid; place-items:center; height:calc(32px * var(--s)); border-radius:5px; background:rgba(0,0,0,.28);
120
+ box-shadow:inset 0 0 0 1.5px rgba(255,59,87,.6); color:var(--rec); }
121
+ .n-face.note { box-shadow:inset 0 0 0 1px var(--edge); color:var(--fg-3); }
122
+ .n-lines { display:flex; flex-direction:column; gap:2px; min-width:0; }
123
+ .n-text { color:var(--fg); font-size:calc(var(--fs) + .5px); line-height:1.35; overflow:hidden; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
124
+ .n-dot { width:7px; height:7px; border-radius:50%; }
125
+ .n-dot.sent { background:var(--ok); }
126
+ .n-dot.queued { background:var(--warn); }
127
+ .n-dot.edited { background:#8fb8ff; }
128
+ .n-empty { margin:4px 16px 8px; font-size:var(--fs-s); color:var(--fg-3); }
129
+ .n-split { display:flex; min-height:0; }
130
+ .n-rail { flex:0 0 calc(60px * var(--s)); display:flex; flex-direction:column; align-items:center; gap:7px; padding:4px 0 8px;
131
+ border-right:1px solid rgba(255,255,255,.08); max-height:min(60vh, calc(380px * var(--s))); overflow-y:auto; scrollbar-width:none; }
132
+ .n-th { all:unset; cursor:pointer; position:relative; display:grid; place-items:center; width:calc(40px * var(--s)); height:calc(30px * var(--s));
133
+ border-radius:7px; background:rgba(0,0,0,.28); box-shadow:inset 0 0 0 1px var(--edge); color:var(--fg-3); opacity:.7; }
134
+ .n-th b { position:absolute; left:4px; bottom:2px; font:600 9px/1 ui-monospace, Menlo, monospace; color:var(--fg-2); }
135
+ .n-th.on { opacity:1; box-shadow:0 0 0 2px var(--rec); color:var(--fg); }
136
+ .n-th:focus-visible { outline:2px solid var(--rec); outline-offset:2px; }
137
+ .n-body { flex:1; min-width:0; display:flex; flex-direction:column; gap:8px; padding:4px 14px 4px;
138
+ max-height:min(60vh, calc(380px * var(--s))); overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin; }
139
+ .n-meta { font-size:var(--fs-s); color:var(--fg-3); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
140
+ .n-ver { padding:8px 10px; border-radius:9px; background:rgba(0,0,0,.22); box-shadow:inset 0 0 0 1px var(--edge);
141
+ font-size:calc(var(--fs) + .5px); line-height:1.4; color:var(--fg); white-space:pre-wrap; overflow-wrap:anywhere; }
142
+ .n-ver .n-kick { display:block; margin-bottom:3px; }
143
+ .n-ver.old { color:var(--fg-3); text-decoration:line-through; text-decoration-color:rgba(244,239,234,.25); }
144
+ .n-ver.old .n-kick { text-decoration:none; }
145
+ textarea.n-edit { margin-top:0; min-height:calc(44px * var(--s)); resize:vertical; overflow-y:auto; }
146
+ .n-body .row { margin-top:0; }
147
+ `;
@@ -2,35 +2,48 @@
2
2
  * The HUD's face: ONE glass pill whose faces are collapsible segments, so a
3
3
  * change of face tweens the pill's size instead of swapping boxes.
4
4
  *
5
- * - Idle: a puck — a hollow ring before the device is linked, a muted dot
6
- * once it is — whose label (and the ⋯ menu button) slide out on intent.
5
+ * - Idle: a puck — a hollow ring before the device is linked, a red record
6
+ * dot once it is — whose label (and the ⋯ menu button) slide out on intent;
7
+ * "Starting…" while a Start boots (HUD polish D3/D11).
7
8
  * - Recording: the handle (rec dot + clock) that unfolds into the tray
8
- * (sync chip · ⏸ ✎ ⌖ ■ ⋯) on hover, focus or tap and folds back ~2.5s
9
- * after the pointer and focus leave. On the middle row it stands up into a
10
- * vertical pill (a measured morph, see useMorph).
9
+ * (⏸ ✎ ⌖ ■ ⋯) on hover, focus or tap and folds back ~2.5s after the
10
+ * pointer and focus leave. The dot's ring is the sync state; the counts
11
+ * float above while the tray is open (`Stats`, D4). On the middle row it
12
+ * stands up into a vertical pill (a measured morph, see useMorph).
11
13
  * - Flows (flow.ts): the pill itself asks "Stop & save?" / "Unlink this
12
- * device?", spins while saving, says "Saved · Open board" until dismissed,
13
- * or says why it could not save (a bug report: "Sending…", "Sent",
14
- * "Couldn't send"). Always horizontal.
14
+ * device?", spins while saving, then follows the board's build — "Building
15
+ * board · 3/5", "Board ready · Open board", "Board build failed · Retry" —
16
+ * until Done (D1/D2), or says why it could not save (a bug report:
17
+ * "Sending…", "Sent", "Couldn't send"). Always horizontal.
18
+ * - Remote: the recording runs in another tab — a quiet "in another tab".
15
19
  * - Tucked: a 6px edge tab.
16
20
  * The handle, the puck and the tab are the drag handles. Tooltips are
17
21
  * `data-tip` / `data-keys` on the triggers (Tooltip.tsx paints them).
18
22
  */
19
23
  import { type ReactElement, type RefObject } from 'react';
20
- import type { HudSnapshot } from './controller';
24
+ import type { HudSnapshot, HudSync } from './controller';
21
25
  import type { Flow } from './flow';
22
26
  import { type Place } from './spots';
23
27
  import type { DockHandle } from './useDock';
24
28
  export declare const MOD: string;
25
- export type Face = 'tab' | 'idle' | 'rec' | 'flow';
29
+ export type Face = 'tab' | 'idle' | 'rec' | 'flow' | 'remote';
30
+ /** What the clock says after a note: `queued` until the server has it, then `saved`. */
31
+ export type Flash = 'queued' | 'saved' | null;
26
32
  /** Which face the pill shows. A flow wins over the recording it belongs to. */
27
33
  export declare function faceOf(snap: HudSnapshot, flow: Flow, place: Place): Face;
34
+ /** A note's client id (D6/D7): random, names the note and nothing else. */
35
+ export declare function newCid(): string;
36
+ /** The details float's default face (D4): what reached vitrinka, by kind. */
37
+ export declare function Stats({ sync, now }: {
38
+ sync: HudSync;
39
+ now: number;
40
+ }): ReactElement;
28
41
  export interface RecorderPillProps {
29
42
  snap: HudSnapshot;
30
43
  now: number;
31
44
  flow: Flow;
32
- /** A note or annotation was just accepted: the clock briefly says so. */
33
- flash: boolean;
45
+ /** A note or annotation was just sent: the clock says `queued`, then briefly `Saved`. */
46
+ flash: Flash;
34
47
  composing: boolean;
35
48
  starting: boolean;
36
49
  menuOpen: boolean;
@@ -51,5 +64,14 @@ export interface RecorderPillProps {
51
64
  onCancel: () => void;
52
65
  onRetry: () => void;
53
66
  onDismiss: () => void;
67
+ /** Build the saved session's board again (a retryable failed build). */
68
+ onRetryBuild: (sessionId: string) => void;
69
+ /** The host implements `retryBuild`: only then does a failed build offer Retry. */
70
+ canRetryBuild: boolean;
71
+ /** The recording's tray unfolded or folded: the stats float follows it. */
72
+ onTrayOpen: (open: boolean) => void;
73
+ /** This recording's notes so far (the tray's notes button counts them, D5); absent = the host lists none. */
74
+ notesCount?: number;
75
+ onNotes: () => void;
54
76
  }
55
77
  export declare function RecorderPill(p: RecorderPillProps): ReactElement;
@@ -1,25 +1,29 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  /**
3
3
  * The HUD's face: ONE glass pill whose faces are collapsible segments, so a
4
4
  * change of face tweens the pill's size instead of swapping boxes.
5
5
  *
6
- * - Idle: a puck — a hollow ring before the device is linked, a muted dot
7
- * once it is — whose label (and the ⋯ menu button) slide out on intent.
6
+ * - Idle: a puck — a hollow ring before the device is linked, a red record
7
+ * dot once it is — whose label (and the ⋯ menu button) slide out on intent;
8
+ * "Starting…" while a Start boots (HUD polish D3/D11).
8
9
  * - Recording: the handle (rec dot + clock) that unfolds into the tray
9
- * (sync chip · ⏸ ✎ ⌖ ■ ⋯) on hover, focus or tap and folds back ~2.5s
10
- * after the pointer and focus leave. On the middle row it stands up into a
11
- * vertical pill (a measured morph, see useMorph).
10
+ * (⏸ ✎ ⌖ ■ ⋯) on hover, focus or tap and folds back ~2.5s after the
11
+ * pointer and focus leave. The dot's ring is the sync state; the counts
12
+ * float above while the tray is open (`Stats`, D4). On the middle row it
13
+ * stands up into a vertical pill (a measured morph, see useMorph).
12
14
  * - Flows (flow.ts): the pill itself asks "Stop & save?" / "Unlink this
13
- * device?", spins while saving, says "Saved · Open board" until dismissed,
14
- * or says why it could not save (a bug report: "Sending…", "Sent",
15
- * "Couldn't send"). Always horizontal.
15
+ * device?", spins while saving, then follows the board's build — "Building
16
+ * board · 3/5", "Board ready · Open board", "Board build failed · Retry" —
17
+ * until Done (D1/D2), or says why it could not save (a bug report:
18
+ * "Sending…", "Sent", "Couldn't send"). Always horizontal.
19
+ * - Remote: the recording runs in another tab — a quiet "in another tab".
16
20
  * - Tucked: a 6px edge tab.
17
21
  * The handle, the puck and the tab are the drag handles. Tooltips are
18
22
  * `data-tip` / `data-keys` on the triggers (Tooltip.tsx paints them).
19
23
  */
20
24
  import { useCallback, useEffect, useLayoutEffect, useRef, useState, } from 'react';
21
25
  import { saveProgress } from './flow';
22
- import { AlertIcon, AnnotateIcon, CheckIcon, CloseIcon, CircleCheckIcon, CloudOffIcon, MoreIcon, NewTabIcon, PauseIcon, PencilIcon, PlayIcon, SpinnerIcon, StopIcon, ArrowUpIcon, } from './icons';
26
+ import { AlertIcon, AnnotateIcon, CheckIcon, CloseIcon, CircleCheckIcon, CloudOffIcon, LayersIcon, ListIcon, MoreIcon, NewTabIcon, PauseIcon, PencilIcon, PlayIcon, SpinnerIcon, StopIcon, ArrowUpIcon, } from './icons';
23
27
  import { isVertical, untuck } from './spots';
24
28
  import { elapsedOf, fmtClock, syncChip } from './status';
25
29
  export const MOD = /Mac|iPhone|iPad/.test(globalThis.navigator?.platform ?? '') ? '⌥⇧' : 'Alt⇧';
@@ -35,8 +39,27 @@ export function faceOf(snap, flow, place) {
35
39
  return 'tab';
36
40
  if (flow.face !== 'none')
37
41
  return 'flow';
42
+ if (snap.following && snap.followingElsewhere)
43
+ return 'remote';
38
44
  return snap.recording ? 'rec' : 'idle';
39
45
  }
46
+ /** A note's client id (D6/D7): random, names the note and nothing else. */
47
+ export function newCid() {
48
+ const c = globalThis.crypto;
49
+ if (typeof c?.randomUUID === 'function')
50
+ return c.randomUUID();
51
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
52
+ }
53
+ /** The sync state and counts as one sentence — the handle's description (D4). */
54
+ function syncSentence(chip, a) {
55
+ return a ? `${chip.title} · ${a.actions} actions · ${a.frames} frames · ${a.notes} notes · ${a.pages} pages` : chip.title;
56
+ }
57
+ /** The details float's default face (D4): what reached vitrinka, by kind. */
58
+ export function Stats({ sync, now }) {
59
+ const chip = syncChip(sync, now);
60
+ const a = sync.acked;
61
+ return (_jsxs("span", { className: "stats", "data-e2e": "sync-chip", "data-kind": chip.kind, children: [_jsxs("span", { className: "s-head", children: [_jsx(SyncGlyph, { chip: chip }), chip.kind === 'synced' ? 'on vitrinka' : chip.label] }), a ? (_jsxs(_Fragment, { children: [_jsx("i", {}), _jsxs("span", { children: [_jsx("b", { children: a.actions }), " actions"] }), _jsxs("span", { children: [_jsx("b", { children: a.frames }), " frames"] }), _jsxs("span", { children: [_jsx("b", { children: a.notes }), " notes"] }), _jsxs("span", { children: [_jsx("b", { children: a.pages }), " pages"] })] })) : null] }));
62
+ }
40
63
  function reducedMotion() {
41
64
  return globalThis.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false;
42
65
  }
@@ -184,6 +207,9 @@ export function RecorderPill(p) {
184
207
  foldIn(FOLD_MS);
185
208
  }, [hold, open, cancelFold, foldIn]);
186
209
  const unfolded = open || (hold && face !== 'flow');
210
+ const trayShown = unfolded && face === 'rec';
211
+ const { onTrayOpen } = p;
212
+ useEffect(() => onTrayOpen(trayShown), [trayShown, onTrayOpen]);
187
213
  // Hover is read with NATIVE pointerenter/leave: React synthesises enter
188
214
  // from over/out pairs and drops an `over` whose related target belongs to
189
215
  // any React root — on a React page the pointer always arrives from the
@@ -258,7 +284,7 @@ export function RecorderPill(p) {
258
284
  const bad = live === 'offline' || live === 'error';
259
285
  const state = bad ? 'bad' : !rec || rec.paused || rec.dead ? 'paused' : 'rec';
260
286
  const unlinked = !p.snap.linked;
261
- const puckLabel = unlinked ? 'Link recorder' : 'Start recording';
287
+ const puckLabel = unlinked ? 'Link recorder' : p.starting ? 'Starting…' : 'Start recording';
262
288
  const confirming = p.flow.face === 'confirm';
263
289
  const dataFace = face === 'flow' && confirming && rec ? 'flow-rec' : face;
264
290
  const progress = saveProgress(p.flow, rec?.sync.queued ?? 0);
@@ -309,11 +335,23 @@ export function RecorderPill(p) {
309
335
  const savedUrl = shownFlow.face === 'saved'
310
336
  ? (shownFlow.boardUrl ?? p.snap.recents.find((r) => r.sessionId === shownFlow.sessionId)?.boardUrl)
311
337
  : undefined;
338
+ // The board's build after a stop (D1): building → ready, or a failure the tester can retry.
339
+ const savedSession = shownFlow.face === 'saved' ? shownFlow.sessionId : undefined;
340
+ const proj = savedSession ? p.snap.recents.find((r) => r.sessionId === savedSession)?.projection : undefined;
341
+ const build = savedUrl
342
+ ? 'ready'
343
+ : proj?.state === 'failed'
344
+ ? 'failed'
345
+ : proj?.state === 'empty'
346
+ ? 'empty'
347
+ : 'building';
348
+ const buildTotal = proj?.total ?? 0;
349
+ const buildProgress = buildTotal > 0 ? Math.min(1, Math.max(0, (proj?.done ?? 0) / buildTotal)) : null;
312
350
  const failure = shownFlow.face === 'failed' ? shownFlow.message : '';
313
351
  // A bug report's send: "Sending…", "Sent", "Couldn't send" — and it can always be retried.
314
352
  const report = 'report' in shownFlow && shownFlow.report === true;
315
353
  const startFailed = shownFlow.face === 'failed' && shownFlow.start === true;
316
- return (_jsxs("div", { ref: p.pillRef, className: "pill glass", "data-e2e": "recorder-pill", "data-face": dataFace, "data-orient": orient, "data-state": state, "data-open": unfolded && face !== 'flow' ? '' : undefined, onPointerDown: onTouch, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKey, children: [_jsx(Seg, { on: face === 'idle', className: "s-idle", children: _jsxs("button", { ref: puckRef, type: "button", className: "puck", "data-state": unlinked ? 'unlinked' : p.starting ? 'busy' : 'ready', "aria-label": puckLabel, onClick: unlinked ? p.onLink : p.onStart, disabled: p.starting, ...p.handle, children: [_jsx("span", { className: "ring" }), _jsx("span", { className: "lab", "aria-hidden": "true", children: _jsx("span", { children: puckLabel }) })] }) }), _jsx(Seg, { on: face === 'idle' && unfolded, className: "s-more", children: _jsx("button", { type: "button", className: "tb b-more", "aria-label": "More", "aria-haspopup": "menu", "aria-expanded": p.menuOpen, "data-tip": "Recents \u00B7 settings", onClick: (e) => p.onMenu(e.detail === 0), onKeyDown: onMoreKey, children: _jsx(MoreIcon, {}) }) }), _jsx(Seg, { on: face === 'rec' || (confirming && rec !== null), className: "s-handle", children: _jsxs("button", { type: "button", className: "handle", "aria-label": "Recorder controls", "aria-expanded": unfolded && face === 'rec', onClick: toggle, ...p.handle, children: [_jsx("span", { className: "dot" }), _jsxs("span", { className: "clock", children: [_jsx(Seg, { on: !p.flash, className: "c-time", children: _jsx("span", { className: "time", children: shownRec ? fmtClock(elapsedOf(shownRec, p.now)) : '00:00' }) }), _jsx(Seg, { on: p.flash, className: "c-flash", children: _jsxs("span", { className: "flash", "data-e2e": "saved-flash", children: [_jsx(CheckIcon, {}), _jsx("span", { children: "Saved" })] }) })] })] }) }), _jsx(Seg, { on: face === 'rec' && unfolded, className: "s-tray", children: _jsxs("div", { className: "tools seg-row", children: [_jsx("span", { className: "sep" }), chip ? (_jsxs("span", { className: "sync", "data-kind": chip.kind, "data-tip": chip.title, role: "status", "aria-label": chip.title, "data-e2e": "sync-chip", children: [_jsx("span", { className: "swap", children: _jsx(SyncGlyph, { chip: chip }) }, `glyph-${chip.kind}`), _jsx("span", { className: "word swap", children: chip.label }, `word-${chip.label}`)] })) : null, _jsx("button", { type: "button", className: "tb b-pause", "aria-label": shownRec?.paused ? 'Resume' : 'Pause', "aria-keyshortcuts": "Alt+Shift+P", "data-tip": shownRec?.paused ? 'Resume' : 'Pause', "data-keys": `${MOD}P`, onClick: p.onPause, children: shownRec?.paused ? _jsx(PlayIcon, {}) : _jsx(PauseIcon, {}) }), _jsx("button", { type: "button", className: "tb b-note", "aria-label": "Note", "aria-keyshortcuts": "Alt+Shift+N", "data-tip": "Note", "data-keys": `${MOD}N`, onClick: p.onNote, children: _jsx(PencilIcon, {}) }), _jsx("button", { type: "button", className: annotating ? 'tb b-annotate on' : 'tb b-annotate', "aria-label": "Annotate", "aria-pressed": annotating, "aria-keyshortcuts": "Alt+Shift+A", "data-tip": "Annotate", "data-keys": `${MOD}A`, onClick: p.onAnnotate, children: _jsx(AnnotateIcon, {}) }), _jsx("button", { ref: stopRef, type: "button", className: "tb b-stop", "aria-label": "Stop", "aria-keyshortcuts": "Alt+Shift+S", "data-tip": "Stop & save", "data-keys": `${MOD}S`, onClick: p.onAskStop, children: _jsx(StopIcon, {}) }), _jsx("button", { type: "button", className: "tb b-more", "aria-label": "More", "aria-haspopup": "menu", "aria-expanded": p.menuOpen, "data-tip": "More", onClick: (e) => p.onMenu(e.detail === 0), onKeyDown: onMoreKey, children: _jsx(MoreIcon, {}) })] }) }), _jsx(Seg, { on: p.flow.face === 'confirm', className: "s-confirm", children: _jsxs("div", { className: "flow confirm", role: "group", "aria-label": confirmAction === 'stop' ? 'Stop and save' : 'Unlink', children: [_jsx("span", { className: "q", children: confirmAction === 'stop' ? 'Stop & save?' : 'Unlink this device?' }), _jsx("button", { type: "button", className: "fb primary", onClick: p.onConfirm, children: confirmAction === 'stop' ? 'Stop' : 'Unlink' }), _jsx("button", { ref: keepRef, type: "button", className: "fb", onClick: p.onCancel, children: confirmAction === 'stop' ? 'Keep recording' : 'Cancel' })] }) }), _jsx(Seg, { on: p.flow.face === 'saving', className: "s-saving", children: _jsxs("div", { className: "flow saving", role: "status", "data-e2e": "saving", children: [_jsx(SpinnerIcon, {}), _jsx("span", { children: report ? 'Sending…' : 'Saving…' }), progress !== null && rec ? _jsxs("span", { className: "muted", children: [rec.sync.queued, " left"] }) : null, _jsx("span", { className: "bar-track", "data-indeterminate": progress === null ? '' : undefined, role: "progressbar", "aria-label": report ? 'Sending' : 'Saving', "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": progress === null ? undefined : Math.round(progress * 100), style: { '--p': String(progress ?? 0) }, children: _jsx("i", {}) })] }) }), _jsx(Seg, { on: p.flow.face === 'saved', className: "s-saved", children: _jsxs("div", { className: "flow saved", "data-e2e": "saved", children: [_jsx("span", { className: "ok t-check", "data-state": flowShown === 'saved' ? 'in' : undefined, children: _jsx(CheckIcon, {}) }), _jsx("span", { children: report ? 'Sent' : 'Saved' }), savedUrl ? (_jsxs("a", { ref: (el) => {
317
- savedRef.current = el;
318
- }, className: "fb", href: savedUrl, target: "_blank", rel: "noopener noreferrer", children: ["Open board ", _jsx(NewTabIcon, {})] })) : (_jsx("span", { className: "muted", children: "in Recents" })), _jsx("button", { ref: savedUrl ? undefined : (el) => void (savedRef.current = el), type: "button", className: "fb icon", "aria-label": "Dismiss", onClick: p.onDismiss, children: _jsx(CloseIcon, {}) })] }) }), _jsx(Seg, { on: p.flow.face === 'failed', className: "s-failed", children: _jsxs("div", { className: "flow failed", role: "alert", "data-tip": failure, children: [_jsx("span", { className: "warn", children: _jsx(AlertIcon, {}) }), _jsx("span", { className: "msg", children: shortFailure(failure, report, startFailed) }), _jsx("span", { className: "sr", children: failure }), (rec || report) && !startFailed ? (_jsx("button", { type: "button", className: "fb", onClick: p.onRetry, children: "Retry" })) : null, _jsx("button", { type: "button", className: "fb icon", "aria-label": "Dismiss", onClick: p.onDismiss, children: _jsx(CloseIcon, {}) })] }) })] }));
354
+ return (_jsxs("div", { ref: p.pillRef, className: "pill glass", "data-e2e": "recorder-pill", "data-face": dataFace, "data-orient": orient, "data-state": state, "data-open": (unfolded || p.starting) && face !== 'flow' ? '' : undefined, onPointerDown: onTouch, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKey, children: [_jsx(Seg, { on: face === 'idle', className: "s-idle", children: _jsxs("button", { ref: puckRef, type: "button", className: "puck", "data-state": unlinked ? 'unlinked' : p.starting ? 'busy' : 'ready', "aria-label": puckLabel, onClick: unlinked ? p.onLink : p.onStart, disabled: p.starting, ...p.handle, children: [_jsx("span", { className: "ring" }), _jsx("span", { className: "lab", "aria-hidden": "true", children: _jsx("span", { children: puckLabel }) })] }) }), _jsx(Seg, { on: face === 'idle' && unfolded, className: "s-more", children: _jsx("button", { type: "button", className: "tb b-more", "aria-label": "More", "aria-haspopup": "menu", "aria-expanded": p.menuOpen, "data-tip": "Recents \u00B7 settings", onClick: (e) => p.onMenu(e.detail === 0), onKeyDown: onMoreKey, children: _jsx(MoreIcon, {}) }) }), _jsxs(Seg, { on: face === 'rec' || (confirming && rec !== null), className: "s-handle", children: [_jsx("span", { id: "vt-sync-desc", className: "sr", children: chip ? syncSentence(chip, shownRec?.sync.acked) : '' }), _jsxs("button", { type: "button", className: "handle", "aria-label": "Recorder controls", "aria-describedby": "vt-sync-desc", "aria-expanded": unfolded && face === 'rec', onClick: toggle, ...p.handle, children: [_jsx("span", { className: "dot", "data-sync": chip?.kind }), _jsxs("span", { className: "clock", children: [_jsx(Seg, { on: p.flash === null, className: "c-time", children: _jsx("span", { className: "time", children: shownRec ? fmtClock(elapsedOf(shownRec, p.now)) : '00:00' }) }), _jsx(Seg, { on: p.flash !== null, className: "c-flash", children: _jsxs("span", { className: "flash", "data-e2e": "saved-flash", "data-word": p.flash ?? 'saved', children: [p.flash === 'queued' ? _jsx(ArrowUpIcon, {}) : _jsx(CheckIcon, {}), _jsx("span", { children: p.flash === 'queued' ? 'queued' : 'Saved' })] }) })] })] })] }), _jsx(Seg, { on: face === 'rec' && unfolded, className: "s-tray", children: _jsxs("div", { className: "tools seg-row", children: [_jsx("span", { className: "sep" }), p.notesCount !== undefined ? (_jsxs("button", { type: "button", className: "tb b-notes", "aria-label": `History · ${p.notesCount}`, "data-tip": "History", onClick: p.onNotes, children: [_jsx(ListIcon, {}), p.notesCount > 0 ? _jsx("span", { className: "cnt", children: p.notesCount }) : null] })) : null, _jsx("button", { type: "button", className: "tb b-pause", "aria-label": shownRec?.paused ? 'Resume' : 'Pause', "aria-keyshortcuts": "Alt+Shift+P", "data-tip": shownRec?.paused ? 'Resume' : 'Pause', "data-keys": `${MOD}P`, onClick: p.onPause, children: shownRec?.paused ? _jsx(PlayIcon, {}) : _jsx(PauseIcon, {}) }), _jsx("button", { type: "button", className: "tb b-note", "aria-label": "Note", "aria-keyshortcuts": "Alt+Shift+N", "data-tip": "Note", "data-keys": `${MOD}N`, onClick: p.onNote, children: _jsx(PencilIcon, {}) }), _jsx("button", { type: "button", className: annotating ? 'tb b-annotate on' : 'tb b-annotate', "aria-label": "Annotate", "aria-pressed": annotating, "aria-keyshortcuts": "Alt+Shift+A", "data-tip": "Annotate", "data-keys": `${MOD}A`, onClick: p.onAnnotate, children: _jsx(AnnotateIcon, {}) }), _jsx("button", { ref: stopRef, type: "button", className: "tb b-stop", "aria-label": "Stop", "aria-keyshortcuts": "Alt+Shift+S", "data-tip": "Stop & save", "data-keys": `${MOD}S`, onClick: p.onAskStop, children: _jsx(StopIcon, {}) }), _jsx("button", { type: "button", className: "tb b-more", "aria-label": "More", "aria-haspopup": "menu", "aria-expanded": p.menuOpen, "data-tip": "More", onClick: (e) => p.onMenu(e.detail === 0), onKeyDown: onMoreKey, children: _jsx(MoreIcon, {}) })] }) }), _jsx(Seg, { on: p.flow.face === 'confirm', className: "s-confirm", children: _jsxs("div", { className: "flow confirm", role: "group", "aria-label": confirmAction === 'stop' ? 'Stop and save' : 'Unlink', children: [_jsx("span", { className: "q", children: confirmAction === 'stop' ? 'Stop & save?' : 'Unlink this device?' }), _jsx("button", { type: "button", className: "fb primary", onClick: p.onConfirm, children: confirmAction === 'stop' ? 'Stop' : 'Unlink' }), _jsx("button", { ref: keepRef, type: "button", className: "fb", onClick: p.onCancel, children: confirmAction === 'stop' ? 'Keep recording' : 'Cancel' })] }) }), _jsx(Seg, { on: p.flow.face === 'saving', className: "s-saving", children: _jsxs("div", { className: "flow saving", role: "status", "data-e2e": "saving", children: [_jsx(SpinnerIcon, {}), _jsx("span", { children: report ? 'Sending…' : 'Saving…' }), progress !== null && rec ? _jsxs("span", { className: "muted", children: [rec.sync.queued, " left"] }) : null, _jsx("span", { className: "bar-track", "data-indeterminate": progress === null ? '' : undefined, role: "progressbar", "aria-label": report ? 'Sending' : 'Saving', "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": progress === null ? undefined : Math.round(progress * 100), style: { '--p': String(progress ?? 0) }, children: _jsx("i", {}) })] }) }), _jsx(Seg, { on: p.flow.face === 'saved', className: "s-saved", children: _jsxs("div", { className: "flow saved", "data-e2e": "saved", "data-build": build, children: [build === 'building' ? (_jsxs(_Fragment, { children: [_jsx(LayersIcon, {}), _jsx("span", { children: report ? 'Sent · building board' : 'Building board' }), proj?.step ? _jsx("span", { className: "muted step", children: proj.step }) : null, buildTotal > 0 ? (_jsxs("span", { className: "frac", children: [proj?.done ?? 0, "/", buildTotal] })) : null, _jsx("span", { className: "bar-track", "data-indeterminate": buildProgress === null ? '' : undefined, role: "progressbar", "aria-label": "Building the board", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": buildProgress === null ? undefined : Math.round(buildProgress * 100), style: { '--p': String(buildProgress ?? 0) }, children: _jsx("i", {}) })] })) : build === 'failed' ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "warn", children: _jsx(AlertIcon, {}) }), _jsx("span", { "data-tip": proj?.error, children: "Board build failed" }), _jsx("span", { className: "sr", children: proj?.error }), proj?.retryable && savedSession && p.canRetryBuild ? (_jsx("button", { type: "button", className: "fb", onClick: () => p.onRetryBuild(savedSession), children: "Retry" })) : null] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "ok t-check", "data-state": flowShown === 'saved' ? 'in' : undefined, children: _jsx(CheckIcon, {}) }), _jsx("span", { children: build === 'ready' ? (report ? 'Sent' : 'Board ready') : report ? 'Sent' : 'Saved' }), savedUrl ? (_jsxs("a", { ref: (el) => {
355
+ savedRef.current = el;
356
+ }, className: "fb primary", href: savedUrl, target: "_blank", rel: "noopener noreferrer", children: ["Open board ", _jsx(NewTabIcon, {})] })) : (_jsx("span", { className: "muted", children: "nothing to build" }))] })), _jsx("button", { ref: savedUrl ? undefined : (el) => void (savedRef.current = el), type: "button", className: "fb", onClick: p.onDismiss, children: "Done" })] }) }), _jsx(Seg, { on: face === 'remote', className: "s-remote", children: _jsxs("div", { className: "flow remote", "data-e2e": "recorder-remote", children: [_jsx("span", { className: "dot" }), _jsx("span", { className: "muted", children: "Recording in another tab" })] }) }), _jsx(Seg, { on: p.flow.face === 'failed', className: "s-failed", children: _jsxs("div", { className: "flow failed", role: "alert", "data-tip": failure, children: [_jsx("span", { className: "warn", children: _jsx(AlertIcon, {}) }), _jsx("span", { className: "msg", children: shortFailure(failure, report, startFailed) }), _jsx("span", { className: "sr", children: failure }), (rec || report) && !startFailed ? (_jsx("button", { type: "button", className: "fb", onClick: p.onRetry, children: "Retry" })) : null, _jsx("button", { type: "button", className: "fb icon", "aria-label": "Dismiss", onClick: p.onDismiss, children: _jsx(CloseIcon, {}) })] }) })] }));
319
357
  }
@@ -1,15 +1,16 @@
1
1
  /**
2
2
  * The composer sheet — the extension's hud.html, as a component: 440px wide
3
3
  * by default, anchored to the dock (a bottom sheet on phones), a 14px textarea
4
- * (16px on touch, so iOS never zooms) that grows with the draft up to a cap
5
- * and then scrolls, a resize grip on the corner away from the dock (width
6
- * and cap are HUD prefs — resize.ts), ✕ in the title row, a three-column footer
7
- * (board|task · context · ↑ Send) and the hint line (hidden on touch). Enter sends, ⇧Enter newlines, Esc
8
- * cancels. The DRAFT is owned by the caller so a cancel keeps it until the
9
- * next send (recorder-hud-polish D3); the board|task choice resets on every
10
- * open — a destination is per observation, not a mode. The bug report is the
11
- * same sheet: a required description and "Mark on screen" in the board|task
12
- * slot.
4
+ * (16px on touch, so iOS never zooms) that grows with the draft and then
5
+ * scrolls, a resize grip on the corner away from the dock (width and the
6
+ * dragged height — a minimum — are HUD prefs, resize.ts), ✕ in the title
7
+ * row, the caller's `head` (what an annotation points at) under it and its
8
+ * `below` (↳ references) under the text, a footer (context · ↑ Send) and the
9
+ * hint line (hidden on touch). Enter sends, ⇧Enter newlines, Esc cancels.
10
+ * The DRAFT is owned by the caller so a cancel keeps it until the next send
11
+ * (recorder-hud-polish D3). Everything lands on the board — there is no
12
+ * destination to pick (HUD polish 2026-10-14). The bug report is the same
13
+ * sheet: a required description and "Mark on screen" left of the context.
13
14
  *
14
15
  * Images (recorder attachments), only when the caller passes `images`: the
15
16
  * paperclip beside Send picks them, an image paste on the textarea and a
@@ -20,7 +21,7 @@
20
21
  * image, the cap) shows in the footer's context slot — one line, so the
21
22
  * footer never moves.
22
23
  */
23
- import { type Dispatch, type ReactElement, type SetStateAction } from 'react';
24
+ import { type Dispatch, type ReactElement, type ReactNode, type SetStateAction } from 'react';
24
25
  import type { HudAttachment } from './controller';
25
26
  import { type Grip } from './resize';
26
27
  export interface SheetProps {
@@ -30,16 +31,18 @@ export interface SheetProps {
30
31
  origin: string;
31
32
  title: string;
32
33
  ctx: string;
33
- /** True when the sheet composes an annotation (shows board|task). */
34
- pick: boolean;
34
+ /** Under the title: what the annotation points at (its crop or size · route chip, Reselect — HUD polish D9/D15). */
35
+ head?: ReactNode;
36
+ /** Under the text box: the notes this one references (↳ chips, D7). */
37
+ below?: ReactNode;
35
38
  draft: string;
36
39
  onDraft: (text: string) => void;
37
- onSend: (text: string, task: boolean) => void;
40
+ onSend: (text: string) => void;
38
41
  onClose: () => void;
39
42
  placeholder?: string;
40
43
  /** Send stays off until the description has text. */
41
44
  required?: boolean;
42
- /** Shows "Mark on screen" (instead of board|task): pick a region or element. */
45
+ /** Shows "Mark on screen": pick a region or element. */
43
46
  onMark?: () => void;
44
47
  /** Something is marked (the button reads pressed). */
45
48
  marked?: boolean;
@@ -66,4 +69,4 @@ export interface SheetProps {
66
69
  /** The sheet's box changed size: place it again before it paints. */
67
70
  onLayout?: () => void;
68
71
  }
69
- export declare function Sheet({ className, origin, title, ctx, pick, draft, onDraft, onSend, onClose, placeholder, required, onMark, marked, images, onImages, preparing: busy, onPreparing, kind, sheetW, sheetH, room, grip, onResize, onLayout, }: SheetProps): ReactElement;
72
+ export declare function Sheet({ className, origin, title, ctx, head, below, draft, onDraft, onSend, onClose, placeholder, required, onMark, marked, images, onImages, preparing: busy, onPreparing, kind, sheetW, sheetH, room, grip, onResize, onLayout, }: SheetProps): ReactElement;
@@ -2,15 +2,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /**
3
3
  * The composer sheet — the extension's hud.html, as a component: 440px wide
4
4
  * by default, anchored to the dock (a bottom sheet on phones), a 14px textarea
5
- * (16px on touch, so iOS never zooms) that grows with the draft up to a cap
6
- * and then scrolls, a resize grip on the corner away from the dock (width
7
- * and cap are HUD prefs — resize.ts), ✕ in the title row, a three-column footer
8
- * (board|task · context · ↑ Send) and the hint line (hidden on touch). Enter sends, ⇧Enter newlines, Esc
9
- * cancels. The DRAFT is owned by the caller so a cancel keeps it until the
10
- * next send (recorder-hud-polish D3); the board|task choice resets on every
11
- * open — a destination is per observation, not a mode. The bug report is the
12
- * same sheet: a required description and "Mark on screen" in the board|task
13
- * slot.
5
+ * (16px on touch, so iOS never zooms) that grows with the draft and then
6
+ * scrolls, a resize grip on the corner away from the dock (width and the
7
+ * dragged height — a minimum — are HUD prefs, resize.ts), ✕ in the title
8
+ * row, the caller's `head` (what an annotation points at) under it and its
9
+ * `below` (↳ references) under the text, a footer (context · ↑ Send) and the
10
+ * hint line (hidden on touch). Enter sends, ⇧Enter newlines, Esc cancels.
11
+ * The DRAFT is owned by the caller so a cancel keeps it until the next send
12
+ * (recorder-hud-polish D3). Everything lands on the board — there is no
13
+ * destination to pick (HUD polish 2026-10-14). The bug report is the same
14
+ * sheet: a required description and "Mark on screen" left of the context.
14
15
  *
15
16
  * Images (recorder attachments), only when the caller passes `images`: the
16
17
  * paperclip beside Send picks them, an image paste on the textarea and a
@@ -48,12 +49,11 @@ function Thumb({ image, onRemove }) {
48
49
  }, [image.blob]);
49
50
  return (_jsxs("li", { className: "att", children: [src ? _jsx("img", { src: src, alt: image.name }) : null, _jsx("button", { type: "button", className: "attx", "aria-label": `Remove ${image.name}`, onClick: onRemove, children: _jsx(CloseIcon, {}) })] }));
50
51
  }
51
- export function Sheet({ className, origin, title, ctx, pick, draft, onDraft, onSend, onClose, placeholder = "what's wrong / what to refine…", required = false, onMark, marked = false, images, onImages, preparing: busy = 0, onPreparing, kind = 'note', sheetW = 0, sheetH = 0, room = 0, grip = null, onResize, onLayout, }) {
52
+ export function Sheet({ className, origin, title, ctx, head, below, draft, onDraft, onSend, onClose, placeholder = "what's wrong / what to refine…", required = false, onMark, marked = false, images, onImages, preparing: busy = 0, onPreparing, kind = 'note', sheetW = 0, sheetH = 0, room = 0, grip = null, onResize, onLayout, }) {
52
53
  const pop = useRef(null);
53
54
  const ta = useRef(null);
54
55
  const file = useRef(null);
55
56
  const size = useSheetSize({ sheet: pop, text: ta, width: sheetW, cap: sheetH, room, grip, onResize, onLayout });
56
- const [task, setTask] = useState(false);
57
57
  const [refusal, setRefusal] = useState('');
58
58
  const [dropping, setDropping] = useState(false);
59
59
  useEffect(() => {
@@ -77,7 +77,7 @@ export function Sheet({ className, origin, title, ctx, pick, draft, onDraft, onS
77
77
  ta.current?.focus();
78
78
  return;
79
79
  }
80
- onSend(draft.trim(), task);
80
+ onSend(draft.trim());
81
81
  };
82
82
  // Normalize in order (the strip keeps the order they came in); the cap is
83
83
  // re-checked as each lands, so two quick adds never pass it. The work can
@@ -164,7 +164,7 @@ export function Sheet({ className, origin, title, ctx, pick, draft, onDraft, onS
164
164
  send();
165
165
  }
166
166
  };
167
- return (_jsxs("div", { ref: pop, className: `pop compose ${className}${dropping ? ' dropping' : ''}`, style: { transformOrigin: origin, ...size.style }, role: "dialog", "aria-labelledby": "vt-pop-title", onKeyDown: onKey, ...(onImages ? { onDragEnter: onDragOver, onDragOver, onDragLeave, onDrop } : {}), children: [_jsxs("div", { className: "pop-head", children: [_jsxs("span", { className: "title", children: [_jsx("i", {}), _jsx("span", { id: "vt-pop-title", children: title })] }), _jsx("button", { type: "button", className: "closeb", "aria-label": "Close", onClick: onClose, children: _jsx(CloseIcon, {}) })] }), _jsx("textarea", { ref: ta, placeholder: placeholder, "aria-required": required || undefined, value: draft, onChange: (e) => onDraft(e.target.value), onKeyDown: onTaKey, ...(onImages ? { onPaste } : {}) }), images && (images.length > 0 || busy > 0) ? (_jsxs("ul", { className: "atts", "aria-label": "Attached images", children: [images.map((image) => (_jsx(Thumb, { image: image, onRemove: () => remove(image) }, keyOf(image)))), Array.from({ length: busy }, (_, i) => (_jsx("li", { className: "att busy", "aria-label": "Preparing image", children: _jsx(SpinnerIcon, {}) }, `busy${i}`)))] })) : null, _jsxs("div", { className: pick || onMark ? 'row' : 'row nodest', children: [onMark ? (_jsx("span", { className: "dest", children: _jsx("button", { type: "button", "aria-pressed": marked, onClick: onMark, children: "Mark on screen" }) })) : pick ? (_jsxs("span", { className: "dest", role: "group", "aria-label": "Where this snap lands", children: [_jsx("button", { type: "button", "aria-pressed": !task, onClick: () => setTask(false), children: "board" }), _jsx("button", { type: "button", "aria-pressed": task, onClick: () => setTask(true), children: "task" })] })) : null, refusal ? (_jsx("span", { className: "ctx bad", title: refusal, children: refusal })) : (_jsx("span", { className: "ctx", children: ctx })), onImages ? (_jsxs("span", { className: "acts", children: [_jsx("button", { type: "button", className: "clipb", "aria-label": "Attach image", "aria-disabled": full || undefined, onClick: browse, children: _jsx(PaperclipIcon, {}) }), _jsx("input", { ref: file, type: "file", accept: "image/*", multiple: true, hidden: true, onChange: (e) => {
167
+ return (_jsxs("div", { ref: pop, className: `pop compose ${className}${dropping ? ' dropping' : ''}`, style: { transformOrigin: origin, ...size.style }, role: "dialog", "aria-labelledby": "vt-pop-title", onKeyDown: onKey, ...(onImages ? { onDragEnter: onDragOver, onDragOver, onDragLeave, onDrop } : {}), children: [_jsxs("div", { className: "pop-head", children: [_jsxs("span", { className: "title", children: [_jsx("i", {}), _jsx("span", { id: "vt-pop-title", children: title })] }), _jsx("button", { type: "button", className: "closeb", "aria-label": "Close", onClick: onClose, children: _jsx(CloseIcon, {}) })] }), head, _jsx("textarea", { ref: ta, placeholder: placeholder, "aria-required": required || undefined, value: draft, onChange: (e) => onDraft(e.target.value), onKeyDown: onTaKey, ...(onImages ? { onPaste } : {}) }), below, images && (images.length > 0 || busy > 0) ? (_jsxs("ul", { className: "atts", "aria-label": "Attached images", children: [images.map((image) => (_jsx(Thumb, { image: image, onRemove: () => remove(image) }, keyOf(image)))), Array.from({ length: busy }, (_, i) => (_jsx("li", { className: "att busy", "aria-label": "Preparing image", children: _jsx(SpinnerIcon, {}) }, `busy${i}`)))] })) : null, _jsxs("div", { className: onMark ? 'row' : 'row nodest', children: [onMark ? (_jsx("span", { className: "dest", children: _jsx("button", { type: "button", "aria-pressed": marked, onClick: onMark, children: "Mark on screen" }) })) : null, refusal ? (_jsx("span", { className: "ctx bad", title: refusal, children: refusal })) : (_jsx("span", { className: "ctx", children: ctx })), onImages ? (_jsxs("span", { className: "acts", children: [_jsx("button", { type: "button", className: "clipb", "aria-label": "Attach image", "aria-disabled": full || undefined, onClick: browse, children: _jsx(PaperclipIcon, {}) }), _jsx("input", { ref: file, type: "file", accept: "image/*", multiple: true, hidden: true, onChange: (e) => {
168
168
  attach(Array.from(e.currentTarget.files ?? []));
169
169
  // The same file picked again is a change too.
170
170
  e.currentTarget.value = '';