parseSessionEntryLine function
Parses one JSONL entry line into its SessionRecord.
Public for the windowed reader (session_chunk_reader.dart). Throws
SessionException on a torn or foreign line — windowed callers treat
that as "skip this line", never as a fatal open failure.
Implementation
SessionRecord parseSessionEntryLine(
String line,
String filePath,
int lineNumber,
) {
Object? parsed;
try {
parsed = jsonDecode(line);
} on Object catch (error) {
_invalidEntry(filePath, lineNumber, 'is not valid JSON', error);
}
if (parsed is! Map<String, dynamic>) {
_invalidEntry(filePath, lineNumber, 'is not a valid session entry');
}
try {
return SessionRecord.fromJson(parsed);
} on FormatException catch (error) {
_invalidEntry(filePath, lineNumber, error.message, error);
}
}