@devries-cameron20 / t3code Mirror · read-only / commits / b796da9b7e
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 22, 07:00 UTC

perf(server): sending a message no longer rereads the thread from the database after settle, snooze or title updates (#28301)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Victor Vogel committed Nov 1, 2026 at 16:04 UTC b796da9b7e784b5ddcaed535be5b75553e3e1a5d
2 files changed +20 -7
apps/server/src/orchestration-v2/Orchestrator.ts
+6 -6
@@ -5483,7 +5483,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
5483 : now,
5484 updatedAt: now,
5485 };
5486 - yield* emit(
5486 + const event = yield* emit(
5487 events,
5488 command,
5489 )({
@@ -5493,7 +5493,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
5493 occurredAt: now,
5494 payload: thread,
5495 });
5496 - projection = yield* getProjectionWithPendingEvents(command.threadId, events);
5496 + projection = applyToProjection(projection, event);
5497 }
5498 // Background wakes and delegated completions continue work the user already snoozed, so
5499 // only a message someone actually sent ends the snooze.
@@ -5507,7 +5507,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
5507 snoozedAt: null,
5508 updatedAt: now,
5509 };
5510 - yield* emit(
5510 + const event = yield* emit(
5511 events,
5512 command,
5513 )({
@@ -5517,7 +5517,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
5517 occurredAt: now,
5518 payload: thread,
5519 });
5520 - projection = yield* getProjectionWithPendingEvents(command.threadId, events);
5520 + projection = applyToProjection(projection, event);
5521 }
5522 const userMessages = projection.messages.filter((message) => message.role === "user");
5523 const onlyMaintenanceHistory =
@@ -5537,7 +5537,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
5537 titleRegeneration: { requestId: command.commandId, startedAt: now },
5538 updatedAt: now,
5539 };
5540 - yield* emit(
5540 + const event = yield* emit(
5541 events,
5542 command,
5543 )({
@@ -5554,7 +5554,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
5554 messageId: command.messageId,
5555 }),
5556 ]);
5557 - projection = yield* getProjectionWithPendingEvents(command.threadId, events);
5557 + projection = applyToProjection(projection, event);
5558 }
5559 const modelSelection = command.modelSelection ?? projection.thread.modelSelection;
5560 let dispatchMode = resolveMessageDispatchIntent(
apps/server/src/orchestration-v2/runtimeLayer.test.ts
+14 -1
@@ -6940,7 +6940,7 @@ it.layer(layerScratchPromotionTest)("turning a No project thread into a project"
6940 });
6941
6942 it.layer(layerSharedApplicationDataPlaneTest)("snooze projection", (it) => {
6943 - it.effect("carries snooze state through the V2 shell projection", () =>
6943 + it.effect("carries snooze, settle and title state through the V2 shell projection", () =>
6944 Effect.gen(function* () {
6945 const projects = yield* ProjectService.ProjectService;
6946 const orchestrator = yield* Orchestrator.OrchestratorV2;
@@ -7009,6 +7009,11 @@ it.layer(layerSharedApplicationDataPlaneTest)("snooze projection", (it) => {
7009 );
7010 const [candidate] = yield* projections.getSettlementCandidates(threadId);
7011 assert.deepEqual(candidate?.lastSnoozeWakeAt, yield* DateTime.now);
7012 + yield* orchestrator.dispatch({
7013 + type: "thread.settle",
7014 + commandId: CommandId.make("runtime-layer-snoozed-thread-settle"),
7015 + threadId,
7016 + });
7017 yield* orchestrator.dispatch({
7018 type: "thread.snooze",
7019 commandId: CommandId.make("runtime-layer-snoozed-thread-snooze-after-wake"),
@@ -7024,6 +7029,7 @@ it.layer(layerSharedApplicationDataPlaneTest)("snooze projection", (it) => {
7029 threadId,
7030 messageId: MessageId.make("runtime-layer-snoozed-message"),
7031 text: "Wake this thread.",
7032 + titleSeed: "Woken thread",
7033 attachments: [],
7034 modelSelection,
7035 dispatchMode: { type: "start_immediately" },
@@ -7032,6 +7038,13 @@ it.layer(layerSharedApplicationDataPlaneTest)("snooze projection", (it) => {
7038 const awakened = yield* orchestrator.getThreadProjection(threadId);
7039 assert.isNull(awakened.thread.snoozedUntil);
7040 assert.isNull(awakened.thread.snoozedAt);
7041 + assert.isNull(awakened.thread.settledOverride);
7042 + assert.isNull(awakened.thread.settledAt);
7043 + assert.equal(awakened.thread.title, "Woken thread");
7044 + assert.equal(
7045 + awakened.thread.titleRegeneration?.requestId,
7046 + CommandId.make("runtime-layer-snoozed-message"),
7047 + );
7048 }),
7049 );
7050