🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
feat(workflow): tri-state completion status icon for WorkflowCollapse (#13952)
Inneic213483a7a0b
diff --git a/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.test.tsx b/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.test.tsxindex 0c2ee0c537c..1565bed87d1 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.test.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.test.tsx@@ -26,7 +26,16 @@ vi.mock('@lobehub/ui', () => ({Block: ({ children }: { children?: ReactNode }) => <div>{children}</div>,Flexbox: ({ children }: { children?: ReactNode }) => <div>{children}</div>,Icon: ({ icon: IconComponent }: { icon?: ComponentType }) =>- IconComponent ? <IconComponent /> : <div />,+ IconComponent ? (+ <div+ data-icon={IconComponent.displayName || IconComponent.name || 'unknown'}+ data-testid="icon"+ >+ <IconComponent />+ </div>+ ) : (+ <div />+ ),ShikiLobeTheme: {},Text: ({ children }: { children?: ReactNode }) => <span>{children}</span>,}));@@ -49,6 +58,8 @@ vi.mock('react-i18next', () => ({(({'workflow.awaitingConfirmation': 'Awaiting your confirmation',+ 'workflow.collapse': 'Collapse',+ 'workflow.expandFull': 'Expand fully','workflow.working': 'Working...',}) as Record<string, string>)[key] ||@@ -234,4 +245,100 @@ describe('WorkflowCollapse', () => {expect(getExpandedKeys()).toBe('["workflow"]');});++ it('shows green check when all tools succeed after completion', () => {+ mockIsGenerating = false;+ const blocks: AssistantContentBlock[] = [+ {+ content: '',+ id: 'block-1',+ tools: [+ {+ apiName: 'search',+ arguments: '{}',+ id: 'tool-1',+ identifier: 'search',+ type: 'builtin',+ result: { content: 'ok' },+ } as any,+ {+ apiName: 'calculate',+ arguments: '{}',+ id: 'tool-2',+ identifier: 'calculate',+ type: 'builtin',+ result: { content: '42' },+ } as any,+ ],+ } as AssistantContentBlock,+ ];++ render(<WorkflowCollapse assistantMessageId="msg-1" blocks={blocks} />);+ const icon = screen.getByTestId('icon');+ expect(icon).toHaveAttribute('data-icon', 'Check');+ });++ it('shows yellow warning when some tools fail after completion', () => {+ mockIsGenerating = false;+ const blocks: AssistantContentBlock[] = [+ {+ content: '',+ id: 'block-1',+ tools: [+ {+ apiName: 'search',+ arguments: '{}',+ id: 'tool-1',+ identifier: 'search',+ type: 'builtin',+ result: { content: 'ok' },+ } as any,+ {+ apiName: 'calculate',+ arguments: '{}',+ id: 'tool-2',+ identifier: 'calculate',+ type: 'builtin',+ result: { content: null, error: { message: 'bad' } },+ } as any,+ ],+ } as AssistantContentBlock,+ ];++ render(<WorkflowCollapse assistantMessageId="msg-1" blocks={blocks} />);+ const icon = screen.getByTestId('icon');+ expect(icon).toHaveAttribute('data-icon', 'TriangleAlert');+ });++ it('shows red x when all tools fail after completion', () => {+ mockIsGenerating = false;+ const blocks: AssistantContentBlock[] = [+ {+ content: '',+ id: 'block-1',+ tools: [+ {+ apiName: 'search',+ arguments: '{}',+ id: 'tool-1',+ identifier: 'search',+ type: 'builtin',+ result: { content: null, error: { message: 'bad' } },+ } as any,+ {+ apiName: 'calculate',+ arguments: '{}',+ id: 'tool-2',+ identifier: 'calculate',+ type: 'builtin',+ result: { content: null, error: { message: 'worse' } },+ } as any,+ ],+ } as AssistantContentBlock,+ ];++ render(<WorkflowCollapse assistantMessageId="msg-1" blocks={blocks} />);+ const icon = screen.getByTestId('icon');+ expect(icon).toHaveAttribute('data-icon', 'X');+ });});diff --git a/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.tsx b/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.tsxindex 1f799e538ec..645dee49f3d 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.tsx@@ -1,7 +1,7 @@import { type ChatToolPayloadWithResult } from '@lobechat/types';import { Accordion, AccordionItem, Block, Flexbox, Icon, Text } from '@lobehub/ui';import { cssVar } from 'antd-style';-import { Check, HandIcon, Maximize2, Minimize2, X } from 'lucide-react';+import { AlertTriangle, Check, HandIcon, Maximize2, Minimize2, X } from 'lucide-react';import { AnimatePresence, m as motion } from 'motion/react';import { type Key, memo, useEffect, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -25,9 +25,9 @@ import {import {areWorkflowToolsComplete,formatReasoningDuration,+ getWorkflowCompletionStatus,getWorkflowStreamingHeadlineState,getWorkflowSummaryText,- hasToolError,shapeProseForWorkflowHeadline,} from '../toolDisplayNames';import type { RenderableAssistantContentBlock } from './types';@@ -137,7 +137,7 @@ const WorkflowCollapse = memo<WorkflowCollapseProps>(const allComplete = toolsPhaseComplete && (workflowChromeComplete || !isGenerating);const summaryText = useMemo(() => getWorkflowSummaryText(blocks), [blocks]);- const errorPresent = hasToolError(allTools);+ const completionStatus = useMemo(() => getWorkflowCompletionStatus(allTools), [allTools]);/** Sum of per-round model output duration (not reasoning-only); see ModelPerformance.duration */const totalWorkflowMs = useMemo(@@ -289,27 +289,35 @@ const WorkflowCollapse = memo<WorkflowCollapseProps>(threshold: WORKFLOW_EXPANDED_SCROLL_THRESHOLD_PX,});- const statusIcon = streaming ? (- pendingInterventionPresent ? (- <Icon color={cssVar.colorInfo} icon={HandIcon} />- ) : (- <NeuralNetworkLoading size={16} />- )- ) : errorPresent ? (- <Icon color={cssVar.colorError} icon={X} />- ) : (- <Icon color={cssVar.colorSuccess} icon={Check} />- );+ const getStatusIcon = (): React.ReactNode => {+ if (streaming) {+ return pendingInterventionPresent ? (+ <Icon color={cssVar.colorInfo} icon={HandIcon} />+ ) : (+ <NeuralNetworkLoading size={16} />+ );+ }++ switch (completionStatus) {+ case 'error': {+ return <Icon color={cssVar.colorError} icon={X} />;+ }+ case 'partial': {+ return <Icon color={cssVar.colorWarning} icon={AlertTriangle} />;+ }+ default: {+ return <Icon color={cssVar.colorSuccess} icon={Check} />;+ }+ }+ };const showExpandToggle = expandLevel !== 'collapsed';const expandToggleLabel =- expandLevel === 'semi'- ? t('workflow.expandFull', { defaultValue: 'Expand fully' })- : t('workflow.collapse', { defaultValue: 'Collapse' });+ expandLevel === 'semi' ? t('workflow.expandFull') : t('workflow.collapse');const expandToggleIcon = expandLevel === 'semi' ? Maximize2 : Minimize2;- const handleToggleExpand = (e: React.MouseEvent) => {+ const handleToggleExpand = (e: React.MouseEvent | React.KeyboardEvent) => {e.stopPropagation();if (expandLevel === 'semi') {setExpandLevel('full');@@ -319,6 +327,13 @@ const WorkflowCollapse = memo<WorkflowCollapseProps>(}};+ const handleToggleKeyDown = (e: React.KeyboardEvent) => {+ if (e.key === 'Enter' || e.key === ' ') {+ e.preventDefault();+ handleToggleExpand(e);+ }+ };+const title = (<Flexbox horizontal align="center" gap={6} width="100%"><Block@@ -331,7 +346,7 @@ const WorkflowCollapse = memo<WorkflowCollapseProps>(variant="outlined"width={24}>- {statusIcon}+ {getStatusIcon()}</Block>{streaming ? (<Flexbox@@ -410,15 +425,18 @@ const WorkflowCollapse = memo<WorkflowCollapseProps>(exit={{ opacity: 0, scale: 0.9, x: 4 }}initial={{ opacity: 0, scale: 0.9, x: 4 }}role="button"+ tabIndex={0}title={expandToggleLabel}transition={WORKFLOW_EXPAND_TOGGLE_TRANSITION}style={{cursor: 'pointer',flex: 'none',marginInlineStart: 8,+ outline: 'none',padding: 2,}}onClick={handleToggleExpand}+ onKeyDown={handleToggleKeyDown}><AnimatePresence initial={false} mode="wait"><motion.spandiff --git a/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.ts b/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.tsindex b8be9d6fd86..7b178437e7b 100644--- a/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.ts+++ b/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.ts@@ -132,6 +132,23 @@ export const hasToolError = (tools: ChatToolPayloadWithResult[]): boolean => {return tools.some((t) => t.result?.error);};+export const getWorkflowCompletionStatus = (+ tools: ChatToolPayloadWithResult[],+): 'success' | 'partial' | 'error' => {+ const collapsible = tools.filter((t) => t.intervention?.status !== 'pending');+ if (collapsible.length === 0) return 'success';++ const completed = collapsible.filter(+ (t) => t.result != null && t.result.content !== LOADING_FLAT,+ );+ if (completed.length === 0) return 'success';++ const errorCount = completed.filter((t) => t.result?.error).length;+ if (errorCount === 0) return 'success';+ if (errorCount === completed.length) return 'error';+ return 'partial';+};+export const getToolFirstDetail = (tool: ChatToolPayloadWithResult): string => {try {const args = JSON.parse(tool.arguments || '{}');diff --git a/src/libs/oidc-provider/jwt.ts b/src/libs/oidc-provider/jwt.tsindex 88e47fd6587..aeb8e8dd0a3 100644--- a/src/libs/oidc-provider/jwt.ts+++ b/src/libs/oidc-provider/jwt.ts@@ -89,7 +89,9 @@ const getVerificationKey = async () => {return await importJWK(publicKeyJwk, 'RS256');} catch (error) {log('Failed to get JWKS public key: %O', error);- throw new Error(`JWKS_KEY public key retrieval failed: ${(error as Error).message}`, { cause: error });+ throw new Error(`JWKS_KEY public key retrieval failed: ${(error as Error).message}`, {+ cause: error,+ });}};diff --git a/src/locales/default/chat.ts b/src/locales/default/chat.tsindex 2f2df6a01d6..e8ac39cd89b 100644--- a/src/locales/default/chat.ts+++ b/src/locales/default/chat.ts@@ -602,6 +602,8 @@ export default {'workflow.toolDisplayName.upsertDocumentByFilename': 'Updated a document','workflow.toolDisplayName.writeLocalFile': 'Wrote a file','workflow.awaitingConfirmation': 'Awaiting your confirmation',+ 'workflow.collapse': 'Collapse',+ 'workflow.expandFull': 'Expand fully','workflow.working': 'Working...','workingPanel.agentDocuments': 'Agent Documents','workingPanel.progress': 'Progress',diff --git a/src/routes/(main)/group/_layout/Sidebar/Topic/List/Item/index.tsx b/src/routes/(main)/group/_layout/Sidebar/Topic/List/Item/index.tsxindex ad3b9e87f68..a9cf2a2e468 100644--- a/src/routes/(main)/group/_layout/Sidebar/Topic/List/Item/index.tsx+++ b/src/routes/(main)/group/_layout/Sidebar/Topic/List/Item/index.tsx@@ -208,6 +208,7 @@ const TopicItem = memo<TopicItemProps>(({ id, title, fav, active, threadId }) =>contextMenuItems={dropdownMenu}disabled={editing}href={!editing ? href : undefined}+ title={title === '...' ? <DotsLoading gap={3} size={4} /> : title}icon={isLoading ? (<Icon spin icon={Loader2Icon} size={'small'} style={{ color: cssVar.colorWarning }} />@@ -218,7 +219,6 @@ const TopicItem = memo<TopicItemProps>(({ id, title, fav, active, threadId }) =>slots={{iconPostfix: unreadNode,}}- title={title === '...' ? <DotsLoading gap={3} size={4} /> : title}onClick={handleClick}onDoubleClick={handleDoubleClick}/>