Skip to content
Source
Sign inSign up
pingdotgg/t3code

Use `fff` for workspace search queries #3099

Mergedjuliusmarmingemerged 2 commits intomain fromrefs/pull/3099/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Summary

  • Replaces the old workspace entry cache service with a dedicated workspace entry index module.
  • Refreshes the index after file writes, checkpount reverts, and other filesystem changes so @ mentions and file search stay current.
  • Adds typo-tolerant search support via fff-node and updates workspace listing behavior to reflect the new index model.
  • Adjusts server and orchestration wiring, tests, and package dependencies to use the new workspace entry layer.

Testing

  • vp check
  • vp run typecheck
  • vp run lint
  • vp test
  • Updated and added tests for workspace indexing, filesystem invalidation, server routing, and checkpoint reactor behavior.

Note

Medium Risk Touches core @-mention and project search paths plus native fff binaries on all platforms; behavior changes include no parentPath in API responses and different ignore/indexing semantics than the prior VCS-first scanner.

Overview Replaces the in-house VCS/filesystem workspace index and Effect Cache with @ff-labs/fff-node (FileFinder) behind a new WorkspaceSearchIndex (per-root LayerMap, scan timeout, idle TTL).

WorkspaceEntries is consolidated into a single module: list / search delegate to the index; invalidate becomes refresh (rescan), with index drop on refresh failure. Checkpoint capture/revert and workspace writes call refresh so @ path pickers stay in sync.

Contract/API: ProjectEntry drops optional parentPath; web and client derive parent paths from path. Server wiring uses WorkspaceEntries.layer without the VCS driver registry on that path.

Tests: workspace and HTTP tests updated (TestClock.withLive, typo/fuzzy search via fff, refresh failure rebuild); native ffi-rs / platform bins added via lockfile.

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

Note

Replace workspace search cache with fff-backed index in WorkspaceEntries

  • Replaces the old cache-based WorkspaceEntries service with a new WorkspaceSearchIndex backed by @ff-labs/fff-node (FileFinder), supporting list, search, and refresh operations per workspace.
  • Each workspace gets a FileFinder instance managed via a LayerMap with idle TTL eviction; initial scan is timeout-controlled with polling.
  • invalidate calls across CheckpointReactor and WorkspaceFileSystem are replaced with refresh, which actively rescans the index rather than dropping a cache.
  • Removes parentPath from ProjectEntry across contracts, client runtime, and the web composer, deriving display descriptions from the full path instead.
  • Risk: search now goes through an in-process file index that must complete an initial scan before serving results; workspaces with large trees may hit the scan timeout.
