fix: route SCM title click to its repo in multi-repo workspaces#3
Merged
Merged
Conversation
When the Generate button is clicked in the SCM title of a specific repo in a workspace with nested .git sub-folders, VS Code passes the SourceControl as the command argument. The extension ignored it and fell back to api.repositories[0], causing "No staged changes found" when the staged changes lived in another sub-repo. Read the rootUri from the command argument and forward it to getGitRepository, which prefers api.getRepository(uri) / rootUri match before the existing single-repo / active-editor / first-repo fallbacks. Palette and keybinding invocations keep the prior behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
|
Good catch, and thanks for the contribution! |
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.
Summary
In workspaces where a root folder contains multiple nested
.gitsub-folders (each shown as its own repo in the SCM view), clicking the Generate Commit Message with Claude button would always read the staged diff fromapi.repositories[0], producingNo staged changes found.whenever the staged changes were in a different sub-repo. Single-repo workspaces were unaffected.VS Code passes the
SourceControlassociated with the clicked title button as the first argument to the command. This PR consumes that argument, extracts itsrootUri, and routes the generation to the correct repository.Changes
src/scm.ts(new) — safe extractor for therootUrion the SCM command argument. Returnsundefinedfor palette/keybinding invocations, preserving existing fallback behavior.src/extension.ts,src/extension.web.ts— command handlers accept the argument and forward the extracted URI.src/generateCommitMessage.ts— new optionaltargetUriparameter passed through to the git resolver.src/git.ts—getGitRepository(targetUri?)prefersapi.getRepository(uri), then arootUri.fsPathmatch, before falling back to single-repo / active-editor / first-repo heuristics.Behavior matrix
Test plan
npm run check-types— cleannpm test— 85/85 pass (9 new tests:scmhelper,getGitRepositoryURI-hint paths,generateCommitMessageURI forwarding).gitsub-folders — click Generate in each sub-repo's SCM title, verify each receives a message from its own staged diffCtrl+Shift+Alt+Cinvocation — still resolves via active editor / first-repo fallback