[BUG] Permission prompt enters render loop with long script-block PowerShell commands, collapsing line height in Windows Terminal

Resolved 💬 3 comments Opened Apr 23, 2026 by darlinmoreno Closed Apr 27, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] 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

  1. Claude will typically respond with a command like:

``powershell
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
``

  1. 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]".
  2. 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.

View original on GitHub ↗

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