Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

feat: Implement .gitignore parsing for file listing and search, and...#982

Open
prath47 wants to merge 4 commits intogeneralaction:main from
prath47:fix-974
Open

feat: Implement .gitignore parsing for file listing and search, and... #982
prath47 wants to merge 4 commits intogeneralaction:main from
prath47:fix-974

Conversation

@prath47
Copy link
Contributor

@prath47 prath47 commented Feb 19, 2026
edited
Loading

fix: #974

This PR includes changes as:

  1. Introduced lazy loading of files and caching
  2. fix of _layout, .* files, node_modules were not visible
  3. introduced functionality to search only in files where they are not there in .gitignore (otherwise it'll search for whole node modules !)

Checks Performed:

  1. Format
  2. Build
  3. Manual verification of the fix and feature

@arnestrickmann please review it

greptile-apps[bot] reacted with thumbs up emoji
Copy link

vercel bot commented Feb 19, 2026

@prath47 is attempting to deploy a commit to the General Action Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

greptile-apps bot commented Feb 19, 2026
edited
Loading

Greptile Summary

This PR introduces lazy loading of file trees and .gitignore-based filtering for the file explorer and search functionality. The changes shift from hardcoded ignore patterns to respecting project-specific .gitignore files, improving performance and allowing visibility of previously hidden files like _layout and .env.

Key Changes:

  • Implemented lazy loading for file tree expansion - directories now load children on-demand rather than loading the entire tree upfront
  • Integrated ignore package to parse and apply .gitignore patterns during file listing and content search
  • Removed node_modules from hardcoded ignore lists since it's now handled via .gitignore
  • Added recursive parameter to fsList API to support non-recursive directory listings
  • Enabled showHiddenFiles: true to display dotfiles and directories starting with .
  • Introduced constructSubRoot helper function to handle path construction with proper separator detection

Issues Found:

  • Line 445 in FileTree.tsx has a filtering bug that could remove sibling directories when loading children
  • The worker thread doesn't parse .gitignore, so large ignored directories like node_modules are still traversed (performance impact)

Confidence Score: 3/5

  • This PR requires fixes before merging due to a path filtering bug
  • The lazy loading implementation is well-designed and the gitignore integration is sound, but there's a critical bug in FileTree.tsx line 445 that filters files incorrectly. The worker performance concern is a secondary issue that should be addressed for optimal performance.
  • Pay close attention to src/renderer/components/FileExplorer/FileTree.tsx - the filtering logic at line 445 needs correction

Important Files Changed

Filename Overview
src/main/utils/gitIgnore.ts New wrapper class for ignore package to handle .gitignore pattern matching
src/main/workers/fsListWorker.ts Added non-recursive mode support - stops scanning subdirectories when recursive: false
src/main/services/fs/LocalFileSystem.ts Integrated gitignore filtering into content search to skip ignored directories
src/main/services/fsIpc.ts Added gitignore parsing to file search and made recursive default to true for backward compatibility
src/renderer/components/FileExplorer/FileTree.tsx Implemented lazy loading with constructSubRoot helper and non-recursive file listing; removed node_modules from default excludes

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
 A[User expands directory] --> B{Node already loaded?}
 B -->|Yes| C[Toggle expand state]
 B -->|No| D[Call loadChildren]
 D --> E[constructSubRoot with rootPath + nodePath]
 E --> F[fsList with recursive: false]
 F --> G[fsListWorker reads directory]
 G --> H{recursive = false?}
 H -->|Yes| I[Skip subdirectories deeper than root]
 H -->|No| J[Traverse all subdirectories]
 I --> K[Return immediate children only]
 J --> K
 K --> L[Prefix paths with node.path]
 L --> M[Filter existing children from allFiles]
 M --> N[Add newItems to allFiles]
 N --> O[Mark node as isLoaded: true]
 O --> C
 
 P[File Search] --> Q[Read .gitignore from project root]
 Q --> R[Create GitIgnoreParser]
 R --> S[collectFiles traverses directories]
 S --> T{Path matches gitignore?}
 T -->|Yes| U[Skip directory/file]
 T -->|No| V[Include in search results]
Loading

Last reviewed commit: 23284c5

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10 files reviewed, 6 comments

Edit Code Review Agent Settings | Greptile

Comment on lines 419 to 421
try {
const separator = rootPath.includes('\\') ? '\\' : '/';
const subRoot = `${rootPath}${separator}${node.path}`; // node.path is relative
Copy link

@greptile-apps greptile-apps bot Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path construction uses string concatenation which may produce double separators or incorrect paths on Windows. The subRoot path could end up as /root//path if rootPath already ends with separator.

Suggested change
try {
const separator = rootPath.includes('\\') ? '\\' : '/';
const subRoot = `${rootPath}${separator}${node.path}`; // node.path is relative
const subRoot = path.join(rootPath, node.path);

// 1. Prefix their paths so they are relative to project root
// 2. Add them to allFiles
const newItems = result.items.map((item: any) => ({
...item,
Copy link

@greptile-apps greptile-apps bot Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path construction with string concatenation may fail with Windows paths or create double separators. Should use a path utility.

Suggested change
...item,
path: path.join(node.path,item.path),

Comment on lines +438 to +439
// Remove any existing children of this node to avoid duplicates (optional but good)
const filtered = prev.filter((p) => !p.path.startsWith(node.path + '/'));
Copy link

@greptile-apps greptile-apps bot Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filtering existing children before adding new ones could incorrectly remove other loaded subdirectories if they share a path prefix. For example, loading src/components would remove src/common entries if they were already loaded.

Copy link

greptile-apps bot commented Feb 19, 2026

Additional Comments (1)

src/renderer/components/FileExplorer/FileTree.tsx
Missing import for path module which is now used in lines 420 and 433.

Copy link
Contributor Author

prath47 commented Feb 19, 2026

will go through this review once more

Copy link
Contributor

@prath47 alright

...struction with tests, and integrate `ignore` package for improved gitignore functionality.
Copy link
Contributor Author

prath47 commented Feb 20, 2026

@arnestrickmann check this once

Copy link
Contributor

@greptile

greptile-apps[bot] reacted with thumbs up emoji

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

12 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile


setAllFiles((prev) => {
// Remove any existing children of this node to avoid duplicates (optional but good)
const filtered = prev.filter((p) => !p.path.startsWith(node.path + '/'));
Copy link

@greptile-apps greptile-apps bot Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This filtering logic removes all existing files that start with the node path. If you load src/components, this would incorrectly remove src/common files if they were already loaded from a previous expansion.

Suggested change
const filtered = prev.filter((p) => !p.path.startsWith(node.path + '/'));
const filtered = prev.filter((p) => p.path!==node.path&&!p.path.startsWith(node.path + '/'));

Comment on lines +60 to +63
// If not recursive and we are deeper than root, don't scan children
if (request.recursive === false && rel !== '.') {
continue;
}
Copy link

@greptile-apps greptile-apps bot Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The worker doesn't have access to .gitignore parsing, so node_modules and other gitignored paths will still be traversed and filtered later. Consider passing gitignore patterns to the worker or reading .gitignore in the worker for better performance.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@greptile-apps greptile-apps[bot] greptile-apps[bot] left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[bug]: _layout.tsx, .env, node_modules not visible in code editor

AltStyle によって変換されたページ (->オリジナル) /