Skip to content

Commit e34a28c

Browse files
committed
fixed flicker on importing multiple workflows
1 parent f0f9c91 commit e34a28c

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workflow-list/components/context-menu/context-menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ export function ContextMenu({
373373
onKeyDown={handleHexKeyDown}
374374
onFocus={handleHexFocus}
375375
onClick={(e) => e.stopPropagation()}
376-
className='h-[20px] min-w-0 flex-1 rounded-[4px] bg-[#363636] px-[6px] text-[11px] text-white uppercase focus:outline-none'
376+
className='h-[20px] min-w-0 flex-1 rounded-[4px] bg-[#363636] px-[6px] text-[11px] text-white uppercase caret-white focus:outline-none'
377377
/>
378378
<button
379379
type='button'

apps/sim/app/workspace/[workspaceId]/w/hooks/use-import-workflow.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,11 @@ export function useImportWorkflow({ workspaceId }: UseImportWorkflowProps) {
206206

207207
logger.info(`Import complete. Imported ${importedWorkflowIds.length} workflow(s)`)
208208

209-
// Navigate to first imported workflow if any
209+
// Navigate to last imported workflow if any
210210
if (importedWorkflowIds.length > 0) {
211-
router.push(`/workspace/${workspaceId}/w/${importedWorkflowIds[0]}`)
211+
router.push(
212+
`/workspace/${workspaceId}/w/${importedWorkflowIds[importedWorkflowIds.length - 1]}`
213+
)
212214
}
213215
} catch (error) {
214216
logger.error('Failed to import workflows:', error)

apps/sim/stores/workflows/registry/store.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,18 @@ export const useWorkflowRegistry = create<WorkflowRegistry>()(
9797
return acc
9898
}, {})
9999

100-
set((state) => ({
101-
workflows: mapped,
102-
error: null,
103-
hydration:
104-
state.hydration.phase === 'state-loading'
100+
set((state) => {
101+
// Preserve hydration if workflow is loading or already ready and still exists
102+
const shouldPreserveHydration =
103+
state.hydration.phase === 'state-loading' ||
104+
(state.hydration.phase === 'ready' &&
105+
state.hydration.workflowId &&
106+
mapped[state.hydration.workflowId])
107+
108+
return {
109+
workflows: mapped,
110+
error: null,
111+
hydration: shouldPreserveHydration
105112
? state.hydration
106113
: {
107114
phase: 'metadata-ready',
@@ -110,7 +117,8 @@ export const useWorkflowRegistry = create<WorkflowRegistry>()(
110117
requestId: null,
111118
error: null,
112119
},
113-
}))
120+
}
121+
})
114122
},
115123

116124
failMetadataLoad: (workspaceId: string | null, errorMessage: string) => {

0 commit comments

Comments
 (0)