Skip to content

Commit 11bb86d

Browse files
committed
fix more comments
1 parent 8ed3e1b commit 11bb86d

3 files changed

Lines changed: 61 additions & 10 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/deploy-modal.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,21 @@ export function DeployModal({
194194
}
195195
}
196196

197+
/**
198+
* Post-activation warnings (dead-lettered or still-queued side effects)
199+
* arrive with an `active` attempt, so the Live badge gives no signal —
200+
* surface them as a toast. Pending/failed attempts are excluded: the
201+
* status badge already covers those.
202+
*/
203+
const toastPostActivationWarnings = (
204+
title: string,
205+
result: { latestDeploymentAttempt?: { status: string } | null; warnings?: string[] }
206+
) => {
207+
if (result.latestDeploymentAttempt?.status !== 'active') return
208+
if (!result.warnings?.length) return
209+
toast.warning(title, { description: result.warnings.join(' ') })
210+
}
211+
197212
useEffect(() => {
198213
deployActionIdRef.current += 1
199214
setIsFinalizingDeploy(false)
@@ -310,6 +325,9 @@ export function DeployModal({
310325
if (result.latestDeploymentAttempt?.status === 'active') {
311326
await syncDraftAfterDeploy()
312327
}
328+
if (isWorkflowStillActive(workflowId)) {
329+
toastPostActivationWarnings('Workflow deployed', result)
330+
}
313331
} finally {
314332
if (deployActionIdRef.current === actionId) {
315333
setIsFinalizingDeploy(false)
@@ -338,7 +356,10 @@ export function DeployModal({
338356
setDeployError(null)
339357

340358
try {
341-
await activateVersionMutation.mutateAsync({ workflowId, version })
359+
const result = await activateVersionMutation.mutateAsync({ workflowId, version })
360+
if (isWorkflowStillActive(workflowId)) {
361+
toastPostActivationWarnings(`Promoted v${version} to live`, result)
362+
}
342363
} catch (error) {
343364
if (!isWorkflowStillActive(workflowId)) return
344365
logger.error('Error promoting version:', { error })
@@ -413,6 +434,9 @@ export function DeployModal({
413434
if (result.latestDeploymentAttempt?.status === 'active') {
414435
await syncDraftAfterDeploy()
415436
}
437+
if (isWorkflowStillActive(workflowId)) {
438+
toastPostActivationWarnings('Workflow redeployed', result)
439+
}
416440
} finally {
417441
if (deployActionIdRef.current === actionId) {
418442
setIsFinalizingDeploy(false)

apps/sim/ee/workspace-forking/lib/promote/rollback.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,23 @@ describe('rollbackFork', () => {
310310
expect(mockDeleteAllRuns).not.toHaveBeenCalled()
311311
})
312312

313+
it('keeps the undo point when no operation row exists to verify cutover', async () => {
314+
const run = makeRun({
315+
snapshot: { updated: [{ workflowId: 'wf-a', priorVersion: 3 }], created: [], archived: [] },
316+
})
317+
mockGetLatestRun.mockResolvedValue(run)
318+
mockGetDeploymentStatus.mockResolvedValue({ activeDeployment: null, latestOperation: null })
319+
320+
const result = await rollbackFork({
321+
targetWorkspaceId: 'target-ws',
322+
otherWorkspaceId: 'other-ws',
323+
userId: 'user-1',
324+
})
325+
326+
expect(result.pendingActivations).toEqual(['wf-a'])
327+
expect(mockDeleteAllRuns).not.toHaveBeenCalled()
328+
})
329+
313330
it('treats a superseding operation as settled and consumes the undo point', async () => {
314331
const run = makeRun({
315332
snapshot: { updated: [{ workflowId: 'wf-a', priorVersion: 3 }], created: [], archived: [] },

apps/sim/ee/workspace-forking/lib/promote/rollback.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,25 @@ export async function rollbackFork(params: RollbackForkParams): Promise<Rollback
276276
try {
277277
const status = await getWorkflowDeploymentStatus(reactivation.workflowId)
278278
const operation = status.latestOperation
279-
const activated =
280-
operation?.id === reactivation.operationId
281-
? operation.status === 'active'
282-
: /**
283-
* A different latest operation means something newer superseded
284-
* our attempt (e.g. a manual promote); treat it as settled — the
285-
* newer intent owns the workflow now.
286-
*/
287-
true
279+
let activated: boolean
280+
if (!operation) {
281+
/**
282+
* No operation row at all — cutover cannot be verified (only a
283+
* concurrent hard-delete of the workflow can cascade ours away), so
284+
* keep the undo point. A re-run skips hard-deleted workflows and
285+
* then consumes it.
286+
*/
287+
activated = false
288+
} else if (operation.id === reactivation.operationId) {
289+
activated = operation.status === 'active'
290+
} else {
291+
/**
292+
* A different latest operation means something newer superseded our
293+
* attempt (e.g. a manual promote); treat it as settled — the newer
294+
* intent owns the workflow now.
295+
*/
296+
activated = true
297+
}
288298
if (!activated) pendingActivations.push(reactivation.workflowId)
289299
} catch (error) {
290300
logger.warn(`[${requestId}] Could not verify rollback activation status`, {

0 commit comments

Comments
 (0)