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
9 changes: 5 additions & 4 deletions apps/server/src/orchestration-v2/CheckpointService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -924,10 +924,11 @@ export const layer: Layer.Layer<
const repositoryScopesIfReadable: CheckpointServiceV2Shape["repositoryScopesIfReadable"] =
Effect.fn("CheckpointService.repositoryScopes")(
function* (input) {
const [workspace, submodules] = yield* Effect.all([
workspaceFolders.forThread(input),
workspaceFolders.submodules(input),
]);
const workspace = yield* workspaceFolders.forThread(input);
const submodules = yield* workspaceFolders.submodules({
...input,
folders: workspace.folders,
});
return yield* Effect.forEach(
[...workspace.folders.filter((folder) => folder.isGitRepository), ...submodules],
(folder) =>
Expand Down
22 changes: 13 additions & 9 deletions apps/server/src/workspace/WorkspaceFolders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,17 +330,21 @@ it.layer(NodeServices.layer)("WorkspaceFolders", (it) => {
folders: [],
extraRoots: [],
});
assert.deepEqual(yield* workspaceFolders.submodules({ projectId, worktreePath: null }), [
{ name: "lib", path: path.join(workspaceRoot, "vendor", "lib"), isGitRepository: true },
{
name: "deep",
path: path.join(workspaceRoot, "vendor", "lib", "deep"),
isGitRepository: true,
},
]);
const { folders } = yield* workspaceFolders.forThread({ projectId, worktreePath: null });
assert.deepEqual(
yield* workspaceFolders.submodules({ projectId, worktreePath: null, folders }),
[
{ name: "lib", path: path.join(workspaceRoot, "vendor", "lib"), isGitRepository: true },
{
name: "deep",
path: path.join(workspaceRoot, "vendor", "lib", "deep"),
isGitRepository: true,
},
],
);
// A worktree reaches its own submodules, named by where the project folder has them.
assert.deepEqual(
yield* workspaceFolders.submodules({ projectId, worktreePath: worktree }),
yield* workspaceFolders.submodules({ projectId, worktreePath: worktree, folders: [] }),
[
{
name: "lib",
Expand Down
5 changes: 3 additions & 2 deletions apps/server/src/workspace/WorkspaceFolders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export class WorkspaceFolders extends Context.Service<
readonly submodules: (input: {
readonly projectId: ProjectId;
readonly worktreePath: string | null;
/** The thread's `forThread` folders; passed in so the project is walked once. */
readonly folders: ReadonlyArray<ThreadFolder>;
}) => Effect.Effect<ReadonlyArray<ThreadFolder>, WorkspaceFoldersError>;
readonly list: (
input: WorkspaceListFoldersInput,
Expand Down Expand Up @@ -508,7 +510,6 @@ const make = Effect.gen(function* () {
const submodules: WorkspaceFolders["Service"]["submodules"] = Effect.fn(
"WorkspaceFolders.submodules",
)(function* (input) {
const { folders } = yield* forThread(input);
// A worktree can outlive its project record; its submodules are then named by where they are.
const projectRoot = yield* readProject(input.projectId).pipe(
Effect.map((project) => path.resolve(project.workspaceRoot)),
Expand All @@ -520,7 +521,7 @@ const make = Effect.gen(function* () {
const identity = Option.getOrElse(projectRoot, () => root);
return yield* submodulesOf([
{ path: root, identity },
...folders.flatMap((folder) =>
...input.folders.flatMap((folder) =>
folder.isGitRepository
? [{ path: folder.path, identity: folder.repositoryPath ?? folder.path }]
: [],
Expand Down
Loading