Skip to content

feat(dynamicprompts): support wildcards and prevent hang on unknown wildcards#9290

Open
Pfannkuchensack wants to merge 2 commits into
invoke-ai:mainfrom
Pfannkuchensack:feat/dynamicprompts-wildcards
Open

feat(dynamicprompts): support wildcards and prevent hang on unknown wildcards#9290
Pfannkuchensack wants to merge 2 commits into
invoke-ai:mainfrom
Pfannkuchensack:feat/dynamicprompts-wildcards

Conversation

@Pfannkuchensack

@Pfannkuchensack Pfannkuchensack commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

Wire up dynamicprompts' WildcardManager so __name__ references resolve against .txt files in a new wildcards/ directory (configurable via the wildcards_dir setting). Both the /utilities/dynamicprompts endpoint and the DynamicPrompt node now build the manager from this path.

Referencing an unknown wildcard previously hung the combinatorial generator forever: its not-found fallback yields the wrapped wildcard infinitely, and the variant dedup logic discards those duplicates without ever advancing. This froze the UI prompt preview. Unknown wildcards are now detected up front and reported as a clear error instead of attempting generation.

Related Issues / Discussions

N/A — reported by a user whose dynamic prompt ({__random__8chan|fenster|stuff}) froze the prompt preview. The __random__ was parsed as a wildcard reference rather than literal text.

#9137 adds wildcard too.

QA Instructions

Hang fix (the actual bug):

  1. Open the canvas/generation tab and enter a prompt containing an unknown wildcard, e.g. {__random__a|b|c}.
  2. Before this change the dynamic prompts preview spinner would hang indefinitely (the request never returned).
  3. After this change the preview returns immediately and shows the error: No values found for wildcard(s): random.

Wildcard feature:

  1. Create a wildcard file under <invokeai_root>/wildcards/animals.txt with one value per line:
    cat
    dog
    bird
    
  2. Use __animals__ in a prompt (also works inside variants, e.g. a {__animals__|house}).
  3. Confirm the preview/generation expands it to the wildcard values. Subdirectories map to __subdir/name__.
  4. The wildcards/ directory is created automatically on first use; the location is configurable via the wildcards_dir setting.

Automated tests:

pytest tests/app/util/test_dynamicprompts.py tests/app/routers/test_utilities.py

Merge Plan

Standard merge — no special handling required. Changes are additive and backwards-compatible:

  • New wildcards_dir config setting (defaults to wildcards/); no migration needed.
  • No DB schema or redux slice changes.
  • docs/src/generated/settings.json was regenerated to include the new setting.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • ❗Changes to a redux slice have a corresponding migration — N/A, no slice changes
  • Documentation added / updated (if applicable) — regenerated settings.json
  • Updated What's New copy (if doing a release after this PR)

…ildcards

Wire up dynamicprompts' WildcardManager so `__name__` references resolve
against .txt files in a new `wildcards/` directory (configurable via the
`wildcards_dir` setting). Both the /utilities/dynamicprompts endpoint and
the DynamicPrompt node now build the manager from this path.

Referencing an unknown wildcard previously hung the combinatorial generator
forever: its not-found fallback yields the wrapped wildcard infinitely, and
the variant dedup logic discards those duplicates without ever advancing.
This froze the UI prompt preview. Unknown wildcards are now detected up front
and reported as a clear error instead of attempting generation.
@github-actions github-actions Bot added api python PRs that change python files invocations PRs that change invocations services PRs that change app services python-tests PRs that change python tests docs PRs that change docs labels Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api docs PRs that change docs invocations PRs that change invocations python PRs that change python files python-tests PRs that change python tests services PRs that change app services

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant