Browse Source

fix: derive array batch behavior dynamically from source node batchMode

Edge metadata (arrayBatchAll) was stamped at connection creation time and
went stale if the source node's batchMode was toggled later. Now
connectedInputs.ts reads batchMode directly from the source node, making
batch behavior always consistent with the current toggle state.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
handoff-20260429-1057
shrimbly 3 months ago
parent
commit
c760c6329a
  1. 3
      src/store/utils/connectedInputs.ts
  2. 7
      src/store/workflowStore.ts

3
src/store/utils/connectedInputs.ts

@ -229,7 +229,8 @@ export function getConnectedInputsPure(
if (dimmedNodeIds && dimmedNodeIds.has(sourceNode.id)) return; if (dimmedNodeIds && dimmedNodeIds.has(sourceNode.id)) return;
// Array batch mode — send all items as textItems instead of a single item // Array batch mode — send all items as textItems instead of a single item
if (sourceNode.type === "array" && (edge.data as Record<string, unknown> | undefined)?.arrayBatchAll === true) { // Derive from source node's current batchMode (not edge metadata which can go stale)
if (sourceNode.type === "array" && (sourceNode.data as ArrayNodeData).batchMode === true) {
const arrayData = sourceNode.data as ArrayNodeData; const arrayData = sourceNode.data as ArrayNodeData;
const items = arrayData.outputItems; const items = arrayData.outputItems;
if (items.length > 0) { if (items.length > 0) {

7
src/store/workflowStore.ts

@ -146,11 +146,8 @@ function buildConnectionEdgeData(
if (sourceNode?.type === "array" && (connection.sourceHandle || "text") === "text") { if (sourceNode?.type === "array" && (connection.sourceHandle || "text") === "text") {
const sourceData = sourceNode.data as Record<string, unknown>; const sourceData = sourceNode.data as Record<string, unknown>;
// Batch mode: all items sent through a single connection // Batch mode is now derived dynamically in connectedInputs.ts from
if (sourceData.batchMode === true) { // the source node's batchMode — no need to stamp edge metadata.
baseData.arrayBatchAll = true;
return baseData;
}
const selectedIndex = sourceData.selectedOutputIndex; const selectedIndex = sourceData.selectedOutputIndex;
const outputItems = Array.isArray(sourceData.outputItems) ? sourceData.outputItems : []; const outputItems = Array.isArray(sourceData.outputItems) ? sourceData.outputItems : [];

Loading…
Cancel
Save