Skip to content

Commit 24ad635

Browse files
committed
fix: replace nowIsoSync with effectful nowIso to respect runtime clock
nowIsoSync used Effect.runSync which creates a fresh execution context bypassing the fiber's runtime clock, making timestamps uncontrollable via TestClock. Replace with an effectful nowIso constant used via Effect.flatMap inside Effect.catch handlers, ensuring DateTime.now is properly evaluated within the fiber's clock context.
1 parent af3bba4 commit 24ad635

1 file changed

Lines changed: 25 additions & 19 deletions

File tree

apps/server/src/orchestration/Layers/CheckpointReactor.ts

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { isGitRepository } from "../../git/Utils.ts";
3333
import { VcsStatusBroadcaster } from "../../vcs/VcsStatusBroadcaster.ts";
3434
import { WorkspaceEntries } from "../../workspace/Services/WorkspaceEntries.ts";
3535

36-
const nowIsoSync = () => Effect.runSync(DateTime.now.pipe(Effect.map(DateTime.formatIso)));
36+
const nowIso = DateTime.now.pipe(Effect.map(DateTime.formatIso));
3737

3838
type ReactorInput =
3939
| {
@@ -724,12 +724,14 @@ const make = Effect.gen(function* () {
724724
if (event.type === "thread.checkpoint-revert-requested") {
725725
yield* handleRevertRequested(event).pipe(
726726
Effect.catch((error) =>
727-
appendRevertFailureActivity({
728-
threadId: event.payload.threadId,
729-
turnCount: event.payload.turnCount,
730-
detail: error.message,
731-
createdAt: nowIsoSync(),
732-
}),
727+
Effect.flatMap(nowIso, (createdAt) =>
728+
appendRevertFailureActivity({
729+
threadId: event.payload.threadId,
730+
turnCount: event.payload.turnCount,
731+
detail: error.message,
732+
createdAt,
733+
}),
734+
),
733735
),
734736
);
735737
return;
@@ -743,12 +745,14 @@ const make = Effect.gen(function* () {
743745
if (event.type === "thread.turn-diff-completed") {
744746
yield* captureCheckpointFromPlaceholder(event).pipe(
745747
Effect.catch((error) =>
746-
appendCaptureFailureActivity({
747-
threadId: event.payload.threadId,
748-
turnId: event.payload.turnId,
749-
detail: error.message,
750-
createdAt: nowIsoSync(),
751-
}).pipe(Effect.catch(() => Effect.void)),
748+
Effect.flatMap(nowIso, (createdAt) =>
749+
appendCaptureFailureActivity({
750+
threadId: event.payload.threadId,
751+
turnId: event.payload.turnId,
752+
detail: error.message,
753+
createdAt,
754+
}),
755+
).pipe(Effect.catch(() => Effect.void)),
752756
),
753757
);
754758
}
@@ -767,12 +771,14 @@ const make = Effect.gen(function* () {
767771
yield* refreshLocalGitStatusFromTurnCompletion(event);
768772
yield* captureCheckpointFromTurnCompletion(event).pipe(
769773
Effect.catch((error) =>
770-
appendCaptureFailureActivity({
771-
threadId: event.threadId,
772-
turnId,
773-
detail: error.message,
774-
createdAt: nowIsoSync(),
775-
}).pipe(Effect.catch(() => Effect.void)),
774+
Effect.flatMap(nowIso, (createdAt) =>
775+
appendCaptureFailureActivity({
776+
threadId: event.threadId,
777+
turnId,
778+
detail: error.message,
779+
createdAt,
780+
}),
781+
).pipe(Effect.catch(() => Effect.void)),
776782
),
777783
);
778784
return;

0 commit comments

Comments
 (0)