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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +3 -3
  2. package/package.json +2 -2
  3. package/plugin/.claude-plugin/plugin.json +1 -1
  4. package/plugin-code-critic/.claude-plugin/plugin.json +1 -1
  5. package/plugin-code-critic/skills/analyze/references/level1-balanced.md +1 -1
  6. package/plugin-code-critic/skills/analyze/references/level1-thorough.md +1 -1
  7. package/plugin-code-critic/skills/analyze/references/level2-balanced.md +2 -2
  8. package/plugin-code-critic/skills/analyze/references/level2-thorough.md +2 -2
  9. package/plugin-code-critic/skills/analyze/references/level3-balanced.md +2 -2
  10. package/plugin-code-critic/skills/analyze/references/level3-thorough.md +2 -2
  11. package/plugin-code-critic/skills/analyze/references/orchestration-balanced.md +3 -3
  12. package/plugin-code-critic/skills/analyze/references/orchestration-fast.md +1 -1
  13. package/plugin-code-critic/skills/analyze/references/orchestration-thorough.md +3 -3
  14. package/plugin-pair-loop/.claude-plugin/plugin.json +1 -1
  15. package/public/index.html +3 -0
  16. package/public/js/components/CouncilProgressModal.js +2 -9
  17. package/public/js/index.js +29 -0
  18. package/public/js/pr.js +21 -8
  19. package/public/js/utils/category-emoji.js +1 -1
  20. package/public/js/utils/header-anchor.js +38 -0
  21. package/public/local.html +3 -0
  22. package/public/pr.html +3 -0
  23. package/src/ai/antigravity-provider.js +76 -35
  24. package/src/ai/claude-provider.js +115 -39
  25. package/src/ai/codex-provider.js +84 -41
  26. package/src/ai/copilot-provider.js +38 -46
  27. package/src/ai/cursor-agent-provider.js +78 -135
  28. package/src/ai/executable-provider.js +1 -1
  29. package/src/ai/pi-format.js +42 -1
  30. package/src/ai/pi-style-provider.js +25 -10
  31. package/src/ai/prompts/baseline/consolidation/balanced.js +2 -2
  32. package/src/ai/prompts/baseline/consolidation/thorough.js +2 -2
  33. package/src/ai/prompts/baseline/level1/balanced.js +1 -1
  34. package/src/ai/prompts/baseline/level1/thorough.js +1 -1
  35. package/src/ai/prompts/baseline/level2/balanced.js +2 -2
  36. package/src/ai/prompts/baseline/level2/thorough.js +2 -2
  37. package/src/ai/prompts/baseline/level3/balanced.js +2 -2
  38. package/src/ai/prompts/baseline/level3/thorough.js +2 -2
  39. package/src/ai/prompts/baseline/orchestration/balanced.js +2 -2
  40. package/src/ai/prompts/baseline/orchestration/thorough.js +2 -2
  41. package/src/ai/prompts/shared/output-schema.js +6 -201
  42. package/src/ai/provider.js +3 -3
  43. package/src/chat/session-manager.js +1 -1
  44. package/src/main.js +7 -3
  45. package/src/routes/bulk-analysis-configs.js +1 -1
  46. package/src/utils/category-emoji.js +1 -1
package/README.md CHANGED
@@ -632,7 +632,7 @@ pair-review integrates with AI providers via their CLI tools:
632
632
 
633
633
  - **Claude**: Uses Claude Code CLI
