1- import {
2- CheckpointRef ,
3- DEFAULT_PROVIDER_INTERACTION_MODE ,
4- ProjectId ,
5- ThreadId ,
6- TurnId ,
7- type OrchestrationReadModel ,
8- } from "@t3tools/contracts" ;
9- import { Effect , Layer } from "effect" ;
1+ import { CheckpointRef , ProjectId , ThreadId , TurnId } from "@t3tools/contracts" ;
2+ import { Effect , Layer , Option } from "effect" ;
103import { describe , expect , it } from "vitest" ;
114
12- import { ProjectionSnapshotQuery } from "../../orchestration/Services/ProjectionSnapshotQuery.ts" ;
5+ import {
6+ ProjectionSnapshotQuery ,
7+ type ProjectionThreadCheckpointContext ,
8+ } from "../../orchestration/Services/ProjectionSnapshotQuery.ts" ;
139import { checkpointRefForThreadTurn } from "../Utils.ts" ;
1410import { CheckpointDiffQueryLive } from "./CheckpointDiffQuery.ts" ;
1511import { CheckpointStore , type CheckpointStoreShape } from "../Services/CheckpointStore.ts" ;
1612import { CheckpointDiffQuery } from "../Services/CheckpointDiffQuery.ts" ;
1713
18- function makeSnapshot ( input : {
14+ function makeThreadCheckpointContext ( input : {
1915 readonly projectId : ProjectId ;
2016 readonly threadId : ThreadId ;
2117 readonly workspaceRoot : string ;
2218 readonly worktreePath : string | null ;
2319 readonly checkpointTurnCount : number ;
2420 readonly checkpointRef : CheckpointRef ;
25- } ) : OrchestrationReadModel {
21+ } ) : ProjectionThreadCheckpointContext {
2622 return {
27- snapshotSequence : 0 ,
28- updatedAt : "2026-01-01T00:00:00.000Z" ,
29- projects : [
30- {
31- id : input . projectId ,
32- title : "Project" ,
33- workspaceRoot : input . workspaceRoot ,
34- defaultModelSelection : null ,
35- scripts : [ ] ,
36- createdAt : "2026-01-01T00:00:00.000Z" ,
37- updatedAt : "2026-01-01T00:00:00.000Z" ,
38- deletedAt : null ,
39- } ,
40- ] ,
41- threads : [
23+ threadId : input . threadId ,
24+ projectId : input . projectId ,
25+ workspaceRoot : input . workspaceRoot ,
26+ worktreePath : input . worktreePath ,
27+ checkpoints : [
4228 {
43- id : input . threadId ,
44- projectId : input . projectId ,
45- title : "Thread" ,
46- modelSelection : {
47- provider : "codex" ,
48- model : "gpt-5-codex" ,
49- } ,
50- interactionMode : DEFAULT_PROVIDER_INTERACTION_MODE ,
51- runtimeMode : "full-access" ,
52- branch : null ,
53- worktreePath : input . worktreePath ,
54- latestTurn : {
55- turnId : TurnId . makeUnsafe ( "turn-1" ) ,
56- state : "completed" ,
57- requestedAt : "2026-01-01T00:00:00.000Z" ,
58- startedAt : "2026-01-01T00:00:00.000Z" ,
59- completedAt : "2026-01-01T00:00:00.000Z" ,
60- assistantMessageId : null ,
61- } ,
62- createdAt : "2026-01-01T00:00:00.000Z" ,
63- updatedAt : "2026-01-01T00:00:00.000Z" ,
64- archivedAt : null ,
65- deletedAt : null ,
66- messages : [ ] ,
67- activities : [ ] ,
68- proposedPlans : [ ] ,
69- checkpoints : [
70- {
71- turnId : TurnId . makeUnsafe ( "turn-1" ) ,
72- checkpointTurnCount : input . checkpointTurnCount ,
73- checkpointRef : input . checkpointRef ,
74- status : "ready" ,
75- files : [ ] ,
76- assistantMessageId : null ,
77- completedAt : "2026-01-01T00:00:00.000Z" ,
78- } ,
79- ] ,
80- session : null ,
29+ turnId : TurnId . makeUnsafe ( "turn-1" ) ,
30+ checkpointTurnCount : input . checkpointTurnCount ,
31+ checkpointRef : input . checkpointRef ,
32+ status : "ready" ,
33+ files : [ ] ,
34+ assistantMessageId : null ,
35+ completedAt : "2026-01-01T00:00:00.000Z" ,
8136 } ,
8237 ] ,
8338 } ;
@@ -95,7 +50,7 @@ describe("CheckpointDiffQueryLive", () => {
9550 readonly cwd : string ;
9651 } > = [ ] ;
9752
98- const snapshot = makeSnapshot ( {
53+ const threadCheckpointContext = makeThreadCheckpointContext ( {
9954 projectId,
10055 threadId,
10156 workspaceRoot : "/tmp/workspace" ,
@@ -125,7 +80,12 @@ describe("CheckpointDiffQueryLive", () => {
12580 Layer . provideMerge ( Layer . succeed ( CheckpointStore , checkpointStore ) ) ,
12681 Layer . provideMerge (
12782 Layer . succeed ( ProjectionSnapshotQuery , {
128- getSnapshot : ( ) => Effect . succeed ( snapshot ) ,
83+ getSnapshot : ( ) =>
84+ Effect . die ( "CheckpointDiffQuery should not request the full orchestration snapshot" ) ,
85+ getCounts : ( ) => Effect . succeed ( { projectCount : 0 , threadCount : 0 } ) ,
86+ getActiveProjectByWorkspaceRoot : ( ) => Effect . succeed ( Option . none ( ) ) ,
87+ getFirstActiveThreadIdByProjectId : ( ) => Effect . succeed ( Option . none ( ) ) ,
88+ getThreadCheckpointContext : ( ) => Effect . succeed ( Option . some ( threadCheckpointContext ) ) ,
12989 } ) ,
13090 ) ,
13191 ) ;
@@ -175,12 +135,11 @@ describe("CheckpointDiffQueryLive", () => {
175135 Layer . provideMerge (
176136 Layer . succeed ( ProjectionSnapshotQuery , {
177137 getSnapshot : ( ) =>
178- Effect . succeed ( {
179- snapshotSequence : 0 ,
180- projects : [ ] ,
181- threads : [ ] ,
182- updatedAt : "2026-01-01T00:00:00.000Z" ,
183- } satisfies OrchestrationReadModel ) ,
138+ Effect . die ( "CheckpointDiffQuery should not request the full orchestration snapshot" ) ,
139+ getCounts : ( ) => Effect . succeed ( { projectCount : 0 , threadCount : 0 } ) ,
140+ getActiveProjectByWorkspaceRoot : ( ) => Effect . succeed ( Option . none ( ) ) ,
141+ getFirstActiveThreadIdByProjectId : ( ) => Effect . succeed ( Option . none ( ) ) ,
142+ getThreadCheckpointContext : ( ) => Effect . succeed ( Option . none ( ) ) ,
184143 } ) ,
185144 ) ,
186145 ) ;
0 commit comments