Merge pull request #1618 from code-yeongyu/fix/594-user-prompt-submit-fires-once

fix(hooks): fire UserPromptSubmitHooks on every prompt, not just first (#594)
This commit is contained in:
YeonGyu-Kim
2026-02-07 20:09:19 +09:00
committed by GitHub
2 changed files with 116 additions and 2 deletions
@@ -44,9 +44,16 @@ export async function executeUserPromptSubmitHooks(
return { block: false, modifiedParts, messages }
}
// Check if hook tags are in the current user input only (not in injected context)
// by checking only the text parts that were provided in this message
const userInputText = ctx.parts
.filter((p) => p.type === "text" && p.text)
.map((p) => p.text ?? "")
.join("\n")
if (
ctx.prompt.includes(USER_PROMPT_SUBMIT_TAG_OPEN) &&
ctx.prompt.includes(USER_PROMPT_SUBMIT_TAG_CLOSE)
userInputText.includes(USER_PROMPT_SUBMIT_TAG_OPEN) &&
userInputText.includes(USER_PROMPT_SUBMIT_TAG_CLOSE)
) {
return { block: false, modifiedParts, messages }
}