Skip to content

fix: keep Claude Code wake tracking on main turns - #3511

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-3510
Oct 21, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/issue-3510

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

Managed Claude Code sessions bypass the module's classic.Stop link, so Leaf cannot use that link to decide when a turn ends. The module now tracks main-loop turn.start and turn.complete alone and ignores subagent starts; input arriving during Stop hooks stays for the watch started at turn completion. This removes the skipped-link notice and lets an idle main loop wake after a subagent starts.

The regression test failed before the change because the subagent start suppressed the wake, and passes after it. Thirteen focused Claude Code module tests and pnpm run check pass. One other module test cannot create an AF_UNIX socket in this runner; the live Claude Code journey could not start a session within 300 seconds, so that path remains unverified here.

Closes #3510 — automated triage

Drop the classic.Stop module link so managed Claude Code sessions do not bypass it. Track only main-loop turn starts and completions; a subagent turn after the main turn no longer suppresses the watch's wake. Replace the obsolete Stop-link test with a regression for that idle wake.

Closes #3510
@leaf-agent
leaf-agent merged commit ecd8140 into main Oct 21, 2026
4 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-3510 branch October 21, 2026 23:46
max-sixty added a commit that referenced this pull request Oct 22, 2026
…the hooks module's watch opt-in (#3512)

Claude Code's watch between turns goes back to the background
`asyncRewake` Stop hook, and the hooks module's watch becomes opt-in
again behind the plugin's `hooks_module` option. The band above the
prompt stays on in both cases.

Since #3399 the module has been the only watcher. It wakes an idle
session with `$.prompt.submit`, which Claude Code draws as a full
user-styled prompt: "The leaf plugin sent a message: Leaf: <page path>
has new input…" followed by the engine's paragraph on plugin prompts.
The background hook's wake draws as one dim "Stop hook feedback" row. A
survey of transcripts since 2026-10-13 also found two kinds of visible
rows that only the module produces. One is a queued wake that fires as
an empty turn after the user's own prompt has already taken the input (2
of 4 module wakes). The other is a pair of `leaf: Leaf: … exit code 143`
notices when the session's children are terminated while it is idle.

- `hooks/hooks.json` gets the background Stop registration back, and
`hooks/scripts/background-watch.py` gets its supervisor back. The
supervisor stands down when `CLAUDE_PLUGIN_OPTION_HOOKS_MODULE` is
`true`, which Claude Code exports to each of the plugin's hooks. This
replaces the `leaf_watch` payload mark, which relied on the module's
`classic.Stop` link, a link #3511 found is bypassed in managed sessions.
- `hooks/claude-code.ts` starts watches only while
`options.hooks_module` is on, and draws the band either way.
- `leaf-dev journey claude-code --hooks-module` is back, so both
watchers run the same journey. On Claude Code 2.1.307 both pass every
step. The default run shows 8 "Stop hook feedback" rows and 1
cross-session nudge. The module run shows 2 plugin prompts and 3 nudges,
and its debug log shows no asyncRewake wake, which confirms the
background hook stood down.
- The shipped Claude Code reference, `session-lifetime.md`, the harness
declarations, the README and the site's integration notes describe the
background watch as the default again.

Comparing the two watchers properly, and cutting what the module shows,
comes in a follow-up.

> _This was written by Claude Code on behalf of max-sixty_
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.

Leaf's Claude Code module never runs its classic.Stop hook where an organization manages Claude Code

1 participant