Description
When reattaching to a session with a large log file (>1MB), replay_session_log() reads the entire file from the beginning. For sessions with heavy output (build logs, progress bars, ANSI sequences), this causes thousands of lines to scroll rapidly, appearing as an infinite loop.
Reproduction
- Create a session and run a long build (e.g., cmake) generating >1MB of output
- Detach
- Reattach → output scrolls for a very long time
Root cause
replay_session_log() reads from byte 0 of the log file regardless of size. There's no cap on how much is replayed.
Suggested fix
lseek to max(0, filesize - SCROLLBACK_SIZE) before reading, consistent with the 128KB in-memory ring buffer.