@in-the-loop-labs/pair-review 5.3.7 → 5.4.1

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 (59) hide show
  1. package/README.md +8 -0
  2. package/package.json +3 -3
  3. package/plugin/.claude-plugin/plugin.json +1 -1
  4. package/plugin-code-critic/.claude-plugin/plugin.json +1 -1
  5. package/plugin-pair-loop/.claude-plugin/plugin.json +1 -1
  6. package/public/css/pr.css +389 -13
  7. package/public/index.html +1 -0
  8. package/public/js/components/AIPanel.js +317 -99
  9. package/public/js/components/AdvancedConfigTab.js +18 -108
  10. package/public/js/components/ReviewHistoryModal.js +294 -0
  11. package/public/js/components/ReviewModal.js +96 -7
  12. package/public/js/components/SplitButton.js +14 -0
  13. package/public/js/components/VoiceCentricConfigTab.js +18 -108
  14. package/public/js/index.js +18 -5
  15. package/public/js/local.js +4 -8
  16. package/public/js/modules/comment-manager.js +2 -1
  17. package/public/js/modules/diff-renderer.js +7 -6
  18. package/public/js/modules/file-comment-manager.js +6 -2
  19. package/public/js/modules/pierre-bridge.js +35 -1
  20. package/public/js/modules/suggestion-manager.js +4 -1
  21. package/public/js/pr.js +174 -66
  22. package/public/js/utils/council-timeout.js +203 -0
  23. package/public/js/utils/posted-comment.js +259 -14
  24. package/public/js/vendor/pierre-diffs-worker.js +41 -13485
  25. package/public/js/vendor/pierre-diffs.js +131 -1364
  26. package/public/local.html +4 -0
  27. package/public/pr.html +5 -0
  28. package/src/ai/copilot-provider.js +21 -2
  29. package/src/ai/cursor-agent-provider.js +21 -2
  30. package/src/ai/opencode-provider.js +21 -2
  31. package/src/chat/api-reference.js +22 -2
  32. package/src/config.js +28 -4
  33. package/src/database.js +416 -114
  34. package/src/git/worktree-pool-lifecycle.js +152 -33
  35. package/src/git/worktree-pool-usage.js +20 -0
  36. package/src/git/worktree.js +14 -5
  37. package/src/github/client.js +70 -15
  38. package/src/github/impl/graphql/pending-review-comments.js +50 -11
  39. package/src/github/impl/graphql/pending-review.js +8 -2
  40. package/src/github/impl/graphql/review-comment-edit.js +89 -0
  41. package/src/github/impl/host/pending-review-comments.js +41 -10
  42. package/src/github/impl/host/review-comment-edit.js +36 -0
  43. package/src/github/impl/rest/pending-review.js +6 -2
  44. package/src/github/impl/rest/review-comment-edit.js +44 -0
  45. package/src/github/impl/review-comment-edit-utils.js +45 -0
  46. package/src/github/operations/pending-review.js +4 -3
  47. package/src/github/operations/review-comment-edit.js +35 -0
  48. package/src/github/record-submission.js +78 -0
  49. package/src/github/update-posted-comment.js +115 -0
  50. package/src/main.js +42 -50
  51. package/src/routes/mcp.js +1 -0
  52. package/src/routes/pr.js +158 -120
  53. package/src/routes/reviews.js +8 -30
  54. package/src/routes/setup.js +22 -9
  55. package/src/setup/pr-setup.js +12 -3
  56. package/src/utils/diff-file-content.js +62 -25
  57. package/src/utils/json-extractor.js +267 -13
  58. package/src/utils/pr-file-blob-cache.js +134 -0
  59. package/src/utils/process-liveness.js +64 -0
