Skip to content

feat(tui): include terminal width in status_line.command payload - #2478

Open
chunxiaoxx wants to merge 1 commit into
MoonshotAI:mainfrom
chunxiaoxx:feat/statusline-width-payload
Open

feat(tui): include terminal width in status_line.command payload#2478
chunxiaoxx wants to merge 1 commit into
MoonshotAI:mainfrom
chunxiaoxx:feat/statusline-width-payload

Conversation

@chunxiaoxx

Copy link
Copy Markdown

Summary

Adds width (terminal columns) to the JSON payload piped to status_line.command, closing the gap flagged in #2477.

The command is spawned with piped stdio, so process.stdout.columns is unavailable to it — today a status line script has no way to know the terminal width and cannot right-align or lay out full-width content (HUD-style footers with left/right-justified segments, full-width context bars, etc.). One field fixes it: FooterComponent.render(width) now passes its width through statusLinePayload().

Change

  • status-line-command.ts: StatusLinePayload gains width: number (with a doc comment explaining why it exists)
  • footer.ts: statusLinePayload(width) threaded from render(width)
  • Test fixture updated + two assertions:
    • runStatusLineCommand stdin round-trip now also checks parsed.width
    • new end-to-end test: render(500) with cat as the command echoes the payload back, asserting the rendered line contains "width":500

Verification

  • npx vitest run test/tui/components/chrome/footer-status-line.test.ts: 13 passed / 17 — the 4 failures are pre-existing on clean origin/main in this Windows environment (they depend on printf/sh/head Unix-isms; verified identical baseline via stash) and are untouched by this change
  • npx tsc --noEmit: clean

Backward compatible in practice: commands that ignore unknown JSON fields are unaffected.

Refs #2477 (also related: #2448, multi-line output — independent change, no overlap)

The JSON snapshot piped to status_line.command had no width, and the
command is spawned with piped stdio so process.stdout.columns is
unavailable — a status line script cannot right-align or lay out
full-width content. Pass FooterComponent.render(width) through in the
payload so commands can build left/right-justified HUD layouts.

Refs MoonshotAI#2477
@changeset-bot

changeset-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: dbf90e4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dbf90e440a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

* (left/right-justified) status lines. Piped stdio has no TTY, so
* `process.stdout.columns` is unavailable to the command.
*/
width: number;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add the required CLI changeset

This adds a user-visible field to the published CLI's status_line.command payload, but the commit contains no .changeset/ entry, so release versioning and changelog automation will not record the enhancement. Add a patch changeset for @moonshot-ai/kimi-code before submission.

AGENTS.md reference: AGENTS.md:L83-L83

Useful? React with 👍 / 👎.

let customLine: string | null = null;
if (this.statusLineRunner !== null) {
this.statusLineRunner.maybeRefresh(this.statusLinePayload());
this.statusLineRunner.maybeRefresh(this.statusLinePayload(width));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Report the outer terminal width

In the production layout, mountFooter() wraps this component in GutterContainer(1, 1), whose render() subtracts both gutters before calling the child, so a 120-column terminal passes 118 here and the command receives "width":118. This contradicts the new field's documented terminal-column semantics and makes scripts that need the actual terminal dimensions calculate against the wrong value; preserve the outer width separately rather than forwarding the component's inner content width.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant