Compare commits

..

1 Commits

Author SHA1 Message Date
CodeRabbit Fixer
140e0a128d fix: docs: document UUID injection behavior in createTemporary() and createNewTemporary() (#9448)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 14:55:08 +01:00
3 changed files with 31 additions and 70 deletions

View File

@@ -121,68 +121,6 @@ describe('resolveSubgraphInputLink', () => {
expect(result).toBe('seed_input')
})
test('skips broken links where getLink returns undefined', () => {
const { subgraph, subgraphNode } = createSubgraphSetup('prompt')
addLinkedInteriorInput(subgraph, 'prompt', 'valid_input', 'valid')
const broken = addLinkedInteriorInput(
subgraph,
'prompt',
'broken_input',
'broken'
)
const originalGetLink = subgraph.getLink.bind(subgraph)
vi.spyOn(subgraph, 'getLink').mockImplementation((linkId) => {
if (typeof linkId !== 'number') return originalGetLink(linkId)
if (linkId === broken.linkId) return undefined
return originalGetLink(linkId)
})
const result = resolveSubgraphInputLink(
subgraphNode,
'prompt',
({ targetInput }) => targetInput.name
)
expect(result).toBe('valid_input')
})
test('returns result from latest connection when multiple links resolve', () => {
const { subgraph, subgraphNode } = createSubgraphSetup('prompt')
addLinkedInteriorInput(subgraph, 'prompt', 'older_input', 'older')
addLinkedInteriorInput(subgraph, 'prompt', 'newer_input', 'newer')
const result = resolveSubgraphInputLink(
subgraphNode,
'prompt',
({ targetInput }) => targetInput.name
)
expect(result).toBe('newer_input')
})
test('falls back to earlier link when latest resolve callback returns undefined', () => {
const { subgraph, subgraphNode } = createSubgraphSetup('prompt')
addLinkedInteriorInput(subgraph, 'prompt', 'fallback_input', 'fallback')
const newer = addLinkedInteriorInput(
subgraph,
'prompt',
'skipped_input',
'skipped'
)
const result = resolveSubgraphInputLink(
subgraphNode,
'prompt',
({ targetInput }) => {
if (targetInput.link === newer.linkId) return undefined
return targetInput.name
}
)
expect(result).toBe('fallback_input')
})
test('caches getTargetWidget result within the same callback evaluation', () => {
const { subgraph, subgraphNode } = createSubgraphSetup('model')
const linked = addLinkedInteriorInput(

View File

@@ -178,7 +178,7 @@
"uploadAlreadyInProgress": "Upload already in progress",
"capture": "capture",
"nodes": "Nodes",
"nodesCount": "{count} node | {count} nodes",
"nodesCount": "{count} nodes | {count} node | {count} nodes",
"addNode": "Add a node...",
"filterBy": "Filter by:",
"filterByType": "Filter by {type}...",
@@ -222,7 +222,7 @@
"failed": "Failed",
"cancelled": "Cancelled",
"job": "Job",
"asset": "{count} asset | {count} assets",
"asset": "{count} assets | {count} asset | {count} assets",
"untitled": "Untitled",
"emDash": "—",
"enabling": "Enabling {id}",
@@ -3347,7 +3347,7 @@
}
},
"errorOverlay": {
"errorCount": "{count} ERROR | {count} ERRORS",
"errorCount": "{count} ERRORS | {count} ERROR | {count} ERRORS",
"seeErrors": "See Errors"
},
"help": {
@@ -3357,7 +3357,7 @@
"progressToast": {
"importingModels": "Importing Models",
"downloadingModel": "Downloading model...",
"downloadsFailed": "{count} download failed | {count} downloads failed",
"downloadsFailed": "{count} downloads failed | {count} download failed | {count} downloads failed",
"allDownloadsCompleted": "All downloads completed",
"noImportsInQueue": "No {filter} in queue",
"failed": "Failed",
@@ -3374,7 +3374,7 @@
"exportingAssets": "Exporting Assets",
"preparingExport": "Preparing export...",
"exportError": "Export failed",
"exportFailed": "{count} export failed | {count} exports failed",
"exportFailed": "{count} export failed | {count} export failed | {count} exports failed",
"allExportsCompleted": "All exports completed",
"noExportsInQueue": "No {filter} exports in queue",
"exportStarted": "Preparing ZIP download...",

View File

@@ -255,6 +255,13 @@ export const useWorkflowStore = defineStore('workflow', () => {
return workflow
}
/**
* Ensures the workflow data has a stable `id` field for sharing.
* If the provided (or default) workflow data does not contain an `id`,
* a new UUID is generated and injected into the returned copy.
*
* @returns A deep copy of the workflow data with a guaranteed `id` field.
*/
const ensureWorkflowId = (
workflowData?: ComfyWorkflowJSON
): ComfyWorkflowJSON => {
@@ -270,7 +277,11 @@ export const useWorkflowStore = defineStore('workflow', () => {
}
/**
* Helper to create a new temporary workflow
* Helper to create a new temporary workflow.
*
* Calls {@link ensureWorkflowId} to guarantee the workflow data contains
* a UUID `id` field. If the provided data has no `id`, one is generated
* and injected into the serialized content.
*/
const createNewWorkflow = (
path: string,
@@ -291,7 +302,13 @@ export const useWorkflowStore = defineStore('workflow', () => {
}
/**
* Create a temporary workflow, attempting to reuse an existing workflow if conditions match
* Create a temporary workflow, attempting to reuse an existing workflow
* if conditions match.
*
* Note: A UUID `id` field is injected into the workflow data via
* {@link ensureWorkflowId} if one is not already present. The serialized
* workflow content will always contain an `id` field, even if none was
* provided in the input.
*/
const createTemporary = (path?: string, workflowData?: ComfyWorkflowJSON) => {
const fullPath = getUnconflictedPath(
@@ -323,7 +340,13 @@ export const useWorkflowStore = defineStore('workflow', () => {
}
/**
* Create a new temporary workflow without attempting to reuse existing workflows
* Create a new temporary workflow without attempting to reuse existing
* workflows.
*
* Note: A UUID `id` field is injected into the workflow data via
* {@link ensureWorkflowId} if one is not already present. The serialized
* workflow content will always contain an `id` field, even if none was
* provided in the input.
*/
const createNewTemporary = (
path?: string,