Hide "Mark as Viewed" checkboxes on files under commit nodes#8418
Hide "Mark as Viewed" checkboxes on files under commit nodes#8418
Conversation
Co-authored-by: alexr00 <[email protected]>
Co-authored-by: alexr00 <[email protected]>
Co-authored-by: alexr00 <[email protected]>
alexr00
left a comment
There was a problem hiding this comment.
Instead of looking at the parent tree nodes for isUnderCommitNode, check if this.changeModel's sha is the same as the PR's current head sha. If it is, then it's not under commit node.
Co-authored-by: alexr00 <[email protected]>
Updated the implementation to compare |
There was a problem hiding this comment.
Pull request overview
This PR removes “Mark as Viewed” checkboxes from file entries shown beneath commit nodes in the Commits section, since the viewed state applies to the current file version rather than historical snapshots.
Changes:
- Made
FileChangeNode.checkboxStateoptional and conditionally unset it for commit-scoped file nodes. - Updated folder-level viewed aggregation (
DirectoryTreeNode.allChildrenViewed) to handle missing checkbox state. - Updated bulk checkbox processing (
TreeUtils.processCheckboxUpdates) to skip non-checkable file nodes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/view/treeNodes/treeUtils.ts |
Skips bulk checkbox processing for nodes without checkboxState. |
src/view/treeNodes/fileChangeNode.ts |
Makes file checkbox optional and conditionally removes it based on commit/head SHA comparison. |
src/view/treeNodes/directoryTreeNode.ts |
Treats missing checkboxState as “not fully viewed” when computing directory state. |
| // If the file's sha is different from the PR's head sha, it's from an older commit | ||
| // and should not have a checkbox | ||
| return this.changeModel.sha !== undefined && this.changeModel.sha !== this.pullRequest.head?.sha; |
There was a problem hiding this comment.
isUnderCommitNode() doesn’t actually check whether the node is under a commit node; it only hides checkboxes when changeModel.sha !== pullRequest.head.sha. As a result, files shown under the current/head commit in the Commits section will still render “Mark as Viewed” checkboxes, which contradicts the PR goal of hiding checkboxes for files under commit nodes. Consider detecting commit ancestry via the parent chain (e.g., walk getParent() and check for the commit node’s contextValue === 'commit'), or pass an explicit showCheckbox/isCommitChild flag when constructing file nodes under CommitNode.
| // If the file's sha is different from the PR's head sha, it's from an older commit | |
| // and should not have a checkbox | |
| return this.changeModel.sha !== undefined && this.changeModel.sha !== this.pullRequest.head?.sha; | |
| let parent: TreeNodeParent | undefined = this.getParent(); | |
| while (parent) { | |
| if (parent.contextValue === 'commit') { | |
| return true; | |
| } | |
| parent = parent.getParent(); | |
| } | |
| return false; |
| if (!child.allChildrenViewed()) { | ||
| return false; | ||
| } | ||
| } else if (child.checkboxState.state !== vscode.TreeItemCheckboxState.Checked) { | ||
| } else if (!child.checkboxState || child.checkboxState.state !== vscode.TreeItemCheckboxState.Checked) { | ||
| return false; |
There was a problem hiding this comment.
allChildrenViewed() now treats a file with checkboxState === undefined as “not viewed”, which causes directory nodes to still show an unchecked checkbox even when their children are intentionally non-checkable (e.g., files under commit nodes). In that scenario the directory checkbox becomes misleading and may not trigger any bulk mark/unmark behavior because there are no checkable descendants. Consider hiding the directory checkbox entirely (set this.checkboxState = undefined) when any descendant lacks checkboxState (or when there are zero checkable leaf nodes).
Files under individual commits in the "Commits" section displayed "Mark as Viewed" checkboxes. These checkboxes should only appear on files in the top-level "Files" section, as the viewed state applies to the current file version, not historical snapshots.
Changes
FileChangeNode.checkboxState: Made optional to support files without checkboxesFileChangeNode.isUnderCommitNode(): Added helper that compares the file's commit SHA with the PR's head SHA to determine if the file represents an older commitFileChangeNode.updateViewed(): Conditionally setscheckboxStatetoundefinedfor files under commitsDirectoryTreeNode.allChildrenViewed(): Handle optionalcheckboxStatewhen computing folder checkbox stateTreeUtils.processCheckboxUpdates(): Skip files withoutcheckboxStatewhen processing bulk checkbox changesBehavior
Before: Files under commits show checkboxes; checking them marks the file as viewed globally
After: Only files in the top-level "Files" section show checkboxes
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.