Sessions interrupted mid-turn become unresumable despite intact data
Bug Description
When a session is interrupted mid-turn (e.g. terminal closed, Ctrl+C during tool execution), the session disappears from the /resume list and cannot be resumed, even though the session JSONL and history.jsonl entries are fully intact.
Steps to Reproduce
- Start a Claude Code session and have a multi-turn conversation
- Issue a prompt that triggers a tool call (e.g. an
Edit) - While the tool is executing (progress spinner visible), kill the terminal or Ctrl+C
- Reopen Claude Code in the same project directory
- Run
/resume— the interrupted session does not appear
Expected Behavior
The interrupted session should still appear in /resume. Ideally it would either:
- Be resumable from the last completed turn (before the interrupted one), or
- Appear in the list with an indicator that it was interrupted, allowing the user to resume from the last clean state
Actual Behavior
The session is silently dropped from the /resume list. The session JSONL file and history.jsonl entries remain on disk but are inaccessible through the CLI.
Analysis
Comparing an interrupted session with a cleanly-stopped session:
- Clean session ends with:
assistant→progress→system/stop_hook_summary→system/turn_duration - Interrupted session ends with:
assistant(tool_use) →progress— nostop_hook_summaryorturn_durationfor the final turn
The interrupted session had 8 prior turns that all completed cleanly (each with stop_hook_summary), but the final turn was killed mid-execution. It appears the /resume logic filters out sessions whose last turn didn't complete cleanly, rather than falling back to the last completed turn.
Suggested Fix
When building the /resume list, if a session's final entry is an incomplete turn (no stop_hook_summary), consider:
- Still showing it in
/resumeand resuming from the last cleanly-completed turn - Showing it with an "[interrupted]" label so the user knows the state
- At minimum, allowing
--resume <session-id>to force-resume even if the session is in an unclean state
Environment
- Claude Code version: 2.1.37
- OS: Fedora Silverblue (Linux 6.18.7)
- Shell: zsh (inside Fedora Toolbox container)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