Skip to content

Commit 527ed7f

Browse files
icecrasher321Vikhyath Mondreti
authored andcommitted
fix(frozen canvas): don't error if workflow state not available for migrated logs (#624)
* fix(frozen canvas): don't error if workflow state not available for old logs * fix lint --------- Co-authored-by: Vikhyath Mondreti <vikhyathmondreti@vikhyaths-air.lan>
1 parent f3bc1fc commit 527ed7f

File tree

2 files changed

+40
-21
lines changed

2 files changed

+40
-21
lines changed

apps/sim/app/workspace/[workspaceId]/logs/logs.tsx

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,18 @@ export default function Logs() {
305305
<div className='flex flex-1 flex-col overflow-hidden'>
306306
{/* Table container */}
307307
<div className='flex flex-1 flex-col overflow-hidden'>
308-
{/* Simple header */}
309-
<div className='border-border/50 border-b px-4 py-3'>
310-
<div className='flex items-center gap-4 font-medium text-muted-foreground text-xs'>
311-
<div className='w-32'>Time</div>
312-
<div className='w-20'>Status</div>
313-
<div className='flex-1'>Workflow</div>
314-
<div className='hidden w-24 lg:block'>Trigger</div>
315-
<div className='hidden w-20 xl:block'>Cost</div>
316-
<div className='w-20'>Duration</div>
308+
{/* Table with fixed layout */}
309+
<div className='w-full min-w-[800px]'>
310+
{/* Header */}
311+
<div className='border-border/50 border-b'>
312+
<div className='grid grid-cols-[160px_100px_1fr_120px_100px_100px] gap-4 px-4 py-3 font-medium text-muted-foreground text-xs'>
313+
<div>Time</div>
314+
<div>Status</div>
315+
<div>Workflow</div>
316+
<div className='hidden lg:block'>Trigger</div>
317+
<div className='hidden xl:block'>Cost</div>
318+
<div>Duration</div>
319+
</div>
317320
</div>
318321
</div>
319322

@@ -357,17 +360,17 @@ export default function Logs() {
357360
}`}
358361
onClick={() => handleLogClick(log)}
359362
>
360-
<div className='flex items-center gap-4 p-4'>
363+
<div className='grid grid-cols-[160px_100px_1fr_120px_100px_100px] gap-4 p-4'>
361364
{/* Time */}
362-
<div className='w-32 flex-shrink-0'>
365+
<div>
363366
<div className='font-medium text-sm'>{formattedDate.formatted}</div>
364367
<div className='text-muted-foreground text-xs'>
365368
{formattedDate.relative}
366369
</div>
367370
</div>
368371

369372
{/* Status */}
370-
<div className='w-20 flex-shrink-0'>
373+
<div>
371374
<div
372375
className={`inline-flex items-center justify-center rounded-md px-2 py-1 text-xs ${
373376
log.level === 'error'
@@ -382,7 +385,7 @@ export default function Logs() {
382385
</div>
383386

384387
{/* Workflow */}
385-
<div className='min-w-0 flex-1'>
388+
<div className='min-w-0'>
386389
<div className='truncate font-medium text-sm'>
387390
{log.workflow?.name || 'Unknown Workflow'}
388391
</div>
@@ -392,14 +395,14 @@ export default function Logs() {
392395
</div>
393396

394397
{/* Trigger */}
395-
<div className='hidden w-24 flex-shrink-0 lg:block'>
398+
<div className='hidden lg:block'>
396399
<div className='text-muted-foreground text-xs'>
397400
{log.trigger || '—'}
398401
</div>
399402
</div>
400403

401404
{/* Cost */}
402-
<div className='hidden w-20 flex-shrink-0 xl:block'>
405+
<div className='hidden xl:block'>
403406
<div className='text-xs'>
404407
{log.metadata?.enhanced && log.metadata?.cost?.total ? (
405408
<span className='text-muted-foreground'>
@@ -412,7 +415,7 @@ export default function Logs() {
412415
</div>
413416

414417
{/* Duration */}
415-
<div className='w-20 flex-shrink-0'>
418+
<div>
416419
<div className='text-muted-foreground text-xs'>
417420
{log.duration || '—'}
418421
</div>

apps/sim/app/workspace/[workspaceId]/w/components/workflow-preview/workflow-preview.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ export function WorkflowPreview({
5858
defaultZoom,
5959
onNodeClick,
6060
}: WorkflowPreviewProps) {
61+
// Handle migrated logs that don't have complete workflow state
62+
if (!workflowState || !workflowState.blocks || !workflowState.edges) {
63+
return (
64+
<div
65+
style={{ height, width }}
66+
className='flex items-center justify-center rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-900'
67+
>
68+
<div className='text-center text-gray-500 dark:text-gray-400'>
69+
<div className='mb-2 font-medium text-lg'>⚠️ Logged State Not Found</div>
70+
<div className='text-sm'>
71+
This log was migrated from the old system and doesn't contain workflow state data.
72+
</div>
73+
</div>
74+
</div>
75+
)
76+
}
6177
const blocksStructure = useMemo(
6278
() => ({
6379
count: Object.keys(workflowState.blocks || {}).length,
@@ -84,8 +100,8 @@ export function WorkflowPreview({
84100

85101
const edgesStructure = useMemo(
86102
() => ({
87-
count: workflowState.edges.length,
88-
ids: workflowState.edges.map((e) => e.id).join(','),
103+
count: workflowState.edges?.length || 0,
104+
ids: workflowState.edges?.map((e) => e.id).join(',') || '',
89105
}),
90106
[workflowState.edges]
91107
)
@@ -115,7 +131,7 @@ export function WorkflowPreview({
115131
const nodes: Node[] = useMemo(() => {
116132
const nodeArray: Node[] = []
117133

118-
Object.entries(workflowState.blocks).forEach(([blockId, block]) => {
134+
Object.entries(workflowState.blocks || {}).forEach(([blockId, block]) => {
119135
if (!block || !block.type) {
120136
logger.warn(`Skipping invalid block: ${blockId}`)
121137
return
@@ -186,7 +202,7 @@ export function WorkflowPreview({
186202
})
187203

188204
if (block.type === 'loop') {
189-
const childBlocks = Object.entries(workflowState.blocks).filter(
205+
const childBlocks = Object.entries(workflowState.blocks || {}).filter(
190206
([_, childBlock]) => childBlock.data?.parentId === blockId
191207
)
192208

@@ -223,7 +239,7 @@ export function WorkflowPreview({
223239
}, [blocksStructure, loopsStructure, parallelsStructure, showSubBlocks, workflowState.blocks])
224240

225241
const edges: Edge[] = useMemo(() => {
226-
return workflowState.edges.map((edge) => ({
242+
return (workflowState.edges || []).map((edge) => ({
227243
id: edge.id,
228244
source: edge.source,
229245
target: edge.target,

0 commit comments

Comments
 (0)