Skip to content

Lazy-load the file tree, decouple the workspace index#8

Open
evanklem wants to merge 1 commit into
mainfrom
fix-fs-tree-lazy-load
Open

Lazy-load the file tree, decouple the workspace index#8
evanklem wants to merge 1 commit into
mainfrom
fix-fs-tree-lazy-load

Conversation

@evanklem

Copy link
Copy Markdown
Owner

What this does

Fixes the explorer rendering as “only dot folders” or appearing empty when a project root contains a large, early-sorted directory, such as a fresh .venv with roughly 11k files.

Previously, the eager recursive listing was capped at 2,500 files. If an oversized early subtree exhausted that budget, later entries were dropped. .venv and common Python cache/build directories were also missing from the ignore list.

Closes #4

This change narrows the resolution path and separates two concerns that the explorer panel had conflated:

  • fs_list_dir(path) lists one directory level only. This is used for collapsed and lazily expanded explorer nodes.
  • fs_list_files() returns a complete project file index using git ls-files for quick-open and Monaco resolution. These previously rode on the same recursive listing path.

Additional changes:

  • Adds venv, __pycache__, .mypy_cache, and .ruff_cache to the ignore list.
  • Plumbs editor.listDir and editor.listFiles through the RPC adapter and SDK under the existing editor.read permission.
  • Adds in-memory fallbacks so headless hosts keep working.
  • Updates the shared FileTree with opt-in lazy onExpand loading while leaving existing eager callers unchanged.
  • Preserves expansion state across refreshes.
  • Feeds quick-open and Monaco from the dedicated file index.
  • Skips binary assets in default-open surfaces.

How to test

  1. Open a project that contains a large early-sorted directory, such as a Python project with a populated .venv.

  2. Confirm the explorer shows the full project tree and that ignored directories such as .venv, venv, __pycache__, .mypy_cache, and .ruff_cache are not shown.

  3. Expand folders and confirm children resolve on demand.

  4. Refresh the file tree and confirm expansion state is preserved.

  5. Confirm quick-open and Monaco file resolution still work.

  6. Run:

    • npm run typecheck
    • cd src-tauri && cargo clippy --no-deps -- -D warnings
    • cd src-tauri && cargo test

Checklist

  • npm run typecheck passes
  • cd src-tauri && cargo clippy --no-deps -- -D warnings passes
  • cd src-tauri && cargo test passes

The explorer rendered as "only dot folders / empty" when a project rooted
a large early-sorted directory (e.g. a fresh .venv with ~11k files). The
eager whole-tree walk in list_dir capped at 2500 files with a hard break,
and because entries sort folders-first/lowercased, an oversized early
subtree exhausted the budget and every sibling after it was dropped. .venv
and the python cache dirs were also absent from the ignore list.

Switch to VS Code-convention lazy resolution and split the two concerns the
editor panel had conflated:

- fs_list_dir(path): one level only, no cap; folders come back collapsed and
  resolve their children on expand. fs_list_files(): complete, gitignore-
  aware index via `rg --files` for quick-open and Monaco cross-file types,
  which previously rode on the same capped tree walk.
- venv/__pycache__/.mypy_cache/.pytest_cache/.ruff_cache added to the
  built-in ignore list.
- editor.listDir / editor.listFiles plumbed through the host RPC adapter,
  SDK client, and Tauri bridge; mapped under the editor.read permission.
- Shared FileTree gains opt-in lazy onExpand (eager KB usage unchanged); the
  editor panel resolves children on expand, preserves expansion across
  create/delete/rename refreshes, and feeds quick-open/Monaco from the
  decoupled index. Default-open skips binary assets the complete index now
  surfaces.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature - Improve Editor with Refresh and Lazy Load

1 participant