Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): queue messages sent during context compaction #9620

Closedflamboh(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/9620/headopened View on GitHub

Showing 5 changed files with 139 additions and 0 deletions (loading 4).

x
0 of 5 viewed, 5 left
139 additions and 0 deletionsapps/server/src/orchestration/Layers/ProjectionPipeline.test.tsModified
View file
@@ -3259,6 +3259,145 @@
assert.deepEqual(pendingRows, [{ messageId: "new-message" }]);
+​
+ it.effect("promotes a turn start deferred behind compaction when the session restores", () =>
+ Effect.gen(function* () {
+ const projectionPipeline = yield* OrchestrationProjectionPipeline;
+ const eventStore = yield* OrchestrationEventStore;
+ const sql = yield* SqlClient.SqlClient;
+ const threadId = ThreadId.make("thread-deferred-compaction-turn");
+ const compactMessageId = MessageId.make("message-deferred-compact");
+ const queuedMessageId = MessageId.make("message-deferred-queued");
+ const compactAt = "2026-02-26T16:00:00.000Z";
+ const queuedAt = "2026-02-26T16:00:01.000Z";
+​
+ for (const [index, message] of [
+ { id: compactMessageId, text: "/compact", createdAt: compactAt },
+ { id: queuedMessageId, text: "send after compact", createdAt: queuedAt },
+ ].entries()) {
+ yield* eventStore.append({
+ type: "thread.message-sent",
+ eventId: EventId.make(`evt-deferred-message-${index}`),
+ aggregateKind: "thread",
+ aggregateId: threadId,
+ occurredAt: message.createdAt,
+ commandId: CommandId.make(`cmd-deferred-message-${index}`),
+ causationEventId: null,
+ correlationId: CorrelationId.make(`cmd-deferred-message-${index}`),
+ metadata: {},