ontrackd 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +32 -18
  3. package/dist/cli/init.d.ts +1 -1
  4. package/dist/cli/init.js +26 -5
  5. package/dist/cli/init.js.map +1 -1
  6. package/dist/cli/link.d.ts +1 -1
  7. package/dist/cli/link.js +16 -82
  8. package/dist/cli/link.js.map +1 -1
  9. package/dist/cli/pull.js +5 -0
  10. package/dist/cli/pull.js.map +1 -1
  11. package/dist/cli/remote.js +6 -1
  12. package/dist/cli/remote.js.map +1 -1
  13. package/dist/core/exportTaskDoc.js +43 -1
  14. package/dist/core/exportTaskDoc.js.map +1 -1
  15. package/dist/core/feedbackTypes.d.ts +43 -0
  16. package/dist/core/journey.d.ts +31 -0
  17. package/dist/core/journey.js +93 -0
  18. package/dist/core/journey.js.map +1 -0
  19. package/dist/core/oxcAst.js.map +1 -1
  20. package/dist/core/staleness.js +1 -0
  21. package/dist/core/staleness.js.map +1 -1
  22. package/dist/core/styleOrigin.js.map +1 -1
  23. package/dist/core/untrusted.js +13 -6
  24. package/dist/core/untrusted.js.map +1 -1
  25. package/dist/expo/app/ConnectSheet.d.ts +13 -0
  26. package/dist/expo/app/ConnectSheet.js +121 -0
  27. package/dist/expo/app/ConnectSheet.js.map +1 -0
  28. package/dist/expo/app/Provider.js +6 -0
  29. package/dist/expo/app/Provider.js.map +1 -1
  30. package/dist/expo/app/adapter.d.ts +5 -0
  31. package/dist/expo/app/adapter.js.map +1 -1
  32. package/dist/expo/app/runtimeConfig.d.ts +4 -0
  33. package/dist/expo/app/runtimeConfig.js +7 -0
  34. package/dist/expo/app/runtimeConfig.js.map +1 -1
  35. package/dist/expo/app/useCloudReviewer.d.ts +6 -0
  36. package/dist/expo/app/useCloudReviewer.js +9 -0
  37. package/dist/expo/app/useCloudReviewer.js.map +1 -1
  38. package/dist/expo/metroBuild.js +28 -3
  39. package/dist/expo/metroBuild.js.map +1 -1
  40. package/dist/expo/publicConfig.d.ts +6 -0
  41. package/dist/expo/publicConfig.js.map +1 -1
  42. package/dist/integration/buildSession.js +3 -3
  43. package/dist/integration/buildSession.js.map +1 -1
  44. package/dist/integration/devCloud.d.ts +11 -5
  45. package/dist/integration/devCloud.js +44 -21
  46. package/dist/integration/devCloud.js.map +1 -1
  47. package/dist/integration/importClient.d.ts +53 -0
  48. package/dist/integration/importClient.js +76 -0
  49. package/dist/integration/importClient.js.map +1 -0
  50. package/dist/integration/importPlan.d.ts +2 -1
  51. package/dist/integration/importPlan.js +10 -3
  52. package/dist/integration/importPlan.js.map +1 -1
  53. package/dist/integration/localImport.d.ts +30 -0
  54. package/dist/integration/localImport.js +139 -0
  55. package/dist/integration/localImport.js.map +1 -0
  56. package/dist/integration/localModeSwitch.d.ts +4 -0
  57. package/dist/integration/localModeSwitch.js +51 -0
  58. package/dist/integration/localModeSwitch.js.map +1 -0
  59. package/dist/integration/middleware.d.ts +8 -0
  60. package/dist/integration/middleware.js +57 -10
  61. package/dist/integration/middleware.js.map +1 -1
  62. package/dist/integration/requestGuards.d.ts +2 -0
  63. package/dist/integration/requestGuards.js +4 -0
  64. package/dist/integration/requestGuards.js.map +1 -1
  65. package/dist/integration/sharedBuild.d.ts +3 -1
  66. package/dist/integration/sharedBuild.js +4 -1
  67. package/dist/integration/sharedBuild.js.map +1 -1
  68. package/dist/mcp/search.js +3 -2
  69. package/dist/mcp/search.js.map +1 -1
  70. package/dist/mcp/server.js +16 -7
  71. package/dist/mcp/server.js.map +1 -1
  72. package/dist/overlay/anchors.d.ts +3 -0
  73. package/dist/overlay/anchors.js +4 -1
  74. package/dist/overlay/anchors.js.map +1 -1
  75. package/dist/overlay/api.d.ts +19 -1
  76. package/dist/overlay/api.js +37 -7
  77. package/dist/overlay/api.js.map +1 -1
  78. package/dist/overlay/attachments.d.ts +5 -1
  79. package/dist/overlay/attachments.js +16 -3
  80. package/dist/overlay/attachments.js.map +1 -1
  81. package/dist/overlay/browser.js +15 -0
  82. package/dist/overlay/browser.js.map +1 -1
  83. package/dist/overlay/connectDialog.d.ts +14 -0
  84. package/dist/overlay/connectDialog.js +297 -0
  85. package/dist/overlay/connectDialog.js.map +1 -0
  86. package/dist/overlay/dialogOpener.d.ts +30 -0
  87. package/dist/overlay/dialogOpener.js +82 -0
  88. package/dist/overlay/dialogOpener.js.map +1 -0
  89. package/dist/overlay/directReviewer.d.ts +17 -2
  90. package/dist/overlay/directReviewer.js +37 -10
  91. package/dist/overlay/directReviewer.js.map +1 -1
  92. package/dist/overlay/journeyRecorder.d.ts +30 -0
  93. package/dist/overlay/journeyRecorder.js +238 -0
  94. package/dist/overlay/journeyRecorder.js.map +1 -0
  95. package/dist/overlay/movedAnchors.js +5 -0
  96. package/dist/overlay/movedAnchors.js.map +1 -1
  97. package/dist/overlay/recorder.d.ts +8 -4
  98. package/dist/overlay/recorder.js +163 -47
  99. package/dist/overlay/recorder.js.map +1 -1
  100. package/dist/overlay/recordingEditor.d.ts +12 -0
  101. package/dist/overlay/recordingEditor.js +130 -0
  102. package/dist/overlay/recordingEditor.js.map +1 -0
  103. package/dist/overlay/recordingPlayer.d.ts +14 -0
  104. package/dist/overlay/recordingPlayer.js +311 -0
  105. package/dist/overlay/recordingPlayer.js.map +1 -0
  106. package/dist/overlay/rrweb-replay.js +120 -0
  107. package/dist/overlay/runtime.js +785 -58
  108. package/dist/overlay/runtime.js.map +1 -1
  109. package/dist/overlay/state.js +2 -1
  110. package/dist/overlay/state.js.map +1 -1
  111. package/dist/overlay/styles.js +45 -0
  112. package/dist/overlay/styles.js.map +1 -1
  113. package/dist/remote/client.d.ts +3 -2
  114. package/dist/remote/client.js +3 -3
  115. package/dist/remote/client.js.map +1 -1
  116. package/dist/remote/content-schema.d.ts +338 -51
  117. package/dist/remote/content-schema.js +92 -0
  118. package/dist/remote/content-schema.js.map +1 -1
  119. package/dist/remote/content.js +4 -2
  120. package/dist/remote/content.js.map +1 -1
  121. package/dist/remote/store.js +3 -1
  122. package/dist/remote/store.js.map +1 -1
  123. package/dist/remote/types.d.ts +1 -0
  124. package/dist/setup/connect.d.ts +49 -0
  125. package/dist/setup/connect.js +144 -82
  126. package/dist/setup/connect.js.map +1 -1
  127. package/dist/sidecar/commentFiles.js +1 -1
  128. package/dist/sidecar/commentFiles.js.map +1 -1
  129. package/dist/sidecar/connectRoutes.d.ts +28 -0
  130. package/dist/sidecar/connectRoutes.js +154 -0
  131. package/dist/sidecar/connectRoutes.js.map +1 -0
  132. package/dist/sidecar/http.d.ts +4 -1
  133. package/dist/sidecar/http.js +61 -9
  134. package/dist/sidecar/http.js.map +1 -1
  135. package/dist/storage/sidecarAccess.d.ts +23 -0
  136. package/dist/storage/sidecarAccess.js +68 -1
  137. package/dist/storage/sidecarAccess.js.map +1 -1
  138. package/package.json +5 -3
@@ -1,8 +1,11 @@
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';
8
+ import { openDialogFor, openerFor, openingDialog, rememberClick } from './dialogOpener.js';
6
9
  import { anchorsToTranslate, locateComment, rememberTranslations, setCurrentBuild, stopAsking } from './movedAnchors.js';
7
10
  import { leaveReviewMode } from './reviewMode.js';
8
11
  import { api, attachmentsAvailable, recordingSupported, remoteFeedbackStatus, renderable } from './api.js';
@@ -57,6 +60,20 @@ export function mountFeedbackOverlay() {
57
60
  }
58
61
  void new FeedbackOverlay().mount();
59
62
  }
