Skip to content

Commit 7894c0b

Browse files
committed
fix(copilot): warn when an edit batch reuses one block handle
Two declarations sharing a handle collapse to a single block, because references naming that handle are ambiguous and the flat id mapping has no way to express a per-declaration-site id. Behavior is unchanged; the warn makes the case visible in production instead of silent.
1 parent f69d12b commit 7894c0b

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

  • apps/sim/lib/copilot/tools/server/workflow/edit-workflow

apps/sim/lib/copilot/tools/server/workflow/edit-workflow/builders.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,17 @@ export function normalizeBlockIdsInOperations(operations: EditWorkflowOperation[
718718
const idMapping = new Map<string, string>()
719719

720720
const claimId = (id: string | undefined) => {
721-
if (!id || isValidUuid(id) || idMapping.has(id)) return
721+
if (!id || isValidUuid(id)) return
722+
if (idMapping.has(id)) {
723+
/*
724+
* Two declarations share one handle. References naming it are already
725+
* ambiguous, so both resolve to whichever block is written last. Warned
726+
* rather than disambiguated because splitting them needs ids minted per
727+
* declaration site, which the flat reference mapping cannot express.
728+
*/
729+
logger.warn('Duplicate block handle in edit batch; declarations will collapse', { id })
730+
return
731+
}
722732
const newId = generateId()
723733
idMapping.set(id, newId)
724734
logger.debug('Normalizing block ID', { oldId: id, newId })

0 commit comments

Comments
 (0)