Skip to content

Commit fe7d06a

Browse files
fix(chat-deploy): keep selected outputs in place
1 parent 4d98153 commit fe7d06a

3 files changed

Lines changed: 20 additions & 29 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/components/output-select/output-select.dom.test.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,11 @@ describe('OutputSelect DOM interaction', () => {
149149
act(() => resultOption.dispatchEvent(new MouseEvent('mousedown', { bubbles: true })))
150150

151151
expect(trigger.textContent).toContain('1 output')
152-
expect(document.body.textContent).toContain('Selected')
153-
expect(document.body.textContent).toContain('invokeChild.result')
152+
expect(document.body.textContent).not.toContain('Selected')
153+
const selectedResultOption = [
154+
...document.querySelectorAll<HTMLElement>('[role="option"]'),
155+
].find((candidate) => candidate.textContent === 'result')
156+
expect(selectedResultOption?.getAttribute('aria-selected')).toBe('true')
154157
expect(document.body.textContent).not.toContain('researchAgent')
155158
})
156159

@@ -187,7 +190,10 @@ describe('OutputSelect DOM interaction', () => {
187190
act(() => outputOption.dispatchEvent(new MouseEvent('mousedown', { bubbles: true })))
188191

189192
expect(trigger.textContent).toContain('1 output')
190-
expect(document.body.textContent).toContain('Selected')
191-
expect(document.body.textContent).toContain('invokeChild / researchAgent.content')
193+
expect(document.body.textContent).not.toContain('Selected')
194+
const selectedOutputOption = [
195+
...document.querySelectorAll<HTMLElement>('[role="option"]'),
196+
].find((candidate) => candidate.textContent === 'content')
197+
expect(selectedOutputOption?.getAttribute('aria-selected')).toBe('true')
192198
})
193199
})

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/components/output-select/output-select.test.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,15 @@ describe('OutputSelect nested workflow menu', () => {
298298
expect(onOutputSelect).toHaveBeenCalledWith(['child-workflow.agent_answer'])
299299
})
300300

301-
it('keeps every selected output at the top and deselects nested outputs from there', () => {
301+
it('keeps a nested selection in its subworkflow and deselects it there', () => {
302302
const onOutputSelect = renderOutputSelect(['child-workflow.agent_answer'])
303303

304-
const sections = [...document.querySelectorAll('[data-section]')]
305-
expect(sections[0]?.textContent).toBe('Selected')
306-
expect(document.body.textContent).toContain('Research / Writer.answer')
304+
expect(document.body.textContent).not.toContain('Selected')
305+
expect(document.body.textContent).not.toContain('Writer')
307306

308-
clickOption('Research / Writer.answer')
307+
clickOption('Research')
308+
expect(document.body.textContent).toContain('Writer')
309+
clickOption('answer')
309310
expect(onOutputSelect).toHaveBeenCalledWith([])
310311
})
311312

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/components/output-select/output-select.tsx

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -293,16 +293,12 @@ function OutputSelectMenu({
293293
<span className='text-small'>{node.blockName}</span>
294294
</div>
295295
),
296-
items: node.outputs
297-
.filter((output) => !selectedValueSet.has(getOutputValue(output, valueMode)))
298-
.map((output) => outputOption(output)),
296+
items: node.outputs.map((output) => outputOption(output)),
299297
})
300298

301299
const menuNodes = activeMenuNode ? activeMenuNode.children : outputMenu
302300
const subworkflowNodes = menuNodes.filter((node) => node.children.length > 0)
303-
const availableOutputNodes = menuNodes.filter((node) =>
304-
node.outputs.some((output) => !selectedValueSet.has(getOutputValue(output, valueMode)))
305-
)
301+
const outputNodes = menuNodes.filter((node) => node.outputs.length > 0)
306302
const menuGroups: ComboboxOptionGroup[] = [
307303
...(activeMenuNode
308304
? [
@@ -328,27 +324,15 @@ function OutputSelectMenu({
328324
},
329325
]
330326
: []),
331-
...availableOutputNodes.map(outputGroup),
327+
...outputNodes.map(outputGroup),
332328
]
333-
const selectedGroup: ComboboxOptionGroup[] =
334-
selectedOutputOptions.length > 0
335-
? [
336-
{
337-
section: 'Selected',
338-
items: selectedOutputOptions.map((output) =>
339-
outputOption(output, `${output.groupLabel}.${output.path}`)
340-
),
341-
},
342-
]
343-
: []
344-
const comboboxGroups = [...selectedGroup, ...menuGroups]
345329
const Trigger = size === 'md' ? ChipCombobox : Combobox
346330

347331
return (
348332
<Trigger
349333
size={size}
350334
className={cn('min-w-[100px]', size === 'sm' && '!py-0.5 w-fit rounded-md px-2.5', className)}
351-
groups={comboboxGroups}
335+
groups={menuGroups}
352336
options={[]}
353337
multiSelect
354338
multiSelectValues={normalizedSelectedValues}

0 commit comments

Comments
 (0)