fix: extract text from ContentPart list for UserPromptSubmit hook prompt#1781
Open
Sibuxiangx wants to merge 1 commit intoMoonshotAI:mainfrom
Open
fix: extract text from ContentPart list for UserPromptSubmit hook prompt#1781Sibuxiangx wants to merge 1 commit intoMoonshotAI:mainfrom
Sibuxiangx wants to merge 1 commit intoMoonshotAI:mainfrom
Conversation
When user_input is a list[ContentPart] (which is the normal case from the shell UI), the UserPromptSubmit hook was passing an empty string for the prompt field. This fix uses Message.extract_text() to properly extract the text content, consistent with how text_input is extracted a few lines later. Fixes MoonshotAI#1779
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes the UserPromptSubmit hook payload so the prompt field contains the actual user-entered text when the shell UI submits input as list[ContentPart] (instead of always sending an empty string).
Changes:
- Extract
text_input_for_hookfromlist[ContentPart]viaMessage.extract_text(" ").strip(). - Keep
strinputs unchanged while correctly populating the hook’smatcher_valueandpromptpayload for shell-originated inputs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
UserPromptSubmithook event always sends an empty string for thepromptfield when the user input comes from the shell UI.Root cause: In
kimisoul.py,user_inputpassed torun()is typed asstr | list[ContentPart]. The shell UI always passeslist[ContentPart], but the hook code only extracted text for thestrcase:Fix
Use
Message.extract_text()to properly extract text fromlist[ContentPart], consistent with howtext_inputis extracted just a few lines later in the same method:Testing
{"prompt": "hello this is a test prompt for hook"}instead of{"prompt": ""}Fixes #1779