statusLine command: terminal_width missing from JSON input

Open 💬 0 comments Opened Jul 3, 2026 by Ashikaga1974

Summary

The statusLine command receives a JSON payload via stdin, but terminal_width is not included — it always falls back to a hardcoded default.

Problem

Custom statusline scripts need the actual terminal width to correctly right-align content. Without terminal_width, there is no reliable way to detect the visible terminal width from within a subprocess:

  • [System.Console]::WindowWidth returns 0 in NonInteractive mode (no console handle)
  • GetConsoleScreenBufferInfo (Windows API) returns False — no console attached
  • mode con returns the buffer width (e.g. 120), not the visible window width
  • $env:COLUMNS is not set by Windows Terminal for subprocesses

The result: right-aligned content (e.g. time, session duration) is cut off when the terminal window is narrower than the hardcoded fallback.

Expected behavior

The JSON payload sent to the statusLine command should include a terminal_width field reflecting the actual visible width of the terminal/status bar area:

{
  "model": { ... },
  "workspace": { ... },
  "context_window": { ... },
  "terminal_width": 104
}

Current JSON payload (example)

{
  "session_id": "...",
  "transcript_path": "...",
  "model": { "id": "claude-sonnet-4-6", "display_name": "Sonnet 4.6" },
  "workspace": { "current_dir": "C:\\Users\\..." },
  "context_window": { "used_percentage": 21, ... },
  "rate_limits": { ... }
}

No terminal_width field is present.

Environment

  • Platform: Windows 10
  • Shell: PowerShell (pwsh)
  • Claude Code version: 2.1.152
  • Terminal: Windows Terminal

Workaround

None reliable. The only option is a hardcoded fallback value, which breaks on terminals narrower than the assumed width.

View original on GitHub ↗