mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 23:17:59 -05:00
fix(wand): subblocks should not be overwritten after wand gen (#1946)
This commit is contained in:
committed by
GitHub
parent
61404d48a3
commit
6315cc105b
@@ -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<string>('')
|
||||
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<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
|
||||
|
||||
|
||||
@@ -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<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({
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user