@@ -258,6 +258,53 @@ it.layer(NodeServices.layer)("EventNdjsonLogger", (it) => {
258258 } ) ,
259259 ) ;
260260
261+ it . effect ( "drops Cursor streaming deltas while keeping its lifecycle updates" , ( ) =>
262+ Effect . gen ( function * ( ) {
263+ const tempDir = NodeFS . mkdtempSync ( NodePath . join ( NodeOS . tmpdir ( ) , "t3-provider-log-" ) ) ;
264+ const basePath = NodePath . join ( tempDir , "events.log" ) ;
265+ const threadId = ThreadId . make ( "cursor-deltas" ) ;
266+ const cursorUpdate = ( update : object ) => ( {
267+ provider : "cursor" ,
268+ kind : "protocol" ,
269+ event : {
270+ direction : "incoming" ,
271+ stage : "decoded" ,
272+ payload : { type : "interaction.update" , runId : "run-1" , update } ,
273+ } ,
274+ } ) ;
275+ const toolCall = { type : "shell" , args : { command : "ls" } } ;
276+ const transient = [
277+ { type : "text-delta" , text : "Hel" } ,
278+ { type : "thinking-delta" , text : "Hmm" } ,
279+ { type : "token-delta" , tokens : 3 } ,
280+ { type : "shell-output-delta" , event : { stdout : "a.ts\n" } } ,
281+ { type : "partial-tool-call" , callId : "call-1" , modelCallId : "m-1" , toolCall } ,
282+ ] . map ( cursorUpdate ) ;
283+ const retained = [
284+ { type : "tool-call-started" , callId : "call-1" , modelCallId : "m-1" , toolCall } ,
285+ { type : "tool-call-completed" , callId : "call-1" , modelCallId : "m-1" , toolCall } ,
286+ { type : "turn-ended" } ,
287+ ] . map ( cursorUpdate ) ;
288+
289+ try {
290+ const store = yield * makeEventNdjsonLogStore ( basePath , { batchWindowMs : 0 } ) ;
291+ const native = store . logger ( "native" ) ;
292+ for ( const event of [ ...transient , ...retained ] ) {
293+ yield * native . write ( event , threadId ) ;
294+ }
295+ yield * store . close ( ) ;
296+
297+ const records = NodeFS . readFileSync ( ownedLogPath ( basePath , "cursor-deltas" ) , "utf8" )
298+ . trim ( )
299+ . split ( "\n" )
300+ . map ( ( line ) => decodeUnknownJson ( parseLogLine ( line ) . payload ) ) ;
301+ assert . deepEqual ( records , retained ) ;
302+ } finally {
303+ NodeFS . rmSync ( tempDir , { recursive : true , force : true } ) ;
304+ }
305+ } ) ,
306+ ) ;
307+
261308 it . effect ( "bounds oversized records while retaining failure details" , ( ) =>
262309 Effect . gen ( function * ( ) {
263310 const tempDir = NodeFS . mkdtempSync ( NodePath . join ( NodeOS . tmpdir ( ) , "t3-provider-log-" ) ) ;
0 commit comments