Skip to content

Fix: Re-parent pulled-up directory children to ensure proper checkbox refresh#8679

Open
MaxDNG wants to merge 2 commits intomicrosoft:mainfrom
MaxDNG:fix/folder-checkbox-parent-reparenting
Open

Fix: Re-parent pulled-up directory children to ensure proper checkbox refresh#8679
MaxDNG wants to merge 2 commits intomicrosoft:mainfrom
MaxDNG:fix/folder-checkbox-parent-reparenting

Conversation

@MaxDNG
Copy link
Copy Markdown

@MaxDNG MaxDNG commented Apr 20, 2026

Fixes #8646

This pull request addresses a bug where directory tree nodes that are promoted to the parent node (when the root directory label is empty) were not correctly updating their parent references. The changes ensure that child nodes have their parent property set correctly when they are moved up in the tree. This improves the consistency and correctness of the tree structure in the UI.

Tree node parenting fixes:

  • In commitNode.ts, when flattening root directory nodes, each child’s parent is now set to the current node before being promoted to the parent.
  • In filesCategoryNode.ts, after flattening root directory nodes, each child’s parent is set to the current node to maintain correct parent relationships.
  • In pullRequestNode.ts, when promoting children of a root directory node, each child’s parent is set appropriately before being added to the parent.

MaxDNG added 2 commits April 20, 2026 15:50
… refresh

When the tree has multiple top-level directories, a temporary DirectoryTreeNode
is created to build the tree, then its children are pulled up to the parent.
However, the children's parent pointers still referenced the phantom root,
causing processCheckboxUpdates to refresh an invisible node, so checkbox state
never updated visually.

Re-parent all pulled-up children to the actual container node (FilesCategoryNode,
PullRequestNode, or CommitNode) so ancestor walks target visible tree nodes.
…ilding

Add tests to verify that pulled-up directory children are correctly re-parented
to the container node, not the phantom root. This ensures processCheckboxUpdates
can walk ancestors and find visible tree nodes for refresh() calls.

Tests cover:
- getParent() correctly returns undefined after re-parenting
- ancestor walk stops at topmost visible directory, not phantom root
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a tree-view checkbox refresh bug caused by “phantom root” DirectoryTreeNode instances (label '') retaining parent pointers after their children are promoted to the real container node.

Changes:

  • Re-parent pulled-up directory children to the actual container in PR, commit, and files category tree nodes.
  • Add a regression test covering parent-pointer behavior after phantom-root promotion.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/view/treeNodes/pullRequestNode.ts Re-parents children promoted from a phantom root to the PRNode so checkbox refresh targets visible nodes.
src/view/treeNodes/filesCategoryNode.ts Re-parents children promoted from a phantom root to FilesCategoryNode to keep the rendered hierarchy consistent.
src/view/treeNodes/commitNode.ts Re-parents children promoted from a phantom root to the CommitNode for correct ancestor refresh behavior.
src/test/view/treeNodes/directoryTreeNode.test.ts Adds coverage for parent-chain behavior when a phantom root’s children are pulled up.

Comment thread src/test/view/treeNodes/directoryTreeNode.test.ts
@MaxDNG
Copy link
Copy Markdown
Author

MaxDNG commented Apr 20, 2026

@microsoft-github-policy-service agree

@Eiji-Kudo
Copy link
Copy Markdown

Eiji-Kudo commented May 6, 2026

Confirmed working locally on top of current main (v0.142.0)!

Screen.Recording.2026-05-06.at.19.13.32.mov

Cherry-picked the two commits from this PR onto origin/main, built and installed the VSIX. After reload, parent folder checkboxes now auto-check correctly when all child files are marked as viewed, and the "Refresh" workaround from #8646 is no longer needed.

Hope this gets merged soon — thanks for tracking down the root cause (the missing parent re-assignment after the phantom-root pull-up).

@alexr00 alexr00 added this to the 1.120.0 milestone May 6, 2026
@alexr00 alexr00 self-assigned this May 6, 2026
@alexr00 alexr00 enabled auto-merge (squash) May 6, 2026 15:34
Copy link
Copy Markdown
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix!

Copy link
Copy Markdown
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/AzurePipelines run

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.

Reopening - Parent folder checkbox not auto-checked when all children are marked as viewed

5 participants