Skip to content
TypeScript

fix(server): pinning a settled thread stamps its return to the active list (#29602)

Alex Southwell30f7600ec82b
diff --git a/apps/server/src/orchestration-v2/Orchestrator.ts b/apps/server/src/orchestration-v2/Orchestrator.ts
index 16256585dc5..08ba4ab5cc0 100644
--- a/apps/server/src/orchestration-v2/Orchestrator.ts
+++ b/apps/server/src/orchestration-v2/Orchestrator.ts
@@ -3559,6 +3559,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
settledOverride:
thread.settledOverride === "settled" ? "active" : thread.settledOverride,
settledAt: thread.settledOverride === "settled" ? null : thread.settledAt,
+ ...(thread.settledOverride === "settled" ? { unsettledAt: now } : {}),
snoozedUntil: null,
snoozedAt: null,
lastSnoozeWakeAt: thread.snoozedUntil == null ? thread.lastSnoozeWakeAt : now,
diff --git a/apps/server/src/orchestration-v2/runtimeLayer.test.ts b/apps/server/src/orchestration-v2/runtimeLayer.test.ts
index 34d252457e6..796a50435ab 100644
--- a/apps/server/src/orchestration-v2/runtimeLayer.test.ts
+++ b/apps/server/src/orchestration-v2/runtimeLayer.test.ts
@@ -2659,6 +2659,20 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
);
assert.deepEqual(activeShell?.unsettledAt, activeProjection.thread.unsettledAt);
+ yield* orchestrator.dispatch({
+ type: "thread.settle",
+ commandId: CommandId.make("runtime-layer-lifecycle-resettle"),
+ threadId,
+ });
+ yield* orchestrator.dispatch({
+ type: "thread.pin",
+ commandId: CommandId.make("runtime-layer-lifecycle-pin-settled"),
+ threadId,
+ });
+ const pinnedProjection = yield* orchestrator.getThreadProjection(threadId);
+ assert.equal(pinnedProjection.thread.settledOverride, "active");
+ assert.isNotNull(pinnedProjection.thread.unsettledAt);
+
const archive = yield* orchestrator.dispatch({
type: "thread.archive",
commandId: CommandId.make("runtime-layer-lifecycle-archive"),