fix(core): respect .gitignore and .geminiignore in session_context directory tree#27886
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where the session context directory tree was failing to respect user-defined ignore rules. By passing the configured file filtering options to the folder structure generation logic, the system now consistently applies .gitignore and .geminiignore settings, preventing unnecessary token usage and potential file exposure. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
📊 PR Size: size/S
|
There was a problem hiding this comment.
Code Review
This pull request updates getDirectoryContextString in environmentContext.ts to pass fileFilteringOptions from the configuration to getFolderStructure. The corresponding unit tests in environmentContext.test.ts have been updated to mock getFileFilteringOptions and verify that the options are correctly passed. There are no review comments, so I have no feedback to provide.
|
Thanks for reviewing. This wires Unit tests assert the options object is forwarded. Happy to add an integration test if you'd like. |
Wire config.getFileFilteringOptions() into getFolderStructure() so session_context directory listings honor .gitignore and .geminiignore.
9cd5c2f to
6b40527
Compare
Summary
Ensures the
<session_context>directory tree honors the same ignore rules as the rest of the CLI.Fixes #27787
Problem
getDirectoryContextString()builds the folder tree shown inside<session_context>. It callsgetFolderStructure()with onlyfileService, but does not passfileFilteringOptionsfrom config.getFolderStructure()only applies.gitignore/.geminiignorefiltering when both are available:fileService.shouldIgnoreFile()/shouldIgnoreDirectory()fileFilteringOptions.respectGitIgnore/respectGeminiIgnoreflagsWithout (2), ignored paths can still appear in the session bootstrap context — wasting tokens and potentially leaking files the user intentionally excluded.
Root cause
Other tools (
ls,glob,read-many-files, etc.) already passconfig.getFileFilteringOptions(). Session context generation was the missing call site.Fix
Pass the configured filtering options alongside the file service:
This aligns session context generation with the ignore behavior used elsewhere in core.
Testing
Updated
environmentContext.test.tsexpectations and mockedgetFileFilteringOptions().