Repository navigation
Run async/asyncRewake hooks in the background instead of awaiting them - #124
Merged
Merged
Conversation
Claude Code runs command hooks flagged async/asyncRewake in the background. pi-code awaited every hook, so a Stop hook with a long timeout held the turn open for the hook's full duration and the session appeared frozen (#123). Per the documented contract: background hooks (command type only) fire without blocking and render no decision; timeout is not enforced on async while asyncRewake keeps its own; an asyncRewake exit 2 wakes the model with the hook's stderr as a new turn; other completions deliver systemMessage/additionalContext to the model on the next turn, invisible to the user; a timeout kill discards the output; hooks still running at session end are killed.
|
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.



Closes #123.
Hooks flagged
async/asyncRewakewere silently ignored and every hook ran blocking, so a Stop hook with a longtimeoutheld pi's turn open for the hook's full duration and the session appeared frozen. They now follow Claude Code's documented background contract, on every event and fortype: "command"hooks only:decision,permissionDecision,continue,updatedInputare inert), implemented as a single seam in the hook dispatcher so Stop, PreToolUse, PostToolUse, UserPromptSubmit and the notify events are all covered.timeoutis not enforced onasynchooks (the timer is raised to the Node ceiling);asyncRewakekeeps its own timeout.asyncRewakehook exiting 2 wakes the model with its stderr (stdout when stderr is empty) as a new turn.systemMessage/additionalContextto the model on the next turn, shown to nobody else; wrong-typed fields are dropped.The README hooks row and the extension header document the behavior.
npm run checkpasses (Biome, strict tsc, Vitest)