From e2f85bf19ba01b06476728ed12c2fd7b645bc07e Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Sun, 9 Aug 2026 18:13:23 +0530 Subject: [PATCH] (fix)streaming status: code quality --- frontend/src/utils/streamingStatusUtils.test.ts | 14 +++++++++++++- frontend/src/utils/streamingStatusUtils.ts | 10 ++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/frontend/src/utils/streamingStatusUtils.test.ts b/frontend/src/utils/streamingStatusUtils.test.ts index f68752fb..1b30823c 100644 --- a/frontend/src/utils/streamingStatusUtils.test.ts +++ b/frontend/src/utils/streamingStatusUtils.test.ts @@ -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( diff --git a/frontend/src/utils/streamingStatusUtils.ts b/frontend/src/utils/streamingStatusUtils.ts index 1b884444..aad9e4bb 100644 --- a/frontend/src/utils/streamingStatusUtils.ts +++ b/frontend/src/utils/streamingStatusUtils.ts @@ -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); }