Skip to content

Add 'Show only files owned by you' CODEOWNERS filter#8542

Draft
smith wants to merge 1 commit intomicrosoft:mainfrom
smith:feature/codeowners-file-filter
Draft

Add 'Show only files owned by you' CODEOWNERS filter#8542
smith wants to merge 1 commit intomicrosoft:mainfrom
smith:feature/codeowners-file-filter

Conversation

@smith
Copy link

@smith smith commented Feb 24, 2026

Summary

Implements the CODEOWNERS-based file filter requested in #6624.

  • Adds a toggle button (person icon) to the "Changes in Pull Request" tree view toolbar that filters files to show only those owned by the authenticated user according to the repository's CODEOWNERS file.
  • New githubPullRequests.showOnlyOwnedFiles setting (default false) and pr.toggleShowOnlyOwnedFiles command.
  • Composable with the existing "hide viewed files" filter.

Implementation details

  • CODEOWNERS parser (src/common/codeowners.ts): Parses GitHub's CODEOWNERS format — handles anchored/unanchored paths, */** wildcards, directory patterns, ? single-char, and [...] character classes. No new dependencies; uses a custom glob-to-regex converter.
  • Owner resolution: GitHubRepository.getCodeownersEntries(ref) fetches and caches the CODEOWNERS file (checks .github/CODEOWNERS, CODEOWNERS, docs/CODEOWNERS). getAuthenticatedUserTeamSlugs() fetches the user's org team memberships for @org/team pattern matching.
  • Filtering: FilesCategoryNode.filterByCodeowners() applies the filter during getChildren(), matching each file's path against the parsed CODEOWNERS entries and checking ownership against the current user's login and team slugs.
  • Shows "No files owned by you" placeholder when the filter yields no results.
  • When no CODEOWNERS file exists, the filter is a no-op (all files shown).

Screenshot reference

The feature mirrors GitHub.com's "Only files owned by you" filter in the Files Changed tab:

github-codeowners-filter

Test plan

  • Verify the person toggle button appears in the "Changes in Pull Request" toolbar
  • Toggle on: only files matching CODEOWNERS rules for the authenticated user are shown
  • Toggle off: all files are shown again
  • Works with both flat and tree file layouts
  • Composes correctly with "hide viewed files" (both filters active simultaneously)
  • Repos without a CODEOWNERS file: filter is no-op, all files shown
  • Team-based ownership (@org/team) resolves correctly when read:org scope is available
  • CODEOWNERS file cached per ref — no redundant API calls on tree refresh
  • All 348 existing tests pass

Closes #6624

Made with Cursor

Implements the CODEOWNERS-based file filter requested in microsoft#6624.
Adds a toggle button to the Changes in Pull Request tree view that
filters files to show only those owned by the authenticated user
according to the repository's CODEOWNERS file.

- New CODEOWNERS parser (src/common/codeowners.ts) that handles
  GitHub's pattern syntax: anchored/unanchored paths, wildcards,
  directory patterns, and character classes.
- GitHubRepository gains getCodeownersEntries() to fetch and cache
  CODEOWNERS from .github/CODEOWNERS, CODEOWNERS, or docs/CODEOWNERS,
  and getAuthenticatedUserTeamSlugs() for @org/team matching.
- FilesCategoryNode applies the filter in getChildren(), composable
  with the existing "hide viewed files" filter.
- New setting githubPullRequests.showOnlyOwnedFiles (default false)
  and command pr.toggleShowOnlyOwnedFiles with $(person) icon.

Closes microsoft#6624

Co-authored-by: Cursor <cursoragent@cursor.com>
@smith smith force-pushed the feature/codeowners-file-filter branch from bfe52a3 to 0a03700 Compare February 24, 2026 16:21
@smith
Copy link
Author

smith commented Feb 24, 2026

@microsoft-github-policy-service agree company="Elastic"

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.

@smith, I see that this is still marked as a draft. Is it ready for review, or should I wait?

@smith
Copy link
Author

smith commented Feb 28, 2026

@alexr00 this should remain a draft. It's a very basic approach that probably needs more thought. If it's noisy having an open draft pr it's ok to close it.

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.

[Feature Request] Add the "only files owned by you" filter.

2 participants