Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as NodeSqlite from "node:sqlite";
import { assert, it } from "@effect/vitest";
import {
CommandId,
EnvironmentId,
MessageId,
EventId,
founderInboxLane,
Expand All @@ -22,6 +23,7 @@ import {
RunAttemptId,
RunId,
RuntimeRequestId,
ScheduledTaskId,
ThreadId,
TurnItemId,
} from "@t3tools/contracts";
Expand All @@ -43,6 +45,7 @@ import {
orchestrationCommandDuration,
orchestrationCommandsTotal,
} from "../observability/Metrics.ts";
import { ServerEnvironmentIdentity } from "../environment/ServerEnvironment.ts";
import * as SqlitePersistence from "../persistence/Sqlite.ts";
import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
import * as DelegatedTaskQuestionReactor from "./DelegatedTaskQuestionReactor.ts";
Expand Down Expand Up @@ -2459,6 +2462,81 @@ it.effect("replays a thread.create receipt without changing the thread", () =>
}).pipe(Effect.provide(layerTest)),
);

it.effect("keeps a standing laptop schedule in the original thread queue through resume", () =>
Effect.gen(function* () {
const orchestrator = yield* Orchestrator.OrchestratorV2;
const projections = yield* ProjectionStore.ProjectionStoreV2;
const events = yield* EventSink.EventSinkV2;
const threadId = ThreadId.make("thread:standing-laptop");
const messageId = MessageId.make("standing-laptop:occurrence");
yield* orchestrator.dispatch({
type: "thread.create",
commandId: CommandId.make("standing-laptop:create"),
threadId,
projectId: ProjectId.make("project:standing-laptop"),
title: "Product Designer",
modelSelection,
runtimeMode: "full-access",
interactionMode: "default",
branch: null,
worktreePath: null,
createdBy: "user",
creationSource: "web",
});
yield* orchestrator.dispatch({
type: "thread.standing.set",
commandId: CommandId.make("standing-laptop:persona"),
threadId,
standing: { name: "Product Designer", avatarId: "bolt", accent: "sky" },
});
const commandId = CommandId.make("standing-laptop:schedule");
yield* orchestrator.dispatch({
type: "message.dispatch",
commandId,
threadId,
messageId,
scheduledTaskId: ScheduledTaskId.make("standing-laptop:job"),
text: "Scheduled occurrence",
attachments: [],
createdBy: "user",
creationSource: "web",
localExecution: true,
dispatchMode: { type: "start_immediately" },
});
const before = yield* projections.getThreadRecords(threadId, ["runs", "messages"]);
assert.lengthOf(before.runs, 1);
assert.equal(before.runs[0]?.status, "queued");
assert.equal(before.runs[0]?.queueHeld, true);
assert.equal(before.messages[0]?.id, messageId);
assert.equal(before.messages[0]?.scheduledTaskId, ScheduledTaskId.make("standing-laptop:job"));
yield* orchestrator.dispatch({
type: "queue.resume",
commandId: CommandId.make("standing-laptop:resume"),
threadId,
});
const after = yield* projections.getThreadRecords(threadId, ["runs", "messages"]);
assert.deepEqual(after.runs, before.runs);
assert.deepEqual(after.messages, before.messages);
assert.isFalse(
(yield* events.readByCommandId({ commandId }).pipe(Stream.runCollect)).some(
({ event }) => event.type === "run.created" && event.payload.status === "starting",
),
);
}).pipe(
Effect.provide(
layerTest.pipe(
Layer.provide(
Layer.succeed(ServerEnvironmentIdentity, {
getEnvironmentId: Effect.succeed(
EnvironmentId.make("2f360b2e-0386-498a-b9cd-62999f3525ba"),
),
}),
),
),
),
),
);

it.effect("explicit settle clears snooze atomically and stays idempotent after re-snoozing", () =>
Effect.gen(function* () {
const orchestrator = yield* Orchestrator.OrchestratorV2;
Expand Down
Loading
Loading