63
+ /** Seconds counted down, on the screen, before a recording starts: time to get the page the way it should be. */
64
+ const COUNTDOWN_SECONDS = 5;
65
+ function retryableModulePath(path, attempt) {
66
+ return `${path}${path.includes('?') ? '&' : '?'}retry=${attempt}`;
67
+ }
68
+ /** A definitive create refusal: the upload claim and its idempotency result cannot be reused. */
69
+ function recordingAttachmentRefusal(error) {
70
+ if (!error || typeof error !== 'object')
71
+ return false;
72
+ const details = error.details;
73
+ if (details && typeof details === 'object' && details.reason === 'recording_attachment')
74
+ return true;
75
+ return error instanceof Error && error.message.includes('recording_attachment');
76
+ }
60
77
  class FeedbackOverlay {
61
78
  host = document.createElement('div');
62
79
  root;
@@ -84,12 +101,25 @@ class FeedbackOverlay {
84
101
  replyBody = '';
85
102
  /** How files reach the API or the sidecar, for both composers. */
86
103
  fileTransport = {
87
- send: (file, onProgress) => api.uploadAttachment(file, onProgress),
104
+ send: async (file, onProgress) => {
105
+ try {
106
+ return await api.uploadAttachment(file, onProgress);
107
+ }
108
+ catch (error) {
109
+ if (error instanceof SessionExpiredError && this.shared && !this.signIn) {
110
+ if (this.recordingSaving)
111
+ this.pendingRecordingSave = true;
112
+ this.handleSessionExpired();
113
+ }
114
+ throw error;
115
+ }
116
+ },
88
117
  discard: (id) => api.discardUpload(id),
89
118
  };
90
119
  /** Files of the comment being written, and of the reply being written (spec: Attachments). */
91
120
  draftTray = new AttachmentTray(this.fileTransport, () => this.render(), (item) => this.showProgress('draft', item));
92
121
  replyTray = new AttachmentTray(this.fileTransport, () => this.render(), (item) => this.showProgress('reply', item));
122
+ recordingTray = new AttachmentTray(this.fileTransport, () => this.render(), (item) => this.showProgress('recording', item));
93
123
  /**
94
124
  * The thread whose reply is being claimed by the server now. Its files are the request's: moving to
95
125
  * another thread meanwhile must not discard them (a removal racing the claim refuses the reply).
@@ -106,6 +136,23 @@ class FeedbackOverlay {
106
136
  /** The recording in progress: the page is the reviewer's meanwhile (the mode they were in comes back after). */
107
137
  recording = null;
108
138
  startingRecording = false;
139
+ /** A whole journey stopped but not yet saved. */
140
+ recordingDraft = null;
141
+ recordingSaving = false;
142
+ recordingError = null;
143
+ recordingDiscard = null;
144
+ recordingDiscardFocus = null;
145
+ pendingRecordingSave = false;
146
+ recordingUi = null;
147
+ recordingUiLoad = null;
148
+ recordingUiAttempt = 0;
149
+ recordingUiFailed = false;
150
+ recordingEditor = null;
151
+ recordingPlayer = null;
152
+ threadRecordingPlayer = null;
153
+ threadRecordingPlayerId = null;
154
+ threadRecordingFile = null;
155
+ threadRecordingGeneration = 0;
109
156
  /** 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. */
110
157
  draftHeldFor = null;
111
158
  /** Until when (performance.now) a draft's elements, gone with the route, are looked for again. */
@@ -229,6 +276,7 @@ class FeedbackOverlay {
229
276
  panelContent;
230
277
  panelToast;
231
278
  fileInput;
279
+ recordingDialog;
232
280
  lightbox;
233
281
  chip;
234
282
  /** The phone's bottom sheet (sheet.ts): every panel goes into it in compact layout. */
@@ -239,10 +287,17 @@ class FeedbackOverlay {
239
287
  sheetBack = null;
240
288
  /** On a phone: the list sheet shows only these comments, after a tap on a group of pins. */
241
289
  listFilter = null;
290
+ /** The list's message kind, independent of open/resolved. */
291
+ kindFilter = 'all';
242
292
  panelToastTimer = null;
243
293
  constructor() {
244
294
  this.host.id = rootId;
295
+ // rrweb preserves a blocked node's class (but strips its data attributes), so replay can remove its placeholder box.
296
+ this.host.classList.add('fb-overlay-blocked');
245
297
  this.host.setAttribute('data-feedback-overlay', '');
298
+ // React Aria listens for outside presses in the capture phase, where nothing of ours can stop it;
299
+ // this marker is the opt-out it documents for floating UI that does not belong to a dialog.
300
+ this.host.setAttribute('data-react-aria-top-layer', 'true');
246
301
  this.root = this.host.attachShadow({ mode: 'open' });
247
302
  }
248
303
  async mount() {
@@ -269,6 +324,7 @@ class FeedbackOverlay {
269
324
  this.panelContent = required(this.root, '[data-fb-panel-content]');
270
325
  this.panelToast = required(this.root, '[data-fb-panel-toast]');
271
326
  this.fileInput = required(this.root, '[data-fb-file-input]');
327
+ this.recordingDialog = required(this.root, '[data-fb-recording-mount]');
272
328
  this.fileInput.accept = acceptAttribute;
273
329
  // The picker's answer. Bound once, here: the composers' markup is rebuilt on every render.
274
330
  this.fileInput.addEventListener('change', () => {
@@ -313,6 +369,22 @@ class FeedbackOverlay {
313
369
  for (const type of ['keydown', 'keypress', 'keyup']) {
314
370
  this.root.addEventListener(type, (event) => event.stopPropagation());
315
371
  }
372
+ // The same for the start of a press and for focus. A modal dialog of the page (Radix, Headless UI)
373
+ // listens on the document for a pointerdown or focus landing "outside" it, and past our shadow
374
+ // root the target reads as our host, which is outside: the toolbar closed the dialog. Only the
375
+ // bubble phase is stopped, so our own capture handlers below and every listener inside the
376
+ // overlay (the sheet's swipe, the picker) run first and are unaffected.
377
+ for (const type of ['pointerdown', 'mousedown', 'touchstart', 'focusin', 'focusout']) {
378
+ this.root.addEventListener(type, (event) => event.stopPropagation());
379
+ }
380
+ // The other half of focus: a dialog's own element loses focus to us, and its focus trap (Radix
381
+ // FocusScope) reads relatedTarget - our host - as "left the dialog" and pulls focus back, so no
382
+ // comment could be typed. A null relatedTarget is what a click on the browser chrome looks like,
383
+ // and every trap lets that one go. The event still reaches the page's own blur handlers.
384
+ document.addEventListener('focusout', (event) => {
385
+ if (event.relatedTarget === this.host)
386
+ Object.defineProperty(event, 'relatedTarget', { value: null });
387
+ }, true);
316
388
  document.addEventListener('pointermove', (event) => this.handlePointerMove(event), true);
317
389
  document.addEventListener('click', (event) => this.handleHostClick(event), true);
318
390
  // The rest of a tap, which the click handler alone would let through to the page's own handlers.
@@ -345,9 +417,7 @@ class FeedbackOverlay {
345
417
  }
346
418
  // A group's filter names pins of the page left behind.
347
419
  this.listFilter = null;
348
- this.state.openThreadId = null;
349
- this.sheetBack = null;
350
- this.abandonReplyFiles();
420
+ this.closeThread();
351
421
  this.render();
352
422
  });
353
423
  this.state.subscribe(() => this.render());
@@ -510,10 +580,13 @@ class FeedbackOverlay {
510
580
  this.state.setMode('visible');
511
581
  if (!this.state.chipsVisible)
512
582
  this.state.setChipsVisible(true);
513
- this.openThread(id);
514
- this.stickyId = id;
515
- this.render();
516
- this.scrollToComment(id);
583
+ const comment = this.state.comments.find((entry) => entry.id === id);
584
+ void openDialogFor(comment, locateComment).then(() => {
585
+ this.openThread(id);
586
+ this.stickyId = id;
587
+ this.render();
588
+ this.scrollToComment(id);
589
+ });
517
590
  }
518
591
  /**
519
592
  * Who the reviewer is, in shared mode.
@@ -830,6 +903,13 @@ class FeedbackOverlay {
830
903
  void this.bootstrapViewer();
831
904
  this.requestNotifications();
832
905
  this.render();
906
+ // The save that discovered the session was dead. Finished now, with the same local file,
907
+ // identity and words, so an ambiguous create cannot turn into a duplicate comment.
908
+ if (this.pendingRecordingSave && this.recordingDraft) {
909
+ this.pendingRecordingSave = false;
910
+ void this.saveRecording();
911
+ return;
912
+ }
833
913
  // The save that discovered the session was dead. Finished now, with the same words the
834
914
  // reviewer typed before they were interrupted.
835
915
  if (this.pendingDraftSave) {
@@ -926,11 +1006,14 @@ class FeedbackOverlay {
926
1006
  this.renderHighlight();
927
1007
  }
928
1008
  handleHostClick(event) {
929
- if (this.isOverlayEvent(event)) {
1009
+ // The overlay's own click on a dialog's opener (openDialogFor) belongs to the page.
1010
+ if (this.isOverlayEvent(event) || openingDialog()) {
930
1011
  return;
931
1012
  }
932
1013
  // SPEC 7.1: outside Comment mode the host app behaves as if the tool were absent.
933
1014
  if (this.state.mode !== 'commenting') {
1015
+ // What opens a dialog, so a comment left in it can open it again.
1016
+ rememberClick(event.target);
934
1017
  // On a phone a tap that gets past the sheet's backdrop keeps a typed reply, as the backdrop does.
935
1018
  if (this.compact && this.state.openThreadId && !this.threadDismissable())
936
1019
  return;
@@ -998,7 +1081,7 @@ class FeedbackOverlay {
998
1081
  this.lastPointerType = event.pointerType;
999
1082
  this.tapSelected = false;
1000
1083
  }
1001
- if (this.state.mode !== 'commenting' || this.isOverlayEvent(event))
1084
+ if (this.state.mode !== 'commenting' || this.isOverlayEvent(event) || openingDialog())
1002
1085
  return;
1003
1086
  // A compat mouse event carries no pointer type: it is the pointerdown's.
1004
1087
  const pointer = event instanceof PointerEvent ? event.pointerType : this.lastPointerType;
@@ -1052,6 +1135,62 @@ class FeedbackOverlay {
1052
1135
  this.render();
1053
1136
  }
1054
1137
  handleKeydown(event) {
1138
+ if (this.recordingDiscard) {
1139
+ const confirm = this.recordingDialog.querySelector('[data-fb-recording-discard]');
1140
+ const inside = event.composedPath().includes(confirm);
1141
+ if (event.key === 'Tab' && confirm) {
1142
+ event.preventDefault();
1143
+ event.stopPropagation();
1144
+ const buttons = Array.from(confirm.querySelectorAll('button:not(:disabled)'));
1145
+ const at = buttons.indexOf(this.root.activeElement);
1146
+ buttons[(at + (event.shiftKey ? -1 : 1) + buttons.length) % buttons.length]?.focus();
1147
+ return;
1148
+ }
1149
+ if (event.key === 'Escape') {
1150
+ event.preventDefault();
1151
+ event.stopPropagation();
1152
+ this.keepRecording();
1153
+ return;
1154
+ }
1155
+ if (event.key !== 'Enter' || !inside) {
1156
+ event.preventDefault();
1157
+ event.stopPropagation();
1158
+ }
1159
+ return;
1160
+ }
1161
+ if (this.recordingDraft && event.key === 'Tab') {
1162
+ const dialog = this.recordingDialog.querySelector('[data-fb-recording-dialog]');
1163
+ 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) : [];
1164
+ const active = this.root.activeElement;
1165
+ const at = controls.indexOf(active);
1166
+ if (controls.length > 0 && (at < 0 || !event.shiftKey && at === controls.length - 1 || event.shiftKey && at === 0)) {
1167
+ event.preventDefault();
1168
+ event.stopPropagation();
1169
+ controls[event.shiftKey ? controls.length - 1 : 0]?.focus();
1170
+ return;
1171
+ }
1172
+ }
1173
+ // Journey recording owns its shortcut in every state, before recording's early return.
1174
+ if (event.altKey && event.shiftKey && event.code === 'KeyR') {
1175
+ event.preventDefault();
1176
+ event.stopPropagation();
1177
+ if (this.recordingSaving)
1178
+ return;
1179
+ if (this.recording) {
1180
+ if (this.recording.countdown != null)
1181
+ this.recording.cancel?.();
1182
+ else
1183
+ this.recording.recorder.stop();
1184
+ return;
1185
+ }
1186
+ if (this.recordingDraft) {
1187
+ this.askToDiscardRecording(true);
1188
+ return;
1189
+ }
1190
+ if (this.recordOffered())
1191
+ void this.startRecording(true);
1192
+ return;
1193
+ }
1055
1194
  // The keys are the page's while recording: Escape closing something of the app must not discard the comment.
1056
1195
  if (this.recording)
1057
1196
  return;
@@ -1063,6 +1202,11 @@ class FeedbackOverlay {
1063
1202
  return;
1064
1203
  }
1065
1204
  if (event.key === 'Escape') {
1205
+ if (this.recordingDraft) {
1206
+ if (!this.recordingSaving)
1207
+ this.askToDiscardRecording(false);
1208
+ return;
1209
+ }
1066
1210
  if (this.signIn) {
1067
1211
  this.dismissSignIn();
1068
1212
  return;
@@ -1602,6 +1746,11 @@ class FeedbackOverlay {
1602
1746
  if (!target) {
1603
1747
  return;
1604
1748
  }
1749
+ if (this.recordingDraft && target === this.recordingDialog.querySelector('[data-fb-recording-dialog]')) {
1750
+ if (!this.recordingSaving)
1751
+ this.askToDiscardRecording(false);
1752
+ return;
1753
+ }
1605
1754
  // A click on the dimmed backdrop around the sign-in, not on the dialog itself. In a sheet (a phone)
1606
1755
  // the scrim is the dialog's own background: a tap there is not a backdrop tap.
1607
1756
  if (this.signIn && target === this.scrim && !this.compact) {
@@ -1625,15 +1774,50 @@ class FeedbackOverlay {
1625
1774
  return;
1626
1775
  }
1627
1776
  const { fbAction: name, fbValue: value } = action.dataset;
1777
+ // The alertdialog is the only interactive surface until its choice is made.
1778
+ if (this.recordingDiscard && name !== 'keep-recording' && name !== 'discard-recording')
1779
+ return;
1628
1780
  // The page is the reviewer's while recording: the rest of the overlay is out of the way, and inert.
1629
1781
  if (this.recording && name !== 'stop-recording')
1630
1782
  return;
1631
1783
  switch (name) {
1784
+ case 'record-journey':
1785
+ void this.startRecording(true);
1786
+ break;
1632
1787
  case 'record':
1633
- void this.startRecording();
1788
+ void this.startRecording(false);
1634
1789
  break;
1635
1790
  case 'stop-recording':
1636
- this.recording?.recorder.stop();
1791
+ // Until it starts, this is the cancel.
1792
+ if (this.recording?.countdown != null)
1793
+ this.recording.cancel?.();
1794
+ else
1795
+ this.recording?.recorder.stop();
1796
+ break;
1797
+ case 'cancel-recording':
1798
+ if (!this.recordingSaving)
1799
+ this.askToDiscardRecording(false);
1800
+ break;
1801
+ case 'save-recording':
1802
+ void this.saveRecording();
1803
+ break;
1804
+ case 'retry-recording-ui':
1805
+ if (this.recordingDraft && !this.recordingSaving) {
1806
+ this.recordingUiFailed = false;
1807
+ this.recordingError = null;
1808
+ this.renderRecordingDialog();
1809
+ void this.mountRecordingUi(this.recordingDraft);
1810
+ }
1811
+ break;
1812
+ case 'discard-recording': {
1813
+ const restart = this.recordingDiscard?.restart === true;
1814
+ this.discardRecording();
1815
+ if (restart)
1816
+ queueMicrotask(() => { void this.startRecording(true); });
1817
+ break;
1818
+ }
1819
+ case 'keep-recording':
1820
+ this.keepRecording();
1637
1821
  break;
1638
1822
  case 'join':
1639
1823
  void this.completeJoin();
@@ -1777,6 +1961,12 @@ class FeedbackOverlay {
1777
1961
  this.clearSticky();
1778
1962
  this.state.setFilter(value);
1779
1963
  break;
1964
+ case 'set-kind-filter':
1965
+ this.clearSticky();
1966
+ if (value === 'all' || value === 'pin' || value === 'recording')
1967
+ this.kindFilter = value;
1968
+ this.render();
1969
+ break;
1780
1970
  case 'cancel-draft':
1781
1971
  this.cancelDraft();
1782
1972
  break;
@@ -1829,8 +2019,8 @@ class FeedbackOverlay {
1829
2019
  void this.sendReply(String(value));
1830
2020
  break;
1831
2021
  case 'attach': {
1832
- const which = value === 'reply' ? 'reply' : 'draft';
1833
- if (!this.takesFiles(which) || this.sending === which)
2022
+ const which = value === 'reply' ? 'reply' : value === 'recording' ? 'recording' : 'draft';
2023
+ if (!this.takesFiles(which) || (which === 'recording' ? this.recordingSaving : this.sending === which))
1834
2024
  break;
1835
2025
  this.pickingFor = which;
1836
2026
  this.fileInput.click();
@@ -1838,9 +2028,9 @@ class FeedbackOverlay {
1838
2028
  }
1839
2029
  case 'remove-file': {
1840
2030
  const [which, key = ''] = String(value).split(':');
1841
- const tray = which === 'reply' ? 'reply' : 'draft';
2031
+ const tray = which === 'reply' ? 'reply' : which === 'recording' ? 'recording' : 'draft';
1842
2032
  // While that composer sends, its files are being claimed: none is taken out from under it.
1843
- if (this.sending === tray)
2033
+ if ((tray !== 'recording' && this.sending === tray) || (tray === 'recording' && this.recordingSaving))
1844
2034
  break;
1845
2035
  this.trayFor(tray).remove(key);
1846
2036
  // The button that had the focus is gone with its file.
@@ -2093,6 +2283,25 @@ class FeedbackOverlay {
2093
2283
  if (!wasThere && candidates[0]?.element.isConnected)
2094
2284
  queueMicrotask(() => this.render());
2095
2285
  }
2286
+ /**
2287
+ * Re-anchors the draft to the page the reviewer is on, at the element in the middle of it, keeping what was written.
2288
+ * False when nothing on the page can be anchored to: the draft then waits for its own page.
2289
+ */
2290
+ anchorDraftHere() {
2291
+ const x = window.innerWidth / 2, y = window.innerHeight / 2;
2292
+ for (const element of document.elementsFromPoint(x, y)) {
2293
+ if (this.host.contains(element))
2294
+ continue;
2295
+ const candidates = anchorCandidatesFor(element);
2296
+ if (!candidates.length)
2297
+ continue;
2298
+ this.draft = this.draftAt(candidates, x, y);
2299
+ this.draftRelocateUntil = 0;
2300
+ this.snapshotSelected();
2301
+ return true;
2302
+ }
2303
+ return false;
2304
+ }
2096
2305
  /** The element the draft currently points at. */
2097
2306
  selectedElement(draft = this.draft) {
2098
2307
  if (!draft)
@@ -2141,7 +2350,9 @@ class FeedbackOverlay {
2141
2350
  this.trace('screenshot-failed', { reason: error instanceof Error ? error.message.slice(0, 120) : 'unknown' });
2142
2351
  }
2143
2352
  }
2144
- trayFor(which) { return which === 'reply' ? this.replyTray : this.draftTray; }
2353
+ trayFor(which) {
2354
+ return which === 'reply' ? this.replyTray : which === 'recording' ? this.recordingTray : this.draftTray;
2355
+ }
2145
2356
  /** The reply being written is left (thread closed or another opened): its uploads go, unless a send is claiming them. */
2146
2357
  abandonReplyFiles() {
2147
2358
  if (!this.claimingReplyFor)
@@ -2152,6 +2363,8 @@ class FeedbackOverlay {
2152
2363
  * a sent message adds none). Never Standalone, and never a thread another session holds.
2153
2364
  */
2154
2365
  takesFiles(which) {
2366
+ if (which === 'recording')
2367
+ return Boolean(this.recordingDraft) && attachmentsAvailable();
2155
2368
  if (which === 'draft')
2156
2369
  return Boolean(this.draft) && attachmentsAvailable();
2157
2370
  const id = this.state.openThreadId;
@@ -2159,6 +2372,10 @@ class FeedbackOverlay {
2159
2372
  }
2160
2373
  /** Back to a composer's words, after the control that had the focus was replaced. */
2161
2374
  focusComposer(which) {
2375
+ if (which === 'recording') {
2376
+ this.recordingEditor?.element.focus();
2377
+ return;
2378
+ }
2162
2379
  const field = this.root.querySelector(which === 'reply' ? '[data-fb-reply]' : '[data-fb-body]');
2163
2380
  if (field && !field.disabled)
2164
2381
  field.focus();
@@ -2183,33 +2400,70 @@ class FeedbackOverlay {
2183
2400
  * Records the page while the reviewer reproduces the problem. The mode they were in is set aside, so the page
2184
2401
  * behaves as if the tool were absent; the draft stays. The limit is asked again: the plan may have changed.
2185
2402
  */
2186
- async startRecording() {
2187
- if (this.recording || this.startingRecording || !this.draft || this.sending === 'draft')
2403
+ async startRecording(journey) {
2404
+ if (this.recording || this.startingRecording || this.recordingSaving)
2405
+ return;
2406
+ if (journey && this.recordingDraft) {
2407
+ this.askToDiscardRecording(true);
2408
+ return;
2409
+ }
2410
+ if (!journey && (!this.draft || this.sending === 'draft'))
2188
2411
  return;
2412
+ const pinDraft = journey ? null : this.draft;
2189
2413
  this.startingRecording = true;
2190
- const refuse = (message) => { this.draftTray.notice = message; this.render(); };
2414
+ const refuse = (message) => {
2415
+ if (journey)
2416
+ this.showReviewerNotice(message);
2417
+ else {
2418
+ this.draftTray.notice = message;
2419
+ this.render();
2420
+ }
2421
+ };
2191
2422
  try {
2192
2423
  const limit = await api.recordingLimit();
2193
2424
  this.recordingLimit = limit;
2425
+ if (!journey && this.draft !== pinDraft)
2426
+ return;
2194
2427
  if (!limit?.available) {
2195
2428
  refuse('Recording is not available');
2196
2429
  return;
2197
2430
  }
2198
- const recorder = new Recorder(limit, '[data-feedback-overlay]', (elapsed) => this.showRecordingTime(elapsed));
2431
+ const recorder = new Recorder(limit, '[data-feedback-overlay]', (elapsed) => this.showRecordingTime(elapsed), api.recordingOrigin());
2199
2432
  const from = this.state.mode;
2200
- const recording = { recorder, from, limit, elapsed: 0, route: location.pathname, moved: false };
2433
+ const recording = {
2434
+ recorder, journey, from, limit, elapsed: 0, route: location.pathname,
2435
+ moved: false, countdown: COUNTDOWN_SECONDS,
2436
+ };
2201
2437
  this.recording = recording;
2202
2438
  // The page as it is without the pin cursor and the highlight: that is where the recording begins.
2203
2439
  this.state.setMode('visible');
2440
+ this.render();
2441
+ this.root.querySelector('[data-fb-action="stop-recording"]')?.focus();
2442
+ if (!await this.countDown(recording))
2443
+ return;
2444
+ if (recording.journey) {
2445
+ recording.route = location.pathname;
2446
+ recording.url = remoteFeedbackStatus ? pageUrl(window.location.href, { query: false }) ?? undefined : undefined;
2447
+ }
2204
2448
  try {
2205
2449
  await recorder.start();
2206
2450
  }
2207
2451
  catch {
2452
+ if (this.recording !== recording)
2453
+ return;
2208
2454
  this.recording = null;
2209
2455
  this.state.setMode(from);
2456
+ if (this.draft)
2457
+ this.settleDraft(recording.route);
2210
2458
  refuse('Could not start recording');
2211
2459
  return;
2212
2460
  }
2461
+ // Cancelled at zero, while it loaded: it is stopped, and what it recorded is dropped.
2462
+ if (this.recording !== recording) {
2463
+ recorder.stop();
2464
+ return;
2465
+ }
2466
+ recording.countdown = null;
2213
2467
  void recorder.ended.then((end) => this.recordingEnded(recording, end));
2214
2468
  this.render();
2215
2469
  this.root.querySelector('[data-fb-action="stop-recording"]')?.focus();
@@ -2218,18 +2472,80 @@ class FeedbackOverlay {
2218
2472
  this.startingRecording = false;
2219
2473
  }
2220
2474
  }
2475
+ /**
2476
+ * The page was the reviewer's (a recording, or the count before it): the draft is where they are. Route changes were not heard,
2477
+ * so its elements may have come back mounted again; and if it ended on another page where what the comment was about is not,
2478
+ * the comment is written here. An element on the page without a box (display: none) is not there either.
2479
+ */
2480
+ settleDraft(route) {
2481
+ if (!this.draft)
2482
+ return;
2483
+ this.relocateDraft();
2484
+ const shown = () => (this.draft?.candidates[0]?.element.getClientRects().length ?? 0) > 0 && this.draftAnchorVisible();
2485
+ if (location.pathname === route || shown())
2486
+ return;
2487
+ if (this.anchorDraftHere())
2488
+ this.showReviewerNotice('The comment is on this page now.');
2489
+ else {
2490
+ this.draftHeldFor = route;
2491
+ this.showReviewerNotice(`Go back to ${route} to finish the comment.`);
2492
+ }
2493
+ }
2494
+ /** Counts down on the screen; true when it reached zero, false when the reviewer cancelled it. */
2495
+ countDown(recording) {
2496
+ return new Promise((resolve) => {
2497
+ const timer = window.setInterval(() => {
2498
+ recording.countdown = (recording.countdown ?? 1) - 1;
2499
+ this.showCountdown();
2500
+ if (recording.countdown > 0)
2501
+ return;
2502
+ // Zero is shown while the recorder loads; cancelling then stops it as soon as it has (startRecording).
2503
+ window.clearInterval(timer);
2504
+ resolve(true);
2505
+ }, 1000);
2506
+ recording.cancel = () => {
2507
+ window.clearInterval(timer);
2508
+ this.recording = null;
2509
+ this.state.setMode(recording.from);
2510
+ if (this.draft)
2511
+ this.settleDraft(recording.route);
2512
+ this.render();
2513
+ if (this.draft)
2514
+ this.focusComposer('draft');
2515
+ resolve(false);
2516
+ };
2517
+ this.showCountdown();
2518
+ });
2519
+ }
2221
2520
  recordingEnded(recording, end) {
2222
2521
  if (this.recording !== recording)
2223
2522
  return;
2224
2523
  this.recording = null;
2225
2524
  this.state.setMode(recording.from);
2226
- if (this.draft && location.pathname !== recording.route) {
2227
- this.draftHeldFor = recording.route;
2228
- this.showReviewerNotice(`Recorded. Go back to ${recording.route} to finish the comment.`);
2229
- }
2230
- else {
2231
- // Route changes were not heard while recording: the page may have come back with its elements mounted again.
2232
- this.relocateDraft();
2525
+ if (this.draft)
2526
+ this.settleDraft(recording.route);
2527
+ if (recording.journey) {
2528
+ if (!end.ok) {
2529
+ this.showReviewerNotice(end.message);
2530
+ this.render();
2531
+ return;
2532
+ }
2533
+ this.recordingDraft = {
2534
+ ...end,
2535
+ route: recording.route,
2536
+ ...(recording.url ? { url: recording.url } : {}),
2537
+ createIdentity: { id: newId('cmt'), idempotencyKey: newIdempotencyKey() },
2538
+ };
2539
+ this.recordingError = end.reason === 'user' ? null
2540
+ : end.reason === 'limit' ? `Stopped at ${clock(recording.limit.seconds * 1000)}, the most your plan records`
2541
+ : 'Stopped: the recording got too long';
2542
+ this.recordingUiFailed = false;
2543
+ this.recordingDiscard = null;
2544
+ this.recordingTray.reset();
2545
+ this.recordingTray.addRecording(end.file, end.durationMs);
2546
+ this.render();
2547
+ void this.mountRecordingUi(this.recordingDraft);
2548
+ return;
2233
2549
  }
2234
2550
  if (this.draft && end.ok) {
2235
2551
  this.draftTray.addRecording(end.file, end.durationMs);
@@ -2246,6 +2562,282 @@ class FeedbackOverlay {
2246
2562
  this.render();
2247
2563
  this.focusComposer('draft');
2248
2564
  }
2565
+ loadRecordingUi() {
2566
+ if (this.recordingUiLoad)
2567
+ return this.recordingUiLoad;
2568
+ const attempt = ++this.recordingUiAttempt;
2569
+ const editorPath = typeof __FEEDBACK_RECORDING_EDITOR_MODULE__ === 'string'
2570
+ ? __FEEDBACK_RECORDING_EDITOR_MODULE__ : './recordingEditor.js';
2571
+ const playerPath = typeof __FEEDBACK_RECORDING_PLAYER_MODULE__ === 'string'
2572
+ ? __FEEDBACK_RECORDING_PLAYER_MODULE__ : './recordingPlayer.js';
2573
+ this.recordingUiLoad = Promise.all([
2574
+ import(/* @vite-ignore */ retryableModulePath(editorPath, attempt)),
2575
+ import(/* @vite-ignore */ retryableModulePath(playerPath, attempt)),
2576
+ ]).then(([editor, player]) => {
2577
+ const ui = { RecordingEditor: editor.RecordingEditor, RecordingPlayer: player.RecordingPlayer };
2578
+ this.recordingUi = ui;
2579
+ return ui;
2580
+ }).catch((error) => { this.recordingUiLoad = null; throw error; });
2581
+ return this.recordingUiLoad;
2582
+ }
2583
+ async mountRecordingUi(draft) {
2584
+ try {
2585
+ const ui = this.recordingUi ?? await this.loadRecordingUi();
2586
+ if (this.recordingDraft !== draft)
2587
+ return;
2588
+ const editorHost = this.recordingDialog.querySelector('[data-fb-recording-editor-host]');
2589
+ const playerHost = this.recordingDialog.querySelector('[data-fb-recording-player]');
2590
+ if (!editorHost || !playerHost)
2591
+ return;
2592
+ const focusEditor = !this.recordingEditor;
2593
+ this.recordingEditor ??= new ui.RecordingEditor(editorHost);
2594
+ this.renderRecordingDialog();
2595
+ if (focusEditor)
2596
+ this.recordingEditor.element.focus();
2597
+ if (!this.recordingPlayer) {
2598
+ const player = new ui.RecordingPlayer(playerHost, draft.file);
2599
+ this.recordingPlayer = player;
2600
+ try {
2601
+ await player.ready;
2602
+ }
2603
+ catch (error) {
2604
+ if (this.recordingPlayer === player) {
2605
+ player.destroy();
2606
+ this.recordingPlayer = null;
2607
+ }
2608
+ throw error;
2609
+ }
2610
+ }
2611
+ if (this.recordingDraft === draft) {
2612
+ this.recordingUiFailed = false;
2613
+ this.renderRecordingDialog();
2614
+ }
2615
+ }
2616
+ catch {
2617
+ if (this.recordingDraft !== draft)
2618
+ return;
2619
+ this.recordingUiFailed = true;
2620
+ this.recordingError = 'The recording could not be shown. You can try again or save it without a description.';
2621
+ this.renderRecordingDialog();
2622
+ }
2623
+ }
2624
+ askToDiscardRecording(restart) {
2625
+ if (!this.recordingDraft || this.recordingSaving)
2626
+ return;
2627
+ const active = this.root.activeElement;
2628
+ this.recordingDiscardFocus = active instanceof HTMLElement && this.recordingDialog.contains(active) ? active : null;
2629
+ this.recordingDiscard = { restart };
2630
+ this.renderRecordingDialog();
2631
+ this.recordingDialog.querySelector('[data-fb-action="keep-recording"]')?.focus();
2632
+ }
2633
+ keepRecording() {
2634
+ const restore = this.recordingDiscardFocus;
2635
+ this.recordingDiscard = null;
2636
+ this.recordingDiscardFocus = null;
2637
+ this.renderRecordingDialog();
2638
+ if (restore?.isConnected && !restore.inert)
2639
+ restore.focus();
2640
+ else
2641
+ this.recordingEditor?.element.focus();
2642
+ }
2643
+ discardRecording() {
2644
+ this.recordingPlayer?.destroy();
2645
+ this.recordingPlayer = null;
2646
+ this.recordingEditor = null;
2647
+ this.recordingTray.reset();
2648
+ this.recordingDraft = null;
2649
+ this.recordingDiscard = null;
2650
+ this.recordingDiscardFocus = null;
2651
+ this.pendingRecordingSave = false;
2652
+ this.recordingUiFailed = false;
2653
+ this.recordingError = null;
2654
+ this.render();
2655
+ }
2656
+ async saveRecording() {
2657
+ const draft = this.recordingDraft;
2658
+ if (!draft || this.recordingSaving)
2659
+ return;
2660
+ const body = this.recordingEditor?.markdown() ?? '';
2661
+ if (this.recordingTray.blocked)
2662
+ this.recordingTray.retryFailed();
2663
+ this.recordingSaving = true;
2664
+ this.recordingError = null;
2665
+ this.renderRecordingDialog();
2666
+ await this.recordingTray.settled();
2667
+ if (this.recordingDraft !== draft) {
2668
+ this.recordingSaving = false;
2669
+ return;
2670
+ }
2671
+ if (this.recordingTray.blocked) {
2672
+ this.recordingSaving = false;
2673
+ this.recordingError = 'One file did not upload. Try Save again.';
2674
+ this.renderRecordingDialog();
2675
+ return;
2676
+ }
2677
+ const attachmentIds = this.recordingTray.ids();
2678
+ const recordingUploads = this.recordingTray.items.filter((item) => item.kind === 'recording' && item.upload);
2679
+ if (recordingUploads.length !== 1) {
2680
+ this.recordingSaving = false;
2681
+ this.recordingError = 'The recording did not upload. Try Save again.';
2682
+ this.renderRecordingDialog();
2683
+ return;
2684
+ }
2685
+ let created;
2686
+ try {
2687
+ created = await api.createComment({
2688
+ kind: 'recording',
2689
+ author: this.authorName,
2690
+ authorId: this.identity?.id ?? null,
2691
+ body,
2692
+ anchor: null,
2693
+ context: {
2694
+ route: draft.route,
2695
+ viewport: { w: window.innerWidth, h: window.innerHeight },
2696
+ ...(draft.url ? { url: draft.url } : {}),
2697
+ },
2698
+ recording: { durationMs: draft.durationMs, startedAt: draft.startedAt },
2699
+ journey: draft.journey,
2700
+ ...(draft.journeyTruncated ? { journeyTruncated: true } : {}),
2701
+ attachmentIds,
2702
+ }, draft.createIdentity);
2703
+ }
2704
+ catch (error) {
2705
+ this.recordingSaving = false;
2706
+ const unavailable = unavailableFile(error);
2707
+ const refusedRecording = recordingAttachmentRefusal(error);
2708
+ if (unavailable)
2709
+ this.recordingTray.fail(unavailable, 'No longer available: remove it and add it again');
2710
+ if (refusedRecording) {
2711
+ const recordingId = recordingUploads[0]?.upload?.id;
2712
+ if (recordingId)
2713
+ this.recordingTray.fail(recordingId, 'Upload expired: Save again to retry');
2714
+ // This refusal is definitive and can be cached under the idempotency key. A new upload
2715
+ // therefore gets a new create identity; unknown/network failures keep the old one.
2716
+ draft.createIdentity = { id: newId('cmt'), idempotencyKey: newIdempotencyKey() };
2717
+ }
2718
+ this.recordingError = unavailable
2719
+ ? 'One file could not be sent. Remove it and try again.'
2720
+ : refusedRecording
2721
+ ? 'The recording upload expired. Save again to retry it.'
2722
+ : 'Not saved. Your recording is still here, try again.';
2723
+ if (error instanceof SessionExpiredError && this.shared) {
2724
+ this.pendingRecordingSave = true;
2725
+ this.handleSessionExpired();
2726
+ }
2727
+ else
2728
+ this.renderRecordingDialog();
2729
+ return;
2730
+ }
2731
+ this.recordingSaving = false;
2732
+ this.recordingPlayer?.destroy();
2733
+ this.recordingPlayer = null;
2734
+ this.recordingEditor = null;
2735
+ this.recordingTray.clear();
2736
+ this.recordingDraft = null;
2737
+ this.recordingDiscard = null;
2738
+ this.recordingDiscardFocus = null;
2739
+ this.pendingRecordingSave = false;
2740
+ this.recordingUiFailed = false;
2741
+ this.recordingError = null;
2742
+ this.stickyId = created.id;
2743
+ const [shown] = renderable([created]);
2744
+ if (shown)
2745
+ this.state.applyLocal((comments) => [shown, ...comments.filter((item) => item.id !== shown.id)]);
2746
+ this.render();
2747
+ void this.state.refresh();
2748
+ }
2749
+ renderRecordingDialog() {
2750
+ const draft = this.recordingDraft;
2751
+ this.recordingDialog.hidden = Boolean(draft && this.signIn);
2752
+ if (!draft) {
2753
+ this.recordingDialog.replaceChildren();
2754
+ return;
2755
+ }
2756
+ let dialog = this.recordingDialog.querySelector('[data-fb-recording-dialog]');
2757
+ if (!dialog) {
2758
+ this.recordingDialog.innerHTML = recordingDialogMarkup();
2759
+ dialog = this.recordingDialog.querySelector('[data-fb-recording-dialog]');
2760
+ }
2761
+ const error = dialog.querySelector('[data-fb-recording-error]');
2762
+ if (error) {
2763
+ error.textContent = this.recordingError ?? '';
2764
+ error.hidden = !this.recordingError;
2765
+ }
2766
+ const oldRetry = dialog.querySelector('[data-fb-action="retry-recording-ui"]');
2767
+ if (this.recordingUiFailed && !oldRetry) {
2768
+ error?.insertAdjacentHTML('afterend', '<button type="button" class="fb-threadblock__cancel" data-fb-action="retry-recording-ui">Try loading the editor and player again</button>');
2769
+ }
2770
+ else if (!this.recordingUiFailed)
2771
+ oldRetry?.remove();
2772
+ const tray = dialog.querySelector('[data-fb-recording-tray]');
2773
+ if (tray)
2774
+ tray.innerHTML = trayMarkup(this.recordingTray, 'recording');
2775
+ const blocked = this.recordingSaving || this.recordingDiscard !== null;
2776
+ this.recordingEditor?.setDisabled(blocked);
2777
+ const save = dialog.querySelector('[data-fb-action="save-recording"]');
2778
+ if (save) {
2779
+ save.disabled = blocked || (!this.recordingEditor && !this.recordingUiFailed);
2780
+ save.setAttribute('aria-busy', String(this.recordingSaving));
2781
+ save.textContent = this.recordingSaving ? 'Saving…' : 'Save';
2782
+ }
2783
+ const cancel = dialog.querySelector('[data-fb-action="cancel-recording"]');
2784
+ if (cancel)
2785
+ cancel.disabled = blocked;
2786
+ const attach = dialog.querySelector('[data-fb-action="attach"]');
2787
+ if (attach)
2788
+ attach.disabled = blocked;
2789
+ const card = dialog.querySelector('.fb-recording-dialog__card');
2790
+ if (card) {
2791
+ card.inert = this.recordingDiscard !== null;
2792
+ card.setAttribute('aria-hidden', String(this.recordingDiscard !== null));
2793
+ }
2794
+ const existing = dialog.querySelector('[data-fb-recording-discard]');
2795
+ if (this.recordingDiscard && !existing)
2796
+ dialog.insertAdjacentHTML('beforeend', recordingDiscardMarkup());
2797
+ else if (!this.recordingDiscard)
2798
+ existing?.remove();
2799
+ }
2800
+ async mountThreadRecording(comment, generation) {
2801
+ const attachment = comment.attachments?.find((item) => item.kind === 'recording');
2802
+ const host = this.popover.querySelector('[data-fb-recording-thread-player]');
2803
+ if (!attachment || !host)
2804
+ return;
2805
+ const key = `${comment.id}:${attachment.id}`;
2806
+ if (this.threadRecordingFile?.key !== key) {
2807
+ this.threadRecordingFile?.abort.abort();
2808
+ const abort = new AbortController();
2809
+ this.threadRecordingFile = { key, abort, promise: api.attachmentBlob(comment.id, attachment.id, abort.signal) };
2810
+ }
2811
+ const loading = this.threadRecordingFile;
2812
+ try {
2813
+ const [ui, file] = await Promise.all([this.recordingUi ?? this.loadRecordingUi(), loading.promise]);
2814
+ if (this.threadRecordingFile === loading)
2815
+ this.threadRecordingFile = null;
2816
+ if (generation !== this.threadRecordingGeneration || this.state.openThreadId !== comment.id || !host.isConnected)
2817
+ return;
2818
+ const player = new ui.RecordingPlayer(host, file);
2819
+ this.threadRecordingPlayer = player;
2820
+ this.threadRecordingPlayerId = comment.id;
2821
+ try {
2822
+ await player.ready;
2823
+ }
2824
+ catch (error) {
2825
+ if (this.threadRecordingPlayer === player) {
2826
+ this.threadRecordingPlayer = null;
2827
+ this.threadRecordingPlayerId = null;
2828
+ }
2829
+ throw error;
2830
+ }
2831
+ }
2832
+ catch {
2833
+ if (this.threadRecordingFile === loading) {
2834
+ loading.abort.abort();
2835
+ this.threadRecordingFile = null;
2836
+ }
2837
+ if (generation === this.threadRecordingGeneration && host.isConnected)
2838
+ host.textContent = 'The recording could not be played.';
2839
+ }
2840
+ }
2249
2841
  /** The indicator that says the page is being recorded: a dot, the time, and the button that stops it. */
2250
2842
  renderRecorder() {
2251
2843
  const pill = this.root.querySelector('[data-fb-recorder]');
@@ -2254,16 +2846,38 @@ class FeedbackOverlay {
2254
2846
  if (!this.recording) {
2255
2847
  pill.hidden = true;
2256
2848
  pill.innerHTML = '';
2849
+ delete pill.dataset.phase;
2850
+ this.showCountdown();
2257
2851
  return;
2258
2852
  }
2259
- if (!pill.hidden)
2853
+ const phase = this.recording.countdown === null ? 'recording' : 'countdown';
2854
+ if (!pill.hidden && pill.dataset.phase === phase)
2260
2855
  return;
2261
2856
  pill.hidden = false;
2262
- // Announced once, when it starts; the time is not read out every second.
2263
- pill.innerHTML = `<span class="fb-sr" role="status">Recording started. Stop recording is the last button on the page.</span>
2857
+ pill.dataset.phase = phase;
2858
+ // Each is announced once, when it begins; the time and the seconds are not read out as they change.
2859
+ pill.innerHTML = phase === 'countdown'
2860
+ ? `<span class="fb-sr" role="status">Recording starts in ${COUNTDOWN_SECONDS} seconds. Cancel recording is the last button on the page.</span>
2861
+ <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>
2862
+ <button type="button" class="fb-recorder__stop" data-fb-action="stop-recording" aria-label="Cancel recording">Cancel</button>`
2863
+ : `<span class="fb-sr" role="status">Recording started. Stop recording is the last button on the page.</span>
2264
2864
  <span class="fb-recorder__dot" aria-hidden="true"></span><span class="fb-recorder__label" aria-hidden="true">Recording</span>
2265
2865
  <span class="fb-recorder__time" data-fb-recorder-time aria-hidden="true">${clock(0)} / ${clock(this.recording.limit.seconds * 1000)}</span>
2266
2866
  <button type="button" class="fb-recorder__stop" data-fb-action="stop-recording" aria-label="Stop recording">Stop</button>`;
2867
+ this.showCountdown();
2868
+ }
2869
+ /** The seconds left, big on the page and in the indicator; both gone once the recording starts. */
2870
+ showCountdown() {
2871
+ const big = this.root.querySelector('[data-fb-countdown]');
2872
+ if (!big)
2873
+ return;
2874
+ const left = this.recording?.countdown;
2875
+ big.hidden = left == null;
2876
+ if (left != null)
2877
+ big.textContent = String(left);
2878
+ const text = this.root.querySelector('[data-fb-countdown-text]');
2879
+ if (text && left != null)
2880
+ text.textContent = String(left);
2267
2881
  }
2268
2882
  showRecordingTime(elapsed) {
2269
2883
  if (!this.recording)
@@ -2277,7 +2891,7 @@ class FeedbackOverlay {
2277
2891
  dropTarget(event) {
2278
2892
  const block = event.composedPath().find((node) => node instanceof HTMLElement && node.dataset.fbDrop !== undefined);
2279
2893
  const which = block?.dataset.fbDrop;
2280
- return (which === 'draft' || which === 'reply') && this.takesFiles(which) ? which : null;
2894
+ return (which === 'draft' || which === 'reply' || which === 'recording') && this.takesFiles(which) ? which : null;
2281
2895
  }
2282
2896
  /**
2283
2897
  * Files over a composer are ours: the browser does not open them in place of the page, and the
@@ -2289,7 +2903,7 @@ class FeedbackOverlay {
2289
2903
  return;
2290
2904
  event.preventDefault();
2291
2905
  event.stopPropagation();
2292
- event.dataTransfer.dropEffect = this.sending === which ? 'none' : 'copy';
2906
+ event.dataTransfer.dropEffect = (which === 'recording' ? this.recordingSaving : this.sending === which) ? 'none' : 'copy';
2293
2907
  }
2294
2908
  onComposerDrop(event) {
2295
2909
  const which = this.dropTarget(event);
@@ -2298,7 +2912,7 @@ class FeedbackOverlay {
2298
2912
  return;
2299
2913
  event.preventDefault();
2300
2914
  event.stopPropagation();
2301
- if (this.sending === which)
2915
+ if (which === 'recording' ? this.recordingSaving : this.sending === which)
2302
2916
  return;
2303
2917
  this.trayFor(which).add(files);
2304
2918
  }
@@ -2306,7 +2920,7 @@ class FeedbackOverlay {
2306
2920
  onComposerPaste(event) {
2307
2921
  const which = this.dropTarget(event);
2308
2922
  const images = Array.from(event.clipboardData?.files ?? []).filter((file) => file.type.startsWith('image/'));
2309
- if (!which || !images.length || this.sending === which)
2923
+ if (!which || !images.length || (which === 'recording' ? this.recordingSaving : this.sending === which))
2310
2924
  return;
2311
2925
  event.stopPropagation();
2312
2926
  // A pasted screenshot carries no text; a copied picture with a caption keeps its caption.
@@ -2493,6 +3107,8 @@ class FeedbackOverlay {
2493
3107
  ...(instances > 1 ? { choice: draft.scopeChoice } : {}),
2494
3108
  },
2495
3109
  pinOffset: draft.offset,
3110
+ // Inside a dialog or drawer: what opened it, so the comment can open it again from the list.
3111
+ opener: openerFor(chosen.element),
2496
3112
  context: {
2497
3113
  route: window.location.pathname,
2498
3114
  viewport: { w: window.innerWidth, h: window.innerHeight },
@@ -2594,6 +3210,11 @@ class FeedbackOverlay {
2594
3210
  return;
2595
3211
  this.state.panelOpen = false;
2596
3212
  this.panelView = 'feedback';
3213
+ if (isRecording(comment)) {
3214
+ this.stickyId = id;
3215
+ this.openThread(id, from);
3216
+ return;
3217
+ }
2597
3218
  const route = comment.context?.route;
2598
3219
  if (route && !belongsOnThisPage(comment)) {
2599
3220
  // Only a same-origin path: the route is stored content, and any reviewer can write it.
@@ -2612,6 +3233,9 @@ class FeedbackOverlay {
2612
3233
  this.openThread(id, from);
2613
3234
  return;
2614
3235
  }
3236
+ // Left in a dialog that is closed now: open it first, so the comment shows where it was made.
3237
+ this.render();
3238
+ await openDialogFor(comment, locateComment);
2615
3239
  this.openThread(id);
2616
3240
  this.scrollToComment(id);
2617
3241
  }
@@ -2634,6 +3258,12 @@ class FeedbackOverlay {
2634
3258
  openThread(id, back = null) {
2635
3259
  this.sheetBack = back;
2636
3260
  if (this.state.openThreadId !== id) {
3261
+ this.threadRecordingPlayer?.destroy();
3262
+ this.threadRecordingPlayer = null;
3263
+ this.threadRecordingPlayerId = null;
3264
+ this.threadRecordingFile?.abort.abort();
3265
+ this.threadRecordingFile = null;
3266
+ this.threadRecordingGeneration += 1;
2637
3267
  this.replyBody = '';
2638
3268
  this.abandonReplyFiles();
2639
3269
  this.clearSticky();
@@ -2646,6 +3276,12 @@ class FeedbackOverlay {
2646
3276
  this.render();
2647
3277
  }
2648
3278
  closeThread() {
3279
+ this.threadRecordingPlayer?.destroy();
3280
+ this.threadRecordingPlayer = null;
3281
+ this.threadRecordingPlayerId = null;
3282
+ this.threadRecordingFile?.abort.abort();
3283
+ this.threadRecordingFile = null;
3284
+ this.threadRecordingGeneration += 1;
2649
3285
  this.state.openThreadId = null;
2650
3286
  this.sheetBack = null;
2651
3287
  this.abandonReplyFiles();
@@ -2751,10 +3387,14 @@ class FeedbackOverlay {
2751
3387
  // Its send button is disabled until the file that failed is removed; Enter does nothing either.
2752
3388
  if (this.replyTray.blocked)
2753
3389
  return;
2754
- // SPEC 5: a reply's anchor is resolved now, not inherited from the thread.
2755
- const element = locateComment(comment);
2756
- const found = element ? anchorCandidatesFor(element)[0] : undefined;
2757
- const currentAnchor = found ? { ...found.anchor, element: describeElement(found.element) } : comment.anchor;
3390
+ // SPEC 5: a pin reply's anchor is resolved now, not inherited from the thread. Recordings have no anchor.
3391
+ const currentAnchor = isRecording(comment)
3392
+ ? { file: '', line: 0, column: 0, componentName: null, domPath: '', textSnippet: null }
3393
+ : (() => {
3394
+ const element = locateComment(comment);
3395
+ const found = element ? anchorCandidatesFor(element)[0] : undefined;
3396
+ return found ? { ...found.anchor, element: describeElement(found.element) } : comment.anchor;
3397
+ })();
2758
3398
  this.sending = 'reply';
2759
3399
  this.saveError = null;
2760
3400
  this.render();
@@ -2962,6 +3602,7 @@ class FeedbackOverlay {
2962
3602
  this.updatePinCursor();
2963
3603
  this.renderBar();
2964
3604
  this.renderJoinDialog();
3605
+ this.renderRecordingDialog();
2965
3606
  this.renderPins();
2966
3607
  this.drawnFiles = new Set();
2967
3608
  this.renderPopover();
@@ -3056,7 +3697,7 @@ class FeedbackOverlay {
3056
3697
  delete this.bar.dataset.compact;
3057
3698
  this.bar.innerHTML = closed
3058
3699
  ? closedBarMarkup()
3059
- : openBarMarkup(this.state, this.identity, this.notifications?.unread ?? 0);
3700
+ : openBarMarkup(this.state, this.identity, this.notifications?.unread ?? 0, this.recordOffered());
3060
3701
  // After the markup: the open bar is wider than the closed one, and the placement is
3061
3702
  // clamped against the size it actually has.
3062
3703
  this.placeBar();
@@ -3527,7 +4168,7 @@ class FeedbackOverlay {
3527
4168
  if (!this.state.chipsVisible && !this.draft && !this.compact) {
3528
4169
  return;
3529
4170
  }
3530
- const visible = this.visibleWithSticky().filter((comment) => belongsOnThisPage(comment));
4171
+ const visible = this.visibleWithSticky().filter((comment) => !isRecording(comment) && belongsOnThisPage(comment));
3531
4172
  if (this.draft && this.draftAnchorVisible()) {
3532
4173
  const pending = document.createElement('span');
3533
4174
  pending.className = 'fb-pin';
@@ -3728,6 +4369,33 @@ class FeedbackOverlay {
3728
4369
  this.popover.innerHTML = '';
3729
4370
  return;
3730
4371
  }
4372
+ if (isRecording(thread)) {
4373
+ const active = this.activeTextarea();
4374
+ const retainedHost = this.threadRecordingPlayer && this.threadRecordingPlayerId === thread.id
4375
+ ? this.popover.querySelector('[data-fb-recording-thread-player]')
4376
+ : null;
4377
+ if (this.threadRecordingPlayer && !retainedHost) {
4378
+ this.threadRecordingPlayer.destroy();
4379
+ this.threadRecordingPlayer = null;
4380
+ this.threadRecordingPlayerId = null;
4381
+ this.threadRecordingGeneration += 1;
4382
+ }
4383
+ const generation = retainedHost ? this.threadRecordingGeneration : ++this.threadRecordingGeneration;
4384
+ const composing = this.editingKey ? this.editingBody : this.replyBody;
4385
+ this.popover.dataset.draft = 'false';
4386
+ this.popover.dataset.resolved = String(thread.status === 'resolved');
4387
+ this.popover.innerHTML = 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'),
4388
+ 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));
4389
+ if (retainedHost) {
4390
+ this.popover.querySelector('[data-fb-recording-thread-player]')?.replaceWith(retainedHost);
4391
+ }
4392
+ this.popover.style.display = 'block';
4393
+ this.positionPopover();
4394
+ this.restoreTextarea(this.editingKey ? '[data-fb-edit-body]' : '[data-fb-reply]', composing, this.editingKey ? !this.compact || active === 'body' : active === 'reply');
4395
+ if (!retainedHost)
4396
+ void this.mountThreadRecording(thread, generation);
4397
+ return;
4398
+ }
3731
4399
  const active = this.activeTextarea();
3732
4400
  const threadPin = this.pinLayer.querySelector(`.fb-pin[data-fb-value="${thread.id}"]`);
3733
4401
  // On a phone the thread is a sheet: it does not need its pin on screen (the audit's F10, F11).
@@ -3987,6 +4655,11 @@ class FeedbackOverlay {
3987
4655
  return;
3988
4656
  }
3989
4657
  if (this.state.openThreadId) {
4658
+ const comment = this.state.comments.find((item) => item.id === this.state.openThreadId);
4659
+ if (comment && isRecording(comment)) {
4660
+ this.popover.style.display = 'block';
4661
+ return;
4662
+ }
3990
4663
  const pin = this.pinLayer.querySelector(`.fb-pin[data-fb-value="${this.state.openThreadId}"]`);
3991
4664
  this.popover.style.display = pin ? 'block' : 'none';
3992
4665
  }
@@ -4064,12 +4737,13 @@ class FeedbackOverlay {
4064
4737
  this.panel.dataset.view = this.panelView;
4065
4738
  if (this.panelView !== 'feedback')
4066
4739
  this.listFilter = null;
4067
- const shown = this.visibleWithSticky();
4740
+ const shown = this.visibleWithSticky().filter((comment) => this.kindFilter === 'all'
4741
+ || (this.kindFilter === 'recording' ? isRecording(comment) : !isRecording(comment)));
4068
4742
  const listed = this.listFilter ? shown.filter((comment) => this.listFilter.includes(comment.id)) : shown;
4069
4743
  this.panelContent.innerHTML = panelMarkup(this.state, listed, this.selection, this.shared !== null, this.notifications, this.panelView,
4070
4744
  // A script-tag install, on a live site: the reviewer needs a way back to being a visitor.
4071
4745
  // A magic-link reviewer on a build preview too: leaving is how the stored key is removed.
4072
- this.shared !== null && (!this.shared.buildId || this.direct !== null), this.shared?.devReviewLinks ?? false, this.listFilter ? listed.length : null);
4746
+ this.shared !== null && (!this.shared.buildId || this.direct !== null), this.shared?.devReviewLinks ?? false, this.listFilter ? listed.length : null, this.kindFilter);
4073
4747
  this.positionPanelToast();
4074
4748
  }
4075
4749
  isOverlayEvent(event) {
@@ -4092,12 +4766,46 @@ function shellMarkup() {
4092
4766
  <input type="file" multiple hidden data-fb-file-input tabindex="-1" aria-hidden="true">
4093
4767
  <div data-fb-toast class="fb-toast" role="status"></div>
4094
4768
  <div data-fb-recorder class="fb-recorder" hidden></div>
4769
+ <div data-fb-countdown class="fb-countdown" aria-hidden="true" hidden></div>
4095
4770
  <div data-fb-bar class="fb-bar" role="toolbar" aria-label="Feedback"></div>
4096
4771
  <div data-fb-tip class="fb-tip" role="tooltip" aria-hidden="true"></div>
4772
+ <div data-fb-recording-mount></div>
4097
4773
  <!-- Last: at the same z-index as the toolbar, the full-size image covers it. -->
4098
4774
  <div data-fb-lightbox class="fb-lightbox" role="dialog" aria-modal="true" aria-label="Image, full size" hidden></div>
4099
4775
  `;
4100
4776
  }
4777
+ function recordingDialogMarkup() {
4778
+ return `<div data-fb-recording-dialog class="fb-recording-dialog" role="dialog" aria-modal="true" aria-label="Recording">
4779
+ <section class="fb-recording-dialog__card" data-fb-drop="recording">
4780
+ <header class="fb-recording-dialog__head">
4781
+ <h2>Recording</h2>
4782
+ <button type="button" class="fb-icon-btn" data-fb-action="cancel-recording" aria-label="Cancel">${icon('close', 16)}</button>
4783
+ </header>
4784
+ <div class="fb-recording-dialog__columns">
4785
+ <div class="fb-recording-dialog__player" data-fb-recording-player><span class="fb-recording-loading">Loading recording…</span></div>
4786
+ <div class="fb-recording-dialog__compose">
4787
+ <div data-fb-recording-error class="fb-savefail" role="alert" hidden></div>
4788
+ <div data-fb-recording-editor-host><span class="fb-recording-loading">Loading editor…</span></div>
4789
+ <div data-fb-recording-tray></div>
4790
+ <div class="fb-recording-dialog__actions">
4791
+ ${attachButton('recording', false)}
4792
+ <button type="button" class="fb-threadblock__cancel" data-fb-action="cancel-recording">Cancel</button>
4793
+ <button type="button" class="fb-primary" data-fb-action="save-recording">Save</button>
4794
+ </div>
4795
+ </div>
4796
+ </div>
4797
+ </section>
4798
+ </div>`;
4799
+ }
4800
+ function recordingDiscardMarkup() {
4801
+ return `<div class="fb-recording-discard" data-fb-recording-discard role="alertdialog" aria-modal="true" aria-label="Discard this recording?">
4802
+ <div class="fb-recording-discard__card">
4803
+ <p>Discard this recording?</p>
4804
+ <div><button type="button" class="fb-threadblock__cancel" data-fb-action="keep-recording">Keep</button>
4805
+ <button type="button" class="fb-primary" data-fb-action="discard-recording">Discard</button></div>
4806
+ </div>
4807
+ </div>`;
4808
+ }
4101
4809
  /** Always draws something: an empty slot next to the input reads as a broken avatar. */
4102
4810
  function composerAvatar(identity) {
4103
4811
  return identity
@@ -4111,7 +4819,7 @@ function closedBarMarkup() {
4111
4819
  return `<button type="button" data-fb-action="close-overlay" data-tip="Show feedback" data-tip-keys="${toggleKeys}"
4112
4820
  aria-label="Show feedback" aria-keyshortcuts="Alt+Shift+F">${icon('comment', 17)}</button>`;
4113
4821
  }
4114
- function openBarMarkup(state, identity, unread = 0) {
4822
+ function openBarMarkup(state, identity, unread = 0, record = false) {
4115
4823
  const commenting = state.mode === 'commenting';
4116
4824
  const count = state.routeCount();
4117
4825
  unread += state.newRemoteComments;
@@ -4134,6 +4842,8 @@ function openBarMarkup(state, identity, unread = 0) {
4134
4842
  * the panel, where there is room to say what it is counting.
4135
4843
  */
4136
4844
  unread > 0 ? '<span class="fb-dot" aria-label="Unread feedback"></span>' : ''}</button>
4845
+ ${record ? `<button type="button" data-fb-action="record-journey" data-tip="Record" data-tip-keys="Alt+Shift+R"
4846
+ aria-label="Record" aria-keyshortcuts="Alt+Shift+R"><span class="fb-toolbar-word">Record</span></button>` : ''}
4137
4847
  ${state.remoteNotice ? `<span role="status" style="font-size:11px;max-width:180px">${escapeHtml(state.remoteNotice)}</span>` : ''}
4138
4848
  <span class="fb-sep"></span>
4139
4849
  ${identity
@@ -4467,6 +5177,13 @@ function threadMarkup(comment, identity, value, editing, editError, sending, fil
4467
5177
  ${threadComposerMarkup(comment, identity, value, editing, editError, sending, files)}
4468
5178
  `;
4469
5179
  }
5180
+ function recordingThreadMarkup(comment, identity, value, editing, editError, sending, files, fileUrl, back = false, changeable = true) {
5181
+ const markup = threadMarkup(comment, identity, value, editing, editError, sending, files, fileUrl, back, changeable);
5182
+ const duration = clock(comment.recording?.durationMs ?? 0);
5183
+ return markup.replace('<div class="fb-card-body">', `<div class="fb-recording-thread-head"><span>Recording</span><time>${escapeHtml(duration)}</time></div>
5184
+ <div data-fb-recording-thread-player class="fb-recording-thread-player"><span class="fb-recording-loading">Loading recording…</span></div>
5185
+ <div class="fb-card-body">`);
5186
+ }
4470
5187
  /**
4471
5188
  * The one place in a thread where anything is typed, and the one place the actions live.
4472
5189
  *
@@ -4586,7 +5303,7 @@ function notificationPanelMarkup(notifications) {
4586
5303
  <div class="fb-list">${body}</div>
4587
5304
  `;
4588
5305
  }
4589
- function panelMarkup(state, comments, selection, shared = false, notifications = null, view = 'feedback', scriptTag = false, devReviewLinks = false, filtered = null) {
5306
+ function panelMarkup(state, comments, selection, shared = false, notifications = null, view = 'feedback', scriptTag = false, devReviewLinks = false, filtered = null, kindFilter = 'all') {
4590
5307
  // The notification list replaces the feedback list rather than sitting beside it: the panel
4591
5308
  // is narrow, and two scrolling lists in it would each be too short to read.
4592
5309
  if (view === 'notifications' && notifications) {
@@ -4608,25 +5325,29 @@ function panelMarkup(state, comments, selection, shared = false, notifications =
4608
5325
  .map(([file, grouped]) => {
4609
5326
  const items = grouped
4610
5327
  .map((comment) => {
4611
- // On another page it is neither orphaned nor off screen: it is on its page.
4612
- const elsewhere = !belongsOnThisPage(comment);
4613
- // Found but not drawn (a closed dialog, menu or tab), or not on this page at all.
4614
- const element = elsewhere ? null : locateComment(comment);
4615
- const orphaned = !elsewhere && element === null;
5328
+ const recording = isRecording(comment);
5329
+ // A recording has a route but no anchor; it is never orphaned or hidden.
5330
+ const elsewhere = recording ? false : !belongsOnThisPage(comment);
5331
+ const element = recording || elsewhere ? null : locateComment(comment);
5332
+ const orphaned = !recording && !elsewhere && element === null;
4616
5333
  const hidden = element !== null && !shownOnPage(element);
4617
5334
  const checked = selection.has(comment.id);
4618
5335
  const latest = comment.replies.at(-1) ?? comment;
5336
+ const summary = recording
5337
+ ? `<b>Recording</b> &middot; ${escapeHtml(clock(comment.recording?.durationMs ?? 0))}${latest.body ? ` &middot; ${escapeHtml(latest.body)}` : ''}`
5338
+ : escapeHtml(latest.body);
5339
+ const anchorMeta = recording ? '' : comment.anchor.file ? `${escapeHtml(`line ${comment.anchor.line}`)} &middot; ` : '';
5340
+ const locationMeta = recording || elsewhere ? ''
5341
+ : orphaned ? (comment.anchor.file ? ' &middot; orphaned' : ' &middot; not on this page')
5342
+ : hidden ? ' &middot; hidden right now' : '';
4619
5343
  return `
4620
- <div class="fb-item" data-status="${comment.status}" data-fb-action="focus-comment" data-fb-value="${comment.id}">
5344
+ <div class="fb-item" data-status="${comment.status}" data-kind="${recording ? 'recording' : 'pin'}" data-fb-action="focus-comment" data-fb-value="${comment.id}">
4621
5345
  ${avatarMarkup(comment.author, colorForId(comment.authorId ?? comment.author), 'sm')}
4622
5346
  <span>
4623
- <p>${escapeHtml(latest.body)}</p>
4624
- <small>${
4625
- // A line is only worth showing where it is known: on a preview the browser
4626
- // never sees a path, and every comment read "line 0".
4627
- comment.anchor.file ? `${escapeHtml(`line ${comment.anchor.line}`)} &middot; ` : ''}${escapeHtml(comment.author)}${comment.authorUnverified ? ' (unverified)' : ''}${comment.replies.length > 0
5347
+ <p>${summary}</p>
5348
+ <small>${anchorMeta}${escapeHtml(comment.author)}${comment.authorUnverified ? ' (unverified)' : ''}${comment.replies.length > 0
4628
5349
  ? ` &middot; ${comment.replies.length} ${comment.replies.length === 1 ? 'reply' : 'replies'}`
4629
- : ''}${elsewhere ? '' : orphaned ? (comment.anchor.file ? ' &middot; orphaned' : ' &middot; not on this page') : hidden ? ' &middot; hidden right now' : ''}</small>
5350
+ : ''}${locationMeta}</small>
4630
5351
  </span>
4631
5352
  <button type="button" class="fb-select" data-selected="${checked}"
4632
5353
  data-fb-action="toggle-selection" data-fb-value="${comment.id}"
@@ -4665,6 +5386,10 @@ function panelMarkup(state, comments, selection, shared = false, notifications =
4665
5386
  aria-pressed="${state.filter === value}">${value[0].toUpperCase()}${value.slice(1)}</button>`)
4666
5387
  .join('')}
4667
5388
  </div>
5389
+ <div class="fb-segmented fb-segmented--kind" role="group" aria-label="Feedback kind">
5390
+ ${[['all', 'All'], ['pin', 'Comments'], ['recording', 'Recordings']].map(([value, label]) => `<button type="button" data-fb-action="set-kind-filter" data-fb-value="${value}"
5391
+ aria-pressed="${kindFilter === value}">${label}</button>`).join('')}
5392
+ </div>
4668
5393
  ${filtered !== null ? `<div class="fb-listfilter"><span>${filtered} ${filtered === 1 ? 'comment' : 'comments'} here</span>
4669
5394
  <button type="button" class="fb-link" data-fb-action="clear-list-filter">Show all</button></div>` : ''}
4670
5395
  <div class="fb-list">${list}</div>
@@ -4782,6 +5507,8 @@ function offsetWithin(element, point) {
4782
5507
  * does not (a preview, where every file is blank and they all fell into one unnamed group).
4783
5508
  */
4784
5509
  function groupOf(comment) {
5510
+ if (isRecording(comment))
5511
+ return 'Recordings';
4785
5512
  if (comment.anchor.file)
4786
5513
  return comment.anchor.file;
4787
5514
  const route = comment.context?.route ?? '';