[Routine - VT] fix(FileManager): use normalized membership check for add/remove files#79
Draft
winterdrive wants to merge 1 commit into
Draft
[Routine - VT] fix(FileManager): use normalized membership check for add/remove files#79winterdrive wants to merge 1 commit into
winterdrive wants to merge 1 commit into
Conversation
group.files can hold workspace-relative entries (e.g. "src/foo.ts") alongside file:// URIs, but addFilesToGroup/removeFilesFromGroup only compared against file:// URIs via includes()/indexOf(). This let the MCP-facing add_files_to_group/remove_files_from_group tools duplicate a file already stored as a relative path, or silently no-op when removing one. Mirrors the matchesStoredFileEntry fix already applied to BookmarkManager.createBookmark (e12c0d9). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Jul 6, 2026
Draft
Draft
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-flight Check
Open PRs / active branches checked before selecting this fix:
routine/vt-fix-bookmark-stale-groupidx-260703— touchessrc/provider.tsroutine/vt-fix-treeview-listener-disposal-260702— touchessrc/extension.tsrelease/0.7.6-260701— touchesCHANGELOG.md,package.json,package-lock.json(release PR, not routine)origin/routine/vt-fix-*branches from prior days (bookmark-relpath, filesorter-tests, groupmgr-cache-miss, senddestguard, treeview-listener-disposal, watcher-new-scope, duplicate-scope) — already merged, no overlap.This PR touches only
src/core/FileManager.tsand adds a new test filesrc/test/unit/fileManagerRelpath.test.ts. No overlap withprovider.ts,extension.ts, or any release metadata files.Changes
FileManager.addFilesToGroupandFileManager.removeFilesFromGroupcompared file paths againstgroup.filesusing plainArray.includes()/Array.indexOf()against a freshly-builtfile://URI. However,group.filescan legitimately contain workspace-relative path strings (e.g."src/foo.ts") instead offile://URIs — this is the same class of bug already fixed forBookmarkManager.createBookmarkin commit e12c0d9 viamatchesStoredFileEntry.Because these two
FileManagermethods back the MCP server'sadd_files_to_group/remove_files_from_grouptools (mcp-server/src/tools/fileTools.ts→mcp-server/src/managers/FileManager.ts, a re-export of this class), the bug was reachable from the MCP-facing API even though the in-editor path (provider.ts) already uses the normalized matcher:addFilesToGroupwould fail to recognize a relative-path entry as a duplicate and push a second (URI) entry for the same file instead of reporting it asskipped.removeFilesFromGroupwould fail to find a relative-path entry and incorrectly report it asnotFoundinstead of removing it.Fix: both methods now use
matchesStoredFileEntry(fromsrc/core/FileEntryMatcher.ts) with the group's workspace root, matching the pattern already used byBookmarkManagerandGroupFileRemoval.Confirms this PR does not modify: command registrations,
package.jsoncontributed configuration keys, dependencies, or the tab-group serialization/storage format. Only comparison logic inside two existing methods changed; the on-diskfilesarray shape andvirtualTab.jsonformat are untouched.Safety Verification
Commands run locally, all passed:
npx tsc -p ./— passed, no errorsnpm run test(tsc -p ./ && jest --runInBand) — 26 suites / 178 tests passed, including 3 new tests insrc/test/unit/fileManagerRelpath.test.tscovering: skip-on-duplicate for a relative-path entry, remove-by-relative-path entry, and notFound still reported for genuinely absent files.lintorformat:checkscript exists inpackage.json, so those steps were skipped.CI / Release Gate Note
This is a daily routine Draft PR. Package version bump and
CHANGELOG.mdupdates are intentionally deferred to the weekend release/integration PR. If CI fails solely due to the repository's version-bump release gate, that is expected release-readiness behavior for a routine PR, not a code validation failure.