Skip to content

Commit b597aea

Browse files
committed
fix(workflow-code): review round 5: check a kept chat's outputs against every draft a deploy publishes
1 parent a23291a commit b597aea

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

‎apps/sim/lib/workspace-source/application/deployments.integration.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,36 @@ describe('workspace source: deployments', () => {
660660
}
661661
)
662662

663+
check(
664+
'refuses to deploy a draft an earlier apply left with no block of the name a kept chat declares',
665+
async () => {
666+
const deployed = await deployedWorkspace(answerChat('dropped-earlier-chat'))
667+
const { workspaceId, id, base } = deployed
668+
const files: Files = deployed.files
669+
const before = await deployState(id)
670+
671+
// The workflow alone first: the Answer block is renamed away, so no block has the name.
672+
const workflowOnly = await apply(
673+
workspaceId,
674+
{ ...files, [WORKFLOW]: files[WORKFLOW].replace("agent('Answer'", "agent('Responder'") },
675+
{ base, kinds: ['workflow'], only: ['workflow'] }
676+
)
677+
expect(workflowOnly.failed).toBeUndefined()
678+
679+
const refused = await refusal(
680+
apply(
681+
workspaceId,
682+
{ ...files, ...workflowOnly.files, [DEPLOYMENT]: files[DEPLOYMENT] },
683+
{ base: workflowOnly.base }
684+
)
685+
)
686+
expect(deploymentCodes(refused.diagnostics, 'error')).toEqual(['E_DEPLOY_CHAT_OUTPUT'])
687+
const after = await deployState(id)
688+
expect(after.versions).toBe(before.versions)
689+
expect(after.chat?.outputConfigs).toEqual(before.chat?.outputConfigs)
690+
}
691+
)
692+
663693
check(
664694
'renames a chat output block and the chat naming it in one apply, keeping the block id',
665695
async () => {

‎apps/sim/lib/workspace-source/application/kinds/deployment/adapter.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,9 @@ async function planDeployment(
639639
}),
640640
}
641641
}
642-
// A chat the apply keeps goes live with the edited draft all the same.
643-
const publishesEditedDraft = detail.deploy && draftEdited
644-
if (decl.chat && (writesChat || publishesEditedDraft)) {
642+
// A chat the apply keeps goes live with the published draft all the same, edited by this apply
643+
// or an earlier one: its outputs must name blocks that draft has.
644+
if (decl.chat && (writesChat || detail.deploy)) {
645645
await checkChat(next, decl.chat, ctx, {
646646
workflowId,
647647
writesChat,

0 commit comments

Comments
 (0)