@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.
- package/CHANGELOG.md +73 -3
- package/README.md +70 -18
- package/build/hud.iife.js +150 -28
- package/build/protocol/index.d.ts +10 -0
- package/build/recorder/capture/click.js +2 -2
- package/build/recorder/capture/nav.js +1 -1
- package/build/recorder/capture/redact.d.ts +10 -2
- package/build/recorder/capture/redact.js +53 -3
- package/build/recorder/config.d.ts +10 -0
- package/build/recorder/config.js +1 -0
- package/build/recorder/flight.d.ts +5 -0
- package/build/recorder/flight.js +5 -2
- package/build/recorder/hud/Hud.js +206 -31
- package/build/recorder/hud/NotesSheet.d.ts +24 -0
- package/build/recorder/hud/NotesSheet.js +147 -0
- package/build/recorder/hud/RecorderPill.d.ts +34 -12
- package/build/recorder/hud/RecorderPill.js +52 -14
- package/build/recorder/hud/Sheet.d.ts +18 -15
- package/build/recorder/hud/Sheet.js +13 -13
- package/build/recorder/hud/controller.d.ts +81 -4
- package/build/recorder/hud/drop.d.ts +26 -0
- package/build/recorder/hud/drop.js +35 -0
- package/build/recorder/hud/icons.d.ts +6 -0
- package/build/recorder/hud/icons.js +12 -0
- package/build/recorder/hud/notes-rows.d.ts +39 -0
- package/build/recorder/hud/notes-rows.js +49 -0
- package/build/recorder/hud/resize.d.ts +6 -3
- package/build/recorder/hud/resize.js +8 -4
- package/build/recorder/hud/styles.d.ts +1 -19
- package/build/recorder/hud/styles.js +62 -19
- package/build/recorder/index.d.ts +8 -0
- package/build/recorder/index.js +1 -0
- package/build/recorder/page-controller.js +13 -7
- package/build/recorder/queue.d.ts +22 -1
- package/build/recorder/queue.js +84 -5
- package/build/recorder/recents.d.ts +20 -4
- package/build/recorder/recents.js +41 -6
- package/build/recorder/report.js +3 -11
- package/build/recorder/session.d.ts +25 -6
- package/build/recorder/session.js +53 -11
- package/build/recorder/version.d.ts +2 -2
- package/build/recorder/version.js +1 -1
- package/package.json +1 -1
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* size tokens (`--h`, `--b`, `--fs`, … and `--s` for the rest).
|
|
17
17
|
* Motion: the transitions.dev token scale; reduced motion stills it all.
|
|
18
18
|
*/
|
|
19
|
+
import { DROP_CSS } from './drop';
|
|
20
|
+
import { NOTES_CSS } from './NotesSheet';
|
|
19
21
|
export const HUD_CSS_BASE = `
|
|
20
22
|
* { box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
|
|
21
23
|
svg { width:1em; height:1em; vertical-align:-.125em; flex:none; }
|
|
@@ -112,8 +114,11 @@ textarea, .code { user-select:text; -webkit-user-select:text; }
|
|
|
112
114
|
.dock[data-col="r"] .puck { flex-direction:row-reverse; }
|
|
113
115
|
.ring { width:10px; height:10px; flex:none; border-radius:50%; box-shadow:inset 0 0 0 1.5px var(--fg-2);
|
|
114
116
|
transition: background-color var(--duration-quick) var(--ease-out), box-shadow var(--duration-quick) var(--ease-out); }
|
|
115
|
-
|
|
116
|
-
.puck[data-state="
|
|
117
|
+
/* ready = a red record dot (HUD polish D3): the puck reads as the action that starts a recording */
|
|
118
|
+
.puck[data-state="ready"] .ring { background:var(--rec); box-shadow:none; }
|
|
119
|
+
.puck[data-state="busy"] .ring { background:var(--rec); box-shadow:none; animation:breathe 1.2s var(--ease-in-out) infinite; }
|
|
120
|
+
/* the idle ⋯ keeps the tray's inset from the pill's round end */
|
|
121
|
+
.s-more > .seg-in { padding-left:3px; padding-right:3px; }
|
|
117
122
|
@keyframes breathe { 50% { opacity:.35; } }
|
|
118
123
|
.lab { display:grid; grid-template-columns:0fr; opacity:0;
|
|
119
124
|
transition: grid-template-columns var(--duration-resize) var(--ease-smooth-out), opacity var(--duration-quick) var(--ease-out); }
|
|
@@ -127,7 +132,7 @@ textarea, .code { user-select:text; -webkit-user-select:text; }
|
|
|
127
132
|
.pill[data-open] .lab, .puck:focus-visible .lab { grid-template-columns:1fr; opacity:1; }
|
|
128
133
|
.puck:focus-visible, .handle:focus-visible { outline:2px solid var(--rec); outline-offset:2px; }
|
|
129
134
|
@media (hover: hover) {
|
|
130
|
-
.puck[data-state="ready"]:hover .ring {
|
|
135
|
+
.puck[data-state="ready"]:hover .ring { box-shadow:0 0 0 3px var(--rec-soft); }
|
|
131
136
|
.puck[data-state="unlinked"]:hover .ring { box-shadow:inset 0 0 0 1.5px var(--fg); }
|
|
132
137
|
}
|
|
133
138
|
|
|
@@ -158,6 +163,9 @@ button.tb { all:unset; pointer-events:auto; box-sizing:border-box; position:rela
|
|
|
158
163
|
button.tb.b-annotate { color:var(--rec); }
|
|
159
164
|
button.tb.on { background:var(--rec); color:#fff; }
|
|
160
165
|
button.tb.b-stop svg { fill:currentColor; stroke:none; font-size:calc(var(--ic) * .82); }
|
|
166
|
+
/* the notes button's count (D5) */
|
|
167
|
+
button.tb .cnt { position:absolute; top:-2px; right:-3px; min-width:14px; height:14px; padding:0 3px; border-radius:7px; box-sizing:border-box;
|
|
168
|
+
background:var(--ink-3); color:var(--fg); font-size:9px; font-weight:700; line-height:14px; text-align:center; box-shadow:0 0 0 1.5px var(--ink-solid); }
|
|
161
169
|
button.tb:focus-visible { outline:2px solid var(--rec); outline-offset:-2px; }
|
|
162
170
|
@media (hover: hover) {
|
|
163
171
|
button.tb:hover { background:var(--ink-2); color:var(--fg); }
|
|
@@ -165,20 +173,21 @@ button.tb:focus-visible { outline:2px solid var(--rec); outline-offset:-2px; }
|
|
|
165
173
|
button.tb.b-stop:hover { background:var(--rec-soft); color:var(--rec); }
|
|
166
174
|
}
|
|
167
175
|
|
|
168
|
-
/*
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
transition:
|
|
172
|
-
.sync
|
|
173
|
-
.
|
|
174
|
-
.
|
|
175
|
-
.
|
|
176
|
-
.
|
|
177
|
-
.
|
|
178
|
-
.
|
|
179
|
-
.
|
|
180
|
-
.
|
|
181
|
-
|
|
176
|
+
/* sync (HUD polish D4): a ring on the rec dot — green synced, amber sending, warn offline, red ended;
|
|
177
|
+
the counts ride the details float (.stats) while the tray is open */
|
|
178
|
+
.dot[data-sync] { box-shadow:0 0 0 2px var(--ink-solid), 0 0 0 3.5px var(--ok);
|
|
179
|
+
transition: box-shadow var(--duration-quick) var(--ease-out); }
|
|
180
|
+
.dot[data-sync="sending"] { box-shadow:0 0 0 2px var(--ink-solid), 0 0 0 3.5px var(--fg-3); }
|
|
181
|
+
.dot[data-sync="offline"] { box-shadow:0 0 0 2px var(--ink-solid), 0 0 0 3.5px var(--warn); }
|
|
182
|
+
.dot[data-sync="error"] { box-shadow:0 0 0 2px var(--ink-solid), 0 0 0 3.5px var(--rec); }
|
|
183
|
+
.detail.statsf { max-width:none; }
|
|
184
|
+
.stats { display:inline-flex; align-items:center; gap:10px; white-space:nowrap; font-weight:600; color:var(--fg-3); }
|
|
185
|
+
.stats .s-head { display:inline-flex; align-items:center; gap:5px; color:var(--ok); }
|
|
186
|
+
.stats[data-kind="sending"] .s-head { color:var(--fg-2); }
|
|
187
|
+
.stats[data-kind="offline"] .s-head { color:var(--warn); }
|
|
188
|
+
.stats[data-kind="error"] .s-head { color:var(--rec); }
|
|
189
|
+
.stats > i { width:1px; height:12px; background:var(--edge); }
|
|
190
|
+
.stats b { color:var(--fg); font-weight:600; font-variant-numeric:tabular-nums; }
|
|
182
191
|
.spin { animation:spin .9s var(--ease-linear) infinite; transform-origin:50% 50%; }
|
|
183
192
|
@keyframes spin { to { transform:rotate(360deg); } }
|
|
184
193
|
|
|
@@ -211,7 +220,21 @@ button.tb:focus-visible { outline:2px solid var(--rec); outline-offset:-2px; }
|
|
|
211
220
|
.bar-track[data-indeterminate] > i { width:35%; animation:slide 1.1s var(--ease-in-out) infinite; }
|
|
212
221
|
@keyframes slide { from { transform:translateX(-100%); } to { transform:translateX(290%); } }
|
|
213
222
|
.saved .ok { display:inline-flex; color:var(--ok); }
|
|
214
|
-
.failed .warn { display:inline-flex; color:var(--warn); }
|
|
223
|
+
.saved .warn, .failed .warn { display:inline-flex; color:var(--warn); }
|
|
224
|
+
/* the board's build (D1): Building board · step · k/n over the save's bar */
|
|
225
|
+
.saved[data-build="building"] { position:relative; }
|
|
226
|
+
.saved[data-build="building"] > svg { color:var(--fg-2); }
|
|
227
|
+
.flow .step { max-width:calc(150px * var(--s)); overflow:hidden; text-overflow:ellipsis; }
|
|
228
|
+
.flow .frac { color:var(--fg-2); font-variant-numeric:tabular-nums; }
|
|
229
|
+
.flash[data-word="queued"] { color:var(--fg-2); }
|
|
230
|
+
/* the first-run hint (D3): once, beside the idle puck */
|
|
231
|
+
.firstrun { width:calc(240px * var(--s)); padding:calc(11px * var(--s)) calc(12px * var(--s)); font-size:calc(var(--fs) - .5px); line-height:1.4; color:var(--fg-2); }
|
|
232
|
+
.firstrun b { display:block; margin-bottom:3px; color:var(--fg); font-size:var(--fs); }
|
|
233
|
+
.firstrun p { margin:0; }
|
|
234
|
+
.firstrun .row2 { display:flex; gap:6px; margin-top:9px; }
|
|
235
|
+
/* a recording in another tab (D11): the dot and where it is, nothing to press */
|
|
236
|
+
.flow.remote { padding-right:calc(var(--h) * .42); }
|
|
237
|
+
.flow.remote .dot { margin-right:2px; }
|
|
215
238
|
.failed .msg { max-width:calc(220px * var(--s)); overflow:hidden; text-overflow:ellipsis; }
|
|
216
239
|
|
|
217
240
|
/* the success check (transitions.dev 10, tuned to a 13px glyph) */
|
|
@@ -395,6 +418,26 @@ textarea:focus { outline:none; box-shadow:inset 0 0 0 1px var(--fg-3); }
|
|
|
395
418
|
.row.nodest { grid-template-columns:minmax(0,1fr) auto; }
|
|
396
419
|
.ctx { font-size:var(--fs-s); line-height:1.35; color:var(--fg-3); text-align:center; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
|
397
420
|
.row.nodest .ctx { text-align:left; }
|
|
421
|
+
/* what an annotation points at (D9/D15): its crop where the host has pixels, else a size · route chip; Reselect either way */
|
|
422
|
+
.selhead { display:flex; align-items:center; gap:10px; margin-top:10px; padding:6px 6px 6px 8px; border-radius:9px; background:rgba(0,0,0,.28);
|
|
423
|
+
box-shadow:inset 0 0 0 1px var(--edge); font-size:var(--fs-s); line-height:1.35; color:var(--fg-3); }
|
|
424
|
+
.selhead.has-crop { padding-left:6px; }
|
|
425
|
+
.selhead > svg { color:var(--rec); font-size:var(--ic); }
|
|
426
|
+
.selcrop { width:calc(92px * var(--s)); height:calc(56px * var(--s)); flex:none; object-fit:cover; border-radius:6px; box-shadow:0 0 0 1.5px var(--rec); }
|
|
427
|
+
.selmeta { display:flex; flex-direction:column; min-width:0; flex:1; }
|
|
428
|
+
.selmeta b { color:var(--fg); font-weight:600; }
|
|
429
|
+
.selmeta span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
|
430
|
+
.selhead .fb { height:calc(24px * var(--s)); flex:none; }
|
|
431
|
+
/* the notes this one references (D7) */
|
|
432
|
+
.refs { display:flex; flex-wrap:wrap; gap:6px; margin:8px 0 0; padding:0; list-style:none; }
|
|
433
|
+
.ref { display:inline-flex; align-items:center; gap:6px; max-width:100%; padding:3px 4px 3px 8px; border-radius:7px; font-size:var(--fs-s);
|
|
434
|
+
color:var(--fg-2); background:rgba(127,214,164,.08); box-shadow:inset 0 0 0 1px rgba(127,214,164,.3); }
|
|
435
|
+
.ref svg { color:var(--ok); }
|
|
436
|
+
.ref b { color:var(--ok); font-weight:600; }
|
|
437
|
+
.ref .t { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
|
438
|
+
.ref button { all:unset; cursor:pointer; display:inline-grid; place-items:center; width:16px; height:16px; border-radius:4px; color:var(--fg-3); font-size:9px; }
|
|
439
|
+
.ref button:focus-visible { outline:2px solid var(--rec); outline-offset:1px; }
|
|
440
|
+
@media (hover: hover) { .ref button:hover { color:var(--fg); background:var(--ink-2); } }
|
|
398
441
|
.dest { display:inline-flex; padding:2px; border-radius:8px; background:rgba(0,0,0,.28); box-shadow:inset 0 0 0 1px var(--edge); }
|
|
399
442
|
.dest button { all:unset; box-sizing:border-box; cursor:pointer; padding:5px 8px; min-height:24px; border-radius:6px; color:var(--fg-3);
|
|
400
443
|
font-size:calc(var(--fs) - .5px); font-weight:600; line-height:14px; transition: background-color var(--duration-quick) var(--ease-out), color var(--duration-quick) var(--ease-out); }
|
|
@@ -486,4 +529,4 @@ export const MOTION_CSS = `
|
|
|
486
529
|
.t-check svg path { stroke-dashoffset:0; }
|
|
487
530
|
}
|
|
488
531
|
`;
|
|
489
|
-
export const HUD_CSS = HUD_CSS_BASE + LINK_CSS + MOTION_CSS;
|
|
532
|
+
export const HUD_CSS = HUD_CSS_BASE + LINK_CSS + DROP_CSS + NOTES_CSS + MOTION_CSS;
|
|
@@ -37,6 +37,14 @@ export interface VitrinkaRecorderRootProps {
|
|
|
37
37
|
* last minute, so "Report a bug" is offered only while recording.
|
|
38
38
|
*/
|
|
39
39
|
flightRecorder?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Rewrites every URL and route the recorder captures (navigation, clicks,
|
|
42
|
+
* notes, network requests, rrweb page URLs, bug reports) before redaction —
|
|
43
|
+
* name the path segments that carry credentials (`/reset-password/:token`).
|
|
44
|
+
* It gets absolute URLs, relative request URLs and bare paths alike. A
|
|
45
|
+
* sanitizer that throws records only the URL's origin.
|
|
46
|
+
*/
|
|
47
|
+
sanitizeUrl?: (url: string) => string;
|
|
40
48
|
/** A router's pathname, when the History wrap is not enough. */
|
|
41
49
|
route?: string | null;
|
|
42
50
|
children?: ReactNode;
|
package/build/recorder/index.js
CHANGED
|
@@ -2,10 +2,10 @@ import { readLink, recorderConfig, vitrinkaLinked } from './config';
|
|
|
2
2
|
import { holdFace, leadStatus, sendToLeader, setRemoteStop } from './lead';
|
|
3
3
|
import { forgetLink, linkDevice } from './link';
|
|
4
4
|
import { cachedAccount, cachedPrefs, fetchMe, savePrefs } from './me';
|
|
5
|
-
import { getState, health } from './queue';
|
|
6
|
-
import { boardUrlOf, readRecents, refreshRecents } from './recents';
|
|
5
|
+
import { ackedCounts, getState, health, pendingNoteCids } from './queue';
|
|
6
|
+
import { boardUrlOf, readRecents, refreshRecents, retryBuild } from './recents';
|
|
7
7
|
import { canAttach, canReport, holdReport, sendReport } from './report';
|
|
8
|
-
import { addAnnotation, addNote, RECORDER_ID, startSession, stopSession, togglePause } from './session';
|
|
8
|
+
import { addAnnotation, addNote, listNotes, RECORDER_ID, startSession, stopSession, togglePause } from './session';
|
|
9
9
|
import { annotateState, leadState, setAnnotating, subscribe } from './state';
|
|
10
10
|
function build() {
|
|
11
11
|
const rec = getState();
|
|
@@ -32,6 +32,8 @@ function build() {
|
|
|
32
32
|
events: h.localSeq,
|
|
33
33
|
serverMaxSeq: h.serverMaxSeq,
|
|
34
34
|
deadReason: h.deadReason,
|
|
35
|
+
acked: ackedCounts(),
|
|
36
|
+
pendingNotes: pendingNoteCids(),
|
|
35
37
|
},
|
|
36
38
|
};
|
|
37
39
|
}
|
|
@@ -49,7 +51,9 @@ function build() {
|
|
|
49
51
|
version: RECORDER_ID,
|
|
50
52
|
canReport: canReport(),
|
|
51
53
|
canAttach: canAttach(),
|
|
52
|
-
...(leadState.following
|
|
54
|
+
...(leadState.following
|
|
55
|
+
? { following: leadState.following, followingElsewhere: leadStatus().claim?.by !== leadState.following }
|
|
56
|
+
: {}),
|
|
53
57
|
};
|
|
54
58
|
}
|
|
55
59
|
export function createPageController() {
|
|
@@ -92,15 +96,17 @@ export function createPageController() {
|
|
|
92
96
|
const url = boardUrlOf(done) ?? boardUrl;
|
|
93
97
|
return { ...(url ? { boardUrl: url } : {}), ...(sessionId ? { sessionId } : {}) };
|
|
94
98
|
},
|
|
95
|
-
note(text, attachments) {
|
|
99
|
+
note(text, attachments, link) {
|
|
96
100
|
if (!leadState.following)
|
|
97
|
-
return addNote(text, attachments);
|
|
101
|
+
return addNote(text, attachments, link);
|
|
98
102
|
// Images never cross to the other recorder; its note carries the text.
|
|
99
103
|
if (attachments?.length)
|
|
100
104
|
console.warn('vitrinka: the note goes to the recorder that leads — without its images');
|
|
101
105
|
sendToLeader('note', text);
|
|
102
106
|
},
|
|
103
|
-
annotate: ({ text, rect, selector,
|
|
107
|
+
annotate: ({ text, rect, selector, attachments, link }) => addAnnotation(text, rect, selector, { ...(attachments ? { attachments } : {}), ...(link ? { link } : {}) }),
|
|
108
|
+
listNotes,
|
|
109
|
+
retryBuild,
|
|
104
110
|
setAnnotating,
|
|
105
111
|
async link() {
|
|
106
112
|
const flow = await linkDevice();
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
import type { RedactionPolicy } from '@vitrinka/redact';
|
|
41
41
|
import type { RecorderEvent } from '../protocol';
|
|
42
42
|
import type { StagedImage } from './attachments';
|
|
43
|
+
import type { HudNote } from './hud/controller';
|
|
43
44
|
export declare const MAX_BATCH_BYTES: number;
|
|
44
45
|
/** The server's per-POST event cap. */
|
|
45
46
|
export declare const EVENTS_PER_POST = 500;
|
|
@@ -106,6 +107,8 @@ export declare const REC_KEY = "rec";
|
|
|
106
107
|
*/
|
|
107
108
|
export declare function getState(): SessionState | null;
|
|
108
109
|
export declare function setState(rec: SessionState | null): void;
|
|
110
|
+
export declare function noteLog(sessionId: string): HudNote[];
|
|
111
|
+
export declare function logNote(sessionId: string, note: HudNote): void;
|
|
109
112
|
/**
|
|
110
113
|
* This tab started (`sessionId`) or finished (null) stopping a session. Only
|
|
111
114
|
* the STORED record changes: this tab's own cache stays live, so the tail
|
|
@@ -135,6 +138,23 @@ export declare function persistNow(): void;
|
|
|
135
138
|
*/
|
|
136
139
|
export declare function pruneBlobJournal(ended?: string): Promise<void>;
|
|
137
140
|
export declare function queuedCount(): number;
|
|
141
|
+
/**
|
|
142
|
+
* What THIS tab delivered and the server acknowledged, by what a tester would
|
|
143
|
+
* call it (the HUD's stats float): clicks are actions, navigations pages,
|
|
144
|
+
* rrweb rows count their DOM frames, notes include annotations.
|
|
145
|
+
*/
|
|
146
|
+
export interface AckedCounts {
|
|
147
|
+
actions: number;
|
|
148
|
+
pages: number;
|
|
149
|
+
frames: number;
|
|
150
|
+
notes: number;
|
|
151
|
+
}
|
|
152
|
+
/** The acknowledged counts; the SAME object until a delivery changes them. */
|
|
153
|
+
export declare function ackedCounts(): AckedCounts;
|
|
154
|
+
/** Whether the server acknowledged the note with this client id. */
|
|
155
|
+
export declare function noteAcked(cid: string): boolean;
|
|
156
|
+
/** Client ids of this tab's notes still on their way: waiting for a seq, or buffered. */
|
|
157
|
+
export declare function pendingNoteCids(): string[];
|
|
138
158
|
/** Fresh-session baseline; called by startSession before capture begins. */
|
|
139
159
|
export declare function resetHealth(baseSeq?: number): void;
|
|
140
160
|
export type RecorderHealthState = 'idle' | 'ok' | 'backlog' | 'offline' | 'dead';
|
|
@@ -176,7 +196,8 @@ export declare function capturesSettled(deadlineMs?: number): Promise<boolean>;
|
|
|
176
196
|
/** Is `id` the session currently in state AND still accepting capture? */
|
|
177
197
|
export declare function isSessionLive(id: string): boolean;
|
|
178
198
|
/**
|
|
179
|
-
* Append an event to the durable buffer (drops while
|
|
199
|
+
* Append an event to the durable buffer (drops while dead, and while paused
|
|
200
|
+
* except a note: the tester wrote it on purpose, so it queues and lands).
|
|
180
201
|
* `tabId`/`tabHost`/`ts`/`seq` are filled here; capture layers pass
|
|
181
202
|
* kind+payload plus the route they observed. With no session the event goes
|
|
182
203
|
* to the flight recorder when the idle pill keeps one (memory only — never
|
package/build/recorder/queue.js
CHANGED
|
@@ -91,11 +91,39 @@ export function getState() {
|
|
|
91
91
|
}
|
|
92
92
|
export function setState(rec) {
|
|
93
93
|
recCache = rec;
|
|
94
|
-
if (rec === null)
|
|
94
|
+
if (rec === null) {
|
|
95
95
|
kv().remove(REC_KEY);
|
|
96
|
+
kv().remove(NOTE_LOG_KEY);
|
|
97
|
+
}
|
|
96
98
|
else
|
|
97
99
|
safeSet(REC_KEY, JSON.stringify(stored(rec)));
|
|
98
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* The live recording's notes as the notes sheet lists them (recorder HUD
|
|
103
|
+
* polish D5): every tab's, in this origin's recorder storage, for as long as
|
|
104
|
+
* the recording lives — a recorder token reads nothing back from the
|
|
105
|
+
* server, and the queue already keeps the same text here until delivery.
|
|
106
|
+
* Gone with the session record (`setState(null)`).
|
|
107
|
+
*/
|
|
108
|
+
const NOTE_LOG_KEY = 'notes';
|
|
109
|
+
const MAX_LOGGED_NOTES = 200;
|
|
110
|
+
export function noteLog(sessionId) {
|
|
111
|
+
const log = readJson(NOTE_LOG_KEY, null);
|
|
112
|
+
return log?.sessionId === sessionId && Array.isArray(log.notes) ? log.notes : [];
|
|
113
|
+
}
|
|
114
|
+
export function logNote(sessionId, note) {
|
|
115
|
+
let notes = [...noteLog(sessionId), note];
|
|
116
|
+
while (notes.length > MAX_LOGGED_NOTES) {
|
|
117
|
+
// Evict the oldest ORIGINAL with its whole edit chain — an edit left
|
|
118
|
+
// without its original would list as a note of its own.
|
|
119
|
+
const root = new Map();
|
|
120
|
+
for (const n of notes)
|
|
121
|
+
root.set(n.cid, (n.replaces && root.get(n.replaces)) || n.cid);
|
|
122
|
+
const oldest = root.get(notes[0].cid);
|
|
123
|
+
notes = notes.filter((n) => root.get(n.cid) !== oldest);
|
|
124
|
+
}
|
|
125
|
+
safeSet(NOTE_LOG_KEY, JSON.stringify({ sessionId, notes }));
|
|
126
|
+
}
|
|
99
127
|
/** The session this tab is stopping, its clock at the Stop, and when its mark was last renewed. */
|
|
100
128
|
let stoppingHere = null;
|
|
101
129
|
let stoppingLease = null;
|
|
@@ -437,12 +465,56 @@ function noteFailure(e) {
|
|
|
437
465
|
failures++;
|
|
438
466
|
lastError = String(e instanceof Error ? e.message : e).slice(0, 200);
|
|
439
467
|
}
|
|
468
|
+
let acked = { actions: 0, pages: 0, frames: 0, notes: 0 };
|
|
469
|
+
/** Client ids (`payload.cid`) of notes the server has acknowledged. */
|
|
470
|
+
const ackedNotes = new Set();
|
|
471
|
+
function countAcked(events) {
|
|
472
|
+
const next = { ...acked };
|
|
473
|
+
for (const ev of events) {
|
|
474
|
+
if (ev.kind === 'click')
|
|
475
|
+
next.actions++;
|
|
476
|
+
else if (ev.kind === 'nav')
|
|
477
|
+
next.pages++;
|
|
478
|
+
else if (ev.kind === 'rrweb')
|
|
479
|
+
next.frames += typeof ev.payload?.count === 'number' ? ev.payload.count : 1;
|
|
480
|
+
else if (ev.kind === 'note') {
|
|
481
|
+
next.notes++;
|
|
482
|
+
if (typeof ev.payload?.cid === 'string')
|
|
483
|
+
ackedNotes.add(ev.payload.cid);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
acked = next;
|
|
487
|
+
}
|
|
488
|
+
/** The acknowledged counts; the SAME object until a delivery changes them. */
|
|
489
|
+
export function ackedCounts() {
|
|
490
|
+
return acked;
|
|
491
|
+
}
|
|
492
|
+
/** Whether the server acknowledged the note with this client id. */
|
|
493
|
+
export function noteAcked(cid) {
|
|
494
|
+
return ackedNotes.has(cid);
|
|
495
|
+
}
|
|
496
|
+
/** Client ids of this tab's notes still on their way: waiting for a seq, or buffered. */
|
|
497
|
+
export function pendingNoteCids() {
|
|
498
|
+
const out = [];
|
|
499
|
+
for (const item of pendingAllocations) {
|
|
500
|
+
const { draft } = item;
|
|
501
|
+
if (draft.kind === 'event' && draft.event.kind === 'note' && typeof draft.event.payload?.cid === 'string')
|
|
502
|
+
out.push(draft.event.payload.cid);
|
|
503
|
+
}
|
|
504
|
+
for (const ev of getBuffer()) {
|
|
505
|
+
if (ev.kind === 'note' && typeof ev.payload?.cid === 'string')
|
|
506
|
+
out.push(ev.payload.cid);
|
|
507
|
+
}
|
|
508
|
+
return out;
|
|
509
|
+
}
|
|
440
510
|
/** Fresh-session baseline; called by startSession before capture begins. */
|
|
441
511
|
export function resetHealth(baseSeq = 0) {
|
|
442
512
|
lastSyncAt = Date.now();
|
|
443
513
|
lastError = '';
|
|
444
514
|
failures = 0;
|
|
445
515
|
serverMaxSeq = baseSeq;
|
|
516
|
+
acked = { actions: 0, pages: 0, frames: 0, notes: 0 };
|
|
517
|
+
ackedNotes.clear();
|
|
446
518
|
}
|
|
447
519
|
export function health() {
|
|
448
520
|
const rec = getState();
|
|
@@ -802,7 +874,8 @@ function allocatePending() {
|
|
|
802
874
|
*/
|
|
803
875
|
function queueCapture(draft, journaled) {
|
|
804
876
|
const accepted = getState();
|
|
805
|
-
|
|
877
|
+
const note = draft.kind === 'event' && draft.event.kind === 'note';
|
|
878
|
+
if (!accepted || accepted.dead || (accepted.paused && !note))
|
|
806
879
|
return false;
|
|
807
880
|
recoverAllocations();
|
|
808
881
|
if (kv().withLock) {
|
|
@@ -884,7 +957,8 @@ export function isSessionLive(id) {
|
|
|
884
957
|
return rec !== null && rec.sessionId === id && !rec.dead;
|
|
885
958
|
}
|
|
886
959
|
/**
|
|
887
|
-
* Append an event to the durable buffer (drops while
|
|
960
|
+
* Append an event to the durable buffer (drops while dead, and while paused
|
|
961
|
+
* except a note: the tester wrote it on purpose, so it queues and lands).
|
|
888
962
|
* `tabId`/`tabHost`/`ts`/`seq` are filled here; capture layers pass
|
|
889
963
|
* kind+payload plus the route they observed. With no session the event goes
|
|
890
964
|
* to the flight recorder when the idle pill keeps one (memory only — never
|
|
@@ -899,7 +973,7 @@ export function pushEvent(kind, payload, route, images = []) {
|
|
|
899
973
|
const rec = getState();
|
|
900
974
|
if (!rec)
|
|
901
975
|
return pushFlightEvent(kind, payload, route);
|
|
902
|
-
if (rec.
|
|
976
|
+
if (rec.dead || (rec.paused && kind !== 'note'))
|
|
903
977
|
return null;
|
|
904
978
|
const ts = new Date().toISOString();
|
|
905
979
|
const { tabId, tabHost } = route;
|
|
@@ -1256,12 +1330,15 @@ async function flushInner(opts) {
|
|
|
1256
1330
|
return true;
|
|
1257
1331
|
noteSync();
|
|
1258
1332
|
serverMaxSeq = Math.max(serverMaxSeq, ...batch.map((event) => event.seq));
|
|
1259
|
-
|
|
1333
|
+
countAcked(batch);
|
|
1260
1334
|
// Remove EXACTLY the sent seqs — events pushed during the in-flight POST survive.
|
|
1261
1335
|
const sent = new Set(batch.map((e) => e.seq));
|
|
1262
1336
|
clearStoredCaptures(rec.sessionId, sent);
|
|
1263
1337
|
const rest = getBuffer().filter((e) => !sent.has(e.seq));
|
|
1264
1338
|
setBuffer(rest);
|
|
1339
|
+
// Announced once the buffer no longer holds them: a snapshot built now
|
|
1340
|
+
// must not still list an acknowledged note as pending (the HUD's flash).
|
|
1341
|
+
notify();
|
|
1265
1342
|
// An acknowledged attachment row: its bytes are the server's now.
|
|
1266
1343
|
for (const seq of sent) {
|
|
1267
1344
|
const key = rowBlobs.get(seq);
|
|
@@ -1344,6 +1421,8 @@ export function __resetForTests() {
|
|
|
1344
1421
|
if (key.startsWith(ALLOCATION_PREFIX))
|
|
1345
1422
|
kv().remove(key);
|
|
1346
1423
|
resetIdle();
|
|
1424
|
+
acked = { actions: 0, pages: 0, frames: 0, notes: 0 };
|
|
1425
|
+
ackedNotes.clear();
|
|
1347
1426
|
}
|
|
1348
1427
|
/** Test-only: the recorded events currently buffered (in order). */
|
|
1349
1428
|
export function __bufferForTests() {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* id, so a recent without a board link is refreshed through that reconcile
|
|
7
7
|
* read (`GET /api/v1/sessions/:id`).
|
|
8
8
|
*/
|
|
9
|
-
import type { HudRecent } from './hud/controller';
|
|
9
|
+
import type { HudProjection, HudRecent } from './hud/controller';
|
|
10
10
|
export declare const RECENTS_KEY = "recents";
|
|
11
11
|
export declare const MAX_RECENTS = 5;
|
|
12
12
|
export declare function readRecents(): readonly HudRecent[];
|
|
@@ -24,8 +24,15 @@ interface SessionRead {
|
|
|
24
24
|
};
|
|
25
25
|
projection?: {
|
|
26
26
|
state?: string;
|
|
27
|
+
step?: string;
|
|
28
|
+
done?: number;
|
|
29
|
+
total?: number;
|
|
30
|
+
error?: string;
|
|
31
|
+
retryable?: boolean;
|
|
27
32
|
};
|
|
28
33
|
}
|
|
34
|
+
/** The session answer's board build as the HUD paints it; undefined for an unknown state. */
|
|
35
|
+
export declare function projectionOf(s: SessionRead): HudProjection | undefined;
|
|
29
36
|
/** A session answer's board link: the server's `boardUrl`, or an older server's `board.url`. */
|
|
30
37
|
export declare function boardUrlOf(s: Pick<SessionRead, 'boardUrl' | 'board'> | null | undefined): string | undefined;
|
|
31
38
|
/** How often, and how long, a saved session is read until its board exists (the extension's D11 numbers). */
|
|
@@ -35,14 +42,23 @@ export declare const BOARD_WAIT_MS: number;
|
|
|
35
42
|
* The server answered a stop (or a report) before the session's board was
|
|
36
43
|
* built — it projects after the stop, stills first, 30–60 s. Read the
|
|
37
44
|
* session until it names its board and put the link on the recent, where
|
|
38
|
-
* the Saved face and the menu pick it up
|
|
39
|
-
* projection
|
|
40
|
-
*
|
|
45
|
+
* the Saved face and the menu pick it up; every read in between puts the
|
|
46
|
+
* build's progress (`projection`) there too, for the Building face. Ends on a
|
|
47
|
+
* failed or empty projection (kept on the recent, so the face can say so), a
|
|
48
|
+
* gone or refused session, or after `forMs`; a transient error keeps
|
|
49
|
+
* waiting. Never rejects.
|
|
41
50
|
*/
|
|
42
51
|
export declare function awaitBoard(sessionId: string, { everyMs, forMs }?: {
|
|
43
52
|
everyMs?: number;
|
|
44
53
|
forMs?: number;
|
|
45
54
|
}): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Build a saved session's board again after a retryable failure, then wait
|
|
57
|
+
* for it as a stop does. A recorder token may not call `…/project`; closing
|
|
58
|
+
* the session again (`PATCH {status: done}`) re-requests the same final pass.
|
|
59
|
+
* Rejects with the server's reason.
|
|
60
|
+
*/
|
|
61
|
+
export declare function retryBuild(sessionId: string): Promise<void>;
|
|
46
62
|
/**
|
|
47
63
|
* Fill the board links the list lacks — `live` (the recording in progress)
|
|
48
64
|
* is skipped, its link arrives with its stop. Never rejects.
|
|
@@ -47,6 +47,22 @@ export function updateRecent(sessionId, patch) {
|
|
|
47
47
|
return;
|
|
48
48
|
write(list.map((r) => (r.sessionId === sessionId ? { ...r, ...patch } : r)));
|
|
49
49
|
}
|
|
50
|
+
const PROJECTION_STATES = ['idle', 'queued', 'running', 'ready', 'empty', 'failed'];
|
|
51
|
+
/** The session answer's board build as the HUD paints it; undefined for an unknown state. */
|
|
52
|
+
export function projectionOf(s) {
|
|
53
|
+
const p = s.projection;
|
|
54
|
+
const state = PROJECTION_STATES.find((st) => st === p?.state);
|
|
55
|
+
if (!p || !state)
|
|
56
|
+
return undefined;
|
|
57
|
+
return {
|
|
58
|
+
state,
|
|
59
|
+
...(p.step ? { step: p.step } : {}),
|
|
60
|
+
...(typeof p.done === 'number' ? { done: p.done } : {}),
|
|
61
|
+
...(typeof p.total === 'number' ? { total: p.total } : {}),
|
|
62
|
+
...(p.error ? { error: p.error } : {}),
|
|
63
|
+
...(p.retryable ? { retryable: true } : {}),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
50
66
|
/** A session answer's board link: the server's `boardUrl`, or an older server's `board.url`. */
|
|
51
67
|
export function boardUrlOf(s) {
|
|
52
68
|
return s?.boardUrl || s?.board?.url || undefined;
|
|
@@ -59,9 +75,11 @@ const awaiting = new Set();
|
|
|
59
75
|
* The server answered a stop (or a report) before the session's board was
|
|
60
76
|
* built — it projects after the stop, stills first, 30–60 s. Read the
|
|
61
77
|
* session until it names its board and put the link on the recent, where
|
|
62
|
-
* the Saved face and the menu pick it up
|
|
63
|
-
* projection
|
|
64
|
-
*
|
|
78
|
+
* the Saved face and the menu pick it up; every read in between puts the
|
|
79
|
+
* build's progress (`projection`) there too, for the Building face. Ends on a
|
|
80
|
+
* failed or empty projection (kept on the recent, so the face can say so), a
|
|
81
|
+
* gone or refused session, or after `forMs`; a transient error keeps
|
|
82
|
+
* waiting. Never rejects.
|
|
65
83
|
*/
|
|
66
84
|
export async function awaitBoard(sessionId, { everyMs = BOARD_POLL_MS, forMs = BOARD_WAIT_MS } = {}) {
|
|
67
85
|
if (awaiting.has(sessionId))
|
|
@@ -74,11 +92,14 @@ export async function awaitBoard(sessionId, { everyMs = BOARD_POLL_MS, forMs = B
|
|
|
74
92
|
try {
|
|
75
93
|
const s = await api('GET', `/api/v1/sessions/${sessionId}`);
|
|
76
94
|
const boardUrl = boardUrlOf(s);
|
|
95
|
+
const projection = projectionOf(s);
|
|
77
96
|
if (boardUrl)
|
|
78
|
-
return updateRecent(sessionId, { boardUrl });
|
|
97
|
+
return updateRecent(sessionId, { boardUrl, projection: undefined });
|
|
79
98
|
if (s.deletedAt)
|
|
80
|
-
return updateRecent(sessionId, { status: 'deleted' });
|
|
81
|
-
if (
|
|
99
|
+
return updateRecent(sessionId, { status: 'deleted', projection: undefined });
|
|
100
|
+
if (projection && !sameProjection(readRecents().find((r) => r.sessionId === sessionId)?.projection, projection))
|
|
101
|
+
updateRecent(sessionId, { projection });
|
|
102
|
+
if (projection?.state === 'failed' || projection?.state === 'empty')
|
|
82
103
|
return;
|
|
83
104
|
}
|
|
84
105
|
catch (e) {
|
|
@@ -94,6 +115,20 @@ export async function awaitBoard(sessionId, { everyMs = BOARD_POLL_MS, forMs = B
|
|
|
94
115
|
awaiting.delete(sessionId);
|
|
95
116
|
}
|
|
96
117
|
}
|
|
118
|
+
function sameProjection(a, b) {
|
|
119
|
+
return a !== undefined && JSON.stringify(a) === JSON.stringify(b);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Build a saved session's board again after a retryable failure, then wait
|
|
123
|
+
* for it as a stop does. A recorder token may not call `…/project`; closing
|
|
124
|
+
* the session again (`PATCH {status: done}`) re-requests the same final pass.
|
|
125
|
+
* Rejects with the server's reason.
|
|
126
|
+
*/
|
|
127
|
+
export async function retryBuild(sessionId) {
|
|
128
|
+
await api('PATCH', `/api/v1/sessions/${sessionId}`, { status: 'done' });
|
|
129
|
+
updateRecent(sessionId, { projection: { state: 'queued' } });
|
|
130
|
+
void awaitBoard(sessionId);
|
|
131
|
+
}
|
|
97
132
|
/** Ids already asked this document — a refused read is not retried on every menu open. */
|
|
98
133
|
const asked = new Set();
|
|
99
134
|
/**
|
package/build/recorder/report.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { api, fetchPolicy, uploadChunk, uploadImage } from './api';
|
|
2
2
|
import { stageAttachments } from './attachments';
|
|
3
|
-
import { setRedactionPolicy } from './capture/redact';
|
|
3
|
+
import { redactedRoute, setRedactionPolicy } from './capture/redact';
|
|
4
4
|
import { checkoutRRWeb } from './capture/rrweb';
|
|
5
5
|
import { recorderConfig, vitrinkaLinked } from './config';
|
|
6
6
|
import { clipHasSnapshot, flightActive, startFlightBuffer, stopFlightBuffer, takeFlightClip } from './flight';
|
|
@@ -121,14 +121,6 @@ function reportTitle(text) {
|
|
|
121
121
|
function viewportRect() {
|
|
122
122
|
return { x: 0, y: 0, w: globalThis.innerWidth || 0, h: globalThis.innerHeight || 0 };
|
|
123
123
|
}
|
|
124
|
-
function pathOf(href) {
|
|
125
|
-
try {
|
|
126
|
-
return new URL(href).pathname;
|
|
127
|
-
}
|
|
128
|
-
catch {
|
|
129
|
-
return currentRoute.pathname;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
124
|
function buildJob(clip, note) {
|
|
133
125
|
const tab = { tabId: currentRoute.tabId, tabHost: currentRoute.tabHost };
|
|
134
126
|
const events = [];
|
|
@@ -136,7 +128,7 @@ function buildJob(clip, note) {
|
|
|
136
128
|
const first = clip.windows[0];
|
|
137
129
|
const startMs = first?.events[0]?.timestamp;
|
|
138
130
|
if (first && startMs !== undefined) {
|
|
139
|
-
events.push({ seq: ++seq, ts: new Date(startMs).toISOString(), ...tab, kind: 'nav', payload: { url: first.href, route:
|
|
131
|
+
events.push({ seq: ++seq, ts: new Date(startMs).toISOString(), ...tab, kind: 'nav', payload: { url: first.href, route: first.route } });
|
|
140
132
|
}
|
|
141
133
|
for (const e of clip.lanes) {
|
|
142
134
|
events.push({ seq: ++seq, ts: e.ts, tabId: e.tabId, tabHost: e.tabHost, kind: e.kind, ...(e.payload ? { payload: e.payload } : {}) });
|
|
@@ -183,7 +175,7 @@ function buildJob(clip, note) {
|
|
|
183
175
|
selector: note.selector,
|
|
184
176
|
annotate: true,
|
|
185
177
|
task: true,
|
|
186
|
-
route:
|
|
178
|
+
route: redactedRoute(),
|
|
187
179
|
...(images.length ? { attachments: images.map((image) => image.seq) } : {}),
|
|
188
180
|
},
|
|
189
181
|
},
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { RedactionPolicy } from '@vitrinka/redact';
|
|
15
15
|
import type { SessionDone } from '../protocol';
|
|
16
|
-
import type { HudAttachment } from './hud/controller';
|
|
16
|
+
import type { HudAttachment, HudNote } from './hud/controller';
|
|
17
17
|
import { type SessionState, type StoredChange } from './queue';
|
|
18
18
|
export { currentRoute, notify, subscribe } from './state';
|
|
19
19
|
export { onBeforeStop } from './queue';
|
|
@@ -80,6 +80,17 @@ export declare function createSession(title: string, opts?: {
|
|
|
80
80
|
*/
|
|
81
81
|
export declare function startSession(opts?: StartOptions): Promise<SessionState>;
|
|
82
82
|
export declare function togglePause(): Promise<boolean>;
|
|
83
|
+
/**
|
|
84
|
+
* A note's identity on the wire (recorder HUD polish D6/D7): `cid` names it,
|
|
85
|
+
* `replaces` supersedes an earlier note's whole content (the board shows the
|
|
86
|
+
* latest, the thread keeps the rest), `refs` points at other notes. All are
|
|
87
|
+
* the HUD's client ids, never seqs — a seq is allocated after the push.
|
|
88
|
+
*/
|
|
89
|
+
export interface NoteLink {
|
|
90
|
+
cid?: string;
|
|
91
|
+
replaces?: string;
|
|
92
|
+
refs?: readonly string[];
|
|
93
|
+
}
|
|
83
94
|
/**
|
|
84
95
|
* A plain note — `{text, route}`, the extension's shape. With attachments
|
|
85
96
|
* (recorder attachments) each image becomes an `attachment` event whose seq
|
|
@@ -87,7 +98,12 @@ export declare function togglePause(): Promise<boolean>;
|
|
|
87
98
|
* lists them: `{text, route, attachments: [seq…]}`; `text` may then be
|
|
88
99
|
* empty. Their bytes upload through `/shot` before their rows ride (queue.ts).
|
|
89
100
|
*/
|
|
90
|
-
export declare function addNote(text: string, attachments?: readonly HudAttachment[]): void;
|
|
101
|
+
export declare function addNote(text: string, attachments?: readonly HudAttachment[], link?: NoteLink): void;
|
|
102
|
+
/**
|
|
103
|
+
* The live recording's notes, every tab's, oldest first (the device log —
|
|
104
|
+
* `noteLog`); null with no live session. Never rejects.
|
|
105
|
+
*/
|
|
106
|
+
export declare function listNotes(): Promise<HudNote[] | null>;
|
|
91
107
|
/** A rect in CSS pixels (viewport coordinates). */
|
|
92
108
|
export interface ViewRect {
|
|
93
109
|
x: number;
|
|
@@ -99,14 +115,17 @@ export interface ViewRect {
|
|
|
99
115
|
export declare function imagePixels(r: ViewRect): ViewRect;
|
|
100
116
|
/**
|
|
101
117
|
* An annotation — the extension's annotate-note `{text, rect, selector,
|
|
102
|
-
* annotate: true}
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
118
|
+
* annotate: true}`; vitrinka projects it into a board annotation. `selector`
|
|
119
|
+
* is '' for a free region. The rect is in device pixels. An empty note is
|
|
120
|
+
* still a valid annotation, matching the extension. `attachments` ride as for
|
|
121
|
+
* `addNote`, `link` as `NoteLink` says. `task` files it as an intake draft
|
|
122
|
+
* too — only a bug report asks for that; the HUD's annotations land on the
|
|
123
|
+
* board alone.
|
|
106
124
|
*/
|
|
107
125
|
export declare function addAnnotation(text: string, rect: ViewRect, selector: string, opts?: {
|
|
108
126
|
task?: boolean;
|
|
109
127
|
attachments?: readonly HudAttachment[];
|
|
128
|
+
link?: NoteLink;
|
|
110
129
|
}): void;
|
|
111
130
|
/**
|
|
112
131
|
* Hooks that run at the top of Stop, before the drain snapshot — the rrweb
|