deictic 0.6.0 → 0.7.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 (90) hide show
  1. package/API.md +136 -30
  2. package/README.md +4 -3
  3. package/dist/annotations/client.d.ts +1 -1
  4. package/dist/annotations/client.d.ts.map +1 -1
  5. package/dist/annotations/client.js +161 -176
  6. package/dist/annotations/client.js.map +1 -1
  7. package/dist/annotations/index.d.ts +2 -11
  8. package/dist/client/index.d.ts +7 -6
  9. package/dist/client/index.d.ts.map +1 -1
  10. package/dist/client/index.js +1007 -192
  11. package/dist/client/index.js.map +1 -1
  12. package/dist/index.d.ts +2 -2
  13. package/dist/recommended/index.d.ts +2 -2
  14. package/dist/recordings/client.d.ts.map +1 -1
  15. package/dist/recordings/client.js +82 -153
  16. package/dist/recordings/client.js.map +1 -1
  17. package/dist/screenshots/client.d.ts.map +1 -1
  18. package/dist/shared/annotations.js +3 -4
  19. package/dist/shared/annotations.js.map +1 -1
  20. package/dist/shared/board.js +1 -1
  21. package/dist/shared/client.js +45 -2
  22. package/dist/shared/client.js.map +1 -1
  23. package/dist/shared/component.js +62 -0
  24. package/dist/shared/component.js.map +1 -0
  25. package/dist/shared/dom.js +79 -0
  26. package/dist/shared/dom.js.map +1 -0
  27. package/dist/shared/drawer.js +217 -0
  28. package/dist/shared/drawer.js.map +1 -0
  29. package/dist/shared/index.d.ts +116 -7
  30. package/dist/shared/index.d.ts.map +1 -1
  31. package/dist/shared/index2.d.ts +9 -19
  32. package/dist/shared/index2.d.ts.map +1 -1
  33. package/dist/shared/index7.d.ts +103 -26
  34. package/dist/shared/index7.d.ts.map +1 -1
  35. package/dist/shared/index9.d.ts +1 -1
  36. package/dist/shared/integration.d.ts +1 -1
  37. package/dist/shared/packages.js +1 -1
  38. package/dist/shared/recording.js +31 -3
  39. package/dist/shared/recording.js.map +1 -1
  40. package/dist/shared/src.js.map +1 -1
  41. package/dist/shared/task.js +44 -29
  42. package/dist/shared/task.js.map +1 -1
  43. package/dist/shared/tasks.js +232 -62
  44. package/dist/shared/tasks.js.map +1 -1
  45. package/dist/shared/vb.js +1 -1
  46. package/dist/shared/voice2.js +6 -4
  47. package/dist/shared/voice2.js.map +1 -1
  48. package/dist/shared/watch.js +14 -14
  49. package/dist/shared/watch.js.map +1 -1
  50. package/dist/tasks/client.d.ts +2 -2
  51. package/dist/tasks/client.d.ts.map +1 -1
  52. package/dist/tasks/client.js +1829 -741
  53. package/dist/tasks/client.js.map +1 -1
  54. package/dist/tasks/index.d.ts +2 -2
  55. package/dist/voice/client.d.ts.map +1 -1
  56. package/dist/voice/client.js +154 -57
  57. package/dist/voice/client.js.map +1 -1
  58. package/package.json +1 -1
  59. package/skills/deictic/SKILL.md +22 -28
  60. package/src/cli/recording.ts +34 -3
  61. package/src/cli/task.ts +59 -30
  62. package/src/cli/voice.ts +9 -4
  63. package/src/cli/watch.ts +14 -13
  64. package/src/client/away.ts +3 -1
  65. package/src/client/component.ts +98 -0
  66. package/src/client/dom.ts +70 -0
  67. package/src/client/drawer.ts +258 -0
  68. package/src/client/index.ts +220 -128
  69. package/src/client/lightbox.ts +8 -8
  70. package/src/client/lighting.ts +279 -0
  71. package/src/client/style.ts +263 -44
  72. package/src/client/tools.ts +279 -0
  73. package/src/client/tooltip.ts +25 -5
  74. package/src/client/tray.ts +48 -0
  75. package/src/index.ts +113 -6
  76. package/src/plugins/annotations/client.ts +103 -129
  77. package/src/plugins/annotations/draw.ts +68 -72
  78. package/src/plugins/annotations/index.ts +12 -19
  79. package/src/plugins/recordings/client.ts +89 -167
  80. package/src/plugins/screenshots/client.ts +53 -2
  81. package/src/plugins/tasks/client.ts +219 -748
  82. package/src/plugins/tasks/composer.ts +797 -0
  83. package/src/plugins/tasks/drawer.ts +516 -0
  84. package/src/plugins/tasks/index.ts +360 -82
  85. package/src/plugins/tasks/pins.ts +275 -0
  86. package/src/plugins/tasks/store.ts +132 -0
  87. package/src/plugins/voice/client.ts +96 -5
  88. package/skills/deictic/references/recordings.md +0 -13
  89. package/skills/deictic/references/tasks.md +0 -22
  90. package/skills/deictic/references/watch.md +0 -17
@@ -0,0 +1,275 @@
1
+ /**
2
+ * The page's tasks, each pinned where its element is: what's shown of them on the page itself, beside the Task
3
+ * tab's list of one element's. A pin is the element's outline, faint, and a badge on its corner with how many
4
+ * tasks are still to do there, in the colour of the furthest along, and a dot where one has something unread. They
5
+ * show while a shortcut's keys are held and while the Task tab is open: a pin under the pointer reads its tasks, and
6
+ * a click opens them in the drawer.
7
+ *
8
+ * In a layer of the overlay's root, which the tab's own styles don't reach once it's closed: so its styles are its own.
9
+ */
10
+ import { named, tell } from '#src/client/component.ts';
11
+ import { div, place, reduced } from '#src/client/dom.ts';
12
+ import type { ClientContext, Point } from '#src/index.ts';
13
+
14
+ import { drawerOf } from './drawer.ts';
15
+ import type { Placed } from './index.ts';
16
+ import { OVER, storeOf } from './store.ts';
17
+
18
+ const STYLE = `
19
+ /* No box of its own, which its pins would stack in: each is under the popup, and the one pointed at over it, with its card. */
20
+ .pins { display: contents; font: 12px/1.4 system-ui, sans-serif; color: var(--deictic-fg); }
21
+ .pin { --pin: var(--deictic-accent); position: fixed; z-index: 2147483646; box-sizing: border-box; pointer-events: none; border: 1px solid color-mix(in srgb, var(--pin) 45%, transparent); border-radius: 6px; transition: border-color 0.15s, box-shadow 0.15s; }
22
+ .pin.claimed { --pin: #60a5fa; }
23
+ .pin.blocked { --pin: #fbbf24; }
24
+ .pin[hidden] { display: none; }
25
+ .pin.spot, .pin.spot:has(.pin-badge:hover, .pin-badge:focus-visible) { border: 0; box-shadow: none; }
26
+ .pin:has(.pin-badge:hover, .pin-badge:focus-visible) { z-index: 2147483647; border-color: var(--pin); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pin) 18%, transparent), 0 0 28px color-mix(in srgb, var(--pin) 45%, transparent); }
27
+ /* A drop, its point on the element's corner. */
28
+ .pin-badge {
29
+ position: absolute;
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: center;
33
+ box-sizing: border-box;
34
+ min-width: 22px;
35
+ height: 22px;
36
+ padding: 0 6px;
37
+ border: 0;
38
+ border-radius: 11px 11px 11px 3px;
39
+ font: 700 12px/22px system-ui, sans-serif;
40
+ font-variant-numeric: tabular-nums;
41
+ color: #09090b;
42
+ background: var(--pin);
43
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--pin) 22%, transparent), 0 0 18px color-mix(in srgb, var(--pin) 60%, transparent), 0 4px 12px rgb(0 0 0 / 0.4);
44
+ pointer-events: auto;
45
+ cursor: pointer;
46
+ }
47
+ .pin-badge:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
48
+ /* Something unread there: a dot on the badge's corner. */
49
+ .pin.unread .pin-badge::after { content: ''; position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border: 2px solid #09090b; border-radius: 50%; background: #fff; }
50
+ .pin-card {
51
+ position: absolute;
52
+ left: 0;
53
+ top: calc(100% + 8px);
54
+ display: none;
55
+ flex-direction: column;
56
+ gap: 4px;
57
+ width: max-content;
58
+ max-width: 300px;
59
+ padding: 8px 10px;
60
+ border: 1px solid rgb(255 255 255 / 0.12);
61
+ border-radius: 10px;
62
+ font: 12px/1.4 system-ui, sans-serif;
63
+ text-align: left;
64
+ color: var(--deictic-fg);
65
+ background: rgb(24 24 27 / 0.9);
66
+ backdrop-filter: blur(16px) saturate(1.6);
67
+ box-shadow: 0 12px 32px rgb(0 0 0 / 0.45);
68
+ cursor: pointer;
69
+ }
70
+ .pin.left .pin-card { left: auto; right: 0; }
71
+ .pin.up .pin-card { top: auto; bottom: calc(100% + 8px); }
72
+ .pin-badge:hover .pin-card, .pin-badge:focus-visible .pin-card { display: flex; }
73
+ .pin-where { font: 11px ui-monospace, monospace; color: var(--deictic-muted); }
74
+ .pin-where b { color: var(--pin); }
75
+ .pin-task { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
76
+ .pin-task span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
77
+ .pin-task i { flex: none; align-self: center; box-sizing: border-box; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--deictic-muted); }
78
+ .pin-task i.claimed { border-color: #60a5fa; background: #60a5fa; }
79
+ .pin-task i.blocked { border-color: #fbbf24; background: #fbbf24; }
80
+ .pin-task i.waiting { border-style: dotted; }
81
+ .pin-task em { flex: none; font-style: normal; color: var(--deictic-muted); }
82
+ .pin-more { color: var(--deictic-muted); }
83
+ @media (prefers-reduced-motion: no-preference) {
84
+ .pin { animation: deictic-pin-area 0.3s ease-out backwards; }
85
+ .pin-badge { animation: deictic-pin 0.34s cubic-bezier(0.2, 0.9, 0.25, 1.4) backwards; animation-delay: inherit; transform-origin: 0 100%; }
86
+ }
87
+ @keyframes deictic-pin-area {
88
+ from { opacity: 0; }
89
+ }
90
+ @keyframes deictic-pin {
91
+ from { opacity: 0; scale: 0.2; }
92
+ }
93
+ `;
94
+
95
+ /** How long the pins outlast what showed them, in ms: the popup opens a moment after the pointing that led to it ends. */
96
+ const LINGER = 200;
97
+ /** A badge's size, and how far out of the element's corner it sits, in pixels. */
98
+ const BADGE = 22;
99
+ const OUT = 10;
100
+ const EDGE = 4;
101
+ /** The tasks a pin's card names, before it only counts them. */
102
+ const NAMED = 4;
103
+ /** The states by how far along, the furthest first: a pin is the colour of its furthest. */
104
+ const ALONG = ['blocked', 'claimed', 'ready', 'waiting'];
105
+
106
+ export interface Pins {
107
+ /** Shows them: every place's, to read under the pointer and open with a click. Answers what takes them away. */
108
+ glance: () => () => void;
109
+ }
110
+
111
+ interface Pin {
112
+ place: string;
113
+ /** The spot in the element it's on, for a task about one: the pin is there, and has no outline. */
114
+ at?: Point;
115
+ el: Element;
116
+ box: HTMLElement;
117
+ badge: HTMLButtonElement;
118
+ count: HTMLElement;
119
+ card: HTMLElement;
120
+ /** The tasks its badge counts, as last drawn: what a click opens. */
121
+ tasks: Placed[];
122
+ }
123
+
124
+ const made = new WeakMap<ShadowRoot, Pins>();
125
+
126
+ /** The pins of the overlay `context` is of: one set, whoever shows it. */
127
+ export function pinsIn(context: ClientContext): Pins {
128
+ const kept = made.get(context.root);
129
+ if (kept !== undefined) return kept;
130
+
131
+ const store = storeOf(context);
132
+ let glances = 0;
133
+ let layer: HTMLElement | undefined;
134
+ let frame = 0;
135
+ let leaving: ReturnType<typeof setTimeout> | undefined;
136
+ const pins = new Map<string, Pin>();
137
+ let frames = 0;
138
+
139
+ const elementAt = (at: string) => document.querySelector(`[data-deictic="${CSS.escape(at)}"]`);
140
+
141
+ const pinOf = (at: string, el: Element, spot: Point | undefined): Pin => {
142
+ const box = div('pin');
143
+ const badge = Object.assign(document.createElement('button'), { type: 'button', className: 'pin-badge' });
144
+ const count = document.createElement('span');
145
+ const card = Object.assign(document.createElement('span'), { className: 'pin-card' });
146
+ badge.append(count, card);
147
+ box.append(badge);
148
+ // One after another, as they come: where motion is reduced there's no animation to delay.
149
+ if (!reduced()) box.style.animationDelay = `${Math.min(pins.size, 12) * 30}ms`;
150
+ const pin: Pin = { place: at, ...(spot === undefined ? {} : { at: spot }), el, box, badge, count, card, tasks: [] };
151
+ // In the drawer, where a task is read and changed: the popup is for a new one.
152
+ badge.addEventListener('click', () => drawerOf(context).open(pin.tasks));
153
+ return pin;
154
+ };
155
+
156
+ /** A pin as its tasks are now: how many, the colour of the furthest along, and its card. */
157
+ const fill = (pin: Pin, list: Placed[]) => {
158
+ const state = ALONG.find((s) => list.some((t) => t.state === s)) ?? 'ready';
159
+ pin.tasks = list;
160
+ pin.box.className = `pin ${state}${pin.at === undefined ? '' : ' spot'}${list.some(store.unread) ? ' unread' : ''}`;
161
+ pin.count.textContent = String(list.length);
162
+ const [, file = '', line = ''] = /^(.*):(\d+):\d+$/.exec(pin.place) ?? [];
163
+ const tag = tell(named(pin.el));
164
+ pin.badge.setAttribute('aria-label', `${list.length} ${list.length === 1 ? 'task' : 'tasks'} on ${tag}, line ${line}: open`);
165
+ const where = Object.assign(document.createElement('span'), { className: 'pin-where' });
166
+ where.append(Object.assign(document.createElement('b'), { textContent: tag }), ` ${file.split('/').at(-1)}:${line}`);
167
+ const rows = list.slice(0, NAMED).map((t) => {
168
+ const row = Object.assign(document.createElement('span'), { className: 'pin-task' });
169
+ const dot = Object.assign(document.createElement('i'), { className: t.state });
170
+ const by = t.by === undefined ? [] : [Object.assign(document.createElement('em'), { textContent: t.by })];
171
+ row.append(dot, Object.assign(document.createElement('span'), { textContent: t.title }), ...by);
172
+ return row;
173
+ });
174
+ const rest = list.length - rows.length;
175
+ const more = rest === 0 ? [] : [Object.assign(document.createElement('span'), { className: 'pin-more', textContent: `+${rest} more` })];
176
+ pin.card.replaceChildren(where, ...rows, ...more);
177
+ };
178
+
179
+ /** The pins as the tasks read last have them: one per place with an element on the page, for those still to do. */
180
+ const draw = () => {
181
+ if (layer === undefined) return;
182
+ const tasks = store.tasks().filter((t): t is Placed => t.place !== undefined && !OVER.has(t.state));
183
+ // One for an element's tasks, and one of its own for each spot a task is about.
184
+ const keyOf = (t: Placed) => (t.point === undefined ? t.place : `${t.place}@${t.point.x},${t.point.y}`);
185
+ const byPlace = new Map<string, Placed[]>();
186
+ for (const t of tasks) byPlace.set(keyOf(t), [...(byPlace.get(keyOf(t)) ?? []), t]);
187
+ for (const [at, pin] of pins) {
188
+ if (byPlace.has(at)) continue;
189
+ pin.box.remove();
190
+ pins.delete(at);
191
+ }
192
+ for (const [at, list] of byPlace) {
193
+ let pin = pins.get(at);
194
+ if (pin === undefined) {
195
+ const [{ place: where, point }] = list as [Placed, ...Placed[]];
196
+ const el = elementAt(where);
197
+ if (el === null) continue;
198
+ pin = pinOf(where, el, point);
199
+ pins.set(at, pin);
200
+ layer.append(pin.box);
201
+ }
202
+ fill(pin, list);
203
+ }
204
+ follow();
205
+ };
206
+
207
+ /** Each pin over its element as the page has it now: read each frame, as nothing tells of an element moving. */
208
+ const follow = () => {
209
+ const width = document.documentElement.clientWidth;
210
+ const height = document.documentElement.clientHeight;
211
+ // An element rendered again is another: looked for now and then, not every frame.
212
+ const look = frames++ % 20 === 0;
213
+ for (const pin of pins.values()) {
214
+ if (!pin.el.isConnected && look) pin.el = elementAt(pin.place) ?? pin.el;
215
+ const whole = pin.el.getBoundingClientRect();
216
+ // A spot's is a box of no size at the spot: nothing to outline, and the badge's point is on it.
217
+ const r = pin.at === undefined ? whole : new DOMRect(whole.left + pin.at.x, whole.top + pin.at.y, 0, 0);
218
+ const seen =
219
+ pin.el.isConnected && whole.width > 0 && whole.height > 0 && r.bottom > 0 && r.top < height && r.right > 0 && r.left < width;
220
+ pin.box.hidden = !seen;
221
+ if (!seen) continue;
222
+ place(pin.box, r);
223
+ // On the top right corner, or the badge's point on the spot, and in the window where that isn't.
224
+ const out = pin.at === undefined ? OUT : 0;
225
+ const x = Math.max(EDGE, Math.min(r.right - out, width - EDGE - pin.badge.offsetWidth));
226
+ const y = Math.max(EDGE, Math.min(r.top - BADGE + out, height - EDGE - BADGE));
227
+ // From the box's padding edge, which is inside its border, where it has one.
228
+ const edge = pin.at === undefined ? 1 : 0;
229
+ Object.assign(pin.badge.style, { left: `${x - r.left - edge}px`, top: `${y - r.top - edge}px` });
230
+ // Its card opens toward the middle of the window.
231
+ pin.box.classList.toggle('left', x > width / 2);
232
+ pin.box.classList.toggle('up', y > height / 2);
233
+ }
234
+ };
235
+
236
+ store.subscribe(draw);
237
+
238
+ const sync = () => {
239
+ clearTimeout(leaving);
240
+ if (glances === 0) {
241
+ leaving = setTimeout(() => {
242
+ cancelAnimationFrame(frame);
243
+ layer?.remove();
244
+ layer = undefined;
245
+ pins.clear();
246
+ }, LINGER);
247
+ return;
248
+ }
249
+ if (layer === undefined) {
250
+ layer = div('pins');
251
+ layer.append(Object.assign(document.createElement('style'), { textContent: STYLE }));
252
+ frame = requestAnimationFrame(function each() {
253
+ frame = requestAnimationFrame(each);
254
+ follow();
255
+ });
256
+ }
257
+ // After a popup that opened since: at the same height, the later is the upper, and a pin's card is over it.
258
+ context.root.append(layer);
259
+ draw();
260
+ store.load();
261
+ };
262
+
263
+ const shown: Pins = {
264
+ glance: () => {
265
+ glances++;
266
+ sync();
267
+ return () => {
268
+ glances--;
269
+ sync();
270
+ };
271
+ },
272
+ };
273
+ made.set(context.root, shown);
274
+ return shown;
275
+ }
@@ -0,0 +1,132 @@
1
+ /**
2
+ * The channel's tasks as the page has them: read once for the pins and the drawer both, and again when one of
3
+ * them changes a task. And which of them have something unread: a reply since the task was last opened here, or an
4
+ * end no one has looked at. What's been read is the browser's to keep, as a board keeps it for no one.
5
+ */
6
+ import type { ClientContext } from '#src/index.ts';
7
+
8
+ import type { Listed } from './index.ts';
9
+
10
+ /** How long the tasks read last are shown as they are, in ms: the keys are held again and again, and each is no reason to ask the board. */
11
+ const FRESH = 4000;
12
+ /** Where what's been read is kept: each task's ID, and how its thread stood when it was last opened. */
13
+ const SEEN = 'deictic:tasks:seen';
14
+ /** Where the finished tasks put away are kept: each one's ID, and how its thread stood then. */
15
+ const ARCHIVED = 'deictic:tasks:archived';
16
+ /** The states of a finished task, as a board names them: nothing more happens to it. */
17
+ export const OVER = new Set(['completed', 'failed']);
18
+ /** The states whose coming is news in itself, whoever said nothing as it came. */
19
+ const NEWS = new Set(['blocked', 'completed', 'failed']);
20
+
21
+ export interface Store {
22
+ /** The tasks as read last: those still to do, oldest first, then the latest finished. */
23
+ tasks: () => Listed[];
24
+ /** The channel, and its page on the board where there's one to link to: nothing before the first read. */
25
+ channel: () => { name: string; link?: string } | undefined;
26
+ /** Reads them again, unless they were a moment ago: `again` whatever, after a change made here. */
27
+ load: (again?: boolean) => void;
28
+ /** Hears each read; answers what stops it. */
29
+ subscribe: (listener: () => void) => () => void;
30
+ /** Whether a task has something no one has read here. */
31
+ unread: (task: Listed) => boolean;
32
+ /** The reply that was its newest when it was last read here, where it had one. */
33
+ read: (task: Listed) => string | undefined;
34
+ /** Says a task is read, as its thread stands. */
35
+ seen: (task: Listed) => void;
36
+ /** Whether a finished task was put away here, and nothing has happened to it since. */
37
+ archived: (task: Listed) => boolean;
38
+ /** Puts finished tasks away, read: out of the drawer until something happens to one. */
39
+ archive: (tasks: Listed[]) => void;
40
+ }
41
+
42
+ /** How a task's thread stands: its newest reply, and its state where that's news. */
43
+ const markOf = (task: Listed) => `${task.last ?? ''}|${NEWS.has(task.state) ? task.state : ''}`;
44
+
45
+ /** What's kept under `key` (what's been read, what's put away), or nothing where this browser has kept none yet. */
46
+ function kept(key = SEEN): Record<string, string> | undefined {
47
+ try {
48
+ const seen: unknown = JSON.parse(localStorage.getItem(key) ?? 'null');
49
+ return typeof seen === 'object' && seen !== null ? (seen as Record<string, string>) : undefined;
50
+ } catch {
51
+ // Storage can be off, or hold something else: nothing's been kept, then.
52
+ return undefined;
53
+ }
54
+ }
55
+
56
+ const made = new WeakMap<ShadowRoot, Store>();
57
+
58
+ /** The tasks of the overlay `context` is of: one store, whoever asks. */
59
+ export function storeOf(context: ClientContext): Store {
60
+ const known = made.get(context.root);
61
+ if (known !== undefined) return known;
62
+
63
+ let tasks: Listed[] = [];
64
+ let channel: { name: string; link?: string } | undefined;
65
+ let read = 0;
66
+ let asked = 0;
67
+ let seen = kept();
68
+ const listeners = new Set<() => void>();
69
+ const tell = () => {
70
+ for (const listener of listeners) listener();
71
+ };
72
+ let away = kept(ARCHIVED) ?? {};
73
+ const keep = (key = SEEN, value: unknown = seen) => {
74
+ try {
75
+ localStorage.setItem(key, JSON.stringify(value));
76
+ } catch {
77
+ // Not kept past the page, then.
78
+ }
79
+ };
80
+
81
+ const store: Store = {
82
+ tasks: () => tasks,
83
+ channel: () => channel,
84
+ load: (again = false) => {
85
+ if (!again && Date.now() - read < FRESH) return;
86
+ const ask = ++asked;
87
+ read = Date.now();
88
+ void context
89
+ .request('page')
90
+ .then(async (res) => {
91
+ if (!res.ok || ask !== asked) return;
92
+ const answer = (await res.json()) as { channel?: string; link?: string; tasks: Listed[] };
93
+ ({ tasks } = answer);
94
+ // The first read in this browser: what the channel has by now is old news, and only what comes after is unread.
95
+ if (seen === undefined) {
96
+ seen = Object.fromEntries(tasks.map((task) => [task.id, markOf(task)]));
97
+ keep();
98
+ }
99
+ if (answer.channel !== undefined) channel = { name: answer.channel, ...(answer.link === undefined ? {} : { link: answer.link }) };
100
+ tell();
101
+ })
102
+ // As they were, then: whatever opens a task says why the board can't be reached.
103
+ .catch(() => {});
104
+ },
105
+ subscribe: (listener) => {
106
+ listeners.add(listener);
107
+ return () => listeners.delete(listener);
108
+ },
109
+ unread: (task) => seen !== undefined && markOf(task) !== '|' && seen[task.id] !== markOf(task),
110
+ read: (task) => seen?.[task.id]?.split('|', 1)[0] || undefined,
111
+ seen: (task) => {
112
+ if (seen?.[task.id] === markOf(task)) return;
113
+ // Another tab may have read others since: theirs are kept too.
114
+ seen = { ...seen, ...kept(), [task.id]: markOf(task) };
115
+ keep();
116
+ tell();
117
+ },
118
+ archived: (task) => OVER.has(task.state) && away[task.id] === markOf(task),
119
+ archive: (finished) => {
120
+ const marks = Object.fromEntries(finished.filter((task) => OVER.has(task.state)).map((task) => [task.id, markOf(task)]));
121
+ // Only what the board still lists: the rest have gone from it, and needn't be kept.
122
+ const listed = new Set(tasks.map((task) => task.id));
123
+ away = Object.fromEntries(Object.entries({ ...away, ...kept(ARCHIVED), ...marks }).filter(([id]) => listed.has(id)));
124
+ keep(ARCHIVED, away);
125
+ seen = { ...seen, ...kept(), ...marks };
126
+ keep();
127
+ tell();
128
+ },
129
+ };
130
+ made.set(context.root, store);
131
+ return store;
132
+ }
@@ -4,10 +4,32 @@
4
4
  * the rest to `more/<id>`. So a take the page leaves in the middle of (a recording that goes on to another
5
5
  * page) is kept up to there. `stop` sends the last of it and lets the mic go, so the browser's recording
