fix: skip exit summary on /reload to prevent blocking#8
Open
tysoncrosbie wants to merge 1 commit intojayzeng:mainfrom
Open
fix: skip exit summary on /reload to prevent blocking#8tysoncrosbie wants to merge 1 commit intojayzeng:mainfrom
tysoncrosbie wants to merge 1 commit intojayzeng:mainfrom
Conversation
/reload emits session_shutdown with reason "reload" before rebuilding
the runtime. The session_shutdown handler was ignoring event.reason and
calling generateExitSummary() unconditionally — a live LLM API call
that blocks /reload for several seconds whenever the session has messages.
An empty session exits early (messages.length === 0) so the delay only
appears after sending at least one message, making it easy to miss.
Fix: check event.reason === "reload" and return early, skipping the LLM
call. The session continues after reload so no summary is needed.
The SessionShutdownEvent.reason field ("quit" | "reload" | "new" |
"resume" | "fork") is already part of pi's public extension API.
Closes jayzeng#7
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.
Issue #7
Description of changes
The
session_shutdownhandler callsgenerateExitSummary()unconditionally on every/reload. Since/reloademitssession_shutdownwithreason: "reload", and the session continues afterward, no exit summary is needed — but the live LLM API call still fires, blocking/reloadfor several seconds whenever the session has messages.The delay is invisible on a fresh empty session (
messages.length === 0exits early), which is why it was easy to miss.Fix: read
event.reasonin the handler and return early when it is"reload". TheSessionShutdownEvent.reasonfield is already part of pi's public extension API.Relationship to #5: that issue was also in
generateExitSummary— same path, different failure mode (throw vs. silent block).Changes
index.ts: rename_event→event, add early return forreason === "reload"test/unit.test.ts: two regression tests added to the existinglifecycle hookssuite:session_shutdown with reason=reload skips exit summary entirely— asserts no daily log file is writtensession_shutdown with reason=quit still writes exit summary— asserts the guard does not suppress real quit summariesValidation