emdash icon indicating copy to clipboard operation
emdash copied to clipboard

feat(changes-panel): show git indicators on parent folders in tree view

Open Cincinnatus101010 opened this issue 6 months ago • 2 comments

Summary

  • Propagate each changed file's git status to every ancestor directory in the Git Changes tree
  • Show the existing GitChangeStatusIcon on folder rows in tree view (including when collapsed)
  • When a folder has mixed descendant statuses, use the highest-priority status (conflicted → deleted → modified → renamed → added)

Closes #2337

Screenshot 2026-06-02 at 1 10 48 AM

Test plan

  • [x] pnpm exec vitest run src/renderer/features/tasks/diff-view/changes-panel/components/changes-tree-utils.test.ts
  • [x] Manual: open a task with nested unstaged changes, switch Changes panel to tree view
  • [x] Confirm parent folders (src, src/components, etc.) show status icons
  • [x] Collapse a parent folder — icon remains visible on the folder row
  • [x] Confirm flat list view and file-level indicators are unchanged

Cincinnatus101010 avatar Jun 02 '26 08:06 Cincinnatus101010

Greptile Summary

This PR propagates each changed file's git status up to all ancestor directories in the Changes panel tree view, then renders the existing GitChangeStatusIcon on directory rows (including when collapsed). When a directory has descendants with mixed statuses, the highest-priority status wins according to a fixed precedence: conflicted > deleted > modified > renamed > added.

  • changes-tree-utils.ts: adds STATUS_PRIORITY, upsertDirectoryStatus, and a directoryStatusByPath map populated during tree construction; exposes buildDirectoryStatusByPath for testing.
  • virtualized-changes-tree.tsx: threads directoryStatusByPath.get(node.path) into DirectoryRow and conditionally renders GitChangeStatusIcon within the button row.
  • changes-tree-utils.test.ts: new test file covering ancestor propagation, all adjacent priority pairs, sibling isolation with an explicit size guard, root-level files, and buildChangesTree integration.

Confidence Score: 5/5

Safe to merge — the change is additive, well-tested, and touches only the tree-view rendering path without affecting the flat list view or file-level indicators.

The status-propagation logic is correct: every ancestor directory is updated during the same loop that builds the node graph, so directoryStatusByPath and directoryPaths are always in sync. The priority comparison is exhaustive over the full GitChangeStatus union, TypeScript enforces completeness of the STATUS_PRIORITY record, and the undefined-guard in DirectoryRow ensures missing entries degrade gracefully.

No files require special attention.

Important Files Changed

Filename Overview
src/renderer/features/tasks/diff-view/changes-panel/components/changes-tree-utils.ts Adds STATUS_PRIORITY map and upsertDirectoryStatus helper; populates directoryStatusByPath for every ancestor directory during tree construction; exports buildDirectoryStatusByPath wrapper for tests. Logic is correct and exhaustive.
src/renderer/features/tasks/diff-view/changes-panel/components/virtualized-changes-tree.tsx Passes directoryStatusByPath.get(node.path) to DirectoryRow and renders GitChangeStatusIcon when a status is present; safely handles absent status via undefined guard. No layout regressions.
src/renderer/features/tasks/diff-view/changes-panel/components/changes-tree-utils.test.ts New test file covering ancestor propagation, all adjacent priority pairs, sibling isolation with size guard and explicit false-positive check, root-level files, and buildChangesTree integration.

Reviews (2): Last reviewed commit: "test(changes-panel): rename sibling isol..." | Re-trigger Greptile

greptile-apps avatar Jun 02 '26 08:06 greptile-apps

@greptileai

Cincinnatus101010 avatar Jun 02 '26 08:06 Cincinnatus101010

Hi @Cincinnatus101010, thanks for the PR, including the tests and the quick follow-ups on Greptile feedback. This branch has unfortunately fallen out of date with conflicts and we're closing out stale PRs, so I'm going to close it for now. The underlying feature is still something we'd like, if you're up for rebasing onto latest main, feel free to open a fresh PR and we'll take a look. Thanks again!

arnestrickmann avatar Jul 06 '26 23:07 arnestrickmann