@in-the-loop-labs/pair-review 5.4.3 → 5.5.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.
@@ -25,6 +25,21 @@ class AIPanel {
25
25
  </svg>`
26
26
  };
27
27
 
28
+ /** Browser-wide key for the severity sort; the hidden levels are saved per review. */
29
+ static SEVERITY_SORT_STORAGE_KEY = 'pair-review-severity-sort';
30
+
31
+ /** Smallest max-height (px) for the filter menu, so a low funnel still shows a few rows. */
32
+ static FILTER_MENU_MIN_HEIGHT = 120;
33
+
34
+ /** The SeverityFilter helpers (window global in the browser, require in tests). */
35
+ static severityFilter() {
36
+ if (typeof window !== 'undefined' && window.SeverityFilter) return window.SeverityFilter;
37
+ if (typeof module !== 'undefined' && module.exports && typeof require === 'function') {
38
+ return require('../utils/severity-filter.js');
39
+ }
40
+ throw new Error('SeverityFilter is not loaded');
41
+ }
42
+
28
43
  constructor() {
29
44
  this.panel = document.getElementById('ai-panel');
30
45
  // Check actual DOM state for collapsed status
@@ -53,6 +68,12 @@ class AIPanel {
53
68
  this.showDismissedComments = false;
54
69
  // User comments the filters hide, counted by PRManager from its data
55
70
  this.hiddenCommentCounts = { posted: 0, dismissed: 0 };
71
+ // Severity sort/filter for AI suggestions: the sort is browser-wide and
72
+ // the hidden severities are per review (see restoreSeverityState).
73
+ // severityHiddenCount is how many AI suggestions the filter hides, for
74
+ // the list notice.
75
+ this.severityState = AIPanel.severityFilter().defaultSeverityState();
76
+ this.severityHiddenCount = 0;
56
77
 
57
78
  this.initElements();
58
79
  this.bindEvents();
@@ -126,10 +147,11 @@ class AIPanel {
126
147
  }
127
148
 
128
149
  /**
129
- * Create the comment filter menu: a funnel button at the right of the
130
- * segment row that opens a small popover of labeled options. The options
131
- * only affect user comments. Local mode has no posted comments, so it
132
- * gets no "Show posted" option.
150
+ * Create the filter menu: a funnel button at the right of the segment row
151
+ * that opens a small popover of labeled options. The severity options sort
152
+ * and filter AI suggestions in the panel; the other options affect user
153
+ * comments. Local mode has no posted comments, so it gets no "Show posted"
154
+ * option.
133
155
  */
134
156
  createFilterMenu() {
135
157
  const wrapper = document.createElement('div');
@@ -146,13 +168,29 @@ class AIPanel {
146
168
  menu.className = 'comment-filter-menu';
147
169
  menu.id = 'comment-filter-menu';
148
170
  menu.setAttribute('role', 'group');
149
- menu.setAttribute('aria-label', 'User comment filters');
171
+ menu.setAttribute('aria-label', 'Review filters');
150
172
  menu.hidden = true;
151
173
  const postedOption = this._isLocalMode() ? '' : `
152
174
  <label class="comment-filter-option">
153
175
  <input type="checkbox" data-filter="showPosted"> Show posted
154
176
  </label>`;
177
+ const { SEVERITY_LEVELS, SEVERITY_LABELS } = AIPanel.severityFilter();
178
+ const severityOptions = SEVERITY_LEVELS.map(level => `
179
+ <label class="comment-filter-option">
180
+ <input type="checkbox" data-severity="${level}"> <span class="severity-option-label severity-option-${level}">${SEVERITY_LABELS[level]}</span>
181
+ </label>`).join('');
155
182
  menu.innerHTML = `
183
+ <div class="comment-filter-section" data-section="severity">
184
+ <div class="comment-filter-menu-title">Sort AI suggestions</div>
185
+ <label class="comment-filter-option">
186
+ <input type="radio" name="severity-sort" data-severity-sort="file"> File order
187
+ </label>
188
+ <label class="comment-filter-option">
189
+ <input type="radio" name="severity-sort" data-severity-sort="severity"> Severity
190
+ </label>
191
+ <div class="comment-filter-menu-title">Show in panel</div>${severityOptions}
192
+ </div>
193
+ <div class="comment-filter-menu-divider" role="separator"></div>
156
194
  <div class="comment-filter-menu-title">User comments</div>
157
195
  <label class="comment-filter-option">
158
196
  <input type="checkbox" data-filter="showDismissed"> Show dismissed
@@ -174,6 +212,17 @@ class AIPanel {
174
212
  });
175
213
  menu.addEventListener('change', (e) => {
176
214
  const input = e.target;
215
+ if (input?.dataset?.severitySort) {
216
+ if (input.checked) this.setSeverityState({ sort: input.dataset.severitySort });
217
+ return;
218
+ }
219
+ if (input?.dataset?.severity) {
220
+ const level = input.dataset.severity;
221
+ const hidden = this.severityState.hidden.filter(l => l !== level);
222
+ if (!input.checked) hidden.push(level);
223
+ this.setSeverityState({ hidden });
224
+ return;
225
+ }
177
226
  if (!input?.dataset?.filter) return;
178
227
  this.setCommentFilter({ [input.dataset.filter]: input.checked });
179
228
  });
@@ -212,8 +261,23 @@ class AIPanel {
212
261
  this.filterMenuBtn.setAttribute('aria-expanded', 'true');
213
262
  // Lift the segment row above the panel sections below it (pr.css)
214
263
  this.segmentControl?.classList.add('comment-filter-open');
264
+ this._fitFilterMenuToViewport();
215
265
  document.addEventListener('pointerdown', this._onFilterMenuOutsidePointer, true);
216
- this.filterMenu.querySelector('input')?.focus();
266
+ // Enter the menu on the checked radio, as native radio groups do
267
+ (this.filterMenu.querySelector('input:checked') || this.filterMenu.querySelector('input'))?.focus();
268
+ }
269
+
270
+ /**
271
+ * Limit the open menu to the space below the funnel so it scrolls instead
272
+ * of running off the window (the page itself cannot scroll, and stacked
273
+ * layouts put the funnel low on the screen).
274
+ * @private
275
+ */
276
+ _fitFilterMenuToViewport() {
277
+ if (!this.filterMenu || !this.filterMenuBtn || typeof window === 'undefined') return;
278
+ const gap = 4 + 8; // menu offset below the button + breathing room at the window edge
279
+ const available = window.innerHeight - this.filterMenuBtn.getBoundingClientRect().bottom - gap;
280
+ this.filterMenu.style.maxHeight = `${Math.max(AIPanel.FILTER_MENU_MIN_HEIGHT, Math.floor(available))}px`;
217
281
  }
218
282
 
219
283
  /**
@@ -332,9 +396,13 @@ class AIPanel {
332
396
  */
