@@ -3517,8 +3517,10 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
35173517 WHERE message.thread_id = child.thread_id
35183518 AND message.message_id = json_extract(terminal.payload_json, '$.userMessageId')
35193519 AND CASE WHEN json_valid(message.payload_json) THEN
3520- json_extract(message.payload_json, '$.notification.source.kind') = 'monitor'
3520+ json_extract(message.payload_json, '$.notification') IS NOT NULL
3521+ OR json_extract(message.payload_json, '$.scheduledTaskId') IS NOT NULL
35213522 OR (json_extract(message.payload_json, '$.creationSource') = 'server'
3523+ AND json_extract(message.payload_json, '$.createdBy') IS NOT 'user'
35223524 AND NOT (
35233525 (terminal.ordinal = 1 AND json_extract(message.payload_json, '$.notification') IS NULL)
35243526 OR json_extract(terminal.payload_json, '$.restartContinuationOfRunId') IS NOT NULL
@@ -6304,42 +6306,40 @@ export const layerMemory: Layer.Layer<ProjectionStoreV2> = Layer.effect(
63046306 ) ,
63056307 getThreadSnapshotWindow : ( threadId , options ) =>
63066308 service . getThreadSnapshot ( threadId ) . pipe (
6307- Effect . flatMap ( ( snapshot ) =>
6308- Effect . gen ( function * ( ) {
6309- const anchorIndex =
6310- options . anchorItemId === undefined
6311- ? snapshot . projection . visibleTurnItems . length
6312- : snapshot . projection . visibleTurnItems . findIndex (
6313- ( row ) => row . sourceItemId === options . anchorItemId ,
6314- ) + 1 ;
6315- const candidates = snapshot . projection . visibleTurnItems . slice ( 0 , anchorIndex ) ;
6316- const turnAnchors =
6317- options . userTurnLimit === undefined
6318- ? [ ]
6319- : candidates . flatMap ( ( row , index ) =>
6320- isThreadHistoryTurnStart ( row . item ) ? [ index ] : [ ] ,
6321- ) ;
6322- const rawStart = turnAnchors . at ( - ( THREAD_HISTORY_MAX_RAW_TURNS + 2 ) ) ?? 0 ;
6323- const anchors = turnAnchors . filter (
6324- ( index ) => index >= rawStart && isThreadHistoryUserTurn ( candidates [ index ] ! . item ) ,
6325- ) ;
6326- const anchorLimit = ( options . userTurnLimit ?? 0 ) + 2 ;
6327- const start =
6328- anchors . length > 0
6329- ? anchors . length < anchorLimit
6330- ? rawStart
6331- : anchors . at ( - anchorLimit ) !
6332- : Math . max ( 0 , anchorIndex - options . rowLimit ) ;
6333- const visibleTurnItems = candidates . slice ( start ) ;
6334- return {
6335- ...snapshot ,
6336- projection : {
6337- ...snapshot . projection ,
6338- visibleTurnItems,
6339- } ,
6340- } ;
6341- } ) ,
6342- ) ,
6309+ Effect . map ( ( snapshot ) => {
6310+ const anchorIndex =
6311+ options . anchorItemId === undefined
6312+ ? snapshot . projection . visibleTurnItems . length
6313+ : snapshot . projection . visibleTurnItems . findIndex (
6314+ ( row ) => row . sourceItemId === options . anchorItemId ,
6315+ ) + 1 ;
6316+ const candidates = snapshot . projection . visibleTurnItems . slice ( 0 , anchorIndex ) ;
6317+ const turnAnchors =
6318+ options . userTurnLimit === undefined
6319+ ? [ ]
6320+ : candidates . flatMap ( ( row , index ) =>
6321+ isThreadHistoryTurnStart ( row . item ) ? [ index ] : [ ] ,
6322+ ) ;
6323+ const rawStart = turnAnchors . at ( - ( THREAD_HISTORY_MAX_RAW_TURNS + 2 ) ) ?? 0 ;
6324+ const anchors = turnAnchors . filter (
6325+ ( index ) => index >= rawStart && isThreadHistoryUserTurn ( candidates [ index ] ! . item ) ,
6326+ ) ;
6327+ const anchorLimit = ( options . userTurnLimit ?? 0 ) + 2 ;
6328+ const start =
6329+ anchors . length > 0
6330+ ? anchors . length < anchorLimit
6331+ ? rawStart
6332+ : anchors . at ( - anchorLimit ) !
6333+ : Math . max ( 0 , anchorIndex - options . rowLimit ) ;
6334+ const visibleTurnItems = candidates . slice ( start ) ;
6335+ return {
6336+ ...snapshot ,
6337+ projection : {
6338+ ...snapshot . projection ,
6339+ visibleTurnItems,
6340+ } ,
6341+ } ;
6342+ } ) ,
63436343 ) ,
63446344 } ;
63456345
0 commit comments