Skip to content

Commit 6967ac0

Browse files
Vikhyath MondretiVikhyath Mondreti
authored andcommitted
improve UI
1 parent 027614f commit 6967ac0

File tree

3 files changed

+525
-104
lines changed

3 files changed

+525
-104
lines changed

apps/sim/app/workspace/[workspaceId]/logs/components/trace-spans/trace-spans-display.tsx

Lines changed: 66 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,70 @@ function transformBlockData(data: any, blockType: string, isInput: boolean) {
9595
return data
9696
}
9797

98+
// Collapsible Input/Output component
99+
interface CollapsibleInputOutputProps {
100+
span: TraceSpan
101+
spanId: string
102+
}
103+
104+
function CollapsibleInputOutput({ span, spanId }: CollapsibleInputOutputProps) {
105+
const [inputExpanded, setInputExpanded] = useState(false)
106+
const [outputExpanded, setOutputExpanded] = useState(false)
107+
108+
return (
109+
<div className='mt-2 mr-4 mb-4 ml-8 space-y-3 overflow-hidden'>
110+
{/* Input Data - Collapsible */}
111+
{span.input && (
112+
<div>
113+
<button
114+
onClick={() => setInputExpanded(!inputExpanded)}
115+
className='flex items-center gap-2 mb-2 font-medium text-muted-foreground text-xs hover:text-foreground transition-colors'
116+
>
117+
{inputExpanded ? (
118+
<ChevronDown className='h-3 w-3' />
119+
) : (
120+
<ChevronRight className='h-3 w-3' />
121+
)}
122+
Input
123+
</button>
124+
{inputExpanded && (
125+
<div className='mb-2 overflow-hidden rounded-md bg-secondary/30 p-3'>
126+
<BlockDataDisplay data={span.input} blockType={span.type} isInput={true} />
127+
</div>
128+
)}
129+
</div>
130+
)}
131+
132+
{/* Output Data - Collapsible */}
133+
{span.output && (
134+
<div>
135+
<button
136+
onClick={() => setOutputExpanded(!outputExpanded)}
137+
className='flex items-center gap-2 mb-2 font-medium text-muted-foreground text-xs hover:text-foreground transition-colors'
138+
>
139+
{outputExpanded ? (
140+
<ChevronDown className='h-3 w-3' />
141+
) : (
142+
<ChevronRight className='h-3 w-3' />
143+
)}
144+
{span.status === 'error' ? 'Error Details' : 'Output'}
145+
</button>
146+
{outputExpanded && (
147+
<div className='mb-2 overflow-hidden rounded-md bg-secondary/30 p-3'>
148+
<BlockDataDisplay
149+
data={span.output}
150+
blockType={span.type}
151+
isInput={false}
152+
isError={span.status === 'error'}
153+
/>
154+
</div>
155+
)}
156+
</div>
157+
)}
158+
</div>
159+
)
160+
}
161+
98162
// Component to display block input/output data in a clean, readable format
99163
function BlockDataDisplay({
100164
data,
@@ -544,37 +608,8 @@ function TraceSpanItem({
544608
{/* Expanded content */}
545609
{expanded && (
546610
<div>
547-
{/* Block Input/Output Data */}
548-
{(span.input || span.output) && (
549-
<div className='mt-2 mr-4 mb-4 ml-8 space-y-3 overflow-hidden'>
550-
{/* Input Data */}
551-
{span.input && (
552-
<div>
553-
<h4 className='mb-2 font-medium text-muted-foreground text-xs'>Input</h4>
554-
<div className='mb-2 overflow-hidden rounded-md bg-secondary/30 p-3'>
555-
<BlockDataDisplay data={span.input} blockType={span.type} isInput={true} />
556-
</div>
557-
</div>
558-
)}
559-
560-
{/* Output Data */}
561-
{span.output && (
562-
<div>
563-
<h4 className='mb-2 font-medium text-muted-foreground text-xs'>
564-
{span.status === 'error' ? 'Error Details' : 'Output'}
565-
</h4>
566-
<div className='mb-2 overflow-hidden rounded-md bg-secondary/30 p-3'>
567-
<BlockDataDisplay
568-
data={span.output}
569-
blockType={span.type}
570-
isInput={false}
571-
isError={span.status === 'error'}
572-
/>
573-
</div>
574-
</div>
575-
)}
576-
</div>
577-
)}
611+
{/* Block Input/Output Data - Collapsible */}
612+
{(span.input || span.output) && <CollapsibleInputOutput span={span} spanId={spanId} />}
578613

579614
{/* Children and tool calls */}
580615
{/* Render child spans */}

0 commit comments

Comments
 (0)