Skip to content

Commit 99a645c

Browse files
committed
fix(ui/connections): fixed tag dropdown and connection block not accurately reflecting source block response format by changing reference from workflow/subblock response format to dedicated subblock store
1 parent 48a8952 commit 99a645c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

app/w/hooks/use-block-connections.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { shallow } from 'zustand/shallow'
22
import { useWorkflowStore } from '@/stores/workflow/store'
3+
import { useSubBlockStore } from '@/stores/workflow/subblock/store'
34

45
interface Field {
56
name: string
@@ -30,7 +31,12 @@ export function useBlockConnections(blockId: string) {
3031
.filter((edge) => edge.target === blockId)
3132
.map((edge) => {
3233
const sourceBlock = blocks[edge.source]
33-
const responseFormatValue = sourceBlock.subBlocks?.responseFormat?.value
34+
35+
// Get the response format from the subblock store instead
36+
const responseFormatValue = useSubBlockStore
37+
.getState()
38+
.getValue(edge.source, 'responseFormat')
39+
3440
let responseFormat
3541

3642
try {

components/ui/tag-dropdown.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useEffect, useMemo, useState } from 'react'
22
import { cn } from '@/lib/utils'
33
import { useWorkflowStore } from '@/stores/workflow/store'
4+
import { useSubBlockStore } from '@/stores/workflow/subblock/store'
45

56
interface Field {
67
name: string
@@ -95,7 +96,9 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
9596

9697
// Then check for response format
9798
try {
98-
const responseFormatValue = sourceBlock.subBlocks?.responseFormat?.value
99+
const responseFormatValue = useSubBlockStore
100+
.getState()
101+
.getValue(activeSourceBlockId, 'responseFormat')
99102
if (typeof responseFormatValue === 'string' && responseFormatValue) {
100103
const responseFormat = JSON.parse(responseFormatValue)
101104
if (responseFormat?.fields) {
@@ -128,7 +131,9 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
128131

129132
// Check for response format first
130133
try {
131-
const responseFormatValue = sourceBlock.subBlocks?.responseFormat?.value
134+
const responseFormatValue = useSubBlockStore
135+
.getState()
136+
.getValue(edge.source, 'responseFormat')
132137
if (typeof responseFormatValue === 'string' && responseFormatValue) {
133138
const responseFormat = JSON.parse(responseFormatValue)
134139
if (responseFormat?.fields) {

0 commit comments

Comments
 (0)