Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(orchestration): speed up new-chat propagation and offline catch-up #4177

MergedRusiruSadathana(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/4177/headmerged by juliusmarminge View on GitHub

Showing 7 changed files with 14 additions and 0 deletions (loading 4).

x
0 of 7 viewed, 7 left
2 additions and 0 deletionsapps/server/src/orchestration/Layers/OrchestrationEngine.test.tsModified
View file
@@ -218,6 +218,7 @@
const runtime = ManagedRuntime.make(layer);
​
const engine = await runtime.runPromise(Effect.service(OrchestrationEngineService));
+ expect(await runtime.runPromise(engine.latestSequence)).toBe(7);
const result = await runtime.runPromise(
engine.dispatch({
type: "thread.meta.update",
@@ -228,6 +229,7 @@
​
expect(result.sequence).toBe(8);
+ expect(await runtime.runPromise(engine.latestSequence)).toBe(8);
expect(fullSnapshotReadCount).toBe(0);
​
await runtime.dispose();
5 additions and 0 deletionsapps/server/src/orchestration/Layers/OrchestrationEngine.tsModified
View file
@@ -329,6 +329,11 @@
get streamDomainEvents(): OrchestrationEngineShape["streamDomainEvents"] {
return Stream.fromPubSub(eventPubSub);
+ // The command read model's snapshotSequence tracks the latest committed
+ // event sequence (updated on the worker fiber). A plain property read is a
+ // consistent, committed value — reassignment of `commandReadModel` is
+ // atomic on the single-threaded event loop.
+ latestSequence: Effect.sync(() => commandReadModel.snapshotSequence),