634
634
  - **Antigravity**: Uses the Antigravity CLI (`agy`), the successor to the Gemini CLI. Install it with `curl -fsSL https://antigravity.google/cli/install.sh | bash` (macOS/Linux; it is not an npm package) — see the [Antigravity docs](https://antigravity.google/docs). Antigravity is an analysis-only provider: it runs as an agentic reviewer in non-interactive print mode and has **no chat/ACP mode**.
635
- - **Codex**: Uses Codex CLI. GPT-5.6 Sol High (`gpt-5.6-sol-high`) remains the recommended default during rollout. GPT-6.1 Sol High (`gpt-6.1-sol-high`) and XHigh (`gpt-6.1-sol-xhigh`) are explicit choices for reviews and chat; Enterprise and Edu administrators must enable GPT-6.1 Sol access.
635
+ - **Codex**: Uses Codex CLI. GPT-5.6 Sol High (`gpt-5.6-sol-high`) remains the recommended default during rollout. GPT-6.2 Sol High (`gpt-6.2-sol-high`) and XHigh (`gpt-6.2-sol-xhigh`), GPT-6.2 Astra High (`gpt-6.2-astra-high`) and XHigh (`gpt-6.2-astra-xhigh`), and GPT-6.1 Sol High (`gpt-6.1-sol-high`) and XHigh (`gpt-6.1-sol-xhigh`) are explicit choices for reviews and chat; Enterprise and Edu administrators must enable GPT-6.1 and GPT-6.2 access, and GPT-6.2 requires Codex CLI 0.170.0 or later. GPT-6.1 Terra XHigh (`gpt-6.1-terra-xhigh`) is an explicit balanced choice; Enterprise access depends on workspace administrator controls.
636
636
  - **GitHub Copilot**: Uses Copilot CLI
637
637
  - **OpenCode**: Uses OpenCode CLI (requires model configuration)
638
638
  - **Cursor**: Uses Cursor Agent CLI (streaming output with sandbox mode)
@@ -762,13 +762,13 @@ Use the provider-level `default_model` and `disabled_models` fields to tailor wh
762
762
  "providers": {
763
763
  "claude": {
764
764
  "default_model": "sonnet-4.6",
765
- "disabled_models": ["haiku", "fable"]
765
+ "disabled_models": ["haiku", "fable-5.2-xhigh"]
766
766
  }
767
767
  }
768
768
  }
