Skip to content

Commit 985f6a6

Browse files
committed
feat(terminal): add fix in copilot for errors
1 parent 037dad6 commit 985f6a6

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/components/log-row-context-menu.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ interface LogRowContextMenuProps {
3434
onCopyRunId: (runId: string) => void
3535
onClearFilters: () => void
3636
onClearConsole: () => void
37+
onFixInCopilot: (entry: ConsoleEntry) => void
3738
hasActiveFilters: boolean
3839
}
3940

@@ -54,6 +55,7 @@ export function LogRowContextMenu({
5455
onCopyRunId,
5556
onClearFilters,
5657
onClearConsole,
58+
onFixInCopilot,
5759
hasActiveFilters,
5860
}: LogRowContextMenuProps) {
5961
const hasRunId = entry?.executionId != null
@@ -96,6 +98,21 @@ export function LogRowContextMenu({
9698
</>
9799
)}
98100

101+
{/* Fix in Copilot - only for error rows */}
102+
{entry && !entry.success && (
103+
<>
104+
<PopoverItem
105+
onClick={() => {
106+
onFixInCopilot(entry)
107+
onClose()
108+
}}
109+
>
110+
Fix in Copilot
111+
</PopoverItem>
112+
<PopoverDivider />
113+
</>
114+
)}
115+
99116
{/* Filter actions */}
100117
{entry && (
101118
<>

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { useShowTrainingControls } from '@/hooks/queries/general-settings'
5454
import { useCodeViewerFeatures } from '@/hooks/use-code-viewer'
5555
import { OUTPUT_PANEL_WIDTH, TERMINAL_HEIGHT } from '@/stores/constants'
5656
import { useCopilotTrainingStore } from '@/stores/copilot-training/store'
57+
import { openCopilotWithMessage } from '@/stores/notifications/utils'
5758
import type { ConsoleEntry } from '@/stores/terminal'
5859
import { useTerminalConsoleStore, useTerminalStore } from '@/stores/terminal'
5960
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
@@ -226,7 +227,6 @@ const isEventFromEditableElement = (e: KeyboardEvent): boolean => {
226227
return false
227228
}
228229

229-
// Check target and walk up ancestors in case editors render nested elements
230230
let el: HTMLElement | null = target
231231
while (el) {
232232
if (isEditable(el)) return true
@@ -1159,6 +1159,17 @@ export const Terminal = memo(function Terminal() {
11591159
clearCurrentWorkflowConsole()
11601160
}, [clearCurrentWorkflowConsole])
11611161

1162+
const handleFixInCopilot = useCallback(
1163+
(entry: ConsoleEntry) => {
1164+
const errorMessage = entry.error ? String(entry.error) : 'Unknown error'
1165+
const blockName = entry.blockName || 'Unknown Block'
1166+
const message = `${errorMessage}\n\nError in ${blockName}.\n\nPlease fix this.`
1167+
openCopilotWithMessage(message)
1168+
closeLogRowMenu()
1169+
},
1170+
[closeLogRowMenu]
1171+
)
1172+
11621173
const handleTrainingClick = useCallback(
11631174
(e: React.MouseEvent) => {
11641175
e.stopPropagation()
@@ -1949,6 +1960,7 @@ export const Terminal = memo(function Terminal() {
19491960
closeLogRowMenu()
19501961
}}
19511962
onClearConsole={handleClearConsoleFromMenu}
1963+
onFixInCopilot={handleFixInCopilot}
19521964
hasActiveFilters={hasActiveFilters}
19531965
/>
19541966
</>

0 commit comments

Comments
 (0)