-
Notifications
You must be signed in to change notification settings - Fork 207
Fix env.files not populated when right-clicking folders in VS Code #1910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
6
commits into
dev
Choose a base branch
from
copilot/vscode1756286754304
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+31
−1
Conversation
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
Co-authored-by: sinedied <[email protected]>
Co-authored-by: sinedied <[email protected]>
Copilot finished work on behalf of
sinedied
August 27, 2025 09:43
Revert all changes made to |
Co-authored-by: sinedied <[email protected]>
Copilot finished work on behalf of
sinedied
August 27, 2025 13:11
Restore |
Co-authored-by: sinedied <[email protected]>
Copilot finished work on behalf of
sinedied
August 27, 2025 13:17
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.
Problem
When right-clicking on a folder in VS Code Explorer and selecting "Run GenAIScript", the
env.files
variable was not populated with the files from the folder. This broke scripts that rely on glob filters or expect to process files from the selected folder.The issue occurred because the current implementation only passed the folder URI itself to the backend, not the actual files within the folder.
Root Cause
In the
scriptRun
function inpackages/vscode/src/fragmentcommands.ts
:fileOrFolder
contains the folder URIextraArgs
is not an array, sofileOrFolders
becomesundefined
files = fileOrFolders?.map((f) => f.toString()) || [fileOrFolder?.toString()];
files = [folderUriString]
- just the folder path, not the files inside itenv.files
with actual filesSolution
Modified the
scriptRun
function to:checkDirectoryExists()
to identify when the selected item is a directorylistFiles()
to recursively find all files within selected directoriesImplementation Details
checkDirectoryExists
andlistFiles
from the existing./fs
module.gitignore
rules (handled automatically by VS Code'sfindFiles
)Test Case Validation
The fix handles these scenarios correctly:
env.files
Example: Right-clicking on a folder with structure:
Now properly populates
env.files
with["my-folder/file1.md", "my-folder/file2.ts", "my-folder/subfolder/nested.md"]
instead of just["my-folder"]
.This enables scripts using
def("FILES", env.files, { endsWith: ".md" })
to work correctly when selecting folders.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
cdn.sheetjs.com
node /home/REDACTED/.local/share/pnpm/.tools/pnpm/10.12.3/bin/pnpm install
(dns block)esm.ubuntu.com
/usr/lib/apt/methods/https
(dns block)example.com
node (vitest 1)
(dns block)https://api.github.com/markdown
node (vitest 3)
(http block)https://api.github.com/repos/microsoft/genaiscript/branches
node (vitest 3)
(http block)https://api.github.com/repos/microsoft/genaiscript/contents/README.md
node (vitest 3)
(http block)https://api.github.com/repos/microsoft/genaiscript/contents/packages%2Fcore%2Fsrc
node (vitest 3)
(http block)https://api.github.com/repos/microsoft/genaiscript/git/blobs
node (vitest 3)
(http block)https://api.github.com/repos/microsoft/genaiscript/git/ref/heads%2Ftest-ignore
node (vitest 3)
(http block)https://api.github.com/repos/microsoft/genaiscript/issues
node (vitest 3)
(http block)https://api.github.com/repos/microsoft/genaiscript/labels
node (vitest 3)
(http block)https://api.github.com/repos/microsoft/genaiscript/languages
node (vitest 3)
(http block)https://api.github.com/repos/microsoft/genaiscript/pulls
node (vitest 3)
(http block)https://api.github.com/repos/microsoft/genaiscript/pulls/999999
node (vitest 3)
(http block)https://api.github.com/test
node (vitest 1)
(http block)microsoft.github.io
node (vitest 2)
(dns block)node (vitest 1)
(dns block)telemetry.astro.build
node /home/REDACTED/work/genaiscript/genaiscript/docs/node_modules/.bin/../astro/astro.js build
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.