Expand description
Read Claude Code’s own session-state file:
~/.claude/sessions/<PID>.json. The file holds Claude’s view of the
UI status — busy (mid-turn), idle (at chat prompt),
waiting (selection / permission dialog up) — keyed by the Claude
process PID. That makes it a perfect primary signal for the
dashboard: no pane scraping, no pattern matching, no session-UUID
mapping.
Caveats (per codex review):
- Undocumented surface — Claude could rename / restructure / drop the file at any version. Treat as best-effort telemetry.
- Partial writes are possible — JSON parse failure on a fresh mtime means we should retry rather than mis-classify.
- Stale entries can outlive the process. Caller already gates on a
live PID via sysinfo, but a check on
version/updatedAtis still worth surfacing if drift is observed.
All failure paths return None so the dashboard stays alive and
falls back to the pane-capture classifier.
Structs§
Enums§
Functions§
- read
- Read + parse the per-PID session file. Returns
Noneon any failure path (missing, unreadable, malformed JSON, unrecognised status) so the caller can fall back to another signal. - session_
path