Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/kimi-code/src/tui/components/chrome/footer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export class FooterComponent implements Component {
let line1: string;
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 👍 / 👎.

customLine = this.statusLineRunner.current();
}

Expand Down Expand Up @@ -435,7 +435,7 @@ export class FooterComponent implements Component {
return slots;
}

private statusLinePayload(): StatusLinePayload {
private statusLinePayload(width: number): StatusLinePayload {
const state = this.state;
return {
model: modelDisplayName(state),
Expand All @@ -448,6 +448,7 @@ export class FooterComponent implements Component {
maxContextTokens: state.maxContextTokens,
sessionId: state.sessionId,
version: state.version,
width,
};
}

Expand Down
6 changes: 6 additions & 0 deletions apps/kimi-code/src/tui/utils/status-line-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export interface StatusLinePayload {
maxContextTokens: number;
sessionId: string;
version: string;
/**
* Terminal width in columns, so the command can lay out full-width
* (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 👍 / 👎.

}

export function runStatusLineCommand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const payload: StatusLinePayload = {
maxContextTokens: 8192,
sessionId: 'ses-1',
version: '1.2.3',
width: 120,
};

function plain(text: string): string {
Expand Down Expand Up @@ -142,6 +143,7 @@ describe('runStatusLineCommand', () => {
expect(parsed.model).toBe('kimi-k2');
expect(parsed.gitBranch).toBe('main');
expect(parsed.cwd).toBe('/tmp/project');
expect(parsed.width).toBe(120);
});

it('returns null on a nonzero exit', async () => {
Expand Down Expand Up @@ -201,6 +203,20 @@ describe('FooterComponent status_line command', () => {

expect(plain(footer.render(120)[0]!)).toContain('kimi-k2');
});

it('sends the terminal width from render() in the payload', async () => {
const state: AppState = {
...baseState,
statusLine: { items: null, command: 'cat' },
};
const footer = new FooterComponent(state);

// Wide render so the echoed payload JSON (width field last) is not truncated.
footer.render(500); // kicks the first run with width 500
await new Promise((resolve) => setTimeout(resolve, 300));

expect(plain(footer.render(500)[0]!)).toContain('"width":500');
});
});

describe('StatusLineCommandRunner', () => {
Expand Down