feat: integrate Google Gemini, MiniMax, and GLM providers; fix persistent agent loading toast
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 1m23s
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 1m23s
This commit is contained in:
@@ -93,24 +93,49 @@ export function AgentCard({ agent, onEdit, onRefresh, onToggle }: AgentCardProps
|
||||
return
|
||||
}
|
||||
if (pollRef.current) clearInterval(pollRef.current)
|
||||
|
||||
const startTime = Date.now()
|
||||
const MAX_POLL_TIME = 10 * 60 * 1000 // 10 minutes
|
||||
|
||||
pollRef.current = setInterval(async () => {
|
||||
// Safety timeout
|
||||
if (Date.now() - startTime > MAX_POLL_TIME) {
|
||||
if (pollRef.current) clearInterval(pollRef.current)
|
||||
pollRef.current = null
|
||||
setIsRunning(false)
|
||||
toast.error(t('agents.toasts.runError', { error: 'Timeout after 10 minutes' }), { id: toastId, description: '' })
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch(`/api/agents/run-for-note?agentId=${agent.id}`)
|
||||
if (!res.ok) throw new Error('Poll failed')
|
||||
|
||||
const data = await res.json()
|
||||
if (data.status === 'success') {
|
||||
clearInterval(pollRef.current!)
|
||||
if (pollRef.current) clearInterval(pollRef.current)
|
||||
pollRef.current = null
|
||||
setIsRunning(false)
|
||||
toast.success(t('agents.toasts.runSuccess', { name: agent.name }), { id: toastId, duration: 6000 })
|
||||
toast.success(t('agents.toasts.runSuccess', { name: agent.name }), {
|
||||
id: toastId,
|
||||
duration: 6000,
|
||||
description: '' // Clear the loading description
|
||||
})
|
||||
onRefresh()
|
||||
} else if (data.status === 'failure') {
|
||||
clearInterval(pollRef.current!)
|
||||
if (pollRef.current) clearInterval(pollRef.current)
|
||||
pollRef.current = null
|
||||
setIsRunning(false)
|
||||
toast.error(t('agents.toasts.runError', { error: data.error || t('agents.toasts.runFailed') }), { id: toastId })
|
||||
toast.error(t('agents.toasts.runError', { error: data.error || t('agents.toasts.runFailed') }), {
|
||||
id: toastId,
|
||||
description: '' // Clear the loading description
|
||||
})
|
||||
onRefresh()
|
||||
}
|
||||
} catch { /* keep polling */ }
|
||||
} catch (err) {
|
||||
console.error('Polling error:', err)
|
||||
// Keep polling until timeout
|
||||
}
|
||||
}, 3000)
|
||||
} catch {
|
||||
toast.error(t('agents.toasts.runGenericError'), { id: toastId })
|
||||
|
||||
Reference in New Issue
Block a user