[BUG] TypeError: toolUseContext.getAppState is not a function when rendering permission prompt

Resolved 💬 3 comments Opened Apr 17, 2026 by luisfelipediaz Closed Apr 18, 2026

Environment

  • Claude Code version: 2.1.112
  • OS: macOS (darwin 25.3.0)
  • Shell: zsh

Error

TypeError: H.toolUseContext.getAppState is not a function
  (In 'H.toolUseContext.getAppState()', 'H.toolUseContext.getAppState' is undefined)
  at /$bunfs/root/src/entrypoints/cli.js:8231:15642

Stack trace

- <anonymous> (/$bunfs/root/src/entrypoints/cli.js:8231:15642)   <- By() useEffect
- qX (/$bunfs/root/src/entrypoints/cli.js:477:63169)
- sPH (/$bunfs/root/src/entrypoints/cli.js:477:76220)
- ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
- sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
- ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
- sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
- ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
- sPH (/$bunfs/root/src/entrypoints/cli.js:477:77010)
- ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)

Root cause (from the minified bundle)

The By function in cli.js:8231 runs this inside a useEffect when mounting the permission-prompt component:

function By(H, _) {
  ...
  useEffect(() => {
    ...
    let O = H.toolUseContext.getAppState().toolPermissionContext.mode;
    track("tengu_tool_use_show_permission_request", {
      ...,
      permissionMode: O
    });
  }, [H, _, q]);
}

H.toolUseContext arrives at the component defined but without the getAppState method, so the sync call inside useEffect throws during render of the permission prompt. The UI hangs and the CLI stops responding to input — had to restart the session.

Reproduction

Triggered while a tool requiring user permission was about to prompt (permission prompt about to render). I could not capture a reliable repro since the CLI becomes unresponsive; the session was using subagents / skills at the time.

Related

Same getAppState() area touched by other bugs:

  • #29547 — AskUserQuestion silently returns empty answers inside plugin skills
  • #12176 — PermissionRequest hook race condition
  • #3958 — CLI crashes when rejecting permission-required tool use within Task tool

Suggested fix

Guard the call so a malformed toolUseContext doesn't crash the render, and log instead:

const mode = H.toolUseContext.getAppState?.()?.toolPermissionContext?.mode;
if (mode === undefined) {
  // log that toolUseContext arrived without getAppState — don't crash the UI
}

A longer-term fix likely wants to investigate why toolUseContext loses getAppState on the way to this component (possibly a context object being re-created / serialized across a subagent or skill boundary).

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