diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/components/log-row-context-menu.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/components/log-row-context-menu.tsx index 009b24b8fb..ff4fd71d12 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/components/log-row-context-menu.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/components/log-row-context-menu.tsx @@ -34,6 +34,7 @@ interface LogRowContextMenuProps { onCopyRunId: (runId: string) => void onClearFilters: () => void onClearConsole: () => void + onFixInCopilot: (entry: ConsoleEntry) => void hasActiveFilters: boolean } @@ -54,6 +55,7 @@ export function LogRowContextMenu({ onCopyRunId, onClearFilters, onClearConsole, + onFixInCopilot, hasActiveFilters, }: LogRowContextMenuProps) { const hasRunId = entry?.executionId != null @@ -96,6 +98,21 @@ export function LogRowContextMenu({ )} + {/* Fix in Copilot - only for error rows */} + {entry && !entry.success && ( + <> + { + onFixInCopilot(entry) + onClose() + }} + > + Fix in Copilot + + + + )} + {/* Filter actions */} {entry && ( <> diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx index 570f13900d..81871fc045 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx @@ -54,6 +54,7 @@ import { useShowTrainingControls } from '@/hooks/queries/general-settings' import { useCodeViewerFeatures } from '@/hooks/use-code-viewer' import { OUTPUT_PANEL_WIDTH, TERMINAL_HEIGHT } from '@/stores/constants' import { useCopilotTrainingStore } from '@/stores/copilot-training/store' +import { openCopilotWithMessage } from '@/stores/notifications/utils' import type { ConsoleEntry } from '@/stores/terminal' import { useTerminalConsoleStore, useTerminalStore } from '@/stores/terminal' import { useWorkflowRegistry } from '@/stores/workflows/registry/store' @@ -226,7 +227,6 @@ const isEventFromEditableElement = (e: KeyboardEvent): boolean => { return false } - // Check target and walk up ancestors in case editors render nested elements let el: HTMLElement | null = target while (el) { if (isEditable(el)) return true @@ -1159,6 +1159,17 @@ export const Terminal = memo(function Terminal() { clearCurrentWorkflowConsole() }, [clearCurrentWorkflowConsole]) + const handleFixInCopilot = useCallback( + (entry: ConsoleEntry) => { + const errorMessage = entry.error ? String(entry.error) : 'Unknown error' + const blockName = entry.blockName || 'Unknown Block' + const message = `${errorMessage}\n\nError in ${blockName}.\n\nPlease fix this.` + openCopilotWithMessage(message) + closeLogRowMenu() + }, + [closeLogRowMenu] + ) + const handleTrainingClick = useCallback( (e: React.MouseEvent) => { e.stopPropagation() @@ -1949,6 +1960,7 @@ export const Terminal = memo(function Terminal() { closeLogRowMenu() }} onClearConsole={handleClearConsoleFromMenu} + onFixInCopilot={handleFixInCopilot} hasActiveFilters={hasActiveFilters} />