@in-the-loop-labs/pair-review 5.2.3 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- 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/references/level1-thorough.md +52 -121
- package/plugin-code-critic/skills/analyze/references/level2-thorough.md +49 -113
- package/plugin-code-critic/skills/analyze/references/level3-thorough.md +46 -195
- package/plugin-code-critic/skills/analyze/references/orchestration-thorough.md +56 -112
- package/plugin-pair-loop/.claude-plugin/plugin.json +1 -1
- package/public/css/analysis-config.css +29 -0
- package/public/css/pr.css +208 -0
- package/public/js/components/AIPanel.js +14 -9
- package/public/js/components/ChatPanel.js +790 -54
- package/public/js/components/ConfirmDialog.js +70 -2
- package/public/js/modules/pierre-bridge.js +58 -97
- package/public/js/modules/suggestion-manager.js +9 -121
- package/public/js/pr.js +15 -28
- package/public/js/utils/scroll-into-view.js +18 -4
- package/src/ai/analyzer.js +30 -5
- package/src/ai/antigravity-provider.js +7 -6
- package/src/ai/claude-provider.js +4 -8
- package/src/ai/codex-provider.js +3 -4
- package/src/ai/index.js +2 -0
- package/src/ai/muse-provider.js +3 -4
- package/src/ai/omp-provider.js +27 -12
- package/src/ai/pi-provider.js +12 -6
- package/src/ai/prompts/baseline/consolidation/thorough.js +56 -43
- package/src/ai/prompts/baseline/level1/thorough.js +76 -138
- package/src/ai/prompts/baseline/level2/thorough.js +76 -129
- package/src/ai/prompts/baseline/level3/thorough.js +67 -212
- package/src/ai/prompts/baseline/orchestration/thorough.js +79 -130
- package/src/ai/prompts/render-for-skill.js +5 -0
- package/src/ai/prompts/shared/adversarial-verification.js +68 -0
- package/src/ai/provider.js +60 -1
- package/src/ai/stream-parser.js +22 -1
- package/src/chat/acp-bridge.js +11 -0
- package/src/chat/chat-models.js +348 -0
- package/src/chat/chat-providers.js +17 -0
- package/src/chat/claude-code-bridge.js +9 -0
- package/src/chat/codex-bridge.js +6 -1
- package/src/chat/omp-bridge.js +5 -0
- package/src/chat/pi-bridge.js +20 -5
- package/src/chat/session-manager.js +158 -63
- package/src/hooks/payloads.js +5 -1
- package/src/routes/chat.js +83 -11
|
@@ -11,6 +11,14 @@ class ConfirmDialog {
|
|
|
11
11
|
this.onSecondary = null;
|
|
12
12
|
this.onCancel = null;
|
|
13
13
|
this.escapeHandler = null;
|
|
14
|
+
/**
|
|
15
|
+
* Opt-in checkbox input (see `options.checkboxLabel`). Null whenever the
|
|
16
|
+
* current dialog has no checkbox. Rebuilt on every show() and torn down on
|
|
17
|
+
* every hide() so one caller's checked state can never leak into the next
|
|
18
|
+
* dialog — the instance is a shared singleton.
|
|
19
|
+
* @type {HTMLInputElement|null}
|
|
20
|
+
*/
|
|
21
|
+
this.checkboxEl = null;
|
|
14
22
|
this.createModal();
|
|
15
23
|
this.setupEventListeners();
|
|
16
24
|
}
|
|
@@ -112,7 +120,10 @@ class ConfirmDialog {
|
|
|
112
120
|
* @param {string} options.confirmClass - Confirm button class (default: "btn-danger")
|
|
113
121
|
* @param {string} options.secondaryText - Secondary button text (optional - if provided, shows 3rd button)
|
|
114
122
|
* @param {string} options.secondaryClass - Secondary button class (default: "btn-secondary")
|
|
115
|
-
* @param {
|
|
123
|
+
* @param {string} options.checkboxLabel - When set, renders a checkbox between the message and
|
|
124
|
+
* the buttons (e.g. "Don't ask again"). Opt-in: omit it and no checkbox exists.
|
|
125
|
+
* @param {Function} options.onConfirm - Callback when confirmed. Receives
|
|
126
|
+
* `{ checkboxChecked: boolean }` (always false when no checkboxLabel was given).
|
|
116
127
|
* @param {Function} options.onSecondary - Callback when secondary clicked (optional)
|
|
117
128
|
* @param {Function} options.onCancel - Callback when cancelled (optional)
|
|
118
129
|
* @returns {Promise<string>} Promise that resolves to 'confirm', 'secondary', or 'cancel'
|
|
@@ -133,6 +144,13 @@ class ConfirmDialog {
|
|
|
133
144
|
messageElement.textContent = options.message || 'Are you sure?';
|
|
134
145
|
}
|
|
135
146
|
|
|
147
|
+
// Opt-in checkbox. Always torn down first so a previous caller's checked
|
|
148
|
+
// state can never leak into this dialog.
|
|
149
|
+
this._removeCheckbox();
|
|
150
|
+
if (options.checkboxLabel) {
|
|
151
|
+
this._renderCheckbox(options.checkboxLabel);
|
|
152
|
+
}
|
|
153
|
+
|
|
136
154
|
// Helper: set button label + optional description subtitle
|
|
137
155
|
const setBtnContent = (btn, label, description) => {
|
|
138
156
|
if (!btn) return;
|
|
@@ -179,8 +197,11 @@ class ConfirmDialog {
|
|
|
179
197
|
|
|
180
198
|
// Store callbacks with promise resolution
|
|
181
199
|
this.onConfirm = () => {
|
|
200
|
+
// Read the checkbox BEFORE hide() tears it down (handleConfirm calls
|
|
201
|
+
// this callback first, then hide()).
|
|
202
|
+
const checkboxChecked = !!this.checkboxEl?.checked;
|
|
182
203
|
if (options.onConfirm) {
|
|
183
|
-
options.onConfirm();
|
|
204
|
+
options.onConfirm({ checkboxChecked });
|
|
184
205
|
}
|
|
185
206
|
resolve('confirm');
|
|
186
207
|
};
|
|
@@ -205,6 +226,47 @@ class ConfirmDialog {
|
|
|
205
226
|
});
|
|
206
227
|
}
|
|
207
228
|
|
|
229
|
+
/**
|
|
230
|
+
* Render the opt-in checkbox row between the message and the buttons.
|
|
231
|
+
* @param {string} label - Visible label text (rendered via textContent)
|
|
232
|
+
*/
|
|
233
|
+
_renderCheckbox(label) {
|
|
234
|
+
if (!this.modal) return;
|
|
235
|
+
const body = this.modal.querySelector('.modal-body');
|
|
236
|
+
if (!body) return;
|
|
237
|
+
|
|
238
|
+
const wrapper = document.createElement('label');
|
|
239
|
+
wrapper.className = 'confirm-dialog__checkbox';
|
|
240
|
+
|
|
241
|
+
const input = document.createElement('input');
|
|
242
|
+
input.type = 'checkbox';
|
|
243
|
+
input.checked = false;
|
|
244
|
+
|
|
245
|
+
const text = document.createElement('span');
|
|
246
|
+
text.textContent = label;
|
|
247
|
+
|
|
248
|
+
wrapper.appendChild(input);
|
|
249
|
+
wrapper.appendChild(document.createTextNode(' '));
|
|
250
|
+
wrapper.appendChild(text);
|
|
251
|
+
body.appendChild(wrapper);
|
|
252
|
+
|
|
253
|
+
this.checkboxEl = input;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Remove the checkbox row (if any) and drop the cached input reference.
|
|
258
|
+
* Idempotent — safe to call when no checkbox is present.
|
|
259
|
+
*/
|
|
260
|
+
_removeCheckbox() {
|
|
261
|
+
if (this.checkboxEl) this.checkboxEl.checked = false;
|
|
262
|
+
this.checkboxEl = null;
|
|
263
|
+
if (!this.modal) return;
|
|
264
|
+
const existing = this.modal.querySelector('.confirm-dialog__checkbox');
|
|
265
|
+
if (existing && existing.parentNode) {
|
|
266
|
+
existing.parentNode.removeChild(existing);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
208
270
|
/**
|
|
209
271
|
* Handle confirm action
|
|
210
272
|
*/
|
|
@@ -246,6 +308,7 @@ class ConfirmDialog {
|
|
|
246
308
|
this.onConfirm = null;
|
|
247
309
|
this.onSecondary = null;
|
|
248
310
|
this.onCancel = null;
|
|
311
|
+
this._removeCheckbox();
|
|
249
312
|
}
|
|
250
313
|
}
|
|
251
314
|
|
|
@@ -259,3 +322,8 @@ if (typeof window !== 'undefined' && !window.confirmDialog) {
|
|
|
259
322
|
window.confirmDialog = new ConfirmDialog();
|
|
260
323
|
}
|
|
261
324
|
}
|
|
325
|
+
|
|
326
|
+
// Export for CommonJS testing environments
|
|
327
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
328
|
+
module.exports = { ConfirmDialog };
|
|
329
|
+
}
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* Depends on: window.PierreDiffs (from vendor bundle)
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
const COLLAPSED_CONTEXT_THRESHOLD = 5;
|
|
12
|
+
|
|
11
13
|
class PierreBridge {
|
|
12
14
|
/**
|
|
13
15
|
* @param {Object} options
|
|
@@ -558,7 +560,7 @@ class PierreBridge {
|
|
|
558
560
|
unsafeCSS: this.getUnsafeCSS(),
|
|
559
561
|
hunkSeparators: 'line-info',
|
|
560
562
|
expansionLineCount: 20,
|
|
561
|
-
collapsedContextThreshold:
|
|
563
|
+
collapsedContextThreshold: COLLAPSED_CONTEXT_THRESHOLD,
|
|
562
564
|
collapsed: renderOptions.collapsed || false,
|
|
563
565
|
|
|
564
566
|
// Custom gutter render — dual buttons (chat + comment) matching legacy UI.
|
|
@@ -931,7 +933,7 @@ class PierreBridge {
|
|
|
931
933
|
// full-contents re-diff can produce narrower context than the patch;
|
|
932
934
|
// these spans are merged into every render so the upgrade never
|
|
933
935
|
// un-renders visible lines (which would orphan annotations anchored to
|
|
934
|
-
// them).
|
|
936
|
+
// them). Keep these original spans alongside dynamic context ranges.
|
|
935
937
|
patchParityRanges: null,
|
|
936
938
|
forcePlainText: !!renderOptions.forcePlainText,
|
|
937
939
|
collapsed: !!renderOptions.collapsed,
|
|
@@ -1080,9 +1082,14 @@ class PierreBridge {
|
|
|
1080
1082
|
return false;
|
|
1081
1083
|
}
|
|
1082
1084
|
|
|
1085
|
+
// Context merging changes hunk indices, so _renderWithFileDiff clears the
|
|
1086
|
+
// vendor's per-hunk expansion state. Preserve manually revealed lines as
|
|
1087
|
+
// context ranges first; comments may already be anchored to those lines.
|
|
1088
|
+
const expandedRanges = this._getExpandedContextRanges(fileState);
|
|
1089
|
+
|
|
1083
1090
|
// Merge with existing context ranges (deduplicate)
|
|
1084
1091
|
const existing = fileState.contextRanges || [];
|
|
1085
|
-
fileState.contextRanges = mergeOverlapping([...existing, ...ranges]);
|
|
1092
|
+
fileState.contextRanges = mergeOverlapping([...existing, ...expandedRanges, ...ranges]);
|
|
1086
1093
|
|
|
1087
1094
|
// If file contents aren't loaded yet, ranges will be applied in upgradeFileContents
|
|
1088
1095
|
if (!fileState.baseMetadata) return false;
|
|
@@ -1139,48 +1146,6 @@ class PierreBridge {
|
|
|
1139
1146
|
return this._renderWithFileDiff(fileState, merged);
|
|
1140
1147
|
}
|
|
1141
1148
|
|
|
1142
|
-
/**
|
|
1143
|
-
* Remove specific context ranges from a file.
|
|
1144
|
-
* @param {string} fileName
|
|
1145
|
-
* @param {Array<{startLine: number, endLine: number}>} ranges
|
|
1146
|
-
* @returns {boolean} true if re-render occurred
|
|
1147
|
-
*/
|
|
1148
|
-
removeContextRanges(fileName, ranges) {
|
|
1149
|
-
const fileState = this.files.get(fileName);
|
|
1150
|
-
if (!fileState) return false;
|
|
1151
|
-
|
|
1152
|
-
const { subtractRanges } = window.PierreContext || {};
|
|
1153
|
-
if (!subtractRanges) return false;
|
|
1154
|
-
|
|
1155
|
-
fileState.contextRanges = subtractRanges(fileState.contextRanges || [], ranges);
|
|
1156
|
-
|
|
1157
|
-
if (!fileState.baseMetadata) return false;
|
|
1158
|
-
if (this._effectiveContextRanges(fileState).length === 0) {
|
|
1159
|
-
return this._renderWithFileDiff(fileState, fileState.baseMetadata);
|
|
1160
|
-
}
|
|
1161
|
-
return this._applyContextRanges(fileName);
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
/**
|
|
1165
|
-
* Remove all context ranges for a file, restoring original diff view.
|
|
1166
|
-
* @param {string} fileName
|
|
1167
|
-
* @returns {boolean} true if re-render occurred
|
|
1168
|
-
*/
|
|
1169
|
-
clearContextRanges(fileName) {
|
|
1170
|
-
const fileState = this.files.get(fileName);
|
|
1171
|
-
if (!fileState) return false;
|
|
1172
|
-
|
|
1173
|
-
fileState.contextRanges = [];
|
|
1174
|
-
|
|
1175
|
-
if (!fileState.baseMetadata) return false;
|
|
1176
|
-
// Patch-parity spans are not "context ranges" — clearing must never
|
|
1177
|
-
// shrink the view below what the original patch rendered.
|
|
1178
|
-
if (this._effectiveContextRanges(fileState).length) {
|
|
1179
|
-
return this._applyContextRanges(fileName);
|
|
1180
|
-
}
|
|
1181
|
-
return this._renderWithFileDiff(fileState, fileState.baseMetadata);
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
1149
|
/**
|
|
1185
1150
|
* Convert OLD-file (deletion-side) line numbers to NEW-file coordinates.
|
|
1186
1151
|
* Delegates to PierreContext using the file's baseMetadata for offset computation.
|
|
@@ -1688,6 +1653,48 @@ class PierreBridge {
|
|
|
1688
1653
|
|
|
1689
1654
|
// ─── Gap Expansion ────────────────────────────────────────────────
|
|
1690
1655
|
|
|
1656
|
+
/**
|
|
1657
|
+
* Read the vendor's manual expansions in file coordinates. Expansion index
|
|
1658
|
+
* i describes the gap BEFORE hunk i: fromStart reveals the beginning of that
|
|
1659
|
+
* gap, fromEnd its end. Index hunks.length describes the trailing EOF gap.
|
|
1660
|
+
* These are not padding counts around the hunk itself.
|
|
1661
|
+
*/
|
|
1662
|
+
_getExpandedContextRanges(fileState, side = 'RIGHT') {
|
|
1663
|
+
const instance = fileState?.instance;
|
|
1664
|
+
const metadata = instance?.fileDiff;
|
|
1665
|
+
if (!metadata || metadata.isPartial) return [];
|
|
1666
|
+
const hunks = metadata.hunks || [];
|
|
1667
|
+
const sideKey = PierreBridge.toPierreSide(side) === 'deletions' ? 'deletion' : 'addition';
|
|
1668
|
+
const ranges = [];
|
|
1669
|
+
for (let i = 0; i <= hunks.length; i++) {
|
|
1670
|
+
const hunk = hunks[i];
|
|
1671
|
+
const last = hunks[hunks.length - 1];
|
|
1672
|
+
if (!hunk && !last) continue;
|
|
1673
|
+
const start = hunk
|
|
1674
|
+
? hunk[`${sideKey}Start`] - hunk.collapsedBefore
|
|
1675
|
+
: last[`${sideKey}Start`] + last[`${sideKey}Count`];
|
|
1676
|
+
const end = hunk
|
|
1677
|
+
? hunk[`${sideKey}Start`] - 1
|
|
1678
|
+
: (metadata[`${sideKey}Lines`]?.length || 0);
|
|
1679
|
+
const gapSize = end - start + 1;
|
|
1680
|
+
if (gapSize <= 0) continue;
|
|
1681
|
+
// The vendor paints small gaps in full without an expandedHunks entry.
|
|
1682
|
+
if (gapSize <= COLLAPSED_CONTEXT_THRESHOLD) {
|
|
1683
|
+
ranges.push({ startLine: start, endLine: end });
|
|
1684
|
+
continue;
|
|
1685
|
+
}
|
|
1686
|
+
const expanded = instance.hunksRenderer?.getExpandedHunk?.(i);
|
|
1687
|
+
if (!expanded) continue;
|
|
1688
|
+
if (expanded.fromStart > 0) {
|
|
1689
|
+
ranges.push({ startLine: start, endLine: Math.min(end, start + expanded.fromStart - 1) });
|
|
1690
|
+
}
|
|
1691
|
+
if (hunk && expanded.fromEnd > 0) {
|
|
1692
|
+
ranges.push({ startLine: Math.max(start, end - expanded.fromEnd + 1), endLine: end });
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
return ranges;
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1691
1698
|
/**
|
|
1692
1699
|
* Expand a hunk in a file's diff.
|
|
1693
1700
|
* @param {string} fileName
|
|
@@ -1720,24 +1727,21 @@ class PierreBridge {
|
|
|
1720
1727
|
// Decide from the instance's CURRENT logical state, never the DOM.
|
|
1721
1728
|
// render()/rerender() paint asynchronously (worker highlighting), so the
|
|
1722
1729
|
// shadow DOM lags behind the latest render call — a DOM query here returns
|
|
1723
|
-
// stale answers
|
|
1724
|
-
//
|
|
1730
|
+
// stale answers while a newly revealed line is awaiting paint.
|
|
1731
|
+
// instance.fileDiff is assigned
|
|
1725
1732
|
// synchronously inside render(), so hunk membership reflects the state the
|
|
1726
1733
|
// in-flight paint will converge to. A line is rendered iff it falls inside
|
|
1727
|
-
// a hunk of the current
|
|
1728
|
-
// user gap expansion tracked per hunk in hunksRenderer.expandedHunks.
|
|
1734
|
+
// a hunk of the current metadata or a manually expanded gap.
|
|
1729
1735
|
const sideKey = PierreBridge.toPierreSide(side) === 'deletions' ? 'deletion' : 'addition';
|
|
1730
1736
|
for (let i = 0; i < hunks.length; i++) {
|
|
1731
1737
|
const hunk = hunks[i];
|
|
1732
1738
|
const count = hunk[`${sideKey}Count`];
|
|
1733
1739
|
if (!count) continue;
|
|
1734
1740
|
const start = hunk[`${sideKey}Start`];
|
|
1735
|
-
|
|
1736
|
-
const from = start - (expanded?.fromStart || 0);
|
|
1737
|
-
const to = start + count - 1 + (expanded?.fromEnd || 0);
|
|
1738
|
-
if (lineNumber >= from && lineNumber <= to) return true;
|
|
1741
|
+
if (lineNumber >= start && lineNumber < start + count) return true;
|
|
1739
1742
|
}
|
|
1740
|
-
return
|
|
1743
|
+
return this._getExpandedContextRanges(fileState, side)
|
|
1744
|
+
.some(range => lineNumber >= range.startLine && lineNumber <= range.endLine);
|
|
1741
1745
|
}
|
|
1742
1746
|
|
|
1743
1747
|
/**
|
|
@@ -1798,49 +1802,6 @@ class PierreBridge {
|
|
|
1798
1802
|
return [pre];
|
|
1799
1803
|
}
|
|
1800
1804
|
|
|
1801
|
-
/**
|
|
1802
|
-
* Expand collapsed gaps so that the given line becomes visible.
|
|
1803
|
-
* Iterates over hunks to find which gap the line falls in, then
|
|
1804
|
-
* expands that hunk upward/downward by enough lines to reveal it.
|
|
1805
|
-
* @param {string} fileName
|
|
1806
|
-
* @param {number} lineNumber
|
|
1807
|
-
* @param {string} side - 'LEFT'/'RIGHT'
|
|
1808
|
-
*/
|
|
1809
|
-
expandToLine(fileName, lineNumber, side = 'RIGHT') {
|
|
1810
|
-
const fileState = this.files.get(fileName);
|
|
1811
|
-
if (!fileState || !fileState.instance) return;
|
|
1812
|
-
const instance = fileState.instance;
|
|
1813
|
-
if (!instance.fileDiff || !instance.fileDiff.hunks) return;
|
|
1814
|
-
|
|
1815
|
-
const hunks = instance.fileDiff.hunks;
|
|
1816
|
-
const sideKey = PierreBridge.toPierreSide(side) === 'deletions' ? 'deletion' : 'addition';
|
|
1817
|
-
|
|
1818
|
-
for (let i = 0; i < hunks.length; i++) {
|
|
1819
|
-
const hunk = hunks[i];
|
|
1820
|
-
const hunkStart = hunk[`${sideKey}Start`];
|
|
1821
|
-
const hunkEnd = hunkStart + hunk[`${sideKey}Count`] - 1;
|
|
1822
|
-
|
|
1823
|
-
// Target line is before this hunk — it's in the collapsed gap above
|
|
1824
|
-
if (lineNumber < hunkStart) {
|
|
1825
|
-
instance.expandHunk(i, 'up', hunk.collapsedBefore);
|
|
1826
|
-
instance.rerender();
|
|
1827
|
-
return;
|
|
1828
|
-
}
|
|
1829
|
-
|
|
1830
|
-
// Target line is within this hunk — already visible (or should be)
|
|
1831
|
-
if (lineNumber <= hunkEnd) {
|
|
1832
|
-
return;
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1835
|
-
// If this is the last hunk and the line is after it — expand down
|
|
1836
|
-
if (i === hunks.length - 1 && lineNumber > hunkEnd) {
|
|
1837
|
-
instance.expandHunk(i, 'down', lineNumber - hunkEnd);
|
|
1838
|
-
instance.rerender();
|
|
1839
|
-
return;
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
|
-
}
|
|
1843
|
-
|
|
1844
1805
|
// ─── Shadow DOM Access ────────────────────────────────────────────
|
|
1845
1806
|
|
|
1846
1807
|
/**
|
|
@@ -192,69 +192,6 @@ class SuggestionManager {
|
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
/**
|
|
196
|
-
* Find suggestions that target lines currently hidden in gaps
|
|
197
|
-
* @param {Array} suggestions - Array of suggestions
|
|
198
|
-
* @returns {Array} Suggestions targeting hidden lines
|
|
199
|
-
*/
|
|
200
|
-
findHiddenSuggestions(suggestions) {
|
|
201
|
-
const hiddenItems = [];
|
|
202
|
-
|
|
203
|
-
for (const suggestion of suggestions) {
|
|
204
|
-
const file = suggestion.file;
|
|
205
|
-
const line = suggestion.line_start;
|
|
206
|
-
const lineEnd = suggestion.line_end || line;
|
|
207
|
-
// Get side from suggestion, default to 'RIGHT' for backwards compatibility
|
|
208
|
-
const side = suggestion.side || 'RIGHT';
|
|
209
|
-
|
|
210
|
-
// For PierreBridge files, check if the line is actually visible in the rendered DOM
|
|
211
|
-
if (this.prManager.pierreBridge?.files.has(file)) {
|
|
212
|
-
if (!this.prManager.pierreBridge.isLineVisible(file, line, side)) {
|
|
213
|
-
hiddenItems.push({ file, line, lineEnd, side });
|
|
214
|
-
}
|
|
215
|
-
continue;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Find the file wrapper
|
|
219
|
-
const fileElement = this.findFileElement(file);
|
|
220
|
-
|
|
221
|
-
if (!fileElement) {
|
|
222
|
-
// File not in diff at all, not a hidden line issue
|
|
223
|
-
continue;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// Check if any line in the range is visible (with matching side)
|
|
227
|
-
let anyLineVisible = false;
|
|
228
|
-
const lineTracker = this.prManager?.lineTracker || (window.LineTracker ? new window.LineTracker() : null);
|
|
229
|
-
|
|
230
|
-
for (let checkLine = line; checkLine <= lineEnd; checkLine++) {
|
|
231
|
-
const lineRows = fileElement.querySelectorAll('tr');
|
|
232
|
-
for (const row of lineRows) {
|
|
233
|
-
// Pass side to getLineNumber() to get the correct coordinate system
|
|
234
|
-
// For LEFT side: returns old line number (deleted lines or context lines in OLD coords)
|
|
235
|
-
// For RIGHT side: returns new line number (added lines or context lines in NEW coords)
|
|
236
|
-
// Context lines have BOTH coordinates, so they can match either side when queried appropriately
|
|
237
|
-
const lineNum = lineTracker ? lineTracker.getLineNumber(row, side) : null;
|
|
238
|
-
// Match the line number returned for the requested side
|
|
239
|
-
// Note: We no longer need to check rowSide separately because getLineNumber(row, side)
|
|
240
|
-
// already returns the appropriate line number for the requested coordinate system
|
|
241
|
-
if (lineNum === checkLine) {
|
|
242
|
-
anyLineVisible = true;
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
if (anyLineVisible) break;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if (!anyLineVisible) {
|
|
250
|
-
console.log(`[findHiddenSuggestions] Hidden: ${file}:${line}-${lineEnd} (${side})`);
|
|
251
|
-
hiddenItems.push({ file, line, lineEnd, side });
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return hiddenItems;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
195
|
/**
|
|
259
196
|
* Normalize the `is_file_level` flag to a boolean.
|
|
260
197
|
* This field arrives in two shapes across the codebase: boolean `true` from
|
|
@@ -294,21 +231,18 @@ class SuggestionManager {
|
|
|
294
231
|
// Only inline (line-targeted) suggestions need the diff body rendered
|
|
295
232
|
// ahead of time. File-level findings (is_file_level === 1 or no
|
|
296
233
|
// line_start) are handed to FileCommentManager and rendered above the
|
|
297
|
-
// diff — they never
|
|
298
|
-
//
|
|
234
|
+
// diff — they never need inline code rows, so forcing their bodies to
|
|
235
|
+
// render would recreate the eager-render cost
|
|
299
236
|
// the lazy-body change removed (reviews dominated by file-level analyses
|
|
300
237
|
// are a common repository-wide pattern). Filter once and reuse below.
|
|
301
238
|
const inlineSuggestions = suggestions.filter(
|
|
302
239
|
s => s.file && s.line_start != null && s.is_file_level !== 1
|
|
303
240
|
);
|
|
304
241
|
|
|
305
|
-
// Render the lazy body of every file an INLINE suggestion targets
|
|
306
|
-
//
|
|
307
|
-
// without this findHiddenSuggestions() would flag every line as "hidden"
|
|
308
|
-
// and we'd gap-expand against bodies that aren't even built yet.
|
|
242
|
+
// Render the lazy body of every file an INLINE suggestion targets before
|
|
243
|
+
// anchoring cards. An unrendered file has no code rows for insertion.
|
|
309
244
|
// ensureFileBodyRendered is a cheap no-op for files already rendered or
|
|
310
|
-
// not in the diff.
|
|
311
|
-
// this only affects legacy-rendered files.
|
|
245
|
+
// not in the diff. Both rendering engines can have lazy file bodies.
|
|
312
246
|
if (this.prManager?.ensureFileBodyRendered) {
|
|
313
247
|
const targetFiles = new Set(inlineSuggestions.map(s => s.file));
|
|
314
248
|
for (const file of targetFiles) {
|
|
@@ -316,11 +250,12 @@ class SuggestionManager {
|
|
|
316
250
|
}
|
|
317
251
|
}
|
|
318
252
|
|
|
319
|
-
//
|
|
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.
|
|
320
256
|
if (this.prManager.pierreBridge) {
|
|
321
257
|
for (const [fileName] of this.prManager.pierreBridge.files) {
|
|
322
258
|
this.prManager.pierreBridge.removeAnnotationsByType(fileName, 'suggestion');
|
|
323
|
-
this.prManager.pierreBridge.clearContextRanges(fileName);
|
|
324
259
|
}
|
|
325
260
|
}
|
|
326
261
|
|
|
@@ -335,6 +270,7 @@ class SuggestionManager {
|
|
|
335
270
|
line_start: suggestion.line_start || suggestion.line_end,
|
|
336
271
|
line_end: suggestion.line_end || suggestion.line_start,
|
|
337
272
|
side: suggestion.side || 'RIGHT',
|
|
273
|
+
contextPadding: 3,
|
|
338
274
|
}));
|
|
339
275
|
if (lineTargets.length > 0 && this.prManager?.ensureLinesVisible) {
|
|
340
276
|
await this.prManager.ensureLinesVisible(lineTargets);
|
|
@@ -385,54 +321,6 @@ class SuggestionManager {
|
|
|
385
321
|
}
|
|
386
322
|
}
|
|
387
323
|
|
|
388
|
-
// Auto-expand hidden lines for suggestions that target non-visible lines
|
|
389
|
-
// Pass the side parameter so expandForSuggestion knows which coordinate system to use:
|
|
390
|
-
// - RIGHT side = NEW coordinates (modified file, most common for AI suggestions)
|
|
391
|
-
// - LEFT side = OLD coordinates (deleted lines from original file)
|
|
392
|
-
const hiddenSuggestions = this.findHiddenSuggestions(inlineSuggestions);
|
|
393
|
-
if (hiddenSuggestions.length > 0) {
|
|
394
|
-
console.log(`[UI] Found ${hiddenSuggestions.length} suggestions targeting hidden lines, expanding...`);
|
|
395
|
-
|
|
396
|
-
// Batch Pierre-bridge files: collect all ranges per file, one addContextRanges call each
|
|
397
|
-
const pierreRanges = new Map();
|
|
398
|
-
const legacyItems = [];
|
|
399
|
-
|
|
400
|
-
for (const hidden of hiddenSuggestions) {
|
|
401
|
-
if (this.prManager?.pierreBridge?.files.has(hidden.file)) {
|
|
402
|
-
if (!pierreRanges.has(hidden.file)) pierreRanges.set(hidden.file, []);
|
|
403
|
-
const padding = 3;
|
|
404
|
-
let rangeStart = hidden.line;
|
|
405
|
-
let rangeEnd = hidden.lineEnd || hidden.line;
|
|
406
|
-
// addContextRanges expects NEW-file coordinates; LEFT-side items carry OLD numbers.
|
|
407
|
-
if (hidden.side === 'LEFT') {
|
|
408
|
-
const converted = this.prManager.pierreBridge.convertOldToNew(hidden.file, rangeStart, rangeEnd);
|
|
409
|
-
if (!converted) continue;
|
|
410
|
-
rangeStart = converted.startLine;
|
|
411
|
-
rangeEnd = converted.endLine;
|
|
412
|
-
}
|
|
413
|
-
pierreRanges.get(hidden.file).push({
|
|
414
|
-
startLine: Math.max(1, rangeStart - padding),
|
|
415
|
-
endLine: rangeEnd + padding,
|
|
416
|
-
});
|
|
417
|
-
} else {
|
|
418
|
-
legacyItems.push(hidden);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// One render per Pierre file instead of N
|
|
423
|
-
for (const [file, ranges] of pierreRanges) {
|
|
424
|
-
this.prManager.pierreBridge.addContextRanges(file, ranges);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
// Legacy files: expand individually
|
|
428
|
-
for (const hidden of legacyItems) {
|
|
429
|
-
if (this.prManager?.expandForSuggestion) {
|
|
430
|
-
await this.prManager.expandForSuggestion(hidden.file, hidden.line, hidden.lineEnd, hidden.side);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
console.log(`[UI] Finished expanding hidden lines`);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
324
|
// Create suggestion navigator if not already created
|
|
437
325
|
if (!this.prManager?.suggestionNavigator && window.SuggestionNavigator) {
|
|
438
326
|
console.log('[UI] Creating SuggestionNavigator instance');
|
package/public/js/pr.js
CHANGED
|
@@ -5900,7 +5900,7 @@ class PRManager {
|
|
|
5900
5900
|
* Ensure that the given line ranges are visible in the diff view.
|
|
5901
5901
|
* For each item, checks if the target line rows exist in the DOM; if not,
|
|
5902
5902
|
* calls expandForSuggestion() to expand the gap containing those lines.
|
|
5903
|
-
* @param {Array<{file: string, line_start: number, line_end: number, side: string}>} items
|
|
5903
|
+
* @param {Array<{file: string, line_start: number, line_end: number, side: string, contextPadding?: number}>} items
|
|
5904
5904
|
*/
|
|
5905
5905
|
async ensureLinesVisible(items) {
|
|
5906
5906
|
for (const item of items) {
|
|
@@ -5945,9 +5945,12 @@ class PRManager {
|
|
|
5945
5945
|
}
|
|
5946
5946
|
}
|
|
5947
5947
|
|
|
5948
|
+
// Pad after converting to NEW coordinates. Padding the requested
|
|
5949
|
+
// endpoints can cross edits on LEFT or put a target beyond EOF.
|
|
5950
|
+
const padding = item.contextPadding || 0;
|
|
5948
5951
|
this.pierreBridge.addContextRanges(file, [{
|
|
5949
|
-
startLine: rangeStart,
|
|
5950
|
-
endLine: rangeEnd,
|
|
5952
|
+
startLine: Math.max(1, rangeStart - padding),
|
|
5953
|
+
endLine: rangeEnd + padding,
|
|
5951
5954
|
}]);
|
|
5952
5955
|
}
|
|
5953
5956
|
continue;
|
|
@@ -5956,28 +5959,16 @@ class PRManager {
|
|
|
5956
5959
|
const fileElement = this.findFileElement(file);
|
|
5957
5960
|
if (!fileElement) continue;
|
|
5958
5961
|
|
|
5959
|
-
//
|
|
5960
|
-
//
|
|
5961
|
-
//
|
|
5962
|
-
//
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
for (let checkLine = line_start; checkLine <= (line_end || line_start); checkLine++) {
|
|
5969
|
-
for (const row of lineRows) {
|
|
5970
|
-
const lineNum = this.getLineNumber(row, resolvedSide);
|
|
5971
|
-
if (lineNum === checkLine) {
|
|
5972
|
-
anyLineVisible = true;
|
|
5973
|
-
break;
|
|
5974
|
-
}
|
|
5962
|
+
// Cards anchor at line_start except Pierre suggestions, which use
|
|
5963
|
+
// line_end. Reveal both endpoints so either card has a row, even when
|
|
5964
|
+
// only a middle line is visible. Endpoints may occupy different gaps;
|
|
5965
|
+
// re-query after expansion because it replaces rows.
|
|
5966
|
+
for (const line of new Set([line_start, line_end || line_start])) {
|
|
5967
|
+
const visible = Array.from(fileElement.querySelectorAll('tr'))
|
|
5968
|
+
.some(row => this.getLineNumber(row, resolvedSide) === line);
|
|
5969
|
+
if (!visible) {
|
|
5970
|
+
await this.expandForSuggestion(file, line, line_end || line_start, resolvedSide);
|
|
5975
5971
|
}
|
|
5976
|
-
if (anyLineVisible) break;
|
|
5977
|
-
}
|
|
5978
|
-
|
|
5979
|
-
if (!anyLineVisible) {
|
|
5980
|
-
await this.expandForSuggestion(file, line_start, line_end || line_start, resolvedSide);
|
|
5981
5972
|
}
|
|
5982
5973
|
}
|
|
5983
5974
|
}
|
|
@@ -6732,10 +6723,6 @@ class PRManager {
|
|
|
6732
6723
|
/**
|
|
6733
6724
|
* AI Suggestion methods - delegate to SuggestionManager
|
|
6734
6725
|
*/
|
|
6735
|
-
findHiddenSuggestions(suggestions) {
|
|
6736
|
-
return this.suggestionManager.findHiddenSuggestions(suggestions);
|
|
6737
|
-
}
|
|
6738
|
-
|
|
6739
6726
|
async displayAISuggestions(suggestions) {
|
|
6740
6727
|
await this.suggestionManager.displayAISuggestions(suggestions);
|
|
6741
6728
|
// Refresh minimize-mode indicators (no-op when minimize mode is off)
|
|
@@ -49,8 +49,8 @@ const SCROLL_KEYS = new Set([
|
|
|
49
49
|
let activeGeneration = 0;
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
* Wait until `target`
|
|
53
|
-
*
|
|
52
|
+
* Wait until `target` has a rendered box whose viewport-relative top stays
|
|
53
|
+
* unchanged for SETTLE_FRAMES frames (or SETTLE_TIMEOUT_MS passes).
|
|
54
54
|
* Resolves early when the target is disconnected or `isCancelled()` trips.
|
|
55
55
|
* @param {Element} target
|
|
56
56
|
* @param {() => boolean} isCancelled
|
|
@@ -66,7 +66,17 @@ function waitForStablePosition(target, isCancelled) {
|
|
|
66
66
|
resolve();
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
-
const
|
|
69
|
+
const rect = target.getBoundingClientRect();
|
|
70
|
+
// Pierre can attach an annotation before its worker paints the slot.
|
|
71
|
+
// An unchanged zero-sized box is not a settled scroll target. Restart
|
|
72
|
+
// settling if an intervening render temporarily removes the box too.
|
|
73
|
+
if (rect.width === 0 && rect.height === 0) {
|
|
74
|
+
lastTop = null;
|
|
75
|
+
stableFrames = 0;
|
|
76
|
+
requestAnimationFrame(tick);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const top = rect.top;
|
|
70
80
|
if (lastTop !== null && Math.abs(top - lastTop) <= STABLE_PX) {
|
|
71
81
|
stableFrames += 1;
|
|
72
82
|
if (stableFrames >= SETTLE_FRAMES) {
|
|
@@ -142,7 +152,11 @@ async function scrollIntoViewStable(target, options = {}) {
|
|
|
142
152
|
if (isCancelled() || !target.isConnected) return;
|
|
143
153
|
// Re-issue instantly: a no-op when the smooth scroll landed true, a
|
|
144
154
|
// snap to the real position when lazy renders shifted the layout.
|
|
145
|
-
const
|
|
155
|
+
const rect = target.getBoundingClientRect();
|
|
156
|
+
// The wait may have timed out before paint. Do not spend corrective
|
|
157
|
+
// attempts scrolling an unrendered target, or treat that no-op as success.
|
|
158
|
+
if (rect.width === 0 && rect.height === 0) return;
|
|
159
|
+
const before = rect.top;
|
|
146
160
|
target.scrollIntoView({ ...options, behavior: 'auto' });
|
|
147
161
|
if (Math.abs(target.getBoundingClientRect().top - before) <= STABLE_PX) return;
|
|
148
162
|
// The correction moved us — newly revealed bodies may render and
|