Problem
SessionManager::list_sessions (crates/tui/src/session_manager.rs:306) reads and JSON-parses every session file in ~/.deepseek/sessions/ to build a Vec<SessionMetadata>. cleanup_old_sessions (line 346) calls list_sessions then sorts and prunes — meaning every cleanup pays the full parse cost for files that are about to be deleted anyway.
For a user with hundreds of historical sessions, this lags the startup path and any session-listing UI.
Fix
Add a metadata-only path:
- Read each session file's first ~4KB only (enough to JSON-parse the header:
id, created_at, last_modified, turn_count, model, etc).
- For
cleanup_old_sessions, use the metadata-only path — we don't need full session contents to decide what to delete.
- Keep the full-parse path for
load_session.
Verify against the existing tests (test_list_sessions at line 586) and add one for the metadata-only path.
Acceptance criteria
Problem
SessionManager::list_sessions(crates/tui/src/session_manager.rs:306) reads and JSON-parses every session file in~/.deepseek/sessions/to build aVec<SessionMetadata>.cleanup_old_sessions(line 346) callslist_sessionsthen sorts and prunes — meaning every cleanup pays the full parse cost for files that are about to be deleted anyway.For a user with hundreds of historical sessions, this lags the startup path and any session-listing UI.
Fix
Add a metadata-only path:
id,created_at,last_modified,turn_count,model, etc).cleanup_old_sessions, use the metadata-only path — we don't need full session contents to decide what to delete.load_session.Verify against the existing tests (
test_list_sessionsat line 586) and add one for the metadata-only path.Acceptance criteria
list_sessions_metadata()returns header-only metadata without full parse.cleanup_old_sessionsswitches to the metadata path.list_sessionsand tests untouched (load + parse semantics preserved for callers that need the full session).