You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/code.tsx
+1-2Lines changed: 1 addition & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -163,8 +163,7 @@ export function Code({
163
163
164
164
// State management - useSubBlockValue with explicit streaming control
Copy file name to clipboardExpand all lines: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/long-input.tsx
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ import { useSubBlockValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/c
Copy file name to clipboardExpand all lines: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/short-input.tsx
Copy file name to clipboardExpand all lines: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/hooks/use-sub-block-value.ts
+19-25Lines changed: 19 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -11,8 +11,7 @@ import { useWorkflowStore } from '@/stores/workflows/workflow/store'
11
11
constlogger=createLogger('SubBlockValue')
12
12
13
13
interfaceUseSubBlockValueOptions{
14
-
debounceMs?: number
15
-
isStreaming?: boolean// Explicit streaming state
14
+
isStreaming?: boolean
16
15
onStreamingEnd?: ()=>void
17
16
}
18
17
@@ -130,8 +129,21 @@ export function useSubBlockValue<T = any>(
130
129
if(!isEqual(valueRef.current,newValue)){
131
130
valueRef.current=newValue
132
131
133
-
// Update local store immediately for UI responsiveness
134
-
// The collaborative function will also update it, but that's okay for idempotency
132
+
// Ensure we're passing the actual value, not a reference that might change
133
+
constvalueCopy=
134
+
newValue===null
135
+
? null
136
+
: typeofnewValue==='object'
137
+
? JSON.parse(JSON.stringify(newValue))
138
+
: newValue
139
+
140
+
// If streaming, hold value locally and do not update global store to avoid render-phase updates
141
+
if(isStreaming){
142
+
streamingValueRef.current=valueCopy
143
+
return
144
+
}
145
+
146
+
// Update local store immediately for UI responsiveness (non-streaming)
135
147
useSubBlockStore.setState((state)=>({
136
148
workflowValues: {
137
149
...state.workflowValues,
@@ -145,44 +157,26 @@ export function useSubBlockValue<T = any>(
145
157
},
146
158
}))
147
159
148
-
// Handle model changes for provider-based blocks - clear API key when provider changes
160
+
// Handle model changes for provider-based blocks - clear API key when provider changes (non-streaming)
0 commit comments