@@ -1450,9 +1450,11 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => {
14501450 const claudeHomePath = yield * makeTempDir ( "t3code-record-budget-claude-" ) ;
14511451 const codexHomePath = yield * makeTempDir ( "t3code-record-budget-codex-" ) ;
14521452 const workspace = yield * makeTempDir ( "t3code-record-budget-workspace-" ) ;
1453- for ( const [ sessionId , padding , mtimeMs ] of [
1454- [ "excessive" , "\n" . repeat ( 100_001 ) , nowMs ] ,
1455- [ "older" , "" , nowMs - 1_000 ] ,
1453+ const exactLimit = makeRecordLimitTranscript ( workspace , false ) ;
1454+ // The newer transcript has 100,001 records; the older one has exactly 100,000.
1455+ for ( const [ sessionId , contents , mtimeMs ] of [
1456+ [ "excessive" , exactLimit . replace ( "record-limit-session" , "excessive" ) + "{}\n" , nowMs ] ,
1457+ [ "older" , exactLimit , nowMs - 1_000 ] ,
14561458 ] as const ) {
14571459 yield * writeTranscript ( {
14581460 filePath : path . join (
@@ -1463,27 +1465,68 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => {
14631465 "24" ,
14641466 `rollout-${ sessionId } .jsonl` ,
14651467 ) ,
1468+ contents,
1469+ mtimeMs,
1470+ } ) ;
1471+ }
1472+ const outcomes = yield * runRecentThreadOutcomes ( {
1473+ claudeHomePath,
1474+ codexHomePath,
1475+ workspaceRoot : workspace ,
1476+ } ) ;
1477+ expect ( outcomes . map ( ( outcome ) => outcome . _tag ) ) . toEqual ( [ "Skipped" , "Importable" ] ) ;
1478+ expect ( outcomes [ 1 ] ) . toMatchObject ( {
1479+ thread : { providerSessionId : "record-limit-session" } ,
1480+ } ) ;
1481+ } ) ,
1482+ ) ;
1483+
1484+ it . effect ( "imports every transcript that fits the per-file record limit" , ( ) =>
1485+ Effect . gen ( function * ( ) {
1486+ const path = yield * Path . Path ;
1487+ const nowMs = Date . parse ( "2026-08-24T12:00:00.000Z" ) ;
1488+ yield * TestClock . setTime ( nowMs ) ;
1489+ const claudeHomePath = yield * makeTempDir ( "t3code-shared-records-claude-" ) ;
1490+ const codexHomePath = yield * makeTempDir ( "t3code-shared-records-codex-" ) ;
1491+ const workspace = yield * makeTempDir ( "t3code-shared-records-workspace-" ) ;
1492+ // Together these exceed 100,000 records, but each one is individually valid.
1493+ const recordCounts = [ 20_000 , 20_000 , 20_000 , 58_000 ] ;
1494+ for ( const [ index , recordCount ] of recordCounts . entries ( ) ) {
1495+ yield * writeTranscript ( {
1496+ filePath : path . join (
1497+ codexHomePath ,
1498+ "sessions" ,
1499+ "2026" ,
1500+ "08" ,
1501+ "24" ,
1502+ `rollout-${ index } .jsonl` ,
1503+ ) ,
14661504 contents :
14671505 [
14681506 encodeTranscriptRecord ( {
14691507 type : "session_meta" ,
1470- payload : { id : sessionId , cwd : workspace } ,
1508+ payload : { id : `session- ${ index } ` , cwd : workspace } ,
14711509 } ) ,
14721510 encodeTranscriptRecord ( {
14731511 type : "event_msg" ,
14741512 payload : { type : "user_message" , message : "Imported prompt" } ,
14751513 } ) ,
1476- ] . join ( "\n" ) + padding ,
1477- mtimeMs,
1514+ ] . join ( "\n" ) +
1515+ "\n" +
1516+ "{}\n" . repeat ( recordCount - 2 ) ,
1517+ mtimeMs : nowMs - index * 1_000 ,
14781518 } ) ;
14791519 }
14801520 const outcomes = yield * runRecentThreadOutcomes ( {
14811521 claudeHomePath,
14821522 codexHomePath,
14831523 workspaceRoot : workspace ,
14841524 } ) ;
1485- expect ( outcomes . map ( ( outcome ) => outcome . _tag ) ) . toEqual ( [ "Skipped" , "Importable" ] ) ;
1486- expect ( outcomes [ 1 ] ) . toMatchObject ( { thread : { providerSessionId : "older" } } ) ;
1525+ expect (
1526+ outcomes . map ( ( outcome ) =>
1527+ outcome . _tag === "Importable" ? outcome . thread . providerSessionId : outcome . _tag ,
1528+ ) ,
1529+ ) . toEqual ( [ "session-0" , "session-1" , "session-2" , "session-3" ] ) ;
14871530 } ) ,
14881531 ) ;
14891532
0 commit comments