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
6 changes: 6 additions & 0 deletions packages/cli/src/ui/utils/formatters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ describe('formatters', () => {
expect(formatTokenCount(10000)).toBe('10k');
expect(formatTokenCount(15000)).toBe('15k');
expect(formatTokenCount(100000)).toBe('100k');
expect(formatTokenCount(999_999)).toBe('999k');
});

it('should display with m suffix for a million and above', () => {
expect(formatTokenCount(1_000_000)).toBe('1.0m');
expect(formatTokenCount(2_500_000)).toBe('2.5m');
});
});

Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/ui/utils/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ export const formatTokenCount = (count: number): string => {
if (count < 10000) {
return `${(count / 1000).toFixed(1)}k`;
}
return `${Math.floor(count / 1000)}k`;
if (count < 1_000_000) {
return `${Math.floor(count / 1000)}k`;
}
return `${(count / 1_000_000).toFixed(1)}m`;
};

/** Context-window usage from the used fraction: `4.5`, or `>100` past the limit. */
Expand Down
Loading