Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -94,6 +95,7 @@ export function LongInput({
}: LongInputProps) {
// Local state for immediate UI updates during streaming
const [localContent, setLocalContent] = useState<string>('')
const persistSubBlockValueRef = useRef<(value: string) => void>(() => {})

// Wand functionality - always call the hook unconditionally
const wandHook = useWand({
Expand All @@ -110,9 +112,22 @@ export function LongInput({
onGeneratedContent: (content) => {
// Final content update (fallback)
setLocalContent(content)
if (!isPreview && !disabled) {
persistSubBlockValueRef.current(content)
}
},
})

const [, setSubBlockValue] = useSubBlockValue<string>(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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -82,6 +83,7 @@ export function ShortInput({
const [localContent, setLocalContent] = useState<string>('')
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({
Expand All @@ -105,9 +107,22 @@ export function ShortInput({
onGeneratedContent: (content) => {
// Final content update
setLocalContent(content)
if (!isPreview && !disabled && !readOnly) {
persistSubBlockValueRef.current(content)
}
},
})

const [, setSubBlockValue] = useSubBlockValue<string>(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

Expand Down