@in-the-loop-labs/pair-review 5.3.4 → 5.3.5
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 +7 -1
- package/bin/git-diff-lines +2 -1
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin-code-critic/.claude-plugin/plugin.json +1 -1
- package/plugin-code-critic/skills/analyze/scripts/git-diff-lines +104 -25
- package/plugin-pair-loop/.claude-plugin/plugin.json +1 -1
- package/public/css/pr.css +162 -46
- package/public/css/styles.css +0 -12
- package/public/js/components/AIPanel.js +3 -2
- package/public/js/components/AnalysisConfigModal.js +4 -1
- package/public/js/components/ChatPanel.js +15 -8
- package/public/js/components/PanelGroup.js +115 -21
- package/public/js/components/SuggestionNavigator.js +16 -3
- package/public/js/local.js +7 -12
- package/public/js/modules/diff-renderer.js +13 -0
- package/public/js/modules/file-comment-manager.js +19 -10
- package/public/js/modules/hunk-parser.js +39 -2
- package/public/js/modules/panel-resizer.js +41 -3
- package/public/js/modules/pierre-bridge.js +11 -2
- package/public/js/modules/suggestion-manager.js +128 -33
- package/public/js/pr.js +132 -29
- package/public/js/repo-settings.js +35 -19
- package/public/js/utils/git-paths.js +140 -0
- package/public/js/utils/smart-truncate.js +88 -0
- package/public/local.html +6 -0
- package/public/pr.html +6 -0
- package/src/ai/analyzer.js +15 -13
- package/src/ai/antigravity-provider.js +44 -24
- package/src/ai/cursor-agent-provider.js +4 -4
- package/src/ai/muse-provider.js +68 -3
- package/src/ai/summary-generator.js +8 -5
- package/src/git/diff-flags.js +26 -12
- package/src/git/worktree.js +21 -43
- package/src/github/client.js +0 -88
- package/src/github/impl/graphql/pending-review-comments.js +5 -1
- package/src/github/submit-pr-context.js +56 -0
- package/src/local-review.js +34 -17
- package/src/main.js +80 -106
- package/src/routes/executable-analysis.js +14 -15
- package/src/routes/local.js +3 -5
- package/src/routes/pr.js +18 -105
- package/src/setup/pr-setup.js +1 -1
- package/src/setup/stack-setup.js +1 -1
- package/src/utils/diff-annotator.js +175 -25
- package/src/utils/diff-file-content.js +4 -26
- package/src/utils/diff-file-list.js +178 -42
- package/src/utils/git-paths.js +77 -0
- package/src/utils/paths.js +1 -25
|
@@ -10,6 +10,11 @@ class SuggestionManager {
|
|
|
10
10
|
this.prManager = prManagerRef;
|
|
11
11
|
// Concurrency guard for displayAISuggestions
|
|
12
12
|
this._isDisplayingSuggestions = false;
|
|
13
|
+
// Latest list requested while a display was running; shown when it ends
|
|
14
|
+
this._pendingSuggestions = null;
|
|
15
|
+
// Bumped by clearAISuggestions so a display already running stops
|
|
16
|
+
// instead of putting the cleared findings back
|
|
17
|
+
this._displayEpoch = 0;
|
|
13
18
|
|
|
14
19
|
// Event delegation for "Ask about this" chat button on suggestions
|
|
15
20
|
document.addEventListener('click', (e) => {
|
|
@@ -206,27 +211,107 @@ class SuggestionManager {
|
|
|
206
211
|
}
|
|
207
212
|
|
|
208
213
|
/**
|
|
209
|
-
*
|
|
210
|
-
*
|
|
214
|
+
* Remove every rendered AI suggestion card: inline rows (legacy renderer),
|
|
215
|
+
* Pierre `suggestion` annotations and file-level AI cards. User comment
|
|
216
|
+
* cards are untouched. The navigator list is left alone; see
|
|
217
|
+
* clearAISuggestions for the full clear.
|
|
218
|
+
* @returns {number} Number of inline rows removed
|
|
219
|
+
* @private
|
|
220
|
+
*/
|
|
221
|
+
_removeRenderedSuggestions() {
|
|
222
|
+
const existingSuggestionRows = document.querySelectorAll('.ai-suggestion-row');
|
|
223
|
+
existingSuggestionRows.forEach(row => row.remove());
|
|
224
|
+
|
|
225
|
+
// Replace suggestion annotations, but preserve expanded context. These
|
|
226
|
+
// ranges are shared with user comments, external threads and navigation;
|
|
227
|
+
// clearing them here can leave those cards without a rendered anchor.
|
|
228
|
+
const pierreBridge = this.prManager?.pierreBridge;
|
|
229
|
+
if (pierreBridge) {
|
|
230
|
+
for (const [fileName] of pierreBridge.files) {
|
|
231
|
+
pierreBridge.removeAnnotationsByType(fileName, 'suggestion');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// An empty suggestions list clears the file-level AI cards; null
|
|
236
|
+
// comments leaves the user's file-level comment cards alone.
|
|
237
|
+
this.prManager?.fileCommentManager?.loadFileComments(null, []);
|
|
238
|
+
|
|
239
|
+
return existingSuggestionRows.length;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Remove every displayed AI suggestion: the rendered cards (inline rows,
|
|
244
|
+
* Pierre annotations, file-level cards) and the navigator list. Used when a
|
|
245
|
+
* new analysis starts, so nothing from the previous run stays on screen
|
|
246
|
+
* while it runs. User comments are untouched.
|
|
247
|
+
*
|
|
248
|
+
* A display that is running, or queued behind one, would put the cleared
|
|
249
|
+
* findings back when it finishes, so both are abandoned.
|
|
250
|
+
*/
|
|
251
|
+
clearAISuggestions() {
|
|
252
|
+
this._displayEpoch = (this._displayEpoch || 0) + 1;
|
|
253
|
+
this._pendingSuggestions = null;
|
|
254
|
+
this._closeReasoningPopover();
|
|
255
|
+
const removed = this._removeRenderedSuggestions();
|
|
256
|
+
console.log(`[UI] Cleared AI suggestions (${removed} inline rows)`);
|
|
257
|
+
|
|
258
|
+
const navigator = this.prManager?.suggestionNavigator;
|
|
259
|
+
if (navigator) {
|
|
260
|
+
navigator.updateSuggestions([]);
|
|
261
|
+
this._syncNavigatorLayout([]);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Reserve room for the navigator only while it has visible suggestions
|
|
267
|
+
* and is not collapsed.
|
|
268
|
+
* @param {Array} suggestions - The suggestions the navigator now shows
|
|
269
|
+
* @private
|
|
270
|
+
*/
|
|
271
|
+
_syncNavigatorLayout(suggestions) {
|
|
272
|
+
const mainContent = document.querySelector('.main-content');
|
|
273
|
+
if (mainContent && this.prManager?.suggestionNavigator) {
|
|
274
|
+
const visibleSuggestions = suggestions.filter(s => s.status !== 'dismissed');
|
|
275
|
+
// Only add navigator-visible if we have suggestions AND the navigator is not collapsed
|
|
276
|
+
if (visibleSuggestions.length > 0 && !this.prManager.suggestionNavigator.isCollapsed) {
|
|
277
|
+
mainContent.classList.add('navigator-visible');
|
|
278
|
+
} else {
|
|
279
|
+
mainContent.classList.remove('navigator-visible');
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Display AI suggestions inline with diff.
|
|
286
|
+
*
|
|
287
|
+
* Displays never interleave. A call made while one is running does not
|
|
288
|
+
* wait: it records its list and returns at once, and the latest recorded
|
|
289
|
+
* list is displayed when the running one ends. Returning at once (rather
|
|
290
|
+
* than awaiting the queued display) matters: a running display can itself
|
|
291
|
+
* be awaiting work that requests a display, and waiting there would
|
|
292
|
+
* deadlock.
|
|
211
293
|
* @param {Array} suggestions - Array of suggestions to display
|
|
212
294
|
*/
|
|
213
295
|
async displayAISuggestions(suggestions) {
|
|
214
|
-
// Concurrency guard: prevent multiple simultaneous executions
|
|
215
|
-
// This avoids duplicated/interleaved suggestions when called rapidly
|
|
216
296
|
if (this._isDisplayingSuggestions) {
|
|
217
|
-
console.log('[UI] displayAISuggestions already in progress,
|
|
297
|
+
console.log('[UI] displayAISuggestions already in progress, queued the latest request');
|
|
298
|
+
this._pendingSuggestions = suggestions;
|
|
218
299
|
return;
|
|
219
300
|
}
|
|
220
301
|
this._isDisplayingSuggestions = true;
|
|
302
|
+
// clearAISuggestions bumps the epoch; a display it interrupts must stop
|
|
303
|
+
// after its awaits rather than show the cleared list.
|
|
304
|
+
const epoch = this._displayEpoch;
|
|
221
305
|
|
|
222
306
|
try {
|
|
223
307
|
this._closeReasoningPopover();
|
|
224
308
|
console.log(`[UI] Displaying ${suggestions.length} AI suggestions`);
|
|
225
309
|
|
|
226
|
-
// Clear
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
310
|
+
// Clear the previous set's cards before displaying new ones. The
|
|
311
|
+
// navigator keeps its list (and selection) until the new list replaces
|
|
312
|
+
// it below.
|
|
313
|
+
const removedRows = this._removeRenderedSuggestions();
|
|
314
|
+
console.log(`[UI] Removed ${removedRows} existing suggestion rows`);
|
|
230
315
|
|
|
231
316
|
// Only inline (line-targeted) suggestions need the diff body rendered
|
|
232
317
|
// ahead of time. File-level findings (is_file_level === 1 or no
|
|
@@ -250,15 +335,6 @@ class SuggestionManager {
|
|
|
250
335
|
}
|
|
251
336
|
}
|
|
252
337
|
|
|
253
|
-
// Replace suggestion annotations, but preserve expanded context. These
|
|
254
|
-
// ranges are shared with user comments, external threads and navigation;
|
|
255
|
-
// clearing them here can leave those cards without a rendered anchor.
|
|
256
|
-
if (this.prManager.pierreBridge) {
|
|
257
|
-
for (const [fileName] of this.prManager.pierreBridge.files) {
|
|
258
|
-
this.prManager.pierreBridge.removeAnnotationsByType(fileName, 'suggestion');
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
338
|
const lineTargets = suggestions
|
|
263
339
|
.filter(suggestion =>
|
|
264
340
|
suggestion.file
|
|
@@ -276,6 +352,12 @@ class SuggestionManager {
|
|
|
276
352
|
await this.prManager.ensureLinesVisible(lineTargets);
|
|
277
353
|
}
|
|
278
354
|
|
|
355
|
+
// The findings were cleared while we awaited (a new analysis started).
|
|
356
|
+
if (epoch !== this._displayEpoch) {
|
|
357
|
+
console.log('[UI] Suggestions were cleared during display; not showing the stale list');
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
|
|
279
361
|
// For files rendered by @pierre/diffs, use annotation-based display.
|
|
280
362
|
// Deferred files may have been materialized by ensureLinesVisible() above,
|
|
281
363
|
// so group after that step.
|
|
@@ -335,16 +417,7 @@ class SuggestionManager {
|
|
|
335
417
|
}
|
|
336
418
|
|
|
337
419
|
// Adjust main content layout when navigator is visible
|
|
338
|
-
|
|
339
|
-
if (mainContent && this.prManager?.suggestionNavigator) {
|
|
340
|
-
const visibleSuggestions = suggestions.filter(s => s.status !== 'dismissed');
|
|
341
|
-
// Only add navigator-visible if we have suggestions AND the navigator is not collapsed
|
|
342
|
-
if (visibleSuggestions.length > 0 && !this.prManager.suggestionNavigator.isCollapsed) {
|
|
343
|
-
mainContent.classList.add('navigator-visible');
|
|
344
|
-
} else {
|
|
345
|
-
mainContent.classList.remove('navigator-visible');
|
|
346
|
-
}
|
|
347
|
-
}
|
|
420
|
+
this._syncNavigatorLayout(suggestions);
|
|
348
421
|
|
|
349
422
|
// Separate file-level and line-level suggestions
|
|
350
423
|
const fileLevelSuggestions = [];
|
|
@@ -358,10 +431,12 @@ class SuggestionManager {
|
|
|
358
431
|
}
|
|
359
432
|
});
|
|
360
433
|
|
|
361
|
-
// Handle file-level suggestions via FileCommentManager
|
|
362
|
-
|
|
434
|
+
// Handle file-level suggestions via FileCommentManager. The list
|
|
435
|
+
// replaces the previous AI cards even when it is empty; null comments
|
|
436
|
+
// leaves the user's file-level comment cards alone.
|
|
437
|
+
if (this.prManager?.fileCommentManager) {
|
|
363
438
|
console.log('[UI] Routing file-level suggestions to FileCommentManager:', fileLevelSuggestions.length);
|
|
364
|
-
this.prManager.fileCommentManager.loadFileComments(
|
|
439
|
+
this.prManager.fileCommentManager.loadFileComments(null, fileLevelSuggestions);
|
|
365
440
|
}
|
|
366
441
|
|
|
367
442
|
// Group line-level suggestions by file, line, and side
|
|
@@ -471,9 +546,29 @@ class SuggestionManager {
|
|
|
471
546
|
} finally {
|
|
472
547
|
// Always clear the guard, even if an error occurred
|
|
473
548
|
this._isDisplayingSuggestions = false;
|
|
549
|
+
this._runPendingDisplay();
|
|
474
550
|
}
|
|
475
551
|
}
|
|
476
552
|
|
|
553
|
+
/**
|
|
554
|
+
* Start the display queued while another one ran, if any. Not awaited by
|
|
555
|
+
* the display that just ended, and its errors are logged here, so they
|
|
556
|
+
* never replace that display's own outcome.
|
|
557
|
+
* @private
|
|
558
|
+
*/
|
|
559
|
+
_runPendingDisplay() {
|
|
560
|
+
const pending = this._pendingSuggestions;
|
|
561
|
+
if (!pending) return;
|
|
562
|
+
this._pendingSuggestions = null;
|
|
563
|
+
// Through PRManager when present, so its post-display refresh runs too.
|
|
564
|
+
const display = typeof this.prManager?.displayAISuggestions === 'function'
|
|
565
|
+
? this.prManager.displayAISuggestions(pending)
|
|
566
|
+
: this.displayAISuggestions(pending);
|
|
567
|
+
Promise.resolve(display).catch(error => {
|
|
568
|
+
console.error('[UI] Queued suggestion display failed:', error);
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
|
|
477
572
|
/**
|
|
478
573
|
* Create a suggestion row for display
|
|
479
574
|
* @param {Array} suggestions - Suggestions for this location
|
|
@@ -568,7 +663,7 @@ class SuggestionManager {
|
|
|
568
663
|
: `<span class="ai-suggestion-badge" data-type="${suggestion.type}" title="${this.getTypeDescription(suggestion.type)}"><svg viewBox="0 0 16 16" fill="currentColor" width="12" height="12"><path d="M9.6 2.279a.426.426 0 0 1 .8 0l.407 1.112a6.386 6.386 0 0 0 3.802 3.802l1.112.407a.426.426 0 0 1 0 .8l-1.112.407a6.386 6.386 0 0 0-3.802 3.802l-.407 1.112a.426.426 0 0 1-.8 0l-.407-1.112a6.386 6.386 0 0 0-3.802-3.802L4.279 8.4a.426.426 0 0 1 0-.8l1.112-.407a6.386 6.386 0 0 0 3.802-3.802L9.6 2.279Zm-4.267 8.837a.178.178 0 0 1 .334 0l.169.464a2.662 2.662 0 0 0 1.584 1.584l.464.169a.178.178 0 0 1 0 .334l-.464.169a2.662 2.662 0 0 0-1.584 1.584l-.169.464a.178.178 0 0 1-.334 0l-.169-.464a2.662 2.662 0 0 0-1.584-1.584l-.464-.169a.178.178 0 0 1 0-.334l.464-.169a2.662 2.662 0 0 0 1.584-1.584l.169-.464ZM2.8.14a.213.213 0 0 1 .4 0l.203.556a3.2 3.2 0 0 0 1.901 1.901l.556.203a.213.213 0 0 1 0 .4l-.556.203a3.2 3.2 0 0 0-1.901 1.901L3.2 5.86a.213.213 0 0 1-.4 0l-.203-.556A3.2 3.2 0 0 0 .696 3.403L.14 3.2a.213.213 0 0 1 0-.4l.556-.203A3.2 3.2 0 0 0 2.597.696L2.8.14Z"/></svg>AI Suggestion</span>`}
|
|
569
664
|
${suggestion.severity ? `<span class="severity-badge severity-${suggestion.severity}">${escapeHtml(suggestion.severity.toUpperCase())}</span>` : ''}
|
|
570
665
|
${categoryLabel ? `<span class="ai-suggestion-category">${escapeHtml(categoryLabel)}</span>` : ''}
|
|
571
|
-
<span class="ai-title">${escapeHtml(suggestion.title || '')}</span>
|
|
666
|
+
<span class="ai-title smart-truncate">${escapeHtml(suggestion.title || '')}</span>
|
|
572
667
|
</div>
|
|
573
668
|
<div class="ai-suggestion-header-right">
|
|
574
669
|
${showReasoningBtn ? `
|
|
@@ -583,7 +678,7 @@ class SuggestionManager {
|
|
|
583
678
|
? `<span class="praise-badge" title="Nice Work"><svg viewBox="0 0 16 16"><path d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25z"/></svg>Nice Work</span>`
|
|
584
679
|
: `<span class="ai-suggestion-badge collapsed" data-type="${suggestion.type}" title="${this.getTypeDescription(suggestion.type)}"><svg viewBox="0 0 16 16" fill="currentColor" width="10" height="10"><path d="M9.6 2.279a.426.426 0 0 1 .8 0l.407 1.112a6.386 6.386 0 0 0 3.802 3.802l1.112.407a.426.426 0 0 1 0 .8l-1.112.407a6.386 6.386 0 0 0-3.802 3.802l-.407 1.112a.426.426 0 0 1-.8 0l-.407-1.112a6.386 6.386 0 0 0-3.802-3.802L4.279 8.4a.426.426 0 0 1 0-.8l1.112-.407a6.386 6.386 0 0 0 3.802-3.802L9.6 2.279Zm-4.267 8.837a.178.178 0 0 1 .334 0l.169.464a2.662 2.662 0 0 0 1.584 1.584l.464.169a.178.178 0 0 1 0 .334l-.464.169a2.662 2.662 0 0 0-1.584 1.584l-.169.464a.178.178 0 0 1-.334 0l-.169-.464a2.662 2.662 0 0 0-1.584-1.584l-.464-.169a.178.178 0 0 1 0-.334l.464-.169a2.662 2.662 0 0 0 1.584-1.584l.169-.464ZM2.8.14a.213.213 0 0 1 .4 0l.203.556a3.2 3.2 0 0 0 1.901 1.901l.556.203a.213.213 0 0 1 0 .4l-.556.203a3.2 3.2 0 0 0-1.901 1.901L3.2 5.86a.213.213 0 0 1-.4 0l-.203-.556A3.2 3.2 0 0 0 .696 3.403L.14 3.2a.213.213 0 0 1 0-.4l.556-.203A3.2 3.2 0 0 0 2.597.696L2.8.14Z"/></svg>AI Suggestion</span>`}
|
|
585
680
|
${suggestion.severity ? `<span class="severity-badge severity-${suggestion.severity}">${escapeHtml(suggestion.severity.toUpperCase())}</span>` : ''}
|
|
586
|
-
<span class="collapsed-title">${escapeHtml(suggestion.title || '')}</span>
|
|
681
|
+
<span class="collapsed-title smart-truncate">${escapeHtml(suggestion.title || '')}</span>
|
|
587
682
|
<div class="ai-suggestion-header-right">
|
|
588
683
|
${showReasoningBtn ? `
|
|
589
684
|
<button class="btn-reasoning-toggle collapsed-reasoning" title="View reasoning" data-suggestion-id="${suggestion.id}" data-reasoning="${reasoningDataAttr}" data-dismissal-reason="${dismissalReasonAttr}">
|
package/public/js/pr.js
CHANGED
|
@@ -234,6 +234,8 @@ class PRManager {
|
|
|
234
234
|
// Lazy-instantiated TourBar / TourRenderer; populated on first open.
|
|
235
235
|
this._tourBar = null;
|
|
236
236
|
this._tourRenderer = null;
|
|
237
|
+
// Re-measures the mounted tour bar; see _trackTourBarHeight().
|
|
238
|
+
this._tourBarResizeObserver = null;
|
|
237
239
|
// Tri-state mirror of `tours.enabled` in /api/config. Tours are
|
|
238
240
|
// independent of summaries on both the server and the client (see
|
|
239
241
|
// the explanatory comment in setupEventHandlers()).
|
|
@@ -411,6 +413,10 @@ class PRManager {
|
|
|
411
413
|
// Track toolbar height for sticky file headers (they sit below the sticky toolbar)
|
|
412
414
|
this._initToolbarHeightTracking();
|
|
413
415
|
|
|
416
|
+
// Wire the file navigator toggles once; the sidebar markup is static, so
|
|
417
|
+
// this must not wait for (or depend on) a non-empty file list
|
|
418
|
+
this.setupSidebarToggle();
|
|
419
|
+
|
|
414
420
|
// Initialize diff options dropdown (gear icon for whitespace toggle).
|
|
415
421
|
// Must happen before init() so the persisted hideWhitespace state is
|
|
416
422
|
// applied before the first loadAndDisplayFiles() call.
|
|
@@ -504,6 +510,29 @@ class PRManager {
|
|
|
504
510
|
}
|
|
505
511
|
}
|
|
506
512
|
|
|
513
|
+
/**
|
|
514
|
+
* Track the mounted tour bar's height (it grows when wrapped). Call after each mount.
|
|
515
|
+
*/
|
|
516
|
+
_trackTourBarHeight() {
|
|
517
|
+
const bar = document.querySelector('.tour-bar');
|
|
518
|
+
if (!bar) return;
|
|
519
|
+
|
|
520
|
+
const update = () => {
|
|
521
|
+
if (bar.offsetHeight) {
|
|
522
|
+
document.documentElement.style.setProperty(
|
|
523
|
+
'--tour-bar-rendered-height', bar.offsetHeight + 'px'
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
update();
|
|
528
|
+
|
|
529
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
530
|
+
this._tourBarResizeObserver?.disconnect();
|
|
531
|
+
this._tourBarResizeObserver = new ResizeObserver(update);
|
|
532
|
+
this._tourBarResizeObserver.observe(bar);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
507
536
|
/**
|
|
508
537
|
* Keep --diff-file-header-height in sync with the rendered sticky file
|
|
509
538
|
* header so navigation (block:'start' + scroll-margin-top in pr.css) lands
|
|
@@ -2291,6 +2320,7 @@ class PRManager {
|
|
|
2291
2320
|
// controls stay visible.
|
|
2292
2321
|
const diffView = document.querySelector('.main-layout .diff-view');
|
|
2293
2322
|
this._tourBar.mount(diffView || undefined);
|
|
2323
|
+
this._trackTourBarHeight();
|
|
2294
2324
|
this._tourBar.setStops(this._tourStops);
|
|
2295
2325
|
this._tourBar.setCompleted(false);
|
|
2296
2326
|
|
|
@@ -2464,6 +2494,10 @@ class PRManager {
|
|
|
2464
2494
|
if (this._tourBar) {
|
|
2465
2495
|
this._tourBar.unmount();
|
|
2466
2496
|
}
|
|
2497
|
+
// The measured height is only read under body.tour-active, so a stale
|
|
2498
|
+
// value is harmless; just stop observing the removed bar.
|
|
2499
|
+
this._tourBarResizeObserver?.disconnect();
|
|
2500
|
+
this._tourBarResizeObserver = null;
|
|
2467
2501
|
this._unregisterTourKeyboardHandlers();
|
|
2468
2502
|
this._tourActiveIndex = -1;
|
|
2469
2503
|
// Consume any pending tour stashed by `review:tour_ready` while we
|
|
@@ -2889,11 +2923,14 @@ class PRManager {
|
|
|
2889
2923
|
for (const part of parts) {
|
|
2890
2924
|
if (!part.trim()) continue;
|
|
2891
2925
|
|
|
2892
|
-
//
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2926
|
+
// Key by the decoded new path: the `rename to` line when there is one,
|
|
2927
|
+
// otherwise the 'b' side of the diff --git line. Git C-quotes names
|
|
2928
|
+
// containing control characters, `"` or `\` (`"b/tab\tname.js"`), and
|
|
2929
|
+
// the server keys changed_files, comments and suggestions by the
|
|
2930
|
+
// decoded spelling.
|
|
2931
|
+
const paths = window.GitPaths.parsePatchPaths(part);
|
|
2932
|
+
if (paths) {
|
|
2933
|
+
filePatchMap.set(paths.newPath, part);
|
|
2897
2934
|
}
|
|
2898
2935
|
}
|
|
2899
2936
|
|
|
@@ -6632,9 +6669,12 @@ class PRManager {
|
|
|
6632
6669
|
});
|
|
6633
6670
|
}
|
|
6634
6671
|
|
|
6635
|
-
// Load file-level comments into their zones (only active comments reach
|
|
6636
|
-
|
|
6637
|
-
|
|
6672
|
+
// Load file-level comments into their zones (only active comments reach
|
|
6673
|
+
// here). Always pass the list, even when empty, so the cards of a
|
|
6674
|
+
// deleted or dismissed last comment are removed. null suggestions
|
|
6675
|
+
// leaves the file-level AI cards alone.
|
|
6676
|
+
if (this.fileCommentManager) {
|
|
6677
|
+
this.fileCommentManager.loadFileComments(fileLevelComments, null);
|
|
6638
6678
|
}
|
|
6639
6679
|
|
|
6640
6680
|
// Populate AI Panel with all comments (including dismissed if requested)
|
|
@@ -7694,8 +7734,6 @@ class PRManager {
|
|
|
7694
7734
|
const groupElement = this.renderFileGroup(dirPath, dirFiles);
|
|
7695
7735
|
fileListContainer.appendChild(groupElement);
|
|
7696
7736
|
}
|
|
7697
|
-
|
|
7698
|
-
this.setupSidebarToggle();
|
|
7699
7737
|
}
|
|
7700
7738
|
|
|
7701
7739
|
renderFileGroup(dirPath, files) {
|
|
@@ -7843,23 +7881,75 @@ class PRManager {
|
|
|
7843
7881
|
});
|
|
7844
7882
|
};
|
|
7845
7883
|
|
|
7884
|
+
// Below its breakpoint pr.css hides the docked sidebar and flags that via
|
|
7885
|
+
// --sidebar-overlay-only; the toolbar toggle then opens it as an overlay
|
|
7886
|
+
// drawer instead. Reading the flag keeps the breakpoint in CSS only.
|
|
7887
|
+
const isOverlayMode = () => getComputedStyle(document.documentElement)
|
|
7888
|
+
.getPropertyValue('--sidebar-overlay-only').trim() === '1';
|
|
7889
|
+
|
|
7890
|
+
// --sidebar-width is the room the docked sidebar takes from the layout:
|
|
7891
|
+
// 0 while collapsed, or on slim screens where it only floats.
|
|
7892
|
+
const syncSidebarWidth = () => {
|
|
7893
|
+
const docked = !isOverlayMode() && !sidebar.classList.contains('collapsed');
|
|
7894
|
+
const width = window.PanelResizer?.getSavedWidth('sidebar')
|
|
7895
|
+
|| window.PanelResizer?.getDefaultWidth('sidebar')
|
|
7896
|
+
|| 260;
|
|
7897
|
+
document.documentElement.style.setProperty('--sidebar-width', docked ? `${width}px` : '0px');
|
|
7898
|
+
// Notify PanelGroup so its docked-vs-floating decision sees the change
|
|
7899
|
+
window.panelGroup?._updateRightPanelGroupWidth();
|
|
7900
|
+
};
|
|
7901
|
+
|
|
7846
7902
|
// Restore collapsed state from localStorage (synchronous on init is fine)
|
|
7847
7903
|
const isCollapsed = localStorage.getItem('file-sidebar-collapsed') === 'true';
|
|
7848
7904
|
if (isCollapsed) {
|
|
7849
7905
|
sidebar.classList.add('collapsed');
|
|
7850
|
-
document.documentElement.style.setProperty('--sidebar-width', '0px');
|
|
7851
|
-
} else {
|
|
7852
|
-
const savedWidth = window.PanelResizer?.getSavedWidth('sidebar')
|
|
7853
|
-
|| window.PanelResizer?.getDefaultWidth('sidebar')
|
|
7854
|
-
|| 260;
|
|
7855
|
-
document.documentElement.style.setProperty('--sidebar-width', `${savedWidth}px`);
|
|
7856
7906
|
}
|
|
7907
|
+
syncSidebarWidth();
|
|
7908
|
+
|
|
7909
|
+
// The drawer state is transient so it never overwrites the persisted
|
|
7910
|
+
// docked (wide-screen) collapsed state.
|
|
7911
|
+
const setOverlayOpen = (open) => {
|
|
7912
|
+
sidebar.classList.toggle('sidebar--overlay-open', open);
|
|
7913
|
+
collapsedBtn.setAttribute('aria-expanded', String(open));
|
|
7914
|
+
};
|
|
7857
7915
|
|
|
7858
7916
|
// Collapse button (X) in sidebar header - collapses sidebar
|
|
7859
|
-
toggleBtn.addEventListener('click', () =>
|
|
7917
|
+
toggleBtn.addEventListener('click', () => {
|
|
7918
|
+
if (isOverlayMode()) {
|
|
7919
|
+
setOverlayOpen(false);
|
|
7920
|
+
return;
|
|
7921
|
+
}
|
|
7922
|
+
toggleSidebar(true);
|
|
7923
|
+
});
|
|
7924
|
+
|
|
7925
|
+
// Expand button in diff toolbar - expands sidebar (toggles the drawer on slim screens)
|
|
7926
|
+
collapsedBtn.addEventListener('click', () => {
|
|
7927
|
+
if (isOverlayMode()) {
|
|
7928
|
+
setOverlayOpen(!sidebar.classList.contains('sidebar--overlay-open'));
|
|
7929
|
+
return;
|
|
7930
|
+
}
|
|
7931
|
+
toggleSidebar(false);
|
|
7932
|
+
});
|
|
7933
|
+
|
|
7934
|
+
// Picking a file from the drawer jumps to it, so get the drawer out of the
|
|
7935
|
+
// way of the diff it was covering.
|
|
7936
|
+
sidebar.addEventListener('click', (e) => {
|
|
7937
|
+
if (isOverlayMode() && e.target.closest?.('.file-item')) {
|
|
7938
|
+
setOverlayOpen(false);
|
|
7939
|
+
}
|
|
7940
|
+
});
|
|
7860
7941
|
|
|
7861
|
-
//
|
|
7862
|
-
|
|
7942
|
+
// Crossing the breakpoint: leaving slim mode docks the sidebar per its
|
|
7943
|
+
// persisted state, so drop the drawer (it must not reappear when the
|
|
7944
|
+
// viewport narrows again) and re-derive --sidebar-width either way.
|
|
7945
|
+
let wasOverlayMode = isOverlayMode();
|
|
7946
|
+
window.addEventListener('resize', () => {
|
|
7947
|
+
const overlayMode = isOverlayMode();
|
|
7948
|
+
if (overlayMode === wasOverlayMode) return;
|
|
7949
|
+
wasOverlayMode = overlayMode;
|
|
7950
|
+
if (!overlayMode) setOverlayOpen(false);
|
|
7951
|
+
syncSidebarWidth();
|
|
7952
|
+
});
|
|
7863
7953
|
}
|
|
7864
7954
|
|
|
7865
7955
|
async scrollToFile(filePath) {
|
|
@@ -8329,6 +8419,27 @@ class PRManager {
|
|
|
8329
8419
|
}
|
|
8330
8420
|
}
|
|
8331
8421
|
|
|
8422
|
+
/**
|
|
8423
|
+
* Clear the previous run's AI findings when a new analysis starts: the AI
|
|
8424
|
+
* panel list and, through SuggestionManager.clearAISuggestions, every
|
|
8425
|
+
* suggestion card in the diff (inline rows, Pierre annotations, file-level
|
|
8426
|
+
* cards) and the navigator list. User comments stay. Shared by PR mode
|
|
8427
|
+
* (startAnalysis) and Local mode (startLocalAnalysis in local.js).
|
|
8428
|
+
*/
|
|
8429
|
+
clearFindingsForNewAnalysis() {
|
|
8430
|
+
if (typeof window.aiPanel?.clearAllFindings === 'function') {
|
|
8431
|
+
try {
|
|
8432
|
+
// Also clears the diff view
|
|
8433
|
+
window.aiPanel.clearAllFindings();
|
|
8434
|
+
return;
|
|
8435
|
+
} catch (e) {
|
|
8436
|
+
console.warn('Error clearing AI panel findings:', e);
|
|
8437
|
+
// Fall through so the diff view is still cleared
|
|
8438
|
+
}
|
|
8439
|
+
}
|
|
8440
|
+
this.suggestionManager?.clearAISuggestions();
|
|
8441
|
+
}
|
|
8442
|
+
|
|
8332
8443
|
/**
|
|
8333
8444
|
* Start the actual AI analysis with the given config
|
|
8334
8445
|
* @param {string} owner - Repository owner
|
|
@@ -8352,16 +8463,7 @@ class PRManager {
|
|
|
8352
8463
|
}
|
|
8353
8464
|
|
|
8354
8465
|
// Clear existing AI suggestions from UI immediately when starting new analysis
|
|
8355
|
-
|
|
8356
|
-
try {
|
|
8357
|
-
window.aiPanel.clearAllFindings();
|
|
8358
|
-
} catch (e) {
|
|
8359
|
-
console.warn('Error clearing AI panel findings:', e);
|
|
8360
|
-
// Fall through to manual DOM cleanup
|
|
8361
|
-
}
|
|
8362
|
-
}
|
|
8363
|
-
// Always do manual DOM cleanup as backup
|
|
8364
|
-
document.querySelectorAll('.ai-suggestion-row').forEach(row => row.remove());
|
|
8466
|
+
this.clearFindingsForNewAnalysis();
|
|
8365
8467
|
|
|
8366
8468
|
// Determine endpoint and body based on whether this is a council analysis
|
|
8367
8469
|
let analyzeUrl, analyzeBody;
|
|
@@ -9015,6 +9117,7 @@ class PRManager {
|
|
|
9015
9117
|
const fileName = document.createElement('span');
|
|
9016
9118
|
fileName.className = 'd2h-file-name';
|
|
9017
9119
|
fileName.textContent = contextFile.file;
|
|
9120
|
+
window.DiffRenderer.applyFilePathTruncation(fileName, contextFile.file);
|
|
9018
9121
|
header.appendChild(fileName);
|
|
9019
9122
|
|
|
9020
9123
|
const contextLabel = document.createElement('span');
|
|
@@ -145,22 +145,10 @@ class RepoSettingsPage {
|
|
|
145
145
|
const oldProvider = this.providers[previousProvider];
|
|
146
146
|
const newProvider = this.providers[newProviderId];
|
|
147
147
|
|
|
148
|
-
if (
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (currentModel) {
|
|
153
|
-
const matchingModel = newProvider.models.find(m => m.tier === currentModel.tier);
|
|
154
|
-
const defaultModel = newProvider.models.find(m => m.default);
|
|
155
|
-
const fallbackModel = matchingModel || defaultModel || newProvider.models[0];
|
|
156
|
-
this.currentSettings.default_model = fallbackModel.id;
|
|
157
|
-
} else {
|
|
158
|
-
const defaultModel = newProvider.models.find(m => m.default) || newProvider.models[0];
|
|
159
|
-
this.currentSettings.default_model = defaultModel.id;
|
|
160
|
-
}
|
|
161
|
-
} else if (newProvider) {
|
|
162
|
-
const defaultModel = newProvider.models.find(m => m.default) || newProvider.models[0];
|
|
163
|
-
this.currentSettings.default_model = defaultModel.id;
|
|
148
|
+
if (newProvider) {
|
|
149
|
+
this.currentSettings.default_model = this.mapModelForProviderSwitch(
|
|
150
|
+
oldProvider, newProvider, this.currentSettings.default_model
|
|
151
|
+
);
|
|
164
152
|
}
|
|
165
153
|
|
|
166
154
|
// Update model select and card to reflect the mapped model
|
|
@@ -478,6 +466,28 @@ class RepoSettingsPage {
|
|
|
478
466
|
this.selectedProvider = providerId;
|
|
479
467
|
}
|
|
480
468
|
|
|
469
|
+
/**
|
|
470
|
+
* Pick the model to keep when the user switches providers: the new
|
|
471
|
+
* provider's model in the same tier as the current one, else its default.
|
|
472
|
+
* Within a tier the default wins over the tier's first entry, because the
|
|
473
|
+
* first entry can be plan-gated (Antigravity's Gemini 4 Argon) and this
|
|
474
|
+
* choice is saved as the repo's default_model.
|
|
475
|
+
* @param {Object|undefined} oldProvider - Provider being switched away from
|
|
476
|
+
* @param {Object} newProvider - Provider being switched to (has `models`)
|
|
477
|
+
* @param {string} currentModelId - Current default_model (id or alias)
|
|
478
|
+
* @returns {string} Model id within newProvider
|
|
479
|
+
*/
|
|
480
|
+
mapModelForProviderSwitch(oldProvider, newProvider, currentModelId) {
|
|
481
|
+
const defaultModel = newProvider.models.find(m => m.default) || newProvider.models[0];
|
|
482
|
+
// Match by id or alias so legacy model IDs still resolve their tier
|
|
483
|
+
// when the user switches providers.
|
|
484
|
+
const currentModel = oldProvider ? this.findModelWithAliases(oldProvider, currentModelId) : null;
|
|
485
|
+
if (!currentModel) return defaultModel.id;
|
|
486
|
+
const matchingModel = newProvider.models.find(m => m.default && m.tier === currentModel.tier)
|
|
487
|
+
|| newProvider.models.find(m => m.tier === currentModel.tier);
|
|
488
|
+
return (matchingModel || defaultModel).id;
|
|
489
|
+
}
|
|
490
|
+
|
|
481
491
|
/**
|
|
482
492
|
* Look up a model by ID within a provider, matching both canonical `id` and
|
|
483
493
|
* `aliases`. Historical repo settings may still reference legacy model IDs
|
|
@@ -1317,6 +1327,12 @@ class RepoSettingsPage {
|
|
|
1317
1327
|
}
|
|
1318
1328
|
|
|
1319
1329
|
// Initialize when DOM is ready
|
|
1320
|
-
document
|
|
1321
|
-
|
|
1322
|
-
|
|
1330
|
+
if (typeof document !== 'undefined') {
|
|
1331
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
1332
|
+
window.repoSettings = new RepoSettingsPage();
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
1337
|
+
module.exports = { RepoSettingsPage };
|
|
1338
|
+
}
|