@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.
- package/README.md +8 -0
- package/package.json +3 -3
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin-code-critic/.claude-plugin/plugin.json +1 -1
- package/plugin-pair-loop/.claude-plugin/plugin.json +1 -1
- package/public/css/pr.css +389 -13
- package/public/index.html +1 -0
- package/public/js/components/AIPanel.js +317 -99
- package/public/js/components/AdvancedConfigTab.js +18 -108
- package/public/js/components/ReviewHistoryModal.js +294 -0
- package/public/js/components/ReviewModal.js +96 -7
- package/public/js/components/SplitButton.js +14 -0
- package/public/js/components/VoiceCentricConfigTab.js +18 -108
- package/public/js/index.js +18 -5
- package/public/js/local.js +4 -8
- package/public/js/modules/comment-manager.js +2 -1
- package/public/js/modules/diff-renderer.js +7 -6
- package/public/js/modules/file-comment-manager.js +6 -2
- package/public/js/modules/pierre-bridge.js +35 -1
- package/public/js/modules/suggestion-manager.js +4 -1
- package/public/js/pr.js +174 -66
- package/public/js/utils/council-timeout.js +203 -0
- package/public/js/utils/posted-comment.js +259 -14
- package/public/js/vendor/pierre-diffs-worker.js +41 -13485
- package/public/js/vendor/pierre-diffs.js +131 -1364
- package/public/local.html +4 -0
- package/public/pr.html +5 -0
- package/src/ai/copilot-provider.js +21 -2
- package/src/ai/cursor-agent-provider.js +21 -2
- package/src/ai/opencode-provider.js +21 -2
- package/src/chat/api-reference.js +22 -2
- package/src/config.js +28 -4
- package/src/database.js +416 -114
- package/src/git/worktree-pool-lifecycle.js +152 -33
- package/src/git/worktree-pool-usage.js +20 -0
- package/src/git/worktree.js +14 -5
- package/src/github/client.js +70 -15
- package/src/github/impl/graphql/pending-review-comments.js +50 -11
- package/src/github/impl/graphql/pending-review.js +8 -2
- package/src/github/impl/graphql/review-comment-edit.js +89 -0
- package/src/github/impl/host/pending-review-comments.js +41 -10
- package/src/github/impl/host/review-comment-edit.js +36 -0
- package/src/github/impl/rest/pending-review.js +6 -2
- package/src/github/impl/rest/review-comment-edit.js +44 -0
- package/src/github/impl/review-comment-edit-utils.js +45 -0
- package/src/github/operations/pending-review.js +4 -3
- package/src/github/operations/review-comment-edit.js +35 -0
- package/src/github/record-submission.js +78 -0
- package/src/github/update-posted-comment.js +115 -0
- package/src/main.js +42 -50
- package/src/routes/mcp.js +1 -0
- package/src/routes/pr.js +158 -120
- package/src/routes/reviews.js +8 -30
- package/src/routes/setup.js +22 -9
- package/src/setup/pr-setup.js +12 -3
- package/src/utils/diff-file-content.js +62 -25
- package/src/utils/json-extractor.js +267 -13
- package/src/utils/pr-file-blob-cache.js +134 -0
- package/src/utils/process-liveness.js +64 -0
|
@@ -41,6 +41,17 @@ class VoiceCentricConfigTab {
|
|
|
41
41
|
/** Default timeout in milliseconds (10 minutes) */
|
|
42
42
|
static DEFAULT_TIMEOUT = 600000;
|
|
43
43
|
|
|
44
|
+
/** DOM shape for the shared timeout mixin (see utils/council-timeout.js) */
|
|
45
|
+
static TIMEOUT_DOM = {
|
|
46
|
+
panelId: 'tab-panel-council',
|
|
47
|
+
voiceWrapperClass: 'vc-reviewer',
|
|
48
|
+
voiceKeys: ['index'],
|
|
49
|
+
timeoutClass: 'vc-timeout',
|
|
50
|
+
orchestrationTimeoutId: 'vc-orchestration-timeout',
|
|
51
|
+
orchestrationToggleId: 'vc-orchestration-timeout-toggle',
|
|
52
|
+
orchestrationRowId: 'vc-orchestration-voice',
|
|
53
|
+
};
|
|
54
|
+
|
|
44
55
|
|
|
45
56
|
constructor(modal) {
|
|
46
57
|
this.modal = modal;
|
|
@@ -574,7 +585,7 @@ class VoiceCentricConfigTab {
|
|
|
574
585
|
this._updateOrchestrationTimeoutIcon(panel, e.target.value);
|
|
575
586
|
} else {
|
|
576
587
|
const idx = e.target.dataset.index;
|
|
577
|
-
this._updateTimeoutIcon(panel, idx, e.target.value);
|
|
588
|
+
this._updateTimeoutIcon(panel, { index: idx }, e.target.value);
|
|
578
589
|
}
|
|
579
590
|
}
|
|
580
591
|
});
|
|
@@ -707,87 +718,6 @@ class VoiceCentricConfigTab {
|
|
|
707
718
|
iconBtn.classList.toggle('has-instructions', hasContent);
|
|
708
719
|
}
|
|
709
720
|
|
|
710
|
-
/**
|
|
711
|
-
* Get the default timeout for a provider, falling back to the static DEFAULT_TIMEOUT.
|
|
712
|
-
* @param {string} providerId - Provider ID (e.g., 'pi', 'claude')
|
|
713
|
-
* @returns {number} Default timeout in ms
|
|
714
|
-
*/
|
|
715
|
-
_getProviderDefaultTimeout(providerId) {
|
|
716
|
-
const provider = this.providers[providerId];
|
|
717
|
-
return provider?.defaultTimeout ?? VoiceCentricConfigTab.DEFAULT_TIMEOUT;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
/**
|
|
721
|
-
* Update the clock/timeout icon styling to indicate non-default timeout.
|
|
722
|
-
* @param {Element} panel - The council panel element
|
|
723
|
-
* @param {string} index - Reviewer index
|
|
724
|
-
* @param {string} value - Current timeout value (as string of ms)
|
|
725
|
-
*/
|
|
726
|
-
_updateTimeoutIcon(panel, index, value) {
|
|
727
|
-
const wrapper = panel.querySelector(`.vc-reviewer[data-index="${index}"]`);
|
|
728
|
-
const iconBtn = wrapper?.querySelector(`.toggle-timeout-icon[data-index="${index}"]`);
|
|
729
|
-
if (!iconBtn) return;
|
|
730
|
-
|
|
731
|
-
const providerId = wrapper?.querySelector('.voice-provider')?.value;
|
|
732
|
-
const defaultTimeout = this._getProviderDefaultTimeout(providerId);
|
|
733
|
-
const isNonDefault = parseInt(value, 10) !== defaultTimeout;
|
|
734
|
-
iconBtn.classList.toggle('has-custom-timeout', isNonDefault);
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
_updateOrchestrationTimeoutIcon(panel, value) {
|
|
738
|
-
const iconBtn = panel.querySelector('#vc-orchestration-timeout-toggle');
|
|
739
|
-
if (!iconBtn) return;
|
|
740
|
-
|
|
741
|
-
const orchRow = panel.querySelector('#vc-orchestration-voice');
|
|
742
|
-
const providerId = orchRow?.querySelector('.voice-provider')?.value;
|
|
743
|
-
const defaultTimeout = this._getProviderDefaultTimeout(providerId);
|
|
744
|
-
const isNonDefault = parseInt(value, 10) !== defaultTimeout;
|
|
745
|
-
iconBtn.classList.toggle('has-custom-timeout', isNonDefault);
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
/**
|
|
749
|
-
* When a voice's provider changes, update its timeout to the new provider's default,
|
|
750
|
-
* preserving explicit user overrides via Math.max when the user had customized the value.
|
|
751
|
-
* @param {HTMLSelectElement} providerSelect - The provider dropdown that changed
|
|
752
|
-
*/
|
|
753
|
-
_applyProviderDefaultTimeout(providerSelect) {
|
|
754
|
-
const panel = this.modal.querySelector('#tab-panel-council');
|
|
755
|
-
if (!panel) return;
|
|
756
|
-
|
|
757
|
-
const providerId = providerSelect.value;
|
|
758
|
-
const newDefault = this._getProviderDefaultTimeout(providerId);
|
|
759
|
-
const oldProviderId = providerSelect.dataset.previousProvider;
|
|
760
|
-
const oldDefault = oldProviderId ? this._getProviderDefaultTimeout(oldProviderId) : null;
|
|
761
|
-
|
|
762
|
-
// Determine which timeout element to update
|
|
763
|
-
const isOrchestration = providerSelect.dataset.target === 'orchestration';
|
|
764
|
-
if (isOrchestration) {
|
|
765
|
-
const timeoutEl = panel.querySelector('#vc-orchestration-timeout');
|
|
766
|
-
if (timeoutEl) {
|
|
767
|
-
const currentValue = parseInt(timeoutEl.value, 10);
|
|
768
|
-
const resolvedTimeout = (oldDefault !== null && currentValue !== oldDefault)
|
|
769
|
-
? Math.max(currentValue, newDefault)
|
|
770
|
-
: newDefault;
|
|
771
|
-
timeoutEl.value = String(resolvedTimeout);
|
|
772
|
-
this._updateOrchestrationTimeoutIcon(panel, String(resolvedTimeout));
|
|
773
|
-
}
|
|
774
|
-
} else {
|
|
775
|
-
const idx = providerSelect.dataset.index;
|
|
776
|
-
const wrapper = providerSelect.closest('.vc-reviewer');
|
|
777
|
-
const timeoutEl = wrapper?.querySelector('.vc-timeout');
|
|
778
|
-
if (timeoutEl) {
|
|
779
|
-
const currentValue = parseInt(timeoutEl.value, 10);
|
|
780
|
-
const resolvedTimeout = (oldDefault !== null && currentValue !== oldDefault)
|
|
781
|
-
? Math.max(currentValue, newDefault)
|
|
782
|
-
: newDefault;
|
|
783
|
-
timeoutEl.value = String(resolvedTimeout);
|
|
784
|
-
this._updateTimeoutIcon(panel, idx, String(resolvedTimeout));
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
providerSelect.dataset.previousProvider = providerId;
|
|
789
|
-
}
|
|
790
|
-
|
|
791
721
|
// --- Dropdown / model management ---
|
|
792
722
|
|
|
793
723
|
_updateAllVoiceDropdowns() {
|
|
@@ -1150,18 +1080,7 @@ class VoiceCentricConfigTab {
|
|
|
1150
1080
|
TimeoutSelect.mount(mount, { className: 'vc-timeout', title: 'Per-reviewer timeout' });
|
|
1151
1081
|
}
|
|
1152
1082
|
const timeoutEl = row.querySelector('.vc-timeout');
|
|
1153
|
-
|
|
1154
|
-
if (timeoutEl && voice.timeout) {
|
|
1155
|
-
timeoutEl.value = String(voice.timeout);
|
|
1156
|
-
// Show the dropdown if non-default for this provider
|
|
1157
|
-
if (voice.timeout !== providerDefaultTimeout) {
|
|
1158
|
-
timeoutEl.style.display = '';
|
|
1159
|
-
}
|
|
1160
|
-
this._updateTimeoutIcon(panel, String(i), String(voice.timeout));
|
|
1161
|
-
} else if (timeoutEl) {
|
|
1162
|
-
// No saved timeout — apply the provider's default
|
|
1163
|
-
timeoutEl.value = String(providerDefaultTimeout);
|
|
1164
|
-
}
|
|
1083
|
+
this._restoreVoiceTimeout(panel, { index: String(i) }, timeoutEl, voice);
|
|
1165
1084
|
}
|
|
1166
1085
|
|
|
1167
1086
|
if (voice.customInstructions) {
|
|
@@ -1202,20 +1121,7 @@ class VoiceCentricConfigTab {
|
|
|
1202
1121
|
}
|
|
1203
1122
|
|
|
1204
1123
|
// Restore orchestration timeout
|
|
1205
|
-
|
|
1206
|
-
const orchProviderDefaultTimeout = this._getProviderDefaultTimeout(vcConfig.orchestration.provider);
|
|
1207
|
-
if (orchTimeoutSelect && vcConfig.orchestration.timeout) {
|
|
1208
|
-
orchTimeoutSelect.value = String(vcConfig.orchestration.timeout);
|
|
1209
|
-
// Show the dropdown if non-default for this provider
|
|
1210
|
-
if (vcConfig.orchestration.timeout !== orchProviderDefaultTimeout) {
|
|
1211
|
-
orchTimeoutSelect.style.display = '';
|
|
1212
|
-
}
|
|
1213
|
-
this._updateOrchestrationTimeoutIcon(panel, String(vcConfig.orchestration.timeout));
|
|
1214
|
-
} else if (orchTimeoutSelect) {
|
|
1215
|
-
// No saved timeout — apply the provider's default
|
|
1216
|
-
orchTimeoutSelect.value = String(orchProviderDefaultTimeout);
|
|
1217
|
-
this._updateOrchestrationTimeoutIcon(panel, String(orchProviderDefaultTimeout));
|
|
1218
|
-
}
|
|
1124
|
+
this._restoreOrchestrationTimeout(panel, vcConfig.orchestration);
|
|
1219
1125
|
|
|
1220
1126
|
// Restore orchestration custom instructions
|
|
1221
1127
|
const orchInstrInput = panel.querySelector('#vc-orchestration-instructions');
|
|
@@ -1521,6 +1427,10 @@ class VoiceCentricConfigTab {
|
|
|
1521
1427
|
}
|
|
1522
1428
|
}
|
|
1523
1429
|
|
|
1430
|
+
// Shared timeout methods (public/js/utils/council-timeout.js). In the browser the
|
|
1431
|
+
// util's <script> tag loads first; unit tests load it via require().
|
|
1432
|
+
((typeof window !== 'undefined' && window.CouncilTimeout) || require('../utils/council-timeout.js')).mixInto(VoiceCentricConfigTab);
|
|
1433
|
+
|
|
1524
1434
|
// Export for use in other modules
|
|
1525
1435
|
if (typeof window !== 'undefined') {
|
|
1526
1436
|
window.VoiceCentricConfigTab = VoiceCentricConfigTab;
|
package/public/js/index.js
CHANGED
|
@@ -1268,8 +1268,19 @@
|
|
|
1268
1268
|
/**
|
|
1269
1269
|
* Fetch and display recent reviews (initial load).
|
|
1270
1270
|
* Resets pagination state and renders the full table from scratch.
|
|
1271
|
+
*
|
|
1272
|
+
* The help modal is opt-in: only the initial page load passes
|
|
1273
|
+
* `showHelpIfEmpty`, so a first-time user with no reviews is greeted with
|
|
1274
|
+
* it, while every refresh (single delete, bulk delete) that happens to
|
|
1275
|
+
* empty the list just shows the empty-state message.
|
|
1276
|
+
*
|
|
1277
|
+
* @param {Object} [options]
|
|
1278
|
+
* @param {boolean} [options.showHelpIfEmpty=false] - Open the help modal
|
|
1279
|
+
* when the list comes back empty.
|
|
1271
1280
|
*/
|
|
1272
|
-
async function loadRecentReviews() {
|
|
1281
|
+
async function loadRecentReviews(options) {
|
|
1282
|
+
const showHelpIfEmpty = Boolean(options && options.showHelpIfEmpty);
|
|
1283
|
+
|
|
1273
1284
|
prSelection.exit();
|
|
1274
1285
|
|
|
1275
1286
|
const container = document.getElementById('recent-reviews-container');
|
|
@@ -1294,8 +1305,9 @@
|
|
|
1294
1305
|
'<p>No PR reviews yet. Paste a PR URL above to get started.</p>' +
|
|
1295
1306
|
'</div>';
|
|
1296
1307
|
container.classList.remove('recent-reviews-loading');
|
|
1297
|
-
//
|
|
1298
|
-
|
|
1308
|
+
// Greet first-time users with the help modal, but only on initial
|
|
1309
|
+
// page load, never after the user emptied the list themselves.
|
|
1310
|
+
if (showHelpIfEmpty) openHelpModal();
|
|
1299
1311
|
return;
|
|
1300
1312
|
}
|
|
1301
1313
|
|
|
@@ -2476,8 +2488,9 @@
|
|
|
2476
2488
|
}
|
|
2477
2489
|
}
|
|
2478
2490
|
|
|
2479
|
-
// Always load PR reviews (they show on initial load)
|
|
2480
|
-
|
|
2491
|
+
// Always load PR reviews (they show on initial load). This is the only
|
|
2492
|
+
// caller that opens the help modal for an empty list.
|
|
2493
|
+
loadRecentReviews({ showHelpIfEmpty: true });
|
|
2481
2494
|
|
|
2482
2495
|
// If local tab is active, load local reviews immediately
|
|
2483
2496
|
if (savedTab === 'local-tab') {
|
package/public/js/local.js
CHANGED
|
@@ -539,8 +539,7 @@ class LocalManager {
|
|
|
539
539
|
await self.loadLocalDiff();
|
|
540
540
|
|
|
541
541
|
// Re-anchor comments and suggestions on the fresh DOM
|
|
542
|
-
|
|
543
|
-
await manager.loadUserComments(includeDismissed);
|
|
542
|
+
await manager.loadUserComments();
|
|
544
543
|
await manager.loadAISuggestions(null, manager.selectedRunId);
|
|
545
544
|
|
|
546
545
|
// Restore scroll position after the DOM settles
|
|
@@ -941,8 +940,7 @@ class LocalManager {
|
|
|
941
940
|
|
|
942
941
|
// Re-render comments and AI suggestions on the fresh DOM
|
|
943
942
|
// (renderDiff clears the diff container, so we must re-populate)
|
|
944
|
-
|
|
945
|
-
await manager.loadUserComments(includeDismissed);
|
|
943
|
+
await manager.loadUserComments();
|
|
946
944
|
// Note: Unlike loadLocalReview() which skips this when analysisHistoryManager exists
|
|
947
945
|
// (because the manager triggers loadAISuggestions via onSelectionChange on init),
|
|
948
946
|
// refresh must call unconditionally since the manager won't re-fire its callback.
|
|
@@ -1157,8 +1155,7 @@ class LocalManager {
|
|
|
1157
1155
|
window.panelGroup?.setPR(`local/${reviewData.repository}#${this.reviewId}`);
|
|
1158
1156
|
|
|
1159
1157
|
// Load saved comments using the restored filter state from AI Panel
|
|
1160
|
-
|
|
1161
|
-
await manager.loadUserComments(includeDismissed);
|
|
1158
|
+
await manager.loadUserComments();
|
|
1162
1159
|
|
|
1163
1160
|
// Initialize analysis history manager for local mode
|
|
1164
1161
|
if (window.AnalysisHistoryManager) {
|
|
@@ -1691,8 +1688,7 @@ class LocalManager {
|
|
|
1691
1688
|
await this.loadLocalDiff();
|
|
1692
1689
|
|
|
1693
1690
|
// Re-anchor comments and suggestions
|
|
1694
|
-
|
|
1695
|
-
await manager.loadUserComments(includeDismissed);
|
|
1691
|
+
await manager.loadUserComments();
|
|
1696
1692
|
await manager.loadAISuggestions(null, manager.selectedRunId);
|
|
1697
1693
|
|
|
1698
1694
|
// Only update dropdown if user hasn't clicked again since this request started
|
|
@@ -606,7 +606,7 @@ class CommentManager {
|
|
|
606
606
|
${commentIcon}
|
|
607
607
|
</span>
|
|
608
608
|
<span class="user-comment-line-info">${lineInfo}</span>
|
|
609
|
-
${window.getPostedCommentIcon?.(comment) || ''}
|
|
609
|
+
${window.getPostedCommentIcon?.(comment, { link: true }) || ''}
|
|
610
610
|
${expandedContextIndicator}
|
|
611
611
|
${metadataHTML}
|
|
612
612
|
</div>
|
|
@@ -627,6 +627,7 @@ class CommentManager {
|
|
|
627
627
|
</div>
|
|
628
628
|
</div>
|
|
629
629
|
<div class="user-comment-body" data-original-markdown="${window.escapeHtmlAttribute(comment.body)}">${window.renderMarkdown ? window.renderMarkdown(comment.body) : escapeHtml(comment.body)}</div>
|
|
630
|
+
${window.PostedComment?.getEditedSincePostedHtml(comment) || ''}
|
|
630
631
|
</div>
|
|
631
632
|
`;
|
|
632
633
|
|
|
@@ -41,7 +41,10 @@ class DiffRenderer {
|
|
|
41
41
|
</svg>
|
|
42
42
|
`;
|
|
43
43
|
|
|
44
|
-
// Map of file extensions to highlight.js language names
|
|
44
|
+
// Map of file extensions to highlight.js language names. Every value must be
|
|
45
|
+
// registered by the bundles pr.html and local.html load (the cdnjs common set
|
|
46
|
+
// plus their languages/*.min.js tags); tests/unit/hljs-language-map.test.js
|
|
47
|
+
// enforces this.
|
|
45
48
|
static LANGUAGE_MAP = {
|
|
46
49
|
// JavaScript/TypeScript
|
|
47
50
|
'js': 'javascript',
|
|
@@ -56,7 +59,6 @@ class DiffRenderer {
|
|
|
56
59
|
'xml': 'xml',
|
|
57
60
|
'css': 'css',
|
|
58
61
|
'scss': 'scss',
|
|
59
|
-
'sass': 'sass',
|
|
60
62
|
'less': 'less',
|
|
61
63
|
// Python
|
|
62
64
|
'py': 'python',
|
|
@@ -113,8 +115,7 @@ class DiffRenderer {
|
|
|
113
115
|
'r': 'r',
|
|
114
116
|
'lua': 'lua',
|
|
115
117
|
'perl': 'perl',
|
|
116
|
-
'pl': 'perl'
|
|
117
|
-
'vim': 'vim'
|
|
118
|
+
'pl': 'perl'
|
|
118
119
|
};
|
|
119
120
|
|
|
120
121
|
/**
|
|
@@ -447,9 +448,9 @@ class DiffRenderer {
|
|
|
447
448
|
}
|
|
448
449
|
|
|
449
450
|
// Apply syntax highlighting if highlight.js is available
|
|
450
|
-
|
|
451
|
+
const language = fileName ? DiffRenderer.detectLanguage(fileName) : null;
|
|
452
|
+
if (language && window.hljs?.getLanguage(language)) {
|
|
451
453
|
try {
|
|
452
|
-
const language = DiffRenderer.detectLanguage(fileName);
|
|
453
454
|
const highlighted = window.hljs.highlight(content, { language, ignoreIllegals: true });
|
|
454
455
|
let html = highlighted.value;
|
|
455
456
|
|
|
@@ -378,7 +378,7 @@ class FileCommentManager {
|
|
|
378
378
|
${commentIcon}
|
|
379
379
|
</span>
|
|
380
380
|
<span class="file-comment-badge" title="Comment applies to the entire file">File comment</span>
|
|
381
|
-
${window.getPostedCommentIcon?.(comment) || ''}
|
|
381
|
+
${window.getPostedCommentIcon?.(comment, { link: true }) || ''}
|
|
382
382
|
${praiseBadge}
|
|
383
383
|
${titleHtml}
|
|
384
384
|
</div>
|
|
@@ -399,6 +399,7 @@ class FileCommentManager {
|
|
|
399
399
|
</div>
|
|
400
400
|
</div>
|
|
401
401
|
<div class="user-comment-body" data-original-markdown="${window.escapeHtmlAttribute(comment.body)}">${renderedBody}</div>
|
|
402
|
+
${window.PostedComment?.getEditedSincePostedHtml(comment) || ''}
|
|
402
403
|
`;
|
|
403
404
|
|
|
404
405
|
// Wire up edit/delete buttons
|
|
@@ -448,7 +449,10 @@ class FileCommentManager {
|
|
|
448
449
|
const userComments = this.prManager?.userComments || [];
|
|
449
450
|
const suggestionIdNum = parseInt(suggestion.id);
|
|
450
451
|
const wasAdopted = userComments.some(comment =>
|
|
451
|
-
|
|
452
|
+
// A dismissed comment no longer adopts its suggestion (dismissing it
|
|
453
|
+
// dismisses the suggestion); the cache keeps dismissed comments.
|
|
454
|
+
comment.status !== 'inactive' && comment.parent_id &&
|
|
455
|
+
(comment.parent_id === suggestion.id || comment.parent_id === suggestionIdNum)
|
|
452
456
|
);
|
|
453
457
|
|
|
454
458
|
// Determine if suggestion should be collapsed based on status or adoption
|
|
@@ -45,6 +45,10 @@ class PierreBridge {
|
|
|
45
45
|
// Monotonic counter for unique annotation IDs
|
|
46
46
|
this._annotationCounter = 0;
|
|
47
47
|
|
|
48
|
+
// Rendered annotation elements, keyed by the annotation's metadata object.
|
|
49
|
+
// See _renderAnnotation for why these are reused across renders.
|
|
50
|
+
this._renderedAnnotations = new WeakMap();
|
|
51
|
+
|
|
48
52
|
// Cache for gutter button containers — keyed by fileName.
|
|
49
53
|
// Stored here instead of on fileState because renderGutterUtility fires
|
|
50
54
|
// during instance.render(), before fileState is set on this.files.
|
|
@@ -1853,6 +1857,35 @@ class PierreBridge {
|
|
|
1853
1857
|
* @private
|
|
1854
1858
|
*/
|
|
1855
1859
|
_renderAnnotation(annotation, fileName, formElements) {
|
|
1860
|
+
const { metadata, lineNumber, side } = annotation;
|
|
1861
|
+
// Forms already reuse their DOM through formElements.
|
|
1862
|
+
if (metadata.type === 'comment-form') {
|
|
1863
|
+
return this._renderAnnotationContent(annotation, fileName, formElements);
|
|
1864
|
+
}
|
|
1865
|
+
// @pierre/diffs 1.6 calls renderAnnotation again for EVERY annotation
|
|
1866
|
+
// whenever the fileDiff object changes (context ranges, gap expansion,
|
|
1867
|
+
// rebuilds from base metadata), not only when the annotation changed, as
|
|
1868
|
+
// 1.2 did. Rebuilt cards would disconnect elements that callers still hold
|
|
1869
|
+
// (e.g. a scroll-to-finding in flight) and drop in-place DOM state. An
|
|
1870
|
+
// annotation's metadata object is replaced whenever its content changes
|
|
1871
|
+
// (_pushAnnotation), so the same metadata at the same line and side means
|
|
1872
|
+
// the same card: hand back the element already built for it.
|
|
1873
|
+
const cached = this._renderedAnnotations.get(metadata);
|
|
1874
|
+
if (cached && cached.lineNumber === lineNumber && cached.side === side) {
|
|
1875
|
+
return cached.element;
|
|
1876
|
+
}
|
|
1877
|
+
const element = this._renderAnnotationContent(annotation, fileName, formElements);
|
|
1878
|
+
if (element) {
|
|
1879
|
+
this._renderedAnnotations.set(metadata, { element, lineNumber, side });
|
|
1880
|
+
}
|
|
1881
|
+
return element;
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1884
|
+
/**
|
|
1885
|
+
* Build the element for an annotation, by type.
|
|
1886
|
+
* @private
|
|
1887
|
+
*/
|
|
1888
|
+
_renderAnnotationContent(annotation, fileName, formElements) {
|
|
1856
1889
|
const { type, data, id } = annotation.metadata;
|
|
1857
1890
|
|
|
1858
1891
|
switch (type) {
|
|
@@ -1957,7 +1990,7 @@ class PierreBridge {
|
|
|
1957
1990
|
<div class="user-comment-header-left">
|
|
1958
1991
|
<span class="comment-origin-icon">${commentIcon}</span>
|
|
1959
1992
|
<span class="user-comment-line-info">${lineInfo}</span>
|
|
1960
|
-
${window.getPostedCommentIcon?.(comment) || ''}
|
|
1993
|
+
${window.getPostedCommentIcon?.(comment, { link: true }) || ''}
|
|
1961
1994
|
${metadataHTML}
|
|
1962
1995
|
</div>
|
|
1963
1996
|
<div class="user-comment-actions">
|
|
@@ -1982,6 +2015,7 @@ class PierreBridge {
|
|
|
1982
2015
|
</div>
|
|
1983
2016
|
</div>
|
|
1984
2017
|
<div class="user-comment-body" data-original-markdown="${window.escapeHtmlAttribute ? window.escapeHtmlAttribute(comment.body) : ''}">${window.renderMarkdown ? window.renderMarkdown(comment.body || '') : escapeHtml(comment.body || '')}</div>
|
|
2018
|
+
${window.PostedComment?.getEditedSincePostedHtml(comment) || ''}
|
|
1985
2019
|
</div>
|
|
1986
2020
|
`;
|
|
1987
2021
|
|
|
@@ -619,7 +619,10 @@ class SuggestionManager {
|
|
|
619
619
|
|
|
620
620
|
// Check if this suggestion was adopted by looking for user comments with matching parent_id
|
|
621
621
|
const wasAdopted = userComments.some(comment =>
|
|
622
|
-
|
|
622
|
+
// A dismissed comment no longer adopts its suggestion (dismissing it
|
|
623
|
+
// dismisses the suggestion); the cache keeps dismissed comments.
|
|
624
|
+
comment.status !== 'inactive' && comment.parent_id &&
|
|
625
|
+
(comment.parent_id === suggestion.id || comment.parent_id === suggestionIdNum)
|
|
623
626
|
);
|
|
624
627
|
|
|
625
628
|
// Log when a suggestion is detected as adopted
|