Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 76 additions & 5 deletions apps/server/src/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
};
};

const workspaceAndProjectServicesLayer = Layer.mergeAll(

Check warning on line 196 in apps/server/src/server.test.ts

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

eslint(no-unused-vars)

Variable 'workspaceAndProjectServicesLayer' is declared but never used. Unused variables should start with a '_'.
WorkspacePathsLive,
WorkspaceEntriesLive.pipe(Layer.provide(WorkspacePathsLive)),
WorkspaceFileSystemLive.pipe(
Expand Down Expand Up @@ -370,9 +370,32 @@
...options?.config,
};
const layerConfig = Layer.succeed(ServerConfig, config);
const gitCoreLayer = Layer.mock(GitCore)({
isInsideWorkTree: () => Effect.succeed(false),
listWorkspaceFiles: () =>
Effect.succeed({
paths: [],
truncated: false,
}),
filterIgnoredPaths: (_cwd, relativePaths) => Effect.succeed(relativePaths),
...options?.layers?.gitCore,
});
const gitManagerLayer = Layer.mock(GitManager)({
...options?.layers?.gitManager,
});
const workspaceEntriesLayer = WorkspaceEntriesLive.pipe(
Layer.provide(WorkspacePathsLive),
Layer.provideMerge(gitCoreLayer),
);
const workspaceAndProjectServicesLayer = Layer.mergeAll(
WorkspacePathsLive,
workspaceEntriesLayer,
WorkspaceFileSystemLive.pipe(
Layer.provide(WorkspacePathsLive),
Layer.provide(workspaceEntriesLayer),
),
ProjectFaviconResolverLive,
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Local variable shadows module-level constant creating dead code

Low Severity

The new local workspaceAndProjectServicesLayer inside buildAppUnderTest shadows the module-level constant of the same name (line 196). The only usage at line 543 is inside buildAppUnderTest, so the module-level definition is now dead code. Worse, the module-level version lacks GitCoreLive — so if someone mistakenly removes the local redefinition assuming it's redundant, the gitignore fix silently regresses. The module-level constant needs to be removed or the local variable renamed.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 650e69f. Configure here.

const gitStatusBroadcasterLayer = options?.layers?.gitStatusBroadcaster
? Layer.mock(GitStatusBroadcaster)({
...options.layers.gitStatusBroadcaster,
Expand Down Expand Up @@ -416,11 +439,7 @@
...options?.layers?.open,
}),
),
Layer.provide(
Layer.mock(GitCore)({
...options?.layers?.gitCore,
}),
),
Layer.provide(gitCoreLayer),
Layer.provide(gitManagerLayer),
Layer.provideMerge(gitStatusBroadcasterLayer),
Layer.provide(
Expand Down Expand Up @@ -2017,6 +2036,58 @@
}).pipe(Effect.provide(NodeHttpServer.layerTest)),
);

it.effect("routes websocket rpc projects.searchEntries excludes gitignored files", () =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const workspaceDir = yield* fs.makeTempDirectoryScoped({
prefix: "t3-ws-project-search-gitignored-",
});
yield* fs.writeFileString(path.join(workspaceDir, ".gitignore"), ".venv/\n");
yield* fs.makeDirectory(path.join(workspaceDir, ".venv", "lib"), { recursive: true });
yield* fs.writeFileString(
path.join(workspaceDir, ".venv", "lib", "ignored-search-target.ts"),
"export const ignored = true;",
);
yield* fs.makeDirectory(path.join(workspaceDir, "src"), { recursive: true });
yield* fs.writeFileString(
path.join(workspaceDir, "src", "tracked.ts"),
"export const ok = 1;",
);

yield* buildAppUnderTest({
layers: {
gitCore: {
isInsideWorkTree: () => Effect.succeed(true),
listWorkspaceFiles: () =>
Effect.succeed({
paths: ["src/tracked.ts"],
truncated: false,
}),
filterIgnoredPaths: (_cwd, relativePaths) =>
Effect.succeed(
relativePaths.filter((relativePath) => !relativePath.startsWith(".venv/")),
),
},
},
});

const wsUrl = yield* getWsServerUrl("/ws");
const response = yield* Effect.scoped(
withWsRpcClient(wsUrl, (client) =>
client[WS_METHODS.projectsSearchEntries]({
cwd: workspaceDir,
query: "ignored-search-target",
limit: 10,
}),
),
);

assert.equal(response.entries.length, 0);
assert.equal(response.truncated, false);
}).pipe(Effect.provide(NodeHttpServer.layerTest)),
);

it.effect("routes websocket rpc projects.searchEntries errors", () =>
Effect.gen(function* () {
yield* buildAppUnderTest();
Expand Down
17 changes: 12 additions & 5 deletions apps/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,20 @@ const GitLayerLive = Layer.empty.pipe(

const TerminalLayerLive = TerminalManagerLive.pipe(Layer.provide(PtyAdapterLive));

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,
WorkspaceEntriesLive.pipe(Layer.provide(WorkspacePathsLive)),
WorkspaceFileSystemLive.pipe(
Layer.provide(WorkspacePathsLive),
Layer.provide(WorkspaceEntriesLive.pipe(Layer.provide(WorkspacePathsLive))),
),
WorkspaceEntriesLayerLive,
WorkspaceFileSystemLayerLive,
);

const AuthLayerLive = ServerAuthLive.pipe(
Expand Down
Loading