From 0c05ccc92eb59a56966a1c2c4dcb0026dc1c1c78 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Fri, 12 Dec 2025 03:41:35 -0500 Subject: [PATCH] refactor: Clarify content handling logic in useStepHandler - Updated comments to better explain the handling of initialContent and existingContent in edit and resume scenarios. - Simplified the logic for merging content, ensuring that initialContent is used directly when available, improving clarity and maintainability. --- client/src/hooks/SSE/useStepHandler.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/hooks/SSE/useStepHandler.ts b/client/src/hooks/SSE/useStepHandler.ts index b061a43b36..24bcaf140d 100644 --- a/client/src/hooks/SSE/useStepHandler.ts +++ b/client/src/hooks/SSE/useStepHandler.ts @@ -239,10 +239,10 @@ export default function useStepHandler({ ? lastMessage : (submission?.initialResponse as TMessage); - // Preserve existing content from DB (partial response) and prepend initialContent if provided + // For edit scenarios, initialContent IS the complete starting content (not to be merged) + // For resume scenarios (no editedContent), initialContent is empty and we use existingContent const existingContent = responseMessage?.content ?? []; - const mergedContent = - initialContent.length > 0 ? [...initialContent, ...existingContent] : existingContent; + const mergedContent = initialContent.length > 0 ? initialContent : existingContent; response = { ...responseMessage,