pub fn trim_session_jsonl(
path: &Path,
keep: usize,
) -> Result<(usize, usize, f64, f64)>Expand description
Trim a session JSONL file by keeping only the last keep requests.
Very long chat sessions (100+ requests) can grow to 50-100+ MB, causing VS Code
to fail loading them. This function compacts the session first (if needed), then
removes old requests from the requests array, keeping only the most recent ones.
The full session is preserved as a .jsonl.bak backup. A trimmed summary is
injected as the first request message so the user knows context was archived.
Returns (original_count, kept_count, original_mb, new_mb).