@in-the-loop-labs/pair-review 4.1.1 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +81 -13
  2. package/package.json +6 -2
  3. package/plugin/.claude-plugin/plugin.json +1 -1
  4. package/plugin-code-critic/.claude-plugin/plugin.json +1 -1
  5. package/plugin-pair-loop/.claude-plugin/plugin.json +1 -1
  6. package/plugin-pair-loop/skills/loop/SKILL.md +17 -8
  7. package/public/css/ai-summary-modal.css +1 -1
  8. package/public/css/analysis-config.css +33 -49
  9. package/public/css/council-card.css +118 -0
  10. package/public/css/council-dropdown.css +164 -0
  11. package/public/css/pr.css +668 -393
  12. package/public/css/repo-settings.css +15 -305
  13. package/public/css/settings.css +1141 -0
  14. package/public/css/snippet-manager.css +233 -0
  15. package/public/index.html +40 -59
  16. package/public/js/components/AIPanel.js +82 -16
  17. package/public/js/components/ChatPanel.js +401 -5
  18. package/public/js/components/CouncilCard.js +202 -0
  19. package/public/js/components/CouncilDropdown.js +292 -0
  20. package/public/js/components/DiffOptionsDropdown.js +177 -4
  21. package/public/js/components/SnippetManager.js +463 -0
  22. package/public/js/index.js +7 -30
  23. package/public/js/local.js +20 -2
  24. package/public/js/modules/comment-manager.js +8 -1
  25. package/public/js/modules/comment-minimizer.js +249 -190
  26. package/public/js/modules/diff-renderer.js +16 -4
  27. package/public/js/modules/external-comment-manager.js +414 -48
  28. package/public/js/modules/file-comment-manager.js +28 -21
  29. package/public/js/modules/hunk-summary-renderer.js +155 -29
  30. package/public/js/modules/pierre-bridge.js +2513 -0
  31. package/public/js/modules/pierre-context.js +345 -0
  32. package/public/js/modules/suggestion-manager.js +176 -20
  33. package/public/js/modules/tour-renderer.js +400 -184
  34. package/public/js/pr.js +1614 -158
  35. package/public/js/repo-settings.js +60 -284
  36. package/public/js/settings.js +1086 -0
  37. package/public/js/theme-bootstrap.js +40 -0
  38. package/public/js/theme.js +247 -0
  39. package/public/js/utils/provider-model.js +3 -3
  40. package/public/js/utils/suggestion-ui.js +157 -8
  41. package/public/local.html +20 -31
  42. package/public/pr.html +14 -23
  43. package/public/repo-settings.html +24 -14
  44. package/public/settings.html +138 -0
  45. package/public/setup.html +8 -13
  46. package/src/chat/api-reference.js +9 -5
  47. package/src/chat/prompt-builder.js +8 -1
  48. package/src/config.js +15 -6
  49. package/src/database.js +307 -14
  50. package/src/external/github-adapter.js +39 -5
  51. package/src/headless/delegate.js +682 -0
  52. package/src/local-review.js +10 -10
  53. package/src/local-scope.js +9 -0
  54. package/src/main.js +276 -157
  55. package/src/mcp-stdio.js +24 -1
  56. package/src/review-config.js +93 -25
  57. package/src/routes/chat.js +2 -2
  58. package/src/routes/config.js +12 -10
  59. package/src/routes/external-comments.js +5 -1
  60. package/src/routes/local.js +2 -4
  61. package/src/routes/mcp.js +18 -13
  62. package/src/routes/reviews.js +223 -4
  63. package/src/routes/settings.js +252 -0
  64. package/src/routes/setup.js +80 -1
  65. package/src/routes/shared.js +31 -29
  66. package/src/routes/snippets.js +154 -0
  67. package/src/routes/stack-analysis.js +17 -14
  68. package/src/server.js +86 -18
  69. package/src/settings/global-settings-service.js +472 -0
  70. package/src/settings/registry.js +624 -0
  71. package/src/utils/db-identity.js +44 -0
