claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

UserPromptSubmit hook decision:block reason not displayed in VS Code/Cursor extension (recurring; multiple closed dupes) — please re-triage

Open trevorsookraj opened this issue 4 months ago • 8 comments

Summary

In the Claude Code IDE extension (VS Code / Cursor), a UserPromptSubmit hook that returns {"decision":"block","reason":"..."} correctly blocks the prompt, but the reason is never shown to the user in the chat panel. The block looks like a silent hang. The identical hook delivers the reason visibly under the standalone CLI. systemMessage and exit 2 + stderr are also silent in the extension.

Since reason/systemMessage are the primary channels by which a hook explains a block to the user, a blocking UserPromptSubmit gate is effectively unusable in the IDE extension — the user cannot tell why their prompt was dropped.

Repro

.claude/settings.json:

{"hooks":{"UserPromptSubmit":[{"matcher":"","hooks":[{"type":"command","command":"bash ./block.sh"}]}]}}

block.sh:

#!/usr/bin/env bash
jq -nc '{decision:"block", reason:"BLOCKED: this reason should be visible to the user"}'
exit 0

Submit any prompt.

  • Expected: the prompt is blocked and "BLOCKED: this reason should be visible to the user" is shown in the chat panel.
  • Actual (extension): the prompt is silently discarded; the reason never appears in the panel.
  • Actual (standalone CLI): the reason is shown (UserPromptSubmit operation blocked by hook: ...).

Also silent in the extension: a top-level systemMessage field, and exit 2 with the reason written to stderr.

Environment

  • Claude Code IDE extension running in Cursor (a VS Code fork), macOS.

This is recurring — related reports (mostly closed "not planned")

  • #15021 — UserPromptSubmit hooks not working in VS Code/Cursor extensions
  • #4084 — Hook output visibility blocked in Claude Code UI
  • #10964 — UserPromptSubmit hook doesn't display stderr on non-zero exit code
  • #16289 — SubagentStop systemMessage not displayed in UI
  • #50542 — Stop hook systemMessage JSON not rendered (plugin-scope dispatch)
  • #16114 — Notification hooks don't fire in the extension (work in CLI)
  • JuliusBrussee/caveman#556 — third-party project reproducing this exact symptom

Ask

Please re-triage. Many independent reports converge on the same root behavior: hook-authored messages (reason, systemMessage, stderr) that render in the standalone CLI do not render in the IDE extension's chat panel. Matching the CLI's visible-block behavior in the extension would resolve an entire class of these issues.

trevorsookraj avatar Jul 08 '26 03:07 trevorsookraj

@trevorsookraj Prompt injection is difficult because the final response often looks perfectly valid. It would be useful to surface how the execution context evolved over time so unexpected instruction sources become visible instead of only inspecting the final prompt.

mayank6091 avatar Jul 08 '26 05:07 mayank6091

Experiencing this issue as well. It disrupts a whole developer workflow we were planning

annabarnes1138 avatar Jul 10 '26 15:07 annabarnes1138

Could you share which version of Claude Code you're using? I've found that this issue no longer occurs in version 2.1.218, so I'm also curious which version officially fixed it.

HHusers avatar Aug 10 '26 09:08 HHusers

Thanks for the detailed report and the consolidated list — this is a real gap.

What I checked on 2.1.233 with your exact settings.json + block.sh: the CLI does emit the block reason on the machine-readable stream that the IDE extension consumes (a system message with subtype: "informational", level: "warning", containing UserPromptSubmit operation blocked by hook: BLOCKED: ..., followed by a result with num_turns: 0). That part has been in place for a while. The VS Code / Cursor extension, however, currently drops informational system messages instead of rendering them in the chat panel, so the block still looks like a silent no-op there. The same applies to systemMessage and exit-2 stderr.

Confirmed as a bug in the IDE extension (the CLI side is fine). I couldn't drive the extension UI in this environment, but the code path is unambiguous. Marking for the extension to render hook block reasons / systemMessage in the panel, matching the standalone CLI.

🤖 Generated with Claude Code

bcherny avatar Aug 16 '26 22:08 bcherny

bumping to keep fresh - this is not stale

tweavers avatar Sep 08 '26 16:09 tweavers

the bumps will continue until stability improves

