Compare commits

...
1 Commits
Author SHA1 Message Date
EnragedAntelope 24321e7f6d 2.5.0: picker search - word-start matching, franchise box, keep place, queue each (#27)
- Search matches from a word's start (names anywhere), quoted phrases, accent-insensitive
- One-way SEARCH_ALSO synonyms and compounds (pants/trousers, suit/bodysuit, sword/katana)
- Roster index also covers eyes, alternate costumes, subject, skin, costume_back, prop_costume, anatomy
- Franchise filter is a type-to-filter box with suggestions; partial names match broadly
- Trait and franchise filters only on the Cosplayer picker; no gender filter on Creature
- Reopening scrolls to and outlines the node's current pick
- Queue each (N) button queues one run per filtered entry and restores the pick
- Backlog: Random from these and plural search under consideration; saved searches and hair/era filters declined
- Docs: usage Searching the picker, history 2.5.0, README, AGENTS.md
2026-11-12 14:25:35 -05:00
11 changed files with 441 additions and 65 deletions
+3 -2
View File
@@ -8,12 +8,13 @@ investigation notes, 1.5.0+ — the reasoning for every item in the release list
## Current state
_Last verified: 2026-11-01_
_Last verified: 2026-11-12_
- **Status:** in active development; main is v2.4.0 (`pyproject.toml`); 2.0.0 was the seed epoch (every seed resolves differently from 1.x, by design). Published to the Comfy Registry via `.github/workflows/publish_action.yml`, which fires on a `pyproject.toml` version change on `main` - bump the version on every functional commit or the release never ships. CI (`.github/workflows/ci.yml`) is deliberately dependency-free, has a Windows leg, and `publish-node` needs it (1.8.0).
- **Status:** in active development; main is v2.5.0 (`pyproject.toml`); 2.0.0 was the seed epoch (every seed resolves differently from 1.x, by design). Published to the Comfy Registry via `.github/workflows/publish_action.yml`, which fires on a `pyproject.toml` version change on `main` - bump the version on every functional commit or the release never ships. CI (`.github/workflows/ci.yml`) is deliberately dependency-free, has a Windows leg, and `publish-node` needs it (1.8.0).
- **Works:** the constraint engine resolving dropdowns into coherent prose plus structured JSON, seed-reproducible; the four preset layer nodes (Archetype, Creature, Modifier, Cosplayer); searchable dropdown widgets, live preview, the `franchise_filter`, the `random_pool` scope-composing filter, and the save/load vault in `js/` (an atomic overwrite, a disk-change-aware cache fingerprint, and Windows-reserved-name handling as of 1.5.5); a searchable **in-node roster picker** (`js/identity_forge_picker.js`) on the Cosplayer/Archetype/Creature nodes — trait facets, gender and franchise filters, cross-tab search, opt-in gallery thumbnails, backed by a generated `js/identity_forge_roster.json` search index; Stylebook interop, the composition axis, and the **Turnaround** reference-set node (which emits every camera view of one resolved character as a list, so one queue renders the set) and its face-side sibling the **Expression Sheet** (1.10.0: one view per curated expression/mood/smile triple); a free-text `held_item` on the Modifier node; a jsdom frontend suite alongside the Python one; generated reference docs and JS data, and a committed field-marginals baseline (`scripts/sweep_marginals.py`, 1.5.5 — catches a value drawing far more or less often than intended), plus a reachability gate (`--unreachable`, 1.8.0: every pool value some gender can draw, or a reasoned exception in `tests/fixtures/unreachable_by_design.json`), all with `--check` modes wired into the gate. A cosplay entry may render as a **person in a costume**, as a **mascot suit** (`covers_face` + `covers_body` + `mask`), or — since 0.95.0 — as the **beast itself** (`body_plan: "feral"`, which emits the Creature node's Species & Anatomy payload instead of a costume); see architecture.md → "Animal characters split four ways". `scripts/render_gallery.py` renders a roster entry's gallery image by driving a running ComfyUI over HTTP and publishes it to `gh-pages`, and `gallery/render_manifest.json` + `--check` fail CI when an entry's text changes without a re-render (architecture.md → "The gallery render pipeline"). Since 0.97.0 every roster entry also carries a **release stamp** (`data/versions.py`, written by `scripts/stamp_versions.py`, gated in CI), which is what lets the three sample gallery pages offer **A–Z / Newest first** and a **New in `<version>`** filter. Since 2.0.0: a **`gaze`** field drawn last with `pose` (both with live constraint rules; architecture.md -> "pose and gaze draw last"), opt-in **`costume_back`** for Turnaround back views, **per-garment `{slot}` variation** in the outfit corpus on its own seed stream, and a gallery hash over **resolved prose** so an engine change marks images stale. Since 2.3.0: the **Outfit Sheet** and **Age Progression** sheet nodes (they release the fields a pin refuses via `lock_clash` rather than override them; architecture.md -> "Sheets that change the person"), and picker previews served through a **server-side gallery cache** (`nodes/gallery_cache.py`) so they work under ComfyUI `--offline`.
- **In progress:** roster and coherence curation is the ongoing work, not a milestone - each release adds characters/creatures/archetypes and closes coherence bugs found by rendering them. `docs/suggested-additions.md` is the live backlog (under consideration / decided against / still to consider). Next: more `costume_back` entries (2.3.0 covered the first caped and back-emblem heroes; continue with the rest of the capes) and more slotted corpus phrases; both are seed-safe additions now (a slot draws from its own stream; a back text touches only back views).
- **Recent releases** — one line each. **This list is a pointer, not a changelog:** the reasoning for every item is in `docs/history.md` (the sections are named there per release) and the full messages are in `git log`. Keep roughly the last eight and let older ones drop off; do not let an entry grow into a paragraph.
- **2.5.0** - Picker search: word-start, accent-insensitive matching with quoted phrases and a one-way `SEARCH_ALSO` synonym/compound list, every description field indexed (eyes, alternate costumes, back view, anatomy), a type-to-filter franchise box, cosplayer-only filters hidden on Archetype/Creature, reopening on the current pick, and a Queue each button for a filtered set. Frontend and roster index only; random characters unchanged. See docs/history.md -> "2.5.0".
- **2.4.0** - Figure Skater on the ice with standing poses (Hockey Goalie, Roller Derby, Carhop, Scuba Diver and Samurai pose locks too), several archetypes moved to a location that fits them, four new venues (wrestling ring, tennis court, pit lane, racecourse paddock), no leaning or perching in open landscapes, no blank-backdrop composition indoors, Indie Sleaze men's costumes split from the women's, a man keeps a locked eyeliner, 1980s New Wave women draw 80s makeup, a prop in each hand drops one-handed poses, and Yoda, Ahsoka, Piccolo, Bane and the Star Wars guards no longer draw a random human under the costume. Anthropomorphic creatures render as one clothed hybrid (Monsters/Aliens lead "humanoid X", an optional per-creature `anthro` text block, and the optional Krea2T Enhancer in the gallery renderer). Random characters move (marginals re-baselined). See docs/history.md -> "2.4.0".
- **2.3.0** - Picker previews through a server-side cache (they now show under `--offline`, with a Clear cached previews button), Outfit Sheet and Age Progression nodes (shared `replay_base` / `release_fields` helpers in the Turnaround module), an Aztec Noble archetype, and `costume_back` for caped and back-emblem heroes. Random characters unchanged (the Archetype node's Random pick moves, as with any archetype addition). See docs/history.md -> "2.3.0".
- **2.2.0** - Cyberpunk roster (David Martinez, Panam and Rebecca rebuilt to canon; new Maine, Kiwi, Talia Yang, Adam Smasher, Song So Mi with a weighted netrunner alternate), Volcana, four period court archetypes (Rococo Courtier, Medieval Monarch, Ottoman Court, Heian Court) and a Female variant for Ancient Roman Patrician, a `tattoos` lock kept in Essentials, a costume-named earring or necklace suppressing the random one, a `gilded palace throne room` location, tattoo and piercing locks on eleven period archetypes, a franchise filter in the roster picker, and four punk/pinup outfit-corpus phrases (the location and the outfits move random seeds). See docs/history.md -> "2.2.0".
+1 -1
View File
@@ -27,7 +27,7 @@ The Cosplayer node is where Identity Forge really shines. Most character wildcar
Ask a plain wildcard for Chun-Li and your prompt says `Chun-Li`. Ask this Cosplayer node and you get: *the blue qipao with gold trim, brown tights, white cross-laced boots, and spiked bracelets.* The look renders even on checkpoints that have never heard of the character.
**Find one fast:** open the in-node picker to browse and search the whole roster without leaving the node — trait facets (Giant, Masked, Mascot/full-suit, Beast), Female/Male and franchise filters, and optional thumbnail previews (fetched once by your ComfyUI server and cached on disk, so they still show when ComfyUI runs with `--offline`). The picker remembers your search, tab and facet while the workflow is open, so you can pick, close and come back to the same filtered view; reloading starts fresh.
**Find one fast:** open the in-node picker to browse and search the whole roster without leaving the node - trait facets (Giant, Masked, Mascot/full-suit, Beast), Female/Male and a type-to-filter franchise box, a **Queue each** button that runs every match in turn, and optional thumbnail previews (fetched once by your ComfyUI server and cached on disk, so they still show when ComfyUI runs with `--offline`). The picker remembers your search, tab and facet while the workflow is open, so you can pick, close and come back to the same filtered view, scrolled to your current pick; reloading starts fresh. Search rules are in [docs/usage.md](docs/usage.md#searching-the-picker).
**Characters from every major franchise:** Marvel, DC, Star Wars, anime, video games, fantasy, sci-fi, horror. Each one with multiple costume variants where applicable (Harley Quinn's three iconic looks, Catwoman's different suits, etc.). Characters rotate between variants by seed, so the same name yields a different signature costume each roll.
+30
View File
@@ -1702,3 +1702,33 @@ hall: the Giza plateau adds clashes with its locked spotlight and evening-formal
Random characters move through the open-landscape pose rule, the indoor composition rule and
the new venues; the marginals baseline was rewritten for those three.
## 2.5.0 - picker search
**Substring search was noisy.** "bow" matched every "elbow-length" glove and "rainbow", "hat"
matched "that", "red" matched "layered". Tokens now match from a word's start (a name still
matches anywhere). Measured on the roster: "bow" 167 to 111 entries, "hat" 224 to 149, "red"
1378 to 770. Word-start alone lost real compounds ("suit" missed 235 "bodysuit" entries,
"sword" missed longswords), so `SEARCH_ALSO` lists the compounds the roster actually uses, plus
a few synonyms (pants/trousers, gray/grey). One-way on purpose, so a specific word stays
specific. A matcher on word endings was rejected: it brought "necklace" for "lace", "earring"
for "ring" and "ponytail" for "tail".
**Accents fold** on both sides (Unicode NFD, plus a few letters NFD keeps, such as ø and ß), so a plain US keyboard finds Día de los Muertos.
**Description text that was not searched:** `eyes`, the alternate looks in `costumes`,
`subject`, `skin`, `costume_back`, `prop_costume` and `anatomy` now go into the roster index.
**The franchise dropdown** was a native select of hundreds of names that only jumped by first
letter. It is a type-to-filter box with the franchises as suggestions. It and the trait facet
only match cosplayers, so the Archetype and Creature pickers no longer show them (nor gender on
Creature, whose entries have none).
**Lost place after a pick.** Reopening rebuilt the grid at the top. It now scrolls to, and
outlines, the entry the node holds.
**Queue each** queues one run per matching entry through `app.queuePrompt`, setting the widget
before each call and restoring the pick after. It shows only while filtering, so the whole
roster cannot be queued by accident, and asks for confirmation with the count.
Frontend only plus the generated roster index: no schema, data or seed change.
+10 -1
View File
@@ -29,7 +29,14 @@ Nothing is open; the last row (the Tellarite snout) closed in 2.1.0 with the `su
tight-shot legwear, free-text `held_item` and expression-sheet rows in 1.10.0, see
`docs/history.md`):
Empty: the gaze field and the noun-expression article both shipped in 2.0.0.
The gaze field and the noun-expression article both shipped in 2.0.0. Open, from the 2.5.0
picker-search review (maintainer is considering them):
- **Random from these** - a picker button that queues one run with a random pick from the
filtered set, a lighter option than Queue each.
- **Plural search** - "boots" does not find a costume that says "boot" (word-start matching
already covers the reverse). Rare in practice; a naive trailing-s strip turns "glasses" into
"glass".
**Researched and skipped — do not re-survey.** Valorant, Apex Legends,
Monster Hunter, Skyrim, Splatoon, FNAF, Among Us, Minecraft, Mortal Shell. Each is an armoured,
@@ -77,6 +84,8 @@ Closed with a reason. Reopen only with a **new** argument, not a repeat of the r
|---|---|
| A negative and/or tags output | Maintainer: not needed. (The subject/scene half of the same row shipped at 1.8.0 as `subject_text`.) |
| An on-node readout of the resolved prompt | Maintainer: not needed. |
| Saved picker searches (a remembered list of frequent filters) (2.5.0) | Maintainer: not wanted. |
| Hair-colour and era filters in the picker (2.5.0) | Maintainer: not wanted; word search covers them. |
| A pair / group node (two or more resolved characters in one prompt) (2.3.0 plan) | Maintainer: deferred, not refused. Most current t2i models blend or swap traits between two described people in one prompt, so the output would not match the characters. Reopen if models hold separate subjects reliably. |
### Individual characters
+22
View File
@@ -266,6 +266,28 @@ Dyed or vivid scopes, cosplay hair and covered hair are left alone. A face-cover
emits one view as resolved. Labels read `1-age-20` and so on. A ready-made workflow is
`example_workflows/Identity Forge - Age Progression.json`.
## Searching the picker
- **Words match from their start.** `bow` finds a bow tie or a bowler hat, not "elbow" or
"rainbow". A name still matches anywhere (`man` finds Batman). Several words must all match,
in any order; put a phrase in quotes (`"bow tie"`) to match it as written.
- **Accents are optional.** `dia` and `día` both find Día de los Muertos; `pokemon` finds
Pokémon. The same holds in the franchise box.
- **Everything in an entry's description is searched:** name, franchise, costume, alternate
costumes, back view, mask, prop, eyes, hair and body text.
- **A few words also find their synonyms and compounds:** `pants` finds trousers, slacks and
jeans, `suit` finds bodysuits and jumpsuits, `sword` finds katanas, `gray` finds grey. The
list is `SEARCH_ALSO` in `js/identity_forge_picker.js`; it is one-way (`jeans` does not
find slacks).
- **Franchise box (Cosplayer node):** type part of a name. `star` keeps Star Wars and Star
Trek; picking a suggestion, or typing a full name, keeps that franchise only. Trait, gender
and franchise filters only appear on nodes where they can narrow something.
- **Your place is kept.** Reopening the picker scrolls to the character the node holds (outlined),
with the same search and filters, so you can pick, queue, and come back to the next one.
- **Queue each (N)** appears while you are filtering: it queues one run per matching entry the
node can take, then puts your original pick back. Each run uses the rest of the workflow as it
stands, so a seed set to randomize gives each one a new person.
## Preview images in the picker
"Show preview images" in the roster picker is off by default. When it is on, your ComfyUI
+10
View File
@@ -211,6 +211,16 @@
outline-offset: 1px;
}
/* 2.5.0: the entry the node currently holds. */
.if-picker-tile.current {
border-color: var(--if-picker-accent, #5c9eff);
box-shadow: inset 0 0 0 1px var(--if-picker-accent, #5c9eff);
}
.if-picker-franchise {
width: 170px;
}
.if-picker-tile-disabled {
cursor: not-allowed;
opacity: 0.55;
+242 -49
View File
@@ -122,15 +122,90 @@ function tabLabel(tab) {
return tab === TAB_ALL ? "All" : KIND_LABEL[tab] || tab;
}
// --- search: substring, multi-token AND, case-insensitive -------------------
// --- search: word-start, multi-token AND, case-insensitive -------------------
//
// 2.5.0: a token matches where a WORD starts in the description ("bow" finds
// "bow tie" and "bowler hat", no longer "elbow" or "rainbow"), or anywhere in
// the entry's name. A quoted phrase ("bow tie") is one token. SEARCH_ALSO widens
// a few words to their synonyms and to the compounds the roster really uses
// (scripts measured: "suit" alone missed 235 "bodysuit" entries under word-start).
// Directional on purpose: "pants" finds trousers, "jeans" does not find slacks.
const SEARCH_ALSO = {
pants: ["trousers", "slacks", "jeans", "sweatpants", "breeches"],
trousers: ["pants", "slacks"],
suit: ["bodysuit", "jumpsuit", "catsuit", "supersuit", "tracksuit", "spacesuit", "swimsuit", "wetsuit", "plugsuit", "batsuit", "exosuit"],
sword: ["longsword", "greatsword", "broadsword", "katana", "sabre", "saber", "rapier", "scimitar", "cutlass"],
coat: ["waistcoat", "tailcoat", "overcoat", "greatcoat", "raincoat", "trenchcoat", "longcoat"],
dress: ["minidress", "sundress", "gown"],
skirt: ["miniskirt", "overskirt"],
shirt: ["sweatshirt", "undershirt", "overshirt"],
glasses: ["sunglasses", "spectacles", "eyeglasses"],
gun: ["shotgun", "handgun", "minigun", "railgun", "pistol", "rifle", "revolver", "blaster"],
band: ["headband", "armband", "wristband", "hairband"],
sweater: ["jumper", "pullover"],
sneakers: ["trainers"],
trainers: ["sneakers"],
gray: ["grey"],
grey: ["gray"],
blonde: ["blond"],
armor: ["armour"],
armour: ["armor"],
color: ["colour"],
colour: ["color"],
mustache: ["moustache"],
moustache: ["mustache"],
saber: ["sabre"],
sabre: ["saber"],
robot: ["android", "droid", "cyborg", "mech"],
};
// Accents and special letters fold to their plain-keyboard form on both sides,
// so "dia", "día" and "Día" all find Día de los Muertos, "pokemon" finds Pokémon.
const FOLD_EXTRA = { "ø": "o", "æ": "ae", "œ": "oe", "ß": "ss", "ł": "l", "đ": "d", "ð": "d", "þ": "th", "ı": "i" };
function fold(text) {
return String(text || "").toLowerCase().normalize("NFD").replace(/[̀-ͯ]/g, "")
.replace(/[øæœßłđðþı]/g, (c) => FOLD_EXTRA[c]);
}
const foldedEntries = new WeakMap(); // entry -> { name, haystack }, folded once
function foldedEntry(entry) {
let f = foldedEntries.get(entry);
if (!f) {
f = { name: fold(entry.name), haystack: fold(entry.haystack) };
foldedEntries.set(entry, f);
}
return f;
}
function tokenize(query) {
return String(query || "").trim().toLowerCase().split(/\s+/).filter(Boolean);
const tokens = [];
for (const m of fold(query).matchAll(/"([^"]*)"|(\S+)/g)) {
const token = (m[1] ?? m[2]).trim().replace(/\s+/g, " ");
if (token) tokens.push(token);
}
return tokens;
}
const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const tokenPatterns = new Map(); // token -> RegExp, built once per distinct token
function tokenPattern(token) {
let re = tokenPatterns.get(token);
if (!re) {
const words = [token, ...(SEARCH_ALSO[token] || [])].map(escapeRegExp);
re = new RegExp("(?:^|[^a-z0-9])(?:" + words.join("|") + ")");
tokenPatterns.set(token, re);
}
return re;
}
function matchesQuery(entry, tokens) {
if (!tokens.length) return true;
return tokens.every((token) => entry.haystack.includes(token));
const { name, haystack } = foldedEntry(entry);
return tokens.every((token) => name.includes(token) || tokenPattern(token).test(haystack));
}
// --- trait facets -------------------------------------------------------------
@@ -177,8 +252,21 @@ function matchesGender(entry, gender) {
}
// Franchise filter (2.2.0). Only cosplayers carry a franchise, so picking one
// narrows to cosplayers. Options come from the loaded roster, grouped by category.
const FRANCHISE_ALL = "All franchises";
// narrows to cosplayers. 2.5.0: a type-to-filter box (there are hundreds of
// franchises) with the franchises as suggestions. Text that names a franchise
// exactly keeps only that one; any other text keeps every franchise containing it
// ("star" -> Star Wars and Star Trek). Empty means all.
const FRANCHISE_ALL = "";
let pickerSerial = 0; // unique datalist ids, one per picker
function franchiseMatcher(text, entries) {
const q = fold(text).trim();
if (!q) return null;
const exact = entries.some((e) => e.franchise && fold(e.franchise) === q);
return exact
? (e) => Boolean(e.franchise) && fold(e.franchise) === q
: (e) => Boolean(e.franchise) && fold(e.franchise).includes(q);
}
function franchiseGroups(entries) {
const groups = new Map();
@@ -370,6 +458,9 @@ class IdentityForgePicker {
open() {
if (this.overlay) return;
this.previousFocus = document.activeElement;
// 2.5.0: reopen on the node's current pick, so a long filtered list keeps
// its place between picks instead of jumping back to the top.
this._revealCurrent = true;
try {
this.build();
document.body.appendChild(this.overlay);
@@ -488,12 +579,7 @@ class IdentityForgePicker {
search.setAttribute("aria-label", "Search the roster by name, franchise, or trait");
search.addEventListener("input", (event) => {
this.query = event.target.value || "";
this.focusIndex = 0;
if (this._searchTimer) clearTimeout(this._searchTimer);
this._searchTimer = setTimeout(() => {
this._searchTimer = null;
this.renderGrid();
}, 80);
this.scheduleRender();
});
search.value = this.query; // restore the surviving query (see close())
this.searchInput = search;
@@ -537,15 +623,23 @@ class IdentityForgePicker {
});
this.genderSelect = genderSelect;
const franchiseSelect = document.createElement("select");
franchiseSelect.className = "if-picker-facet";
franchiseSelect.setAttribute("aria-label", "Filter by franchise");
franchiseSelect.addEventListener("change", () => {
this.franchise = franchiseSelect.value;
this.focusIndex = 0;
this.renderGrid();
const franchiseInput = document.createElement("input");
franchiseInput.type = "search";
franchiseInput.className = "if-picker-facet if-picker-franchise";
franchiseInput.placeholder = "Franchise...";
franchiseInput.spellcheck = false;
franchiseInput.autocomplete = "off";
franchiseInput.setAttribute("aria-label", "Filter by franchise (type part of a name)");
const franchiseList = document.createElement("datalist");
franchiseList.id = "if-picker-franchises-" + ++pickerSerial;
franchiseInput.setAttribute("list", franchiseList.id);
franchiseInput.value = this.franchise;
franchiseInput.addEventListener("input", () => {
this.franchise = franchiseInput.value;
this.scheduleRender();
});
this.franchiseSelect = franchiseSelect;
this.franchiseInput = franchiseInput;
this.franchiseList = franchiseList;
this.fillFranchiseOptions();
const previewLabel = document.createElement("label");
@@ -568,7 +662,25 @@ class IdentityForgePicker {
close.setAttribute("aria-label", "Close (" + this.config.title + ")");
close.addEventListener("click", () => this.close());
header.append(search, facet, genderSelect, franchiseSelect, count, previewLabel, close);
// 2.5.0: queue one run per matching character, so a filtered set can be
// cycled through in one go. Shown only while filtering (never the whole roster).
const queueAll = document.createElement("button");
queueAll.type = "button";
queueAll.className = "if-picker-btn if-picker-queue-all";
queueAll.title = "Queue one run for each matching entry, then put your current pick back.";
queueAll.addEventListener("click", () => this.queueEach());
this.queueAllButton = queueAll;
// 2.5.0: trait and franchise filters match cosplayers only, and creatures carry
// no gender, so a node shows only the filters that can narrow what it can pick.
const kind = this.config.kind;
header.append(
search,
...(kind === "cosplayer" ? [facet] : []),
...(kind !== "creature" ? [genderSelect] : []),
...(kind === "cosplayer" ? [franchiseInput, franchiseList] : []),
count, queueAll, previewLabel, close,
);
const notice = document.createElement("div");
notice.className = "if-picker-notice";
@@ -629,7 +741,9 @@ class IdentityForgePicker {
footer.className = "if-picker-footer";
footer.textContent =
"Searches roster entries (cosplayers, archetypes, creatures) — not the randomizable "
+ "field pools on the main node. Arrow keys move, Enter selects, Escape closes.";
+ "field pools on the main node. Words match from their start; \"quote a phrase\"; "
+ "a few words also find synonyms (pants finds trousers). "
+ "Arrow keys move, Enter selects, Escape closes.";
dialog.append(header, notice, links, tabs, grid, footer);
overlay.appendChild(dialog);
@@ -722,11 +836,11 @@ class IdentityForgePicker {
return Math.max(1, Math.floor(width / 210));
}
highlight() {
highlight(block = "nearest") {
if (!this.grid) return;
const next = this.visible.length ? this.grid.children[this.focusIndex] || null : null;
if (this._focused === next) {
if (next && next.scrollIntoView) next.scrollIntoView({ block: "nearest" });
if (next && next.scrollIntoView) next.scrollIntoView({ block });
return;
}
if (this._focused) {
@@ -737,7 +851,7 @@ class IdentityForgePicker {
if (next) {
next.classList.add("focused");
next.setAttribute("aria-selected", "true");
if (next.scrollIntoView) next.scrollIntoView({ block: "nearest" });
if (next.scrollIntoView) next.scrollIntoView({ block });
}
}
@@ -796,30 +910,99 @@ class IdentityForgePicker {
if (this.gender !== GENDER_ANY) {
list = list.filter((entry) => matchesGender(entry, this.gender));
}
if (this.franchise !== FRANCHISE_ALL) {
list = list.filter((entry) => entry.franchise === this.franchise);
}
const inFranchise = franchiseMatcher(this.franchise, roster);
if (inFranchise) list = list.filter(inFranchise);
return list;
}
/** (Re)build the franchise dropdown; a no-op until the roster has loaded. */
/** Fill the franchise suggestions (category as the label); a no-op until the roster has loaded. */
fillFranchiseOptions() {
const select = this.franchiseSelect;
if (!select || (roster && select.options.length > 1)) return;
const all = document.createElement("option");
all.value = all.textContent = FRANCHISE_ALL;
select.replaceChildren(all);
for (const [category, names] of franchiseGroups(roster || [])) {
const group = document.createElement("optgroup");
group.label = category;
const list = this.franchiseList;
if (!list || !roster || list.options.length) return;
for (const [category, names] of franchiseGroups(roster)) {
for (const name of names) {
const option = document.createElement("option");
option.value = option.textContent = name;
group.appendChild(option);
option.value = name;
option.label = category;
list.appendChild(option);
}
select.appendChild(group);
}
select.value = this.franchise;
}
/** Re-render shortly after typing stops, so each keystroke does not rebuild the grid. */
scheduleRender() {
this.focusIndex = 0;
if (this._searchTimer) clearTimeout(this._searchTimer);
this._searchTimer = setTimeout(() => {
this._searchTimer = null;
this.renderGrid();
}, 80);
}
/** The visible entries this node can take -- what "Queue each" runs. */
queueableEntries() {
return this.visible.filter((entry) => entry.kind === this.config.kind);
}
/**
* Queue one run per matching entry, then restore the node's own pick.
* Each app.queuePrompt() call snapshots the graph, so setting the widget and
* awaiting the call in turn gives one job per character.
*/
async queueEach() {
const entries = this.queueableEntries();
const node = this.config.node;
const widget = findWidget(node, this.config.targetWidgetName);
if (!entries.length || !widget || this._queueing) return;
if (typeof app.queuePrompt !== "function") {
alert("This ComfyUI frontend does not expose app.queuePrompt, so runs cannot be queued from here.");
return;
}
const noun = entries.length === 1 ? "run" : "runs";
if (!confirm("Queue " + entries.length + " " + noun + ", one for each matching entry?")) return;
this._queueing = true;
const original = widget.value;
const button = this.queueAllButton;
let queued = 0;
try {
for (const entry of entries) {
widget.value = entry.name;
// false = ComfyUI was already building another prompt and only queued ours
// for later, when the widget would hold a different name. Stop rather than
// queue the wrong character.
if ((await app.queuePrompt(0, 1)) === false) break;
queued += 1;
if (button && button.isConnected) button.textContent = "Queued " + queued + " / " + entries.length;
}
} catch (error) {
console.error("[IdentityForgePicker] queueing failed", error);
} finally {
setWidgetValue(node, widget, original);
this.resyncFranchiseFilter();
if (typeof node.setDirtyCanvas === "function") node.setDirtyCanvas(true, true);
this._queueing = false;
if (queued < entries.length) {
alert("Queued " + queued + " of " + entries.length + " runs; the rest were not queued.");
}
this.updateQueueButton();
}
}
updateQueueButton() {
const button = this.queueAllButton;
if (!button || this._queueing) return;
const n = this.isFiltering() ? this.queueableEntries().length : 0;
button.style.display = n ? "" : "none";
button.textContent = "Queue each (" + n + ")";
}
/** Re-run franchise_filter's callback so the node's pick stays in its combo list. */
resyncFranchiseFilter() {
if (!this.config.franchiseFilterWidgetName) return;
const filterWidget = findWidget(this.config.node, this.config.franchiseFilterWidgetName);
if (filterWidget && typeof filterWidget.callback === "function") {
filterWidget.callback(filterWidget.value);
}
}
/** The grid's contents: the query/facet matches, narrowed to the active tab. */
@@ -841,7 +1024,7 @@ class IdentityForgePicker {
/** True while anything is narrowing the roster -- when the counts are worth showing. */
isFiltering() {
return Boolean(tokenize(this.query).length) || this.facet !== FACET_ALL
|| this.gender !== GENDER_ANY || this.franchise !== FRANCHISE_ALL;
|| this.gender !== GENDER_ANY || Boolean(String(this.franchise).trim());
}
renderGrid() {
@@ -863,6 +1046,19 @@ class IdentityForgePicker {
if (this.count) {
this.count.textContent = this.visible.length + (this.visible.length === 1 ? " result" : " results");
}
this.updateQueueButton();
const current = findWidget(this.config.node, this.config.targetWidgetName)?.value;
let reveal = false;
// Only once the dialog is on the page: build() renders before it is attached.
if (this._revealCurrent && this.overlay && this.overlay.isConnected) {
this._revealCurrent = false;
const index = this.visible.findIndex((e) => e.kind === this.config.kind && e.name === current);
if (index > -1) {
this.focusIndex = index;
reveal = true;
}
}
if (!this.visible.length) {
const empty = document.createElement("div");
@@ -923,10 +1119,12 @@ class IdentityForgePicker {
const fragment = document.createDocumentFragment();
this.visible.forEach((entry, index) => {
fragment.appendChild(this.buildTile(entry, index));
const tile = this.buildTile(entry, index);
if (entry.kind === this.config.kind && entry.name === current) tile.classList.add("current");
fragment.appendChild(tile);
});
this.grid.appendChild(fragment);
this.highlight();
this.highlight(reveal ? "center" : "nearest");
if (this.showPreviews) {
// One manifest fetch per kind actually shown, not per card.
@@ -1026,12 +1224,7 @@ class IdentityForgePicker {
// its own current value recomputes that rule with the new selection,
// reusing the exact logic in identity_forge_cosplayer.js rather than
// duplicating it.
if (this.config.franchiseFilterWidgetName) {
const filterWidget = findWidget(node, this.config.franchiseFilterWidgetName);
if (filterWidget && typeof filterWidget.callback === "function") {
filterWidget.callback(filterWidget.value);
}
}
this.resyncFranchiseFilter();
if (typeof node.setDirtyCanvas === "function") node.setDirtyCanvas(true, true);
} catch (error) {
console.error("[IdentityForgePicker] selection failed", error);
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "comfyui-identity-forge"
version = "2.4.0"
version = "2.5.0"
description = "Create believable, coherent people, cosplayers and creatures from dropdowns - no prompt engineering required. A constraint engine keeps every trait sensible and a seed makes any result reproducible. Cosplay characters carry a hand-written, canon-checked costume description - garments, colours, masks, markings, signature props - that renders on any checkpoint, and are searchable from an in-node picker with trait facets, gender and franchise filters, and thumbnail previews that are cached on disk so they also show offline. Sheet nodes build one-queue reference sets of the same resolved character: Turnaround (camera views), Expression Sheet, Outfit Sheet (one look per outfit style) and Age Progression (the character across ages). Public galleries showcase every entry with a sample render and its exact workflow. Optional preset layers add themed archetypes, creature/monster/alien hybridization, per-element style modifiers, and a save/load character vault."
license = { text = "MIT" }
readme = "README.md"
+15
View File
@@ -251,6 +251,17 @@ def _cosplayer_traits(entry: dict) -> list[str]:
return traits
def _text_leaves(value) -> list[str]:
"""Every string inside a nested dict/list value, in order."""
if isinstance(value, str):
return [value]
if isinstance(value, dict):
value = list(value.values())
if isinstance(value, list):
return [s for v in value for s in _text_leaves(v)]
return []
def _cosplayer_roster_entry(
name: str, entry: dict, franchise_categories: dict[str, str], default_category: str,
) -> dict:
@@ -270,6 +281,10 @@ def _cosplayer_roster_entry(
aliases = entry.get("aliases")
if aliases:
haystack_parts.extend(aliases)
# 2.5.0: every other piece of descriptive text is searchable too, including
# each alternate look in `costumes`.
for key in ("eyes", "subject", "skin", "costume_back", "prop_costume", "anatomy", "costumes"):
haystack_parts.extend(_text_leaves(entry.get(key)))
roster = {
"kind": "cosplayer",
"name": name,
+106 -10
View File
@@ -281,30 +281,126 @@ test("the gender filter keeps that gender plus entries that suit either", async
}
});
test("the franchise filter lists roster franchises by category and keeps only that franchise", async () => {
test("the franchise box suggests every franchise, keeps an exact name only, and part of a name broadly", async () => {
resetDom();
__testing.__resetForTests();
const stub = installFetchStub(rosterOkHandler);
try {
const picker = await openPicker();
const select = picker.franchiseSelect;
assert.ok(select.querySelectorAll("optgroup").length > 1, "options are grouped by category");
const franchise = REAL_ROSTER.find((e) => e.franchise).franchise;
assert.ok([...select.options].some((o) => o.value === franchise));
select.value = franchise;
select.dispatchEvent(new window.Event("change"));
const franchises = new Set(REAL_ROSTER.filter((e) => e.franchise).map((e) => e.franchise));
assert.equal(picker.franchiseList.options.length, franchises.size, "one suggestion per franchise");
assert.ok(picker.franchiseList.options[0].label, "suggestions carry their category");
const input = picker.franchiseInput;
input.value = "star wars";
input.dispatchEvent(new window.Event("input"));
picker.renderGrid();
assert.ok(picker.visible.length > 0);
assert.ok(picker.visible.every((e) => e.franchise === franchise));
assert.ok(picker.visible.every((e) => e.franchise === "Star Wars"), "an exact name (any case) keeps that franchise only");
picker.franchise = "star";
picker.renderGrid();
const hit = new Set(picker.visible.map((e) => e.franchise));
assert.ok(hit.has("Star Wars") && hit.has("Star Trek"), "part of a name keeps every franchise containing it");
picker.close();
picker.open();
await new Promise((r) => setTimeout(r, 0));
assert.equal(picker.franchiseSelect.value, franchise, "the choice survives a reopen");
await flush();
assert.equal(picker.franchiseInput.value, "star", "the text survives a reopen");
picker.close();
} finally {
stub.restore();
}
});
test("archetype and creature pickers hide the cosplayer-only filters", async () => {
resetDom();
__testing.__resetForTests();
const stub = installFetchStub(rosterOkHandler);
try {
for (const [kind, widget, gender] of [["archetype", "archetype", true], ["creature", "creature", false]]) {
const picker = await openPicker(kind, widget);
const header = picker.overlay.querySelector(".if-picker-header");
assert.ok(!header.contains(picker.franchiseInput), kind + ": no franchise box");
assert.ok(!header.contains(picker.facetSelect), kind + ": no trait facet");
assert.equal(header.contains(picker.genderSelect), gender, kind + ": gender only where entries have one");
picker.close();
}
const cos = await openPicker();
const header = cos.overlay.querySelector(".if-picker-header");
assert.ok(header.contains(cos.franchiseInput) && header.contains(cos.facetSelect) && header.contains(cos.genderSelect));
cos.close();
} finally {
stub.restore();
}
});
test("search matches from a word's start, quoted phrases, and the SEARCH_ALSO synonyms", () => {
const find = (q) => REAL_ROSTER.filter((e) => __testing.matchesQuery(e, __testing.tokenize(q)));
const elbowOnly = (e) => /elbow|rainbow/.test(e.haystack) && !/(^|[^a-z0-9])bow/.test(e.haystack)
&& !e.name.toLowerCase().includes("bow");
assert.ok(REAL_ROSTER.some(elbowOnly), "sanity: some entries mention bow only inside elbow/rainbow");
assert.ok(!find("bow").some(elbowOnly), '"bow" must not match inside "elbow" or "rainbow"');
assert.ok(find("man").some((e) => e.name === "Batman"), "a name still matches anywhere");
assert.deepEqual(__testing.tokenize('red "bow tie"'), ["red", "bow tie"]);
for (const q of ["dia de los", "día", "DÍA"]) {
assert.ok(find(q).some((e) => e.name === "Día de los Muertos"), `"${q}" finds Día de los Muertos`);
}
assert.equal(__testing.tokenize("Øyvind Straße")[1], "strasse");
assert.ok(find('"bow tie"').length > 0 && find('"bow tie"').length < find("bow").length);
const trousersOnly = REAL_ROSTER.filter((e) => /(^|[^a-z0-9])trousers/.test(e.haystack) && !/pants/.test(e.haystack));
assert.ok(trousersOnly.length > 0, "sanity");
const pants = new Set(find("pants"));
assert.ok(trousersOnly.every((e) => pants.has(e)), '"pants" finds trousers');
assert.ok(find("suit").some((e) => /bodysuit/.test(e.haystack) && !/(^|[^a-z0-9])suit/.test(e.haystack)),
'"suit" finds bodysuits');
});
test("reopening lands on the node's current pick, marked, instead of the top of the list", async () => {
resetDom();
__testing.__resetForTests();
const stub = installFetchStub(rosterOkHandler);
try {
const picker = await openPicker();
const target = picker.visible[40];
picker.select(target);
picker.open();
await flush();
assert.equal(picker.visible[picker.focusIndex].name, target.name);
const tile = picker.grid.children[picker.focusIndex];
assert.ok(tile.classList.contains("current") && tile.classList.contains("focused"));
picker.close();
} finally {
stub.restore();
}
});
test("Queue each queues one run per matching entry, then restores the pick", async () => {
resetDom();
__testing.__resetForTests();
const stub = installFetchStub(rosterOkHandler);
const seen = [];
try {
const picker = await openPicker();
assert.equal(picker.queueAllButton.style.display, "none", "hidden with no filter: never the whole roster");
const widget = picker.config.node.widgets.find((w) => w.name === "character");
widget.value = "None";
app.queuePrompt = async () => { seen.push(widget.value); return true; };
picker.franchise = "Star Wars";
picker.tabs.querySelector('[data-tab="__all__"]').click(); // mixed kinds: only cosplayers queue
const expected = picker.visible.filter((e) => e.kind === "cosplayer").map((e) => e.name);
assert.ok(expected.length > 1);
assert.equal(picker.queueAllButton.textContent, "Queue each (" + expected.length + ")");
await picker.queueEach();
assert.deepEqual(seen, expected);
assert.equal(widget.value, "None", "the original pick is put back");
picker.close();
} finally {
delete app.queuePrompt;
stub.restore();
}
});
test("while filtering, every tab shows its own match count so other kinds stay discoverable", async () => {
resetDom();
__testing.__resetForTests();