fix: use selectFirstNodeByTitles to avoid strict mode violations

The default workflow has 2 CLIP Text Encode (Prompt) nodes.
Using selectNodes(['KSampler', 'CLIP Text Encode (Prompt)']) selected
all 3 nodes (1 KSampler + 2 CLIP) instead of just 2.

Added selectFirstNodeByTitles helper that only selects the first
matching node for each title, avoiding strict mode violations.

Amp-Thread-ID: https://ampcode.com/threads/T-019c177d-06bf-779a-9c72-51a3626e4659
This commit is contained in:
bymyself
2026-01-31 20:50:20 -08:00
parent 71324f2408
commit 40961820d0
6 changed files with 50 additions and 21 deletions

View File

@@ -1384,6 +1384,18 @@ export class ComfyPage {
await this.nextFrame()
}
async selectFirstNodeByTitles(nodeTitles: string[]) {
await this.page.keyboard.down('Control')
for (const nodeTitle of nodeTitles) {
const nodes = await this.getNodeRefsByTitle(nodeTitle)
if (nodes.length > 0) {
await nodes[0].click('title')
}
}
await this.page.keyboard.up('Control')
await this.nextFrame()
}
async select2Nodes() {
// Select 2 CLIP nodes.
await this.page.keyboard.down('Control')