Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): keep the file tree working without the native index #8402

Closedalejacre(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/8402/headopened View on GitHub

What Changed

The server now lazy-loads @ff-labs/fff-node when a workspace index is first requested instead of importing the native binding during startup.

If the native index cannot be created, projects.listEntries falls back to a bounded file listing:

  • git ls-files --cached --others --exclude-standard for Git repositories
  • a bounded directory walk when Git is unavailable
  • the existing 25,000-entry cap and truncation reporting

Workspace and content search remain index-only. Scan timeouts and failures from an already-created index are not masked by the fallback.

Why

On hosts where the packaged native binding cannot load, such as systems with an older glibc, the eager import prevented the server from providing workspace functionality. The file tree can still provide useful degraded behavior without the native fuzzy/content index.

Validation

  • vp test run apps/server/src/workspace/WorkspaceEntries.test.ts apps/server/src/workspace/WorkspaceSearchIndex.test.ts apps/server/src/workspace/WorkspaceFileSystem.test.ts — 58 passed
  • tsgo --noEmit in apps/server
  • vp lint on the four touched workspace files
  • Tests cover rejected native imports, Git ignore behavior, parent reconstruction, output truncation, entry limits, and the non-Git directory fallback

Implemented with Claude Fable 5 through Kiro CLI; verified and published with Codex.


Note

Medium Risk Adds a new degraded listing path that shells out to Git and walks the filesystem, with different ignore/performance semantics than the native index; WorkspaceEntries now requires VcsProcess in its layer for fallback to work.

Overview Lazy-loads the @ff-labs/fff-node native binding on first index use (via nativeBinding.load) so hosts that cannot load it still start the server; a failed dynamic import becomes WorkspaceSearchIndexCreateFailed instead of crashing at module load.

When WorkspaceEntries.list hits that create failure only, it logs a warning and falls back to a bounded listing: git ls-files with check-ignore when Git works (8MB output cap, 15s timeout), otherwise a BFS directory walk. Results exclude .git, .convex, and node_modules, synthesize parent directories, sort paths, and honor the 25,000-entry cap with truncated. Search and content search still require the native index; scan/timeouts on an existing index are not masked by this fallback. WorkspaceEntries.layer now provides VcsProcess for the Git path.

Tests cover native import/FileFinder failures, gitignore behavior, truncated git output, entry limits, submodule dirs, and the non-Git walk (including a mocked VcsProcess block).

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a335642c2dc55123198685120737d68c71a44cb9. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add filesystem fallback to WorkspaceEntries when native index is unavailable

  • When WorkspaceSearchIndex creation fails with WorkspaceSearchIndexCreateFailed, WorkspaceEntries.list now returns a filesystem-derived listing instead of propagating the error. See WorkspaceEntries.ts.
  • The fallback first tries git ls-files -z (with git check-ignore filtering) and, if git is unavailable or fails, walks the filesystem breadth-first. Results are capped at 25,000 entries and marked truncated when the limit is exceeded.
  • Fallback excludes .git, .convex, and node_modules directories and reconstructs parent directories so the output resembles a normal file tree.
  • Native binding import for WorkspaceSearchIndex is deferred from module-load time to first use via a nativeBinding.load() indirection, so hosts that cannot load the binding fail deterministically with WorkspaceSearchIndexCreateFailed rather than crashing at import. See WorkspaceSearchIndex.ts.
  • Risk: WorkspaceEntries.list previously surfaced WorkspaceSearchIndexCreateFailed to callers; it now logs a warning and returns a fallback list. Other index errors still propagate. Reviewers should check every caller of WorkspaceEntries.list for assumptions about error propagation.
Macroscope summarized a335642.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: e6a1db64-7990-4f92-8dba-562177e3bf4d

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. One convention violation found: Effect.catchTag used for a statically known tagged failure. See inline comment.

      Posted via Macroscope — Effect Service Conventions
    4. Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).

      Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6ed30f9115aeb0a16d028d74f501b411a002457b. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -140,0 +179,21 @@
      179+ );
      180+ return {
      181+ entries: sortedEntries.slice(0, FALLBACK_LIST_MAX_ENTRIES),
      182+ truncated: truncated || sortedEntries.length > FALLBACK_LIST_MAX_ENTRIES,
      183+ };
      184+}
      185+
      186+const listWorkspaceEntriesFromFilesystem = Effect.fn(
      187+ "WorkspaceEntries.listWorkspaceEntriesFromFilesystem",
      188+)(function* (cwd: string, path: Path.Path, vcsProcess: VcsProcess.VcsProcess["Service"]) {
      189+ const gitResult = yield* vcsProcess
      190+ .run({
      191+ operation: "WorkspaceEntries.fallbackList.gitLsFiles",
      192+ command: "git",
      193+ cwd,
      194+ args: ["ls-files", "--cached", "--others", "--exclude-standard", "-z"],
      195+ allowNonZeroExit: true,
      196+ timeoutMs: 15_000,
      197+ maxOutputBytes: FALLBACK_LIST_GIT_OUTPUT_MAX_BYTES,
      198+ })
      199+ .pipe(Effect.orElseSucceed(() => null));

      Git fallback can ignore gitignore after timeout

      Medium Severity

      The fallback git ls-files invocation does not disable core.fsmonitor or core.untrackedCache. The same listing elsewhere passes those -c flags because fsmonitor hooks can stall --others. Here a stall hits the 15s timeout, orElseSucceed treats git as unavailable, and the directory walk then includes gitignored trees such as dist and .next.

      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6ed30f9115aeb0a16d028d74f501b411a002457b. Configure [here](https://www.cursor.com/dashboard/bugbot).
    5. @@ -140,0 +174,21 @@
      174+ }
      175+ }
      176+
      177+ const sortedEntries = [...entryByPath.values()].toSorted((left, right) =>
      178+ left.path.localeCompare(right.path),
      179+ );
      180+ return {
      181+ entries: sortedEntries.slice(0, FALLBACK_LIST_MAX_ENTRIES),
      182+ truncated: truncated || sortedEntries.length > FALLBACK_LIST_MAX_ENTRIES,
      183+ };
      184+}
      185+
      186+const listWorkspaceEntriesFromFilesystem = Effect.fn(
      187+ "WorkspaceEntries.listWorkspaceEntriesFromFilesystem",
      188+)(function* (cwd: string, path: Path.Path, vcsProcess: VcsProcess.VcsProcess["Service"]) {
      189+ const gitResult = yield* vcsProcess
      190+ .run({
      191+ operation: "WorkspaceEntries.fallbackList.gitLsFiles",
      192+ command: "git",
      193+ cwd,
      194+ args: ["ls-files", "--cached", "--others", "--exclude-standard", "-z"],
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium workspace/WorkspaceEntries.ts:194

      The Git fallback omits empty directories, so a successful git ls-files path returns a file tree missing visible directories such as src/components/ before it contains any file. Because the directory-walk branch is only used when Git fails, this case never gets added; merge a directory walk into the Git results or otherwise include empty directories.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/workspace/WorkspaceEntries.ts around line 194:
      
      The Git fallback omits empty directories, so a successful `git ls-files` path returns a file tree missing visible directories such as `src/components/` before it contains any file. Because the directory-walk branch is only used when Git fails, this case never gets added; merge a directory walk into the Git results or otherwise include empty directories.
    6. Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR adds a substantial production fallback that shells out to Git or walks the filesystem, with behavior that differs from the native index around ignore handling, truncation, and directory completeness. Unresolved concerns about ignored trees after Git timeouts and missing directories leave important runtime behavior requiring human review.

      Not approved because:

      • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    7. Note

      This comment is posted by Julius' dot

      This adds a second file listing path through Git and a directory walk when the native index cannot load, with separate ignore, truncation and directory handling. This substantial compatibility fix does not link a maintainer-triaged issue establishing the native-loading failure and intended fallback, as the prior approval policy requires. Please link a triaged report and agree on the fallback's direction and scope with maintainers, then request reconsideration.

    8. juliusmarminge closed this

Sign in to join this conversation.