Fix prompt extraction in Stop hook notifications#3
Open
RonAmihai wants to merge 1 commit intowarpdotdev:mainfrom
Open
Fix prompt extraction in Stop hook notifications#3RonAmihai wants to merge 1 commit intowarpdotdev:mainfrom
RonAmihai wants to merge 1 commit intowarpdotdev:mainfrom
Conversation
The prompt extraction uses .message.content which returns the raw JSON content blocks array instead of extracting the text values. This applies the same content block parsing pattern already used for response extraction. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Problem
The Stop hook in
on-stop.shproduces broken or missing notifications in all terminals — both Warp and terminals that support OSC 777 (like Ghostty).Root cause
The prompt extraction on line 19-21 uses
.message.contentwhich returns the raw JSON content blocks array rather than extracting the text:Claude Code transcripts store user messages as content block arrays:
{"type": "user", "message": {"content": [{"type": "text", "text": "my prompt"}]}}So
.message.contentreturns the entire array[{"type":"text","text":"my prompt"}]instead of the string"my prompt".The response extraction on lines 24-27 already handles this correctly by iterating
.message.content[]and selecting.text— the prompt extraction just needs the same pattern.How this manifests per terminal
"Task completed"— the raw JSON array causes jq to silently fail downstream"prompt" → responsecontent"[ { "type": "text", "text": "my prompt" ..." → response"my prompt" → responseFix
One-line change — apply the same content block parsing pattern already used for response extraction:
The fallback to
"Task completed"is preserved — if extraction fails for any reason, the default message still applies.