Repository navigation
fix: deliver hands-free updates through the active API after reload - #84
Merged
Merged
Conversation
Overlay sessions survive /reload, but their update, dispatch-completion, transfer and semantic-setup-failure callbacks used the pi captured before the reload. Pi invalidates that API, so the first emit/sendMessage threw and crashed pi. Route them through coordinator.runWithExtensionApi like the headless completion path. Fixes #82
nicobailon
force-pushed
the
fix/82-stale-pi-after-reload
branch
from
October 13, 2026 06:42
8714796 to
2d91b46
Compare
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.
After
/reload, hands-free and dispatch overlay sessions keep running, but their callbacks still held thepifrom before the reload. Pi invalidates that object, so the firstpi.events.emit/pi.sendMessagewhen the session updated or exited threw "This extension ctx is stale after session replacement or reload" and took pi down through its uncaughtException handler.Those callbacks now go through
coordinator.runWithExtensionApi, the same path the headless completion already uses: it delivers on the currently bound API, or queues until the reloaded extension binds. Covered sites: the hands-free update handler, the foreground semantic setup failure message, transferred-output delivery, and the dispatch completion / moved-to-background / semantic transition messages. Message shapes and non-reload shutdown are unchanged.tests/reload-stale-api.test.tsstarts a hands-free session, reloads (old API throws pi's stale error), binds a new API, and checks that exit updates and transferred output arrive on the new API. It fails onmainwith the stale-ctx error.Fixes #82. Thanks to @masonc15 for the detailed report and repro.