From 944e0dc98729074d9d9581f64419a5a7e2306735 Mon Sep 17 00:00:00 2001 From: RTCartist Date: Fri, 5 Jun 2026 00:08:58 +0800 Subject: [PATCH 1/2] feat: colorize diff stats in footer git badge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apply semantic colors to the diff line-change indicators in the footer's git badge: additions (+N) render in the theme's success color, deletions (-N) in the error color, and the dirty marker (±) in the warning color. Sync arrows and branch name retain the existing status color. Closes #289 --- .../src/tui/components/chrome/footer.ts | 15 +++++- .../components/panels/footer-context.test.ts | 52 +++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/apps/kimi-code/src/tui/components/chrome/footer.ts b/apps/kimi-code/src/tui/components/chrome/footer.ts index 350da47ce..58b86ed06 100644 --- a/apps/kimi-code/src/tui/components/chrome/footer.ts +++ b/apps/kimi-code/src/tui/components/chrome/footer.ts @@ -206,7 +206,7 @@ function formatContextStatus(usage: number, tokens?: number, maxTokens?: number) } export function formatFooterGitBadge(status: GitStatus, colors: ColorPalette): string { - const base = chalk.hex(colors.status)(formatGitBadgeBase(status)); + const base = formatColorizedGitBadge(status, colors); if (status.pullRequest === null) return base; const pullRequest = chalk.hex(colors.primary)( @@ -215,6 +215,19 @@ export function formatFooterGitBadge(status: GitStatus, colors: ColorPalette): s return `${base} ${pullRequest}`; } +function formatColorizedGitBadge(status: GitStatus, colors: ColorPalette): string { + const parts: string[] = []; + if (status.diffAdded > 0) parts.push(chalk.hex(colors.success)(`+${String(status.diffAdded)}`)); + if (status.diffDeleted > 0) parts.push(chalk.hex(colors.error)(`-${String(status.diffDeleted)}`)); + if (parts.length === 0 && status.dirty) parts.push(chalk.hex(colors.warning)('±')); + let sync = ''; + if (status.ahead > 0) sync += `↑${status.ahead}`; + if (status.behind > 0) sync += `↓${status.behind}`; + if (sync) parts.push(chalk.hex(colors.status)(sync)); + const branch = chalk.hex(colors.status)(status.branch); + return parts.length === 0 ? branch : `${branch} ${chalk.hex(colors.status)('[')}${parts.join(' ')}${chalk.hex(colors.status)(']')}`; +} + export class FooterComponent implements Component { private state: AppState; private colors: ColorPalette; diff --git a/apps/kimi-code/test/tui/components/panels/footer-context.test.ts b/apps/kimi-code/test/tui/components/panels/footer-context.test.ts index db34ee895..6f1ef4f3a 100644 --- a/apps/kimi-code/test/tui/components/panels/footer-context.test.ts +++ b/apps/kimi-code/test/tui/components/panels/footer-context.test.ts @@ -145,6 +145,58 @@ describe('FooterComponent — context NaN resilience', () => { chalk.level = previousLevel; } }); + + it('colorizes diff additions in success color and deletions in error color', () => { + const previousLevel = chalk.level; + chalk.level = 3; + try { + const out = formatFooterGitBadge( + { + branch: 'main', + dirty: true, + ahead: 0, + behind: 0, + diffAdded: 42, + diffDeleted: 7, + pullRequest: null, + }, + darkColors, + ); + + const plain = strip(out); + expect(plain).toContain('+42'); + expect(plain).toContain('-7'); + expect(out).toContain(hexToSgr(darkColors.success)); + expect(out).toContain(hexToSgr(darkColors.error)); + } finally { + chalk.level = previousLevel; + } + }); + + it('renders dirty marker in warning color when no line stats are available', () => { + const previousLevel = chalk.level; + chalk.level = 3; + try { + const out = formatFooterGitBadge( + { + branch: 'main', + dirty: true, + ahead: 0, + behind: 0, + diffAdded: 0, + diffDeleted: 0, + pullRequest: null, + }, + darkColors, + ); + + const plain = strip(out); + expect(plain).toContain('±'); + expect(out).toContain(hexToSgr(darkColors.warning)); + } finally { + chalk.level = previousLevel; + } + }); }); describe('buildWeightedTips — weighted rotation', () => { From 3cec24bb95110a2db6c36f39b9e5557212866120 Mon Sep 17 00:00:00 2001 From: RTCartist Date: Fri, 5 Jun 2026 00:09:34 +0800 Subject: [PATCH 2/2] chore: add changeset for footer diff colorization --- .changeset/colorize-footer-diff-stats.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/colorize-footer-diff-stats.md diff --git a/.changeset/colorize-footer-diff-stats.md b/.changeset/colorize-footer-diff-stats.md new file mode 100644 index 000000000..02d1737ed --- /dev/null +++ b/.changeset/colorize-footer-diff-stats.md @@ -0,0 +1,5 @@ +--- +"@moonshot-ai/kimi-code": patch +--- + +Colorize diff line-change stats in the footer git badge: additions in green, deletions in red, dirty marker in amber