333
397
  updateFilterMenuVisual() {
334
398
  if (!this.filterMenuBtn) return;
335
- const nonDefault = this.isCommentFilterNonDefault();
399
+ // The dot means "this review hides something". The severity sort is a
400
+ // browser-wide preference, so like the browser-wide "hide posted"
401
+ // setting it never lights the dot; hidden severities do.
402
+ const nonDefault = this.isCommentFilterNonDefault()
403
+ || this.severityState.hidden.length > 0;
336
404
  this.filterMenuBtn.classList.toggle('has-active-filter', nonDefault);
337
- const label = nonDefault ? 'Filter user comments (filters on)' : 'Filter user comments';
405
+ const label = nonDefault ? 'Sort and filter (filters on)' : 'Sort and filter';
338
406
  this.filterMenuBtn.title = label;
339
407
  this.filterMenuBtn.setAttribute('aria-label', label);
340
408
 
@@ -343,6 +411,65 @@ class AIPanel {
343
411
  if (dismissedInput) dismissedInput.checked = state.includeDismissed;
344
412
  const postedInput = this.filterMenu?.querySelector('input[data-filter="showPosted"]');
345
413
  if (postedInput) postedInput.checked = state.showPosted;
414
+
415
+ const { sort, hidden } = this.severityState;
416
+ this.filterMenu?.querySelectorAll('input[data-severity-sort]').forEach(input => {
417
+ input.checked = input.dataset.severitySort === sort;
418
+ });
419
+ this.filterMenu?.querySelectorAll('input[data-severity]').forEach(input => {
420
+ input.checked = !hidden.includes(input.dataset.severity);
421
+ });
422
+ }
423
+
424
+ /**
425
+ * Change the AI suggestion severity sort/filter as the user asked: persist
426
+ * it, update the menu and re-render the list. AI suggestions are already
427
+ * loaded, so nothing reloads.
428
+ * @param {{sort?: 'file'|'severity', hidden?: string[]}} updates
429
+ * @returns {boolean} Whether anything changed
430
+ */
431
+ setSeverityState(updates = {}) {
432
+ const lib = AIPanel.severityFilter();
433
+ const next = lib.parseSeverityState({ ...this.severityState, ...updates });
434
+ const prev = this.severityState;
435
+ const sortChanged = next.sort !== prev.sort;
436
+ const hiddenChanged = next.hidden.join() !== prev.hidden.join();
437
+ const changed = sortChanged || hiddenChanged;
438
+ // Navigation updates the index, so capture its identity using the old
439
+ // sort/filter before changing which items that index refers to.
440
+ if (changed) this.saveCurrentSelection();
441
+ this.severityState = next;
442
+ this.updateFilterMenuVisual();
443
+ if (!changed) return false;
444
+
445
+ this.saveSeverityState({ sort: sortChanged, hidden: hiddenChanged });
446
+ this.renderFindings();
447
+ if (!this.restoreSelection()) {
448
+ this.selectedItemKey = null;
449
+ this.currentIndex = -1;
450
+ this.autoSelectFirst();
451
+ }
452
+ return true;
453
+ }
454
+
455
+ /** Show every severity again (the notice's Show button). Keeps the sort. */
456
+ showAllSeverities() {
457
+ return this.setSeverityState({ hidden: [] });
458
+ }
459
+
460
+ /**
461
+ * The muted "N AI suggestions hidden from this list — Show all" line, or ''
462
+ * when the severity filter hides nothing in this segment.
463
+ */
464
+ renderHiddenSeverityNotice() {
465
+ const count = this.severityHiddenCount;
466
+ if (!count || (this.selectedSegment !== 'ai' && this.selectedSegment !== 'all')) return '';
467
+ const noun = count === 1 ? 'AI suggestion' : 'AI suggestions';
468
+ return `
469
+ <div class="hidden-severity-notice">
470
+ <span>${count} ${noun} hidden from this list</span> —
471
+ <button type="button" class="hidden-severity-show" aria-label="Show AI suggestions of every severity">Show all</button>
472
+ </div>`;
346
473
  }
347
474
 
348
475
  /**
@@ -484,6 +611,67 @@ class AIPanel {
484
611
  return `pair-review-show-posted_${this.currentPRKey}`;
485
612
  }
486
613
 
614
+ /**
615
+ * Get the localStorage key for this review's hidden severities (per-review).
616
+ * The sort is browser-wide instead (AIPanel.SEVERITY_SORT_STORAGE_KEY): it
617
+ * is how the reviewer likes to work, while which severities to hide
618
+ * depends on the review.
619
+ * @returns {string|null} Storage key or null if no PR context
620
+ */
621
+ getSeverityStorageKey() {
622
+ if (!this.currentPRKey) return null;
623
+ return `pair-review-severity-hidden_${this.currentPRKey}`;
624
+ }
625
+
626
+ /**
627
+ * Save what the reviewer changed: the severity sort (browser-wide, last
628
+ * choice wins) and/or this review's hidden severities. A tab only writes
629
+ * the setting it changed, so another tab's choice for the other one is
630
+ * never overwritten with this tab's stale copy. Default values remove the
631
+ * entry.
632
+ * @param {{sort?: boolean, hidden?: boolean}} [scope] - What to write (both by default)
633
+ */
634
+ saveSeverityState({ sort: saveSort = true, hidden: saveHidden = true } = {}) {
635
+ const { sort, hidden } = this.severityState;
636
+ if (saveSort) {
637
+ if (sort === 'file') {
638
+ localStorage.removeItem(AIPanel.SEVERITY_SORT_STORAGE_KEY);
639
+ } else {
640
+ localStorage.setItem(AIPanel.SEVERITY_SORT_STORAGE_KEY, sort);
641
+ }
642
+ }
643
+
644
+ const key = this.getSeverityStorageKey();
645
+ if (saveHidden && key) {
646
+ if (hidden.length === 0) {
647
+ localStorage.removeItem(key);
648
+ } else {
649
+ localStorage.setItem(key, JSON.stringify(hidden));
650
+ }
651
+ }
652
+ }
653
+
654
+ /**
655
+ * Restore the severity sort (browser-wide) and this review's hidden
656
+ * severities. Missing or corrupt entries fall back to the defaults.
657
+ */
658
+ restoreSeverityState() {
659
+ const lib = AIPanel.severityFilter();
660
+ const sort = localStorage.getItem(AIPanel.SEVERITY_SORT_STORAGE_KEY);
661
+
662
+ let hidden = [];
663
+ const key = this.getSeverityStorageKey();
664
+ const storedHidden = key ? localStorage.getItem(key) : null;
665
+ if (storedHidden) {
666
+ try {
667
+ hidden = JSON.parse(storedHidden);
668
+ } catch {
669
+ hidden = [];
670
+ }
671
+ }
672
+ this.severityState = lib.parseSeverityState({ sort, hidden });
673
+ }
674
+
487
675
  /**
488
676
  * Save the "Show dismissed" filter to localStorage (per-review)
489
677
  */
@@ -509,6 +697,7 @@ class AIPanel {
509
697
  const key = this.getFilterStorageKey();
510
698
  // Default to false (hidden) for new reviews
511
699
  this.showDismissedComments = key ? localStorage.getItem(key) === 'true' : false;
700
+ this.restoreSeverityState();
512
701
 
513
702
  // "Show posted": this review's override, if any. Local mode has no
514
703
  // posted comments and so no override.
@@ -565,8 +754,10 @@ class AIPanel {
565
754
  setPR(owner, repo, number) {
566
755
  this.currentPRKey = `${owner}/${repo}#${number}`;
567
756
  this._restoreOrCollapsePanel();
568
- this.restoreSegmentSelection();
757
+ // Restore the filters first: restoreSegmentSelection renders the list,
758
+ // and the render must see this review's severity sort and filter.
569
759
  this.restoreFilterState();
760
+ this.restoreSegmentSelection();
570
761
 
571
762
  // If the external-comment manager finished its initial fetch BEFORE
572
763
  // the panel was wired up (race on slow loads), pull the threads it
@@ -908,8 +1099,13 @@ class AIPanel {
908
1099
  break;
909
1100
  }
910
1101
 
911
- // Sort by canonical file order, then file-level first, then line number
912
- return this.sortItemsByFileOrder(items);
1102
+ // Sort by canonical file order, then file-level first, then line
1103
+ // number; then apply the severity filter and (optional) severity sort,
1104
+ // which is stable so equal severities stay in file order.
1105
+ const result = AIPanel.severityFilter().applySeverityState(
1106
+ this.sortItemsByFileOrder(items), this.severityState);
1107
+ this.severityHiddenCount = result.hiddenCount;
1108
+ return result.items;
913
1109
  }
914
1110
 
915
1111
  /**
@@ -976,7 +1172,7 @@ class AIPanel {
976
1172
 
977
1173
  const items = this.getFilteredItems();
978
1174
  // "N posted · M dismissed hidden — Show", or '' when nothing is hidden
979
- const hiddenNotice = this.renderHiddenCommentsNotice();
1175
+ const hiddenNotice = this.renderHiddenSeverityNotice() + this.renderHiddenCommentsNotice();
980
1176
 
981
1177
  // Show empty state based on segment and analysis state
982
1178
  if (items.length === 0) {
@@ -993,6 +1189,14 @@ class AIPanel {
993
1189
  <div class="empty-state-title">No comments yet</div>
994
1190
  <div class="empty-state-description">Click the <strong>+</strong> button next to any line to add a comment.</div>
995
1191
  `;
1192
+ } else if ((this.selectedSegment === 'ai' || this.selectedSegment === 'all')
1193
+ && this.severityHiddenCount > 0) {
1194
+ // Nothing else to show (in All: no comments or threads either)
1195
+ emptyContent = `
1196
+ <div class="empty-state-icon">${this.getEmptyStateIcon('sparkle')}</div>
1197
+ <div class="empty-state-title">No suggestions shown</div>
1198
+ <div class="empty-state-description">The severity filter hides every AI suggestion.</div>
1199
+ `;
996
1200
  } else if (this.selectedSegment === 'ai') {
997
1201
  // Show different states based on analysis status
998
1202
  if (this.analysisState === 'loading') {
@@ -1140,6 +1344,13 @@ class AIPanel {
1140
1344
  this.showHiddenComments();
1141
1345
  });
1142
1346
  }
1347
+ const severityBtn = this.findingsList?.querySelector('.hidden-severity-show');
1348
+ if (severityBtn) {
1349
+ severityBtn.addEventListener('click', (e) => {
1350
+ e.stopPropagation();
1351
+ this.showAllSeverities();
1352
+ });
1353
+ }
1143
1354
  }
1144
1355
 
1145
1356
  /**
@@ -1,9 +1,13 @@
1
1
  // Copyright 2026 Tim Perkins (tjwp) | SPDX-License-Identifier: Apache-2.0
2
2
  /**
3
3
  * Toast Notification Component
4
- * Shows temporary success/error/warning/info messages at the top of the page
4
+ * Shows temporary success/error/warning/info messages at the top of the page.
5
+ * Each toast closes on its timer, or at once when the user clicks its close button.
5
6
  */
6
7
  class Toast {
8
+ // Length of the fade-out animation before the toast node is removed
9
+ static FADE_MS = 300;
10
+
7
11
  constructor() {
8
12
  this.toastContainer = null;
9
13
  this.activeToasts = [];
@@ -134,6 +138,8 @@ class Toast {
134
138
  * @param {number} duration - Duration in ms
135
139
  */
136
140
  showToast(toast, duration) {
141
+ this.addCloseButton(toast);
142
+
137
143
  // Add to container
138
144
  this.toastContainer.appendChild(toast);
139
145
  this.activeToasts.push(toast);
@@ -144,22 +150,46 @@ class Toast {
144
150
  }, 10);
145
151
 
146
152
  // Auto dismiss after duration
147
- setTimeout(() => {
153
+ toast._dismissTimer = setTimeout(() => {
148
154
  this.dismissToast(toast);
149
155
  }, duration);
150
156
  }
151
157
 
158
+ /**
159
+ * Append a close button to the toast's content row
160
+ * @param {HTMLElement} toast - The toast element
161
+ */
162
+ addCloseButton(toast) {
163
+ const content = toast.querySelector('.toast-content');
164
+ if (!content || content.querySelector('.toast-close')) return;
165
+
166
+ const button = document.createElement('button');
167
+ button.type = 'button';
168
+ button.className = 'toast-close';
169
+ button.setAttribute('aria-label', 'Dismiss notification');
170
+ button.innerHTML = `
171
+ <svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
172
+ <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path>
173
+ </svg>
174
+ `;
175
+ button.addEventListener('click', () => this.dismissToast(toast));
176
+ content.appendChild(button);
177
+ }
178
+
152
179
  /**
153
180
  * Dismiss a specific toast
154
181
  * @param {HTMLElement} toast - The toast element to dismiss
155
182
  */
156
183
  dismissToast(toast) {
157
184
  if (!toast || !toast.parentNode) return;
185
+ if (toast.classList.contains('toast-fade-out')) return;
186
+
187
+ clearTimeout(toast._dismissTimer);
158
188
 
159
189
  // Add fade-out class
160
190
  toast.classList.add('toast-fade-out');
161
191
 
162
- // Remove after fade animation (300ms)
192
+ // Remove after fade animation
163
193
  setTimeout(() => {
164
194
  if (toast.parentNode) {
165
195
  toast.parentNode.removeChild(toast);
@@ -170,7 +200,7 @@ class Toast {
170
200
  if (index > -1) {
171
201
  this.activeToasts.splice(index, 1);
172
202
  }
173
- }, 300);
203
+ }, Toast.FADE_MS);
174
204
  }
175
205
 
176
206
  /**
@@ -190,4 +220,9 @@ if (typeof window !== 'undefined' && !window.toast) {
190
220
  } else {
191
221
  window.toast = new Toast();
192
222
  }
223
+ }
224
+
225
+ // Export for CommonJS testing environments
226
+ if (typeof module !== 'undefined' && module.exports) {
227
+ module.exports = { Toast };
193
228
  }
package/public/js/pr.js CHANGED
@@ -7835,16 +7835,20 @@ class PRManager {
7835
7835
  return 'modified';
7836
7836
  }
7837
7837
 
7838
- groupFilesByDirectory(files) {
7839
- const groups = {};
7840
- files.forEach(file => {
7838
+ /**
7839
+ * Build the file navigator's directory tree. Directories that only contain
7840
+ * a single subdirectory are collapsed into one node (e.g. `src/js/utils`),
7841
+ * so long shared prefixes take one row instead of one row per segment.
7842
+ * @param {Array} files - Diff/context file entries
7843
+ * @returns {Object} Root node from FileOrderUtils.buildDirectoryTree whose
7844
+ * `files` are navigator items and `dirs` are nested nodes
7845
+ */
7846
+ buildFileNavigatorTree(files) {
7847
+ const items = files.map(file => {
7841
7848
  const filePath = file.file;
7842
7849
  const lastSlashIndex = filePath.lastIndexOf('/');
7843
- const dirPath = lastSlashIndex === -1 ? '.' : filePath.substring(0, lastSlashIndex);
7844
7850
  const fileName = lastSlashIndex === -1 ? filePath : filePath.substring(lastSlashIndex + 1);
7845
-
7846
- if (!groups[dirPath]) groups[dirPath] = [];
7847
- groups[dirPath].push({
7851
+ return {
7848
7852
  name: fileName,
7849
7853
  fullPath: filePath,
7850
7854
  status: this.getFileStatus(file),
@@ -7859,14 +7863,9 @@ class PRManager {
7859
7863
  label: file.label || null,
7860
7864
  lineStart: file.lineStart || null,
7861
7865
  lineEnd: file.lineEnd || null,
7862
- });
7863
- });
7864
-
7865
- const sortedGroups = {};
7866
- Object.keys(groups).sort().forEach(key => {
7867
- sortedGroups[key] = groups[key];
7866
+ };
7868
7867
  });
7869
- return sortedGroups;
7868
+ return window.FileOrderUtils.buildDirectoryTree(items, item => item.fullPath);
7870
7869
  }
7871
7870
 
7872
7871
  updateFileList(files) {
@@ -7887,22 +7886,27 @@ class PRManager {
7887
7886
  return;
7888
7887
  }
7889
7888
 
7890
- const groupedFiles = this.groupFilesByDirectory(files);
7889
+ const tree = this.buildFileNavigatorTree(files);
7891
7890
  fileListContainer.innerHTML = '';
7892
7891
 
7893
- for (const [dirPath, dirFiles] of Object.entries(groupedFiles)) {
7894
- const groupElement = this.renderFileGroup(dirPath, dirFiles);
7895
- fileListContainer.appendChild(groupElement);
7896
- }
7892
+ // Root-level files sit directly in the list, followed by top-level folders
7893
+ tree.files.forEach(file => fileListContainer.appendChild(this.renderFileItem(file)));
7894
+ tree.dirs.forEach(dir => fileListContainer.appendChild(this.renderFileGroup(dir)));
7897
7895
  }
7898
7896
 
7899
- renderFileGroup(dirPath, files) {
7897
+ /**
7898
+ * Render a directory node and, recursively, its subdirectories.
7899
+ * @param {{name: string, path: string, files: Array, dirs: Array}} node
7900
+ * @returns {HTMLElement}
7901
+ */
7902
+ renderFileGroup(node) {
7900
7903
  const group = document.createElement('div');
7901
7904
  group.className = 'file-group';
7902
- group.dataset.path = dirPath;
7905
+ group.dataset.path = node.path;
7903
7906
 
7904
7907
  const header = document.createElement('div');
7905
7908
  header.className = 'file-group-header';
7909
+ header.title = node.path;
7906
7910
 
7907
7911
  const chevron = document.createElement('span');
7908
7912
  chevron.className = 'file-group-chevron';
@@ -7913,7 +7917,8 @@ class PRManager {
7913
7917
  folderIcon.innerHTML = `<svg viewBox="0 0 16 16" fill="currentColor" width="14" height="14"><path d="M1.75 1A1.75 1.75 0 000 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0016 13.25v-8.5A1.75 1.75 0 0014.25 3H7.5a.25.25 0 01-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75z"/></svg>`;
7914
7918
 
7915
7919
  const dirName = document.createElement('span');
7916
- dirName.textContent = dirPath === '.' ? '(root)' : dirPath;
7920
+ dirName.className = 'file-group-name';
7921
+ dirName.textContent = node.name;
7917
7922
 
7918
7923
  header.appendChild(chevron);
7919
7924
  header.appendChild(folderIcon);
@@ -7923,10 +7928,8 @@ class PRManager {
7923
7928
  const fileList = document.createElement('div');
7924
7929
  fileList.className = 'file-group-items';
7925
7930
 
7926
- files.forEach(file => {
7927
- const fileItem = this.renderFileItem(file);
7928
- fileList.appendChild(fileItem);
7929
- });
7931
+ node.files.forEach(file => fileList.appendChild(this.renderFileItem(file)));
7932
+ node.dirs.forEach(dir => fileList.appendChild(this.renderFileGroup(dir)));
7930
7933
 
7931
7934
  group.appendChild(fileList);
7932
7935
  group.classList.add('expanded');