claude-code - 💡(How to fix) Fix [BUG] Permission prompt enters render loop with long script-block PowerShell commands, collapsing line height in Windows Terminal [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52410Fetched 2026-04-24 06:07:54
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×5commented ×1

Error Message

Error Messages/Logs

(No error output — this is a UI render bug, not a crash)

Root Cause

  1. Open Windows Terminal with a PowerShell (5.1 or 7+) profile
  2. Start Claude Code (claude) — no special flags needed. Fresh session, default auto mode.
  3. Ask Claude a question that prompts it to run a PowerShell pipeline with a scriptblock, e.g.:

    hey what's eating my RAM? pls help

  4. Claude will typically respond with a command like:
    Get-Process | Group-Object -Property ProcessName | ForEach-Object { [PSCustomObject]@{ Name = $_.Name; Count = $_.Count; MemGB = [math]::Round((($_.Group | Measure-Object WorkingSet64 -Sum).Sum)/1GB, 2) } } | Sort-Object MemGB -Descending | Select-Object -First 20 | Format-Table -AutoSize
  5. Because the command contains a ForEach-Object { ... } scriptblock, Claude Code shows the permission dialog with the message "Command contains script block that may execute arbitrary code" and three options including "Yes, and don't ask again for [full command]".
  6. Observe: the dialog repaints continuously, the command text in option 2 wraps differently each frame, and line spacing across the screen collapses.

Code Example

2.Yes, and don't ask again for
2.Yes, and don't ask again fo
2.Yes, and don't ask again
2.Yes, and don't ask agai

---

(No error output — this is a UI render bug, not a crash)

---

Get-Process | Group-Object -Property ProcessName | ForEach-Object { [PSCustomObject]@{ Name = $_.Name; Count = $_.Count; MemGB = [math]::Round((($_.Group | Measure-Object WorkingSet64 -Sum).Sum)/1GB, 2) } } | Sort-Object MemGB -Descending | Select-Object -First 20 | Format-Table -AutoSize
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

When a PowerShell tool call triggers the "Command contains script block that may execute arbitrary code" permission prompt, and the command is long enough that the rendered text wraps inside option 2 (Yes, and don't ask again for [COMMAND]), the permission dialog enters a render loop: the command text re-wraps at slightly different column widths on every frame, repainting the entire Ink tree at high frequency.

Watching the dialog, the "don't ask again for" label oscillates character-by-character across frames:

2.Yes, and don't ask again for
2.Yes, and don't ask again fo
2.Yes, and don't ask again
2.Yes, and don't ask agai

Each oscillation triggers a full repaint of the banner, user message, tool calls, and dialog.

Secondary symptom: Windows Terminal can't keep up with the repaint rate and drops vertical line-padding, producing visible collapse of line spacing across the entire scrollback. The damage is baked into the buffer — /clear, Ctrl+L, and even resizing the window (SIGWINCH redraw) do not repair it. The session is effectively unusable until restarted.

What Should Happen?

The permission dialog should render once and stay stable. Long commands should either wrap cleanly or be truncated, but the layout must be fixed-point.

Error Messages/Logs

(No error output — this is a UI render bug, not a crash)

Steps to Reproduce

  1. Open Windows Terminal with a PowerShell (5.1 or 7+) profile
  2. Start Claude Code (claude) — no special flags needed. Fresh session, default auto mode.
  3. Ask Claude a question that prompts it to run a PowerShell pipeline with a scriptblock, e.g.:

    hey what's eating my RAM? pls help

  4. Claude will typically respond with a command like:
    Get-Process | Group-Object -Property ProcessName | ForEach-Object { [PSCustomObject]@{ Name = $_.Name; Count = $_.Count; MemGB = [math]::Round((($_.Group | Measure-Object WorkingSet64 -Sum).Sum)/1GB, 2) } } | Sort-Object MemGB -Descending | Select-Object -First 20 | Format-Table -AutoSize
  5. Because the command contains a ForEach-Object { ... } scriptblock, Claude Code shows the permission dialog with the message "Command contains script block that may execute arbitrary code" and three options including "Yes, and don't ask again for [full command]".
  6. Observe: the dialog repaints continuously, the command text in option 2 wraps differently each frame, and line spacing across the screen collapses.

Any PowerShell command ≳200 chars that triggers the scriptblock warning reproduces this reliably.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.118 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

Likely root cause: flexbox measurement instability in the permission-prompt option layout. The left column (label "Yes, and don't ask again for") and the right column (the full command string) appear to be in the same flex row. When the command wraps, its rendered width affects the label column's allocated width, which reflows the command to a different wrap point, which shifts the label column again — a positive-feedback measurement loop that never reaches a fixed point.

Likely fix directions:

  • Pin the label column to a fixed width (character or fractional), breaking the feedback
  • Truncate/ellipsize the command in option 2 to a single line with a fixed max width
  • Display the command once above the options list (stable) and keep options purely as short labels

Why this matters in practice: any user on Windows who routinely asks Claude to run PowerShell pipelines with scriptblocks (very common — ForEach-Object, Where-Object, custom filters) hits this constantly. The collapsed-line-spacing side effect makes the terminal hard to read for the rest of the session, forcing a restart.

Screenshots and a character-by-character transcript of the oscillation are available on request.

extent analysis

TL;DR

The likely fix involves modifying the permission-prompt option layout to prevent the flexbox measurement instability, such as pinning the label column to a fixed width or truncating the command in option 2.

Guidance

  • Investigate the CSS styles applied to the permission-prompt option layout, specifically the flexbox configuration, to identify the root cause of the measurement instability.
  • Consider pinning the label column to a fixed width (character or fractional) to break the feedback loop, or truncating/ellipsizing the command in option 2 to a single line with a fixed max width.
  • Review the layout options for displaying the command, such as showing it once above the options list (stable) and keeping options purely as short labels, to determine the most suitable solution.
  • Test the proposed fixes with different command lengths and wrapping scenarios to ensure the solution is robust.

Example

No code snippet is provided as the issue is related to the UI layout and rendering, and the exact implementation details are not specified.

Notes

The fix may require modifications to the CSS styles or the layout configuration of the permission-prompt dialog. It is essential to test the proposed solutions thoroughly to ensure they do not introduce any new issues or affect the overall user experience.

Recommendation

Apply a workaround by truncating the command in option 2 to a single line with a fixed max width, as this is a relatively simple and non-intrusive solution that can help mitigate the issue until a more permanent fix is implemented.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING