ontrackd 0.13.0 → 0.15.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/README.md +24 -12
- package/dist/cli/pull.js +5 -0
- package/dist/cli/pull.js.map +1 -1
- package/dist/core/attachmentTypes.d.ts +4 -1
- package/dist/core/attachmentTypes.js +25 -4
- package/dist/core/attachmentTypes.js.map +1 -1
- package/dist/core/exportTaskDoc.js +43 -1
- package/dist/core/exportTaskDoc.js.map +1 -1
- package/dist/core/feedbackTypes.d.ts +41 -1
- package/dist/core/journey.d.ts +31 -0
- package/dist/core/journey.js +93 -0
- package/dist/core/journey.js.map +1 -0
- package/dist/core/untrusted.js +12 -7
- package/dist/core/untrusted.js.map +1 -1
- package/dist/integration/middleware.js +11 -0
- package/dist/integration/middleware.js.map +1 -1
- package/dist/mcp/search.js +3 -2
- package/dist/mcp/search.js.map +1 -1
- package/dist/mcp/server.js +13 -7
- package/dist/mcp/server.js.map +1 -1
- package/dist/overlay/anchors.d.ts +1 -0
- package/dist/overlay/anchors.js +3 -0
- package/dist/overlay/anchors.js.map +1 -1
- package/dist/overlay/api.d.ts +27 -2
- package/dist/overlay/api.js +47 -9
- package/dist/overlay/api.js.map +1 -1
- package/dist/overlay/attachments.d.ts +5 -1
- package/dist/overlay/attachments.js +16 -3
- package/dist/overlay/attachments.js.map +1 -1
- package/dist/overlay/camera.d.ts +130 -0
- package/dist/overlay/camera.js +388 -0
- package/dist/overlay/camera.js.map +1 -0
- package/dist/overlay/cameraEffects.d.ts +10 -0
- package/dist/overlay/cameraEffects.js +240 -0
- package/dist/overlay/cameraEffects.js.map +1 -0
- package/dist/overlay/cameraPanel.d.ts +39 -0
- package/dist/overlay/cameraPanel.js +275 -0
- package/dist/overlay/cameraPanel.js.map +1 -0
- package/dist/overlay/cameraPlayback.d.ts +75 -0
- package/dist/overlay/cameraPlayback.js +291 -0
- package/dist/overlay/cameraPlayback.js.map +1 -0
- package/dist/overlay/connectDialog.js +1 -1
- package/dist/overlay/connectDialog.js.map +1 -1
- package/dist/overlay/directReviewer.d.ts +27 -3
- package/dist/overlay/directReviewer.js +59 -19
- package/dist/overlay/directReviewer.js.map +1 -1
- package/dist/overlay/effects/NOTICE.md +10 -0
- package/dist/overlay/effects/selfie_segmenter.tflite +0 -0
- package/dist/overlay/effects/vision_wasm_internal.js +9155 -0
- package/dist/overlay/effects/vision_wasm_internal.wasm +0 -0
- package/dist/overlay/icons.js +8 -1
- package/dist/overlay/icons.js.map +1 -1
- package/dist/overlay/journeyRecorder.d.ts +30 -0
- package/dist/overlay/journeyRecorder.js +238 -0
- package/dist/overlay/journeyRecorder.js.map +1 -0
- package/dist/overlay/movedAnchors.js +5 -0
- package/dist/overlay/movedAnchors.js.map +1 -1
- package/dist/overlay/recorder.d.ts +11 -4
- package/dist/overlay/recorder.js +186 -46
- package/dist/overlay/recorder.js.map +1 -1
- package/dist/overlay/recordingEditor.d.ts +12 -0
- package/dist/overlay/recordingEditor.js +131 -0
- package/dist/overlay/recordingEditor.js.map +1 -0
- package/dist/overlay/recordingPlayer.d.ts +24 -0
- package/dist/overlay/recordingPlayer.js +379 -0
- package/dist/overlay/recordingPlayer.js.map +1 -0
- package/dist/overlay/recordingPlayerShell.d.ts +19 -0
- package/dist/overlay/recordingPlayerShell.js +51 -0
- package/dist/overlay/recordingPlayerShell.js.map +1 -0
- package/dist/overlay/rrweb-replay.js +120 -0
- package/dist/overlay/runtime.js +1046 -57
- package/dist/overlay/runtime.js.map +1 -1
- package/dist/overlay/state.js +2 -1
- package/dist/overlay/state.js.map +1 -1
- package/dist/overlay/storageFull.d.ts +16 -0
- package/dist/overlay/storageFull.js +39 -0
- package/dist/overlay/storageFull.js.map +1 -0
- package/dist/overlay/styles.js +118 -5
- package/dist/overlay/styles.js.map +1 -1
- package/dist/overlay/tasks-vision.js +3 -0
- package/dist/overlay/upload.d.ts +2 -2
- package/dist/overlay/upload.js +4 -2
- package/dist/overlay/upload.js.map +1 -1
- package/dist/remote/client.d.ts +3 -2
- package/dist/remote/client.js +3 -3
- package/dist/remote/client.js.map +1 -1
- package/dist/remote/content-schema.d.ts +291 -43
- package/dist/remote/content-schema.js +91 -0
- package/dist/remote/content-schema.js.map +1 -1
- package/dist/remote/content.js +4 -2
- package/dist/remote/content.js.map +1 -1
- package/dist/remote/store.js +3 -1
- package/dist/remote/store.js.map +1 -1
- package/dist/remote/types.d.ts +1 -0
- package/dist/sidecar/commentFiles.js +5 -3
- package/dist/sidecar/commentFiles.js.map +1 -1
- package/dist/storage/localAttachments.js +1 -1
- package/dist/storage/localAttachments.js.map +1 -1
- package/package.json +9 -2
package/dist/overlay/runtime.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { hasContractSession } from '../core/apiKind.js';
|
|
2
|
+
import { newId, newIdempotencyKey } from '../remote/index.js';
|
|
2
3
|
import { joinReviewer, forgetReviewer, hasMagicLink } from './magicLink.js';
|
|
3
4
|
import { configureDirectApi } from './api.js';
|
|
5
|
+
import { isRecording } from '../core/journey.js';
|
|
4
6
|
import { anchorCandidatesFor, filesInsideSelection, instancesOf, locateAnchor, scopeFor, siblingInstances, belongsOnThisPage, } from './anchors.js';
|
|
5
7
|
import { describeElement, summarizeDescription } from './elementDescription.js';
|
|
6
8
|
import { openDialogFor, openerFor, openingDialog, rememberClick } from './dialogOpener.js';
|
|
@@ -9,13 +11,17 @@ import { leaveReviewMode } from './reviewMode.js';
|
|
|
9
11
|
import { api, attachmentsAvailable, recordingSupported, remoteFeedbackStatus, renderable } from './api.js';
|
|
10
12
|
import { acceptAttribute } from '../core/attachmentTypes.js';
|
|
11
13
|
import { AttachmentTray, filesMarkup, trayMarkup } from './attachments.js';
|
|
12
|
-
import { unavailableFile } from './upload.js';
|
|
14
|
+
import { unavailableFile, UploadRefused } from './upload.js';
|
|
15
|
+
import { storageDialogMarkup } from './storageFull.js';
|
|
16
|
+
import { cameraIcon, CameraCapture, loadCameraPrefs, saveCameraPrefs, touchScreen } from './camera.js';
|
|
17
|
+
import { CameraPanel } from './cameraPanel.js';
|
|
13
18
|
import { clock, Recorder } from './recorder.js';
|
|
14
19
|
import { captureElement } from './snapshot.js';
|
|
15
20
|
import { isLocalMachine, notLocalMessage } from './localMachine.js';
|
|
16
21
|
import { hidePinCursor, showPinCursor } from './cursor.js';
|
|
17
22
|
import { colorForId, forgetIdentity, identify, initialsFor, saveIdentity } from './identity.js';
|
|
18
23
|
import { icon } from './icons.js';
|
|
24
|
+
import { recordingPlayerShellMarkup } from './recordingPlayerShell.js';
|
|
19
25
|
import { observeRoute, pageUrl, sameOriginRoute } from './route.js';
|
|
20
26
|
import { cssScopeFor } from './cssScope.js';
|
|
21
27
|
import { flushTrace, trace } from './trace.js';
|
|
@@ -58,6 +64,20 @@ export function mountFeedbackOverlay() {
|
|
|
58
64
|
}
|
|
59
65
|
void new FeedbackOverlay().mount();
|
|
60
66
|
}
|
|
67
|
+
/** Seconds counted down, on the screen, before a recording starts: time to get the page the way it should be. */
|
|
68
|
+
const COUNTDOWN_SECONDS = 5;
|
|
69
|
+
function retryableModulePath(path, attempt) {
|
|
70
|
+
return `${path}${path.includes('?') ? '&' : '?'}retry=${attempt}`;
|
|
71
|
+
}
|
|
72
|
+
/** A definitive create refusal: the upload claim and its idempotency result cannot be reused. */
|
|
73
|
+
function recordingAttachmentRefusal(error) {
|
|
74
|
+
if (!error || typeof error !== 'object')
|
|
75
|
+
return false;
|
|
76
|
+
const details = error.details;
|
|
77
|
+
if (details && typeof details === 'object' && details.reason === 'recording_attachment')
|
|
78
|
+
return true;
|
|
79
|
+
return error instanceof Error && error.message.includes('recording_attachment');
|
|
80
|
+
}
|
|
61
81
|
class FeedbackOverlay {
|
|
62
82
|
host = document.createElement('div');
|
|
63
83
|
root;
|
|
@@ -85,12 +105,27 @@ class FeedbackOverlay {
|
|
|
85
105
|
replyBody = '';
|
|
86
106
|
/** How files reach the API or the sidecar, for both composers. */
|
|
87
107
|
fileTransport = {
|
|
88
|
-
send: (file, onProgress) =>
|
|
108
|
+
send: async (file, onProgress) => {
|
|
109
|
+
try {
|
|
110
|
+
return await api.uploadAttachment(file, onProgress);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
if (error instanceof UploadRefused && error.reason === 'storage_full')
|
|
114
|
+
void this.refusedForStorage(file.name.endsWith('.rrweb') ? file : null);
|
|
115
|
+
if (error instanceof SessionExpiredError && this.shared && !this.signIn) {
|
|
116
|
+
if (this.recordingSaving)
|
|
117
|
+
this.pendingRecordingSave = true;
|
|
118
|
+
this.handleSessionExpired();
|
|
119
|
+
}
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
},
|
|
89
123
|
discard: (id) => api.discardUpload(id),
|
|
90
124
|
};
|
|
91
125
|
/** Files of the comment being written, and of the reply being written (spec: Attachments). */
|
|
92
126
|
draftTray = new AttachmentTray(this.fileTransport, () => this.render(), (item) => this.showProgress('draft', item));
|
|
93
127
|
replyTray = new AttachmentTray(this.fileTransport, () => this.render(), (item) => this.showProgress('reply', item));
|
|
128
|
+
recordingTray = new AttachmentTray(this.fileTransport, () => this.render(), (item) => this.showProgress('recording', item));
|
|
94
129
|
/**
|
|
95
130
|
* The thread whose reply is being claimed by the server now. Its files are the request's: moving to
|
|
96
131
|
* another thread meanwhile must not discard them (a removal racing the claim refuses the reply).
|
|
@@ -103,10 +138,35 @@ class FeedbackOverlay {
|
|
|
103
138
|
* cannot be recorded. Record is offered in a new comment's composer, on a Cloud session, with room to record.
|
|
104
139
|
*/
|
|
105
140
|
recordingLimit;
|
|
141
|
+
/** The workspace's storage as last read: undefined until asked, null where unknown. Only a read that says "full" blocks. */
|
|
142
|
+
storage;
|
|
143
|
+
askingStorage = false;
|
|
144
|
+
storageDialog = null;
|
|
106
145
|
askingRecordingLimit = false;
|
|
146
|
+
/** What the plan allows of a camera file: undefined until asked, null where unknown (no camera is offered). */
|
|
147
|
+
cameraLimit;
|
|
148
|
+
askingCameraLimit = false;
|
|
149
|
+
cameraPanel = null;
|
|
107
150
|
/** The recording in progress: the page is the reviewer's meanwhile (the mode they were in comes back after). */
|
|
108
151
|
recording = null;
|
|
109
152
|
startingRecording = false;
|
|
153
|
+
/** A whole journey stopped but not yet saved. */
|
|
154
|
+
recordingDraft = null;
|
|
155
|
+
recordingSaving = false;
|
|
156
|
+
recordingError = null;
|
|
157
|
+
recordingDiscard = null;
|
|
158
|
+
recordingDiscardFocus = null;
|
|
159
|
+
pendingRecordingSave = false;
|
|
160
|
+
recordingUi = null;
|
|
161
|
+
recordingUiLoad = null;
|
|
162
|
+
recordingUiAttempt = 0;
|
|
163
|
+
recordingUiFailed = false;
|
|
164
|
+
recordingEditor = null;
|
|
165
|
+
recordingPlayer = null;
|
|
166
|
+
threadRecordingPlayer = null;
|
|
167
|
+
threadRecordingPlayerId = null;
|
|
168
|
+
threadRecordingFile = null;
|
|
169
|
+
threadRecordingGeneration = 0;
|
|
110
170
|
/** The route a comment's recording began on, while the page is elsewhere: the draft waits there, as it does when its element is scrolled away. */
|
|
111
171
|
draftHeldFor = null;
|
|
112
172
|
/** Until when (performance.now) a draft's elements, gone with the route, are looked for again. */
|
|
@@ -230,6 +290,7 @@ class FeedbackOverlay {
|
|
|
230
290
|
panelContent;
|
|
231
291
|
panelToast;
|
|
232
292
|
fileInput;
|
|
293
|
+
recordingDialog;
|
|
233
294
|
lightbox;
|
|
234
295
|
chip;
|
|
235
296
|
/** The phone's bottom sheet (sheet.ts): every panel goes into it in compact layout. */
|
|
@@ -240,9 +301,13 @@ class FeedbackOverlay {
|
|
|
240
301
|
sheetBack = null;
|
|
241
302
|
/** On a phone: the list sheet shows only these comments, after a tap on a group of pins. */
|
|
242
303
|
listFilter = null;
|
|
304
|
+
/** The list's message kind, independent of open/resolved. */
|
|
305
|
+
kindFilter = 'all';
|
|
243
306
|
panelToastTimer = null;
|
|
244
307
|
constructor() {
|
|
245
308
|
this.host.id = rootId;
|
|
309
|
+
// rrweb preserves a blocked node's class (but strips its data attributes), so replay can remove its placeholder box.
|
|
310
|
+
this.host.classList.add('fb-overlay-blocked');
|
|
246
311
|
this.host.setAttribute('data-feedback-overlay', '');
|
|
247
312
|
// React Aria listens for outside presses in the capture phase, where nothing of ours can stop it;
|
|
248
313
|
// this marker is the opt-out it documents for floating UI that does not belong to a dialog.
|
|
@@ -273,6 +338,7 @@ class FeedbackOverlay {
|
|
|
273
338
|
this.panelContent = required(this.root, '[data-fb-panel-content]');
|
|
274
339
|
this.panelToast = required(this.root, '[data-fb-panel-toast]');
|
|
275
340
|
this.fileInput = required(this.root, '[data-fb-file-input]');
|
|
341
|
+
this.recordingDialog = required(this.root, '[data-fb-recording-mount]');
|
|
276
342
|
this.fileInput.accept = acceptAttribute;
|
|
277
343
|
// The picker's answer. Bound once, here: the composers' markup is rebuilt on every render.
|
|
278
344
|
this.fileInput.addEventListener('change', () => {
|
|
@@ -339,6 +405,9 @@ class FeedbackOverlay {
|
|
|
339
405
|
for (const type of ['pointerdown', 'pointerup', 'mousedown', 'mouseup', 'touchstart', 'touchend']) {
|
|
340
406
|
document.addEventListener(type, (event) => this.holdTapFromPage(event), true);
|
|
341
407
|
}
|
|
408
|
+
// Back from the dashboard, where space may have been freed: a workspace last seen full is read again.
|
|
409
|
+
document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'visible' && this.storage?.full)
|
|
410
|
+
void this.stillFull(); });
|
|
342
411
|
document.addEventListener('keydown', (event) => this.handleKeydown(event), true);
|
|
343
412
|
window.addEventListener('scroll', () => this.schedulePositionUpdate(), true);
|
|
344
413
|
window.addEventListener('resize', () => this.schedulePositionUpdate());
|
|
@@ -365,9 +434,7 @@ class FeedbackOverlay {
|
|
|
365
434
|
}
|
|
366
435
|
// A group's filter names pins of the page left behind.
|
|
367
436
|
this.listFilter = null;
|
|
368
|
-
this.
|
|
369
|
-
this.sheetBack = null;
|
|
370
|
-
this.abandonReplyFiles();
|
|
437
|
+
this.closeThread();
|
|
371
438
|
this.render();
|
|
372
439
|
});
|
|
373
440
|
this.state.subscribe(() => this.render());
|
|
@@ -853,6 +920,13 @@ class FeedbackOverlay {
|
|
|
853
920
|
void this.bootstrapViewer();
|
|
854
921
|
this.requestNotifications();
|
|
855
922
|
this.render();
|
|
923
|
+
// The save that discovered the session was dead. Finished now, with the same local file,
|
|
924
|
+
// identity and words, so an ambiguous create cannot turn into a duplicate comment.
|
|
925
|
+
if (this.pendingRecordingSave && this.recordingDraft) {
|
|
926
|
+
this.pendingRecordingSave = false;
|
|
927
|
+
void this.saveRecording();
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
856
930
|
// The save that discovered the session was dead. Finished now, with the same words the
|
|
857
931
|
// reviewer typed before they were interrupted.
|
|
858
932
|
if (this.pendingDraftSave) {
|
|
@@ -1078,6 +1152,92 @@ class FeedbackOverlay {
|
|
|
1078
1152
|
this.render();
|
|
1079
1153
|
}
|
|
1080
1154
|
handleKeydown(event) {
|
|
1155
|
+
if (this.storageDialog) {
|
|
1156
|
+
event.stopPropagation();
|
|
1157
|
+
if (event.key === 'Escape') {
|
|
1158
|
+
event.preventDefault();
|
|
1159
|
+
this.closeStorageDialog();
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
if (event.key === 'Tab') {
|
|
1163
|
+
event.preventDefault();
|
|
1164
|
+
const controls = Array.from(this.storageDialog.element.querySelectorAll('a, button'));
|
|
1165
|
+
const at = controls.indexOf(this.root.activeElement);
|
|
1166
|
+
controls[(at + (event.shiftKey ? -1 : 1) + controls.length) % controls.length]?.focus();
|
|
1167
|
+
}
|
|
1168
|
+
else if (event.key !== 'Enter' && event.key !== ' ')
|
|
1169
|
+
event.preventDefault();
|
|
1170
|
+
return;
|
|
1171
|
+
}
|
|
1172
|
+
if (this.cameraPanel) {
|
|
1173
|
+
if (event.key === 'Escape') {
|
|
1174
|
+
event.preventDefault();
|
|
1175
|
+
event.stopPropagation();
|
|
1176
|
+
this.closeCameraPanel();
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
if (event.key === 'Tab') {
|
|
1180
|
+
event.stopPropagation();
|
|
1181
|
+
this.cameraPanel.panel.trapTab(event, this.root.activeElement);
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
if (this.recordingDiscard) {
|
|
1186
|
+
const confirm = this.recordingDialog.querySelector('[data-fb-recording-discard]');
|
|
1187
|
+
const inside = event.composedPath().includes(confirm);
|
|
1188
|
+
if (event.key === 'Tab' && confirm) {
|
|
1189
|
+
event.preventDefault();
|
|
1190
|
+
event.stopPropagation();
|
|
1191
|
+
const buttons = Array.from(confirm.querySelectorAll('button:not(:disabled)'));
|
|
1192
|
+
const at = buttons.indexOf(this.root.activeElement);
|
|
1193
|
+
buttons[(at + (event.shiftKey ? -1 : 1) + buttons.length) % buttons.length]?.focus();
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
if (event.key === 'Escape') {
|
|
1197
|
+
event.preventDefault();
|
|
1198
|
+
event.stopPropagation();
|
|
1199
|
+
this.keepRecording();
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
if (event.key !== 'Enter' || !inside) {
|
|
1203
|
+
event.preventDefault();
|
|
1204
|
+
event.stopPropagation();
|
|
1205
|
+
}
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
if (this.recordingDraft && event.key === 'Tab') {
|
|
1209
|
+
const dialog = this.recordingDialog.querySelector('[data-fb-recording-dialog]');
|
|
1210
|
+
const controls = dialog ? Array.from(dialog.querySelectorAll('button, input, [contenteditable="true"], [tabindex]:not([tabindex="-1"])')).filter((element) => !element.hasAttribute('disabled') && !element.closest('[inert]') && element.getClientRects().length > 0) : [];
|
|
1211
|
+
const active = this.root.activeElement;
|
|
1212
|
+
const at = controls.indexOf(active);
|
|
1213
|
+
if (controls.length > 0 && (at < 0 || !event.shiftKey && at === controls.length - 1 || event.shiftKey && at === 0)) {
|
|
1214
|
+
event.preventDefault();
|
|
1215
|
+
event.stopPropagation();
|
|
1216
|
+
controls[event.shiftKey ? controls.length - 1 : 0]?.focus();
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
// Journey recording owns its shortcut in every state, before recording's early return.
|
|
1221
|
+
if (event.altKey && event.shiftKey && event.code === 'KeyR') {
|
|
1222
|
+
event.preventDefault();
|
|
1223
|
+
event.stopPropagation();
|
|
1224
|
+
if (this.recordingSaving)
|
|
1225
|
+
return;
|
|
1226
|
+
if (this.recording) {
|
|
1227
|
+
if (this.recording.countdown != null)
|
|
1228
|
+
this.recording.cancel?.();
|
|
1229
|
+
else
|
|
1230
|
+
this.recording.recorder.stop();
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
if (this.recordingDraft) {
|
|
1234
|
+
this.askToDiscardRecording(true);
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
if (this.recordOffered())
|
|
1238
|
+
void this.startRecording(true);
|
|
1239
|
+
return;
|
|
1240
|
+
}
|
|
1081
1241
|
// The keys are the page's while recording: Escape closing something of the app must not discard the comment.
|
|
1082
1242
|
if (this.recording)
|
|
1083
1243
|
return;
|
|
@@ -1089,6 +1249,11 @@ class FeedbackOverlay {
|
|
|
1089
1249
|
return;
|
|
1090
1250
|
}
|
|
1091
1251
|
if (event.key === 'Escape') {
|
|
1252
|
+
if (this.recordingDraft) {
|
|
1253
|
+
if (!this.recordingSaving)
|
|
1254
|
+
this.askToDiscardRecording(false);
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1092
1257
|
if (this.signIn) {
|
|
1093
1258
|
this.dismissSignIn();
|
|
1094
1259
|
return;
|
|
@@ -1628,6 +1793,11 @@ class FeedbackOverlay {
|
|
|
1628
1793
|
if (!target) {
|
|
1629
1794
|
return;
|
|
1630
1795
|
}
|
|
1796
|
+
if (this.recordingDraft && target === this.recordingDialog.querySelector('[data-fb-recording-dialog]')) {
|
|
1797
|
+
if (!this.recordingSaving)
|
|
1798
|
+
this.askToDiscardRecording(false);
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1631
1801
|
// A click on the dimmed backdrop around the sign-in, not on the dialog itself. In a sheet (a phone)
|
|
1632
1802
|
// the scrim is the dialog's own background: a tap there is not a backdrop tap.
|
|
1633
1803
|
if (this.signIn && target === this.scrim && !this.compact) {
|
|
@@ -1651,15 +1821,65 @@ class FeedbackOverlay {
|
|
|
1651
1821
|
return;
|
|
1652
1822
|
}
|
|
1653
1823
|
const { fbAction: name, fbValue: value } = action.dataset;
|
|
1824
|
+
// The storage dialog is the only interactive surface until it is closed.
|
|
1825
|
+
if (this.storageDialog && name !== 'close-storage-dialog' && name !== 'download-refused-recording')
|
|
1826
|
+
return;
|
|
1827
|
+
// The alertdialog is the only interactive surface until its choice is made.
|
|
1828
|
+
if (this.recordingDiscard && name !== 'keep-recording' && name !== 'discard-recording')
|
|
1829
|
+
return;
|
|
1654
1830
|
// The page is the reviewer's while recording: the rest of the overlay is out of the way, and inert.
|
|
1655
1831
|
if (this.recording && name !== 'stop-recording')
|
|
1656
1832
|
return;
|
|
1657
1833
|
switch (name) {
|
|
1834
|
+
case 'close-storage-dialog':
|
|
1835
|
+
this.closeStorageDialog();
|
|
1836
|
+
break;
|
|
1837
|
+
case 'download-refused-recording':
|
|
1838
|
+
this.downloadRefusedRecording();
|
|
1839
|
+
break;
|
|
1840
|
+
case 'record-journey':
|
|
1841
|
+
void this.startRecording(true);
|
|
1842
|
+
break;
|
|
1843
|
+
case 'camera-panel':
|
|
1844
|
+
if (this.cameraPanel)
|
|
1845
|
+
this.closeCameraPanel();
|
|
1846
|
+
else
|
|
1847
|
+
this.openCameraPanel();
|
|
1848
|
+
break;
|
|
1658
1849
|
case 'record':
|
|
1659
|
-
void this.startRecording();
|
|
1850
|
+
void this.startRecording(false);
|
|
1660
1851
|
break;
|
|
1661
1852
|
case 'stop-recording':
|
|
1662
|
-
this.
|
|
1853
|
+
// Until it starts, this is the cancel.
|
|
1854
|
+
if (this.recording?.countdown != null)
|
|
1855
|
+
this.recording.cancel?.();
|
|
1856
|
+
else
|
|
1857
|
+
this.recording?.recorder.stop();
|
|
1858
|
+
break;
|
|
1859
|
+
case 'cancel-recording':
|
|
1860
|
+
if (!this.recordingSaving)
|
|
1861
|
+
this.askToDiscardRecording(false);
|
|
1862
|
+
break;
|
|
1863
|
+
case 'save-recording':
|
|
1864
|
+
void this.saveRecording();
|
|
1865
|
+
break;
|
|
1866
|
+
case 'retry-recording-ui':
|
|
1867
|
+
if (this.recordingDraft && !this.recordingSaving) {
|
|
1868
|
+
this.recordingUiFailed = false;
|
|
1869
|
+
this.recordingError = null;
|
|
1870
|
+
this.renderRecordingDialog();
|
|
1871
|
+
void this.mountRecordingUi(this.recordingDraft);
|
|
1872
|
+
}
|
|
1873
|
+
break;
|
|
1874
|
+
case 'discard-recording': {
|
|
1875
|
+
const restart = this.recordingDiscard?.restart === true;
|
|
1876
|
+
this.discardRecording();
|
|
1877
|
+
if (restart)
|
|
1878
|
+
queueMicrotask(() => { void this.startRecording(true); });
|
|
1879
|
+
break;
|
|
1880
|
+
}
|
|
1881
|
+
case 'keep-recording':
|
|
1882
|
+
this.keepRecording();
|
|
1663
1883
|
break;
|
|
1664
1884
|
case 'join':
|
|
1665
1885
|
void this.completeJoin();
|
|
@@ -1803,6 +2023,12 @@ class FeedbackOverlay {
|
|
|
1803
2023
|
this.clearSticky();
|
|
1804
2024
|
this.state.setFilter(value);
|
|
1805
2025
|
break;
|
|
2026
|
+
case 'set-kind-filter':
|
|
2027
|
+
this.clearSticky();
|
|
2028
|
+
if (value === 'all' || value === 'pin' || value === 'recording')
|
|
2029
|
+
this.kindFilter = value;
|
|
2030
|
+
this.render();
|
|
2031
|
+
break;
|
|
1806
2032
|
case 'cancel-draft':
|
|
1807
2033
|
this.cancelDraft();
|
|
1808
2034
|
break;
|
|
@@ -1855,18 +2081,24 @@ class FeedbackOverlay {
|
|
|
1855
2081
|
void this.sendReply(String(value));
|
|
1856
2082
|
break;
|
|
1857
2083
|
case 'attach': {
|
|
1858
|
-
const which = value === 'reply' ? 'reply' : 'draft';
|
|
1859
|
-
if (!this.takesFiles(which) || this.sending === which)
|
|
2084
|
+
const which = value === 'reply' ? 'reply' : value === 'recording' ? 'recording' : 'draft';
|
|
2085
|
+
if (!this.takesFiles(which) || (which === 'recording' ? this.recordingSaving : this.sending === which))
|
|
1860
2086
|
break;
|
|
2087
|
+
if (this.storage?.full) {
|
|
2088
|
+
this.openStorageDialog();
|
|
2089
|
+
void api.storageStatus().then((status) => { this.storage = status; }, () => { });
|
|
2090
|
+
break;
|
|
2091
|
+
}
|
|
2092
|
+
this.ensureStorage();
|
|
1861
2093
|
this.pickingFor = which;
|
|
1862
2094
|
this.fileInput.click();
|
|
1863
2095
|
break;
|
|
1864
2096
|
}
|
|
1865
2097
|
case 'remove-file': {
|
|
1866
2098
|
const [which, key = ''] = String(value).split(':');
|
|
1867
|
-
const tray = which === 'reply' ? 'reply' : 'draft';
|
|
2099
|
+
const tray = which === 'reply' ? 'reply' : which === 'recording' ? 'recording' : 'draft';
|
|
1868
2100
|
// While that composer sends, its files are being claimed: none is taken out from under it.
|
|
1869
|
-
if (this.sending === tray)
|
|
2101
|
+
if ((tray !== 'recording' && this.sending === tray) || (tray === 'recording' && this.recordingSaving))
|
|
1870
2102
|
break;
|
|
1871
2103
|
this.trayFor(tray).remove(key);
|
|
1872
2104
|
// The button that had the focus is gone with its file.
|
|
@@ -2119,6 +2351,25 @@ class FeedbackOverlay {
|
|
|
2119
2351
|
if (!wasThere && candidates[0]?.element.isConnected)
|
|
2120
2352
|
queueMicrotask(() => this.render());
|
|
2121
2353
|
}
|
|
2354
|
+
/**
|
|
2355
|
+
* Re-anchors the draft to the page the reviewer is on, at the element in the middle of it, keeping what was written.
|
|
2356
|
+
* False when nothing on the page can be anchored to: the draft then waits for its own page.
|
|
2357
|
+
*/
|
|
2358
|
+
anchorDraftHere() {
|
|
2359
|
+
const x = window.innerWidth / 2, y = window.innerHeight / 2;
|
|
2360
|
+
for (const element of document.elementsFromPoint(x, y)) {
|
|
2361
|
+
if (this.host.contains(element))
|
|
2362
|
+
continue;
|
|
2363
|
+
const candidates = anchorCandidatesFor(element);
|
|
2364
|
+
if (!candidates.length)
|
|
2365
|
+
continue;
|
|
2366
|
+
this.draft = this.draftAt(candidates, x, y);
|
|
2367
|
+
this.draftRelocateUntil = 0;
|
|
2368
|
+
this.snapshotSelected();
|
|
2369
|
+
return true;
|
|
2370
|
+
}
|
|
2371
|
+
return false;
|
|
2372
|
+
}
|
|
2122
2373
|
/** The element the draft currently points at. */
|
|
2123
2374
|
selectedElement(draft = this.draft) {
|
|
2124
2375
|
if (!draft)
|
|
@@ -2160,14 +2411,24 @@ class FeedbackOverlay {
|
|
|
2160
2411
|
]);
|
|
2161
2412
|
if (!snapshot)
|
|
2162
2413
|
return;
|
|
2414
|
+
if (this.storage?.full && await this.stillFull()) {
|
|
2415
|
+
this.openStorageDialog();
|
|
2416
|
+
return;
|
|
2417
|
+
}
|
|
2163
2418
|
try {
|
|
2164
2419
|
await api.uploadScreenshot(commentId, snapshot);
|
|
2165
2420
|
}
|
|
2166
2421
|
catch (error) {
|
|
2422
|
+
if (error instanceof UploadRefused && error.reason === 'storage_full') {
|
|
2423
|
+
this.openStorageDialog();
|
|
2424
|
+
return;
|
|
2425
|
+
}
|
|
2167
2426
|
this.trace('screenshot-failed', { reason: error instanceof Error ? error.message.slice(0, 120) : 'unknown' });
|
|
2168
2427
|
}
|
|
2169
2428
|
}
|
|
2170
|
-
trayFor(which) {
|
|
2429
|
+
trayFor(which) {
|
|
2430
|
+
return which === 'reply' ? this.replyTray : which === 'recording' ? this.recordingTray : this.draftTray;
|
|
2431
|
+
}
|
|
2171
2432
|
/** The reply being written is left (thread closed or another opened): its uploads go, unless a send is claiming them. */
|
|
2172
2433
|
abandonReplyFiles() {
|
|
2173
2434
|
if (!this.claimingReplyFor)
|
|
@@ -2178,6 +2439,8 @@ class FeedbackOverlay {
|
|
|
2178
2439
|
* a sent message adds none). Never Standalone, and never a thread another session holds.
|
|
2179
2440
|
*/
|
|
2180
2441
|
takesFiles(which) {
|
|
2442
|
+
if (which === 'recording')
|
|
2443
|
+
return Boolean(this.recordingDraft) && attachmentsAvailable();
|
|
2181
2444
|
if (which === 'draft')
|
|
2182
2445
|
return Boolean(this.draft) && attachmentsAvailable();
|
|
2183
2446
|
const id = this.state.openThreadId;
|
|
@@ -2185,6 +2448,10 @@ class FeedbackOverlay {
|
|
|
2185
2448
|
}
|
|
2186
2449
|
/** Back to a composer's words, after the control that had the focus was replaced. */
|
|
2187
2450
|
focusComposer(which) {
|
|
2451
|
+
if (which === 'recording') {
|
|
2452
|
+
this.recordingEditor?.element.focus();
|
|
2453
|
+
return;
|
|
2454
|
+
}
|
|
2188
2455
|
const field = this.root.querySelector(which === 'reply' ? '[data-fb-reply]' : '[data-fb-body]');
|
|
2189
2456
|
if (field && !field.disabled)
|
|
2190
2457
|
field.focus();
|
|
@@ -2203,40 +2470,208 @@ class FeedbackOverlay {
|
|
|
2203
2470
|
this.askingRecordingLimit = true;
|
|
2204
2471
|
void api.recordingLimit().then((limit) => { this.recordingLimit = limit; this.askingRecordingLimit = false; this.render(); });
|
|
2205
2472
|
}
|
|
2473
|
+
if (this.cameraLimit === undefined && !this.askingCameraLimit) {
|
|
2474
|
+
this.askingCameraLimit = true;
|
|
2475
|
+
void api.cameraLimit().then((limit) => { this.cameraLimit = limit; this.askingCameraLimit = false; this.render(); }, () => { this.cameraLimit = null; this.askingCameraLimit = false; });
|
|
2476
|
+
}
|
|
2477
|
+
this.ensureStorage();
|
|
2206
2478
|
return this.recordingLimit?.available === true;
|
|
2207
2479
|
}
|
|
2480
|
+
/** The camera is offered where Record is, the plan has it, and the device is not a touch screen. Hidden entirely otherwise. */
|
|
2481
|
+
cameraOffered() {
|
|
2482
|
+
return this.recordOffered() && this.cameraLimit?.available === true && !touchScreen();
|
|
2483
|
+
}
|
|
2484
|
+
openCameraPanel() {
|
|
2485
|
+
if (this.cameraPanel || this.recording || this.startingRecording || this.recordingSaving || this.recordingDraft || !this.cameraOffered())
|
|
2486
|
+
return;
|
|
2487
|
+
const focus = this.root.activeElement;
|
|
2488
|
+
const panel = new CameraPanel(this.root, {
|
|
2489
|
+
start: () => { this.closeCameraPanel(false); void this.startRecording(true); },
|
|
2490
|
+
pageOnly: () => { this.closeCameraPanel(false); void this.startRecording(true, { pageOnly: true }); },
|
|
2491
|
+
close: () => this.closeCameraPanel(),
|
|
2492
|
+
});
|
|
2493
|
+
this.cameraPanel = { panel, focus };
|
|
2494
|
+
}
|
|
2495
|
+
closeCameraPanel(restoreFocus = true) {
|
|
2496
|
+
const open = this.cameraPanel;
|
|
2497
|
+
if (!open)
|
|
2498
|
+
return;
|
|
2499
|
+
this.cameraPanel = null;
|
|
2500
|
+
open.panel.close();
|
|
2501
|
+
if (restoreFocus) {
|
|
2502
|
+
const button = this.root.querySelector('[data-fb-action="camera-panel"]');
|
|
2503
|
+
if (open.focus instanceof HTMLElement && open.focus.isConnected)
|
|
2504
|
+
open.focus.focus();
|
|
2505
|
+
else
|
|
2506
|
+
button?.focus();
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
/** Asks the workspace's storage once; a failed read leaves it unknown, and unknown never blocks. */
|
|
2510
|
+
ensureStorage() {
|
|
2511
|
+
if (this.storage !== undefined || this.askingStorage)
|
|
2512
|
+
return;
|
|
2513
|
+
this.askingStorage = true;
|
|
2514
|
+
void api.storageStatus().then((status) => { this.storage = status; }, () => { this.storage = null; }).finally(() => { this.askingStorage = false; });
|
|
2515
|
+
}
|
|
2516
|
+
/** Whether a workspace last seen full still is: read again, since space may have been freed meanwhile. */
|
|
2517
|
+
async stillFull() {
|
|
2518
|
+
const fresh = await api.storageStatus().catch(() => undefined);
|
|
2519
|
+
if (fresh !== undefined)
|
|
2520
|
+
this.storage = fresh;
|
|
2521
|
+
return this.storage?.full === true;
|
|
2522
|
+
}
|
|
2523
|
+
/**
|
|
2524
|
+
* The "Storage is full" dialog, in place of whatever was about to start. The buttons are the Worker's `actions`
|
|
2525
|
+
* for this reviewer; with no dashboard known there are no links. A refused recording can be saved locally.
|
|
2526
|
+
*/
|
|
2527
|
+
openStorageDialog(recording = null) {
|
|
2528
|
+
if (this.storage)
|
|
2529
|
+
this.storage = { ...this.storage, full: true };
|
|
2530
|
+
else
|
|
2531
|
+
this.storage = { used: 0, limit: null, full: true, actions: [], dashboard: null };
|
|
2532
|
+
this.closeStorageDialog(false);
|
|
2533
|
+
const holder = document.createElement('div');
|
|
2534
|
+
holder.innerHTML = storageDialogMarkup(this.storage, recording !== null);
|
|
2535
|
+
const element = holder.firstElementChild;
|
|
2536
|
+
this.storageDialog = { element, recording, focus: this.root.activeElement };
|
|
2537
|
+
this.root.append(element);
|
|
2538
|
+
element.querySelector('a, button')?.focus();
|
|
2539
|
+
}
|
|
2540
|
+
/** Another reviewer took the last room: the dialog's buttons come from a fresh read, not from what was cached. */
|
|
2541
|
+
async refusedForStorage(recording) {
|
|
2542
|
+
const fresh = await api.storageStatus().catch(() => null);
|
|
2543
|
+
if (fresh)
|
|
2544
|
+
this.storage = fresh;
|
|
2545
|
+
this.openStorageDialog(recording);
|
|
2546
|
+
}
|
|
2547
|
+
closeStorageDialog(restoreFocus = true) {
|
|
2548
|
+
const open = this.storageDialog;
|
|
2549
|
+
if (!open)
|
|
2550
|
+
return;
|
|
2551
|
+
this.storageDialog = null;
|
|
2552
|
+
open.element.remove();
|
|
2553
|
+
if (restoreFocus && open.focus instanceof HTMLElement && open.focus.isConnected)
|
|
2554
|
+
open.focus.focus();
|
|
2555
|
+
}
|
|
2556
|
+
downloadRefusedRecording() {
|
|
2557
|
+
const file = this.storageDialog?.recording;
|
|
2558
|
+
if (!file)
|
|
2559
|
+
return;
|
|
2560
|
+
const url = URL.createObjectURL(file);
|
|
2561
|
+
const link = document.createElement('a');
|
|
2562
|
+
link.href = url;
|
|
2563
|
+
link.download = file.name;
|
|
2564
|
+
link.rel = 'noopener';
|
|
2565
|
+
this.root.append(link);
|
|
2566
|
+
link.click();
|
|
2567
|
+
link.remove();
|
|
2568
|
+
window.setTimeout(() => URL.revokeObjectURL(url), 30_000);
|
|
2569
|
+
}
|
|
2208
2570
|
/**
|
|
2209
2571
|
* Records the page while the reviewer reproduces the problem. The mode they were in is set aside, so the page
|
|
2210
2572
|
* behaves as if the tool were absent; the draft stays. The limit is asked again: the plan may have changed.
|
|
2211
2573
|
*/
|
|
2212
|
-
async startRecording() {
|
|
2213
|
-
if (this.recording || this.startingRecording ||
|
|
2574
|
+
async startRecording(journey, options = {}) {
|
|
2575
|
+
if (this.recording || this.startingRecording || this.recordingSaving)
|
|
2214
2576
|
return;
|
|
2577
|
+
this.closeCameraPanel(false);
|
|
2578
|
+
if (journey && this.recordingDraft) {
|
|
2579
|
+
this.askToDiscardRecording(true);
|
|
2580
|
+
return;
|
|
2581
|
+
}
|
|
2582
|
+
if (!journey && (!this.draft || this.sending === 'draft'))
|
|
2583
|
+
return;
|
|
2584
|
+
const pinDraft = journey ? null : this.draft;
|
|
2215
2585
|
this.startingRecording = true;
|
|
2216
|
-
const refuse = (message) => {
|
|
2586
|
+
const refuse = (message) => {
|
|
2587
|
+
if (journey)
|
|
2588
|
+
this.showReviewerNotice(message);
|
|
2589
|
+
else {
|
|
2590
|
+
this.draftTray.notice = message;
|
|
2591
|
+
this.render();
|
|
2592
|
+
}
|
|
2593
|
+
};
|
|
2217
2594
|
try {
|
|
2218
|
-
const limit = await api.recordingLimit();
|
|
2595
|
+
const [limit, storage, cameraLimit] = await Promise.all([api.recordingLimit(), api.storageStatus().catch(() => null), journey ? api.cameraLimit() : Promise.resolve(null)]);
|
|
2219
2596
|
this.recordingLimit = limit;
|
|
2597
|
+
this.cameraLimit = cameraLimit;
|
|
2598
|
+
this.storage = storage;
|
|
2599
|
+
if (storage?.full && limit?.available) {
|
|
2600
|
+
this.openStorageDialog();
|
|
2601
|
+
return;
|
|
2602
|
+
}
|
|
2603
|
+
if (!journey && this.draft !== pinDraft)
|
|
2604
|
+
return;
|
|
2220
2605
|
if (!limit?.available) {
|
|
2221
2606
|
refuse('Recording is not available');
|
|
2222
2607
|
return;
|
|
2223
2608
|
}
|
|
2224
|
-
const recorder = new Recorder(limit, '[data-feedback-overlay]', (elapsed) => this.showRecordingTime(elapsed));
|
|
2609
|
+
const recorder = new Recorder(limit, '[data-feedback-overlay]', (elapsed) => this.showRecordingTime(elapsed), api.recordingOrigin());
|
|
2225
2610
|
const from = this.state.mode;
|
|
2226
|
-
|
|
2611
|
+
// The saved camera and microphone choices, for Record and Alt+Shift+R alike: with both off this is the plain page recording.
|
|
2612
|
+
let camera = null;
|
|
2613
|
+
const prefs = loadCameraPrefs();
|
|
2614
|
+
if (journey && !options.pageOnly && cameraLimit?.available && !touchScreen() && (prefs.camera || prefs.mic)) {
|
|
2615
|
+
const opened = await CameraCapture.open(this.root, prefs, cameraLimit.bytes, (move, final) => {
|
|
2616
|
+
recorder.emitCustom('ontrackd-camera', move);
|
|
2617
|
+
if (final && camera?.bubble) {
|
|
2618
|
+
saveCameraPrefs({ ...loadCameraPrefs(), at: camera.bubble.centre });
|
|
2619
|
+
}
|
|
2620
|
+
});
|
|
2621
|
+
camera = opened.capture;
|
|
2622
|
+
if (opened.problems.length)
|
|
2623
|
+
this.showReviewerNotice(`${opened.problems[0]}${camera ? '' : ' Recording the page only.'}`);
|
|
2624
|
+
}
|
|
2625
|
+
const recording = {
|
|
2626
|
+
recorder, journey, from, limit, elapsed: 0, route: location.pathname,
|
|
2627
|
+
moved: false, countdown: COUNTDOWN_SECONDS, ...(camera ? { camera } : {}),
|
|
2628
|
+
};
|
|
2227
2629
|
this.recording = recording;
|
|
2228
2630
|
// The page as it is without the pin cursor and the highlight: that is where the recording begins.
|
|
2229
2631
|
this.state.setMode('visible');
|
|
2632
|
+
this.render();
|
|
2633
|
+
this.root.querySelector('[data-fb-action="stop-recording"]')?.focus();
|
|
2634
|
+
if (!await this.countDown(recording)) {
|
|
2635
|
+
camera?.dispose();
|
|
2636
|
+
return;
|
|
2637
|
+
}
|
|
2638
|
+
if (recording.journey) {
|
|
2639
|
+
recording.route = location.pathname;
|
|
2640
|
+
recording.url = remoteFeedbackStatus ? pageUrl(window.location.href, { query: false }) ?? undefined : undefined;
|
|
2641
|
+
}
|
|
2230
2642
|
try {
|
|
2231
2643
|
await recorder.start();
|
|
2232
2644
|
}
|
|
2233
2645
|
catch {
|
|
2646
|
+
camera?.dispose();
|
|
2647
|
+
if (this.recording !== recording)
|
|
2648
|
+
return;
|
|
2234
2649
|
this.recording = null;
|
|
2235
2650
|
this.state.setMode(from);
|
|
2651
|
+
if (this.draft)
|
|
2652
|
+
this.settleDraft(recording.route);
|
|
2236
2653
|
refuse('Could not start recording');
|
|
2237
2654
|
return;
|
|
2238
2655
|
}
|
|
2239
|
-
|
|
2656
|
+
// Cancelled at zero, while it loaded: it is stopped, and what it recorded is dropped.
|
|
2657
|
+
if (this.recording !== recording) {
|
|
2658
|
+
camera?.dispose();
|
|
2659
|
+
recorder.stop();
|
|
2660
|
+
return;
|
|
2661
|
+
}
|
|
2662
|
+
recording.countdown = null;
|
|
2663
|
+
if (camera) {
|
|
2664
|
+
if (!camera.start()) {
|
|
2665
|
+
recording.camera = undefined;
|
|
2666
|
+
this.showReviewerNotice('The camera could not be recorded here. Recording the page only.');
|
|
2667
|
+
}
|
|
2668
|
+
else if (camera.bubble)
|
|
2669
|
+
recorder.emitCustom('ontrackd-camera', camera.bubble.move);
|
|
2670
|
+
}
|
|
2671
|
+
void recorder.ended.then(async (end) => {
|
|
2672
|
+
const captured = recording.camera ? await recording.camera.finish() : null;
|
|
2673
|
+
this.recordingEnded(recording, end, captured);
|
|
2674
|
+
});
|
|
2240
2675
|
this.render();
|
|
2241
2676
|
this.root.querySelector('[data-fb-action="stop-recording"]')?.focus();
|
|
2242
2677
|
}
|
|
@@ -2244,18 +2679,83 @@ class FeedbackOverlay {
|
|
|
2244
2679
|
this.startingRecording = false;
|
|
2245
2680
|
}
|
|
2246
2681
|
}
|
|
2247
|
-
|
|
2682
|
+
/**
|
|
2683
|
+
* The page was the reviewer's (a recording, or the count before it): the draft is where they are. Route changes were not heard,
|
|
2684
|
+
* so its elements may have come back mounted again; and if it ended on another page where what the comment was about is not,
|
|
2685
|
+
* the comment is written here. An element on the page without a box (display: none) is not there either.
|
|
2686
|
+
*/
|
|
2687
|
+
settleDraft(route) {
|
|
2688
|
+
if (!this.draft)
|
|
2689
|
+
return;
|
|
2690
|
+
this.relocateDraft();
|
|
2691
|
+
const shown = () => (this.draft?.candidates[0]?.element.getClientRects().length ?? 0) > 0 && this.draftAnchorVisible();
|
|
2692
|
+
if (location.pathname === route || shown())
|
|
2693
|
+
return;
|
|
2694
|
+
if (this.anchorDraftHere())
|
|
2695
|
+
this.showReviewerNotice('The comment is on this page now.');
|
|
2696
|
+
else {
|
|
2697
|
+
this.draftHeldFor = route;
|
|
2698
|
+
this.showReviewerNotice(`Go back to ${route} to finish the comment.`);
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
/** Counts down on the screen; true when it reached zero, false when the reviewer cancelled it. */
|
|
2702
|
+
countDown(recording) {
|
|
2703
|
+
return new Promise((resolve) => {
|
|
2704
|
+
const timer = window.setInterval(() => {
|
|
2705
|
+
recording.countdown = (recording.countdown ?? 1) - 1;
|
|
2706
|
+
this.showCountdown();
|
|
2707
|
+
if (recording.countdown > 0)
|
|
2708
|
+
return;
|
|
2709
|
+
// Zero is shown while the recorder loads; cancelling then stops it as soon as it has (startRecording).
|
|
2710
|
+
window.clearInterval(timer);
|
|
2711
|
+
resolve(true);
|
|
2712
|
+
}, 1000);
|
|
2713
|
+
recording.cancel = () => {
|
|
2714
|
+
window.clearInterval(timer);
|
|
2715
|
+
this.recording = null;
|
|
2716
|
+
this.state.setMode(recording.from);
|
|
2717
|
+
if (this.draft)
|
|
2718
|
+
this.settleDraft(recording.route);
|
|
2719
|
+
this.render();
|
|
2720
|
+
if (this.draft)
|
|
2721
|
+
this.focusComposer('draft');
|
|
2722
|
+
resolve(false);
|
|
2723
|
+
};
|
|
2724
|
+
this.showCountdown();
|
|
2725
|
+
});
|
|
2726
|
+
}
|
|
2727
|
+
recordingEnded(recording, end, captured = null) {
|
|
2248
2728
|
if (this.recording !== recording)
|
|
2249
2729
|
return;
|
|
2250
2730
|
this.recording = null;
|
|
2251
2731
|
this.state.setMode(recording.from);
|
|
2252
|
-
if (this.draft
|
|
2253
|
-
this.
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2732
|
+
if (this.draft)
|
|
2733
|
+
this.settleDraft(recording.route);
|
|
2734
|
+
if (recording.journey) {
|
|
2735
|
+
if (!end.ok) {
|
|
2736
|
+
this.showReviewerNotice(end.message);
|
|
2737
|
+
this.render();
|
|
2738
|
+
return;
|
|
2739
|
+
}
|
|
2740
|
+
this.recordingDraft = {
|
|
2741
|
+
...end,
|
|
2742
|
+
...(captured?.file ? { camera: captured.file } : {}),
|
|
2743
|
+
route: recording.route,
|
|
2744
|
+
...(recording.url ? { url: recording.url } : {}),
|
|
2745
|
+
createIdentity: { id: newId('cmt'), idempotencyKey: newIdempotencyKey() },
|
|
2746
|
+
};
|
|
2747
|
+
this.recordingError = end.reason === 'user' ? null
|
|
2748
|
+
: end.reason === 'limit' ? `Stopped at ${clock(recording.limit.seconds * 1000)}, the most your plan records`
|
|
2749
|
+
: 'Stopped: the recording got too long';
|
|
2750
|
+
if (captured?.tooBig)
|
|
2751
|
+
this.recordingError = `${this.recordingError ? `${this.recordingError}. ` : ''}The camera video was over your plan's size and was left out. The page recording is kept.`;
|
|
2752
|
+
this.recordingUiFailed = false;
|
|
2753
|
+
this.recordingDiscard = null;
|
|
2754
|
+
this.recordingTray.reset();
|
|
2755
|
+
this.recordingTray.addRecording(end.file, end.durationMs);
|
|
2756
|
+
this.render();
|
|
2757
|
+
void this.mountRecordingUi(this.recordingDraft);
|
|
2758
|
+
return;
|
|
2259
2759
|
}
|
|
2260
2760
|
if (this.draft && end.ok) {
|
|
2261
2761
|
this.draftTray.addRecording(end.file, end.durationMs);
|
|
@@ -2272,6 +2772,339 @@ class FeedbackOverlay {
|
|
|
2272
2772
|
this.render();
|
|
2273
2773
|
this.focusComposer('draft');
|
|
2274
2774
|
}
|
|
2775
|
+
loadRecordingUi() {
|
|
2776
|
+
if (this.recordingUiLoad)
|
|
2777
|
+
return this.recordingUiLoad;
|
|
2778
|
+
const attempt = ++this.recordingUiAttempt;
|
|
2779
|
+
const editorPath = typeof __FEEDBACK_RECORDING_EDITOR_MODULE__ === 'string'
|
|
2780
|
+
? __FEEDBACK_RECORDING_EDITOR_MODULE__ : './recordingEditor.js';
|
|
2781
|
+
const playerPath = typeof __FEEDBACK_RECORDING_PLAYER_MODULE__ === 'string'
|
|
2782
|
+
? __FEEDBACK_RECORDING_PLAYER_MODULE__ : './recordingPlayer.js';
|
|
2783
|
+
this.recordingUiLoad = Promise.all([
|
|
2784
|
+
import(/* @vite-ignore */ retryableModulePath(editorPath, attempt)),
|
|
2785
|
+
import(/* @vite-ignore */ retryableModulePath(playerPath, attempt)),
|
|
2786
|
+
]).then(([editor, player]) => {
|
|
2787
|
+
const ui = { RecordingEditor: editor.RecordingEditor, RecordingPlayer: player.RecordingPlayer };
|
|
2788
|
+
this.recordingUi = ui;
|
|
2789
|
+
return ui;
|
|
2790
|
+
}).catch((error) => { this.recordingUiLoad = null; throw error; });
|
|
2791
|
+
return this.recordingUiLoad;
|
|
2792
|
+
}
|
|
2793
|
+
async mountRecordingUi(draft) {
|
|
2794
|
+
try {
|
|
2795
|
+
const ui = this.recordingUi ?? await this.loadRecordingUi();
|
|
2796
|
+
if (this.recordingDraft !== draft)
|
|
2797
|
+
return;
|
|
2798
|
+
const editorHost = this.recordingDialog.querySelector('[data-fb-recording-editor-host]');
|
|
2799
|
+
const playerHost = this.recordingDialog.querySelector('[data-fb-recording-player]');
|
|
2800
|
+
if (!editorHost || !playerHost)
|
|
2801
|
+
return;
|
|
2802
|
+
const focusEditor = !this.recordingEditor;
|
|
2803
|
+
this.recordingEditor ??= new ui.RecordingEditor(editorHost);
|
|
2804
|
+
// The paperclip joins the formatting toolbar once it exists; it waits beside the editor until then,
|
|
2805
|
+
// so a recording whose editor failed to load can still take files.
|
|
2806
|
+
const attach = this.recordingDialog.querySelector('[data-fb-recording-attach] [data-fb-action="attach"]');
|
|
2807
|
+
if (attach)
|
|
2808
|
+
editorHost.querySelector('.fb-recording-editor__toolbar')?.append(attach);
|
|
2809
|
+
this.renderRecordingDialog();
|
|
2810
|
+
if (focusEditor)
|
|
2811
|
+
this.recordingEditor.element.focus();
|
|
2812
|
+
if (!this.recordingPlayer) {
|
|
2813
|
+
const camera = draft.camera ? { file: Promise.resolve(draft.camera), voice: draft.camera.type.startsWith('audio/') } : null;
|
|
2814
|
+
const player = new ui.RecordingPlayer(playerHost, draft.file, undefined, { w: window.innerWidth, h: window.innerHeight }, camera);
|
|
2815
|
+
this.recordingPlayer = player;
|
|
2816
|
+
try {
|
|
2817
|
+
await player.ready;
|
|
2818
|
+
}
|
|
2819
|
+
catch (error) {
|
|
2820
|
+
if (this.recordingPlayer === player) {
|
|
2821
|
+
player.destroy();
|
|
2822
|
+
this.recordingPlayer = null;
|
|
2823
|
+
}
|
|
2824
|
+
throw error;
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
if (this.recordingDraft === draft) {
|
|
2828
|
+
this.recordingUiFailed = false;
|
|
2829
|
+
this.renderRecordingDialog();
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
catch {
|
|
2833
|
+
if (this.recordingDraft !== draft)
|
|
2834
|
+
return;
|
|
2835
|
+
this.recordingUiFailed = true;
|
|
2836
|
+
this.recordingError = 'The recording could not be shown. You can try again or save it without a description.';
|
|
2837
|
+
this.renderRecordingDialog();
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
askToDiscardRecording(restart) {
|
|
2841
|
+
if (!this.recordingDraft || this.recordingSaving)
|
|
2842
|
+
return;
|
|
2843
|
+
const active = this.root.activeElement;
|
|
2844
|
+
this.recordingDiscardFocus = active instanceof HTMLElement && this.recordingDialog.contains(active) ? active : null;
|
|
2845
|
+
this.recordingDiscard = { restart };
|
|
2846
|
+
this.renderRecordingDialog();
|
|
2847
|
+
this.recordingDialog.querySelector('[data-fb-action="keep-recording"]')?.focus();
|
|
2848
|
+
}
|
|
2849
|
+
keepRecording() {
|
|
2850
|
+
const restore = this.recordingDiscardFocus;
|
|
2851
|
+
this.recordingDiscard = null;
|
|
2852
|
+
this.recordingDiscardFocus = null;
|
|
2853
|
+
this.renderRecordingDialog();
|
|
2854
|
+
if (restore?.isConnected && !restore.inert)
|
|
2855
|
+
restore.focus();
|
|
2856
|
+
else
|
|
2857
|
+
this.recordingEditor?.element.focus();
|
|
2858
|
+
}
|
|
2859
|
+
discardRecording() {
|
|
2860
|
+
const cameraUpload = this.recordingDraft?.cameraUpload;
|
|
2861
|
+
if (cameraUpload)
|
|
2862
|
+
void api.discardUpload(cameraUpload.id).catch(() => undefined);
|
|
2863
|
+
this.recordingPlayer?.destroy();
|
|
2864
|
+
this.recordingPlayer = null;
|
|
2865
|
+
this.recordingEditor = null;
|
|
2866
|
+
this.recordingTray.reset();
|
|
2867
|
+
this.recordingDraft = null;
|
|
2868
|
+
this.recordingDiscard = null;
|
|
2869
|
+
this.recordingDiscardFocus = null;
|
|
2870
|
+
this.pendingRecordingSave = false;
|
|
2871
|
+
this.recordingUiFailed = false;
|
|
2872
|
+
this.recordingError = null;
|
|
2873
|
+
this.render();
|
|
2874
|
+
}
|
|
2875
|
+
async saveRecording() {
|
|
2876
|
+
const draft = this.recordingDraft;
|
|
2877
|
+
if (!draft || this.recordingSaving)
|
|
2878
|
+
return;
|
|
2879
|
+
const body = this.recordingEditor?.markdown() ?? '';
|
|
2880
|
+
if (this.recordingTray.blocked)
|
|
2881
|
+
this.recordingTray.retryFailed();
|
|
2882
|
+
this.recordingSaving = true;
|
|
2883
|
+
this.recordingError = null;
|
|
2884
|
+
this.renderRecordingDialog();
|
|
2885
|
+
await this.recordingTray.settled();
|
|
2886
|
+
if (this.recordingDraft !== draft) {
|
|
2887
|
+
this.recordingSaving = false;
|
|
2888
|
+
return;
|
|
2889
|
+
}
|
|
2890
|
+
if (this.recordingTray.blocked) {
|
|
2891
|
+
this.recordingSaving = false;
|
|
2892
|
+
this.recordingError = 'One file did not upload. Try Save again.';
|
|
2893
|
+
this.renderRecordingDialog();
|
|
2894
|
+
return;
|
|
2895
|
+
}
|
|
2896
|
+
const attachmentIds = this.recordingTray.ids();
|
|
2897
|
+
const recordingUploads = this.recordingTray.items.filter((item) => item.kind === 'recording' && item.upload);
|
|
2898
|
+
if (recordingUploads.length !== 1) {
|
|
2899
|
+
this.recordingSaving = false;
|
|
2900
|
+
this.recordingError = 'The recording did not upload. Try Save again.';
|
|
2901
|
+
this.renderRecordingDialog();
|
|
2902
|
+
return;
|
|
2903
|
+
}
|
|
2904
|
+
// The camera video is paired with the recording upload it belongs to. A failure other than a full storage or an
|
|
2905
|
+
// expired session costs only the camera: the page recording is saved without it.
|
|
2906
|
+
const recordingId = recordingUploads[0].upload.id;
|
|
2907
|
+
const cameraIds = [];
|
|
2908
|
+
if (draft.camera) {
|
|
2909
|
+
if (draft.cameraUpload && draft.cameraUpload.pairedWith !== recordingId) {
|
|
2910
|
+
void api.discardUpload(draft.cameraUpload.id).catch(() => undefined);
|
|
2911
|
+
draft.cameraUpload = undefined;
|
|
2912
|
+
}
|
|
2913
|
+
if (!draft.cameraUpload) {
|
|
2914
|
+
try {
|
|
2915
|
+
const upload = await api.uploadAttachment(draft.camera, () => undefined, { pairsWith: recordingId });
|
|
2916
|
+
if (this.recordingDraft !== draft) {
|
|
2917
|
+
void api.discardUpload(upload.id).catch(() => undefined);
|
|
2918
|
+
this.recordingSaving = false;
|
|
2919
|
+
return;
|
|
2920
|
+
}
|
|
2921
|
+
draft.cameraUpload = { id: upload.id, pairedWith: recordingId };
|
|
2922
|
+
}
|
|
2923
|
+
catch (error) {
|
|
2924
|
+
if (this.recordingDraft !== draft) {
|
|
2925
|
+
this.recordingSaving = false;
|
|
2926
|
+
return;
|
|
2927
|
+
}
|
|
2928
|
+
if (error instanceof SessionExpiredError && this.shared) {
|
|
2929
|
+
this.recordingSaving = false;
|
|
2930
|
+
this.pendingRecordingSave = true;
|
|
2931
|
+
this.handleSessionExpired();
|
|
2932
|
+
return;
|
|
2933
|
+
}
|
|
2934
|
+
if (error instanceof UploadRefused && error.reason === 'storage_full') {
|
|
2935
|
+
this.recordingSaving = false;
|
|
2936
|
+
this.renderRecordingDialog();
|
|
2937
|
+
void this.refusedForStorage(draft.file);
|
|
2938
|
+
return;
|
|
2939
|
+
}
|
|
2940
|
+
draft.camera = undefined;
|
|
2941
|
+
this.recordingError = 'The camera video could not be uploaded, so it was left out. The page recording is kept.';
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
if (draft.cameraUpload)
|
|
2945
|
+
cameraIds.push(draft.cameraUpload.id);
|
|
2946
|
+
}
|
|
2947
|
+
let created;
|
|
2948
|
+
try {
|
|
2949
|
+
created = await api.createComment({
|
|
2950
|
+
kind: 'recording',
|
|
2951
|
+
author: this.authorName,
|
|
2952
|
+
authorId: this.identity?.id ?? null,
|
|
2953
|
+
body,
|
|
2954
|
+
anchor: null,
|
|
2955
|
+
context: {
|
|
2956
|
+
route: draft.route,
|
|
2957
|
+
viewport: { w: window.innerWidth, h: window.innerHeight },
|
|
2958
|
+
...(draft.url ? { url: draft.url } : {}),
|
|
2959
|
+
},
|
|
2960
|
+
recording: { durationMs: draft.durationMs, startedAt: draft.startedAt },
|
|
2961
|
+
journey: draft.journey,
|
|
2962
|
+
...(draft.journeyTruncated ? { journeyTruncated: true } : {}),
|
|
2963
|
+
attachmentIds: [...attachmentIds, ...cameraIds],
|
|
2964
|
+
}, draft.createIdentity);
|
|
2965
|
+
}
|
|
2966
|
+
catch (error) {
|
|
2967
|
+
this.recordingSaving = false;
|
|
2968
|
+
const unavailable = unavailableFile(error);
|
|
2969
|
+
if (unavailable && draft.cameraUpload?.id === unavailable)
|
|
2970
|
+
draft.cameraUpload = undefined;
|
|
2971
|
+
const refusedRecording = recordingAttachmentRefusal(error);
|
|
2972
|
+
if (unavailable && unavailable !== cameraIds[0])
|
|
2973
|
+
this.recordingTray.fail(unavailable, 'No longer available: remove it and add it again');
|
|
2974
|
+
if (refusedRecording) {
|
|
2975
|
+
if (recordingId)
|
|
2976
|
+
this.recordingTray.fail(recordingId, 'Upload expired: Save again to retry');
|
|
2977
|
+
// This refusal is definitive and can be cached under the idempotency key. A new upload
|
|
2978
|
+
// therefore gets a new create identity; unknown/network failures keep the old one.
|
|
2979
|
+
draft.createIdentity = { id: newId('cmt'), idempotencyKey: newIdempotencyKey() };
|
|
2980
|
+
}
|
|
2981
|
+
this.recordingError = unavailable
|
|
2982
|
+
? 'One file could not be sent. Remove it and try again.'
|
|
2983
|
+
: refusedRecording
|
|
2984
|
+
? 'The recording upload expired. Save again to retry it.'
|
|
2985
|
+
: 'Not saved. Your recording is still here, try again.';
|
|
2986
|
+
if (error instanceof SessionExpiredError && this.shared) {
|
|
2987
|
+
this.pendingRecordingSave = true;
|
|
2988
|
+
this.handleSessionExpired();
|
|
2989
|
+
}
|
|
2990
|
+
else
|
|
2991
|
+
this.renderRecordingDialog();
|
|
2992
|
+
return;
|
|
2993
|
+
}
|
|
2994
|
+
this.recordingSaving = false;
|
|
2995
|
+
this.recordingPlayer?.destroy();
|
|
2996
|
+
this.recordingPlayer = null;
|
|
2997
|
+
this.recordingEditor = null;
|
|
2998
|
+
this.recordingTray.clear();
|
|
2999
|
+
this.recordingDraft = null;
|
|
3000
|
+
this.recordingDiscard = null;
|
|
3001
|
+
this.recordingDiscardFocus = null;
|
|
3002
|
+
this.pendingRecordingSave = false;
|
|
3003
|
+
this.recordingUiFailed = false;
|
|
3004
|
+
this.recordingError = null;
|
|
3005
|
+
this.stickyId = created.id;
|
|
3006
|
+
const [shown] = renderable([created]);
|
|
3007
|
+
if (shown)
|
|
3008
|
+
this.state.applyLocal((comments) => [shown, ...comments.filter((item) => item.id !== shown.id)]);
|
|
3009
|
+
this.render();
|
|
3010
|
+
void this.state.refresh();
|
|
3011
|
+
}
|
|
3012
|
+
renderRecordingDialog() {
|
|
3013
|
+
const draft = this.recordingDraft;
|
|
3014
|
+
this.recordingDialog.hidden = Boolean(draft && this.signIn);
|
|
3015
|
+
if (!draft) {
|
|
3016
|
+
this.recordingDialog.replaceChildren();
|
|
3017
|
+
return;
|
|
3018
|
+
}
|
|
3019
|
+
let dialog = this.recordingDialog.querySelector('[data-fb-recording-dialog]');
|
|
3020
|
+
if (!dialog) {
|
|
3021
|
+
this.recordingDialog.innerHTML = recordingDialogMarkup();
|
|
3022
|
+
dialog = this.recordingDialog.querySelector('[data-fb-recording-dialog]');
|
|
3023
|
+
}
|
|
3024
|
+
const error = dialog.querySelector('[data-fb-recording-error]');
|
|
3025
|
+
if (error) {
|
|
3026
|
+
error.textContent = this.recordingError ?? '';
|
|
3027
|
+
error.hidden = !this.recordingError;
|
|
3028
|
+
}
|
|
3029
|
+
const oldRetry = dialog.querySelector('[data-fb-action="retry-recording-ui"]');
|
|
3030
|
+
if (this.recordingUiFailed && !oldRetry) {
|
|
3031
|
+
error?.insertAdjacentHTML('afterend', '<button type="button" class="fb-threadblock__cancel" data-fb-action="retry-recording-ui">Try loading the editor and player again</button>');
|
|
3032
|
+
}
|
|
3033
|
+
else if (!this.recordingUiFailed)
|
|
3034
|
+
oldRetry?.remove();
|
|
3035
|
+
const tray = dialog.querySelector('[data-fb-recording-tray]');
|
|
3036
|
+
if (tray)
|
|
3037
|
+
tray.innerHTML = trayMarkup(this.recordingTray, 'recording');
|
|
3038
|
+
const blocked = this.recordingSaving || this.recordingDiscard !== null;
|
|
3039
|
+
this.recordingEditor?.setDisabled(blocked);
|
|
3040
|
+
const save = dialog.querySelector('[data-fb-action="save-recording"]');
|
|
3041
|
+
if (save) {
|
|
3042
|
+
save.disabled = blocked || (!this.recordingEditor && !this.recordingUiFailed);
|
|
3043
|
+
save.setAttribute('aria-busy', String(this.recordingSaving));
|
|
3044
|
+
save.textContent = this.recordingSaving ? 'Saving…' : 'Save';
|
|
3045
|
+
}
|
|
3046
|
+
const cancel = dialog.querySelector('[data-fb-action="cancel-recording"]');
|
|
3047
|
+
if (cancel)
|
|
3048
|
+
cancel.disabled = blocked;
|
|
3049
|
+
const attach = dialog.querySelector('[data-fb-action="attach"]');
|
|
3050
|
+
if (attach)
|
|
3051
|
+
attach.disabled = blocked;
|
|
3052
|
+
const card = dialog.querySelector('.fb-recording-dialog__card');
|
|
3053
|
+
if (card) {
|
|
3054
|
+
card.inert = this.recordingDiscard !== null;
|
|
3055
|
+
card.setAttribute('aria-hidden', String(this.recordingDiscard !== null));
|
|
3056
|
+
}
|
|
3057
|
+
const existing = dialog.querySelector('[data-fb-recording-discard]');
|
|
3058
|
+
if (this.recordingDiscard && !existing)
|
|
3059
|
+
dialog.insertAdjacentHTML('beforeend', recordingDiscardMarkup());
|
|
3060
|
+
else if (!this.recordingDiscard)
|
|
3061
|
+
existing?.remove();
|
|
3062
|
+
}
|
|
3063
|
+
async mountThreadRecording(comment, generation) {
|
|
3064
|
+
const attachment = comment.attachments?.find((item) => item.kind === 'recording');
|
|
3065
|
+
const host = this.popover.querySelector('[data-fb-recording-thread-player]');
|
|
3066
|
+
if (!attachment || !host)
|
|
3067
|
+
return;
|
|
3068
|
+
const key = `${comment.id}:${attachment.id}`;
|
|
3069
|
+
if (this.threadRecordingFile?.key !== key) {
|
|
3070
|
+
this.threadRecordingFile?.abort.abort();
|
|
3071
|
+
const abort = new AbortController();
|
|
3072
|
+
// The camera or voice file recorded with it is fetched beside it; the replay does not wait for it.
|
|
3073
|
+
const video = comment.attachments?.find((item) => item.kind === 'video' && item.pairsWith === attachment.id);
|
|
3074
|
+
const camera = video ? { file: api.attachmentBlob(comment.id, video.id, abort.signal), voice: video.mime.startsWith('audio/') } : null;
|
|
3075
|
+
camera?.file.catch(() => undefined);
|
|
3076
|
+
this.threadRecordingFile = { key, abort, promise: api.attachmentBlob(comment.id, attachment.id, abort.signal), camera };
|
|
3077
|
+
}
|
|
3078
|
+
const loading = this.threadRecordingFile;
|
|
3079
|
+
try {
|
|
3080
|
+
const [ui, file] = await Promise.all([this.recordingUi ?? this.loadRecordingUi(), loading.promise]);
|
|
3081
|
+
if (this.threadRecordingFile === loading)
|
|
3082
|
+
this.threadRecordingFile = null;
|
|
3083
|
+
if (generation !== this.threadRecordingGeneration || this.state.openThreadId !== comment.id || !host.isConnected)
|
|
3084
|
+
return;
|
|
3085
|
+
const player = new ui.RecordingPlayer(host, file, undefined, comment.context?.viewport, loading.camera);
|
|
3086
|
+
this.threadRecordingPlayer = player;
|
|
3087
|
+
this.threadRecordingPlayerId = comment.id;
|
|
3088
|
+
try {
|
|
3089
|
+
await player.ready;
|
|
3090
|
+
}
|
|
3091
|
+
catch (error) {
|
|
3092
|
+
if (this.threadRecordingPlayer === player) {
|
|
3093
|
+
this.threadRecordingPlayer = null;
|
|
3094
|
+
this.threadRecordingPlayerId = null;
|
|
3095
|
+
}
|
|
3096
|
+
throw error;
|
|
3097
|
+
}
|
|
3098
|
+
}
|
|
3099
|
+
catch {
|
|
3100
|
+
if (this.threadRecordingFile === loading) {
|
|
3101
|
+
loading.abort.abort();
|
|
3102
|
+
this.threadRecordingFile = null;
|
|
3103
|
+
}
|
|
3104
|
+
if (generation === this.threadRecordingGeneration && host.isConnected)
|
|
3105
|
+
host.textContent = 'The recording could not be played.';
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
2275
3108
|
/** The indicator that says the page is being recorded: a dot, the time, and the button that stops it. */
|
|
2276
3109
|
renderRecorder() {
|
|
2277
3110
|
const pill = this.root.querySelector('[data-fb-recorder]');
|
|
@@ -2280,16 +3113,38 @@ class FeedbackOverlay {
|
|
|
2280
3113
|
if (!this.recording) {
|
|
2281
3114
|
pill.hidden = true;
|
|
2282
3115
|
pill.innerHTML = '';
|
|
3116
|
+
delete pill.dataset.phase;
|
|
3117
|
+
this.showCountdown();
|
|
2283
3118
|
return;
|
|
2284
3119
|
}
|
|
2285
|
-
|
|
3120
|
+
const phase = this.recording.countdown === null ? 'recording' : 'countdown';
|
|
3121
|
+
if (!pill.hidden && pill.dataset.phase === phase)
|
|
2286
3122
|
return;
|
|
2287
3123
|
pill.hidden = false;
|
|
2288
|
-
|
|
2289
|
-
|
|
3124
|
+
pill.dataset.phase = phase;
|
|
3125
|
+
// Each is announced once, when it begins; the time and the seconds are not read out as they change.
|
|
3126
|
+
pill.innerHTML = phase === 'countdown'
|
|
3127
|
+
? `<span class="fb-sr" role="status">Recording starts in ${COUNTDOWN_SECONDS} seconds. Cancel recording is the last button on the page.</span>
|
|
3128
|
+
<span class="fb-recorder__dot" aria-hidden="true"></span><span class="fb-recorder__label" aria-hidden="true">Recording in <span data-fb-countdown-text>${this.recording.countdown}</span></span>
|
|
3129
|
+
<button type="button" class="fb-recorder__stop" data-fb-action="stop-recording" aria-label="Cancel recording">${icon('close', 15)}</button>`
|
|
3130
|
+
: `<span class="fb-sr" role="status">Recording started. Stop recording is the last button on the page.</span>
|
|
2290
3131
|
<span class="fb-recorder__dot" aria-hidden="true"></span><span class="fb-recorder__label" aria-hidden="true">Recording</span>
|
|
2291
3132
|
<span class="fb-recorder__time" data-fb-recorder-time aria-hidden="true">${clock(0)} / ${clock(this.recording.limit.seconds * 1000)}</span>
|
|
2292
|
-
<button type="button" class="fb-recorder__stop" data-fb-action="stop-recording" aria-label="Stop recording"
|
|
3133
|
+
<button type="button" class="fb-recorder__stop" data-fb-action="stop-recording" aria-label="Stop recording">${icon('stop', 14)}</button>`;
|
|
3134
|
+
this.showCountdown();
|
|
3135
|
+
}
|
|
3136
|
+
/** The seconds left, big on the page and in the indicator; both gone once the recording starts. */
|
|
3137
|
+
showCountdown() {
|
|
3138
|
+
const big = this.root.querySelector('[data-fb-countdown]');
|
|
3139
|
+
if (!big)
|
|
3140
|
+
return;
|
|
3141
|
+
const left = this.recording?.countdown;
|
|
3142
|
+
big.hidden = left == null;
|
|
3143
|
+
if (left != null)
|
|
3144
|
+
big.textContent = String(left);
|
|
3145
|
+
const text = this.root.querySelector('[data-fb-countdown-text]');
|
|
3146
|
+
if (text && left != null)
|
|
3147
|
+
text.textContent = String(left);
|
|
2293
3148
|
}
|
|
2294
3149
|
showRecordingTime(elapsed) {
|
|
2295
3150
|
if (!this.recording)
|
|
@@ -2303,7 +3158,7 @@ class FeedbackOverlay {
|
|
|
2303
3158
|
dropTarget(event) {
|
|
2304
3159
|
const block = event.composedPath().find((node) => node instanceof HTMLElement && node.dataset.fbDrop !== undefined);
|
|
2305
3160
|
const which = block?.dataset.fbDrop;
|
|
2306
|
-
return (which === 'draft' || which === 'reply') && this.takesFiles(which) ? which : null;
|
|
3161
|
+
return (which === 'draft' || which === 'reply' || which === 'recording') && this.takesFiles(which) ? which : null;
|
|
2307
3162
|
}
|
|
2308
3163
|
/**
|
|
2309
3164
|
* Files over a composer are ours: the browser does not open them in place of the page, and the
|
|
@@ -2315,7 +3170,7 @@ class FeedbackOverlay {
|
|
|
2315
3170
|
return;
|
|
2316
3171
|
event.preventDefault();
|
|
2317
3172
|
event.stopPropagation();
|
|
2318
|
-
event.dataTransfer.dropEffect = this.sending === which ? 'none' : 'copy';
|
|
3173
|
+
event.dataTransfer.dropEffect = (which === 'recording' ? this.recordingSaving : this.sending === which) ? 'none' : 'copy';
|
|
2319
3174
|
}
|
|
2320
3175
|
onComposerDrop(event) {
|
|
2321
3176
|
const which = this.dropTarget(event);
|
|
@@ -2324,7 +3179,7 @@ class FeedbackOverlay {
|
|
|
2324
3179
|
return;
|
|
2325
3180
|
event.preventDefault();
|
|
2326
3181
|
event.stopPropagation();
|
|
2327
|
-
if (this.sending === which)
|
|
3182
|
+
if (which === 'recording' ? this.recordingSaving : this.sending === which)
|
|
2328
3183
|
return;
|
|
2329
3184
|
this.trayFor(which).add(files);
|
|
2330
3185
|
}
|
|
@@ -2332,7 +3187,7 @@ class FeedbackOverlay {
|
|
|
2332
3187
|
onComposerPaste(event) {
|
|
2333
3188
|
const which = this.dropTarget(event);
|
|
2334
3189
|
const images = Array.from(event.clipboardData?.files ?? []).filter((file) => file.type.startsWith('image/'));
|
|
2335
|
-
if (!which || !images.length || this.sending === which)
|
|
3190
|
+
if (!which || !images.length || (which === 'recording' ? this.recordingSaving : this.sending === which))
|
|
2336
3191
|
return;
|
|
2337
3192
|
event.stopPropagation();
|
|
2338
3193
|
// A pasted screenshot carries no text; a copied picture with a caption keeps its caption.
|
|
@@ -2622,6 +3477,11 @@ class FeedbackOverlay {
|
|
|
2622
3477
|
return;
|
|
2623
3478
|
this.state.panelOpen = false;
|
|
2624
3479
|
this.panelView = 'feedback';
|
|
3480
|
+
if (isRecording(comment)) {
|
|
3481
|
+
this.stickyId = id;
|
|
3482
|
+
this.openThread(id, from);
|
|
3483
|
+
return;
|
|
3484
|
+
}
|
|
2625
3485
|
const route = comment.context?.route;
|
|
2626
3486
|
if (route && !belongsOnThisPage(comment)) {
|
|
2627
3487
|
// Only a same-origin path: the route is stored content, and any reviewer can write it.
|
|
@@ -2665,6 +3525,12 @@ class FeedbackOverlay {
|
|
|
2665
3525
|
openThread(id, back = null) {
|
|
2666
3526
|
this.sheetBack = back;
|
|
2667
3527
|
if (this.state.openThreadId !== id) {
|
|
3528
|
+
this.threadRecordingPlayer?.destroy();
|
|
3529
|
+
this.threadRecordingPlayer = null;
|
|
3530
|
+
this.threadRecordingPlayerId = null;
|
|
3531
|
+
this.threadRecordingFile?.abort.abort();
|
|
3532
|
+
this.threadRecordingFile = null;
|
|
3533
|
+
this.threadRecordingGeneration += 1;
|
|
2668
3534
|
this.replyBody = '';
|
|
2669
3535
|
this.abandonReplyFiles();
|
|
2670
3536
|
this.clearSticky();
|
|
@@ -2677,6 +3543,12 @@ class FeedbackOverlay {
|
|
|
2677
3543
|
this.render();
|
|
2678
3544
|
}
|
|
2679
3545
|
closeThread() {
|
|
3546
|
+
this.threadRecordingPlayer?.destroy();
|
|
3547
|
+
this.threadRecordingPlayer = null;
|
|
3548
|
+
this.threadRecordingPlayerId = null;
|
|
3549
|
+
this.threadRecordingFile?.abort.abort();
|
|
3550
|
+
this.threadRecordingFile = null;
|
|
3551
|
+
this.threadRecordingGeneration += 1;
|
|
2680
3552
|
this.state.openThreadId = null;
|
|
2681
3553
|
this.sheetBack = null;
|
|
2682
3554
|
this.abandonReplyFiles();
|
|
@@ -2782,10 +3654,14 @@ class FeedbackOverlay {
|
|
|
2782
3654
|
// Its send button is disabled until the file that failed is removed; Enter does nothing either.
|
|
2783
3655
|
if (this.replyTray.blocked)
|
|
2784
3656
|
return;
|
|
2785
|
-
// SPEC 5: a reply's anchor is resolved now, not inherited from the thread.
|
|
2786
|
-
const
|
|
2787
|
-
|
|
2788
|
-
|
|
3657
|
+
// SPEC 5: a pin reply's anchor is resolved now, not inherited from the thread. Recordings have no anchor.
|
|
3658
|
+
const currentAnchor = isRecording(comment)
|
|
3659
|
+
? { file: '', line: 0, column: 0, componentName: null, domPath: '', textSnippet: null }
|
|
3660
|
+
: (() => {
|
|
3661
|
+
const element = locateComment(comment);
|
|
3662
|
+
const found = element ? anchorCandidatesFor(element)[0] : undefined;
|
|
3663
|
+
return found ? { ...found.anchor, element: describeElement(found.element) } : comment.anchor;
|
|
3664
|
+
})();
|
|
2789
3665
|
this.sending = 'reply';
|
|
2790
3666
|
this.saveError = null;
|
|
2791
3667
|
this.render();
|
|
@@ -2993,6 +3869,7 @@ class FeedbackOverlay {
|
|
|
2993
3869
|
this.updatePinCursor();
|
|
2994
3870
|
this.renderBar();
|
|
2995
3871
|
this.renderJoinDialog();
|
|
3872
|
+
this.renderRecordingDialog();
|
|
2996
3873
|
this.renderPins();
|
|
2997
3874
|
this.drawnFiles = new Set();
|
|
2998
3875
|
this.renderPopover();
|
|
@@ -3087,7 +3964,7 @@ class FeedbackOverlay {
|
|
|
3087
3964
|
delete this.bar.dataset.compact;
|
|
3088
3965
|
this.bar.innerHTML = closed
|
|
3089
3966
|
? closedBarMarkup()
|
|
3090
|
-
: openBarMarkup(this.state, this.identity, this.notifications?.unread ?? 0);
|
|
3967
|
+
: openBarMarkup(this.state, this.identity, this.notifications?.unread ?? 0, this.recordOffered(), this.cameraOffered());
|
|
3091
3968
|
// After the markup: the open bar is wider than the closed one, and the placement is
|
|
3092
3969
|
// clamped against the size it actually has.
|
|
3093
3970
|
this.placeBar();
|
|
@@ -3558,7 +4435,7 @@ class FeedbackOverlay {
|
|
|
3558
4435
|
if (!this.state.chipsVisible && !this.draft && !this.compact) {
|
|
3559
4436
|
return;
|
|
3560
4437
|
}
|
|
3561
|
-
const visible = this.visibleWithSticky().filter((comment) => belongsOnThisPage(comment));
|
|
4438
|
+
const visible = this.visibleWithSticky().filter((comment) => !isRecording(comment) && belongsOnThisPage(comment));
|
|
3562
4439
|
if (this.draft && this.draftAnchorVisible()) {
|
|
3563
4440
|
const pending = document.createElement('span');
|
|
3564
4441
|
pending.className = 'fb-pin';
|
|
@@ -3759,6 +4636,44 @@ class FeedbackOverlay {
|
|
|
3759
4636
|
this.popover.innerHTML = '';
|
|
3760
4637
|
return;
|
|
3761
4638
|
}
|
|
4639
|
+
if (isRecording(thread)) {
|
|
4640
|
+
const active = this.activeTextarea();
|
|
4641
|
+
const retainedHost = this.threadRecordingPlayer && this.threadRecordingPlayerId === thread.id
|
|
4642
|
+
? this.popover.querySelector('[data-fb-recording-thread-player]')
|
|
4643
|
+
: null;
|
|
4644
|
+
if (this.threadRecordingPlayer && !retainedHost) {
|
|
4645
|
+
this.threadRecordingPlayer.destroy();
|
|
4646
|
+
this.threadRecordingPlayer = null;
|
|
4647
|
+
this.threadRecordingPlayerId = null;
|
|
4648
|
+
this.threadRecordingGeneration += 1;
|
|
4649
|
+
}
|
|
4650
|
+
const generation = retainedHost ? this.threadRecordingGeneration : ++this.threadRecordingGeneration;
|
|
4651
|
+
const composing = this.editingKey ? this.editingBody : this.replyBody;
|
|
4652
|
+
this.popover.dataset.draft = 'false';
|
|
4653
|
+
this.popover.dataset.resolved = String(thread.status === 'resolved');
|
|
4654
|
+
const markup = recordingThreadMarkup(thread, this.identity, composing, this.editingKey, this.editingKey ? this.saveError : null, this.sending === (this.editingKey ? 'edit' : 'reply'), { offered: this.takesFiles('reply'), tray: this.editingKey || (this.claimingReplyFor && this.claimingReplyFor !== thread.id) ? '' : trayMarkup(this.replyTray, 'reply'),
|
|
4655
|
+
blocked: this.replyTray.blocked && (!this.claimingReplyFor || this.claimingReplyFor === thread.id) }, (attachment) => this.fileUrl(thread.id, attachment), this.compact && this.sheetBack !== null, mayChange(thread, this.identity, this.direct?.moderates ?? true));
|
|
4656
|
+
if (retainedHost) {
|
|
4657
|
+
/**
|
|
4658
|
+
* Everything but the player is replaced. The player holds the replay's iframe, and an
|
|
4659
|
+
* iframe taken out of the page, even for a moment, comes back as an empty document: the
|
|
4660
|
+
* cursor kept moving over a white frame.
|
|
4661
|
+
*/
|
|
4662
|
+
const fresh = document.createElement('template');
|
|
4663
|
+
fresh.innerHTML = markup;
|
|
4664
|
+
this.popover.querySelector('.fb-card-head')?.replaceWith(fresh.content.querySelector('.fb-card-head'));
|
|
4665
|
+
this.popover.querySelector('[data-fb-recording-thread-side]')?.replaceWith(fresh.content.querySelector('[data-fb-recording-thread-side]'));
|
|
4666
|
+
}
|
|
4667
|
+
else {
|
|
4668
|
+
this.popover.innerHTML = markup;
|
|
4669
|
+
}
|
|
4670
|
+
this.popover.style.display = 'block';
|
|
4671
|
+
this.positionPopover();
|
|
4672
|
+
this.restoreTextarea(this.editingKey ? '[data-fb-edit-body]' : '[data-fb-reply]', composing, this.editingKey ? !this.compact || active === 'body' : active === 'reply');
|
|
4673
|
+
if (!retainedHost)
|
|
4674
|
+
void this.mountThreadRecording(thread, generation);
|
|
4675
|
+
return;
|
|
4676
|
+
}
|
|
3762
4677
|
const active = this.activeTextarea();
|
|
3763
4678
|
const threadPin = this.pinLayer.querySelector(`.fb-pin[data-fb-value="${thread.id}"]`);
|
|
3764
4679
|
// On a phone the thread is a sheet: it does not need its pin on screen (the audit's F10, F11).
|
|
@@ -4018,6 +4933,11 @@ class FeedbackOverlay {
|
|
|
4018
4933
|
return;
|
|
4019
4934
|
}
|
|
4020
4935
|
if (this.state.openThreadId) {
|
|
4936
|
+
const comment = this.state.comments.find((item) => item.id === this.state.openThreadId);
|
|
4937
|
+
if (comment && isRecording(comment)) {
|
|
4938
|
+
this.popover.style.display = 'block';
|
|
4939
|
+
return;
|
|
4940
|
+
}
|
|
4021
4941
|
const pin = this.pinLayer.querySelector(`.fb-pin[data-fb-value="${this.state.openThreadId}"]`);
|
|
4022
4942
|
this.popover.style.display = pin ? 'block' : 'none';
|
|
4023
4943
|
}
|
|
@@ -4048,6 +4968,12 @@ class FeedbackOverlay {
|
|
|
4048
4968
|
this.popover.dataset.stackBelow = String(this.popover.getBoundingClientRect().top < 64);
|
|
4049
4969
|
return;
|
|
4050
4970
|
}
|
|
4971
|
+
// A recording has no pin to sit beside: its two-column card is centred like a dialog.
|
|
4972
|
+
if (this.popover.querySelector('.fb-recording-thread')) {
|
|
4973
|
+
this.popover.style.left = `${fit((window.innerWidth - width) / 2, width, window.innerWidth)}px`;
|
|
4974
|
+
this.popover.style.top = `${fit((window.innerHeight - height) / 2, height, window.innerHeight)}px`;
|
|
4975
|
+
return;
|
|
4976
|
+
}
|
|
4051
4977
|
const origin = this.popoverOrigin();
|
|
4052
4978
|
const gap = 12;
|
|
4053
4979
|
// Prefer below-right of the origin, flip up or left only when it would overflow.
|
|
@@ -4095,12 +5021,13 @@ class FeedbackOverlay {
|
|
|
4095
5021
|
this.panel.dataset.view = this.panelView;
|
|
4096
5022
|
if (this.panelView !== 'feedback')
|
|
4097
5023
|
this.listFilter = null;
|
|
4098
|
-
const shown = this.visibleWithSticky()
|
|
5024
|
+
const shown = this.visibleWithSticky().filter((comment) => this.kindFilter === 'all'
|
|
5025
|
+
|| (this.kindFilter === 'recording' ? isRecording(comment) : !isRecording(comment)));
|
|
4099
5026
|
const listed = this.listFilter ? shown.filter((comment) => this.listFilter.includes(comment.id)) : shown;
|
|
4100
5027
|
this.panelContent.innerHTML = panelMarkup(this.state, listed, this.selection, this.shared !== null, this.notifications, this.panelView,
|
|
4101
5028
|
// A script-tag install, on a live site: the reviewer needs a way back to being a visitor.
|
|
4102
5029
|
// A magic-link reviewer on a build preview too: leaving is how the stored key is removed.
|
|
4103
|
-
this.shared !== null && (!this.shared.buildId || this.direct !== null), this.shared?.devReviewLinks ?? false, this.listFilter ? listed.length : null);
|
|
5030
|
+
this.shared !== null && (!this.shared.buildId || this.direct !== null), this.shared?.devReviewLinks ?? false, this.listFilter ? listed.length : null, this.kindFilter);
|
|
4104
5031
|
this.positionPanelToast();
|
|
4105
5032
|
}
|
|
4106
5033
|
isOverlayEvent(event) {
|
|
@@ -4123,12 +5050,46 @@ function shellMarkup() {
|
|
|
4123
5050
|
<input type="file" multiple hidden data-fb-file-input tabindex="-1" aria-hidden="true">
|
|
4124
5051
|
<div data-fb-toast class="fb-toast" role="status"></div>
|
|
4125
5052
|
<div data-fb-recorder class="fb-recorder" hidden></div>
|
|
5053
|
+
<div data-fb-countdown class="fb-countdown" aria-hidden="true" hidden></div>
|
|
4126
5054
|
<div data-fb-bar class="fb-bar" role="toolbar" aria-label="Feedback"></div>
|
|
4127
5055
|
<div data-fb-tip class="fb-tip" role="tooltip" aria-hidden="true"></div>
|
|
5056
|
+
<div data-fb-recording-mount></div>
|
|
4128
5057
|
<!-- Last: at the same z-index as the toolbar, the full-size image covers it. -->
|
|
4129
5058
|
<div data-fb-lightbox class="fb-lightbox" role="dialog" aria-modal="true" aria-label="Image, full size" hidden></div>
|
|
4130
5059
|
`;
|
|
4131
5060
|
}
|
|
5061
|
+
function recordingDialogMarkup() {
|
|
5062
|
+
return `<div data-fb-recording-dialog class="fb-recording-dialog" role="dialog" aria-modal="true" aria-label="Recording">
|
|
5063
|
+
<section class="fb-recording-dialog__card" data-fb-drop="recording">
|
|
5064
|
+
<header class="fb-recording-dialog__head">
|
|
5065
|
+
<h2>Recording</h2>
|
|
5066
|
+
<button type="button" class="fb-icon-btn" data-fb-action="cancel-recording" aria-label="Cancel">${icon('close', 16)}</button>
|
|
5067
|
+
</header>
|
|
5068
|
+
<div class="fb-recording-dialog__columns">
|
|
5069
|
+
<div class="fb-recording-dialog__player" data-fb-recording-player>${recordingPlayerShellMarkup({ w: window.innerWidth, h: window.innerHeight })}</div>
|
|
5070
|
+
<div class="fb-recording-dialog__compose">
|
|
5071
|
+
<div data-fb-recording-error class="fb-savefail" role="alert" hidden></div>
|
|
5072
|
+
<div class="fb-recording-dialog__attach" data-fb-recording-attach>${attachButton('recording', false)}</div>
|
|
5073
|
+
<div data-fb-recording-editor-host><span class="fb-recording-loading">Loading editor…</span></div>
|
|
5074
|
+
<div data-fb-recording-tray></div>
|
|
5075
|
+
</div>
|
|
5076
|
+
</div>
|
|
5077
|
+
<footer class="fb-recording-dialog__foot">
|
|
5078
|
+
<button type="button" class="fb-recording-dialog__cancel" data-fb-action="cancel-recording">Cancel</button>
|
|
5079
|
+
<button type="button" class="fb-recording-dialog__save" data-fb-action="save-recording">Save</button>
|
|
5080
|
+
</footer>
|
|
5081
|
+
</section>
|
|
5082
|
+
</div>`;
|
|
5083
|
+
}
|
|
5084
|
+
function recordingDiscardMarkup() {
|
|
5085
|
+
return `<div class="fb-recording-discard" data-fb-recording-discard role="alertdialog" aria-modal="true" aria-label="Discard this recording?">
|
|
5086
|
+
<div class="fb-recording-discard__card">
|
|
5087
|
+
<p>Discard this recording?</p>
|
|
5088
|
+
<div><button type="button" class="fb-recording-discard__keep" data-fb-action="keep-recording">Keep</button>
|
|
5089
|
+
<button type="button" class="fb-recording-discard__drop" data-fb-action="discard-recording">Discard</button></div>
|
|
5090
|
+
</div>
|
|
5091
|
+
</div>`;
|
|
5092
|
+
}
|
|
4132
5093
|
/** Always draws something: an empty slot next to the input reads as a broken avatar. */
|
|
4133
5094
|
function composerAvatar(identity) {
|
|
4134
5095
|
return identity
|
|
@@ -4142,7 +5103,7 @@ function closedBarMarkup() {
|
|
|
4142
5103
|
return `<button type="button" data-fb-action="close-overlay" data-tip="Show feedback" data-tip-keys="${toggleKeys}"
|
|
4143
5104
|
aria-label="Show feedback" aria-keyshortcuts="Alt+Shift+F">${icon('comment', 17)}</button>`;
|
|
4144
5105
|
}
|
|
4145
|
-
function openBarMarkup(state, identity, unread = 0) {
|
|
5106
|
+
function openBarMarkup(state, identity, unread = 0, record = false, camera = false) {
|
|
4146
5107
|
const commenting = state.mode === 'commenting';
|
|
4147
5108
|
const count = state.routeCount();
|
|
4148
5109
|
unread += state.newRemoteComments;
|
|
@@ -4165,6 +5126,9 @@ function openBarMarkup(state, identity, unread = 0) {
|
|
|
4165
5126
|
* the panel, where there is room to say what it is counting.
|
|
4166
5127
|
*/
|
|
4167
5128
|
unread > 0 ? '<span class="fb-dot" aria-label="Unread feedback"></span>' : ''}</button>
|
|
5129
|
+
${record ? `<button type="button" data-fb-action="record-journey" data-tip="Record" data-tip-keys="Alt+Shift+R"
|
|
5130
|
+
aria-label="Record" aria-keyshortcuts="Alt+Shift+R">${icon('record', 17)}</button>` : ''}
|
|
5131
|
+
${record && camera ? `<button type="button" data-fb-action="camera-panel" data-tip="Camera and microphone" aria-label="Camera and microphone" aria-haspopup="dialog">${cameraIcon(17)}</button>` : ''}
|
|
4168
5132
|
${state.remoteNotice ? `<span role="status" style="font-size:11px;max-width:180px">${escapeHtml(state.remoteNotice)}</span>` : ''}
|
|
4169
5133
|
<span class="fb-sep"></span>
|
|
4170
5134
|
${identity
|
|
@@ -4498,6 +5462,21 @@ function threadMarkup(comment, identity, value, editing, editError, sending, fil
|
|
|
4498
5462
|
${threadComposerMarkup(comment, identity, value, editing, editError, sending, files)}
|
|
4499
5463
|
`;
|
|
4500
5464
|
}
|
|
5465
|
+
function recordingThreadMarkup(comment, identity, value, editing, editError, sending, files, fileUrl, back = false, changeable = true) {
|
|
5466
|
+
const markup = threadMarkup(comment, identity, value, editing, editError, sending, files, fileUrl, back, changeable);
|
|
5467
|
+
const duration = clock(comment.recording?.durationMs ?? 0);
|
|
5468
|
+
const split = markup.indexOf('<div class="fb-card-body">');
|
|
5469
|
+
// Two columns: the video on the left, the messages and the reply box on the right. The right
|
|
5470
|
+
// column is its own element so a render can swap it without touching the player beside it.
|
|
5471
|
+
return `${markup.slice(0, split)}
|
|
5472
|
+
<div class="fb-recording-thread">
|
|
5473
|
+
<div class="fb-recording-thread__media">
|
|
5474
|
+
<div class="fb-recording-thread-head"><span>Recording</span><time>${escapeHtml(duration)}</time></div>
|
|
5475
|
+
<div data-fb-recording-thread-player class="fb-recording-thread-player">${recordingPlayerShellMarkup(comment.context?.viewport)}</div>
|
|
5476
|
+
</div>
|
|
5477
|
+
<div class="fb-recording-thread__side" data-fb-recording-thread-side>${markup.slice(split)}</div>
|
|
5478
|
+
</div>`;
|
|
5479
|
+
}
|
|
4501
5480
|
/**
|
|
4502
5481
|
* The one place in a thread where anything is typed, and the one place the actions live.
|
|
4503
5482
|
*
|
|
@@ -4617,7 +5596,7 @@ function notificationPanelMarkup(notifications) {
|
|
|
4617
5596
|
<div class="fb-list">${body}</div>
|
|
4618
5597
|
`;
|
|
4619
5598
|
}
|
|
4620
|
-
function panelMarkup(state, comments, selection, shared = false, notifications = null, view = 'feedback', scriptTag = false, devReviewLinks = false, filtered = null) {
|
|
5599
|
+
function panelMarkup(state, comments, selection, shared = false, notifications = null, view = 'feedback', scriptTag = false, devReviewLinks = false, filtered = null, kindFilter = 'all') {
|
|
4621
5600
|
// The notification list replaces the feedback list rather than sitting beside it: the panel
|
|
4622
5601
|
// is narrow, and two scrolling lists in it would each be too short to read.
|
|
4623
5602
|
if (view === 'notifications' && notifications) {
|
|
@@ -4639,25 +5618,29 @@ function panelMarkup(state, comments, selection, shared = false, notifications =
|
|
|
4639
5618
|
.map(([file, grouped]) => {
|
|
4640
5619
|
const items = grouped
|
|
4641
5620
|
.map((comment) => {
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
const element = elsewhere ? null : locateComment(comment);
|
|
4646
|
-
const orphaned = !elsewhere && element === null;
|
|
5621
|
+
const recording = isRecording(comment);
|
|
5622
|
+
// A recording has a route but no anchor; it is never orphaned or hidden.
|
|
5623
|
+
const elsewhere = recording ? false : !belongsOnThisPage(comment);
|
|
5624
|
+
const element = recording || elsewhere ? null : locateComment(comment);
|
|
5625
|
+
const orphaned = !recording && !elsewhere && element === null;
|
|
4647
5626
|
const hidden = element !== null && !shownOnPage(element);
|
|
4648
5627
|
const checked = selection.has(comment.id);
|
|
4649
5628
|
const latest = comment.replies.at(-1) ?? comment;
|
|
5629
|
+
const summary = recording
|
|
5630
|
+
? `<b>Recording</b> · ${escapeHtml(clock(comment.recording?.durationMs ?? 0))}${latest.body ? ` · ${escapeHtml(latest.body)}` : ''}`
|
|
5631
|
+
: escapeHtml(latest.body);
|
|
5632
|
+
const anchorMeta = recording ? '' : comment.anchor.file ? `${escapeHtml(`line ${comment.anchor.line}`)} · ` : '';
|
|
5633
|
+
const locationMeta = recording || elsewhere ? ''
|
|
5634
|
+
: orphaned ? (comment.anchor.file ? ' · orphaned' : ' · not on this page')
|
|
5635
|
+
: hidden ? ' · hidden right now' : '';
|
|
4650
5636
|
return `
|
|
4651
|
-
<div class="fb-item" data-status="${comment.status}" data-fb-action="focus-comment" data-fb-value="${comment.id}">
|
|
5637
|
+
<div class="fb-item" data-status="${comment.status}" data-kind="${recording ? 'recording' : 'pin'}" data-fb-action="focus-comment" data-fb-value="${comment.id}">
|
|
4652
5638
|
${avatarMarkup(comment.author, colorForId(comment.authorId ?? comment.author), 'sm')}
|
|
4653
5639
|
<span>
|
|
4654
|
-
<p>${
|
|
4655
|
-
<small>${
|
|
4656
|
-
// A line is only worth showing where it is known: on a preview the browser
|
|
4657
|
-
// never sees a path, and every comment read "line 0".
|
|
4658
|
-
comment.anchor.file ? `${escapeHtml(`line ${comment.anchor.line}`)} · ` : ''}${escapeHtml(comment.author)}${comment.authorUnverified ? ' (unverified)' : ''}${comment.replies.length > 0
|
|
5640
|
+
<p>${summary}</p>
|
|
5641
|
+
<small>${anchorMeta}${escapeHtml(comment.author)}${comment.authorUnverified ? ' (unverified)' : ''}${comment.replies.length > 0
|
|
4659
5642
|
? ` · ${comment.replies.length} ${comment.replies.length === 1 ? 'reply' : 'replies'}`
|
|
4660
|
-
: ''}${
|
|
5643
|
+
: ''}${locationMeta}</small>
|
|
4661
5644
|
</span>
|
|
4662
5645
|
<button type="button" class="fb-select" data-selected="${checked}"
|
|
4663
5646
|
data-fb-action="toggle-selection" data-fb-value="${comment.id}"
|
|
@@ -4696,6 +5679,10 @@ function panelMarkup(state, comments, selection, shared = false, notifications =
|
|
|
4696
5679
|
aria-pressed="${state.filter === value}">${value[0].toUpperCase()}${value.slice(1)}</button>`)
|
|
4697
5680
|
.join('')}
|
|
4698
5681
|
</div>
|
|
5682
|
+
<div class="fb-segmented fb-segmented--kind" role="group" aria-label="Feedback kind">
|
|
5683
|
+
${[['all', 'All'], ['pin', 'Comments'], ['recording', 'Recordings']].map(([value, label]) => `<button type="button" data-fb-action="set-kind-filter" data-fb-value="${value}"
|
|
5684
|
+
aria-pressed="${kindFilter === value}">${label}</button>`).join('')}
|
|
5685
|
+
</div>
|
|
4699
5686
|
${filtered !== null ? `<div class="fb-listfilter"><span>${filtered} ${filtered === 1 ? 'comment' : 'comments'} here</span>
|
|
4700
5687
|
<button type="button" class="fb-link" data-fb-action="clear-list-filter">Show all</button></div>` : ''}
|
|
4701
5688
|
<div class="fb-list">${list}</div>
|
|
@@ -4813,6 +5800,8 @@ function offsetWithin(element, point) {
|
|
|
4813
5800
|
* does not (a preview, where every file is blank and they all fell into one unnamed group).
|
|
4814
5801
|
*/
|
|
4815
5802
|
function groupOf(comment) {
|
|
5803
|
+
if (isRecording(comment))
|
|
5804
|
+
return 'Recordings';
|
|
4816
5805
|
if (comment.anchor.file)
|
|
4817
5806
|
return comment.anchor.file;
|
|
4818
5807
|
const route = comment.context?.route ?? '';
|