@devries-cameron20 / t3code Mirror · read-only / commits / 79b8fd7b00
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 25, 17:15 UTC

Fix ProviderCommandReactor: add error recovery and deduplicate CWD resolution

- Wrap processDomainEvent in catchCause to prevent the reactor fiber from terminating on handler errors, matching the pattern used by ProviderRuntimeIngestion and CheckpointReactor. - Replace duplicated resolveEffectiveThreadCwd with the shared resolveThreadWorkspaceCwd from checkpointing/Utils.ts.

Cursor Agent committed Feb 26, 2026 at 18:49 UTC 79b8fd7b0096c3a75e69e877df1d5253daa7e1f8
1 file changed +17 -21
apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
+17 -21
@@ -8,8 +8,9 @@ import {
8 type ThreadId,
9 type TurnId,
10 } from "@t3tools/contracts";
11 -import { Cache, Duration, Effect, Layer, Option, Queue, Stream } from "effect";
11 +import { Cache, Cause, Duration, Effect, Layer, Option, Queue, Stream } from "effect";
12
13 +import { resolveThreadWorkspaceCwd } from "../../checkpointing/Utils.ts";
14 import { ProviderService } from "../../provider/Services/ProviderService.ts";
15 import { OrchestrationEngineService } from "../Services/OrchestrationEngine.ts";
16 import {
@@ -33,24 +34,6 @@ function toNonEmptyProviderInput(value: string | undefined): string | undefined
34 return normalized && normalized.length > 0 ? normalized : undefined;
35 }
36
36 -function resolveEffectiveThreadCwd(input: {
37 - readonly thread: {
38 - readonly projectId: string;
39 - readonly worktreePath: string | null;
40 - };
41 - readonly projects: ReadonlyArray<{
42 - readonly id: string;
43 - readonly workspaceRoot: string;
44 - }>;
45 -}): string | undefined {
46 - const worktreeCwd = input.thread.worktreePath ?? undefined;
47 - if (worktreeCwd) {
48 - return worktreeCwd;
49 - }
50 -
51 - return input.projects.find((project) => project.id === input.thread.projectId)?.workspaceRoot;
52 -}
53 -
37 function mapProviderSessionStatusToOrchestrationStatus(
38 status: "connecting" | "ready" | "running" | "error" | "closed",
39 ): OrchestrationSession["status"] {
@@ -161,7 +144,7 @@ const make = Effect.gen(function* () {
144 thread.session?.providerName === "codex" || thread.session?.providerName === "claudeCode"
145 ? thread.session.providerName
146 : undefined;
164 - const effectiveCwd = resolveEffectiveThreadCwd({
147 + const effectiveCwd = resolveThreadWorkspaceCwd({
148 thread,
149 projects: readModel.projects,
150 });
@@ -353,12 +336,25 @@ const make = Effect.gen(function* () {
336 }
337 });
338
339 + const processDomainEventSafely = (event: ProviderIntentEvent) =>
340 + processDomainEvent(event).pipe(
341 + Effect.catchCause((cause) => {
342 + if (Cause.hasInterruptsOnly(cause)) {
343 + return Effect.failCause(cause);
344 + }
345 + return Effect.logWarning("provider command reactor failed to process event", {
346 + eventType: event.type,
347 + cause: Cause.pretty(cause),
348 + });
349 + }),
350 + );
351 +
352 const start: ProviderCommandReactorShape["start"] = Effect.gen(function* () {
353 const queue = yield* Queue.unbounded<ProviderIntentEvent>();
354 yield* Effect.addFinalizer(() => Queue.shutdown(queue).pipe(Effect.asVoid));
355
356 yield* Effect.forkScoped(
361 - Effect.forever(Queue.take(queue).pipe(Effect.flatMap(processDomainEvent))),
357 + Effect.forever(Queue.take(queue).pipe(Effect.flatMap(processDomainEventSafely))),
358 );
359
360 yield* Effect.forkScoped(