Skip to content

Commit c3e8f29

Browse files
fix(tui): align quota columns and soften color gradient
1 parent 8e677aa commit c3e8f29

2 files changed

Lines changed: 12 additions & 16 deletions

File tree

apps/kimi-code/src/tui/components/chrome/footer.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,28 +242,31 @@ function formatQuotaLines(
242242
.map((quota) => {
243243
const usedRatio = Math.max(0, Math.min(quota.used / quota.limit, 1));
244244
return {
245-
label: `${quota.label.toLowerCase()}:`,
245+
labelName: quota.label.toLowerCase(),
246246
percent: `${Math.round(usedRatio * 100)}%`,
247247
reset: formatResetHint(quota.resetHint),
248248
ratio: usedRatio,
249249
};
250250
});
251251
if (rows.length === 0) return [];
252252

253-
const labelColWidth = Math.max(...rows.map((r) => visibleWidth(r.label)));
253+
const labelNameWidth = Math.max(...rows.map((r) => visibleWidth(r.labelName)));
254254
const percentColWidth = Math.max(...rows.map((r) => visibleWidth(r.percent)));
255255
const resetColWidth = Math.max(...rows.map((r) => visibleWidth(r.reset)));
256256
const gap = 3;
257-
const blockWidth = labelColWidth + gap + percentColWidth + gap + resetColWidth;
257+
const blockWidth = labelNameWidth + 1 + gap + percentColWidth + gap + resetColWidth;
258258

259259
const lines: string[] = [];
260260
for (const row of rows) {
261-
const numberColor = chalk.hex(hslToHex(Math.round((1 - row.ratio) * 120), 80, 40));
261+
// Subtle gradient: fully green at 0 %, fully red at 100 %, desaturated.
262+
const numberColor = chalk.hex(hslToHex(Math.round((1 - row.ratio) * 120), 55, 50));
262263
const content =
263-
row.label.padEnd(labelColWidth + gap) +
264+
row.labelName.padEnd(labelNameWidth) +
265+
':' +
266+
' '.repeat(gap) +
264267
numberColor(row.percent.padStart(percentColWidth)) +
265268
' '.repeat(gap) +
266-
chalk.hex(colors.text)(row.reset.padStart(resetColWidth));
269+
chalk.hex(colors.text)(row.reset.padEnd(resetColWidth));
267270
const leftPad = Math.max(0, width - blockWidth);
268271
lines.push(truncateToWidth(' '.repeat(leftPad) + content, width));
269272
}

apps/kimi-code/test/tui/components/chrome/footer.test.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,8 @@ describe('FooterComponent', () => {
131131
const weekLine = stripAnsi(lines[2]!);
132132
const hourLine = stripAnsi(lines[3]!);
133133

134-
expect(weekLine).toContain('weekly limit:');
135-
expect(weekLine).toContain('41%');
136-
expect(weekLine).toContain('(5d, 3h)');
137-
138-
expect(hourLine).toContain('5h limit:');
139-
expect(hourLine).toContain('65%');
140-
expect(hourLine).toContain('(1h, 3m)');
134+
expect(weekLine).toMatch(/weekly limit\s*:\s+41%\s+\(5d, 3h\)/);
135+
expect(hourLine).toMatch(/5h limit\s*:\s+65%\s+\(1h, 3m\)/);
141136

142137
// Both rows should end at the same column (right-aligned block).
143138
expect(weekLine.trimEnd().length).toBe(hourLine.trimEnd().length);
@@ -155,9 +150,7 @@ describe('FooterComponent', () => {
155150
const lines = footer.render(120);
156151
const quotaLine = lines[2]!;
157152

158-
expect(stripAnsi(quotaLine)).toContain('5h limit:');
159-
expect(stripAnsi(quotaLine)).toContain('50%');
160-
expect(stripAnsi(quotaLine)).toContain('(reset)');
153+
expect(stripAnsi(quotaLine)).toMatch(/5h limit\s*:\s+50%\s+\(reset\)/);
161154
expect(truecolorCodes(quotaLine).size).toBeGreaterThan(0);
162155
});
163156
});

0 commit comments

Comments
 (0)