@in-the-loop-labs/pair-review 5.3.4 → 5.3.6
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 +13 -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 +39 -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/chat/acp-bridge.js +26 -1
- package/src/chat/claude-code-bridge.js +10 -0
- package/src/chat/codex-bridge.js +10 -0
- package/src/chat/pi-bridge.js +10 -0
- package/src/chat/session-manager.js +333 -19
- package/src/config.js +40 -26
- 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/impl/host/pending-review-comments.js +75 -11
- 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/chat.js +44 -1
- package/src/routes/executable-analysis.js +14 -15
- package/src/routes/local.js +3 -5
- package/src/routes/pr.js +18 -105
- package/src/server.js +5 -3
- package/src/settings/registry.js +10 -0
- 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
|
@@ -1208,15 +1208,21 @@ class ChatPanel {
|
|
|
1208
1208
|
const handle = this.panel.querySelector('.chat-panel__resize-handle');
|
|
1209
1209
|
if (!handle) return;
|
|
1210
1210
|
|
|
1211
|
-
const { min, storageKey } = this._resizeConfig;
|
|
1211
|
+
const { min, storageKey, cssVar } = this._resizeConfig;
|
|
1212
|
+
|
|
1213
|
+
// The panel can render narrower than its width variable while it shrinks to
|
|
1214
|
+
// share a drawer, so resize from (and save) the variable, not the box
|
|
1215
|
+
const getWidth = () => parseInt(getComputedStyle(document.documentElement).getPropertyValue(cssVar), 10)
|
|
1216
|
+
|| this.panel.getBoundingClientRect().width;
|
|
1212
1217
|
|
|
1213
1218
|
let startX = 0;
|
|
1214
1219
|
let startWidth = 0;
|
|
1215
1220
|
|
|
1216
1221
|
const onMouseMove = (e) => {
|
|
1217
|
-
//
|
|
1218
|
-
|
|
1219
|
-
|
|
1222
|
+
// Dynamic max: leave room for the docked sidebar and a minimum content
|
|
1223
|
+
// area. Shared with the Review panel so both resize against the same
|
|
1224
|
+
// bound (a collapsed/slim-screen sidebar correctly counts as 0).
|
|
1225
|
+
const dynamicMax = window.PanelResizer?.getDynamicPanelMax?.() ?? (window.innerWidth - 100);
|
|
1220
1226
|
|
|
1221
1227
|
// Panel is right-anchored, so dragging left (decreasing clientX) should increase width
|
|
1222
1228
|
const delta = startX - e.clientX;
|
|
@@ -1226,8 +1232,7 @@ class ChatPanel {
|
|
|
1226
1232
|
|
|
1227
1233
|
const onMouseUp = () => {
|
|
1228
1234
|
// Persist the final width
|
|
1229
|
-
|
|
1230
|
-
localStorage.setItem(storageKey, Math.round(finalWidth));
|
|
1235
|
+
localStorage.setItem(storageKey, Math.round(getWidth()));
|
|
1231
1236
|
|
|
1232
1237
|
handle.classList.remove('dragging');
|
|
1233
1238
|
this.panel.classList.remove('chat-panel--resizing');
|
|
@@ -1243,7 +1248,7 @@ class ChatPanel {
|
|
|
1243
1248
|
handle.addEventListener('mousedown', (e) => {
|
|
1244
1249
|
e.preventDefault();
|
|
1245
1250
|
startX = e.clientX;
|
|
1246
|
-
startWidth =
|
|
1251
|
+
startWidth = getWidth();
|
|
1247
1252
|
|
|
1248
1253
|
handle.classList.add('dragging');
|
|
1249
1254
|
this.panel.classList.add('chat-panel--resizing');
|
|
@@ -1644,6 +1649,9 @@ class ChatPanel {
|
|
|
1644
1649
|
this.isOpen = true;
|
|
1645
1650
|
this.panel.classList.remove('chat-panel--closed');
|
|
1646
1651
|
this.panel.classList.add('chat-panel--open');
|
|
1652
|
+
// Tell PanelGroup now, not after the awaits below: it lays the panels out
|
|
1653
|
+
// from this, and a close() during the restore must not be overwritten
|
|
1654
|
+
window.panelGroup?._onChatVisibilityChanged(true);
|
|
1647
1655
|
|
|
1648
1656
|
// Warm the model catalog so the header can show real model names. Never
|
|
1649
1657
|
// blocks the open; the header is re-rendered if/when it lands.
|
|
@@ -1763,7 +1771,6 @@ class ChatPanel {
|
|
|
1763
1771
|
}
|
|
1764
1772
|
|
|
1765
1773
|
this._updateActionButtons();
|
|
1766
|
-
window.panelGroup?._onChatVisibilityChanged(true);
|
|
1767
1774
|
if (!options.suppressFocus) {
|
|
1768
1775
|
this.inputEl.focus();
|
|
1769
1776
|
}
|
|
@@ -5025,6 +5032,12 @@ class ChatPanel {
|
|
|
5025
5032
|
console.debug('[ChatPanel] WS event:', data.type, 'tab:', tab.sessionId);
|
|
5026
5033
|
}
|
|
5027
5034
|
|
|
5035
|
+
// Same handling whether or not the tab is in the foreground.
|
|
5036
|
+
if (data.type === 'session_closed') {
|
|
5037
|
+
this._handleSessionClosed(tab);
|
|
5038
|
+
return;
|
|
5039
|
+
}
|
|
5040
|
+
|
|
5028
5041
|
const isActive = this.isOpen && this._getActiveTab() === tab;
|
|
5029
5042
|
|
|
5030
5043
|
// Background tab (or panel closed): drive the per-tab DOM via tab-aware
|
|
@@ -5112,6 +5125,24 @@ class ChatPanel {
|
|
|
5112
5125
|
}
|
|
5113
5126
|
}
|
|
5114
5127
|
|
|
5128
|
+
/**
|
|
5129
|
+
* The server shut down this tab's agent process (idle timeout). The session
|
|
5130
|
+
* resumes transparently on the next send, so nothing is shown; clearing
|
|
5131
|
+
* `sessionWarm` makes that send show the ACP "Resuming" indicator.
|
|
5132
|
+
* The server does not reap a session mid-turn, but if this tab still thinks
|
|
5133
|
+
* it is streaming, no 'complete' will ever arrive for it: end the stream the
|
|
5134
|
+
* way 'complete' does (tab-aware, so it is correct for a background tab
|
|
5135
|
+
* too — UI controls are only touched when the tab is active).
|
|
5136
|
+
* @param {ChatTab} tab
|
|
5137
|
+
*/
|
|
5138
|
+
_handleSessionClosed(tab) {
|
|
5139
|
+
if (tab.isStreaming) {
|
|
5140
|
+
tab.abortPending = false;
|
|
5141
|
+
this.finalizeStreamingMessage(null, tab);
|
|
5142
|
+
}
|
|
5143
|
+
tab.sessionWarm = false;
|
|
5144
|
+
}
|
|
5145
|
+
|
|
5115
5146
|
/**
|
|
5116
5147
|
* Close the review-scope subscription and every tab's chat subscription.
|
|
5117
5148
|
*/
|
|
@@ -13,6 +13,11 @@ class PanelGroup {
|
|
|
13
13
|
static V_RATIO_KEY = 'panel-group-v-ratio';
|
|
14
14
|
static MIN_PANEL_HEIGHT = 150;
|
|
15
15
|
|
|
16
|
+
// Panels float instead of docking when docking would leave the diff narrower
|
|
17
|
+
// than this (always below the --right-panel-group-overlay-only breakpoint).
|
|
18
|
+
// Small enough that 1280px + navigator + both panels (~300px diff) stays docked.
|
|
19
|
+
static MIN_DOCKED_DIFF_WIDTH = 280;
|
|
20
|
+
|
|
16
21
|
// Tooltip text for each layout
|
|
17
22
|
static LAYOUT_LABELS = {
|
|
18
23
|
'h-review-chat': 'Review left, Chat right',
|
|
@@ -46,6 +51,10 @@ class PanelGroup {
|
|
|
46
51
|
// Read persisted layout
|
|
47
52
|
const savedLayout = localStorage.getItem(PanelGroup.STORAGE_KEY);
|
|
48
53
|
this._layout = PanelGroup.LAYOUTS.includes(savedLayout) ? savedLayout : PanelGroup.LAYOUTS[0];
|
|
54
|
+
// Layout actually applied: _layout, or its vertical twin while a too-narrow
|
|
55
|
+
// drawer stacks side-by-side panels (see _syncLayoutClass)
|
|
56
|
+
this._effectiveLayout = null;
|
|
57
|
+
this._sideBySideFits = true;
|
|
49
58
|
|
|
50
59
|
// Restore direction preferences from localStorage
|
|
51
60
|
const savedLastH = localStorage.getItem('panel-group-last-h');
|
|
@@ -128,6 +137,15 @@ class PanelGroup {
|
|
|
128
137
|
}
|
|
129
138
|
});
|
|
130
139
|
}
|
|
140
|
+
|
|
141
|
+
// Re-evaluate docking when the diff's room changes: viewport resizes and the
|
|
142
|
+
// docked navigator toggling or resizing (panel changes already call this).
|
|
143
|
+
const update = () => this._updateRightPanelGroupWidth();
|
|
144
|
+
window.addEventListener('resize', update);
|
|
145
|
+
const sidebar = document.getElementById('files-sidebar');
|
|
146
|
+
if (sidebar && typeof ResizeObserver !== 'undefined') {
|
|
147
|
+
new ResizeObserver(update).observe(sidebar);
|
|
148
|
+
}
|
|
131
149
|
}
|
|
132
150
|
|
|
133
151
|
/**
|
|
@@ -137,33 +155,48 @@ class PanelGroup {
|
|
|
137
155
|
_applyLayout(layout) {
|
|
138
156
|
if (!this.groupEl) return;
|
|
139
157
|
|
|
140
|
-
// Remove all layout classes
|
|
141
|
-
PanelGroup.LAYOUTS.forEach(l => {
|
|
142
|
-
this.groupEl.classList.remove(`layout-${l}`);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
// Add the current layout class
|
|
146
|
-
this.groupEl.classList.add(`layout-${layout}`);
|
|
147
158
|
this._layout = layout;
|
|
148
159
|
|
|
149
160
|
// Update direction preferences
|
|
150
161
|
if (layout.startsWith('h-')) {
|
|
151
162
|
this._lastHorizontalLayout = layout;
|
|
152
163
|
localStorage.setItem('panel-group-last-h', layout);
|
|
153
|
-
// Clear explicit heights when switching to horizontal so panels revert to flex defaults
|
|
154
|
-
this._clearVerticalHeights();
|
|
155
164
|
} else {
|
|
156
165
|
this._lastVerticalLayout = layout;
|
|
157
166
|
localStorage.setItem('panel-group-last-v', layout);
|
|
158
|
-
// Restore persisted vertical split ratio
|
|
159
|
-
this._restoreVerticalRatio();
|
|
160
167
|
}
|
|
161
168
|
|
|
162
|
-
//
|
|
163
|
-
|
|
169
|
+
// Recalculate group width, which applies the layout class (forced, so
|
|
170
|
+
// heights are cleared/restored as before) and updates the popover
|
|
171
|
+
this._effectiveLayout = null;
|
|
164
172
|
this._updateRightPanelGroupWidth();
|
|
165
173
|
}
|
|
166
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Apply the layout class: the chosen layout, or its vertical twin when `stack`.
|
|
177
|
+
*/
|
|
178
|
+
_syncLayoutClass(stack = false) {
|
|
179
|
+
if (!this.groupEl) return;
|
|
180
|
+
// Before the early return: a chosen v-* layout and a forced stack share a class
|
|
181
|
+
this.groupEl.classList.toggle('right-panel-group--forced-stack', stack);
|
|
182
|
+
const effective = stack ? this._layout.replace(/^h-/, 'v-') : this._layout;
|
|
183
|
+
if (effective === this._effectiveLayout) return;
|
|
184
|
+
|
|
185
|
+
PanelGroup.LAYOUTS.forEach(l => {
|
|
186
|
+
this.groupEl.classList.remove(`layout-${l}`);
|
|
187
|
+
});
|
|
188
|
+
this.groupEl.classList.add(`layout-${effective}`);
|
|
189
|
+
this._effectiveLayout = effective;
|
|
190
|
+
|
|
191
|
+
if (effective.startsWith('h-')) {
|
|
192
|
+
// Clear explicit heights when switching to horizontal so panels revert to flex defaults
|
|
193
|
+
this._clearVerticalHeights();
|
|
194
|
+
} else {
|
|
195
|
+
// Restore persisted vertical split ratio
|
|
196
|
+
this._restoreVerticalRatio();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
167
200
|
/**
|
|
168
201
|
* Render the popover DOM element and append to document.body
|
|
169
202
|
*/
|
|
@@ -288,12 +321,17 @@ class PanelGroup {
|
|
|
288
321
|
_updatePopoverActiveState() {
|
|
289
322
|
if (!this._popoverEl) return;
|
|
290
323
|
|
|
324
|
+
// Reflect what is shown: while the panels are forced to stack, mark the
|
|
325
|
+
// stacked layout and hide the side-by-side options (they can't apply)
|
|
326
|
+
const active = this._effectiveLayout || this._layout;
|
|
291
327
|
const thumbs = this._popoverEl.querySelectorAll('.layout-popover__thumb');
|
|
292
328
|
thumbs.forEach(thumb => {
|
|
293
329
|
thumb.classList.toggle(
|
|
294
330
|
'layout-popover__thumb--active',
|
|
295
|
-
thumb.dataset.layout ===
|
|
331
|
+
thumb.dataset.layout === active
|
|
296
332
|
);
|
|
333
|
+
const hidden = !this._sideBySideFits && thumb.dataset.layout.startsWith('h-');
|
|
334
|
+
thumb.style.display = hidden ? 'none' : '';
|
|
297
335
|
});
|
|
298
336
|
}
|
|
299
337
|
|
|
@@ -356,8 +394,11 @@ class PanelGroup {
|
|
|
356
394
|
const sidebar = document.getElementById('files-sidebar');
|
|
357
395
|
if (!sidebar) return;
|
|
358
396
|
|
|
359
|
-
|
|
360
|
-
|
|
397
|
+
// Go by what is actually on screen rather than the `collapsed` class: on
|
|
398
|
+
// slim screens CSS hides the docked sidebar (or shows it as an overlay
|
|
399
|
+
// drawer) independently of its persisted collapsed state.
|
|
400
|
+
const isShown = sidebar.offsetWidth > 0;
|
|
401
|
+
if (!isShown) {
|
|
361
402
|
// Click the expand button in the diff toolbar
|
|
362
403
|
const expandBtn = document.getElementById('sidebar-toggle-collapsed');
|
|
363
404
|
if (expandBtn) expandBtn.click();
|
|
@@ -507,7 +548,7 @@ class PanelGroup {
|
|
|
507
548
|
}
|
|
508
549
|
|
|
509
550
|
// Clear inline flex heights so the remaining panel fills the space
|
|
510
|
-
if (this._layout.startsWith('v-')) {
|
|
551
|
+
if ((this._effectiveLayout || this._layout).startsWith('v-')) {
|
|
511
552
|
this._clearVerticalHeights();
|
|
512
553
|
}
|
|
513
554
|
|
|
@@ -524,7 +565,7 @@ class PanelGroup {
|
|
|
524
565
|
this._reviewVisible = visible;
|
|
525
566
|
|
|
526
567
|
// Clear inline flex heights so the remaining panel fills the space
|
|
527
|
-
if (this._layout.startsWith('v-')) {
|
|
568
|
+
if ((this._effectiveLayout || this._layout).startsWith('v-')) {
|
|
528
569
|
this._clearVerticalHeights();
|
|
529
570
|
}
|
|
530
571
|
|
|
@@ -546,10 +587,50 @@ class PanelGroup {
|
|
|
546
587
|
this.groupEl.classList.toggle('review-only', this._reviewVisible && !this._chatVisible);
|
|
547
588
|
}
|
|
548
589
|
|
|
590
|
+
/**
|
|
591
|
+
* Whether the Review/Chat group should float over the diff instead of docking (pure).
|
|
592
|
+
*/
|
|
593
|
+
static shouldOverlay({ slimViewport, layoutWidth, dockedSidebarWidth, groupWidth }) {
|
|
594
|
+
if (slimViewport) return true;
|
|
595
|
+
// Nothing visible to dock, or no layout to measure (e.g. not rendered yet)
|
|
596
|
+
if (!(groupWidth > 0) || !(layoutWidth > 0)) return false;
|
|
597
|
+
const diffWidth = layoutWidth - (dockedSidebarWidth || 0) - groupWidth;
|
|
598
|
+
return diffWidth < PanelGroup.MIN_DOCKED_DIFF_WIDTH;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Whether side-by-side panels must stack because they'd shrink below their minimums (pure).
|
|
603
|
+
*/
|
|
604
|
+
static shouldStack({ availableWidth, aiWidth, chatWidth, aiMin, chatMin }) {
|
|
605
|
+
const total = aiWidth + chatWidth;
|
|
606
|
+
if (!(aiWidth > 0) || !(chatWidth > 0) || !(availableWidth > 0) || total <= availableWidth) return false;
|
|
607
|
+
// Both panels flex-shrink in proportion to their widths
|
|
608
|
+
const scale = availableWidth / total;
|
|
609
|
+
return aiWidth * scale < aiMin || chatWidth * scale < chatMin;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Toggle .right-panel-group--overlay for the given docked width; returns whether it floats.
|
|
614
|
+
*/
|
|
615
|
+
_updateOverlayMode(groupWidth, layoutWidth) {
|
|
616
|
+
if (!this.groupEl) return false;
|
|
617
|
+
const slimViewport = getComputedStyle(document.documentElement)
|
|
618
|
+
.getPropertyValue('--right-panel-group-overlay-only').trim() === '1';
|
|
619
|
+
const overlay = PanelGroup.shouldOverlay({
|
|
620
|
+
slimViewport,
|
|
621
|
+
layoutWidth,
|
|
622
|
+
dockedSidebarWidth: window.PanelResizer?.getDockedSidebarWidth?.() ?? 0,
|
|
623
|
+
groupWidth
|
|
624
|
+
});
|
|
625
|
+
this.groupEl.classList.toggle('right-panel-group--overlay', overlay);
|
|
626
|
+
return overlay;
|
|
627
|
+
}
|
|
628
|
+
|
|
549
629
|
/**
|
|
550
630
|
* Compute and set --right-panel-group-width based on current layout and panel visibility.
|
|
551
631
|
* In horizontal layouts, the group width is the SUM of visible panels.
|
|
552
632
|
* In vertical layouts, the group width is the MAX of visible panels.
|
|
633
|
+
* While the group floats over the diff it takes no space, so the variable is 0.
|
|
553
634
|
* This single variable is used by max-width calcs on .ai-suggestion and .user-comment.
|
|
554
635
|
*/
|
|
555
636
|
_updateRightPanelGroupWidth() {
|
|
@@ -565,7 +646,20 @@ class PanelGroup {
|
|
|
565
646
|
? Math.max(aiWidth, chatWidth)
|
|
566
647
|
: aiWidth + chatWidth;
|
|
567
648
|
|
|
568
|
-
|
|
649
|
+
const layoutWidth = this.groupEl?.parentElement?.clientWidth || 0;
|
|
650
|
+
const overlay = this._updateOverlayMode(groupWidth, layoutWidth);
|
|
651
|
+
// A drawer too narrow for side-by-side panels stacks them (user's layout
|
|
652
|
+
// untouched). Checked for vertical layouts too, for the popover's options.
|
|
653
|
+
this._sideBySideFits = !PanelGroup.shouldStack({
|
|
654
|
+
availableWidth: layoutWidth,
|
|
655
|
+
aiWidth,
|
|
656
|
+
chatWidth,
|
|
657
|
+
aiMin: window.PanelResizer?.getMinWidth?.('ai-panel') ?? 0,
|
|
658
|
+
chatMin: window.ChatPanel?.RESIZE_CONFIG?.min ?? 0
|
|
659
|
+
});
|
|
660
|
+
this._syncLayoutClass(overlay && !isVertical && !this._sideBySideFits);
|
|
661
|
+
this._updatePopoverActiveState();
|
|
662
|
+
document.documentElement.style.setProperty('--right-panel-group-width', `${overlay ? 0 : groupWidth}px`);
|
|
569
663
|
}
|
|
570
664
|
|
|
571
665
|
/**
|
|
@@ -685,7 +779,7 @@ class PanelGroup {
|
|
|
685
779
|
|
|
686
780
|
if (!aiPanel || !chatPanel) return { topPanel: null, bottomPanel: null };
|
|
687
781
|
|
|
688
|
-
if (this._layout === 'v-review-chat') {
|
|
782
|
+
if ((this._effectiveLayout || this._layout) === 'v-review-chat') {
|
|
689
783
|
return { topPanel: aiPanel, bottomPanel: chatPanel };
|
|
690
784
|
}
|
|
691
785
|
// v-chat-review
|
|
@@ -705,7 +799,7 @@ class PanelGroup {
|
|
|
705
799
|
|
|
706
800
|
// Defer to next frame so flex container has settled
|
|
707
801
|
requestAnimationFrame(() => {
|
|
708
|
-
if (!this.groupEl || !this._layout.startsWith('v-')) return;
|
|
802
|
+
if (!this.groupEl || !(this._effectiveLayout || this._layout).startsWith('v-')) return;
|
|
709
803
|
|
|
710
804
|
const groupHeight = this.groupEl.clientHeight;
|
|
711
805
|
const dividerHeight = this._dividerEl ? this._dividerEl.offsetHeight : 6;
|
|
@@ -141,9 +141,15 @@ class SuggestionNavigator {
|
|
|
141
141
|
* Update suggestions and rebuild the list
|
|
142
142
|
*/
|
|
143
143
|
updateSuggestions(suggestions) {
|
|
144
|
+
// Keep the selection on the same suggestion (by id) across refreshes,
|
|
145
|
+
// e.g. after adopting/dismissing or reloading; clear it only when the
|
|
146
|
+
// selected suggestion is gone.
|
|
147
|
+
const selectedId = this.suggestions[this.currentSuggestionIndex]?.id;
|
|
144
148
|
// Keep all suggestions visible (adopted and dismissed are de-emphasized but navigatable)
|
|
145
149
|
this.suggestions = suggestions;
|
|
146
|
-
this.currentSuggestionIndex =
|
|
150
|
+
this.currentSuggestionIndex = selectedId == null
|
|
151
|
+
? -1
|
|
152
|
+
: suggestions.findIndex(item => item.id === selectedId);
|
|
147
153
|
this.renderSuggestionsList();
|
|
148
154
|
this.updateCounter();
|
|
149
155
|
this.updateNavigationButtons();
|
|
@@ -182,7 +188,7 @@ class SuggestionNavigator {
|
|
|
182
188
|
const tooltip = locationInfo || 'Location unknown';
|
|
183
189
|
|
|
184
190
|
return `
|
|
185
|
-
<div class="suggestion-item ${statusClass}" data-index="${index}" data-id="${suggestion.id}" data-type="${suggestion.type}" data-status="${suggestion.status || 'active'}" title="${this.escapeHtml(tooltip)}">
|
|
191
|
+
<div class="suggestion-item ${statusClass}${index === this.currentSuggestionIndex ? ' current' : ''}" data-index="${index}" data-id="${suggestion.id}" data-type="${suggestion.type}" data-status="${suggestion.status || 'active'}" title="${this.escapeHtml(tooltip)}">
|
|
186
192
|
<div class="suggestion-type-icon">${typeIcon}</div>
|
|
187
193
|
<div class="suggestion-content">
|
|
188
194
|
<div class="suggestion-preview">${this.escapeHtml(preview)}</div>
|
|
@@ -401,6 +407,7 @@ class SuggestionNavigator {
|
|
|
401
407
|
scrollToSuggestion() {
|
|
402
408
|
if (this.currentSuggestionIndex >= 0) {
|
|
403
409
|
const currentSuggestion = this.suggestions[this.currentSuggestionIndex];
|
|
410
|
+
if (!currentSuggestion) return;
|
|
404
411
|
const suggestionEl = document.querySelector(`[data-suggestion-id="${currentSuggestion.id}"]`);
|
|
405
412
|
|
|
406
413
|
if (suggestionEl) {
|
|
@@ -422,6 +429,12 @@ class SuggestionNavigator {
|
|
|
422
429
|
} else {
|
|
423
430
|
scrollTarget.scrollIntoView(options);
|
|
424
431
|
}
|
|
432
|
+
} else if (!window.prManager?.suggestionManager?._isDisplayingSuggestions) {
|
|
433
|
+
// The finding has no card in the diff (file or line not shown).
|
|
434
|
+
// Say so instead of silently doing nothing. Not while suggestions
|
|
435
|
+
// are being redisplayed: every card is removed first and re-added
|
|
436
|
+
// when the display ends, so a miss then is not an error.
|
|
437
|
+
window.toast?.showError?.(currentSuggestion._displayError || 'Could not reveal this finding');
|
|
425
438
|
}
|
|
426
439
|
}
|
|
427
440
|
}
|
|
@@ -519,4 +532,4 @@ if (typeof window !== 'undefined') {
|
|
|
519
532
|
|
|
520
533
|
if (typeof module !== 'undefined' && module.exports) {
|
|
521
534
|
module.exports = SuggestionNavigator;
|
|
522
|
-
}
|
|
535
|
+
}
|
package/public/js/local.js
CHANGED
|
@@ -624,6 +624,10 @@ class LocalManager {
|
|
|
624
624
|
|
|
625
625
|
// Staleness is now checked in triggerAIAnalysis before showing config modal
|
|
626
626
|
|
|
627
|
+
// Clear existing AI suggestions from UI immediately when starting new
|
|
628
|
+
// analysis (same as PR mode's startAnalysis)
|
|
629
|
+
manager.clearFindingsForNewAnalysis();
|
|
630
|
+
|
|
627
631
|
// Determine endpoint and body based on whether this is a council analysis
|
|
628
632
|
let analyzeUrl, analyzeBody;
|
|
629
633
|
if (config.isCouncil) {
|
|
@@ -1539,18 +1543,9 @@ class LocalManager {
|
|
|
1539
1543
|
let totalDeletions = 0;
|
|
1540
1544
|
|
|
1541
1545
|
for (const [fileName, patch] of filePatchMap) {
|
|
1542
|
-
// Count
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
let deletions = 0;
|
|
1546
|
-
|
|
1547
|
-
for (const line of lines) {
|
|
1548
|
-
if (line.startsWith('+') && !line.startsWith('+++')) {
|
|
1549
|
-
additions++;
|
|
1550
|
-
} else if (line.startsWith('-') && !line.startsWith('---')) {
|
|
1551
|
-
deletions++;
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1546
|
+
// Count hunk-body lines only: a removed `-- x` / added `++ x` line
|
|
1547
|
+
// reads as `--- x` / `+++ x` and must still count.
|
|
1548
|
+
const { additions, deletions } = window.HunkParser.countPatchStats(patch);
|
|
1554
1549
|
|
|
1555
1550
|
const isGenerated = generatedFiles.has(fileName);
|
|
1556
1551
|
|
|
@@ -552,6 +552,10 @@ class DiffRenderer {
|
|
|
552
552
|
} else {
|
|
553
553
|
fileName.textContent = filePath;
|
|
554
554
|
}
|
|
555
|
+
DiffRenderer.applyFilePathTruncation(
|
|
556
|
+
fileName,
|
|
557
|
+
renamed && renamedFrom ? `${renamedFrom} \u2192 ${filePath}` : filePath
|
|
558
|
+
);
|
|
555
559
|
fileHeader.appendChild(fileName);
|
|
556
560
|
|
|
557
561
|
// File stats summary (visible in collapsed view)
|
|
@@ -593,6 +597,15 @@ class DiffRenderer {
|
|
|
593
597
|
return fileHeader;
|
|
594
598
|
}
|
|
595
599
|
|
|
600
|
+
/**
|
|
601
|
+
* Front-truncate a file path ("…/dir/file.js") with a full-path tooltip
|
|
602
|
+
* @param {HTMLElement} el - Element containing the path
|
|
603
|
+
* @param {string} fullText - Tooltip text
|
|
604
|
+
*/
|
|
605
|
+
static applyFilePathTruncation(el, fullText) {
|
|
606
|
+
window.SmartTruncate?.apply(el, { mode: 'start', fullText });
|
|
607
|
+
}
|
|
608
|
+
|
|
596
609
|
/**
|
|
597
610
|
* Update file header expand/collapse state
|
|
598
611
|
* @param {HTMLElement} header - The file header element
|
|
@@ -504,7 +504,7 @@ class FileCommentManager {
|
|
|
504
504
|
: `<span class="ai-suggestion-badge" data-type="${suggestion.type}" title="AI Suggestion"><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>`}
|
|
505
505
|
<span class="file-comment-badge" title="Comment applies to the entire file">File comment</span>
|
|
506
506
|
${categoryLabel ? `<span class="ai-suggestion-category">${this.escapeHtml(categoryLabel)}</span>` : ''}
|
|
507
|
-
<span class="ai-title">${this.escapeHtml(suggestion.title || '')}</span>
|
|
507
|
+
<span class="ai-title smart-truncate">${this.escapeHtml(suggestion.title || '')}</span>
|
|
508
508
|
</div>
|
|
509
509
|
<div class="ai-suggestion-header-right">
|
|
510
510
|
${showReasoningBtn ? `
|
|
@@ -518,7 +518,7 @@ class FileCommentManager {
|
|
|
518
518
|
${suggestion.type === 'praise'
|
|
519
519
|
? `<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>`
|
|
520
520
|
: `<span class="ai-suggestion-badge collapsed" data-type="${suggestion.type}" title="AI Suggestion"><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>`}
|
|
521
|
-
<span class="collapsed-title">${this.escapeHtml(suggestion.title || '')}</span>
|
|
521
|
+
<span class="collapsed-title smart-truncate">${this.escapeHtml(suggestion.title || '')}</span>
|
|
522
522
|
<div class="ai-suggestion-header-right">
|
|
523
523
|
${showReasoningBtn ? `
|
|
524
524
|
<button class="btn-reasoning-toggle collapsed-reasoning" title="View reasoning" data-suggestion-id="${suggestion.id}" data-reasoning="${reasoningDataAttr}" data-dismissal-reason="${dismissalReasonAttr}">
|
|
@@ -1170,9 +1170,16 @@ class FileCommentManager {
|
|
|
1170
1170
|
}
|
|
1171
1171
|
|
|
1172
1172
|
/**
|
|
1173
|
-
* Load and display file-level comments for all files
|
|
1174
|
-
*
|
|
1175
|
-
*
|
|
1173
|
+
* Load and display file-level comments for all files.
|
|
1174
|
+
*
|
|
1175
|
+
* Both arguments follow one rule: any array, including an empty one,
|
|
1176
|
+
* replaces that kind of card; null leaves it untouched. A user-comment
|
|
1177
|
+
* reload passes null suggestions, and an AI suggestion display passes null
|
|
1178
|
+
* comments, so neither wipes the other's cards.
|
|
1179
|
+
* @param {Array|null} comments - Replacement list of file-level user
|
|
1180
|
+
* comments, or null to leave the user comment cards alone
|
|
1181
|
+
* @param {Array|null} suggestions - Replacement list of file-level AI
|
|
1182
|
+
* suggestions, or null to leave the AI cards alone
|
|
1176
1183
|
*/
|
|
1177
1184
|
loadFileComments(comments, suggestions) {
|
|
1178
1185
|
// Group by rendered file comments zone so path variants still attach to the
|
|
@@ -1218,17 +1225,19 @@ class FileCommentManager {
|
|
|
1218
1225
|
// Selectively clear existing cards based on what we're about to reload
|
|
1219
1226
|
// This prevents user comments from being cleared when only reloading AI suggestions
|
|
1220
1227
|
if (container) {
|
|
1221
|
-
//
|
|
1222
|
-
//
|
|
1223
|
-
|
|
1228
|
+
// A supplied suggestions list replaces the previous AI cards, even
|
|
1229
|
+
// when it is empty (a new run or level with no file-level findings
|
|
1230
|
+
// must not leave the old cards behind). null leaves them alone.
|
|
1231
|
+
if (suggestions) {
|
|
1224
1232
|
const existingAISuggestions = container.querySelectorAll('.file-comment-card.ai-suggestion');
|
|
1225
1233
|
for (const card of existingAISuggestions) {
|
|
1226
1234
|
card.remove();
|
|
1227
1235
|
}
|
|
1228
1236
|
}
|
|
1229
1237
|
|
|
1230
|
-
//
|
|
1231
|
-
|
|
1238
|
+
// Same rule for user comments: a supplied list replaces them, even
|
|
1239
|
+
// when empty (the last file-level comment was deleted or dismissed).
|
|
1240
|
+
if (comments) {
|
|
1232
1241
|
const existingUserComments = container.querySelectorAll('.file-comment-card.user-comment');
|
|
1233
1242
|
for (const card of existingUserComments) {
|
|
1234
1243
|
card.remove();
|
|
@@ -201,8 +201,10 @@ class HunkParser {
|
|
|
201
201
|
if (!header) return null;
|
|
202
202
|
// Match: @@ followed by line info, then @@ and optional trailing context
|
|
203
203
|
// The [^@]+ between @@ markers ensures we stop at the closing @@, so even
|
|
204
|
-
// if the function name contains @ characters, they're captured correctly
|
|
205
|
-
|
|
204
|
+
// if the function name contains @ characters, they're captured correctly.
|
|
205
|
+
// The `s` flag keeps a lone `\r` inside the context line (git keeps it)
|
|
206
|
+
// from failing the match, mirroring the server's parseHunkHeader.
|
|
207
|
+
const match = header.match(/^@@[^@]+@@\s*(.*)$/s);
|
|
206
208
|
const context = match ? match[1].trim() : null;
|
|
207
209
|
return context || null; // Return null for empty strings too
|
|
208
210
|
}
|
|
@@ -389,6 +391,41 @@ class HunkParser {
|
|
|
389
391
|
return blocks;
|
|
390
392
|
}
|
|
391
393
|
|
|
394
|
+
/**
|
|
395
|
+
* Count added and deleted lines in a per-file patch.
|
|
396
|
+
*
|
|
397
|
+
* Counts only lines inside a hunk (a block from parseDiffIntoBlocks, within
|
|
398
|
+
* the line counts its `@@` header declares), so a prefix never decides
|
|
399
|
+
* header-vs-content: inside a hunk a deleted `-- x` line is `--- x` and an
|
|
400
|
+
* added `++ x` line is `+++ x`, and both count. Mirrors the server's
|
|
401
|
+
* `countPatchStats` (src/utils/diff-file-list.js); both suites share
|
|
402
|
+
* tests/utils/diff-stat-fixtures.js.
|
|
403
|
+
* @param {string} patch - Per-file patch text
|
|
404
|
+
* @returns {{additions: number, deletions: number}}
|
|
405
|
+
*/
|
|
406
|
+
static countPatchStats(patch) {
|
|
407
|
+
let additions = 0;
|
|
408
|
+
let deletions = 0;
|
|
409
|
+
for (const block of HunkParser.parseDiffIntoBlocks(patch || '')) {
|
|
410
|
+
const counts = block.header.match(/@@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? @@/) || [];
|
|
411
|
+
let oldRemaining = counts[1] === undefined ? 1 : parseInt(counts[1], 10);
|
|
412
|
+
let newRemaining = counts[2] === undefined ? 1 : parseInt(counts[2], 10);
|
|
413
|
+
for (const line of block.lines) {
|
|
414
|
+
if (line.startsWith('+') && newRemaining > 0) {
|
|
415
|
+
additions++;
|
|
416
|
+
newRemaining--;
|
|
417
|
+
} else if (line.startsWith('-') && oldRemaining > 0) {
|
|
418
|
+
deletions++;
|
|
419
|
+
oldRemaining--;
|
|
420
|
+
} else if (line.startsWith(' ')) {
|
|
421
|
+
oldRemaining--;
|
|
422
|
+
newRemaining--;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return { additions, deletions };
|
|
427
|
+
}
|
|
428
|
+
|
|
392
429
|
/**
|
|
393
430
|
* Remove trailing empty string artifact from a block's lines array.
|
|
394
431
|
* split('\n') on newline-terminated input produces a trailing '' that has no
|
|
@@ -50,6 +50,26 @@ window.PanelResizer = (function() {
|
|
|
50
50
|
return _panelGroupConfig;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
// Minimum diff width a right-hand panel drag must leave visible
|
|
54
|
+
const MIN_CONTENT_WIDTH = 100;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Width the docked file navigator takes. A real 0 (collapsed/slim) stays 0.
|
|
58
|
+
*/
|
|
59
|
+
function getDockedSidebarWidth() {
|
|
60
|
+
const parsed = parseInt(
|
|
61
|
+
getComputedStyle(document.documentElement).getPropertyValue(CONFIG.sidebar.cssVar), 10
|
|
62
|
+
);
|
|
63
|
+
return Number.isFinite(parsed) ? parsed : CONFIG.sidebar.default;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Max right-hand panel width: viewport minus docked sidebar minus MIN_CONTENT_WIDTH.
|
|
68
|
+
*/
|
|
69
|
+
function getDynamicPanelMax() {
|
|
70
|
+
return window.innerWidth - getDockedSidebarWidth() - MIN_CONTENT_WIDTH;
|
|
71
|
+
}
|
|
72
|
+
|
|
53
73
|
/**
|
|
54
74
|
* Compute the effective max width for a panel.
|
|
55
75
|
* For panels with a static max, returns that value.
|
|
@@ -59,8 +79,7 @@ window.PanelResizer = (function() {
|
|
|
59
79
|
const config = CONFIG[panelName];
|
|
60
80
|
if (!config) return Infinity;
|
|
61
81
|
if (config.max != null) return config.max;
|
|
62
|
-
|
|
63
|
-
return window.innerWidth - sidebarWidth - 100;
|
|
82
|
+
return getDynamicPanelMax();
|
|
64
83
|
}
|
|
65
84
|
|
|
66
85
|
/**
|
|
@@ -318,6 +337,16 @@ window.PanelResizer = (function() {
|
|
|
318
337
|
return config ? config.default : 0;
|
|
319
338
|
}
|
|
320
339
|
|
|
340
|
+
/**
|
|
341
|
+
* Get minimum width for a panel
|
|
342
|
+
* @param {string} panelName - 'sidebar' or 'ai-panel'
|
|
343
|
+
* @returns {number} Minimum width
|
|
344
|
+
*/
|
|
345
|
+
function getMinWidth(panelName) {
|
|
346
|
+
const config = CONFIG[panelName];
|
|
347
|
+
return config ? config.min : 0;
|
|
348
|
+
}
|
|
349
|
+
|
|
321
350
|
// Public API
|
|
322
351
|
return {
|
|
323
352
|
init,
|
|
@@ -325,6 +354,15 @@ window.PanelResizer = (function() {
|
|
|
325
354
|
setPanelWidth,
|
|
326
355
|
getSavedWidth,
|
|
327
356
|
getDefaultWidth,
|
|
328
|
-
|
|
357
|
+
getMinWidth,
|
|
358
|
+
applySavedWidths,
|
|
359
|
+
getDockedSidebarWidth,
|
|
360
|
+
getDynamicPanelMax,
|
|
361
|
+
getEffectiveMax
|
|
329
362
|
};
|
|
330
363
|
})();
|
|
364
|
+
|
|
365
|
+
// Export for CommonJS testing environments
|
|
366
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
367
|
+
module.exports = window.PanelResizer;
|
|
368
|
+
}
|