Skip to content

Hide "Mark as Viewed" checkboxes on files under commit nodes#8418

Merged
alexr00 merged 6 commits intomainfrom
copilot/fix-mark-as-viewed-issue
Jan 26, 2026
Merged

Hide "Mark as Viewed" checkboxes on files under commit nodes#8418
alexr00 merged 6 commits intomainfrom
copilot/fix-mark-as-viewed-issue

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

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 checkboxes
  • FileChangeNode.isUnderCommitNode(): Added helper that compares the file's commit SHA with the PR's head SHA to determine if the file represents an older commit
  • FileChangeNode.updateViewed(): Conditionally sets checkboxState to undefined for files under commits
  • DirectoryTreeNode.allChildrenViewed(): Handle optional checkboxState when computing folder checkbox state
  • TreeUtils.processCheckboxUpdates(): Skip files without checkboxState when processing bulk checkbox changes

Behavior

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

This section details on the original issue you should resolve

<issue_title>Mark as Viewed: Marking a file as views on an older commit marks the file as viewed for all versions of the file</issue_title>
<issue_description>Image</issue_description>

<agent_instructions>Don't show the mark as viewed checkboxes on files under commit nodes.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix marking file as viewed on older commits Hide "Mark as Viewed" checkboxes on files under commit nodes Jan 23, 2026
Copilot AI requested a review from alexr00 January 23, 2026 17:41
Copy link
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.

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.

Copy link
Contributor Author

Copilot AI commented Jan 26, 2026

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.

Updated the implementation to compare this.changeModel.sha with this.pullRequest.head?.sha instead of traversing the parent tree. This is cleaner and more direct. The logic now checks: if the file's sha differs from the PR's head sha (or sha is defined), it's from an older commit and shouldn't have a checkbox. Commit: 65bef86

Copilot AI requested a review from alexr00 January 26, 2026 10:44
@alexr00 alexr00 marked this pull request as ready for review January 26, 2026 10:51
Copilot AI review requested due to automatic review settings January 26, 2026 10:51
@alexr00 alexr00 enabled auto-merge (squash) January 26, 2026 10:51
@vs-code-engineering vs-code-engineering bot added this to the January 2026 milestone Jan 26, 2026
Copy link
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

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.checkboxState optional 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.

Comment on lines +163 to +165
// 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;
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
// 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;

Copilot uses AI. Check for mistakes.
Comment on lines 124 to 128
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;
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
@alexr00 alexr00 merged commit ebb1209 into main Jan 26, 2026
12 checks passed
@alexr00 alexr00 deleted the copilot/fix-mark-as-viewed-issue branch January 26, 2026 11:06
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.

Mark as Viewed: Marking a file as views on an older commit marks the file as viewed for all versions of the file

4 participants