@@ -162,10 +162,32 @@ export async function loadConversationRecord(
162162
163163 const sessionId = getMatch ( headStr , / " s e s s i o n I d " \s * : \s * " ( [ ^ " ] + ) " / ) ;
164164 const projectHash = getMatch ( headStr , / " p r o j e c t H a s h " \s * : \s * " ( [ ^ " ] + ) " / ) ;
165- const startTime = getMatch ( headStr , / " s t a r t T i m e " \s * : \s * " ( [ ^ " ] + ) " / ) ;
165+ let startTime = getMatch ( headStr , / " s t a r t T i m e " \s * : \s * " ( [ ^ " ] + ) " / ) ;
166+ let filenameTimestamp : string | undefined ;
167+
168+ // Fallback: Extract startTime from filename if not in header (format: session-YYYY-MM-DDTHH-MM-8CHARS.jsonl)
169+ if ( ! startTime || ! getMatch ( tailStr , / " l a s t U p d a t e d " \s * : \s * " ( [ ^ " ] + ) " / ) ) {
170+ const basename = path . basename ( filePath ) ;
171+ const timeMatch = basename . match (
172+ / s e s s i o n - ( \d { 4 } - \d { 2 } - \d { 2 } T \d { 2 } - \d { 2 } ) / ,
173+ ) ;
174+ if ( timeMatch ) {
175+ // Convert session-2026-05-10T11-45-... to valid ISO 2026-05-10T11:45:00Z
176+ filenameTimestamp =
177+ timeMatch [ 1 ] . replace ( / - / g, ( m , offset ) =>
178+ offset > 10 ? ':' : '-' ,
179+ ) + ':00Z' ;
180+ }
181+ }
182+
183+ if ( ! startTime ) {
184+ startTime = filenameTimestamp ;
185+ }
186+
166187 const lastUpdated =
167188 getMatch ( tailStr , / " l a s t U p d a t e d " \s * : \s * " ( [ ^ " ] + ) " / ) ||
168- getMatch ( headStr , / " l a s t U p d a t e d " \s * : \s * " ( [ ^ " ] + ) " / ) ;
189+ getMatch ( headStr , / " l a s t U p d a t e d " \s * : \s * " ( [ ^ " ] + ) " / ) ||
190+ filenameTimestamp ;
169191 const summary =
170192 getMatch ( tailStr , / " s u m m a r y " \s * : \s * " ( (?: [ ^ " \\ \\ ] | \\ \\ .) * ) " / ) ||
171193 getMatch ( headStr , / " s u m m a r y " \s * : \s * " ( (?: [ ^ " \\ \\ ] | \\ \\ .) * ) " / ) ;
0 commit comments