Skip to content

feat(watch): let a session's status survive the daemon that ran it - #39

Merged
pfriedrix merged 2 commits into
masterfrom
feature/recover-session-status-from-hooks
Aug 7, 2026
Merged

feat(watch): let a session's status survive the daemon that ran it#39
pfriedrix merged 2 commits into
masterfrom
feature/recover-session-status-from-hooks

Conversation

@pfriedrix

Copy link
Copy Markdown
Owner
  • A replaced daemon used to erase the registry within a second of starting, so every worktree but the one just started read no session — eight sessions became one live row and seven blanks. Hooks now persist what they report to a per-session file, and the dashboard reads it for any worktree with no live session.
  • The sessions themselves still die with the daemon; only the status comes back. Recovered rows deliberately carry no session id, which is what keeps Row.attachable false so enter restarts the work with --resume instead of asking for a pty nothing holds. An interrupted turn reads waiting, not active.
  • Transcripts were the other candidate source and would also have covered sessions that died before this ships. Rejected: it reintroduces a dependency on Claude Code's internal .jsonl shape, which is what the hook-based statuses exist to avoid. Nothing here is retroactive.

Verified with 289 unit tests (up from 269), a ReleaseFast build, and an end-to-end hook run against an isolated LCC_WATCH_DIR covering the write, the plan-mode carry-forward across an event that reports no mode, and the SessionEnd cleanup.

A fresh daemon starts with an empty session list and flushes it a second
later, so sessions.json loses every row the previous one recorded. The
dashboard then joins the worktrees against a registry holding only the
session just started, and every other row reads `no session`. Eight
sessions became one live row and seven blanks, with nothing left to say
which had been mid-turn and which had finished.

The sessions themselves cannot come back — the ptys are revoked with the
daemon. The status can. Every hook already receives the worktree, the
Claude Code session id and the permission mode, and already drops all of
it when the socket is not there; it now writes that report to a small
file of its own first, which the dashboard reads for any worktree with no
live session. Reading Claude Code's transcripts would have covered more,
including sessions that died before this shipped, at the cost of the
dependency on its internals that the hooks exist to avoid.

A recovered row carries no session id, so enter starts the work again
with --resume instead of asking for a pty nothing holds. An interrupted
turn reads waiting rather than active: it has no process left, and a turn
in flight is a claim only a running one can make.
The sanity check CLAUDE.md prescribes is that the pass count moved when a
source file is added; it is worth less when the number to compare against
is two hundred tests stale.
@pfriedrix
pfriedrix merged commit db6dd8b into master Aug 7, 2026
1 check passed
@pfriedrix
pfriedrix deleted the feature/recover-session-status-from-hooks branch August 7, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant