Skip to content

bug: closing Claude Code session doesn't terminate the tmux session #71

@alexsiri7

Description

@alexsiri7

Problem

When the user closes/exits a Claude Code session (e.g., via /exit, closing the terminal tab, or Ctrl+C), the underlying tmux session managed by the gc controller remains alive. The user gets kicked out of the interactive session, but the claude process continues running in the tmux pane, consuming tokens on every re-prime or system reminder.

This compounds with #70 (gc handoff doesn't trigger controller restart) — the user has no way to cleanly end a session:

Expected behavior

When the user exits Claude Code:

  1. The claude process in the tmux session should terminate
  2. The controller should detect the session ended
  3. If work is pending, controller should restart the session (fresh context)
  4. If no work, session stays stopped until new work arrives

Observed behavior

  • User closes Claude Code → gets disconnected from the session
  • tmux session stays alive with the claude process still running
  • Agent continues responding to system reminders and cron jobs
  • Tokens are consumed with no user present
  • User has to manually kill the tmux session or wait for it to die

Impact

Token waste. The mayor session was re-primed multiple times after the user tried to end it, each prime injecting the full context (~thousands of tokens) with no productive work being done.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugBroken behaviorpriority/p1High — core workflow broken

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions