feat: support mask editor in comfyui cloud

- use response from /api/upload/mask to find mask layers
- query for /api/files/mask-layers when making additional edits
This commit is contained in:
Richard Yu
2025-10-10 16:17:31 -07:00
parent 5869b04e57
commit 963741f554
3 changed files with 271 additions and 40 deletions

View File

@@ -85,6 +85,34 @@ export const graphToPrompt = async (
const inputs: ComfyApiWorkflow[string]['inputs'] = {}
const { widgets } = node
// Sync widget values from widgets_values array ONLY for old clipspace filenames
// This ensures we use the latest hash-based filenames from clipspace
// without breaking normal image selection
const graphNode = (node as any).node || node // Access underlying LGraph node from DTO wrapper
if (widgets && graphNode.widgets_values) {
for (const [i, widget] of widgets.entries()) {
// Only apply to image widgets to avoid affecting other widget types
if (
widget.name === 'image' &&
graphNode.widgets_values[i] !== undefined
) {
const currentValue = String(widget.value)
const newValue = String(graphNode.widgets_values[i])
// Only sync if current value is an old clipspace friendly filename
const isOldClipspaceFilename =
/clipspace\/clipspace-(painted-masked|painted|mask|paint)-\d+\.png(\s+\[input\])?/.test(
currentValue
)
if (isOldClipspaceFilename && currentValue !== newValue) {
widget.value = graphNode.widgets_values[i]
}
}
}
}
// Store all widget values
if (widgets) {
for (const [i, widget] of widgets.entries()) {