fix: don't wait for sessions that are older then 120s#545
Conversation
Entire-Checkpoint: e933e20e67cc
PR SummaryLow Risk Overview Adds unit tests covering stale files (returns quickly), recent files (still waits ~3s without a sentinel), and nonexistent files (completes without hanging). Written by Cursor Bugbot for commit a009258. Configure here. |
There was a problem hiding this comment.
Pull request overview
This pull request optimizes the transcript flush waiting mechanism in Claude Code agent lifecycle management by adding a fast-path check for stale transcript files. The change prevents unnecessary 3-second polling loops when waiting for transcripts that haven't been modified in over 2 minutes, which indicates the agent is no longer running.
Changes:
- Added stale file detection (2-minute threshold) to skip polling when agent clearly isn't active
- Added comprehensive test coverage for stale, recent, and nonexistent file scenarios
- Maintains existing timeout behavior for recently-modified files
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| cmd/entire/cli/agent/claudecode/lifecycle.go | Implements stale file check using os.Stat and ModTime() comparison before entering the poll loop |
| cmd/entire/cli/agent/claudecode/lifecycle_test.go | Adds three test cases covering stale (10min old), recent (just created), and nonexistent file scenarios with timing assertions |
Entire-Checkpoint: cd7235a190d2
Entire-Checkpoint: 8c595b62e952
Added a stale file check at the top of waitForTranscriptFlush: if the transcript file's mtime is older than 2 minutes, skip the poll loop entirely. The agent clearly isn't running, so the sentinel will never appear.
Files changed:
Not fixed (potential follow-ups)