@@ -0,0 +1,40 @@
1
+ // Copyright 2026 Tim Perkins (tjwp) | SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * Synchronous theme bootstrap — the single source of truth for the pre-paint
4
+ * theme decision, shared by every page.
5
+ *
6
+ * Loaded as the FIRST <script> in each page <head> (render-blocking, no
7
+ * `defer`/`async`) so the correct `data-theme` is set before first paint,
8
+ * preventing a flash of the wrong theme (FOUC).
9
+ *
10
+ * It is deliberately tiny, dependency-free, and duplicated-logic-free: the six
11
+ * pages previously each inlined their own copy of this resolution. The
12
+ * richer runtime behavior (toggle cycling, live OS-change tracking, button
13
+ * icon) lives in js/theme.js, loaded later at the end of <body>.
14
+ *
15
+ * DEFAULT_PREFERENCE below is the single place that decides what a first-time
16
+ * visitor (no stored preference) sees; keep it in sync with
17
+ * PairReviewTheme.DEFAULT_PREFERENCE in js/theme.js.
18
+ */
19
+ (function () {
20
+ 'use strict';
21
+
22
+ var DEFAULT_PREFERENCE = 'system';
23
+
24
+ var pref;
25
+ try {
26
+ pref = localStorage.getItem('theme');
27
+ } catch (e) {
28
+ // localStorage can throw in privacy modes — fall back to the default.
29
+ pref = null;
30
+ }
31
+ if (pref !== 'light' && pref !== 'dark' && pref !== 'system') {
32
+ pref = DEFAULT_PREFERENCE;
33
+ }
34
+
35
+ var systemDark = !!(window.matchMedia &&
36
+ window.matchMedia('(prefers-color-scheme: dark)').matches);
37
+ var resolved = pref === 'system' ? (systemDark ? 'dark' : 'light') : pref;
38
+
39
+ document.documentElement.setAttribute('data-theme', resolved);
40
+ })();
@@ -0,0 +1,247 @@
1
+ // Copyright 2026 Tim Perkins (tjwp) | SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * Shared theme helper.
4
+ *
5
+ * The app supports three theme *preferences*:
6
+ * - 'light' — always light
7
+ * - 'dark' — always dark
8
+ * - 'system' — follow the OS setting, live (via prefers-color-scheme)
9
+ *
10
+ * A preference is persisted in localStorage under 'theme'. It is *resolved*
11
+ * to a concrete 'light' | 'dark' before being written to the
12
+ * `data-theme` attribute on <html>, because every theme CSS rule keys off
13
+ * `[data-theme="dark"]`. The literal value 'system' is NEVER placed on the
14
+ * element — only its resolved value.
15
+ *
16
+ * This module exposes pure helpers (resolveTheme, nextPreference, iconSvg,
17
+ * labelFor) for unit testing, plus browser-facing helpers that touch the DOM.
18
+ * Loading the module has no side effects; a page must call
19
+ * `PairReviewTheme.setup()` (or the lower-level helpers) explicitly.
20
+ */
21
+ (function (factory) {
22
+ 'use strict';
23
+ const api = factory();
24
+ if (typeof module !== 'undefined' && module.exports) {
25
+ module.exports = api;
26
+ }
27
+ if (typeof window !== 'undefined') {
28
+ window.PairReviewTheme = api;
29
+ }
30
+ })(function () {
31
+ 'use strict';
32
+
33
+ const STORAGE_KEY = 'theme';
34
+ // A first-time visitor (no stored preference) follows the OS light/dark
35
+ // setting. Once they click the toggle, their explicit choice is persisted and
36
+ // wins. Keep in sync with DEFAULT_PREFERENCE in js/theme-bootstrap.js.
37
+ const DEFAULT_PREFERENCE = 'system';
38
+ /** Cycle order used by the toggle button. */
39
+ const PREFERENCES = ['light', 'dark', 'system'];
40
+ const SYSTEM_QUERY = '(prefers-color-scheme: dark)';
41
+
42
+ // ─── Pure helpers (safe to call without a DOM) ──────────────────────────────
43
+
44
+ /**
45
+ * Resolve a preference to a concrete theme.
46
+ * @param {string} preference - 'light' | 'dark' | 'system'
47
+ * @param {boolean} systemIsDark - whether the OS currently prefers dark
48
+ * @returns {'light'|'dark'}
49
+ */
50
+ function resolveTheme(preference, systemIsDark) {
51
+ if (preference === 'system') {
52
+ return systemIsDark ? 'dark' : 'light';
53
+ }
54
+ return preference === 'dark' ? 'dark' : 'light';
55
+ }
56
+
57
+ /**
58
+ * Next preference in the toggle cycle: light → dark → system → light.
59
+ * Unknown values fall back to the start of the cycle.
60
+ * @param {string} preference
61
+ * @returns {'light'|'dark'|'system'}
62
+ */
63
+ function nextPreference(preference) {
64
+ const idx = PREFERENCES.indexOf(preference);
65
+ return PREFERENCES[(idx + 1) % PREFERENCES.length];
66
+ }
67
+
68
+ /** Capitalized human name for a preference. */
69
+ function describe(preference) {
70
+ if (preference === 'dark') return 'Dark';
71
+ if (preference === 'system') return 'System';
72
+ return 'Light';
73
+ }
74
+
75
+ /**
76
+ * Accessible label / tooltip text describing the current preference and
77
+ * what a click will switch to.
78
+ */
79
+ function labelFor(preference) {
80
+ // Unknown/corrupt input renders as light here (a safe visual fallback,
81
+ // matching iconSvg); the *actual* default preference is DEFAULT_PREFERENCE,
82
+ // applied in getPreference() before any value reaches this function.
83
+ const pref = PREFERENCES.indexOf(preference) === -1 ? 'light' : preference;
84
+ return `Theme: ${describe(pref)} (click for ${describe(nextPreference(pref))})`;
85
+ }
86
+
87
+ /**
88
+ * SVG markup for the button icon representing a preference.
89
+ * Sun = light, moon = dark, monitor = system.
90
+ */
91
+ function iconSvg(preference) {
92
+ if (preference === 'dark') {
93
+ return '<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M9.598 1.591a.749.749 0 0 1 .785-.175 7.001 7.001 0 1 1-8.967 8.967.75.75 0 0 1 .961-.96 5.5 5.5 0 0 0 7.046-7.046.75.75 0 0 1 .175-.786Z"/></svg>';
94
+ }
95
+ if (preference === 'system') {
96
+ return '<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M1.75 2A1.75 1.75 0 0 0 0 3.75v7c0 .966.784 1.75 1.75 1.75H6v1H4.75a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5H10v-1h4.25A1.75 1.75 0 0 0 16 10.75v-7A1.75 1.75 0 0 0 14.25 2H1.75Zm0 1.5h12.5a.25.25 0 0 1 .25.25v7a.25.25 0 0 1-.25.25H1.75a.25.25 0 0 1-.25-.25v-7a.25.25 0 0 1 .25-.25Z"/></svg>';
97
+ }
98
+ return '<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8Zm0-1.5a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5Zm0-10.5a.75.75 0 0 1 .75.75v1.5a.75.75 0 0 1-1.5 0V.75A.75.75 0 0 1 8 0Zm0 13a.75.75 0 0 1 .75.75v1.5a.75.75 0 0 1-1.5 0v-1.5A.75.75 0 0 1 8 13ZM2.343 2.343a.75.75 0 0 1 1.061 0l1.06 1.061a.75.75 0 0 1-1.06 1.06l-1.06-1.06a.75.75 0 0 1 0-1.06Zm9.193 9.193a.75.75 0 0 1 1.06 0l1.061 1.06a.75.75 0 0 1-1.06 1.061l-1.061-1.06a.75.75 0 0 1 0-1.061ZM16 8a.75.75 0 0 1-.75.75h-1.5a.75.75 0 0 1 0-1.5h1.5A.75.75 0 0 1 16 8ZM3 8a.75.75 0 0 1-.75.75H.75a.75.75 0 0 1 0-1.5h1.5A.75.75 0 0 1 3 8Zm10.657-5.657a.75.75 0 0 1 0 1.061l-1.061 1.06a.75.75 0 1 1-1.06-1.06l1.06-1.06a.75.75 0 0 1 1.06 0Zm-9.193 9.193a.75.75 0 0 1 0 1.06l-1.06 1.061a.75.75 0 0 1-1.061-1.06l1.06-1.061a.75.75 0 0 1 1.061 0Z"/></svg>';
99
+ }
100
+
101
+ // ─── Browser helpers (require a DOM) ─────────────────────────────────────────
102
+
103
+ /** Whether the OS currently prefers a dark color scheme. */
104
+ function systemIsDark() {
105
+ return !!(typeof window !== 'undefined' &&
106
+ window.matchMedia &&
107
+ window.matchMedia(SYSTEM_QUERY).matches);
108
+ }
109
+
110
+ /** Read the stored preference, falling back to the default. */
111
+ function getPreference() {
112
+ try {
113
+ const stored = window.localStorage.getItem(STORAGE_KEY);
114
+ return PREFERENCES.indexOf(stored) === -1 ? DEFAULT_PREFERENCE : stored;
115
+ } catch (_e) {
116
+ return DEFAULT_PREFERENCE;
117
+ }
118
+ }
119
+
120
+ /** Persist a preference. */
121
+ function setPreference(preference) {
122
+ try {
123
+ window.localStorage.setItem(STORAGE_KEY, preference);
124
+ } catch (_e) {
125
+ /* localStorage unavailable — preference is still applied for this page */
126
+ }
127
+ }
128
+
129
+ /** Resolve the stored (or given) preference to a concrete theme. */
130
+ function resolvePreference(preference) {
131
+ return resolveTheme(preference || getPreference(), systemIsDark());
132
+ }
133
+
134
+ /**
135
+ * Write the resolved theme to <html data-theme>. Returns the resolved theme.
136
+ * Does not persist — call setPreference separately.
137
+ */
138
+ function applyResolved(preference) {
139
+ const resolved = resolvePreference(preference);
140
+ if (typeof document !== 'undefined') {
141
+ document.documentElement.setAttribute('data-theme', resolved);
142
+ }
143
+ return resolved;
144
+ }
145
+
146
+ /** Update a toggle button's icon, title, and aria-label for a preference. */
147
+ function updateButton(button, preference) {
148
+ if (!button) return;
149
+ button.innerHTML = iconSvg(preference);
150
+ button.title = labelFor(preference);
151
+ button.setAttribute('aria-label', labelFor(preference));
152
+ }
153
+
154
+ /**
155
+ * Wire up the theme system for a page.
156
+ *
157
+ * - Applies the stored preference to <html> and the toggle button.
158
+ * - Cycles light → dark → system → light on click.
159
+ * - Re-applies live when the OS scheme changes AND the preference is
160
+ * 'system' (so 'light'/'dark' users are never overridden).
161
+ * - Calls onChange(resolvedTheme, preference) after every apply (initial
162
+ * load, toggle, and OS change) so callers can sync dependent state
163
+ * (e.g. the diff renderer).
164
+ *
165
+ * @param {object} [opts]
166
+ * @param {string} [opts.buttonId='theme-toggle'] - id of the toggle button
167
+ * @param {(resolved: 'light'|'dark', preference: string) => void} [opts.onChange]
168
+ * @returns {() => void} dispose function (removes the OS-change listener)
169
+ */
170
+ function setup(opts) {
171
+ const options = opts || {};
172
+ const buttonId = options.buttonId || 'theme-toggle';
173
+ const onChange = typeof options.onChange === 'function' ? options.onChange : null;
174
+
175
+ const button = typeof document !== 'undefined' ? document.getElementById(buttonId) : null;
176
+
177
+ // Track the active preference in memory so the toggle cycle never depends
178
+ // on a successful localStorage write to advance. If persistence silently
179
+ // fails, the button still cycles light → dark → system correctly (the
180
+ // choice just won't survive a reload) instead of sticking at light↔dark.
181
+ let currentPreference = getPreference();
182
+
183
+ function applyAndNotify(preference) {
184
+ currentPreference = preference;
185
+ const resolved = applyResolved(preference);
186
+ updateButton(button, preference);
187
+ if (onChange) onChange(resolved, preference);
188
+ return resolved;
189
+ }
190
+
191
+ // Initial paint (inline bootstrap already set data-theme; this syncs the
192
+ // button + notifies dependents).
193
+ applyAndNotify(currentPreference);
194
+
195
+ if (button) {
196
+ button.addEventListener('click', function () {
197
+ const next = nextPreference(currentPreference);
198
+ setPreference(next);
199
+ applyAndNotify(next);
200
+ });
201
+ }
202
+
203
+ // Live OS-change listener — only takes effect while preference is 'system'.
204
+ let mql = null;
205
+ let handler = null;
206
+ if (typeof window !== 'undefined' && window.matchMedia) {
207
+ mql = window.matchMedia(SYSTEM_QUERY);
208
+ handler = function () {
209
+ if (currentPreference === 'system') {
210
+ applyAndNotify('system');
211
+ }
212
+ };
213
+ if (mql.addEventListener) {
214
+ mql.addEventListener('change', handler);
215
+ } else if (mql.addListener) {
216
+ mql.addListener(handler); // Safari < 14 fallback
217
+ }
218
+ }
219
+
220
+ return function dispose() {
221
+ if (mql && handler) {
222
+ if (mql.removeEventListener) mql.removeEventListener('change', handler);
223
+ else if (mql.removeListener) mql.removeListener(handler);
224
+ }
225
+ };
226
+ }
227
+
228
+ return {
229
+ STORAGE_KEY,
230
+ DEFAULT_PREFERENCE,
231
+ PREFERENCES,
232
+ // pure
233
+ resolveTheme,
234
+ nextPreference,
235
+ describe,
236
+ labelFor,
237
+ iconSvg,
238
+ // browser
239
+ systemIsDark,
240
+ getPreference,
241
+ setPreference,
242
+ resolvePreference,
243
+ applyResolved,
244
+ updateButton,
245
+ setup,
246
+ };
247
+ });
@@ -100,9 +100,9 @@ function resolveProviderModelPair(scopes, providersInfo) {
100
100
  * 1. `extraOverride` — a per-invocation override carried on the auto-analyze
101
101
  * URL (single-port delegation: the flag can only reach the already-running
102
102
  * server through the URL).
103
- * 2. `appConfig.provider_override` / `appConfig.model_override` — the
104
- * PAIR_REVIEW_PROVIDER / PAIR_REVIEW_MODEL env override surfaced by
105
- * /api/config, for the process that actually received the CLI flag.
103
+ * 2. `appConfig.provider_override` / `appConfig.model_override` — the per-run
104
+ * `--provider` / `--model` override surfaced by /api/config, for the
105
+ * process that actually received the CLI flag.
106
106
  *
107
107
  * A provider-only override (`{ provider: 'codex', model: null }`) resolves via
108
108
  * resolveProviderModelPair to codex + codex's own default model, matching CLI
@@ -6,10 +6,150 @@
6
6
 
7
7
  (function() {
8
8
  /**
9
- * Text shown when an AI suggestion is hidden/dismissed
9
+ * Label shown above a dismissal reason note.
10
10
  * @constant {string}
11
11
  */
12
- const HIDDEN_SUGGESTION_TEXT = 'Hidden AI suggestion';
12
+ const DISMISSAL_NOTE_LABEL = 'Dismissal note';
13
+
14
+ /**
15
+ * Heading shown above the dismissal reason inside the reasoning popover.
16
+ * @constant {string}
17
+ */
18
+ const POPOVER_DISMISSAL_HEADING = 'Dismissal';
19
+
20
+ /**
21
+ * Minimal HTML escaper. Self-contained so the reason builders can be called
22
+ * from any render path (suggestion cards, file-comment cards, AI panel)
23
+ * without depending on the caller's escape helper.
24
+ * @param {*} text
25
+ * @returns {string}
26
+ */
27
+ function escapeReasonHtml(text) {
28
+ if (text == null) return '';
29
+ return String(text)
30
+ .replace(/&/g, '&amp;')
31
+ .replace(/</g, '&lt;')
32
+ .replace(/>/g, '&gt;')
33
+ .replace(/"/g, '&quot;')
34
+ .replace(/'/g, '&#39;');
35
+ }
36
+
37
+ /**
38
+ * Build the expanded reply-styled dismissal note block. Rendered under the
39
+ * suggestion body of a dismissed AI suggestion when a reason is present.
40
+ * Returns an empty string when there is no reason so callers can inline it.
41
+ *
42
+ * @param {string|null|undefined} statusReason - The dismissal reason
43
+ * @returns {string} HTML string (empty when no reason)
44
+ */
45
+ function buildDismissalNoteHtml(statusReason) {
46
+ if (!statusReason) return '';
47
+ const safe = escapeReasonHtml(statusReason);
48
+ return `
49
+ <div class="ai-dismissal-note" role="note">
50
+ <span class="ai-dismissal-note-label">${DISMISSAL_NOTE_LABEL}</span>
51
+ <span class="ai-dismissal-note-body">${safe}</span>
52
+ </div>`;
53
+ }
54
+
55
+ /**
56
+ * Build the inner HTML for a reasoning popover's content area.
57
+ *
58
+ * Renders the reasoning steps as a markdown bullet list (as before) and, when
59
+ * a dismissal reason is present, appends a "Dismissal" section beneath it.
60
+ * Either part may be absent: a reason-only popover renders just the Dismissal
61
+ * section, and a reasoning-only popover renders just the bullets. Returns an
62
+ * empty string when neither is present.
63
+ *
64
+ * Content is rendered through window.renderMarkdown when available (which uses
65
+ * markdown-it with html:false, so agent-controlled text stays inert). When it
66
+ * is unavailable the text is HTML-escaped instead, matching the reasoning
67
+ * bullets' own fallback.
68
+ *
69
+ * @param {Array<string>|null|undefined} reasoning - Reasoning steps
70
+ * @param {string|null|undefined} dismissalReason - The dismissal reason
71
+ * @returns {string} HTML string for the popover content (empty when neither)
72
+ */
73
+ function buildReasoningPopoverContentHtml(reasoning, dismissalReason) {
74
+ const renderMd = (typeof window !== 'undefined' && window.renderMarkdown)
75
+ ? window.renderMarkdown
76
+ : null;
77
+
78
+ let html = '';
79
+
80
+ if (Array.isArray(reasoning) && reasoning.length > 0) {
81
+ const bulletMd = reasoning.map(step => `- ${step}`).join('\n');
82
+ html += renderMd
83
+ ? renderMd(bulletMd)
84
+ : `<ul>${reasoning.map(step => `<li>${escapeReasonHtml(step)}</li>`).join('')}</ul>`;
85
+ }
86
+
87
+ if (dismissalReason) {
88
+ const reasonHtml = renderMd
89
+ ? renderMd(dismissalReason)
90
+ : `<p>${escapeReasonHtml(dismissalReason)}</p>`;
91
+ html += `
92
+ <div class="reasoning-popover-dismissal">
93
+ <span class="reasoning-popover-dismissal-heading">${POPOVER_DISMISSAL_HEADING}</span>
94
+ ${reasonHtml}
95
+ </div>`;
96
+ }
97
+
98
+ return html;
99
+ }
100
+
101
+ /**
102
+ * Set (or clear) the collapsed-bar state tooltip on a suggestion card.
103
+ *
104
+ * The collapsed bar no longer shows inline state text; the dismissed/adopted
105
+ * signal now lives in a tooltip on the collapsed-content container. Pass a
106
+ * falsy label to clear it (e.g. when restoring a suggestion to active).
107
+ *
108
+ * @param {HTMLElement|null} suggestionDiv - The .ai-suggestion element
109
+ * @param {string} [label] - 'Dismissed', 'Adopted', or '' to clear
110
+ */
111
+ function setCollapsedStateTooltip(suggestionDiv, label) {
112
+ if (!suggestionDiv) return;
113
+ const collapsedContent = suggestionDiv.querySelector('.ai-suggestion-collapsed-content');
114
+ if (!collapsedContent) return;
115
+ if (label) {
116
+ collapsedContent.title = label;
117
+ } else {
118
+ collapsedContent.removeAttribute('title');
119
+ }
120
+ }
121
+
122
+ /**
123
+ * Strip stale dismissal-reason UI from a suggestion card when it is restored
124
+ * to active. While dismissed, the reason is baked into the card markup in two
125
+ * places: the expanded reply-styled note (`.ai-dismissal-note`) and the
126
+ * reasoning popover (via `data-dismissal-reason` on the brain buttons). Restore
127
+ * paths only flip the `collapsed` class, so without this the reason survives on
128
+ * a now-active suggestion.
129
+ *
130
+ * Shared by the line-level card (pr.js `restoreSuggestion`) and the file-level
131
+ * card (file-comment-manager `restoreAISuggestion`), which have identical
132
+ * reason markup.
133
+ *
134
+ * @param {HTMLElement|null} cardEl - The `.ai-suggestion` card element
135
+ */
136
+ function clearDismissalReasonUI(cardEl) {
137
+ if (!cardEl) return;
138
+
139
+ // Remove the expanded reply-styled note(s).
140
+ cardEl.querySelectorAll('.ai-dismissal-note').forEach(el => el.remove());
141
+
142
+ // Clear the stale reason from both reasoning-toggle buttons (expanded +
143
+ // collapsed). A brain button that exists ONLY because of the reason (no
144
+ // reasoning steps, so an empty data-reasoning) is removed entirely; one that
145
+ // also carries reasoning steps stays but drops its Dismissal section.
146
+ cardEl.querySelectorAll('.btn-reasoning-toggle').forEach(btn => {
147
+ btn.removeAttribute('data-dismissal-reason');
148
+ if (!btn.getAttribute('data-reasoning')) {
149
+ btn.remove();
150
+ }
151
+ });
152
+ }
13
153
 
14
154
  /**
15
155
  * Update the UI for a dismissed AI suggestion.
@@ -28,11 +168,8 @@
28
168
  // Collapse the suggestion
29
169
  suggestionDiv.classList.add('collapsed');
30
170
 
31
- // Update collapsed content text to indicate dismissed state
32
- const collapsedText = suggestionDiv.querySelector('.collapsed-text');
33
- if (collapsedText) {
34
- collapsedText.textContent = HIDDEN_SUGGESTION_TEXT;
35
- }
171
+ // Signal the dismissed state via the collapsed-bar tooltip
172
+ setCollapsedStateTooltip(suggestionDiv, 'Dismissed');
36
173
 
37
174
  // Update the suggestion div dataset
38
175
  suggestionDiv.dataset.hiddenForAdoption = 'false';
@@ -46,7 +183,19 @@
46
183
 
47
184
  // Export to global scope
48
185
  window.SuggestionUI = {
49
- HIDDEN_SUGGESTION_TEXT,
186
+ DISMISSAL_NOTE_LABEL,
187
+ POPOVER_DISMISSAL_HEADING,
188
+ escapeReasonHtml,
189
+ buildDismissalNoteHtml,
190
+ buildReasoningPopoverContentHtml,
191
+ setCollapsedStateTooltip,
192
+ clearDismissalReasonUI,
50
193
  updateDismissedSuggestionUI
51
194
  };
195
+
196
+ // Support CommonJS require() in unit tests (jsdom / vm sandbox) while keeping
197
+ // the browser IIFE behavior of assigning to window.
198
+ if (typeof module !== 'undefined' && module.exports) {
199
+ module.exports = window.SuggestionUI;
200
+ }
52
201
  })();
package/public/local.html CHANGED
@@ -1,12 +1,8 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en" data-theme="light" data-chat="disabled">
3
3
  <head>
4
+ <script src="/js/theme-bootstrap.js"></script>
4
5
  <script>
5
- // Initialize theme immediately to prevent flash
6
- (function() {
7
- const savedTheme = localStorage.getItem('theme') || 'light';
8
- document.documentElement.setAttribute('data-theme', savedTheme);
9
- })();
10
6
  // Fetch chat availability early so PanelGroup sees the correct state
11
7
  fetch('/api/config').then(r => r.ok ? r.json() : null).then(config => {
12
8
  if (!config) return;
@@ -33,18 +29,14 @@
33
29
  <title>Pair Review - Local Mode</title>
34
30
  <link rel="icon" type="image/png" href="/favicon.png">
35
31
 
36
- <!-- Google Fonts: DM Sans and JetBrains Mono -->
37
- <link rel="preconnect" href="https://fonts.googleapis.com">
38
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
39
- <link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
40
-
41
32
  <!-- PR Display Styles -->
42
33
  <link rel="stylesheet" href="/css/pr.css">
43
34
  <link rel="stylesheet" href="/css/ai-summary-modal.css">
44
35
  <link rel="stylesheet" href="/css/analysis-config.css">
36
+ <link rel="stylesheet" href="/css/snippet-manager.css">
45
37
  <link rel="stylesheet" href="/css/styles.css">
46
38
 
47
- <!-- Highlight.js for syntax highlighting -->
39
+ <!-- Highlight.js for syntax highlighting (legacy/context-file rendering; diffs use @pierre/diffs Shiki) -->
48
40
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css" media="(prefers-color-scheme: light)">
49
41
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css" media="(prefers-color-scheme: dark)">
50
42
 
@@ -56,7 +48,7 @@
56
48
  }
57
49
 
58
50
  body {
59
- font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
51
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
60
52
  background-color: #f6f8fa;
61
53
  color: #24292f;
62
54
  line-height: 1.5;
@@ -80,14 +72,13 @@
80
72
  align-items: center;
81
73
  gap: 6px;
82
74
  padding: 4px 10px;
83
- background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
75
+ background: #7c3aed;
84
76
  color: #ffffff;
85
77
  font-size: 11px;
86
78
  font-weight: 600;
87
79
  text-transform: uppercase;
88
80
  letter-spacing: 0.5px;
89
81
  border-radius: 12px;
90
- box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
91
82
  margin-right: 12px;
92
83
  }
93
84
 
@@ -98,8 +89,7 @@
98
89
 
99
90
  /* Dark theme for local mode badge */
100
91
  [data-theme="dark"] .local-mode-badge {
101
- background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
102
- box-shadow: 0 2px 8px rgba(124, 58, 237, 0.4);
92
+ background: #6d28d9;
103
93
  }
104
94
 
105
95
  /* Branch badge styling for local mode */
@@ -111,7 +101,7 @@
111
101
  background-color: var(--color-bg-tertiary);
112
102
  border: 1px solid var(--color-border-primary);
113
103
  border-radius: 6px;
114
- font-family: 'JetBrains Mono', monospace;
104
+ font-family: var(--font-mono);
115
105
  font-size: 11px;
116
106
  color: var(--color-text-primary);
117
107
  white-space: nowrap;
@@ -189,7 +179,7 @@
189
179
  display: inline-flex;
190
180
  align-items: center;
191
181
  gap: 4px;
192
- font-family: 'JetBrains Mono', monospace;
182
+ font-family: var(--font-mono);
193
183
  font-size: 11px;
194
184
  color: var(--color-text-secondary);
195
185
  max-width: 300px;
@@ -223,7 +213,7 @@
223
213
  padding: 2px 6px;
224
214
  border-radius: 4px;
225
215
  border: 1px dashed var(--color-border-primary);
226
- transition: all 0.15s ease;
216
+ transition: background-color 0.15s ease, border-color 0.15s ease;
227
217
  max-width: 100%;
228
218
  overflow: hidden;
229
219
  text-overflow: ellipsis;
@@ -249,7 +239,7 @@
249
239
  }
250
240
 
251
241
  .local-review-name-input {
252
- font-family: 'DM Sans', -apple-system, sans-serif;
242
+ font-family: var(--font-github);
253
243
  font-size: 15px;
254
244
  font-weight: 500;
255
245
  padding: 2px 6px;
@@ -333,13 +323,11 @@
333
323
  <path d="M8 0a8 8 0 0 1 8 8h-2A6 6 0 0 0 8 2V0Z"/>
334
324
  </svg>
335
325
  </button>
336
- <button class="btn btn-icon" id="theme-toggle" title="Toggle theme">
337
- <svg class="theme-icon-light" viewBox="0 0 16 16" fill="currentColor" width="16" height="16">
326
+ <button class="btn btn-icon" id="theme-toggle" title="Toggle theme" aria-label="Toggle theme">
327
+ <!-- Placeholder icon; the shared helper (js/theme.js) swaps in the icon for the active preference (light/dark/system). -->
328
+ <svg viewBox="0 0 16 16" fill="currentColor" width="16" height="16" aria-hidden="true">
338
329
  <path d="M8 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8Zm0-1.5a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5Zm0-10.5a.75.75 0 0 1 .75.75v1.5a.75.75 0 0 1-1.5 0V.75A.75.75 0 0 1 8 0Zm0 13a.75.75 0 0 1 .75.75v1.5a.75.75 0 0 1-1.5 0v-1.5A.75.75 0 0 1 8 13ZM2.343 2.343a.75.75 0 0 1 1.061 0l1.06 1.061a.75.75 0 0 1-1.06 1.06l-1.06-1.06a.75.75 0 0 1 0-1.06Zm9.193 9.193a.75.75 0 0 1 1.06 0l1.061 1.06a.75.75 0 0 1-1.06 1.061l-1.061-1.06a.75.75 0 0 1 0-1.061ZM16 8a.75.75 0 0 1-.75.75h-1.5a.75.75 0 0 1 0-1.5h1.5A.75.75 0 0 1 16 8ZM3 8a.75.75 0 0 1-.75.75H.75a.75.75 0 0 1 0-1.5h1.5A.75.75 0 0 1 3 8Zm10.657-5.657a.75.75 0 0 1 0 1.061l-1.061 1.06a.75.75 0 1 1-1.06-1.06l1.06-1.06a.75.75 0 0 1 1.06 0Zm-9.193 9.193a.75.75 0 0 1 0 1.06l-1.06 1.061a.75.75 0 0 1-1.061-1.06l1.06-1.061a.75.75 0 0 1 1.061 0Z"/>
339
330
  </svg>
340
- <svg class="theme-icon-dark" viewBox="0 0 16 16" fill="currentColor" width="16" height="16" style="display: none;">
341
- <path d="M9.598 1.591a.749.749 0 0 1 .785-.175 7.001 7.001 0 1 1-8.967 8.967.75.75 0 0 1 .961-.96 5.5 5.5 0 0 0 7.046-7.046.75.75 0 0 1 .175-.786Z"/>
342
- </svg>
343
331
  </button>
344
332
  <button class="btn btn-icon" id="notification-toggle" title="Notification sounds">
345
333
  <svg class="bell-icon-on" viewBox="0 0 16 16" fill="currentColor" width="16" height="16">
@@ -436,9 +424,6 @@
436
424
  <div class="diff-stats" id="diff-stats"></div>
437
425
  <div class="toolbar-actions">
438
426
  <button class="btn btn-sm btn-secondary" id="analyze-btn" title="Analyze with AI">
439
- <svg class="analyze-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="14" height="14">
440
- <path d="M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09z"/>
441
- </svg>
442
427
  <span class="btn-text">Analyze</span>
443
428
  </button>
444
429
  <button class="btn btn-sm btn-icon btn-summary-toggle" id="summary-toggle-btn" title="Hide hunk summaries" aria-label="Toggle hunk summaries" aria-pressed="true" style="display: none;">
@@ -571,10 +556,10 @@
571
556
  </div>
572
557
  </div>
573
558
 
574
- <!-- Diff2Html Library -->
575
- <script src="https://cdn.jsdelivr.net/npm/diff2html@3.4.47/bundles/js/diff2html.min.js"></script>
559
+ <!-- @pierre/diffs - Diff rendering with Shiki syntax highlighting -->
560
+ <script src="/js/vendor/pierre-diffs.js"></script>
576
561
 
577
- <!-- Highlight.js for syntax highlighting -->
562
+ <!-- Highlight.js for legacy/context-file syntax highlighting -->
578
563
  <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
579
564
  <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/elixir.min.js"></script>
580
565
 
@@ -645,6 +630,8 @@
645
630
  <script src="/js/modules/hunk-parser.js"></script>
646
631
  <script src="/js/modules/line-tracker.js"></script>
647
632
  <script src="/js/modules/diff-renderer.js"></script>
633
+ <script src="/js/modules/pierre-context.js"></script>
634
+ <script src="/js/modules/pierre-bridge.js"></script>
648
635
  <script src="/js/modules/comment-manager.js"></script>
649
636
  <script src="/js/modules/suggestion-manager.js"></script>
650
637
  <script src="/js/modules/comment-minimizer.js"></script>
@@ -659,6 +646,7 @@
659
646
  <script src="/js/components/TourBar.js"></script>
660
647
 
661
648
  <!-- Chat Panel Component -->
649
+ <script src="/js/components/SnippetManager.js"></script>
662
650
  <script src="/js/components/ChatPanel.js"></script>
663
651
 
664
652
  <!-- Panel Group Component -->
@@ -679,6 +667,7 @@
679
667
  <script src="/js/repo-links.js"></script>
680
668
 
681
669
  <!-- PR JavaScript (shared with local mode) -->
670
+ <script src="/js/theme.js"></script>
682
671
  <script src="/js/pr.js"></script>
683
672
 
684
673
  <!-- Local Mode JavaScript -->