diff --git a/ui/admin/app/components/chat/Chat.tsx b/ui/admin/app/components/chat/Chat.tsx index 8968f096..66fb4161 100644 --- a/ui/admin/app/components/chat/Chat.tsx +++ b/ui/admin/app/components/chat/Chat.tsx @@ -12,16 +12,7 @@ type ChatProps = React.HTMLAttributes & { }; export function Chat({ className }: ChatProps) { - const { - id, - messages, - threadId, - mode, - invoke, - readOnly, - isInvoking, - isRunning, - } = useChat(); + const { id, messages, threadId, mode, invoke, readOnly } = useChat(); const [runTriggered, setRunTriggered] = useState(false); const showMessagePane = @@ -59,8 +50,6 @@ export function Chat({ className }: ChatProps) { popoverContentProps={{ className: cn({ "translate-y-[-50%]": !threadId }), }} - loading={isInvoking || isRunning} - disabled={isInvoking || isRunning} > Run diff --git a/ui/admin/app/components/chat/RunWorkflow.tsx b/ui/admin/app/components/chat/RunWorkflow.tsx index be7a1505..c39de072 100644 --- a/ui/admin/app/components/chat/RunWorkflow.tsx +++ b/ui/admin/app/components/chat/RunWorkflow.tsx @@ -1,9 +1,11 @@ +import { SquareIcon } from "lucide-react"; import { ComponentProps, useState } from "react"; import useSWR from "swr"; import { WorkflowService } from "~/lib/service/api/workflowService"; import { cn } from "~/lib/utils"; +import { useChat } from "~/components/chat/ChatContext"; import { RunWorkflowForm } from "~/components/chat/RunWorkflowForm"; import { ModelProviderTooltip } from "~/components/model-providers/ModelProviderTooltip"; import { Button, ButtonProps } from "~/components/ui/button"; @@ -32,19 +34,35 @@ export function RunWorkflow({ WorkflowService.getWorkflowById.key(workflowId), ({ workflowId }) => WorkflowService.getWorkflowById(workflowId) ); + const { abortRunningThread, isInvoking, isRunning } = useChat(); const params = workflow?.params; - if (!params || isLoading || !modelProviderConfigured) + const loading = props.loading || isLoading || isInvoking; + const disabled = props.disabled || loading || !modelProviderConfigured; + if (isRunning) { + return ( + + ); + } + + if (!params || !modelProviderConfigured) return ( @@ -56,8 +74,8 @@ export function RunWorkflow({