feat(tui): include terminal width in status_line.command payload - #2478
feat(tui): include terminal width in status_line.command payload#2478chunxiaoxx wants to merge 1 commit into
Conversation
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
|
There was a problem hiding this comment.
💡 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; |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
Adds
width(terminal columns) to the JSON payload piped tostatus_line.command, closing the gap flagged in #2477.The command is spawned with piped stdio, so
process.stdout.columnsis 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 itswidththroughstatusLinePayload().Change
status-line-command.ts:StatusLinePayloadgainswidth: number(with a doc comment explaining why it exists)footer.ts:statusLinePayload(width)threaded fromrender(width)runStatusLineCommandstdin round-trip now also checksparsed.widthrender(500)withcatas the command echoes the payload back, asserting the rendered line contains"width":500Verification
npx vitest run test/tui/components/chrome/footer-status-line.test.ts: 13 passed / 17 — the 4 failures are pre-existing on cleanorigin/mainin this Windows environment (they depend onprintf/sh/headUnix-isms; verified identical baseline via stash) and are untouched by this changenpx tsc --noEmit: cleanBackward compatible in practice: commands that ignore unknown JSON fields are unaffected.
Refs #2477 (also related: #2448, multi-line output — independent change, no overlap)