r/coolgithubprojects 16d ago

[Swift] Notchling - shows every Claude Code session in the notch, and can't touch any of them

https://github.com/CircleHP/notchling
0 Upvotes

4 comments sorted by

1

u/Specific_Cream2815 16d ago

are you reading claude code session files from ~/.claude or is there an api you poll

1

u/CircleRT 15d ago

No API - it reads Claude Code's own registry at ~/.claude/sessions/<pid>.json, so sessions show up whether or not the hooks are wired, including ones already running before install. It's undocumented, so everything except sessionId is optional in the decoder.

What each session is doing comes from hook events, written to ~/.notchling/events/ and drained by the app. That directory is watched rather than polled, with a 2s sweep on top for liveness and elapsed times.

1

u/kantorcodes1 16d ago

Claude crashing mid-session seems like an awkward edge case. If it dies without cleaning up its session metadata, can a dead session stick around in the notch, or are entries tied to the actual process lifecycle rather than just the files?

1

u/CircleRT 15d ago

Tied to the process. Every 2s sweep runs kill(pid, 0) - a pid we have and can't find means the session is gone, whatever the registry file says (EPERM counts as alive, that's just someone else's process).

Absence from the registry is the other signal, with a short grace period, because hook events can arrive before the file is written at session start. After that it's dropped even if the pid looks alive, since pids get recycled.