claude-code - 💡(How to fix) Fix Include terminal width in statusLine JSON payload [1 comments, 1 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#52125Fetched 2026-04-23 07:35:58
View on GitHub
Comments
1
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×2closed ×1commented ×1

The JSON payload passed to custom statusLine scripts on stdin does not include terminal width, which makes width-aware rendering (progress bars, truncation, adaptive layout) unreliable on a large class of setups. The sibling subagentStatusLine schema already receives a columns field — this request is to surface the same value in the main statusLine payload.

Root Cause

Root cause: claude is launched by an interactive shell that does know its pty size, but that information is never propagated to the pipe-connected subprocesses invoked for the statusline. The information exists on the Claude Code side — it's just not in the JSON contract.

Fix Action

Fix / Workaround

  1. Hardcode a width (overflow or underfill on resize)
  2. Require users to maintain a manual config file with their column count (current workaround in my setup — ~/.claude/statusline-width.conf)
  3. Add a PROMPT_COMMAND / PowerShell-profile hook that writes the live width to disk on every prompt — works but requires pressing Enter after a resize, and adds an install-side step that the "custom statusline" feature otherwise advertises as unnecessary
  • Docs: https://code.claude.com/docs/en/statusline.mdsubagentStatusLine.columns is documented; main statusLine input schema has no equivalent
  • My investigation and current workaround: a statusline skill that reads ~/.claude/statusline-width.conf as a manual override, which would become obsolete once terminal.columns lands

Code Example

{
  "model": { ... },
  "workspace": { ... },
  "context_window": { ... },
  "terminal": {
    "columns": 180,
    "rows": 48
  }
}
RAW_BUFFERClick to expand / collapse

Summary

The JSON payload passed to custom statusLine scripts on stdin does not include terminal width, which makes width-aware rendering (progress bars, truncation, adaptive layout) unreliable on a large class of setups. The sibling subagentStatusLine schema already receives a columns field — this request is to surface the same value in the main statusLine payload.

Affected environments

Any configuration where the statusline subprocess has no console/TTY it can query:

  • JetBrains IDE terminals (JediTerm — PyCharm, IntelliJ, WebStorm, RubyMine, etc.) on Windows
  • WSL statusline scripts whose host terminal isn't reachable through the WSL boundary
  • tmux / screen inside a wrapped shell
  • Any piped / redirected invocation

Reproduction

On Windows, run Claude Code inside PyCharm's embedded Git Bash. From a subprocess spawned under the same contract as the statusline command (stdin piped with JSON), every documented width-detection API fails:

MethodResult
[Console]::WindowWidth (PowerShell)throws Invalid handle
mode.com conreturns stub 120
AttachConsole walking ancestorsfails — no Windows console in the chain
stty size </dev/tty from bash/dev/tty: No such device or address
tput colsreturns stale terminfo default 80
$env:COLUMNS / $env:LINESunset by JediTerm
JediTerm env vars (TERMINAL_EMULATOR, TERM_SESSION_ID)present, but no width field

Root cause: claude is launched by an interactive shell that does know its pty size, but that information is never propagated to the pipe-connected subprocesses invoked for the statusline. The information exists on the Claude Code side — it's just not in the JSON contract.

Proposed change

Add terminal dimensions to the main statusLine JSON, mirroring what subagentStatusLine already receives:

{
  "model": { ... },
  "workspace": { ... },
  "context_window": { ... },
  "terminal": {
    "columns": 180,
    "rows": 48
  }
}

A top-level columns field would work too, but a nested terminal block leaves room for future additions (e.g., is_tty, color_depth) without further schema churn.

Why it matters

Without this field, custom statusline authors have three choices, all unpleasant:

  1. Hardcode a width (overflow or underfill on resize)
  2. Require users to maintain a manual config file with their column count (current workaround in my setup — ~/.claude/statusline-width.conf)
  3. Add a PROMPT_COMMAND / PowerShell-profile hook that writes the live width to disk on every prompt — works but requires pressing Enter after a resize, and adds an install-side step that the "custom statusline" feature otherwise advertises as unnecessary

All three degrade the "install and forget" UX. The columns field already flows through internally for subagentStatusLine, so surfacing it in the parent schema should be a small schema addition.

References

  • Docs: https://code.claude.com/docs/en/statusline.mdsubagentStatusLine.columns is documented; main statusLine input schema has no equivalent
  • My investigation and current workaround: a statusline skill that reads ~/.claude/statusline-width.conf as a manual override, which would become obsolete once terminal.columns lands

extent analysis

TL;DR

Add a terminal field with columns and rows to the main statusLine JSON payload to enable reliable width-aware rendering.

Guidance

  • Verify that the subagentStatusLine schema already includes a columns field, which can serve as a reference for the proposed change.
  • Consider adding a nested terminal block to the statusLine JSON payload, allowing for future additions like is_tty or color_depth.
  • Evaluate the proposed JSON structure: { "terminal": { "columns": 180, "rows": 48 } } for compatibility and ease of implementation.
  • Assess the impact of this change on custom statusline authors, who currently face unpleasant workarounds due to the missing columns field.

Example

{
  "model": { ... },
  "workspace": { ... },
  "context_window": { ... },
  "terminal": {
    "columns": 180,
    "rows": 48
  }
}

Notes

The proposed change aims to mirror the existing subagentStatusLine schema, which already includes a columns field. This addition should be a small schema update, given the internal flow of the columns field for subagentStatusLine.

Recommendation

Apply the proposed workaround by adding a terminal field with columns and rows to the main statusLine JSON payload, as it directly addresses the issue and enhances the user experience by providing a reliable way to determine terminal width.

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