Repository navigation
Keep a session's hooks, follower and commands on the Leaf copy it loaded - #6758
Merged
Merged
Conversation
A running Claude Code session's hooks, pages follower and bare `leaf` commands now run the plugin copy the session loaded, until `/reload-plugins` or a new process of the session (a background job's wake, a resume) loads the copy Claude Code has installed since. They used to hand themselves to the copy `installed_plugins.json` names, which left the hooks module and skills, which Claude Code reads only as it loads the plugin, on the loaded copy while the Python ran another. The user chose this on 2026-11-22. - `session_runtime.installed_launcher` and its rung in `delivering_launcher` go: a session's delivering Leaf is the checkout it selected, while that exists, or else its own copy. Checkout selection is unchanged (`select_launcher`, `select_checkout`, `hand_off_command` for a selected checkout, the Codex adapter, `leaf-dev preview --user`), and a selection whose checkout is gone falls back to the session's own copy. - `bin/leaf` no longer reads `installed_plugins.json` for a copy that lost its files; such a copy refuses, naming `/reload-plugins`. - The `newer-layer` refusal names `/reload-plugins` for Claude Code, since an older loaded copy can now meet a page a newer Leaf initialized, and `serving-pages.md` tells the agent the refusal says how to load a newer Leaf. - Kept, since selection still needs them: `state.plugin_cache_copy`, the follower's EX_TEMPFAIL restart and the module's handling of exit 75 (a follower moves to a newly selected checkout, or off one whose worktree went), and `registry.kernel.installed_protocol` (a selected or `--plugin-dir` checkout can move past a protocol bump under a running follower). - The session_runtime, carrier and hooks headers, `session-lifetime.md`, `bin/leaf`, `docs/how-it-works.html` and developing-leaf's landing note say what holds now. The user's choice not to check that the loaded module and the hooks' Python agree now rests on sessions whose hooks run a checkout, the only ones where the two can differ. Tests: - `test_an_older_installed_copy_delivers_through_the_copy_installed_since` becomes `test_a_bare_command_from_an_installed_copy_runs_only_a_selected_checkout`. It protects that a bare command from an installed copy runs that copy even with a newer one recorded, runs a checkout the session selected, leaves a hook to `hooks.main`, and that a checkout runs itself. - `test_an_installed_copy_that_lost_its_project_runs_the_copy_installed_since` becomes `test_a_copy_that_lost_its_project_refuses_naming_the_reload`. It protects that such a copy refuses, naming `/reload-plugins`, and runs neither the recorded copy nor uv. - Both fail on the previous code. The follower and bridge hand-off tests keep their assertions; their docstrings drop the installed copy, and `select_another_leaf` stands for another checkout, the only Leaf a session selects.
leaf-agent
approved these changes
Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A running Claude Code session's Leaf hooks, pages follower and bare
leafcommands now run the plugin copy the session loaded, until/reload-pluginsor a new process (a background job's wake, a resume) loads the copy Claude Code installed since. They used to hand themselves to the copyinstalled_plugins.jsonnames, which left the hooks module and skills on the loaded copy while the Python ran another: 828 of 1,082 active minutes across 36 job processes over a day and a half.Checkout selection is unchanged; whether to keep it is a separate decision, postponed for now. A selection whose checkout is gone now falls back to the session's own copy rather than the installed one. A loaded copy that lost its files refuses at
bin/leaf, naming/reload-plugins, instead of running another copy. Thenewer-layerrefusal now names/reload-pluginsfor Claude Code.Worth weighing: a Leaf fix reaches a background job at its next wake and a terminal session at its next restart or reload, rather than at the next hook. When the newer Leaf behind a
newer-layerrefusal was a checkout ahead of the installed copy, the reload advice won't help, and the finding can't tell the two cases apart.The maintainer chose this on the Leaf page about keeping a session on one version of Leaf (#8, first part). It supersedes #6575, which kept the hand-off and moved it into the shell launcher. Tests:
tests/model/test_hook_registration.py(two tests rewritten for the new behaviour), the follower, module-restart, bridge, selection andnewer-layertests, andtest_product_page.py, all passing. A fresh reviewer read the diff.