Skip to content

SessionEnd hook does not fire when Claude Code subprocess is terminated by Kanna #71

Description

@GlebGlebovAKAJJ

Environment

  • Kanna: v0.41.5
  • Claude Code: 2.1.143
  • OS: Linux (Debian, amd64)
  • Deployed as a persistent server via supervisord (not desktop app)

Description

The Stop hook fires correctly after each agent response. However, the SessionEnd hook never fires when a Kanna session ends — neither when the browser window is closed, nor when the Kanna server process is stopped (via SIGTERM from
supervisord).

Claude Code hooks are configured in the project's .claude/settings.json:

{
"hooks": {
"Stop": [{ "hooks": [{ "type": "command", "command": "python3 ..." }] }],
"SessionEnd": [{ "hooks": [{ "type": "command", "command": "bash ..." }] }]
}
}

Steps to reproduce

  1. Configure a SessionEnd hook in .claude/settings.json of any project.
  2. Open Kanna, start a conversation in that project.
  3. Close the browser tab or stop the Kanna server.
  4. Observe: SessionEnd hook is never executed.

Expected behavior

When Kanna terminates a Claude Code session (gracefully or on server shutdown), the underlying Claude Code process should receive a graceful shutdown signal so the SessionEnd hook fires before the process exits.

Impact

SessionEnd is the standard integration point for post-session automation (report generation, session archiving, cleanup). Without it, Kanna is incompatible with hook-based pipelines that rely on session lifecycle events.

Possible fix

Ensure that when a session ends (browser disconnect, explicit close, or server shutdown), Kanna sends SIGTERM to the Claude Code subprocess and waits for graceful exit rather than killing it immediately

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions