From 68b1e3c327f27a20d28b6ea154bd8936c59f0c8e Mon Sep 17 00:00:00 2001 From: Emir Karabeg Date: Fri, 31 Jan 2025 16:15:48 -0800 Subject: [PATCH] Fixed icons showing in console for every block --- .../console/components/console-entry/console-entry.tsx | 7 +++---- app/w/hooks/use-workflow-execution.ts | 3 ++- executor/index.ts | 5 +++++ executor/types.ts | 1 + stores/console/types.ts | 3 ++- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/w/components/console/components/console-entry/console-entry.tsx b/app/w/components/console/components/console-entry/console-entry.tsx index c9b8ec9621..6901853c2c 100644 --- a/app/w/components/console/components/console-entry/console-entry.tsx +++ b/app/w/components/console/components/console-entry/console-entry.tsx @@ -28,10 +28,9 @@ export function ConsoleEntry({ entry, consoleWidth }: ConsoleEntryProps) { ) const blockConfig = useMemo(() => { - if (!entry.blockName) return null - const blockType = entry.blockName.split(' ')[0].toLowerCase() - return getBlock(blockType) - }, [entry.blockName]) + if (!entry.blockType) return null + return getBlock(entry.blockType) + }, [entry.blockType]) const BlockIcon = blockConfig?.toolbar.icon diff --git a/app/w/hooks/use-workflow-execution.ts b/app/w/hooks/use-workflow-execution.ts index 3468ac23ec..c6bdbd0a9b 100644 --- a/app/w/hooks/use-workflow-execution.ts +++ b/app/w/hooks/use-workflow-execution.ts @@ -45,7 +45,8 @@ export function useWorkflowExecution() { endedAt: log.endedAt, workflowId: activeWorkflowId, timestamp: log.startedAt, - blockName: log.blockTitle + blockName: log.blockTitle, + blockType: log.blockType }) }) } diff --git a/executor/index.ts b/executor/index.ts index df2c73b845..9475618bb0 100644 --- a/executor/index.ts +++ b/executor/index.ts @@ -18,6 +18,7 @@ import { BlockLog } from './types' import { tools } from '@/tools' +import { getBlockTypeForTool } from '@/blocks' export class Executor { constructor( @@ -185,10 +186,14 @@ export class Executor { ...inputs, }) + // Get the block type from the tool ID using the helper function + const blockType = getBlockTypeForTool(toolId) + // Prepare a new blockLog entry const blockLog: Partial = { blockId: block.id, blockTitle: block.metadata?.title || 'Unnamed Block', + blockType: blockType, startedAt: new Date().toISOString(), } diff --git a/executor/types.ts b/executor/types.ts index 9cb4509469..7b043bd7d4 100644 --- a/executor/types.ts +++ b/executor/types.ts @@ -12,6 +12,7 @@ export interface BlockLog { endedAt: string durationMs: number output?: any + blockType?: string } /** diff --git a/stores/console/types.ts b/stores/console/types.ts index f67bd13e53..48183373d4 100644 --- a/stores/console/types.ts +++ b/stores/console/types.ts @@ -5,9 +5,10 @@ export interface ConsoleEntry { durationMs: number startedAt: string endedAt: string - workflowId?: string | null + workflowId: string | null timestamp: string blockName?: string + blockType?: string } export interface ConsoleStore {