@@ -152,13 +152,14 @@ function dispatchUserMessage(input: {
152152 } ) ;
153153}
154154
155- /** Records a finished source run with one exchange, as a provider turn would. */
156- function recordCompletedRun ( input : {
155+ /** Records a settled source run with one exchange, as a provider turn would. */
156+ function recordRun ( input : {
157157 readonly threadId : ThreadId ;
158158 readonly runId : RunId ;
159159 readonly ordinal : number ;
160160 readonly user : string ;
161161 readonly assistant : string ;
162+ readonly status ?: "completed" | "rolled_back" ;
162163} ) {
163164 return Effect . gen ( function * ( ) {
164165 const eventSink = yield * EventSink . EventSinkV2 ;
@@ -203,7 +204,7 @@ function recordCompletedRun(input: {
203204 userMessageId : MessageId . make ( `${ input . runId } :user` ) ,
204205 rootNodeId : null ,
205206 activeAttemptId : null ,
206- status : "completed" ,
207+ status : input . status ?? "completed" ,
207208 requestedAt : now ,
208209 startedAt : now ,
209210 completedAt : now ,
@@ -383,18 +384,26 @@ describe("ThreadTitleRegenerationService", () => {
383384 command : "command:title:fork:create" ,
384385 thread : "thread:title:fork:source" ,
385386 } ) ;
387+ yield * recordRun ( {
388+ threadId : sourceThreadId ,
389+ runId : RunId . make ( "run:title:fork:0" ) ,
390+ ordinal : 1 ,
391+ user : "Rolled back attempt" ,
392+ assistant : "Discarded." ,
393+ status : "rolled_back" ,
394+ } ) ;
386395 const forkRunId = RunId . make ( "run:title:fork:1" ) ;
387- yield * recordCompletedRun ( {
396+ yield * recordRun ( {
388397 threadId : sourceThreadId ,
389398 runId : forkRunId ,
390- ordinal : 1 ,
399+ ordinal : 2 ,
391400 user : "Move session storage from Redis to Postgres" ,
392401 assistant : "Sessions now persist in the Postgres sessions table." ,
393402 } ) ;
394- yield * recordCompletedRun ( {
403+ yield * recordRun ( {
395404 threadId : sourceThreadId ,
396405 runId : RunId . make ( "run:title:fork:2" ) ,
397- ordinal : 2 ,
406+ ordinal : 3 ,
398407 user : "Later work the fork never saw" ,
399408 assistant : "Done." ,
400409 } ) ;
@@ -436,6 +445,7 @@ describe("ThreadTitleRegenerationService", () => {
436445 assert . include ( call ?. forkSource ?. history , "Move session storage from Redis to Postgres" ) ;
437446 assert . include ( call ?. forkSource ?. history , "Sessions now persist in the Postgres" ) ;
438447 assert . notInclude ( call ?. forkSource ?. history , "Later work the fork never saw" ) ;
448+ assert . notInclude ( call ?. forkSource ?. history , "Rolled back attempt" ) ;
439449 const fork = yield * threads . getThreadProjection ( forkThreadId ) ;
440450 assert . equal ( fork . thread . title , "Generated title" ) ;
441451 } ) . pipe ( Effect . provide ( harness . layer ) ) ;
0 commit comments