Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: `@` workspace search ignores `.gitignore` because `WorkspaceEntriesLive` is wired without `GitCoreLive` #2077

Closednmharmon8(GitHub profile, opens in a new tab) opened this issue 1 comment

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Create a repo with an ignored directory:

    mkdir repro && cd repro
    git init
    printf ".venv/\n" > .gitignore
    mkdir -p .venv/lib
    printf "ignored\n" > .venv/lib/test.txt
    printf "tracked\n" > tracked.txt
    git add .gitignore tracked.txt
  2. Start T3 against that repo and select the repo root as the project root.

  3. In the chat composer, type @.venv or search for test.txt.

  4. Observe that the ignored path can appear in the picker / search results.

Expected behavior

Paths ignored by Git should not be returned by @ workspace search when the selected project root is inside a Git worktree and the repo's .gitignore excludes those paths.

Actual behavior

@ workspace search can include ignored files and directories.

The likely root cause is in apps/server/src/server.ts:183, where WorkspaceLayerLive is built like this:

const WorkspaceLayerLive = Layer.mergeAll(
  WorkspacePathsLive,
  WorkspaceEntriesLive.pipe(Layer.provide(WorkspacePathsLive)),
  WorkspaceFileSystemLive.pipe(
    Layer.provide(WorkspacePathsLive),
    Layer.provide(WorkspaceEntriesLive.pipe(Layer.provide(WorkspacePathsLive))),
  ),
);

But WorkspaceEntries resolves Git through Effect.serviceOption(GitCore) in apps/server/src/workspace/Layers/WorkspaceEntries.ts:177:

const gitOption = yield* Effect.serviceOption(GitCore);

That same file only uses the Git-backed index when GitCore is present:

  • buildWorkspaceIndexFromGit(...) returns null when Option.isNone(gitOption) at apps/server/src/workspace/Layers/WorkspaceEntries.ts:199
  • buildWorkspaceIndex(...) then falls back to buildWorkspaceIndexFromFilesystem(...) at apps/server/src/workspace/Layers/WorkspaceEntries.ts:381

So the server appears to have the Git-aware implementation, but WorkspaceEntriesLive is not receiving GitCoreLive in this layer composition, which causes the Git-aware path to be disabled in practice.

The fix that worked locally was to wire GitCoreLive directly into WorkspaceEntriesLive and reuse that wired layer for WorkspaceFileSystemLive, for example:

const WorkspaceEntriesLayerLive = WorkspaceEntriesLive.pipe(
  Layer.provide(WorkspacePathsLive),
  Layer.provideMerge(GitCoreLive),
);

const WorkspaceFileSystemLayerLive = WorkspaceFileSystemLive.pipe(
  Layer.provide(WorkspacePathsLive),
  Layer.provide(WorkspaceEntriesLayerLive),
);

const WorkspaceLayerLive = Layer.mergeAll(
  WorkspacePathsLive,
  WorkspaceEntriesLayerLive,
  WorkspaceFileSystemLayerLive,
);

Impact

Major degradation or frequent failure

Version or commit

3e07f5a6a412be551e1d74fe4600a31e5ef557c4

Environment

Linux, Runtime used during repro: Node 22.22.0, Installed CLI observed here: t3 0.0.17

Logs or stack traces

Screenshots, recordings, or supporting files

No response

Workaround

There does not appear to be a clean repo-side workaround when this wiring bug is present.

The workaround that succeeded locally was to patch the installed runtime so WorkspaceEntriesLive is provided GitCoreLive, then restart the T3 server. After that change, ignored paths stopped appearing in @ workspace search.

  1. nmharmon8(GitHub profile, opens in a new tab) added labelsneeds-triage

  2. Opened PR #2078 with a fix and regression test for this.

  3. juliusmarminge closed this

Sign in to join this conversation.