Skip to content

Commit 0e22b66

Browse files
committed
fix(chat): never re-enable a chat archived while its relaunch was deploying
1 parent b67e578 commit 0e22b66

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎apps/sim/lib/workflows/orchestration/chat-deploy.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export async function performChatDeploy(
271271
passwordToStore = null
272272
}
273273

274-
await db
274+
const [updated] = await db
275275
.update(chat)
276276
.set({
277277
identifier,
@@ -288,7 +288,12 @@ export async function performChatDeploy(
288288
isActive: true,
289289
updatedAt: new Date(),
290290
})
291-
.where(eq(chat.id, chatId))
291+
// An archive landing during the deploy above must not be undone by this write.
292+
.where(and(eq(chat.id, chatId), isNull(chat.archivedAt)))
293+
.returning({ id: chat.id })
294+
if (!updated) {
295+
return { success: false, error: 'Chat deployment not found', errorCode: 'not_found' }
296+
}
292297
} else {
293298
chatId = generateId()
294299
await db.insert(chat).values({

0 commit comments

Comments
 (0)