Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 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
3 changes: 3 additions & 0 deletions apps/server/src/auth/RpcAuthorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ export const RPC_REQUIRED_SCOPES = {
[WS_METHODS.gitResolvePullRequest]: AuthOrchestrationOperateScope,
[WS_METHODS.gitPreparePullRequestThread]: AuthOrchestrationOperateScope,
[WS_METHODS.vcsListRefs]: AuthOrchestrationReadScope,
[WS_METHODS.vcsListWorktrees]: AuthOrchestrationReadScope,
[WS_METHODS.subscribeWorktreeInventory]: AuthOrchestrationReadScope,
[WS_METHODS.vcsPruneWorktrees]: AuthOrchestrationOperateScope,
[WS_METHODS.vcsCreateWorktree]: AuthOrchestrationOperateScope,
[WS_METHODS.vcsRemoveWorktree]: AuthOrchestrationOperateScope,
[WS_METHODS.vcsCreateRef]: AuthOrchestrationOperateScope,
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/environment/ServerEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export const make = Effect.gen(function* () {
serverResolvedCommandContext: true,
environmentIcon: true,
projectCloneTracking: true,
worktreeManagement: true,
...(serverSelfUpdate === null ? {} : { serverSelfUpdate }),
// V2 restart recovery uses the environment-owned opt-in. The old
// per-update request flag is not wired into the V2 update RPC path.
Expand Down
3 changes: 3 additions & 0 deletions apps/server/src/git/GitWorkflowService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as GitManager from "./GitManager.ts";
import * as GitWorkflowService from "./GitWorkflowService.ts";
import * as GitVcsDriver from "../vcs/GitVcsDriver.ts";
import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
import * as WorktreeLifecycle from "../vcs/WorktreeLifecycle.ts";

function makeLayer(input: {
readonly detect: VcsDriverRegistry.VcsDriverRegistry["Service"]["detect"];
Expand All @@ -22,6 +23,7 @@ function makeLayer(input: {
),
Layer.provide(Layer.mock(GitVcsDriver.GitVcsDriver)({})),
Layer.provide(Layer.mock(GitManager.GitManager)({})),
Layer.provide(WorktreeLifecycle.layer),
);
}

Expand Down Expand Up @@ -131,6 +133,7 @@ describe("GitWorkflowService", () => {
status,
}),
),
Layer.provide(WorktreeLifecycle.layer),
);

return Effect.gen(function* () {
Expand Down
21 changes: 15 additions & 6 deletions apps/server/src/git/GitWorkflowService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
import * as GitManager from "./GitManager.ts";
import * as GitVcsDriver from "../vcs/GitVcsDriver.ts";
import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
import * as WorktreeLifecycle from "../vcs/WorktreeLifecycle.ts";

export class GitWorkflowService extends Context.Service<
GitWorkflowService,
Expand Down Expand Up @@ -159,6 +160,7 @@ export const make = Effect.gen(function* () {
const registry = yield* VcsDriverRegistry.VcsDriverRegistry;
const git = yield* GitVcsDriver.GitVcsDriver;
const gitManager = yield* GitManager.GitManager;
const worktreeLifecycle = yield* WorktreeLifecycle.WorktreeLifecycle;

const ensureGit = Effect.fn("GitWorkflowService.ensureGit")(function* (
operation: string,
Expand Down Expand Up @@ -335,10 +337,13 @@ export const make = Effect.gen(function* () {
"GitWorkflowService.resolvePullRequest",
gitManager.resolvePullRequest,
),
preparePullRequestThread: routeGitManager(
"GitWorkflowService.preparePullRequestThread",
gitManager.preparePullRequestThread,
),
// Creating a worktree only adds a new path, so it skips the mutation
// permit: parallel launches keep checking out (and fetching) side by side.
preparePullRequestThread: (input) =>
ensureGit("GitWorkflowService.preparePullRequestThread", input.cwd).pipe(
Effect.andThen(gitManager.preparePullRequestThread(input)),
Effect.tap(() => worktreeLifecycle.markInventoryChanged),
),
listRefs: (input) =>
detectGitRepositoryForCommand("GitWorkflowService.listRefs", input.cwd).pipe(
Effect.flatMap((isGitRepository) =>
Expand All @@ -348,6 +353,7 @@ export const make = Effect.gen(function* () {
createWorktree: (input, options) =>
ensureGitCommand("GitWorkflowService.createWorktree", input.cwd).pipe(
Effect.andThen(git.createWorktree(input, options)),
Effect.tap(() => worktreeLifecycle.markInventoryChanged),
),
listLocalBranchNames: (cwd) =>
ensureGitCommand("GitWorkflowService.listLocalBranchNames", cwd).pipe(
Expand All @@ -370,8 +376,11 @@ export const make = Effect.gen(function* () {
Effect.andThen(git.resolveRemoteTrackingCommit(input)),
),
removeWorktree: (input) =>
ensureGitCommand("GitWorkflowService.removeWorktree", input.cwd).pipe(
Effect.andThen(git.removeWorktree(input)),
worktreeLifecycle.withMutationPermit(
ensureGitCommand("GitWorkflowService.removeWorktree", input.cwd).pipe(
Effect.andThen(git.removeWorktree(input)),
Effect.tap(() => worktreeLifecycle.markInventoryChanged),
),
),
pruneWorktrees: (input) =>
ensureGitCommand("GitWorkflowService.pruneWorktrees", input.cwd).pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import * as OpenCodeServerLedger from "../provider/OpenCodeServerLedger.ts";
import { ServerSettingsService } from "../serverSettings.ts";
import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
import * as VcsProcess from "../vcs/VcsProcess.ts";
import { layerNoop as worktreeRevivalTestLayer } from "../vcs/WorktreeRevivalService.testkit.ts";
import { OrchestratorV2 } from "./Orchestrator.ts";
import { worktreeRepairDependenciesTestLayer } from "./ProviderTurnStartService.testkit.ts";
import { OrchestrationV2LayerLive } from "./runtimeLayer.ts";
import { layer as mcpSessionRegistryTestLayer } from "../mcp/McpSessionRegistry.testkit.ts";

Expand Down Expand Up @@ -128,6 +128,7 @@ const providerInstanceRegistryLayer = ProviderInstanceRegistryHydrationLive.pipe
);

const liveLayer = OrchestrationV2LayerLive.pipe(
Layer.provide(worktreeRevivalTestLayer),
Layer.provide(mcpSessionRegistryTestLayer),
Layer.provide(SqlitePersistenceMemory),
Layer.provide(checkpointStoreLayer),
Expand All @@ -136,7 +137,6 @@ const liveLayer = OrchestrationV2LayerLive.pipe(
Layer.provide(providerInstanceRegistryLayer),
Layer.provide(ResetCreditCoordinator.layer),
Layer.provide(backgroundPolicyLayer),
Layer.provide(worktreeRepairDependenciesTestLayer),
Layer.provide(PlatformTestLayer),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import * as OpenCodeServerLedger from "../provider/OpenCodeServerLedger.ts";
import { ServerSettingsService } from "../serverSettings.ts";
import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
import * as VcsProcess from "../vcs/VcsProcess.ts";
import { layerNoop as worktreeRevivalTestLayer } from "../vcs/WorktreeRevivalService.testkit.ts";
import { OrchestratorV2 } from "./Orchestrator.ts";
import { worktreeRepairDependenciesTestLayer } from "./ProviderTurnStartService.testkit.ts";
import { runDaemonWithOptions as runEffectWorkerDaemonWithOptions } from "./EffectWorker.ts";
import { OrchestrationV2LayerLive } from "./runtimeLayer.ts";
import { layer as mcpSessionRegistryTestLayer } from "../mcp/McpSessionRegistry.testkit.ts";
Expand Down Expand Up @@ -103,7 +103,7 @@ const providerInstanceRegistryLayer = ProviderInstanceRegistryHydrationLive.pipe
);

const liveLayer = OrchestrationV2LayerLive.pipe(
Layer.provide(worktreeRepairDependenciesTestLayer),
Layer.provide(worktreeRevivalTestLayer),
Layer.provide(mcpSessionRegistryTestLayer),
Layer.provide(SqlitePersistenceMemory),
Layer.provide(checkpointStoreLayer),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { ProviderInstanceRegistry } from "../provider/Services/ProviderInstanceR
import { ServerSettingsService } from "../serverSettings.ts";
import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
import * as VcsProcess from "../vcs/VcsProcess.ts";
import { layerNoop as worktreeRevivalTestLayer } from "../vcs/WorktreeRevivalService.testkit.ts";
import { WorkspacePaths } from "../workspace/WorkspacePaths.ts";
import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
import { EventSinkV2 } from "./EventSink.ts";
Expand All @@ -40,7 +41,6 @@ import {
OrchestrationV2LayerLive,
ProjectServiceLayerLive,
} from "./runtimeLayer.ts";
import { worktreeRepairDependenciesTestLayer } from "./ProviderTurnStartService.testkit.ts";

const PlatformTestLayer = Layer.merge(
NodeServices.layer,
Expand Down Expand Up @@ -105,7 +105,7 @@ const TestLayer = Layer.mergeAll(OrchestrationV2LayerLive, OrchestrationV2EventS
normalizeWorkspaceRoot: (workspaceRoot) => Effect.succeed(workspaceRoot),
}),
),
Layer.provide(worktreeRepairDependenciesTestLayer),
Layer.provide(worktreeRevivalTestLayer),
Layer.provide(
Layer.succeed(ProjectEnrichmentService, {
peek: () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import * as OpenCodeServerLedger from "../provider/OpenCodeServerLedger.ts";
import { ServerSettingsService } from "../serverSettings.ts";
import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
import * as VcsProcess from "../vcs/VcsProcess.ts";
import { layerNoop as worktreeRevivalTestLayer } from "../vcs/WorktreeRevivalService.testkit.ts";
import { OrchestratorV2 } from "./Orchestrator.ts";
import { worktreeRepairDependenciesTestLayer } from "./ProviderTurnStartService.testkit.ts";
import { OrchestrationV2LayerLive } from "./runtimeLayer.ts";
import { layer as mcpSessionRegistryTestLayer } from "../mcp/McpSessionRegistry.testkit.ts";
import { GROK_MODEL_SELECTION } from "./testkit/fixtures/shared.ts";
Expand Down Expand Up @@ -102,7 +102,7 @@ const providerInstanceRegistryLayer = ProviderInstanceRegistryHydrationLive.pipe
);

const liveLayer = OrchestrationV2LayerLive.pipe(
Layer.provide(worktreeRepairDependenciesTestLayer),
Layer.provide(worktreeRevivalTestLayer),
Layer.provide(mcpSessionRegistryTestLayer),
Layer.provide(SqlitePersistenceMemory),
Layer.provide(checkpointStoreLayer),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { ServerSettingsService } from "../serverSettings.ts";
import { SourceControlProviderRegistry } from "../sourceControl/SourceControlProviderRegistry.ts";
import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
import * as VcsProcess from "../vcs/VcsProcess.ts";
import { layerNoop as worktreeRevivalTestLayer } from "../vcs/WorktreeRevivalService.testkit.ts";
import { WorkspacePaths } from "../workspace/WorkspacePaths.ts";
import { LegacyV1ThreadImporter } from "./legacy/LegacyV1ThreadImporter.ts";
import { OrchestrationV2LayerLive, ProjectServiceLayerLive } from "./runtimeLayer.ts";
Expand Down Expand Up @@ -166,6 +167,7 @@ const makeRuntimeLayer = (dbPath: string) => {
pruneWorktrees: () => Effect.void,
}),
),
Layer.provide(worktreeRevivalTestLayer),
Layer.provide(platform),
);
};
Expand Down
Loading
Loading