Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(workflows): clear folderId on restore when folder is archived or …
…missing

When individually restoring a workflow from Recently Deleted, check if
its folder still exists and is active. If the folder is archived or
missing, clear folderId so the workflow appears at root instead of
being orphaned (invisible in sidebar).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
  • Loading branch information
waleedlatif1 and claude committed Apr 7, 2026
commit cbabc16d0906d82caa74776cf6da5de94630ab4e
19 changes: 18 additions & 1 deletion apps/sim/lib/workflows/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
webhook,
workflow,
workflowDeploymentVersion,
workflowFolder,
workflowMcpTool,
workflowSchedule,
} from '@sim/db/schema'
Expand Down Expand Up @@ -258,12 +259,28 @@ export async function restoreWorkflow(
}
}

let clearFolderId = false
if (existingWorkflow.folderId) {
const [folder] = await db
.select({ archivedAt: workflowFolder.archivedAt })
.from(workflowFolder)
.where(eq(workflowFolder.id, existingWorkflow.folderId))

if (!folder || folder.archivedAt) {
clearFolderId = true
}
}

const now = new Date()

await db.transaction(async (tx) => {
await tx
.update(workflow)
.set({ archivedAt: null, updatedAt: now })
.set({
archivedAt: null,
updatedAt: now,
...(clearFolderId && { folderId: null }),
})
.where(eq(workflow.id, workflowId))

await tx
Expand Down
Loading