diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/long-input/long-input.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/long-input/long-input.tsx index adc488919..fbc57c897 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/long-input/long-input.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/long-input/long-input.tsx @@ -15,6 +15,7 @@ import { cn } from '@/lib/utils' import { formatDisplayText } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/formatted-text' import { SubBlockInputController } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/sub-block-input-controller' import { useSubBlockInput } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/hooks/use-sub-block-input' +import { useSubBlockValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/hooks/use-sub-block-value' import type { WandControlHandlers } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/sub-block' import { WandPromptBar } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/wand-prompt-bar/wand-prompt-bar' import { useAccessibleReferencePrefixes } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-accessible-reference-prefixes' @@ -94,6 +95,7 @@ export function LongInput({ }: LongInputProps) { // Local state for immediate UI updates during streaming const [localContent, setLocalContent] = useState('') + const persistSubBlockValueRef = useRef<(value: string) => void>(() => {}) // Wand functionality - always call the hook unconditionally const wandHook = useWand({ @@ -110,9 +112,22 @@ export function LongInput({ onGeneratedContent: (content) => { // Final content update (fallback) setLocalContent(content) + if (!isPreview && !disabled) { + persistSubBlockValueRef.current(content) + } }, }) + const [, setSubBlockValue] = useSubBlockValue(blockId, subBlockId, false, { + isStreaming: wandHook.isStreaming, + }) + + useEffect(() => { + persistSubBlockValueRef.current = (value: string) => { + setSubBlockValue(value) + } + }, [setSubBlockValue]) + // Check if wand is actually enabled const isWandEnabled = config.wandConfig?.enabled ?? false diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/short-input/short-input.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/short-input/short-input.tsx index e1b9508e2..6a181eecc 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/short-input/short-input.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/short-input/short-input.tsx @@ -6,6 +6,7 @@ import { Button } from '@/components/ui/button' import { cn } from '@/lib/utils' import { formatDisplayText } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/formatted-text' import { SubBlockInputController } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/sub-block-input-controller' +import { useSubBlockValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/hooks/use-sub-block-value' import type { WandControlHandlers } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/sub-block' import { WandPromptBar } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/wand-prompt-bar/wand-prompt-bar' import { useAccessibleReferencePrefixes } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-accessible-reference-prefixes' @@ -82,6 +83,7 @@ export function ShortInput({ const [localContent, setLocalContent] = useState('') const [isFocused, setIsFocused] = useState(false) const [copied, setCopied] = useState(false) + const persistSubBlockValueRef = useRef<(value: string) => void>(() => {}) // Always call the hook - hooks must be called unconditionally const webhookManagement = useWebhookManagement({ @@ -105,9 +107,22 @@ export function ShortInput({ onGeneratedContent: (content) => { // Final content update setLocalContent(content) + if (!isPreview && !disabled && !readOnly) { + persistSubBlockValueRef.current(content) + } }, }) + const [, setSubBlockValue] = useSubBlockValue(blockId, subBlockId, false, { + isStreaming: wandHook.isStreaming, + }) + + useEffect(() => { + persistSubBlockValueRef.current = (value: string) => { + setSubBlockValue(value) + } + }, [setSubBlockValue]) + // Check if wand is actually enabled const isWandEnabled = config.wandConfig?.enabled ?? false