@@ -20,11 +20,8 @@ class AIPanel {
20
20
  filter: `<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor">
21
21
  <path d="M.75 3h14.5a.75.75 0 010 1.5H.75a.75.75 0 010-1.5zM3 7.75A.75.75 0 013.75 7h8.5a.75.75 0 010 1.5h-8.5A.75.75 0 013 7.75zm3 4a.75.75 0 01.75-.75h2.5a.75.75 0 010 1.5h-2.5a.75.75 0 01-.75-.75z"></path>
22
22
  </svg>`,
23
- eye: `<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor">
24
- <path d="M8 2c1.981 0 3.671.992 4.933 2.078 1.27 1.091 2.187 2.345 2.637 3.023a1.62 1.62 0 0 1 0 1.798c-.45.678-1.367 1.932-2.637 3.023C11.67 13.008 9.981 14 8 14c-1.981 0-3.671-.992-4.933-2.078C1.797 10.83.88 9.576.43 8.898a1.62 1.62 0 0 1 0-1.798c.45-.677 1.367-1.931 2.637-3.022C4.33 2.992 6.019 2 8 2ZM1.679 7.932a.12.12 0 0 0 0 .136c.411.622 1.241 1.75 2.366 2.717C5.176 11.758 6.527 12.5 8 12.5c1.473 0 2.825-.742 3.955-1.715 1.124-.967 1.954-2.096 2.366-2.717a.12.12 0 0 0 0-.136c-.412-.621-1.242-1.75-2.366-2.717C10.824 4.242 9.473 3.5 8 3.5c-1.473 0-2.825.742-3.955 1.715-1.124.967-1.954 2.096-2.366 2.717ZM8 10a2 2 0 1 1-.001-3.999A2 2 0 0 1 8 10Z"></path>
25
- </svg>`,
26
- eyeClosed: `<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor">
27
- <path d="M.143 2.31a.75.75 0 0 1 1.047-.167l14.5 10.5a.75.75 0 1 1-.88 1.214l-2.248-1.628C11.346 13.19 9.792 14 8 14c-1.981 0-3.67-.992-4.933-2.078C1.797 10.832.88 9.577.43 8.9a1.619 1.619 0 0 1 0-1.797c.353-.533.995-1.42 1.868-2.305L.31 3.357A.75.75 0 0 1 .143 2.31Zm1.536 5.622A.12.12 0 0 0 1.657 8c0 .021.006.045.022.068.412.621 1.242 1.75 2.366 2.717C5.175 11.758 6.527 12.5 8 12.5c1.195 0 2.31-.488 3.29-1.191L9.063 9.695A2 2 0 0 1 6.058 7.52L3.529 5.688a14.207 14.207 0 0 0-1.85 2.244ZM8 3.5c-.516 0-1.017.09-1.499.251a.75.75 0 1 1-.473-1.423A6.207 6.207 0 0 1 8 2c1.981 0 3.67.992 4.933 2.078 1.27 1.091 2.187 2.345 2.637 3.023a1.62 1.62 0 0 1 0 1.798c-.11.166-.248.365-.41.587a.75.75 0 1 1-1.21-.887c.148-.201.272-.382.371-.53a.119.119 0 0 0 0-.137c-.412-.621-1.242-1.75-2.366-2.717C10.825 4.242 9.473 3.5 8 3.5Z"></path>
23
+ funnel: `<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor" aria-hidden="true">
24
+ <path fill-rule="evenodd" d="M.75 2h14.5a.75.75 0 0 1 .58 1.22L10 10.37v3.88a.75.75 0 0 1-1.13.65l-2.5-1.46A.75.75 0 0 1 6 12.8v-2.43L.17 3.22A.75.75 0 0 1 .75 2Zm1.58 1.5 4.99 6.1a.75.75 0 0 1 .18.48v2.3l1 .58v-2.88a.75.75 0 0 1 .18-.48l4.99-6.1H2.33Z"></path>
28
25
  </svg>`
29
26
  };
30
27
 
@@ -51,8 +48,11 @@ class AIPanel {
51
48
  // Canonical file order for consistent sorting across components
52
49
  this.fileOrder = new Map(); // Map of file path -> index
53
50
 
54
- // Filter toggle state for showing dismissed comments (default: hidden)
51
+ // "Show dismissed" filter for user comments (default: hidden). The
52
+ // "Show posted" filter lives in PostedComment (see showPostedComments).
55
53
  this.showDismissedComments = false;
54
+ // User comments the filters hide, counted by PRManager from its data
55
+ this.hiddenCommentCounts = { posted: 0, dismissed: 0 };
56
56
 
57
57
  this.initElements();
58
58
  this.bindEvents();
@@ -104,8 +104,9 @@ class AIPanel {
104
104
  this.segmentScrollRight = document.getElementById('segment-scroll-right');
105
105
  this.segmentExternalBtn = this.segmentControl?.querySelector('.segment-btn[data-segment="external"]');
106
106
 
107
- // Create filter toggle button (will be inserted after segment control)
108
- this.filterToggleBtn = null; // Created dynamically in createFilterToggle()
107
+ // Comment filter menu (created dynamically in createFilterMenu())
108
+ this.filterMenuBtn = null;
109
+ this.filterMenu = null;
109
110
 
110
111
  // Level filter
111
112
  this.levelFilter = document.getElementById('level-filter');
@@ -118,44 +119,273 @@ class AIPanel {
118
119
  // AI Summary data
119
120
  this.summaryData = null;
120
121
 
121
- // Create filter toggle if segment control exists
122
+ // Create the comment filter menu if segment control exists
122
123
  if (this.segmentControl) {
123
- this.createFilterToggle();
124
+ this.createFilterMenu();
125
+ }
126
+ }
127
+
128
+ /**
129
+ * Create the comment filter menu: a funnel button at the right of the
130
+ * segment row that opens a small popover of labeled options. The options
131
+ * only affect user comments. Local mode has no posted comments, so it
132
+ * gets no "Show posted" option.
133
+ */
134
+ createFilterMenu() {
135
+ const wrapper = document.createElement('div');
136
+ wrapper.className = 'comment-filter';
137
+
138
+ const button = document.createElement('button');
139
+ button.type = 'button';
140
+ button.className = 'comment-filter-btn';
141
+ button.setAttribute('aria-expanded', 'false');
142
+ button.setAttribute('aria-controls', 'comment-filter-menu');
143
+ button.innerHTML = `${AIPanel.ICONS.funnel}<span class="comment-filter-dot" aria-hidden="true"></span>`;
144
+
145
+ const menu = document.createElement('div');
146
+ menu.className = 'comment-filter-menu';
147
+ menu.id = 'comment-filter-menu';
148
+ menu.setAttribute('role', 'group');
149
+ menu.setAttribute('aria-label', 'User comment filters');
150
+ menu.hidden = true;
151
+ const postedOption = this._isLocalMode() ? '' : `
152
+ <label class="comment-filter-option">
153
+ <input type="checkbox" data-filter="showPosted"> Show posted
154
+ </label>`;
155
+ menu.innerHTML = `
156
+ <div class="comment-filter-menu-title">User comments</div>
157
+ <label class="comment-filter-option">
158
+ <input type="checkbox" data-filter="showDismissed"> Show dismissed
159
+ </label>${postedOption}`;
160
+
161
+ wrapper.appendChild(button);
162
+ wrapper.appendChild(menu);
163
+ this.filterMenuWrapper = wrapper;
164
+ this.filterMenuBtn = button;
165
+ this.filterMenu = menu;
166
+
167
+ button.addEventListener('click', (e) => {
168
+ e.stopPropagation();
169
+ if (this.filterMenu.hidden) {
170
+ this.openFilterMenu();
171
+ } else {
172
+ this.closeFilterMenu();
173
+ }
174
+ });
175
+ menu.addEventListener('change', (e) => {
176
+ const input = e.target;
177
+ if (!input?.dataset?.filter) return;
178
+ this.setCommentFilter({ [input.dataset.filter]: input.checked });
179
+ });
180
+ wrapper.addEventListener('keydown', (e) => {
181
+ if (e.key === 'Escape' && !this.filterMenu.hidden) {
182
+ e.preventDefault();
183
+ e.stopPropagation();
184
+ this.closeFilterMenu({ focusButton: true });
185
+ }
186
+ });
187
+ // Tabbing out of the menu closes it
188
+ wrapper.addEventListener('focusout', (e) => {
189
+ if (e.relatedTarget && !wrapper.contains(e.relatedTarget)) {
190
+ this.closeFilterMenu();
191
+ }
192
+ });
193
+ this._onFilterMenuOutsidePointer = (e) => {
194
+ if (!wrapper.contains(e.target)) this.closeFilterMenu();
195
+ };
196
+
197
+ this.updateFilterMenuVisual();
198
+
199
+ // Insert as the LAST child of segment-control so it sits at the
200
+ // right edge of the row, after the segment buttons and the right
201
+ // overflow chevron. Append-to-end is correct for the nested
202
+ // scroll-wrapper structure and avoids a cross-parent insertBefore.
203
+ if (this.segmentControl) {
204
+ this.segmentControl.appendChild(wrapper);
124
205
  }
125
206
  }
126
207
 
208
+ openFilterMenu() {
209
+ if (!this.filterMenu || !this.filterMenu.hidden) return;
210
+ this.updateFilterMenuVisual();
211
+ this.filterMenu.hidden = false;
212
+ this.filterMenuBtn.setAttribute('aria-expanded', 'true');
213
+ // Lift the segment row above the panel sections below it (pr.css)
214
+ this.segmentControl?.classList.add('comment-filter-open');
215
+ document.addEventListener('pointerdown', this._onFilterMenuOutsidePointer, true);
216
+ this.filterMenu.querySelector('input')?.focus();
217
+ }
218
+
127
219
  /**
128
- * Create the filter toggle button for showing dismissed comments
220
+ * @param {Object} [options]
221
+ * @param {boolean} [options.focusButton] - Return focus to the funnel (keyboard close)
129
222
  */
130
- createFilterToggle() {
131
- // Create filter toggle button
132
- this.filterToggleBtn = document.createElement('button');
133
- this.filterToggleBtn.className = 'filter-toggle-btn';
223
+ closeFilterMenu({ focusButton = false } = {}) {
224
+ if (!this.filterMenu || this.filterMenu.hidden) return;
225
+ this.filterMenu.hidden = true;
226
+ this.filterMenuBtn.setAttribute('aria-expanded', 'false');
227
+ this.segmentControl?.classList.remove('comment-filter-open');
228
+ document.removeEventListener('pointerdown', this._onFilterMenuOutsidePointer, true);
229
+ if (focusButton) this.filterMenuBtn.focus();
230
+ }
231
+
232
+ _isLocalMode() {
233
+ return typeof window !== 'undefined' && !!window.PAIR_REVIEW_LOCAL_MODE;
234
+ }
235
+
236
+ _postedComment() {
237
+ return (typeof window !== 'undefined' && window.PostedComment) || null;
238
+ }
239
+
240
+ /** The browser-wide default for "Show posted": the opposite of "hide comments after posting". */
241
+ _defaultShowPosted() {
242
+ return !(this._postedComment()?.isHidePostedEnabled() || false);
243
+ }
244
+
245
+ /** Whether posted comments show in this review (its override, else the browser-wide setting). */
246
+ get showPostedComments() {
247
+ const posted = this._postedComment();
248
+ return posted ? !posted.isHidePostedInEffect() : true;
249
+ }
134
250
 
135
- // Apply restored state from constructor
136
- // Use eye icon when dismissed comments are visible, eye-closed when hidden
137
- if (this.showDismissedComments) {
138
- this.filterToggleBtn.classList.add('active');
139
- this.filterToggleBtn.title = 'Hide dismissed user comments';
140
- this.filterToggleBtn.innerHTML = AIPanel.ICONS.eye;
251
+ /**
252
+ * The user-comment filters, read by PRManager.loadUserComments and
253
+ * applyPostedCommentVisibility.
254
+ * @returns {{includeDismissed: boolean, showPosted: boolean}}
255
+ */
256
+ getCommentFilterState() {
257
+ return {
258
+ includeDismissed: !!this.showDismissedComments,
259
+ showPosted: this.showPostedComments
260
+ };
261
+ }
262
+
263
+ /** True when any filter option differs from its default (shows the dot on the funnel). */
264
+ isCommentFilterNonDefault() {
265
+ if (this.showDismissedComments) return true;
266
+ if (this._isLocalMode()) return false;
267
+ return this.showPostedComments !== this._defaultShowPosted();
268
+ }
269
+
270
+ /**
271
+ * Change filter options as the user asked: persist them, update the menu
272
+ * and dispatch one commentFilterChanged event so the comments reload.
273
+ * Restoring saved state goes through restoreFilterState instead, which
274
+ * does not dispatch.
275
+ * @param {{showDismissed?: boolean, showPosted?: boolean}} updates
276
+ * @returns {boolean} Whether anything changed
277
+ */
278
+ setCommentFilter(updates = {}) {
279
+ let changed = false;
280
+ if ('showDismissed' in updates && !!updates.showDismissed !== !!this.showDismissedComments) {
281
+ this.showDismissedComments = !!updates.showDismissed;
282
+ this.saveFilterState();
283
+ changed = true;
284
+ }
285
+ if ('showPosted' in updates && !this._isLocalMode()
286
+ && !!updates.showPosted !== this.showPostedComments) {
287
+ this._setShowPosted(!!updates.showPosted);
288
+ changed = true;
289
+ }
290
+ this.updateFilterMenuVisual();
291
+ if (!changed) return false;
292
+
293
+ document.dispatchEvent(new CustomEvent('commentFilterChanged', {
294
+ detail: this.getCommentFilterState()
295
+ }));
296
+ return true;
297
+ }
298
+
299
+ /**
300
+ * Set this review's "Show posted" override. A value equal to the
301
+ * browser-wide default drops the override, so the review follows that
302
+ * setting again. Never writes the browser-wide setting.
303
+ * @private
304
+ */
305
+ _setShowPosted(value) {
306
+ const override = value === this._defaultShowPosted() ? null : value;
307
+ this._postedComment()?.setShowPostedOverride(override);
308
+ const key = this.getShowPostedStorageKey();
309
+ if (!key) return;
310
+ if (override === null) {
311
+ localStorage.removeItem(key);
141
312
  } else {
142
- this.filterToggleBtn.title = 'Show dismissed user comments';
143
- this.filterToggleBtn.innerHTML = AIPanel.ICONS.eyeClosed;
313
+ localStorage.setItem(key, String(override));
144
314
  }
145
- this.filterToggleBtn.setAttribute('aria-label', this.filterToggleBtn.title);
315
+ }
146
316
 
147
- // Insert as the LAST child of segment-control so it sits at the
148
- // right edge of the row, after the segment buttons and the right
149
- // overflow chevron. Previous versions used insertBefore relative
150
- // to .segment-control-inner — that breaks now that the inner row
151
- // is nested inside a scroll wrapper. Append-to-end is correct for
152
- // both old and new structures and avoids the cross-parent
153
- // insertBefore footgun.
154
- if (this.segmentControl) {
155
- this.segmentControl.appendChild(this.filterToggleBtn);
317
+ /**
318
+ * Drop this review's "Show posted" override so it follows the browser-wide
319
+ * setting. Called when the reviewer changes that setting in the submit
320
+ * dialog. Updates the menu only; the caller refreshes the comments.
321
+ */
322
+ clearShowPostedOverride() {
323
+ this._postedComment()?.setShowPostedOverride(null);
324
+ const key = this.getShowPostedStorageKey();
325
+ if (key) localStorage.removeItem(key);
326
+ this.updateFilterMenuVisual();
327
+ }
328
+
329
+ /**
330
+ * Update the funnel (dot, label) and the menu's checkboxes to match the
331
+ * filter state.
332
+ */
333
+ updateFilterMenuVisual() {
334
+ if (!this.filterMenuBtn) return;
335
+ const nonDefault = this.isCommentFilterNonDefault();
336
+ this.filterMenuBtn.classList.toggle('has-active-filter', nonDefault);
337
+ const label = nonDefault ? 'Filter user comments (filters on)' : 'Filter user comments';
338
+ this.filterMenuBtn.title = label;
339
+ this.filterMenuBtn.setAttribute('aria-label', label);
340
+
341
+ const state = this.getCommentFilterState();
342
+ const dismissedInput = this.filterMenu?.querySelector('input[data-filter="showDismissed"]');
343
+ if (dismissedInput) dismissedInput.checked = state.includeDismissed;
344
+ const postedInput = this.filterMenu?.querySelector('input[data-filter="showPosted"]');
345
+ if (postedInput) postedInput.checked = state.showPosted;
346
+ }
347
+
348
+ /**
349
+ * Record how many user comments the filters hide, for the notice at the
350
+ * end of the list. PRManager counts them from its comment data.
351
+ * @param {{posted?: number, dismissed?: number}} counts
352
+ */
353
+ setHiddenCommentCounts(counts = {}) {
354
+ const next = { posted: counts.posted || 0, dismissed: counts.dismissed || 0 };
355
+ const prev = this.hiddenCommentCounts || { posted: 0, dismissed: 0 };
356
+ this.hiddenCommentCounts = next;
357
+ const changed = next.posted !== prev.posted || next.dismissed !== prev.dismissed;
358
+ // Only the User and All lists show the notice
359
+ if (changed && (this.selectedSegment === 'comments' || this.selectedSegment === 'all')) {
360
+ this.renderFindings();
156
361
  }
362
+ }
363
+
364
+ /** Turn on the filter options that show the comments the notice counts. */
365
+ showHiddenComments() {
366
+ const { posted, dismissed } = this.hiddenCommentCounts || {};
367
+ const updates = {};
368
+ if (dismissed > 0) updates.showDismissed = true;
369
+ if (posted > 0) updates.showPosted = true;
370
+ return this.setCommentFilter(updates);
371
+ }
157
372
 
158
- // Button is always visible - no conditional hiding to prevent layout shift
373
+ /**
374
+ * The muted "N posted · M dismissed hidden — Show" line at the end of the
375
+ * user comment list, or '' when nothing is hidden.
376
+ */
377
+ renderHiddenCommentsNotice() {
378
+ if (this.selectedSegment !== 'comments' && this.selectedSegment !== 'all') return '';
379
+ const { posted = 0, dismissed = 0 } = this.hiddenCommentCounts || {};
380
+ const parts = [];
381
+ if (posted > 0) parts.push(`${posted} posted`);
382
+ if (dismissed > 0) parts.push(`${dismissed} dismissed`);
383
+ if (parts.length === 0) return '';
384
+ return `
385
+ <div class="hidden-comments-notice">
386
+ <span>${parts.join(' · ')} hidden</span> —
387
+ <button type="button" class="hidden-comments-show" aria-label="Show hidden user comments">Show</button>
388
+ </div>`;
159
389
  }
160
390
 
161
391
  bindEvents() {
@@ -187,11 +417,6 @@ class AIPanel {
187
417
  });
188
418
  }
189
419
 
190
- // Filter toggle button
191
- if (this.filterToggleBtn) {
192
- this.filterToggleBtn.addEventListener('click', () => this.onFilterToggle());
193
- }
194
-
195
420
  // Segment overflow scroll chevrons
196
421
  if (this.segmentScrollLeft) {
197
422
  this.segmentScrollLeft.addEventListener('click', () => this.scrollSegmentRow(-1));
@@ -201,43 +426,6 @@ class AIPanel {
201
426
  }
202
427
  }
203
428
 
204
- /**
205
- * Handle filter toggle button click
206
- */
207
- onFilterToggle() {
208
- this.showDismissedComments = !this.showDismissedComments;
209
-
210
- // Update button visual state
211
- this.updateFilterToggleVisual();
212
-
213
- // Persist to localStorage (per-review)
214
- this.saveFilterState();
215
-
216
- // Dispatch event for prManager to reload comments with new filter
217
- const event = new CustomEvent('filterDismissedChanged', {
218
- detail: { showDismissed: this.showDismissedComments }
219
- });
220
- document.dispatchEvent(event);
221
- }
222
-
223
- /**
224
- * Update the filter toggle button visual state
225
- */
226
- updateFilterToggleVisual() {
227
- if (this.filterToggleBtn) {
228
- this.filterToggleBtn.classList.toggle('active', this.showDismissedComments);
229
- // Use eye icon when dismissed comments are visible, eye-closed when hidden
230
- if (this.showDismissedComments) {
231
- this.filterToggleBtn.title = 'Hide dismissed user comments';
232
- this.filterToggleBtn.innerHTML = AIPanel.ICONS.eye;
233
- } else {
234
- this.filterToggleBtn.title = 'Show dismissed user comments';
235
- this.filterToggleBtn.innerHTML = AIPanel.ICONS.eyeClosed;
236
- }
237
- this.filterToggleBtn.setAttribute('aria-label', this.filterToggleBtn.title);
238
- }
239
- }
240
-
241
429
  /**
242
430
  * Get the localStorage key for the collapsed state (per-review)
243
431
  * @returns {string|null} Storage key or null if no PR context
@@ -278,7 +466,7 @@ class AIPanel {
278
466
  }
279
467
 
280
468
  /**
281
- * Get the localStorage key for the filter state (per-review)
469
+ * Get the localStorage key for the "Show dismissed" filter (per-review)
282
470
  * @returns {string|null} Storage key or null if no PR context
283
471
  */
284
472
  getFilterStorageKey() {
@@ -287,7 +475,17 @@ class AIPanel {
287
475
  }
288
476
 
289
477
  /**
290
- * Save the filter state to localStorage (per-review)
478
+ * Get the localStorage key for this review's "Show posted" override. Absent
479
+ * means the review follows the browser-wide "hide comments after posting".
480
+ * @returns {string|null} Storage key or null if no PR context
481
+ */
482
+ getShowPostedStorageKey() {
483
+ if (!this.currentPRKey) return null;
484
+ return `pair-review-show-posted_${this.currentPRKey}`;
485
+ }
486
+
487
+ /**
488
+ * Save the "Show dismissed" filter to localStorage (per-review)
291
489
  */
292
490
  saveFilterState() {
293
491
  const key = this.getFilterStorageKey();
@@ -298,35 +496,33 @@ class AIPanel {
298
496
 
299
497
  /**
300
498
  * Restore the filter state from localStorage (per-review)
301
- * Note: This method only updates internal state and button visual.
302
- * It does NOT dispatch the filterDismissedChanged event because:
499
+ * Note: This method only updates internal state and the menu visual.
500
+ * It does NOT dispatch the commentFilterChanged event because:
303
501
  * 1. During initial setup (setPR), loadUserComments is called explicitly by the caller
304
- * (pr.js or local.js) with the appropriate filter state.
502
+ * (pr.js or local.js), and it reads this restored state.
305
503
  * 2. Dispatching here would cause a duplicate loadUserComments call that could
306
504
  * override the filter state with an incorrect value.
307
505
  *
308
- * The event is only dispatched from onFilterToggle() when the user clicks the button.
506
+ * The event is only dispatched from setCommentFilter() when the user changes an option.
309
507
  */
310
508
  restoreFilterState() {
311
509
  const key = this.getFilterStorageKey();
312
- if (key) {
313
- const stored = localStorage.getItem(key);
314
- if (stored !== null) {
315
- this.showDismissedComments = stored === 'true';
316
- } else {
317
- // Default to false (hidden) for new reviews
318
- this.showDismissedComments = false;
319
- }
320
- } else {
321
- this.showDismissedComments = false;
322
- }
510
+ // Default to false (hidden) for new reviews
511
+ this.showDismissedComments = key ? localStorage.getItem(key) === 'true' : false;
512
+
513
+ // "Show posted": this review's override, if any. Local mode has no
514
+ // posted comments and so no override.
515
+ const postedKey = this._isLocalMode() ? null : this.getShowPostedStorageKey();
516
+ const storedPosted = postedKey ? localStorage.getItem(postedKey) : null;
517
+ const override = storedPosted === 'true' ? true : storedPosted === 'false' ? false : null;
518
+ this._postedComment()?.setShowPostedOverride(override);
323
519
 
324
- // Update button visual to match restored state
325
- this.updateFilterToggleVisual();
520
+ // Update the menu to match restored state
521
+ this.updateFilterMenuVisual();
326
522
 
327
- // NOTE: We intentionally do NOT dispatch filterDismissedChanged here.
523
+ // NOTE: We intentionally do NOT dispatch commentFilterChanged here.
328
524
  // The caller (pr.js or local.js) is responsible for calling loadUserComments
329
- // with the restored filter state after setPR() completes.
525
+ // after setPR() completes.
330
526
  }
331
527
 
332
528
  toggle() {
@@ -779,11 +975,19 @@ class AIPanel {
779
975
  if (!this.findingsList) return;
780
976
 
781
977
  const items = this.getFilteredItems();
978
+ // "N posted · M dismissed hidden — Show", or '' when nothing is hidden
979
+ const hiddenNotice = this.renderHiddenCommentsNotice();
782
980
 
783
981
  // Show empty state based on segment and analysis state
784
982
  if (items.length === 0) {
785
983
  let emptyContent;
786
- if (this.selectedSegment === 'comments') {
984
+ if (this.selectedSegment === 'comments' && hiddenNotice) {
985
+ emptyContent = `
986
+ <div class="empty-state-icon">${this.getEmptyStateIcon('comment')}</div>
987
+ <div class="empty-state-title">No comments shown</div>
988
+ <div class="empty-state-description">The comment filters hide every user comment.</div>
989
+ `;
990
+ } else if (this.selectedSegment === 'comments') {
787
991
  emptyContent = `
788
992
  <div class="empty-state-icon">${this.getEmptyStateIcon('comment')}</div>
789
993
  <div class="empty-state-title">No comments yet</div>
@@ -845,7 +1049,9 @@ class AIPanel {
845
1049
  <div class="findings-empty empty-state">
846
1050
  ${emptyContent}
847
1051
  </div>
1052
+ ${hiddenNotice}
848
1053
  `;
1054
+ this._bindHiddenCommentsNotice();
849
1055
  this.updateFindingsHeader(0);
850
1056
  return;
851
1057
  }
@@ -861,7 +1067,8 @@ class AIPanel {
861
1067
  } else {
862
1068
  return this.renderFindingItem(item, index);
863
1069
  }
864
- }).join('');
1070
+ }).join('') + hiddenNotice;
1071
+ this._bindHiddenCommentsNotice();
865
1072
 
866
1073
  // Bind click events
867
1074
  this.findingsList.querySelectorAll('.finding-item').forEach(item => {
@@ -924,6 +1131,17 @@ class AIPanel {
924
1131
  this.highlightCurrentItem();
925
1132
  }
926
1133
 
1134
+ /** Wire the hidden-comments notice's Show button, if the list has one. @private */
1135
+ _bindHiddenCommentsNotice() {
1136
+ const showBtn = this.findingsList?.querySelector('.hidden-comments-show');
1137
+ if (showBtn) {
1138
+ showBtn.addEventListener('click', (e) => {
1139
+ e.stopPropagation();
1140
+ this.showHiddenComments();
1141
+ });
1142
+ }
1143
+ }
1144
+
927
1145
  /**
928
1146
  * Handle delete comment button click
929
1147
  * @param {number} commentId - The comment ID to delete