Expand description
The transcript watcher (Feed 2): an engine-owned background task that scans
~/.claude/projects/**/*.jsonl for new and growing session transcripts and
feeds the SessionsRegistry.
It exists to cover the two gaps a purely hook-driven feed leaves:
- Discovery — a session that started before the daemon (or before hooks
were installed) fires no
SessionStartthe daemon can see; its transcript file still appears, so the watcher discovers it. - The thinking window — between
UserPromptSubmitand the firstPreToolUse(~5–15s) no hook fires, but the transcript keeps growing, so the watcher marks the sessionworkingthrough the gap.
Per ADR-0052 the watcher parses only file presence and growth (size/mtime)
— never the per-line transcript schema, which is explicitly internal and
version-unstable. The session_id comes from the filename stem; cwd is left
unknown (the encoded directory name is a lossy /→- transform that cannot be
reliably reversed — the hook feed supplies the real cwd, and
SessionsRegistry::observe never clobbers a known cwd with None).
Only transcripts touched within [RECENT_ACTIVITY_WINDOW] are surfaced, so a
fresh daemon does not flood the registry with hundreds of long-dead historical
sessions on its first scan — ancient files are recorded (for later
growth comparison) but never announced.
Functions§
- spawn
- Spawns the watcher loop, returning its
JoinHandle.