Commit Graph

1 Commits

Author SHA1 Message Date
William Valentin 2e277fb138 fix: preserve session state across turns in claude-code hook handler
handleNotification("Done") was incorrectly emitting session.end and
calling clearState at the end of each Claude turn. Since "Done" means
a turn finished (not the session), clearing state caused subsequent
tool calls to find no runId, storing spans without run_id and making
them invisible in run-level queries.

- handleNotification: remove session.end emission and clearState call;
  only emit run.end for the completed turn
- handleSessionEnd: load state file to get runId (in-memory activeRuns
  is always empty in a subprocess)
- handlePromptSubmit: load state file to get runId for ending previous
  run before starting a new one

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 23:42:22 -07:00