Skip to content

fix(watch): route a hook report to the session that sent it - #38

Merged
pfriedrix merged 1 commit into
chore/strip-commentsfrom
fix/route-hooks-by-session
Aug 7, 2026
Merged

fix(watch): route a hook report to the session that sent it#38
pfriedrix merged 1 commit into
chore/strip-commentsfrom
fix/route-hooks-by-session

Conversation

@pfriedrix

Copy link
Copy Markdown
Owner
  • The daemon matched every hook report against the worktree path and took the first session there. A worktree is not a unique key — lcc open starts a second session in one that already has another — so with four sessions in one worktree every report landed on the same row.
  • Each session now gets hooks-<id>.json with its id baked into every hook command line beside the event, for the same reason the event is baked in rather than parsed out of a payload. A report with no id still falls back to the worktree (that is what an older daemon's sessions send), and both that fallback and the dashboard's worktree merge now prefer a live session over an exited one.

Review notes

Measured on PE-289, four sessions deep. The row the reports landed on had already exited; apply keeps exited terminal, so nothing moved except its last_event_at — a dead session carrying an activity timestamp two minutes younger than its own death. The two live agents under it were frozen at the idle their first byte of output set. The dashboard merged the worktree onto that same first row, so it reported a corpse for a worktree with two agents working in it, and enter on that row could not attach.

Both new tests were checked red against the old behaviour before being committed green.

~/.config/lcc/hooks.json is now unused and can be deleted; the per-session files are bounded by max_sessions and reused, since session ids restart at s-00000001 with each daemon.

Stacked on #37.

The daemon matched every report against the worktree path in the payload
and took the first session it found there. A worktree is not a unique
key — `lcc open` will start a second session in one that already has
another — so with four sessions in the same worktree every hook landed on
the same row.

Measured on PE-289, four sessions deep: the row the reports landed on had
already exited, `apply` keeps `exited` terminal, so nothing moved except
its `last_event_at`, which is why a dead session carried an activity
timestamp two minutes younger than its own death. The two live agents
under it were never updated at all — frozen at the `idle` their first byte
of output set, whatever they went on to do. The dashboard then merged the
worktree onto that same first row, so it reported a corpse for a worktree
with two agents working in it, and enter on that row could not attach.

Each session now gets its own settings file, `hooks-<id>.json`, with its
id baked into every hook command line beside the event — the same reason
the event is baked in rather than parsed out of a payload. Reports name
their session and route exactly. A report with no id still falls back to
the worktree, which is what a session started by an older daemon sends,
and both that fallback and the dashboard's merge now prefer a session that
is still alive over one that has exited.
@pfriedrix
pfriedrix merged commit 3c469ea into chore/strip-comments Aug 7, 2026
@pfriedrix
pfriedrix deleted the fix/route-hooks-by-session branch August 7, 2026 14:23
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