From 6b9ea59e6757278c306526b76084b3801ea6bc11 Mon Sep 17 00:00:00 2001 From: Stanislav Novosad Date: Wed, 14 Jan 2026 16:56:50 -0700 Subject: [PATCH] Workflow Copilot: various small fixes (#4454) --- .../routes/workflows/editor/WorkflowCopilotChat.tsx | 10 +++++++--- skyvern/forge/prompts/skyvern/workflow-copilot.j2 | 3 +-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/skyvern-frontend/src/routes/workflows/editor/WorkflowCopilotChat.tsx b/skyvern-frontend/src/routes/workflows/editor/WorkflowCopilotChat.tsx index 47fa6306..f0d9fd24 100644 --- a/skyvern-frontend/src/routes/workflows/editor/WorkflowCopilotChat.tsx +++ b/skyvern-frontend/src/routes/workflows/editor/WorkflowCopilotChat.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect, useRef, memo } from "react"; +import { useState, useEffect, useLayoutEffect, useRef, memo } from "react"; import { getClient } from "@/api/AxiosClient"; import { useCredentialGetter } from "@/hooks/useCredentialGetter"; import { useIsSkyvernUser } from "@/hooks/useIsSkyvernUser"; @@ -165,6 +165,10 @@ export function WorkflowCopilotChat({ }, [messages.length, onMessageCountChange]); useEffect(() => { + if (!isOpen) { + hasScrolledOnLoad.current = false; + return; + } if (isLoadingHistory) { return; } @@ -174,7 +178,7 @@ export function WorkflowCopilotChat({ return; } scrollToBottom("smooth"); - }, [messages, isLoading, isLoadingHistory]); + }, [messages, isLoading, isLoadingHistory, isOpen]); useEffect(() => { if (!workflowPermanentId) { @@ -525,7 +529,7 @@ export function WorkflowCopilotChat({ }, [size]); // Recalculate position when chat opens to align with button (only first time) - useEffect(() => { + useLayoutEffect(() => { if (isOpen && buttonRef?.current && !hasInitializedPosition.current) { const newPosition = calculateDefaultPosition( size.width, diff --git a/skyvern/forge/prompts/skyvern/workflow-copilot.j2 b/skyvern/forge/prompts/skyvern/workflow-copilot.j2 index dbae58fe..0071c9b2 100644 --- a/skyvern/forge/prompts/skyvern/workflow-copilot.j2 +++ b/skyvern/forge/prompts/skyvern/workflow-copilot.j2 @@ -169,8 +169,7 @@ Use this when the user's request is ambiguous, missing critical information, or { "type": "ASK_QUESTION", - "user_response": "A short response to show the user in chat", - "question": "A clear, specific question to ask the user", + "user_response": "A clear, specific question to ask the user", "global_llm_context": "User's overall goal (preserve from previous)" }