[BUG] SessionEnd hooks never fire for long-lived `remote-control` sessions — lifecycle automation silently dead

Open 💬 1 comment Opened Jul 3, 2026 by Crasher545

Environment: Claude Code v2.1.195 (also present on 2.1.200), Ubuntu 24.04 (LXC), claude remote-control running under systemd (Restart=always), driven from the Claude mobile app.

Description:
The hook system assumes sessions are mortal. A persistent remote-control host process holds sessions open for days, so SessionEnd never occurs — and every SessionEnd hook (we use them for transcript archiving and metrics snapshots) silently never runs. Stop hooks with once-per-session semantics fire once per multi-DAY session instead of once per work-session. There is no error and no signal: the automation just doesn't exist on that host. We only noticed when per-session artifacts existed for our other machines but not this one, while unarchived transcripts piled up in ~/.claude/projects/<slug>/.

Repro:

  1. Run claude remote-control under systemd with Restart=always.
  2. Register any SessionEnd hook (e.g. copy transcript_path somewhere).
  3. Use the session from the mobile app across several days.
  4. SessionEnd hook never executes; transcripts accumulate unarchived.

Verified workaround (may help others): systemctl restart (SIGTERM, default KillMode=control-group) DOES run SessionEnd hooks for all held sessions on graceful shutdown — verified on v2.1.195. We run a nightly restart timer plus an idempotent archive-sweep script as a crash backstop.

Ask: fire SessionEnd when a remote-control conversation ends/detaches, or provide conversation-level lifecycle hook events for long-lived hosts.

Adjacent: #33612 (SessionStart hooks skipped for non-terminal clients, closed by stale-bot) — for what it's worth, SessionStart hooks DO fire in this always-on architecture on v2.1.195–2.1.200.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