Don't show Claude Code's injected turns as the notification query - #79
Open
kadufarah1979 wants to merge 1 commit into
Open
Don't show Claude Code's injected turns as the notification query#79kadufarah1979 wants to merge 1 commit into
kadufarah1979 wants to merge 1 commit into
Conversation
The Stop and StopFailure hooks build the notification title from the last
transcript entry of type "user". Not every such entry is something a human
typed: Claude Code injects turns of its own with the same type — background
task notifications, skill loads, slash-command expansions, compaction
summaries. When a turn ends because one of those arrived, the notification
shows raw markup instead of the prompt:
<task-notification>
<task-id>bpzyv8z2j</task-id>
<summary>Monitor event: "pipeline for MR !1151 rea...
Claude Code already distinguishes the two: real prompts carry
origin.kind == "human", injected turns carry another origin kind (or no
origin plus isMeta: true). Key on that instead of on type alone.
The extraction was duplicated in on-stop.sh and on-stop-failure.sh, so it
moves to a shared extract-query.sh. Transcripts predating the origin field
fall back to the last non-meta turn whose text isn't injected markup.
Co-Authored-By: Claude Opus 5 (1M context) <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.
What happens
When a turn ends because a background task reported back, the Warp notification shows raw markup instead of the prompt:
Why
on-stop.shbuildsqueryfrom the last transcript entry oftype: "user". Not every such entry is something a human typed — Claude Code injects turns of its own with the same type: background task notifications, skill loads, slash-command expansions, compaction summaries. When one of those is the lastuserentry, its raw markup becomes the notification title.Counting
userentries across my own transcripts:origin.kindhumantask-notification<task-notification>…isMeta: true<local-command-stdout>,[Image: …]So Claude Code already marks the difference — the hook just wasn't reading it.
The change
Key on
origin.kind == "human"rather than ontypealone. The extraction was duplicated inon-stop.shandon-stop-failure.sh, so it moves into a sharedextract-query.sh; transcripts predating theoriginfield fall back to the last non-meta turn whose text isn't injected markup, so nothing regresses for older clients.Tests
Six cases added to
plugins/warp/tests/test-hooks.sh, covering task notifications,isMetaturns, tool results, the no-originfallback, an all-injected transcript, and a missing transcript. Each one fails againstmainand passes here.Also verified end to end —
on-stop.shwith a mock hook payload now emits"query":"review the pipeline for MR !1151"where it previously emitted the<task-notification>block.🤖 Generated with Claude Code