[BUG] Stats "Longest session" is the first-to-last message span, so resuming an old session reports it as a multi-week session
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
The Stats tab reports Longest session: 26d 2h 4m ("~1707x longer than an episode of The Office"). That session was not 26 days of work: it was started and used on 2026-08-11, then resumed on 2026-09-05 and used again on 09-05 and 09-06 (1,275 messages in total, per stats-cache.json). Nothing happened in it for the 25 days in between.
The value appears to be last message timestamp − first message timestamp of the session file (non-sidechain entries). Any session that is resumed after a long pause therefore becomes the "longest session", and the headline stat measures how long a session file stayed around rather than how long anyone worked in it.
What Should Happen?
Either measure active time (e.g. sum of intervals between consecutive messages, ignoring gaps over some idle threshold), or label the value honestly (e.g. "longest span between first and last message"). Resumed sessions could also be treated as separate segments.
Error Messages/Logs
None — no error is shown; the reported value is just misleading.
Steps to Reproduce
- Start a session, send a few messages, exit.
- Wait a few days.
claude --resume <that session>, send a few messages.- Open the Stats tab: "Longest session" equals the full span between the first and last message.
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.284 (Claude Code)
Platform
Anthropic API (Claude Max subscription)
Operating System
macOS
Terminal/Shell
Other (Ghostty, via tmux)
Additional Information
Related but different: #65611 and #67085 (heatmap/streak credited only to the session-start day) were about which days a resumed session counts toward; this report is about the duration shown as "Longest session".