@@ -88,6 +88,7 @@ const TranscriptRecord = Schema.Struct({
8888 cwd : Schema . optional ( Schema . String ) ,
8989 sessionId : Schema . optional ( Schema . String ) ,
9090 aiTitle : Schema . optional ( Schema . String ) ,
91+ customTitle : Schema . optional ( Schema . String ) ,
9192 isSidechain : Schema . optional ( Schema . Boolean ) ,
9293 isMeta : Schema . optional ( Schema . Boolean ) ,
9394 isCompactSummary : Schema . optional ( Schema . Boolean ) ,
@@ -277,6 +278,7 @@ function parseAgentSessionRecords(
277278 // timestamp text, so only transcript metadata can provide a resumable ID.
278279 let providerSessionId = input . source === "codex" ? "" : input . fallbackSessionId ;
279280 let title : string | null = null ;
281+ let customTitle : string | null = null ;
280282 let derivedTitle : string | undefined ;
281283 let model : string | null = null ;
282284 let hasCodexSessionId = false ;
@@ -379,6 +381,10 @@ function parseAgentSessionRecords(
379381 }
380382 if ( record . sessionId ?. trim ( ) ) providerSessionId = record . sessionId . trim ( ) ;
381383 if ( record . aiTitle ?. trim ( ) ) title = record . aiTitle . trim ( ) ;
384+ // Claude rewrites both title records on every flush, so the user's
385+ // rename is tracked separately instead of racing the later ai-title.
386+ // An empty customTitle is how Claude clears a rename.
387+ if ( record . customTitle !== undefined ) customTitle = record . customTitle . trim ( ) || null ;
382388 const messageModel = record . message ?. model ?. trim ( ) ;
383389 // Claude uses this sentinel for local error responses. It is not a
384390 // model ID that can be selected when the imported session resumes.
@@ -471,7 +477,7 @@ function parseAgentSessionRecords(
471477 source : input . source ,
472478 providerInstanceId : input . providerInstanceId ,
473479 providerSessionId,
474- title : title ?? derivedTitle ?? "Imported thread" ,
480+ title : customTitle ?? title ?? derivedTitle ?? "Imported thread" ,
475481 model,
476482 createdAt : retainedMessages [ 0 ] ?. createdAt ?? fallbackTimestamp ,
477483 updatedAt : fallbackTimestamp ,
@@ -495,6 +501,7 @@ function shouldRetainDecodedRecord(
495501 record . type === "assistant" ||
496502 record . sessionId !== undefined ||
497503 record . aiTitle !== undefined ||
504+ record . customTitle !== undefined ||
498505 record . message ?. model !== undefined
499506 ) ;
500507 }
0 commit comments