Skip to content

Commit eb099eb

Browse files
committed
Fix superagent
1 parent 9c27950 commit eb099eb

File tree

2 files changed

+27
-39
lines changed
  • apps/sim
    • app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call
    • stores/panel/copilot

2 files changed

+27
-39
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call/tool-call.tsx

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,10 +1636,8 @@ function WorkflowEditSummary({ toolCall }: { toolCall: CopilotToolCall }) {
16361636
* Checks if a tool is an integration tool (server-side executed, not a client tool)
16371637
*/
16381638
function isIntegrationTool(toolName: string): boolean {
1639-
// Check if it's NOT a client tool (not in CLASS_TOOL_METADATA and not in registered tools)
1640-
const isClientTool = !!CLASS_TOOL_METADATA[toolName]
1641-
const isRegisteredTool = !!getRegisteredTools()[toolName]
1642-
return !isClientTool && !isRegisteredTool
1639+
// Any tool NOT in CLASS_TOOL_METADATA is an integration tool (server-side execution)
1640+
return !CLASS_TOOL_METADATA[toolName]
16431641
}
16441642

16451643
function shouldShowRunSkipButtons(toolCall: CopilotToolCall): boolean {
@@ -1668,16 +1666,9 @@ function shouldShowRunSkipButtons(toolCall: CopilotToolCall): boolean {
16681666
return true
16691667
}
16701668

1671-
// Also show buttons for integration tools in pending state (they need user confirmation)
1672-
// But NOT if the tool is auto-allowed (it will auto-execute)
1669+
// Always show buttons for integration tools in pending state (they need user confirmation)
16731670
const mode = useCopilotStore.getState().mode
1674-
const isAutoAllowed = useCopilotStore.getState().isToolAutoAllowed(toolCall.name)
1675-
if (
1676-
mode === 'build' &&
1677-
isIntegrationTool(toolCall.name) &&
1678-
toolCall.state === 'pending' &&
1679-
!isAutoAllowed
1680-
) {
1671+
if (mode === 'build' && isIntegrationTool(toolCall.name) && toolCall.state === 'pending') {
16811672
return true
16821673
}
16831674

@@ -1899,15 +1890,20 @@ function RunSkipButtons({
18991890

19001891
if (buttonsHidden) return null
19011892

1902-
// Standardized buttons for all interrupt tools: Allow, Always Allow, Skip
1893+
// Hide "Always Allow" for integration tools (only show for client tools with interrupts)
1894+
const showAlwaysAllow = !isIntegrationTool(toolCall.name)
1895+
1896+
// Standardized buttons for all interrupt tools: Allow, (Always Allow for client tools only), Skip
19031897
return (
19041898
<div className='mt-1.5 flex gap-[6px]'>
19051899
<Button onClick={onRun} disabled={isProcessing} variant='tertiary'>
19061900
{isProcessing ? 'Allowing...' : 'Allow'}
19071901
</Button>
1908-
<Button onClick={onAlwaysAllow} disabled={isProcessing} variant='default'>
1909-
{isProcessing ? 'Allowing...' : 'Always Allow'}
1910-
</Button>
1902+
{showAlwaysAllow && (
1903+
<Button onClick={onAlwaysAllow} disabled={isProcessing} variant='default'>
1904+
{isProcessing ? 'Allowing...' : 'Always Allow'}
1905+
</Button>
1906+
)}
19111907
<Button onClick={onSkip} disabled={isProcessing} variant='default'>
19121908
Skip
19131909
</Button>

apps/sim/stores/panel/copilot/store.ts

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,30 +1223,20 @@ const sseHandlers: Record<string, SSEHandler> = {
12231223
}
12241224
} catch {}
12251225

1226-
// Integration tools: Check if auto-allowed, otherwise wait for user confirmation
1227-
// This handles tools like google_calendar_*, exa_*, etc. that aren't in the client registry
1226+
// Integration tools: Stay in pending state until user confirms via buttons
1227+
// This handles tools like google_calendar_*, exa_*, gmail_read, etc. that aren't in the client registry
12281228
// Only relevant if mode is 'build' (agent)
1229-
const { mode, workflowId, autoAllowedTools } = get()
1229+
const { mode, workflowId } = get()
12301230
if (mode === 'build' && workflowId) {
1231-
// Check if tool was NOT found in client registry (def is undefined from above)
1231+
// Check if tool was NOT found in client registry
12321232
const def = name ? getTool(name) : undefined
12331233
const inst = getClientTool(id) as any
12341234
if (!def && !inst && name) {
1235-
// Check if this tool is auto-allowed
1236-
if (autoAllowedTools.includes(name)) {
1237-
logger.info('[build mode] Integration tool auto-allowed, executing', { id, name })
1238-
1239-
// Auto-execute the tool
1240-
setTimeout(() => {
1241-
get().executeIntegrationTool(id)
1242-
}, 0)
1243-
} else {
1244-
// Integration tools stay in pending state until user confirms
1245-
logger.info('[build mode] Integration tool awaiting user confirmation', {
1246-
id,
1247-
name,
1248-
})
1249-
}
1235+
// Integration tools stay in pending state until user confirms
1236+
logger.info('[build mode] Integration tool awaiting user confirmation', {
1237+
id,
1238+
name,
1239+
})
12501240
}
12511241
}
12521242
},
@@ -2639,13 +2629,14 @@ export const useCopilotStore = create<CopilotStore>()(
26392629
),
26402630
isSendingMessage: false,
26412631
isAborting: false,
2642-
abortController: null,
2632+
// Keep abortController so streaming loop can check signal.aborted
2633+
// It will be nulled when streaming completes or new message starts
26432634
}))
26442635
} else {
26452636
set({
26462637
isSendingMessage: false,
26472638
isAborting: false,
2648-
abortController: null,
2639+
// Keep abortController so streaming loop can check signal.aborted
26492640
})
26502641
}
26512642

@@ -2674,7 +2665,7 @@ export const useCopilotStore = create<CopilotStore>()(
26742665
} catch {}
26752666
}
26762667
} catch {
2677-
set({ isSendingMessage: false, isAborting: false, abortController: null })
2668+
set({ isSendingMessage: false, isAborting: false })
26782669
}
26792670
},
26802671

@@ -3175,6 +3166,7 @@ export const useCopilotStore = create<CopilotStore>()(
31753166
: msg
31763167
),
31773168
isSendingMessage: false,
3169+
isAborting: false,
31783170
abortController: null,
31793171
currentUserMessageId: null,
31803172
}))

0 commit comments

Comments
 (0)