769
769
  ```
770
770
 
771
- - `disabled_models` removes those models from the picker. It matches canonical ids only (`opus-5.5-xhigh`, not the `opus` alias). An alias entry is ignored with a warning, so hiding a retired id such as `opus-4.7-high` never hides the newer model it now redirects to. To find the built-in IDs for a provider, see the comments in `config.example.json` (e.g. Claude ships `opus-5.5-medium`, `sonnet-4.6`, `haiku`, …).
771
+ - `disabled_models` removes those models from the picker. It matches canonical ids only (`opus-5.5-high`, not the `opus` alias). An alias entry is ignored with a warning, so hiding a retired id such as `opus-4.7-high` never hides the newer model it now redirects to. To find the built-in IDs for a provider, see the comments in `config.example.json` (e.g. Claude ships `opus-5.5-medium`, `sonnet-4.6`, `haiku`, …).
772
772
  - `default_model` selects which of the *remaining* models is the default. If it points at a model that is unknown or also disabled, the provider falls back to automatic selection (the model marked `default: true`, then the first `balanced`-tier model, then the first model).
773
773
  - Prefer `default_model` over the per-model `default: true` flag, which is deprecated. Setting `default_model` suppresses the deprecation warning.
774
774
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in-the-loop-labs/pair-review",
3
- "version": "5.4.1",
3
+ "version": "5.4.3",
4
4
  "description": "Your AI-powered code review partner - Close the feedback loop with AI coding agents",
5
5
  "main": "src/server.js",
6
6
  "bin": {
@@ -83,7 +83,7 @@
83
83
  },
84
84
  "devDependencies": {
85
85
  "@changesets/cli": "^2.29.8",
86
- "@playwright/test": "^1.57.0",
86
+ "@playwright/test": "^1.65.0",
87
87
  "@vitest/coverage-v8": "^4.0.16",
88
88
  "dompurify": "^3.2.6",
89
89
  "esbuild": "^0.27.4",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pair-review",
3
- "version": "5.4.1",
3
+ "version": "5.4.3",
4
4
  "description": "pair-review app integration — Open PRs and local changes in the pair-review web UI, run server-side AI analysis, and address review feedback. Requires the pair-review MCP server.",
5
5
  "author": {
6
6
  "name": "in-the-loop-labs",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-critic",
3
- "version": "5.4.1",
3
+ "version": "5.4.3",
4
4
  "description": "AI-powered code review analysis — Run three-level AI analysis directly in your coding agent. Works standalone, no server required.",
5
5
  "author": {
6
6
  "name": "in-the-loop-labs",
@@ -95,7 +95,7 @@ Omit severity for praise items.
95
95
  "description": "Detailed explanation",
96
96
  "suggestion": "How to fix/improve (omit for praise items)",
97
97
  "confidence": 0.0-1.0,
98
- "reasoning": ["Step-by-step reasoning explaining why this issue was flagged (optional)"]
98
+ "reasoning": ["Concise code evidence and impact supporting this issue (optional)"]
99
99
  }],
100
100
  "summary": "Brief summary of findings"
101
101
  }
@@ -117,7 +117,7 @@ Output JSON with this structure:
117
117
  "description": "Detailed explanation",
118
118
  "suggestion": "How to fix/improve (omit this field for praise items - no action needed)",
119
119
  "confidence": 0.0-1.0,
120
- "reasoning": ["Step-by-step reasoning explaining why this issue was flagged"]
120
+ "reasoning": ["Concise code evidence and impact supporting this issue"]
121
121
  }],
122
122
  "summary": "Brief summary of findings"
123
123
  }
@@ -97,7 +97,7 @@ Omit severity for praise items.
97
97
  "description": "Explanation mentioning why full file context was needed",
98
98
  "suggestion": "How to fix/improve (omit for praise items)",
99
99
  "confidence": 0.0-1.0,
100
- "reasoning": ["Step-by-step reasoning explaining why this issue was flagged (optional)"]
100
+ "reasoning": ["Concise code evidence and impact supporting this issue (optional)"]
101
101
  }],
102
102
  "fileLevelSuggestions": [{
103
103
  "file": "path/to/file",
@@ -107,7 +107,7 @@ Omit severity for praise items.
107
107
  "description": "File-level observation (architecture, organization, naming, etc.)",
108
108
  "suggestion": "How to address (omit for praise items)",
109
109
  "confidence": 0.0-1.0,
110
- "reasoning": ["Step-by-step reasoning explaining why this issue was flagged (optional)"]
110
+ "reasoning": ["Concise code evidence and impact supporting this issue (optional)"]
111
111
  }],
112
112
  "summary": "Brief summary of file context findings"
113
113
  }
@@ -146,7 +146,7 @@ Output JSON with this structure:
146
146
  "description": "Detailed explanation mentioning why full file context was needed",
147
147
  "suggestion": "How to fix/improve based on file context (omit for praise items)",
148
148
  "confidence": 0.0-1.0,
149
- "reasoning": ["Step-by-step reasoning explaining why this issue was flagged"]
149
+ "reasoning": ["Concise code evidence and impact supporting this issue"]
150
150
  }],
151
151
  "fileLevelSuggestions": [{
152
152
  "file": "path/to/file",
@@ -156,7 +156,7 @@ Output JSON with this structure:
156
156
  "description": "Explanation of the file-level observation (architecture, organization, naming, etc.)",
157
157
  "suggestion": "How to address the file-level concern (omit for praise items)",
158
158
  "confidence": 0.0-1.0,
159
- "reasoning": ["Step-by-step reasoning explaining why this issue was flagged"]
159
+ "reasoning": ["Concise code evidence and impact supporting this issue"]
160
160
  }],
161
161
  "summary": "Brief summary of file context findings"
162
162
  }
@@ -134,7 +134,7 @@ Output JSON with this structure:
134
134
  "description": "Detailed explanation mentioning why codebase context was needed",
135
135
  "suggestion": "How to fix/improve based on codebase context (omit for praise items)",
136
136
  "confidence": 0.0-1.0,
137
- "reasoning": ["Step-by-step reasoning explaining why this issue was flagged (optional)"]
137
+ "reasoning": ["Concise code evidence and impact supporting this issue (optional)"]
138
138
  }],
139
139
  "fileLevelSuggestions": [{
140
140
  "file": "path/to/file",
@@ -144,7 +144,7 @@ Output JSON with this structure:
144
144
  "description": "Explanation of the file-level observation from codebase perspective",
145
145
  "suggestion": "How to address the file-level concern (omit for praise items)",
146
146
  "confidence": 0.0-1.0,
147
- "reasoning": ["Step-by-step reasoning explaining why this issue was flagged (optional)"]
147
+ "reasoning": ["Concise code evidence and impact supporting this issue (optional)"]
148
148
  }],
149
149
  "summary": "Brief summary of how these changes connect to and impact the codebase"
150
150
  }
@@ -146,7 +146,7 @@ Output JSON with this structure:
146
146
  "description": "Detailed explanation mentioning why codebase context was needed",
147
147
  "suggestion": "How to fix/improve based on codebase context (omit for praise items)",
148
148
  "confidence": 0.0-1.0,
149
- "reasoning": ["Step-by-step reasoning explaining why this issue was flagged"]
149
+ "reasoning": ["Concise code evidence and impact supporting this issue"]
150
150
  }],
151
151
  "fileLevelSuggestions": [{
152
152
  "file": "path/to/file",
@@ -156,7 +156,7 @@ Output JSON with this structure:
156
156
  "description": "Explanation of the file-level observation from codebase perspective",
157
157
  "suggestion": "How to address the file-level concern (omit for praise items)",
158
158
  "confidence": 0.0-1.0,
159
- "reasoning": ["Step-by-step reasoning explaining why this issue was flagged"]
159
+ "reasoning": ["Concise code evidence and impact supporting this issue"]
160
160
  }],
161
161
  "summary": "Brief summary of how these changes connect to and impact the codebase"
162
162
  }
@@ -50,7 +50,7 @@ Each level provides suggestions as a JSON array with the following schema per it
50
50
  - suggestion: remediation advice
51
51
  - severity: "critical", "medium", or "minor" (omit for praise items)
52
52
  - confidence: 0.0-1.0 score
53
- - reasoning: (optional) array of strings with step-by-step reasoning
53
+ - reasoning: (optional) array of strings with concise code evidence and impact
54
54
  - is_file_level: true if this is a file-level suggestion (no line numbers)
55
55
 
56
56
  **Level 1 - Diff Analysis ([N] suggestions):**
@@ -122,7 +122,7 @@ Output JSON with this structure:
122
122
  "description": "Clear explanation of the issue and why this guidance matters to the human reviewer",
123
123
  "suggestion": "Specific, actionable guidance for the reviewer. For praise items this can be omitted. For other types always include specific, actionable suggestions.",
124
124
  "confidence": 0.0-1.0,
125
- "reasoning": ["Step-by-step reasoning explaining why this issue was flagged (optional)"]
125
+ "reasoning": ["Concise code evidence and impact supporting this issue (optional)"]
126
126
  }],
127
127
  "fileLevelSuggestions": [{
128
128
  "file": "path/to/file",
@@ -132,7 +132,7 @@ Output JSON with this structure:
132
132
  "description": "Explanation of the file-level observation",
133
133
  "suggestion": "How to address the file-level concern (omit for praise items)",
134
134
  "confidence": 0.0-1.0,
135
- "reasoning": ["Step-by-step reasoning explaining why this issue was flagged (optional)"]
135
+ "reasoning": ["Concise code evidence and impact supporting this issue (optional)"]
136
136
  }],
137
137
  "summary": "Formatted markdown summary following the Summary Structure guidance above."
138
138
  }
@@ -50,7 +50,7 @@ Each level provides suggestions as a JSON array with the following schema per it
50
50
  - suggestion: remediation advice
51
51
  - severity: "critical", "medium", or "minor" (omit for praise items)
52
52
  - confidence: 0.0-1.0 score
53
- - reasoning: (optional) array of strings with step-by-step reasoning
53
+ - reasoning: (optional) array of strings with concise code evidence and impact
54
54
  - is_file_level: true if this is a file-level suggestion (no line numbers)
55
55
 
56
56
  **Level 1 - Diff Analysis ([N] suggestions):**
@@ -55,7 +55,7 @@ Each level provides suggestions as a JSON array with the following schema per it
55
55
  - suggestion: remediation advice
56
56
  - severity: "critical", "medium", or "minor" (omit for praise items)
57
57
  - confidence: 0.0-1.0 score
58
- - reasoning: (optional) array of strings with step-by-step reasoning
58
+ - reasoning: (optional) array of strings with concise code evidence and impact
59
59
  - is_file_level: true if this is a file-level suggestion (no line numbers)
60
60
 
61
61
  **Level 1 - Diff Analysis ([N] suggestions):**
@@ -213,7 +213,7 @@ Output JSON with this structure:
213
213
  "description": "Clear explanation of the issue and why this guidance matters to the human reviewer",
214
214
  "suggestion": "Specific, actionable guidance for the reviewer (omit for praise items)",
215
215
  "confidence": 0.0-1.0,
216
- "reasoning": ["Step-by-step reasoning explaining why this issue was flagged"]
216
+ "reasoning": ["Concise code evidence and impact supporting this issue"]
217
217
  }],
218
218
  "fileLevelSuggestions": [{
219
219
  "file": "path/to/file",
@@ -223,7 +223,7 @@ Output JSON with this structure:
223
223
  "description": "Explanation of the file-level observation",
224
224
  "suggestion": "How to address the file-level concern (omit for praise items)",
225
225
  "confidence": 0.0-1.0,
226
- "reasoning": ["Step-by-step reasoning explaining why this issue was flagged"]
226
+ "reasoning": ["Concise code evidence and impact supporting this issue"]
227
227
  }],
228
228
  "summary": "Formatted markdown summary following the Summary Synthesis Guidance above."
229
229
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pair-loop",
3
- "version": "5.4.1",
3
+ "version": "5.4.3",
4
4
  "description": "Agent-orchestrated review loop — implement, review with pair-review multi-model councils via the headless CLI, triage, fix, and repeat until a final review returns no blockers. MCP-independent.",
5
5
  "author": {
6
6
  "name": "in-the-loop-labs",
package/public/index.html CHANGED
@@ -278,6 +278,9 @@
278
278
  .help-modal-overlay.visible {
279
279
  opacity: 1;
280
280
  visibility: visible;
281
+ /* Become visible immediately on open so the close button can take
282
+ focus; the base rule still delays hiding until the fade-out ends. */
283
+ transition: opacity var(--transition-default), visibility 0s;
281
284
  }
282
285
 
283
286
  [data-theme="dark"] .help-modal-overlay {
@@ -17,7 +17,6 @@ class CouncilProgressModal {
17
17
  this._wsUnsub = null;
18
18
  this._onReconnect = null;
19
19
  this.statusCheckInterval = null;
20
- this.isRunningInBackground = false;
21
20
  this.councilConfig = null;
22
21
 
23
22
  // Track per-voice completion state
@@ -93,22 +92,18 @@ class CouncilProgressModal {
93
92
  }
94
93
 
95
94
  /**
96
- * Hide the modal.
95
+ * Hide the modal. Progress monitoring continues so the analyze button
96
+ * still completes when the analysis finishes.
97
97
  */
98
98
  hide() {
99
99
  this.isVisible = false;
100
100
  this.modal.style.display = 'none';
101
-
102
- if (!this.isRunningInBackground) {
103
- this.stopProgressMonitoring();
104
- }
105
101
  }
106
102
 
107
103
  /**
108
104
  * Run analysis in background.
109
105
  */
110
106
  runInBackground() {
111
- this.isRunningInBackground = true;
112
107
  this.hide();
113
108
  }
114
109
 
@@ -116,7 +111,6 @@ class CouncilProgressModal {
116
111
  * Reopen the modal from background execution.
117
112
  */
118
113
  reopenFromBackground() {
119
- this.isRunningInBackground = false;
120
114
  if (this.currentAnalysisId) {
121
115
  // Don't rebuild — just re-show the existing DOM
122
116
  this.isVisible = true;
@@ -1432,7 +1426,6 @@ class CouncilProgressModal {
1432
1426
  if (cancelBtn) {
1433
1427
  cancelBtn.textContent = 'Cancel';
1434
1428
  }
1435
- this.isRunningInBackground = false;
1436
1429
  }
1437
1430
 
1438
1431
  // ---------------------------------------------------------------------------
@@ -22,16 +22,23 @@
22
22
 
23
23
  // ─── Help Modal ─────────────────────────────────────────────────────────────
24
24
 
25
+ /** Element that had focus before the help modal opened, refocused on close */
26
+ let helpModalReturnFocus = null;
27
+
25
28
  function openHelpModal() {
26
29
  const overlay = document.getElementById('help-modal-overlay');
30
+ helpModalReturnFocus = document.activeElement;
27
31
  overlay.classList.add('visible');
28
32
  document.body.style.overflow = 'hidden';
33
+ document.getElementById('help-modal-close').focus();
29
34
  }
30
35
 
31
36
  function closeHelpModal() {
32
37
  const overlay = document.getElementById('help-modal-overlay');
33
38
  overlay.classList.remove('visible');
34
39
  document.body.style.overflow = '';
40
+ if (helpModalReturnFocus) helpModalReturnFocus.focus();
41
+ helpModalReturnFocus = null;
35
42
  }
36
43
 
37
44
  // Set up help button
@@ -2471,6 +2478,27 @@
2471
2478
 
2472
2479
  // ─── DOMContentLoaded Initialization ────────────────────────────────────────
2473
2480
 
2481
+ /** Start-review input to focus on load, keyed by tab pane id */
2482
+ const TAB_AUTOFOCUS_INPUT_IDS = {
2483
+ 'pr-tab': 'pr-url-input',
2484
+ 'local-tab': 'local-path-input'
2485
+ };
2486
+
2487
+ /**
2488
+ * Focus the restored tab's start-review input so a review can be started by
2489
+ * pasting and pressing Enter. Leaves focus alone if the user already moved
2490
+ * it while the page was loading.
2491
+ * @param {string} tabId - Tab pane id restored on load
2492
+ */
2493
+ function focusRestoredTabInput(tabId) {
2494
+ const inputId = TAB_AUTOFOCUS_INPUT_IDS[tabId];
2495
+ if (!inputId) return;
2496
+ if (document.activeElement && document.activeElement !== document.body) return;
2497
+
2498
+ const input = document.getElementById(inputId);
2499
+ if (input) input.focus();
2500
+ }
2501
+
2474
2502
  document.addEventListener('DOMContentLoaded', async function () {
2475
2503
  // Load config and update command examples based on npx detection.
2476
2504
  // Await so that window.__pairReview.enableGraphite (and other config
@@ -2487,6 +2515,7 @@
2487
2515
  switchTab(tabBar, targetBtn);
2488
2516
  }
2489
2517
  }
2518
+ focusRestoredTabInput(savedTab);
2490
2519
 
2491
2520
  // Always load PR reviews (they show on initial load). This is the only
2492
2521
  // caller that opens the help modal for an empty list.
package/public/js/pr.js CHANGED
@@ -5155,8 +5155,10 @@ class PRManager {
5155
5155
  wrapper.classList.remove('collapsed');
5156
5156
  this.collapsedFiles.delete(filePath);
5157
5157
  } else {
5158
- wrapper.classList.add('collapsed');
5159
- this.collapsedFiles.add(filePath);
5158
+ window.HeaderAnchor.keepHeaderInPlace(header, () => {
5159
+ wrapper.classList.add('collapsed');
5160
+ this.collapsedFiles.add(filePath);
5161
+ });
5160
5162
  }
5161
5163
 
5162
5164
  // Update header state
@@ -5182,9 +5184,11 @@ class PRManager {
5182
5184
  this.viewedFiles.add(filePath);
5183
5185
  // Auto-collapse when marking as viewed
5184
5186
  if (wrapper && !wrapper.classList.contains('collapsed')) {
5185
- wrapper.classList.add('collapsed');
5186
- this.collapsedFiles.add(filePath);
5187
5187
  const header = wrapper.querySelector('.d2h-file-header');
5188
+ window.HeaderAnchor.keepHeaderInPlace(header, () => {
5189
+ wrapper.classList.add('collapsed');
5190
+ this.collapsedFiles.add(filePath);
5191
+ });
5188
5192
  if (header) {
5189
5193
  window.DiffRenderer.updateFileHeaderState(header, false);
5190
5194
  }
@@ -5257,14 +5261,21 @@ class PRManager {
5257
5261
  if (!wrapper) return;
5258
5262
 
5259
5263
  const key = this._contextStateKey(filePath);
5260
- const collapsed = wrapper.classList.toggle('collapsed');
5264
+ const header = wrapper.querySelector('.d2h-file-header');
5265
+ const collapsed = !wrapper.classList.contains('collapsed');
5261
5266
  if (collapsed) {
5267
+ window.HeaderAnchor.keepHeaderInPlace(header, () => {
5268
+ wrapper.classList.add('collapsed');
5269
+ });
5262
5270
  this.collapsedFiles.add(key);
5263
5271
  } else {
5272
+ // Not anchored: a collapsed header partly under the sticky toolbar
5273
+ // drops to the sticky line on expand, and compensating for that would
5274
+ // push the top of the newly revealed body up under it.
5275
+ wrapper.classList.remove('collapsed');
5264
5276
  this.collapsedFiles.delete(key);
5265
5277
  }
5266
5278
 
5267
- const header = wrapper.querySelector('.d2h-file-header');
5268
5279
  if (header) {
5269
5280
  window.DiffRenderer.updateFileHeaderState(header, !collapsed);
5270
5281
  }
@@ -5286,8 +5297,10 @@ class PRManager {
5286
5297
  this.viewedFiles.add(key);
5287
5298
  // Auto-collapse when marking as viewed
5288
5299
  if (wrapper && !wrapper.classList.contains('collapsed')) {
5289
- wrapper.classList.add('collapsed');
5290
- this.collapsedFiles.add(key);
5300
+ window.HeaderAnchor.keepHeaderInPlace(header, () => {
5301
+ wrapper.classList.add('collapsed');
5302
+ this.collapsedFiles.add(key);
5303
+ });
5291
5304
  if (header) {
5292
5305
  window.DiffRenderer.updateFileHeaderState(header, false);
5293
5306
  }
@@ -3,7 +3,7 @@
3
3
  * Canonical category-to-emoji mapping for AI suggestion types.
4
4
  * Used by SuggestionManager and FileCommentManager to format adopted comments.
5
5
  *
6
- * Canonical types from src/ai/prompts/shared/output-schema.js:
6
+ * Canonical types from the output-schema sections in src/ai/prompts/baseline/:
7
7
  * bug|improvement|praise|suggestion|design|performance|security|code-style
8
8
  */
9
9
 
@@ -0,0 +1,38 @@
1
+ // Copyright 2026 Tim Perkins (tjwp) | SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * Keeps a file header at the same viewport position across a synchronous
4
+ * change that resizes its file, such as collapsing it.
5
+ *
6
+ * A header stuck to the top of the diff pane belongs to a file the reader is
7
+ * partway through. Collapsing that file shrinks it to just the header, which
8
+ * would leave the header far above the viewport. Scrolling the pane by however
9
+ * far the header moved puts the collapsed header back where it was stuck, with
10
+ * the next file directly below it. A header that wasn't stuck doesn't move, so
11
+ * nothing scrolls.
12
+ *
13
+ * @param {Element|null} header - The file header to hold in place
14
+ * @param {() => T} change - Synchronous change that resizes the header's file
15
+ * @returns {T} the change's return value
16
+ * @template T
17
+ */
18
+ function keepHeaderInPlace(header, change) {
19
+ if (!header) return change();
20
+
21
+ const topBefore = header.getBoundingClientRect().top;
22
+ const result = change();
23
+ const shift = header.getBoundingClientRect().top - topBefore;
24
+
25
+ if (shift !== 0) {
26
+ header.closest('.diff-view')?.scrollBy(0, shift);
27
+ }
28
+
29
+ return result;
30
+ }
31
+
32
+ if (typeof window !== 'undefined') {
33
+ window.HeaderAnchor = { keepHeaderInPlace };
34
+ }
35
+
36
+ if (typeof module !== 'undefined' && module.exports) {
37
+ module.exports = { keepHeaderInPlace };
38
+ }
package/public/local.html CHANGED
@@ -608,6 +608,9 @@
608
608
  <!-- Stable scroll-into-view for lazily rendered diff bodies -->
609
609
  <script src="/js/utils/scroll-into-view.js"></script>
610
610
 
611
+ <!-- Holds a file header in place when its file collapses -->
612
+ <script src="/js/utils/header-anchor.js"></script>
613
+
611
614
  <!-- WebSocket client -->
612
615
  <script src="/js/ws-client.js"></script>
613
616
 
package/public/pr.html CHANGED
@@ -413,6 +413,9 @@
413
413
  <!-- Stable scroll-into-view for lazily rendered diff bodies -->
414
414
  <script src="/js/utils/scroll-into-view.js"></script>
415
415
 
416
+ <!-- Holds a file header in place when its file collapses -->
417
+ <script src="/js/utils/header-anchor.js"></script>
418
+
416
419
  <!-- WebSocket client -->
417
420
  <script src="/js/ws-client.js"></script>
418
421