Map Photos roles to Qwen image_1/image_2 and inject encode tags silently.

Mention phrases become <imageN> only in the TextEncode string; the inspector never shows Comfy tokens.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-26 16:01:49 -05:00
co-authored by Cursor
parent 5c2248a3fd
commit 50319e03a9
4 changed files with 49 additions and 15 deletions
+6
View File
@@ -9,6 +9,7 @@ import {compilePrompt,validateRequest} from '../shared/studio2/contracts.mjs'
import {cachedLoras} from '../shared/studio2/lora-cache.mjs'
import {resolveQwen21Size} from '../shared/studio2/qwen21-size.mjs'
import {ensureQwen21EditPrompt,stitchQwen21PeEditPrompt,QWEN21_EDIT_KEEP_CHANGE} from '../shared/studio2/qwen21-edit.mjs'
import {injectQwenEditMentionTags} from '../shared/studio2/photos.mjs'
import {qwen21PeRefusal} from '../shared/studio2/qwen21-pe.mjs'
test('deleted library files never return from job outputs; selection falls back or clears',()=>{
@@ -112,7 +113,10 @@ test('qwen21 supports Generate and Edit with 25/1 defaults and no locks',()=>{
assert.throws(()=>validateRequest({mode:'iterate',engine:'qwen21',folderId:'f',imageAId:'s',promptSections:{action:'x'}}),/Generate and Edit/)
assert.equal(ensureQwen21EditPrompt('put her in a red leather jacket'),`${QWEN21_EDIT_KEEP_CHANGE} put her in a red leather jacket`)
assert.match(ensureQwen21EditPrompt('put her in a red leather jacket'),/<image1>/)
assert.match(ensureQwen21EditPrompt('put her in that dress',{hasImage2:true}),/<image2>/)
assert.equal(ensureQwen21EditPrompt('Keep the identity, face, body, pose, and likeness of the person in <image1>.\nDo not invent a different person.\nApply only this change: x'),'Keep the identity, face, body, pose, and likeness of the person in <image1>.\nDo not invent a different person.\nApply only this change: x')
assert.match(injectQwenEditMentionTags('Put her in the outfit photo',[{stillId:'a',role:'change'},{stillId:'b',role:'outfit'}]),/<image2>/)
assert.match(injectQwenEditMentionTags('Change this photo',[{stillId:'a',role:'change'}]),/<image1>/)
const stitchedKeep=stitchQwen21PeEditPrompt('put her in a red leather jacket','Change the outfit on the person in <image1> to a red leather jacket')
assert.match(stitchedKeep.prompt,/Keep the identity/)
assert.match(stitchedKeep.prompt,/<image1>/)
@@ -192,6 +196,8 @@ test('custom negative chips survive normalizeStyles and bench exposes Load actio
const runner=readFileSync(new URL('../server/utils/studio2/runner.ts',import.meta.url),'utf8')
assert.match(runner,/ensureQwen21EditPrompt/)
assert.match(runner,/stitchQwen21PeEditPrompt/)
assert.match(runner,/injectQwenEditMentionTags/)
assert.match(runner,/applyPhotosToRequest/)
assert.match(runner,/skippedAsDescribe/)
assert.match(runner,/promptRaw/)
assert.match(runner,/images\.image_1/)