tweavers avatar Sep 16 '26 20:09 tweavers

I am experiencing the same issue.

A SessionStart hook returns systemMessage. The desktop app accepts it, records it in the session transcript as a hook_system_message attachment, and never displays it. The same hook, same plugin version, same machine, renders correctly in the CLI.

The failure is silent in both directions: the hook exits 0, the model still receives hookSpecificOutput.additionalContext, and nothing in the session indicates the user-facing half of the output was dropped. A hook author cannot detect the degradation at runtime.

Every prior report of this class is closed — #77518 as a duplicate, #76736, #15344, #50542 and #16289 as not planned or auto-closed stale, #47692 as stale — and none of them received a response. The specific intersection here, desktop app + SessionStart, is not among them. I am also adding evidence none of those reports carried: the message is parsed and persisted before it is dropped, so the gap is in rendering alone.

#50542 independently points at the same mechanism from the other direction, suspecting that AttachmentMessage.tsx stopped emitting the hook_system_message <Line>. That matches exactly what the transcript below shows arriving and then going nowhere.

Environment

CLAUDE_CODE_ENTRYPOINT claude-desktop
CLAUDE_CODE_DESKTOP_APP_VERSION 2.110.1
CLAUDE_AGENT_SDK_VERSION 0.3.271
OS Windows 11 Pro 26200
Hook runtime pwsh -NoProfile -File …
Plugin scope user

Reproduction

hooks/hooks.json:

{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "startup|clear|resume",
        "hooks": [
          { "type": "command", "command": "pwsh -NoProfile -File \"${CLAUDE_PLUGIN_ROOT}/hooks/Show-Tip.ps1\"", "timeout": 10 }
        ]
      }
    ]
  }
}

The script writes exactly this to stdout and exits 0:

{
  "systemMessage": "TIP: /there is a new extension for you. Want it installed?",
  "hookSpecificOutput": {
    "hookEventName": "SessionStart",
    "additionalContext": "A tip was shown to the user - do not repeat it."
  }
}
  1. Install the plugin at user scope, restart the desktop app.
  2. Open a new chat in any project and send any message.

Expected: the systemMessage text appears to the user, as it does in the CLI.

Actual: nothing appears. The model receives additionalContext and behaves accordingly, so from inside the session everything looks healthy.

Evidence the app received and parsed it

~/.claude/projects/<project>/<session>.jsonl contains, for this one hook invocation, both the raw stdout and a parsed, typed attachment:

{"attachment": {"type": "hook_success", "hookName": "SessionStart:startup",
  "toolUseID": "b8422fd7-a306-43f9-a51d-6958ce0657b7", "hookEvent": "SessionStart",
  "content": "", "stdout": "{\"systemMessage\":\"TIP: /there …\", …}"}}
{"attachment": {"type": "hook_system_message", "hookName": "SessionStart:startup",
  "toolUseID": "b8422fd7-a306-43f9-a51d-6958ce0657b7", "hookEvent": "SessionStart",
  "content": "TIP: /there is a new extension for you. Want it installed?"}}

The message is lifted out of stdout into its own hook_system_message attachment and persisted, so transport and parsing both work. Only the desktop UI never renders that attachment type.

Scope

Surface systemMessage additionalContext
CLI (CLAUDE_CODE_ENTRYPOINT=cli) rendered immediately reaches the model
Desktop app (claude-desktop) silently dropped reaches the model

Workaround, and what it costs

Branch on the client: on desktop, put the notice into additionalContext with an instruction to print it verbatim; elsewhere use systemMessage. #76736 describes the same workaround and is blunt that it is brittle.

Two costs. The notice arrives one turn late on desktop, so it cannot precede the work it is meant to influence. And it becomes advisory — the model may reword it, drop it, or act on it instead of relaying it, which also corrupts any measurement of whether the notice worked.

Why it matters

Any hook-driven notice at session start — onboarding banners, environment warnings, policy notices, deprecation notices — has no deterministic user-visible channel on the desktop app. Plugins cannot contribute a statusLine (per the plugins reference), and every other documented channel is model-mediated. systemMessage is the only mechanism available, and on the surface where most people now work it does nothing.

peterkrajkovic avatar Sep 17 '26 13:09 peterkrajkovic

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] avatar Nov 25 '26 22:11 github-actions[bot]