feat: LoraManager integration — trigger words & example import (#52)#136
feat: LoraManager integration — trigger words & example import (#52)#136
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ae73c8b4e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| document.getElementById("resultTimeout").value = this.settings.resultTimeout; | ||
| document.getElementById("webuiDisplayMode").value = this.settings.webuiDisplayMode; | ||
| document.getElementById("galleryRootPath").value = this.settings.galleryRootPath || ''; | ||
| this.renderScanPaths(); |
There was a problem hiding this comment.
Remove call to undefined renderScanPaths
The settings entry point now calls this.renderScanPaths() before opening the modal, but there is no renderScanPaths method defined in web/js/admin.js. This throws a TypeError when users click Settings and prevents the rest of showSettingsModal() from running, so the settings dialog no longer opens.
Useful? React with 👍 / 👎.
py/api/lora_integration.py
Outdated
| meta_files = [] | ||
| for d in lora_dirs: | ||
| dir_path = Path(d) | ||
| meta_files.extend(dir_path.glob("*.metadata.json")) |
There was a problem hiding this comment.
Recursively scan metadata files during LoRA import
The import path only uses glob("*.metadata.json") per discovered directory, so metadata files in nested LoRA subfolders are skipped. In setups where models/loras is organized into subdirectories, the scan will under-import LoRAs and their previews while reporting completion, which makes imported results incomplete.
Useful? React with 👍 / 👎.
py/lora_utils.py
Outdated
| lora_dirs = find_lora_directories(lora_manager_path) | ||
| for lora_dir in lora_dirs: | ||
| dir_path = Path(lora_dir) | ||
| for meta_file in dir_path.glob("*.metadata.json"): |
There was a problem hiding this comment.
Recursively build trigger cache from metadata files
TriggerWordCache.load() also uses non-recursive glob("*.metadata.json"), so LoRAs whose metadata is stored in nested folders are never cached. When users reference those LoRAs with <lora:...> tags, trigger-word injection silently does nothing even though integration is enabled.
Useful? React with 👍 / 👎.
Detection, metadata reading, trigger word cache, and prompt injection for ComfyUI-Lora-Manager. All functions return empty results when LoraManager is not installed.
Detection, enable/disable, scan/import, trigger word lookup, and cache refresh endpoints under /prompt_manager/lora/*.
When enabled, scans for <lora:NAME:WEIGHT> tags in prompt text and appends trigger words from LoraManager metadata. Behind config toggle.
Integrations section in settings with auto-detection badge, enable toggle, trigger word toggle, and Import LoRA Data button.
0ae73c8 to
062f430
Compare
The styled div was intercepting clicks meant for the sr-only checkbox input, preventing toggle switches from being clickable.
…#52) Only models/loras under the ComfyUI root was checked. Now also parses extra_model_paths.yaml and uses folder_paths.get_folder_paths('loras') at runtime to find all configured LoRA directories.
… images (#52) - Prompt text now uses civitai example prompts (images[].meta.prompt) when available, falling back to model name instead of trigger words - Image serving now allows paths within LoRA directories when the integration is enabled, fixing 403 errors on preview images
- Guard against civitai: null in metadata (was crashing the scan) - Link all local preview images per LoRA, not just the first - Add get_civitai_image_urls() for future remote image support
Clicking Import LoRA Data now deletes all existing lora-manager category prompts before scanning, ensuring a clean reimport.
Images from civitai.images[] are downloaded to data/lora_images/ cache and linked to prompts alongside local preview files. Cached files are reused on reimport. Image serving allows the cache directory.
Closes settings modal and shows a dedicated progress modal with progress bar, status text, and processed/imported counts during LoRA import. Auto-closes after completion.
5K images at 15s timeout was painfully slow. Reduced to 5s fail-fast. Progress now updates for every LoRA with image count, not every 5th.
Full-size civitai images averaged 5.6MB each (27GB total for 5K images). Now requests /width=512/ thumbnails (~50-100KB) and downloads 8 in parallel per LoRA. Expected speedup: ~100x smaller + 8x parallel.
Civitai CDN returns 401 for /width=N/ thumbnail URLs with API key auth. Instead, download the original and resize to 512px via PIL before saving. Reduces disk usage from ~5MB to ~30-50KB per image.
- Add LoRA Manager integration section with setup guide and CivitAI key docs - Add folder filter section with rescan note for existing libraries - Add v3.2.1 changelog entry, split from v3.2.0 - Add WIP notice for LoRA Manager feature - Update AutoTag section to include WD14 models - Fix stale references (KikoTextEncode, outdated file structure) - Remove dated v2 development note - Add screenshots for settings, integration, and filtered results - Fix code review items: remove unused constant, add comments to empty excepts - Bump version to 3.2.1
- test_lora_utils.py: 32 tests covering trigger word extraction, example prompts, image URLs, metadata parsing, cache dir, TriggerWordCache - test_lora_database.py: 17 tests covering delete_prompts_by_category, folder filter search, get_prompt_subfolders, LoRA import workflow - test_config.py: 7 new IntegrationConfig tests for structure, enable, partial update, reset, and roundtrip
Summary
Adds opt-in integration with ComfyUI-Lora-Manager as requested in #52.
custom_nodes/when opening Settings<lora:NAME:WEIGHT>tags and appends the LoRA's trigger words before CLIP encoding.metadata.jsonfiles to import LoRA names, trigger words, and preview images into PromptManager's databaseNew files
py/lora_utils.py— Detection, metadata parsing, trigger word cachepy/api/lora_integration.py— 6 API endpoints under/prompt_manager/lora/*Modified files
py/config.py— NewIntegrationConfigclass for integration settingspy/api/__init__.py— RegisterLoraIntegrationMixinprompt_manager_base.py— Trigger word injection methodprompt_manager.py/prompt_manager_text.py— Call injection before encodingweb/admin.html— Integrations section in Settings modalweb/js/admin.js— LoRA detection, toggle, import UITest plan
loracategory<lora:some_lora:1>in prompt → verify trigger words appended in outputCloses #52