@@ -559,6 +559,14 @@ it.effect(
559559 assert . deepEqual ( yield * outbox . listByCommandId ( commandId ) , [ ] ) ;
560560 }
561561 }
562+ if ( mode === "live" ) {
563+ yield * orchestrator . dispatch ( {
564+ type : "thread.snooze" ,
565+ commandId : CommandId . make ( "snooze-live-control" ) ,
566+ threadId,
567+ snoozedUntil : "2099-07-25T09:00:00.000Z" ,
568+ } ) ;
569+ }
562570 yield * orchestrator . dispatch (
563571 mode === "live"
564572 ? {
@@ -583,6 +591,8 @@ it.effect(
583591 assert . equal ( response . node ?. status , mode === "live" ? "completed" : "cancelled" ) ;
584592 assert . equal ( response . item ?. status , mode === "live" ? "completed" : "cancelled" ) ;
585593 if ( mode === "live" ) {
594+ assert . isNull ( ( yield * projections . getThread ( threadId ) ) . snoozedUntil ) ;
595+ assert . isNull ( ( yield * projections . getThread ( threadId ) ) . snoozedAt ) ;
586596 assert . deepEqual ( response . request ?. answers , normalizedAnswers ) ;
587597 assert . equal ( response . item ?. type , "user_input_request" ) ;
588598 if ( response . item ?. type === "user_input_request" ) {
@@ -1537,6 +1547,92 @@ it.effect("explicit settle clears snooze atomically and stays idempotent after r
15371547 } ) . pipe ( Effect . provide ( layerTest ) ) ,
15381548) ;
15391549
1550+ it . effect ( "keeps a snooze when a live question is cancelled or an approval is answered" , ( ) =>
1551+ Effect . gen ( function * ( ) {
1552+ const orchestrator = yield * Orchestrator . OrchestratorV2 ;
1553+ const projections = yield * ProjectionStore . ProjectionStoreV2 ;
1554+ const outbox = yield * EffectOutbox . EffectOutboxV2 ;
1555+ const now = yield * DateTime . now ;
1556+ for ( const kind of [ "user_input" , "command" ] as const ) {
1557+ const threadId = ThreadId . make ( `thread:snoozed-live-${ kind } ` ) ;
1558+ const requestId = RuntimeRequestId . make ( `request:snoozed-live-${ kind } ` ) ;
1559+ const sessionId = ProviderSessionId . make ( `session:snoozed-live-${ kind } ` ) ;
1560+ yield * orchestrator . dispatch ( {
1561+ type : "thread.create" ,
1562+ commandId : CommandId . make ( `create-snoozed-live-${ kind } ` ) ,
1563+ threadId,
1564+ projectId : ProjectId . make ( "project:snoozed-live" ) ,
1565+ title : "Deferred question" ,
1566+ modelSelection,
1567+ runtimeMode : "full-access" ,
1568+ interactionMode : "default" ,
1569+ branch : null ,
1570+ worktreePath : null ,
1571+ createdBy : "user" ,
1572+ creationSource : "web" ,
1573+ } ) ;
1574+ yield * orchestrator . dispatch ( {
1575+ type : "thread.snooze" ,
1576+ commandId : CommandId . make ( `snooze-live-${ kind } ` ) ,
1577+ threadId,
1578+ snoozedUntil : "2099-07-25T09:00:00.000Z" ,
1579+ } ) ;
1580+ const before = yield * projections . getThread ( threadId ) ;
1581+ yield * projections . apply ( {
1582+ id : EventId . make ( `attach-snoozed-live-${ kind } ` ) ,
1583+ type : "provider-session.attached" ,
1584+ threadId,
1585+ occurredAt : now ,
1586+ payload : {
1587+ id : sessionId ,
1588+ driver : adapter . driver ,
1589+ providerInstanceId : instanceId ,
1590+ status : "ready" ,
1591+ cwd : "/repo" ,
1592+ model : modelSelection . model ,
1593+ capabilities : CodexProviderCapabilitiesV2 ,
1594+ createdAt : now ,
1595+ updatedAt : now ,
1596+ lastError : null ,
1597+ } ,
1598+ } ) ;
1599+ yield * projections . apply ( {
1600+ id : EventId . make ( `request-snoozed-live-${ kind } ` ) ,
1601+ type : "runtime-request.updated" ,
1602+ threadId,
1603+ occurredAt : now ,
1604+ payload : {
1605+ id : requestId ,
1606+ nodeId : NodeId . make ( `node:snoozed-live-${ kind } ` ) ,
1607+ providerTurnId : null ,
1608+ nativeRequestRef : null ,
1609+ kind,
1610+ status : "pending" ,
1611+ responseCapability : { type : "live" , providerSessionId : sessionId } ,
1612+ createdAt : now ,
1613+ resolvedAt : null ,
1614+ } ,
1615+ } ) ;
1616+ const commandId = CommandId . make ( `respond-snoozed-live-${ kind } ` ) ;
1617+ yield * orchestrator . dispatch ( {
1618+ type : "runtime-request.respond" ,
1619+ commandId,
1620+ threadId,
1621+ requestId,
1622+ decision : kind === "user_input" ? "cancel" : "accept" ,
1623+ } ) ;
1624+ const after = yield * projections . getThread ( threadId ) ;
1625+ assert . deepEqual ( after . snoozedUntil , before . snoozedUntil ) ;
1626+ assert . deepEqual ( after . snoozedAt , before . snoozedAt ) ;
1627+ assert . equal ( ( yield * projections . getRuntimeRequest ( threadId , requestId ) ) ?. status , "resolved" ) ;
1628+ assert . equal (
1629+ ( yield * outbox . listByCommandId ( commandId ) ) [ 0 ] ?. request . type ,
1630+ "runtime-request.respond" ,
1631+ ) ;
1632+ }
1633+ } ) . pipe ( Effect . provide ( layerTest ) ) ,
1634+ ) ;
1635+
15401636it . effect ( "dispatch records the command outcome and its duration" , ( ) =>
15411637 Effect . gen ( function * ( ) {
15421638 const orchestrator = yield * Orchestrator . OrchestratorV2 ;
0 commit comments