6
6
  * light goes out between takes.
7
+ *
8
+ * Its tool in the tool panel is the mic: on, it's a take, with its time and the mic's live waveform, so it's plain
9
+ * it hears; off again, the clip goes in the tray, for the next task. While a recording is going the mic is the
10
+ * recording's own, and this one is away.
7
11
  */
12
+ import { toolButton } from '#src/client/dom.ts';
13
+ import { playMark, trayed } from '#src/client/drawer.ts';
14
+ import { liveWaveform } from '#src/client/waveform.ts';
8
15
  import { defineClientPlugin } from '#src/index.ts';
9
16
 
10
- import type { Clip, Voice } from './index.ts';
17
+ import type { Clip, Take, Voice } from './index.ts';
18
+
19
+ const STYLE = `
20
+ .voice-tool .time { font: 12px ui-monospace, monospace; }
21
+ .voice-tool .wave { width: 44px; height: 18px; }
22
+ .tool-panel.vertical .voice-tool .wave { width: 28px; }
23
+ .voice-tool .mic[aria-pressed='true'], .voice-tool .mic[aria-pressed='true']:hover { background: #ef4444; color: #fff; }
24
+ /* The recordings plugin's own mic is in the panel while one is going (its \`.recorder.going\`): one mic at a time. */
25
+ .tool-panel:has(.recorder.going) :is(.voice-tool, .sep:has(+ .voice-tool)) { display: none; }
26
+ `;
27
+ const MIC = '<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0M12 18v3"/>';
28
+
29
+ const clock = (ms: number) => {
30
+ const s = Math.floor(ms / 1000);
31
+ return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`;
32
+ };
11
33
 
12
34
  /** What the browser can record, best first: Opus in WebM where it can (Chrome, Firefox), else MP4 (Safari). */
13
35
  const TYPES = ['audio/webm;codecs=opus', 'audio/webm', 'audio/ogg;codecs=opus', 'audio/mp4'];
@@ -16,8 +38,8 @@ const EVERY = 1000;
16
38
 
17
39
  export default defineClientPlugin<never, never, Voice>({
18
40
  name: 'voice',
19
- setup: ({ base, request }) => ({
20
- start: async () => {
41
+ setup: ({ base, request, tools, tray, drawer, lightbox }) => {
42
+ const start = async (): Promise<Take> => {
21
43
  if (typeof MediaRecorder === 'undefined' || navigator.mediaDevices?.getUserMedia === undefined)
22
44
  throw new Error("voice: this browser can't record the mic here: it needs a secure page (https or localhost)");
23
45
  const stream = await navigator.mediaDevices.getUserMedia({ audio: true }).catch((e: unknown) => {
@@ -75,6 +97,75 @@ export default defineClientPlugin<never, never, Voice>({
75
97
  return { id: id!, url: url ?? `${base}__deictic/plugins/voice/clip/${id}`, duration, type: typeOf() };
76
98
  },
77
99
  };
78
- },
79
- }),
100
+ };
101
+
102
+ const group = Object.assign(document.createElement('div'), { className: 'tool-group voice-tool' });
103
+ const time = Object.assign(document.createElement('span'), { className: 'time', hidden: true });
104
+ const wave = Object.assign(document.createElement('canvas'), { className: 'wave', hidden: true });
105
+ let take: Take | undefined;
106
+ // What the mic is doing (asking for it, keeping a take): the next press waits for it.
107
+ let busy: Promise<void> = Promise.resolve();
108
+ const problem = (e: unknown) => {
109
+ mic.classList.add('problem');
110
+ mic.title = e instanceof Error ? e.message : String(e);
111
+ };
112
+ const on = async () => {
113
+ const mine = await start();
114
+ take = mine;
115
+ // The panel stays while the mic is on: its button is what turns it off.
116
+ const unkeep = tools.keep();
117
+ const stopWave = liveWaveform(wave, mine.stream, { played: '#ef4444', rest: '#52525b' });
118
+ const tick = () => (time.textContent = clock(Date.now() - mine.started));
119
+ tick();
120
+ const ticking = setInterval(tick, 250);
121
+ time.hidden = wave.hidden = false;
122
+ mic.setAttribute('aria-pressed', 'true');
123
+ mic.title = 'Stop';
124
+ return async () => {
125
+ take = undefined;
126
+ clearInterval(ticking);
127
+ stopWave();
128
+ time.hidden = wave.hidden = true;
129
+ mic.setAttribute('aria-pressed', 'false');
130
+ mic.title = 'Voice';
131
+ unkeep();
132
+ const clip = await mine.stop();
133
+ tray.add('voice', clip.id, clip);
134
+ };
135
+ };
136
+ let off: (() => Promise<void>) | undefined;
137
+ const mic = toolButton(MIC, 'Voice', 'K', () => {
138
+ busy = busy.then(async () => {
139
+ mic.classList.remove('problem');
140
+ try {
141
+ if (off === undefined) {
142
+ off = await on();
143
+ } else {
144
+ const ending = off;
145
+ off = undefined;
146
+ await ending();
147
+ }
148
+ } catch (e) {
149
+ problem(e);
150
+ }
151
+ });
152
+ });
153
+ mic.classList.add('mic');
154
+ mic.setAttribute('aria-pressed', 'false');
155
+ group.append(Object.assign(document.createElement('style'), { textContent: STYLE }), mic, time, wave);
156
+ // Beside the other tools that capture the page: a shot, a recording, the mic.
157
+ tools.add(group, { section: 'capture' });
158
+ // In the drawer until a task takes them: each plays in the lightbox.
159
+ drawer.add(
160
+ trayed({ tray }, 'voice', 'Voice notes', (item, i, all) => {
161
+ const { url, duration } = item.value as Clip;
162
+ const name = `${all.length === 1 ? 'Voice' : `Voice ${i + 1}`} ${clock(duration)}`;
163
+ return { label: [playMark(), name], open: (from) => lightbox([{ kind: 'audio', url, title: name }], { from }) };
164
+ }),
165
+ );
166
+ // A take the page leaves in the middle of is kept as far as it's sent, and the mic let go.
167
+ addEventListener('pagehide', () => take?.cancel());
168
+
169
+ return { start };
170
+ },
80
171
  });
@@ -1,13 +0,0 @@
1
- # Recordings and voice
2
-
3
- Each takes the task's ID; `--help` has the rest.
4
-
5
- - `npx deictic recording 68`: the timeline. Clicks and typing name the element and its source line, marks say what
6
- was drawn, and with the project's `logs` and `network` plugins there's the console and the requests. A recording
7
- may cross pages: each is a `page` line. To find what went wrong: `--problems`, then `--around <seconds>`.
8
- - `npx deictic frame 68 --at <seconds>`: a PNG of the page at that moment, marks drawn. Needs the dev server.
9
- - `npx deictic voice 68`: when they spoke, in the recording's time. What was on screen then is what they mean.
10
- - `npx deictic transcribe 68`: what they said. Its first run says what it downloads: ask the person before
11
- `--setup`, and if they say no, don't ask again this session.
12
-
13
- Never send the audio off the machine unless the person asks.
@@ -1,22 +0,0 @@
1
- # Reading a task
2
-
3
- `npx deictic task 68` prints what was asked, where, the page and viewport, the notes drawn, what's attached with the
4
- command to read each, and whether the line still reads as the task saw it.
5
-
6
- - **`Source:`** (the `deictic.source` label, after its own place) is the chain the element rendered through, from its
7
- own line out:
8
- `src/ui/label.tsx:6 ← ParticipantsField (src/ParticipantsField.tsx:20) ← WorkflowPanel`. When the first is a shared
9
- component (`ui/label.tsx`), the change is usually at the next one. A name alone is a component to find by name.
10
- - **`Pointed at, inside it:`** is markup inside the element that no line marks (a dependency's): what they mean. Its
11
- HTML is in the file named beside it. Find it by its classes.
12
- - **The element is one place**: what they mean may be its parent, a sibling, or every element the line renders. The
13
- words and the marks decide.
14
- - **`element.html`** is the element as it rendered. Read it only when the task and the screenshot don't settle which
15
- of several alike is meant, or you can't open the page.
16
- - **The page** (`deictic.url`) is theirs: their host, account and data. Reach the same screen in the app as the
17
- project says to run it, by its path. Never ask for or use their session. Say in the result what you couldn't see.
18
- - **Still unsure**: `vb reply 68 "<what you understood, and the question>"`, then `vb tasks block 68 "<why>"` while
19
- they answer.
20
-
21
- Other endings: `vb tasks release 68` (someone else can take it), `vb tasks fail 68 "<why, and what would make it
22
- possible>"`.
@@ -1,17 +0,0 @@
1
- # Watching
2
-
3
- `npx deictic watch` prints a line per thing to act on: `ready: #68 …` for each task waiting as it starts, `new task`,
4
- `reply on`, `task … canceled`. Each says what to do. Use what your harness has for being woken by a command:
5
-
6
- - **A monitor** (each output line an event, like Claude Code's Monitor): run it as the monitor with the longest
7
- timeout allowed, and work each event while it keeps running. Start it again when the monitor times out.
8
- - **A background command that wakes you when it exits**: `npx deictic watch --once` ends at the first event. Work
9
- it, then start it again.
10
- - **Neither**: run `npx deictic watch --once` in the foreground after each task, and tell the person it holds the
11
- session.
12
-
13
- It ends by itself after 20 quiet minutes (`--idle` for another), saying `idle`: then stop watching and tell the
14
- person, unless you're mid-task. Never sleep-poll, and don't detach it (`nohup`, `&`): it ends with the process
15
- that started it.
16
-
17
- A claim is a 15-minute lease unless `--lease` (1h at most): `vb tasks renew 68` for longer work.