perf: optimize message array traversal in session parsing
Replaced the double array clone and reverse search pattern `[...messages].reverse().find(...)` in `buildSessionSummary` with a single reverse loop. This avoids multiple O(N) array memory allocations and traverses the array backwards with early returns, achieving the same result faster and more efficiently.
Co-authored-by: catoncat <204556023+catoncat@users.noreply.github.com>
authored by