Skip to content

feat(ui): embeddable read-only DiffFileTree shared with the code-review tree - #1678

Merged
backnotprop merged 1 commit into
mainfrom
feat/ui-diff-file-tree
Oct 4, 2026
Merged

backnotprop merged 1 commit into
mainfrom
feat/ui-diff-file-tree

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

Adds @plannotator/ui/components/DiffFileTree, a read-only file tree a host can put beside its own per-file diff list (asked for by Pando). It is the code-review tree, not a copy: the shared parts moved from packages/review-editor into @plannotator/ui, and the review now renders from them. No release and no version bumps.

The export

<DiffFileTree files={files} selectedPath={selected} onSelect={setSelected} />
  • Required: files: { path; oldPath?; status: 'added' | 'modified' | 'deleted' | 'renamed' | 'binary'; additions; deletions }[], selectedPath: string | null, onSelect(path).
  • Optional: defaultExpanded ('all' default, 'none', or folder paths), label (accessible name, default "Changed files"), className.
  • Same folder merging, sort, change letters, +/- counts, chevrons and indentation as the review. role="tree" / treeitem with aria-level, aria-expanded, aria-selected and one tab stop.
  • Keyboard works only while focus is in the tree. ArrowDown/j, ArrowUp/k, Home and End select files in tree order, the same keys the review uses. ArrowRight/ArrowLeft open and close folders.
  • If the host passes a new files array with the same content, folder state is kept. It resets only when the content changes.

What moved where

From packages/review-editor To @plannotator/ui
utils/buildFileTree.ts utils/diffFileTree.ts (generic buildDiffFileTree<F>); the review file is now a re-export shim with its old names
FileTree.tsx folder-expansion state hooks/useDiffFileTreeExpansion.ts
FileTreeNode.tsx folder button, file-row layout, indent components/DiffFileTree.tsx: DiffFileTreeFolderRow, DiffFileTreeFileRowContent, diffFileTreeIndent
FileRowBits.tsx ChangeTypeLetter, DiffCounts components/DiffFileTree.tsx, re-exported from FileRowBits

These stay in the review only: viewed and stage controls, the hide-viewed filter, annotation badge and tint, scroll highlight, the context menu, double-click, pickers, search, nav rows, and the window-wide j/k shortcut. The review's rows keep their DOM exactly as before; no ARIA roles were added there.

Verification

  • bun run typecheck (including the strict-consumer config, which now covers a compile-only consumer of the new export), full bun test (5927 pass, 0 fail), and the CI DOM list with the new DiffFileTree.test.tsx (1392 pass). The DOM allowlist guard passes.
  • bun run --cwd packages/ui smoke:package now also requires and imports DiffFileTree from the packed tarball.
  • bun run --cwd apps/review build && bun run build:hook.
  • Live parity check. I built the CLI from main and from this branch into /tmp (temp PLANNOTATOR_DATA_DIR, headless Chromium 1243 with --use-mock-keychain --password-store=basic) and ran plannotator review --patch-file on the same fixture: merged chains, A/D/R/M files, nested folders. I took the sidebar screenshot three times: at rest, after j j, and after collapsing a folder. All three screenshots and the sidebar outerHTML were byte-identical between main and this branch.

Not verified in a browser: the standalone DiffFileTree inside a host page. Its behavior is covered by the DOM tests.

…iew file tree

Move the review's pure tree builder, folder-expansion state and row atoms
into @plannotator/ui and render the review's tree from them; add the
DiffFileTree component (files / selectedPath / onSelect) with ARIA tree
semantics and tree-scoped keyboard navigation for hosts.
@backnotprop
backnotprop merged commit 4ed6f88 into main Oct 4, 2026
28 checks passed
@backnotprop
backnotprop deleted the feat/ui-diff-file-tree branch October 4, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant