mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-12 16:15:14 +00:00
(fix)streaming status: code quality
This commit is contained in:
1 parent
c990ce7414
commit
e2f85bf19b
2 files changed
+17
-7
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import type { TFunction } from 'i18next';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { ToolCallsType } from '../conversation/types';
|
||||
import type { ToolCallsType } from '../conversation/types';
|
||||
import { getToolChipLabel } from './streamingStatusUtils';
|
||||
|
||||
// Stub that renders "key" or "key|value,value" so assertions can check both
|
||||
@@ -44,6 +44,18 @@ describe('getToolChipLabel', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('treats a status-less call as settled, matching the non-shimmer row', () => {
|
||||
expect(
|
||||
getToolChipLabel(
|
||||
call({ arguments: { query: 'docsgpt' }, status: undefined }),
|
||||
t,
|
||||
),
|
||||
).toBe('conversation.toolChip.searchingWeb|docsgpt');
|
||||
expect(getToolChipLabel(call({ status: undefined }), t)).toBe(
|
||||
'conversation.toolChip.searchedWebGeneric',
|
||||
);
|
||||
});
|
||||
|
||||
it('labels read_webpage with the hostname', () => {
|
||||
expect(
|
||||
getToolChipLabel(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { TFunction } from 'i18next';
|
||||
|
||||
import { ToolCallsType } from '../conversation/types';
|
||||
import type { ToolCallsType } from '../conversation/types';
|
||||
|
||||
const WEB_SEARCH_ACTIONS = new Set([
|
||||
'brave_web_search',
|
||||
@@ -96,9 +96,7 @@ export function getToolChipLabel(
|
||||
t: TFunction,
|
||||
): string {
|
||||
const activity = describeToolCall(toolCall);
|
||||
const settled =
|
||||
toolCall.status && toolCall.status !== 'pending'
|
||||
? 'toolChip'
|
||||
: 'streamingStatus';
|
||||
return activityLabel(activity, settled, t);
|
||||
const namespace =
|
||||
toolCall.status === 'pending' ? 'streamingStatus' : 'toolChip';
|
||||
return activityLabel(activity, namespace, t);
|
||||
}
|
||||
Reference in new issue
Block a user