mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 04:30:48 +00:00
feat(ui): enhance LoadingIndicator to display token counts and improve formatting
- Added candidatesTokens prop to LoadingIndicator for displaying token counts. - Updated formatting to show elapsed time and token counts inline. - Refactored tests to validate new token display functionality and formatting changes. - Introduced formatTokenCount utility for consistent token count representation. This improves user feedback during loading states by providing clearer information on token usage.
This commit is contained in:
parent
dbfa5b3e8e
commit
03e59256c4
6 changed files with 152 additions and 18 deletions
|
|
@ -9,6 +9,7 @@ import {
|
|||
formatDuration,
|
||||
formatMemoryUsage,
|
||||
formatRelativeTime,
|
||||
formatTokenCount,
|
||||
} from './formatters.js';
|
||||
|
||||
describe('formatters', () => {
|
||||
|
|
@ -154,4 +155,25 @@ describe('formatters', () => {
|
|||
expect(formatDuration(-100)).toBe('0s');
|
||||
});
|
||||
});
|
||||
|
||||
describe('formatTokenCount', () => {
|
||||
it('should display exact number for counts less than 1000', () => {
|
||||
expect(formatTokenCount(0)).toBe('0');
|
||||
expect(formatTokenCount(100)).toBe('100');
|
||||
expect(formatTokenCount(847)).toBe('847');
|
||||
expect(formatTokenCount(999)).toBe('999');
|
||||
});
|
||||
|
||||
it('should display with k suffix and one decimal for counts 1000-9999', () => {
|
||||
expect(formatTokenCount(1000)).toBe('1.0k');
|
||||
expect(formatTokenCount(5400)).toBe('5.4k');
|
||||
expect(formatTokenCount(9999)).toBe('10.0k');
|
||||
});
|
||||
|
||||
it('should display with k suffix without decimal for counts 10000 and above', () => {
|
||||
expect(formatTokenCount(10000)).toBe('10k');
|
||||
expect(formatTokenCount(15000)).toBe('15k');
|
||||
expect(formatTokenCount(100000)).toBe('100k');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue