Repository navigation
fix: bind the extension API at session_start, not in the factory - #86
Merged
Merged
Conversation
During /reload pi runs extension factories before the new runtime exists, so action methods like sendMessage throw until session_start. Binding in the factory flushed queued session messages into that stub (failing the extension load) and delivered later ones to it (crashing pi from PTY callbacks). Delivery now binds only at session_start. /spawn --worktree also skips its closing notice when a reload replaced the command context while the overlay was open. Fixes #85
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.
During
/reload, pi runs extension factories while the new runtime's action methods are still a loader stub that throws "Extension runtime not initialized". The real runtime exists only right beforesession_start. Our factory bound the coordinator's API first thing, so for sessions that survive a reload:session_shutdownwere flushed inside the factory,sendMessagethrew, and pi reported the extension as failed to load;session_startran on the stub and threw from a PTY callback, crashing pi the same way as Hands-free update handler crashes pi after /reload #82.The API is now bound only in
session_start, so those messages wait and are delivered once to the reloaded session. Tools, commands, and shortcuts cannot run beforesession_start, and headless semantic supervision stays paused through the loading window, as it already was after shutdown./spawn --worktreealso skips its "Worktree left in place" notice when the overlay outlived a reload, since that commandctxis stale.tests/reload-stale-api.test.tssends one update before the new factory runs and one after it but beforesession_start; neither may throw, nothing is sent early, and both arrive in order afterwards. It fails onmainwith the "not initialized" error. Two test harnesses that never firedsession_startnow do, matching pi.Fixes #85.