Macroscope summarized 40c49f9.
    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

      Run ID: 5aa66450-4ba2-4af5-b42a-da58af1abc66

      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
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `t3code/de132d75`

      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. juliusmarminge changed the title

    3. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    4. github-actions[bot](GitHub profile, opens in a new tab)commented

      🚀 Expo continuous deployment is ready!

      • Project → t3-code
      • Platforms → android, ios
      • Scheme → t3code-preview
       🤖 Android🍎 iOS
      Fingerprintae17d94b35f91f9c608a63dadbc3ddd9f4ba056e313e506a7f15a9c3f15b01d787d68a12382432bf
      Build DetailsBuild Permalink
      DetailsDistribution: INTERNAL
      Build profile: preview:dev
      Runtime version: ae17d94b35f91f9c608a63dadbc3ddd9f4ba056e
      App version: 0.1.0
      Git commit: 9a3b586808bcaf7252994c15b003818b749977b8
      Build Permalink
      DetailsDistribution: INTERNAL
      Build profile: preview:dev
      Runtime version: 313e506a7f15a9c3f15b01d787d68a12382432bf
      App version: 0.1.0
      Git commit: 9a3b586808bcaf7252994c15b003818b749977b8
      Update DetailsUpdate Permalink
      DetailsBranch: pr-3099
      Runtime version: ae17d94b35f91f9c608a63dadbc3ddd9f4ba056e
      Git commit: 9a3b586808bcaf7252994c15b003818b749977b8
      Update Permalink
      DetailsBranch: pr-3099
      Runtime version: 313e506a7f15a9c3f15b01d787d68a12382432bf
      Git commit: 9a3b586808bcaf7252994c15b003818b749977b8
      Update QR
    5. Cursor Bugbot has reviewed your changes and found 2 potential issues.

      Fix All in Cursor

      Bugbot Autofix prepared fixes for both issues found in the latest run.

      • ✅ Fixed: Refresh failures leave stale index
        • Added retry logic (3 attempts with exponential backoff) to the refresh operation and propagated errors through the type system so callers explicitly handle failures with Effect.ignoreCause({ log: true }) instead of silently swallowing them.
      • ✅ Fixed: Scan wait may exit early
        • Replaced manual isScanning() polling loop with the native FileFinder.waitForScan(timeoutMs) API which properly blocks until scanning completes, eliminating the race where polling exits early before a scan has started.

      Create PR

      Or push these changes by commenting:

      @cursor push b85d2886d0
      Preview (pingdotgg/t3code@b85d2886d0)
      diff --git a/apps/server/src/orchestration/Layers/CheckpointReactor.ts b/apps/server/src/orchestration/Layers/CheckpointReactor.ts
      --- a/apps/server/src/orchestration/Layers/CheckpointReactor.ts
      +++ b/apps/server/src/orchestration/Layers/CheckpointReactor.ts
      @@ -254,7 +254,7 @@
       
           // Refresh the workspace entry index so the @-mention file picker
           // reflects files created or deleted during this turn.
      -    yield* workspaceEntries.refresh(input.cwd);
      +    yield* workspaceEntries.refresh(input.cwd).pipe(Effect.ignoreCause({ log: true }));
       
           const files = yield* checkpointStore
             .diffCheckpoints({
      @@ -692,7 +692,9 @@
       
           // Refresh the workspace entry index so the @-mention file picker
           // reflects the reverted filesystem state.
      -    yield* workspaceEntries.refresh(sessionRuntime.value.cwd);
      +    yield* workspaceEntries
      +      .refresh(sessionRuntime.value.cwd)
      +      .pipe(Effect.ignoreCause({ log: true }));
       
           const rolledBackTurns = Math.max(0, currentTurnCount - event.payload.turnCount);
           if (rolledBackTurns > 0) {
      
      diff --git a/apps/server/src/workspace/Layers/WorkspaceFileSystem.ts b/apps/server/src/workspace/Layers/WorkspaceFileSystem.ts
      --- a/apps/server/src/workspace/Layers/WorkspaceFileSystem.ts
      +++ b/apps/server/src/workspace/Layers/WorkspaceFileSystem.ts
      @@ -114,7 +114,7 @@
                 }),
             ),
           );
      -    yield* workspaceEntries.refresh(input.cwd);
      +    yield* workspaceEntries.refresh(input.cwd).pipe(Effect.ignoreCause({ log: true }));
           return { relativePath: target.relativePath };
         });
         return { readFile, writeFile } satisfies WorkspaceFileSystemShape;
      
      diff --git a/apps/server/src/workspace/WorkspaceEntries.ts b/apps/server/src/workspace/WorkspaceEntries.ts
      --- a/apps/server/src/workspace/WorkspaceEntries.ts
      +++ b/apps/server/src/workspace/WorkspaceEntries.ts
      @@ -7,6 +7,7 @@
       import * as Layer from "effect/Layer";
       import * as Path from "effect/Path";
       import * as RcMap from "effect/RcMap";
      +import * as Schedule from "effect/Schedule";
       import * as Schema from "effect/Schema";
       
       import type {
      @@ -56,7 +57,9 @@
           readonly search: (
             input: ProjectSearchEntriesInput,
           ) => Effect.Effect<ProjectSearchEntriesResult, WorkspaceEntriesError>;
      -    readonly refresh: (cwd: string) => Effect.Effect<void>;
      +    readonly refresh: (
      +      cwd: string,
      +    ) => Effect.Effect<void, WorkspaceSearchIndex.WorkspaceSearchIndexError>;
         }
       >()("t3/workspace/WorkspaceEntries") {}
       
      @@ -132,16 +135,10 @@
             }
             yield* Effect.gen(function* () {
               const searchIndex = yield* WorkspaceSearchIndex.WorkspaceSearchIndex;
      -        yield* searchIndex.refresh();
      -      }).pipe(
      -        Effect.provide(workspaceSearchIndexes.get(normalizedCwd)),
      -        Effect.catch((cause) =>
      -          Effect.logWarning("Failed to refresh workspace search index", {
      -            cwd,
      -            cause,
      -          }),
      -        ),
      -      );
      +        yield* searchIndex
      +          .refresh()
      +          .pipe(Effect.retry({ times: 2, schedule: Schedule.exponential("100 millis") }));
      +      }).pipe(Effect.provide(workspaceSearchIndexes.get(normalizedCwd)));
           },
         );
       
      
      diff --git a/apps/server/src/workspace/WorkspaceSearchIndex.ts b/apps/server/src/workspace/WorkspaceSearchIndex.ts
      --- a/apps/server/src/workspace/WorkspaceSearchIndex.ts
      +++ b/apps/server/src/workspace/WorkspaceSearchIndex.ts
      @@ -1,9 +1,9 @@
       import { FileFinder, type MixedItem, type MixedSearchResult } from "@ff-labs/fff-node";
       import * as Context from "effect/Context";
      +import * as Duration from "effect/Duration";
       import * as Effect from "effect/Effect";
       import * as Layer from "effect/Layer";
       import * as LayerMap from "effect/LayerMap";
      -import * as Schedule from "effect/Schedule";
       import * as Schema from "effect/Schema";
       
       import type {
      @@ -16,7 +16,6 @@
       const WORKSPACE_INDEX_PAGE_SIZE = WORKSPACE_INDEX_MAX_ENTRIES + 2;
       const WORKSPACE_INDEX_SCAN_TIMEOUT = "15 seconds";
       const WORKSPACE_INDEX_IDLE_TTL = "15 minutes";
      -const WORKSPACE_INDEX_SCAN_POLL_INTERVAL = "50 millis";
       
       export class WorkspaceSearchIndexCreateFailed extends Schema.TaggedErrorClass<WorkspaceSearchIndexCreateFailed>()(
         "WorkspaceSearchIndexCreateFailed",
      @@ -169,17 +168,18 @@
         cwd: string,
         finder: FileFinder,
       ) {
      -  yield* Effect.sync(() => finder.isScanning()).pipe(
      -    Effect.repeat({
      -      while: (scanning) => scanning,
      -      schedule: Schedule.spaced(WORKSPACE_INDEX_SCAN_POLL_INTERVAL),
      -    }),
      -    Effect.timeoutOrElse({
      -      duration: WORKSPACE_INDEX_SCAN_TIMEOUT,
      -      orElse: () =>
      -        new WorkspaceSearchIndexScanTimedOut({ cwd, timeout: WORKSPACE_INDEX_SCAN_TIMEOUT }),
      -    }),
      -  );
      +  const timeoutMs = Duration.toMillis(WORKSPACE_INDEX_SCAN_TIMEOUT);
      +  const result = yield* Effect.tryPromise({
      +    try: () => finder.waitForScan(timeoutMs),
      +    catch: () =>
      +      new WorkspaceSearchIndexScanTimedOut({ cwd, timeout: WORKSPACE_INDEX_SCAN_TIMEOUT }),
      +  });
      +  if (!result.ok || !result.value) {
      +    return yield* new WorkspaceSearchIndexScanTimedOut({
      +      cwd,
      +      timeout: WORKSPACE_INDEX_SCAN_TIMEOUT,
      +    });
      +  }
       });
       
       const makeWorkspaceSearchIndex = (cwd: string) =>
      You can send follow-ups to the cloud agent here. Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 486719688be84db8fb344263e57d5815b33a9778. Configure [here](https://www.cursor.com/dashboard/bugbot).
    6. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      This PR replaces the core workspace file search implementation with an external library (@ff-labs/fff-node), introducing a new native dependency, changing search behavior to be typo-tolerant, and modifying API contracts. These significant infrastructure and runtime behavior changes warrant human review.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    7. juliusmarminge merged thisd12da19

    8. juliusmarminge closed this

Sign in to join this conversation.