diff --git a/backend/run_agent_background.py b/backend/run_agent_background.py index 53121184..43f4d0e7 100644 --- a/backend/run_agent_background.py +++ b/backend/run_agent_background.py @@ -591,9 +591,9 @@ async def run_workflow_background( except Exception as e: logger.warning(f"Error closing pubsub for {execution_id}: {str(e)}") - await _cleanup_redis_response_list(execution_id, agent_run_id) - await _cleanup_redis_instance_key(execution_id, agent_run_id) - await _cleanup_redis_run_lock(execution_id) + await _cleanup_redis_response_list(agent_run_id) + await _cleanup_redis_instance_key(agent_run_id) + await _cleanup_redis_run_lock(agent_run_id) try: await asyncio.wait_for(asyncio.gather(*pending_redis_operations), timeout=30.0) @@ -615,7 +615,6 @@ async def update_workflow_execution_status(client, execution_id: str, status: st await client.table('workflow_executions').update(update_data).eq('id', execution_id).execute() logger.info(f"Updated workflow execution {execution_id} status to {status}") - # Also update agent_runs table if agent_run_id provided (for frontend streaming compatibility) if agent_run_id: await client.table('agent_runs').update(update_data).eq('id', agent_run_id).execute() logger.info(f"Updated agent run {agent_run_id} status to {status}") diff --git a/frontend/src/components/workflows/nodes/InputNode.tsx b/frontend/src/components/workflows/nodes/InputNode.tsx index 69a5f32e..b2896b72 100644 --- a/frontend/src/components/workflows/nodes/InputNode.tsx +++ b/frontend/src/components/workflows/nodes/InputNode.tsx @@ -1,6 +1,6 @@ "use client"; -import { memo, useState } from "react"; +import { memo, useState, useEffect, useCallback } from "react"; import { Handle, Position, NodeProps } from "@xyflow/react"; import { Play, Settings, Clock, Webhook, User, ChevronDown, ChevronUp, Brain } from "lucide-react"; import { CardContent, CardHeader } from "@/components/ui/card"; @@ -35,6 +35,7 @@ const InputNode = memo(({ data, selected, id }: NodeProps) => { const [isConfigOpen, setIsConfigOpen] = useState(false); const [isWebhookDialogOpen, setIsWebhookDialogOpen] = useState(false); const [isScheduleDialogOpen, setIsScheduleDialogOpen] = useState(false); + const [localPrompt, setLocalPrompt] = useState(nodeData.prompt || ''); const { updateNodeData, workflowId } = useWorkflow(); // Use the model selection hook @@ -50,6 +51,30 @@ const InputNode = memo(({ data, selected, id }: NodeProps) => { // Initialize model if not set const currentModel = nodeData.model || selectedModel; + // Update local prompt when nodeData changes + useEffect(() => { + setLocalPrompt(nodeData.prompt || ''); + }, [nodeData.prompt]); + + // eslint-disable-next-line react-hooks/exhaustive-deps + const debouncedUpdatePrompt = useCallback( + (() => { + let timeoutId: NodeJS.Timeout; + return (value: string) => { + clearTimeout(timeoutId); + timeoutId = setTimeout(() => { + updateNodeData(id, { prompt: value }); + }, 300); + }; + })(), + [id, updateNodeData] + ); + + const handlePromptChange = (value: string) => { + setLocalPrompt(value); + debouncedUpdatePrompt(value); + }; + const handleModelChange = (modelId: string) => { updateNodeData(id, { model: modelId }); }; @@ -182,8 +207,8 @@ const InputNode = memo(({ data, selected, id }: NodeProps) => {