mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-22 11:34:08 -03:00
Compare commits
91
Commits
v1.1.8
..
4bf9a4b640
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4bf9a4b640 | ||
|
|
c5088772e8 | ||
|
|
56acefbd6c | ||
|
|
5ab06c4aae | ||
|
|
c11f4b5c68 | ||
|
|
86376284f4 | ||
|
|
2b8a2fc7d8 | ||
|
|
f26e1b41c8 | ||
|
|
c1671af99f | ||
|
|
ac7707d0f6 | ||
|
|
381cd710a2 | ||
|
|
ad0d18cb79 | ||
|
|
7980ee77d0 | ||
|
|
916b8bb327 | ||
|
|
87e3d4dea9 | ||
|
|
76a913f5e0 | ||
|
|
d8c192e647 | ||
|
|
c453437620 | ||
|
|
720fa6d909 | ||
|
|
b4f71089f4 | ||
|
|
83e6657ead | ||
|
|
7ea6df4111 | ||
|
|
d9ab92602a | ||
|
|
5ffadaed31 | ||
|
|
24f5f7df5d | ||
|
|
daf01fb1d6 | ||
|
|
0f11b6def9 | ||
|
|
7df83f44b8 | ||
|
|
169fa7bed6 | ||
|
|
027b504fe8 | ||
|
|
186ef4da78 | ||
|
|
dc674098e7 | ||
|
|
9087b4b07c | ||
|
|
8e45c22d7a | ||
|
|
191c4e03cd | ||
|
|
ab4154c57d | ||
|
|
28e93d12ff | ||
|
|
75e63c758b | ||
|
|
823f71f269 | ||
|
|
042dd4088d | ||
|
|
eaa791a9eb | ||
|
|
2228627ff4 | ||
|
|
4c647ad9c8 | ||
|
|
8ca3e6c33f | ||
|
|
dd6bdbf297 | ||
|
|
b47dde87e4 | ||
|
|
99e65cccd8 | ||
|
|
3bdacb8f46 | ||
|
|
b4f9c224d3 | ||
|
|
5ec0399c81 | ||
|
|
b464fdc333 | ||
|
|
53825500db | ||
|
|
f2ac790752 | ||
|
|
0d8805cdee | ||
|
|
656e24ac9b | ||
|
|
6718b37403 | ||
|
|
c9e5e784fc | ||
|
|
f92f958682 | ||
|
|
f63fab0676 | ||
|
|
cfc4903c0c | ||
|
|
a527a847fe | ||
|
|
91b0bf8933 | ||
|
|
66d1c96783 | ||
|
|
986128076e | ||
|
|
1de0a53241 | ||
|
|
0ec7eaf606 | ||
|
|
d9fcb0e92b | ||
|
|
f49b4ba4db | ||
|
|
84e708328b | ||
|
|
125bed3f09 | ||
|
|
077e70169d | ||
|
|
e6dc169a05 | ||
|
|
f34c02756d | ||
|
|
1e4c315481 | ||
|
|
a8283a0d00 | ||
|
|
55896669fc | ||
|
|
e341e0b9d2 | ||
|
|
e6538c83bb | ||
|
|
92e1285ea5 | ||
|
|
2aabd1d90e | ||
|
|
7b8b778f83 | ||
|
|
7c8dc57d55 | ||
|
|
fe95fae5f2 | ||
|
|
ce8a95abf7 | ||
|
|
c8e7e543d6 | ||
|
|
a9dbb15ffa | ||
|
|
cf64043f7d | ||
|
|
ccaff92c18 | ||
|
|
585b5c922a | ||
|
|
ea80c2224c | ||
|
|
8b0f56c1a6 |
@@ -25,6 +25,7 @@ model_cache/
|
|||||||
reasonix.toml
|
reasonix.toml
|
||||||
.reasonix/
|
.reasonix/
|
||||||
.codegraph/
|
.codegraph/
|
||||||
|
.playwright-mcp/
|
||||||
|
|
||||||
# Vue widgets development cache (but keep build output)
|
# Vue widgets development cache (but keep build output)
|
||||||
vue-widgets/node_modules/
|
vue-widgets/node_modules/
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ COVERAGE_FILE=coverage/backend/.coverage pytest \
|
|||||||
--cov-report=xml:coverage/backend/coverage.xml
|
--cov-report=xml:coverage/backend/coverage.xml
|
||||||
```
|
```
|
||||||
|
|
||||||
### Frontend Development (Standalone Web UI)
|
### Frontend Development (LoRA Manager Web UI)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install
|
npm install
|
||||||
@@ -137,7 +137,13 @@ npm run test:coverage # Generate coverage report
|
|||||||
- Dual mode: ComfyUI plugin (folder_paths) vs standalone (settings.json)
|
- Dual mode: ComfyUI plugin (folder_paths) vs standalone (settings.json)
|
||||||
- Detection: `os.environ.get("LORA_MANAGER_STANDALONE", "0") == "1"`
|
- Detection: `os.environ.get("LORA_MANAGER_STANDALONE", "0") == "1"`
|
||||||
- Run `python scripts/sync_translation_keys.py` after adding UI strings to `locales/en.json`
|
- Run `python scripts/sync_translation_keys.py` after adding UI strings to `locales/en.json`
|
||||||
- Symlinks require normalized paths
|
- Symlinks require normalized paths.
|
||||||
|
**Business paths vs real paths**: All stored paths and operation routing use the
|
||||||
|
original paths as they appear under configured model roots — symlinks are NOT
|
||||||
|
resolved. `os.path.realpath` is only for scanner dedup and the symlink cache.
|
||||||
|
Any path passed to `os.remove`/`os.rename`/`shutil.move` or validated by a
|
||||||
|
containment check MUST use the business path (i.e. `os.path.abspath`, not
|
||||||
|
`realpath`).
|
||||||
|
|
||||||
## Git / Commit Messages
|
## Git / Commit Messages
|
||||||
|
|
||||||
@@ -148,9 +154,9 @@ npm run test:coverage # Generate coverage report
|
|||||||
|
|
||||||
## Frontend UI Architecture
|
## Frontend UI Architecture
|
||||||
|
|
||||||
### 1. Standalone Web UI
|
### 1. LoRA Manager Web UI
|
||||||
- Location: `./static/` and `./templates/`
|
- Location: `./static/` and `./templates/`
|
||||||
- Tech: Vanilla JS + CSS, served by standalone server
|
- Tech: Vanilla JS + CSS, served by the hosting server (ComfyUI app in plugin mode, `standalone.py` in standalone mode)
|
||||||
- Tests via npm in root directory
|
- Tests via npm in root directory
|
||||||
|
|
||||||
### 2. ComfyUI Custom Node Widgets
|
### 2. ComfyUI Custom Node Widgets
|
||||||
|
|||||||
+10
@@ -17,6 +17,8 @@ try: # pragma: no cover - import fallback for pytest collection
|
|||||||
from .py.nodes.lora_cycler import LoraCyclerLM
|
from .py.nodes.lora_cycler import LoraCyclerLM
|
||||||
from .py.nodes.lora_info import LoraInfoLM
|
from .py.nodes.lora_info import LoraInfoLM
|
||||||
from .py.nodes.lora_syntax_to_path import LoraSyntaxToPath
|
from .py.nodes.lora_syntax_to_path import LoraSyntaxToPath
|
||||||
|
from .py.nodes.create_hook_lora import CreateHookLoraLM
|
||||||
|
from .py.nodes.metadata_overwrite import MetadataOverwriteLM
|
||||||
from .py.metadata_collector import init as init_metadata_collector
|
from .py.metadata_collector import init as init_metadata_collector
|
||||||
except (
|
except (
|
||||||
ImportError
|
ImportError
|
||||||
@@ -62,6 +64,12 @@ except (
|
|||||||
LoraSyntaxToPath = importlib.import_module(
|
LoraSyntaxToPath = importlib.import_module(
|
||||||
"py.nodes.lora_syntax_to_path"
|
"py.nodes.lora_syntax_to_path"
|
||||||
).LoraSyntaxToPath
|
).LoraSyntaxToPath
|
||||||
|
CreateHookLoraLM = importlib.import_module(
|
||||||
|
"py.nodes.create_hook_lora"
|
||||||
|
).CreateHookLoraLM
|
||||||
|
MetadataOverwriteLM = importlib.import_module(
|
||||||
|
"py.nodes.metadata_overwrite"
|
||||||
|
).MetadataOverwriteLM
|
||||||
init_metadata_collector = importlib.import_module("py.metadata_collector").init
|
init_metadata_collector = importlib.import_module("py.metadata_collector").init
|
||||||
|
|
||||||
NODE_CLASS_MAPPINGS = {
|
NODE_CLASS_MAPPINGS = {
|
||||||
@@ -83,6 +91,8 @@ NODE_CLASS_MAPPINGS = {
|
|||||||
LoraCyclerLM.NAME: LoraCyclerLM,
|
LoraCyclerLM.NAME: LoraCyclerLM,
|
||||||
LoraInfoLM.NAME: LoraInfoLM,
|
LoraInfoLM.NAME: LoraInfoLM,
|
||||||
LoraSyntaxToPath.NAME: LoraSyntaxToPath,
|
LoraSyntaxToPath.NAME: LoraSyntaxToPath,
|
||||||
|
CreateHookLoraLM.NAME: CreateHookLoraLM,
|
||||||
|
MetadataOverwriteLM.NAME: MetadataOverwriteLM,
|
||||||
}
|
}
|
||||||
|
|
||||||
WEB_DIRECTORY = "./web/comfyui"
|
WEB_DIRECTORY = "./web/comfyui"
|
||||||
|
|||||||
+313
-291
File diff suppressed because it is too large
Load Diff
+45
-2
@@ -449,6 +449,12 @@
|
|||||||
"compact": "7 (1080p), 8 (2K), 10 (4K)"
|
"compact": "7 (1080p), 8 (2K), 10 (4K)"
|
||||||
},
|
},
|
||||||
"displayDensityWarning": "Warnung: Höhere Dichten können bei Systemen mit begrenzten Ressourcen zu Performance-Problemen führen.",
|
"displayDensityWarning": "Warnung: Höhere Dichten können bei Systemen mit begrenzten Ressourcen zu Performance-Problemen führen.",
|
||||||
|
"recipesLayout": "Rezepte-Layout",
|
||||||
|
"recipesLayoutHelp": "Wählen Sie, wie Rezeptkarten angeordnet werden: ein einheitliches Raster oder ein Masonry-Layout (Pinterest-Stil), das das Seitenverhältnis jedes Bildes beibehält.",
|
||||||
|
"recipesLayoutOptions": {
|
||||||
|
"grid": "Raster",
|
||||||
|
"masonry": "Masonry"
|
||||||
|
},
|
||||||
"showFolderSidebar": "Ordner-Seitenleiste anzeigen",
|
"showFolderSidebar": "Ordner-Seitenleiste anzeigen",
|
||||||
"showFolderSidebarHelp": "Blenden Sie die Ordner-Navigationsleiste auf den Modellseiten ein oder aus. Wenn deaktiviert, bleiben Seitenleiste und Hoverbereich verborgen.",
|
"showFolderSidebarHelp": "Blenden Sie die Ordner-Navigationsleiste auf den Modellseiten ein oder aus. Wenn deaktiviert, bleiben Seitenleiste und Hoverbereich verborgen.",
|
||||||
"cardInfoDisplay": "Karten-Info-Anzeige",
|
"cardInfoDisplay": "Karten-Info-Anzeige",
|
||||||
@@ -678,6 +684,7 @@
|
|||||||
"deepseek": "DeepSeek",
|
"deepseek": "DeepSeek",
|
||||||
"groq": "Groq",
|
"groq": "Groq",
|
||||||
"openrouter": "OpenRouter",
|
"openrouter": "OpenRouter",
|
||||||
|
"google": "Gemini",
|
||||||
"opencode-go": "OpenCode Go",
|
"opencode-go": "OpenCode Go",
|
||||||
"custom": "Benutzerdefiniert (OpenAI-kompatibel)"
|
"custom": "Benutzerdefiniert (OpenAI-kompatibel)"
|
||||||
},
|
},
|
||||||
@@ -714,7 +721,9 @@
|
|||||||
"versionsCount": "Lokale Versionen",
|
"versionsCount": "Lokale Versionen",
|
||||||
"versionsCountDesc": "Meiste Versionen zuerst",
|
"versionsCountDesc": "Meiste Versionen zuerst",
|
||||||
"versionsCountAsc": "Wenigste Versionen zuerst",
|
"versionsCountAsc": "Wenigste Versionen zuerst",
|
||||||
"versionIdDesc": "Neueste Version zuerst"
|
"versionIdDesc": "Neueste Version zuerst",
|
||||||
|
"random": "Zufällig",
|
||||||
|
"randomAction": "Zufällig mischen"
|
||||||
},
|
},
|
||||||
"refresh": {
|
"refresh": {
|
||||||
"title": "Modelliste aktualisieren",
|
"title": "Modelliste aktualisieren",
|
||||||
@@ -771,6 +780,8 @@
|
|||||||
"deleteAll": "Ausgewählte löschen",
|
"deleteAll": "Ausgewählte löschen",
|
||||||
"downloadMissingLoras": "Fehlende LoRAs herunterladen",
|
"downloadMissingLoras": "Fehlende LoRAs herunterladen",
|
||||||
"downloadExamples": "Beispielbilder herunterladen",
|
"downloadExamples": "Beispielbilder herunterladen",
|
||||||
|
"downloadMissingExamples": "Fehlende herunterladen",
|
||||||
|
"reprocessExamples": "Alle erneut verarbeiten",
|
||||||
"clear": "Auswahl löschen",
|
"clear": "Auswahl löschen",
|
||||||
"skipMetadataRefreshCount": "Überspringen({count} Modelle)",
|
"skipMetadataRefreshCount": "Überspringen({count} Modelle)",
|
||||||
"resumeMetadataRefreshCount": "Fortsetzen({count} Modelle)",
|
"resumeMetadataRefreshCount": "Fortsetzen({count} Modelle)",
|
||||||
@@ -806,6 +817,8 @@
|
|||||||
"sendToWorkflowReplace": "An Workflow senden (Ersetzen)",
|
"sendToWorkflowReplace": "An Workflow senden (Ersetzen)",
|
||||||
"openExamples": "Beispiele-Ordner öffnen",
|
"openExamples": "Beispiele-Ordner öffnen",
|
||||||
"downloadExamples": "Beispielbilder herunterladen",
|
"downloadExamples": "Beispielbilder herunterladen",
|
||||||
|
"downloadMissingExamples": "Fehlende herunterladen",
|
||||||
|
"reprocessExamples": "Alle erneut verarbeiten",
|
||||||
"replacePreview": "Vorschau ersetzen",
|
"replacePreview": "Vorschau ersetzen",
|
||||||
"setContentRating": "Inhaltsbewertung festlegen",
|
"setContentRating": "Inhaltsbewertung festlegen",
|
||||||
"moveToFolder": "In Ordner verschieben",
|
"moveToFolder": "In Ordner verschieben",
|
||||||
@@ -1548,6 +1561,7 @@
|
|||||||
"empty": "Noch keine Versionshistorie für dieses Modell vorhanden.",
|
"empty": "Noch keine Versionshistorie für dieses Modell vorhanden.",
|
||||||
"error": "Versionen konnten nicht geladen werden.",
|
"error": "Versionen konnten nicht geladen werden.",
|
||||||
"missingModelId": "Für dieses Modell ist keine Civitai-Model-ID vorhanden.",
|
"missingModelId": "Für dieses Modell ist keine Civitai-Model-ID vorhanden.",
|
||||||
|
"hfGroupInfo": "Dies ist eine HuggingFace-Modellgruppe. Öffnen Sie die Bibliothek, um alle Versionen im Raster zu sehen.",
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"delete": "Diese Version aus Ihrer Bibliothek löschen?"
|
"delete": "Diese Version aus Ihrer Bibliothek löschen?"
|
||||||
},
|
},
|
||||||
@@ -1574,6 +1588,21 @@
|
|||||||
"downloadCsv": "CSV herunterladen",
|
"downloadCsv": "CSV herunterladen",
|
||||||
"columnModelName": "Modellname",
|
"columnModelName": "Modellname",
|
||||||
"columnError": "Fehler"
|
"columnError": "Fehler"
|
||||||
|
},
|
||||||
|
"downloadBatchSummary": {
|
||||||
|
"title": "Zusammenfassung des Batch-Downloads",
|
||||||
|
"statSuccess": "Erfolgreich",
|
||||||
|
"statFailed": "Fehlgeschlagen",
|
||||||
|
"statTotal": "Gesamt",
|
||||||
|
"successMessage": "Alle {count} Modelle erfolgreich heruntergeladen",
|
||||||
|
"completedWithErrors": "Abgeschlossen, aber mit Fehlern",
|
||||||
|
"failed": "Download fehlgeschlagen",
|
||||||
|
"failedItems": "Fehlgeschlagene Elemente ({count})",
|
||||||
|
"columnName": "Modellname",
|
||||||
|
"columnError": "Fehler",
|
||||||
|
"close": "Schließen",
|
||||||
|
"copyReport": "Bericht kopieren",
|
||||||
|
"retryFailed": "Fehlgeschlagene erneut versuchen ({count})"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"modelTags": {
|
"modelTags": {
|
||||||
@@ -1751,6 +1780,12 @@
|
|||||||
"checkingMessage": "Bitte warten Sie, während wir nach der neuesten Version suchen.",
|
"checkingMessage": "Bitte warten Sie, während wir nach der neuesten Version suchen.",
|
||||||
"showNotifications": "Update-Benachrichtigungen anzeigen",
|
"showNotifications": "Update-Benachrichtigungen anzeigen",
|
||||||
"latestBadge": "Neueste",
|
"latestBadge": "Neueste",
|
||||||
|
"latestMain": "Main-Branch",
|
||||||
|
"channel": "Update-Kanal",
|
||||||
|
"channels": {
|
||||||
|
"release": "Release",
|
||||||
|
"nightly": "Nightly"
|
||||||
|
},
|
||||||
"updateProgress": {
|
"updateProgress": {
|
||||||
"preparing": "Update wird vorbereitet...",
|
"preparing": "Update wird vorbereitet...",
|
||||||
"installing": "Update wird installiert...",
|
"installing": "Update wird installiert...",
|
||||||
@@ -1771,6 +1806,15 @@
|
|||||||
"warning": "Warnung: Nightly Builds können experimentelle Funktionen enthalten und könnten instabil sein.",
|
"warning": "Warnung: Nightly Builds können experimentelle Funktionen enthalten und könnten instabil sein.",
|
||||||
"enable": "Nightly Updates aktivieren"
|
"enable": "Nightly Updates aktivieren"
|
||||||
},
|
},
|
||||||
|
"channelSwitch": {
|
||||||
|
"nightlyTitle": "Zu Nightly-Kanal wechseln",
|
||||||
|
"nightlyMessage": "Der Wechsel zu Nightly initialisiert ein Git-Repository und verfolgt die neuesten Commits des main-Branches. Updates sind häufiger, können aber instabil sein. Sie können jederzeit zu Release zurückwechseln.",
|
||||||
|
"releaseTitle": "Zu Release-Kanal wechseln",
|
||||||
|
"releaseMessage": "Der Wechsel zu Release checkt den neuesten stabilen Versions-Tag aus. Sie können jederzeit zu Nightly zurückwechseln.",
|
||||||
|
"switching": "Wechsle zu {channel}-Kanal...",
|
||||||
|
"completed": "Erfolgreich zu {channel}-Kanal gewechselt",
|
||||||
|
"failed": "Kanalwechsel fehlgeschlagen"
|
||||||
|
},
|
||||||
"banners": {
|
"banners": {
|
||||||
"recent": "Neueste Mitteilungen",
|
"recent": "Neueste Mitteilungen",
|
||||||
"empty": "Keine aktuellen Banner verfügbar.",
|
"empty": "Keine aktuellen Banner verfügbar.",
|
||||||
@@ -2015,7 +2059,6 @@
|
|||||||
"presetNameTooLong": "Voreinstellungsname darf maximal {max} Zeichen haben",
|
"presetNameTooLong": "Voreinstellungsname darf maximal {max} Zeichen haben",
|
||||||
"presetNameInvalidChars": "Voreinstellungsname enthält ungültige Zeichen",
|
"presetNameInvalidChars": "Voreinstellungsname enthält ungültige Zeichen",
|
||||||
"presetNameExists": "Eine Voreinstellung mit diesem Namen existiert bereits",
|
"presetNameExists": "Eine Voreinstellung mit diesem Namen existiert bereits",
|
||||||
"maxPresetsReached": "Maximal {max} Voreinstellungen erlaubt. Löschen Sie eine, um weitere hinzuzufügen.",
|
|
||||||
"presetNotFound": "Voreinstellung nicht gefunden",
|
"presetNotFound": "Voreinstellung nicht gefunden",
|
||||||
"invalidPreset": "Ungültige Voreinstellungsdaten",
|
"invalidPreset": "Ungültige Voreinstellungsdaten",
|
||||||
"deletePresetFailed": "Fehler beim Löschen der Voreinstellung",
|
"deletePresetFailed": "Fehler beim Löschen der Voreinstellung",
|
||||||
|
|||||||
+45
-2
@@ -449,6 +449,12 @@
|
|||||||
"compact": "7 (1080p), 8 (2K), 10 (4K)"
|
"compact": "7 (1080p), 8 (2K), 10 (4K)"
|
||||||
},
|
},
|
||||||
"displayDensityWarning": "Warning: Higher densities may cause performance issues on systems with limited resources.",
|
"displayDensityWarning": "Warning: Higher densities may cause performance issues on systems with limited resources.",
|
||||||
|
"recipesLayout": "Recipes Layout",
|
||||||
|
"recipesLayoutHelp": "Choose how recipe cards are arranged: a uniform grid or a masonry (Pinterest-style) layout that preserves each image's aspect ratio.",
|
||||||
|
"recipesLayoutOptions": {
|
||||||
|
"grid": "Grid",
|
||||||
|
"masonry": "Masonry"
|
||||||
|
},
|
||||||
"showFolderSidebar": "Show Folder Sidebar",
|
"showFolderSidebar": "Show Folder Sidebar",
|
||||||
"showFolderSidebarHelp": "Toggle the folder navigation sidebar on model pages. When disabled, the sidebar and hover area stay hidden.",
|
"showFolderSidebarHelp": "Toggle the folder navigation sidebar on model pages. When disabled, the sidebar and hover area stay hidden.",
|
||||||
"cardInfoDisplay": "Card Info Display",
|
"cardInfoDisplay": "Card Info Display",
|
||||||
@@ -678,6 +684,7 @@
|
|||||||
"deepseek": "DeepSeek",
|
"deepseek": "DeepSeek",
|
||||||
"groq": "Groq",
|
"groq": "Groq",
|
||||||
"openrouter": "OpenRouter",
|
"openrouter": "OpenRouter",
|
||||||
|
"google": "Gemini",
|
||||||
"opencode-go": "OpenCode Go",
|
"opencode-go": "OpenCode Go",
|
||||||
"custom": "Custom (OpenAI-compatible)"
|
"custom": "Custom (OpenAI-compatible)"
|
||||||
},
|
},
|
||||||
@@ -714,7 +721,9 @@
|
|||||||
"versionsCount": "Local Versions",
|
"versionsCount": "Local Versions",
|
||||||
"versionsCountDesc": "Most versions first",
|
"versionsCountDesc": "Most versions first",
|
||||||
"versionsCountAsc": "Fewest versions first",
|
"versionsCountAsc": "Fewest versions first",
|
||||||
"versionIdDesc": "Newest version first"
|
"versionIdDesc": "Newest version first",
|
||||||
|
"random": "Random",
|
||||||
|
"randomAction": "Randomize (shuffle)"
|
||||||
},
|
},
|
||||||
"refresh": {
|
"refresh": {
|
||||||
"title": "Refresh model list",
|
"title": "Refresh model list",
|
||||||
@@ -771,6 +780,8 @@
|
|||||||
"deleteAll": "Delete Selected",
|
"deleteAll": "Delete Selected",
|
||||||
"downloadMissingLoras": "Download Missing LoRAs",
|
"downloadMissingLoras": "Download Missing LoRAs",
|
||||||
"downloadExamples": "Download Example Images",
|
"downloadExamples": "Download Example Images",
|
||||||
|
"downloadMissingExamples": "Download Missing",
|
||||||
|
"reprocessExamples": "Re-process All",
|
||||||
"clear": "Clear Selection",
|
"clear": "Clear Selection",
|
||||||
"skipMetadataRefreshCount": "Skip ({count} models)",
|
"skipMetadataRefreshCount": "Skip ({count} models)",
|
||||||
"resumeMetadataRefreshCount": "Resume ({count} models)",
|
"resumeMetadataRefreshCount": "Resume ({count} models)",
|
||||||
@@ -806,6 +817,8 @@
|
|||||||
"sendToWorkflowReplace": "Send to Workflow (Replace)",
|
"sendToWorkflowReplace": "Send to Workflow (Replace)",
|
||||||
"openExamples": "Open Examples Folder",
|
"openExamples": "Open Examples Folder",
|
||||||
"downloadExamples": "Download Example Images",
|
"downloadExamples": "Download Example Images",
|
||||||
|
"downloadMissingExamples": "Download Missing",
|
||||||
|
"reprocessExamples": "Re-process All",
|
||||||
"replacePreview": "Replace Preview",
|
"replacePreview": "Replace Preview",
|
||||||
"setContentRating": "Set Content Rating",
|
"setContentRating": "Set Content Rating",
|
||||||
"moveToFolder": "Move to Folder",
|
"moveToFolder": "Move to Folder",
|
||||||
@@ -1548,6 +1561,7 @@
|
|||||||
"empty": "No version history available for this model yet.",
|
"empty": "No version history available for this model yet.",
|
||||||
"error": "Failed to load versions.",
|
"error": "Failed to load versions.",
|
||||||
"missingModelId": "This model is missing a Civitai model id.",
|
"missingModelId": "This model is missing a Civitai model id.",
|
||||||
|
"hfGroupInfo": "This is a HuggingFace model group. Open the library to see all versions in the grid.",
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"delete": "Delete this version from your library?"
|
"delete": "Delete this version from your library?"
|
||||||
},
|
},
|
||||||
@@ -1574,6 +1588,21 @@
|
|||||||
"downloadCsv": "Download CSV",
|
"downloadCsv": "Download CSV",
|
||||||
"columnModelName": "Model Name",
|
"columnModelName": "Model Name",
|
||||||
"columnError": "Error"
|
"columnError": "Error"
|
||||||
|
},
|
||||||
|
"downloadBatchSummary": {
|
||||||
|
"title": "Batch Download Summary",
|
||||||
|
"statSuccess": "Success",
|
||||||
|
"statFailed": "Failed",
|
||||||
|
"statTotal": "Total",
|
||||||
|
"successMessage": "All {count} models downloaded successfully",
|
||||||
|
"completedWithErrors": "Completed with errors",
|
||||||
|
"failed": "Download failed",
|
||||||
|
"failedItems": "Failed Items ({count})",
|
||||||
|
"columnName": "Model Name",
|
||||||
|
"columnError": "Error",
|
||||||
|
"close": "Close",
|
||||||
|
"copyReport": "Copy Report",
|
||||||
|
"retryFailed": "Retry Failed ({count})"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"modelTags": {
|
"modelTags": {
|
||||||
@@ -1751,6 +1780,12 @@
|
|||||||
"checkingMessage": "Please wait while we check for the latest version.",
|
"checkingMessage": "Please wait while we check for the latest version.",
|
||||||
"showNotifications": "Show update notifications",
|
"showNotifications": "Show update notifications",
|
||||||
"latestBadge": "Latest",
|
"latestBadge": "Latest",
|
||||||
|
"latestMain": "Latest main",
|
||||||
|
"channel": "Update Channel",
|
||||||
|
"channels": {
|
||||||
|
"release": "Release",
|
||||||
|
"nightly": "Nightly"
|
||||||
|
},
|
||||||
"updateProgress": {
|
"updateProgress": {
|
||||||
"preparing": "Preparing update...",
|
"preparing": "Preparing update...",
|
||||||
"installing": "Installing update...",
|
"installing": "Installing update...",
|
||||||
@@ -1771,6 +1806,15 @@
|
|||||||
"warning": "Warning: Nightly builds may contain experimental features and could be unstable.",
|
"warning": "Warning: Nightly builds may contain experimental features and could be unstable.",
|
||||||
"enable": "Enable Nightly Updates"
|
"enable": "Enable Nightly Updates"
|
||||||
},
|
},
|
||||||
|
"channelSwitch": {
|
||||||
|
"nightlyTitle": "Switch to Nightly Channel",
|
||||||
|
"nightlyMessage": "Switching to Nightly will initialize a Git repository and track the latest main branch commits. Updates will be more frequent but may be unstable. You can switch back to Release at any time.",
|
||||||
|
"releaseTitle": "Switch to Release Channel",
|
||||||
|
"releaseMessage": "Switching to Release will checkout the latest stable release tag. You can switch back to Nightly at any time.",
|
||||||
|
"switching": "Switching to {channel} channel...",
|
||||||
|
"completed": "Successfully switched to {channel} channel",
|
||||||
|
"failed": "Failed to switch channel"
|
||||||
|
},
|
||||||
"banners": {
|
"banners": {
|
||||||
"recent": "Recent messages",
|
"recent": "Recent messages",
|
||||||
"empty": "No recent banners yet.",
|
"empty": "No recent banners yet.",
|
||||||
@@ -2015,7 +2059,6 @@
|
|||||||
"presetNameTooLong": "Preset name must be {max} characters or less",
|
"presetNameTooLong": "Preset name must be {max} characters or less",
|
||||||
"presetNameInvalidChars": "Preset name contains invalid characters",
|
"presetNameInvalidChars": "Preset name contains invalid characters",
|
||||||
"presetNameExists": "A preset with this name already exists",
|
"presetNameExists": "A preset with this name already exists",
|
||||||
"maxPresetsReached": "Maximum {max} presets allowed. Delete one to add more.",
|
|
||||||
"presetNotFound": "Preset not found",
|
"presetNotFound": "Preset not found",
|
||||||
"invalidPreset": "Invalid preset data",
|
"invalidPreset": "Invalid preset data",
|
||||||
"deletePresetFailed": "Failed to delete preset",
|
"deletePresetFailed": "Failed to delete preset",
|
||||||
|
|||||||
+46
-3
@@ -449,6 +449,12 @@
|
|||||||
"compact": "7 (1080p), 8 (2K), 10 (4K)"
|
"compact": "7 (1080p), 8 (2K), 10 (4K)"
|
||||||
},
|
},
|
||||||
"displayDensityWarning": "Advertencia: Densidades más altas pueden causar problemas de rendimiento en sistemas con recursos limitados.",
|
"displayDensityWarning": "Advertencia: Densidades más altas pueden causar problemas de rendimiento en sistemas con recursos limitados.",
|
||||||
|
"recipesLayout": "Diseño de recetas",
|
||||||
|
"recipesLayoutHelp": "Elige cómo se organizan las tarjetas de recetas: una cuadrícula uniforme o un diseño masonry (estilo Pinterest) que conserva la proporción de aspecto de cada imagen.",
|
||||||
|
"recipesLayoutOptions": {
|
||||||
|
"grid": "Cuadrícula",
|
||||||
|
"masonry": "Masonry"
|
||||||
|
},
|
||||||
"showFolderSidebar": "Mostrar barra lateral de carpetas",
|
"showFolderSidebar": "Mostrar barra lateral de carpetas",
|
||||||
"showFolderSidebarHelp": "Activa o desactiva la barra lateral de navegación de carpetas en las páginas de modelos. Cuando está desactivada, la barra lateral y el área de desplazamiento permanecen ocultas.",
|
"showFolderSidebarHelp": "Activa o desactiva la barra lateral de navegación de carpetas en las páginas de modelos. Cuando está desactivada, la barra lateral y el área de desplazamiento permanecen ocultas.",
|
||||||
"cardInfoDisplay": "Visualización de información de tarjeta",
|
"cardInfoDisplay": "Visualización de información de tarjeta",
|
||||||
@@ -678,6 +684,7 @@
|
|||||||
"deepseek": "DeepSeek",
|
"deepseek": "DeepSeek",
|
||||||
"groq": "Groq",
|
"groq": "Groq",
|
||||||
"openrouter": "OpenRouter",
|
"openrouter": "OpenRouter",
|
||||||
|
"google": "Gemini",
|
||||||
"opencode-go": "OpenCode Go",
|
"opencode-go": "OpenCode Go",
|
||||||
"custom": "Personalizado (compatible con OpenAI)"
|
"custom": "Personalizado (compatible con OpenAI)"
|
||||||
},
|
},
|
||||||
@@ -714,7 +721,9 @@
|
|||||||
"versionsCount": "Versiones locales",
|
"versionsCount": "Versiones locales",
|
||||||
"versionsCountDesc": "Más versiones primero",
|
"versionsCountDesc": "Más versiones primero",
|
||||||
"versionsCountAsc": "Menos versiones primero",
|
"versionsCountAsc": "Menos versiones primero",
|
||||||
"versionIdDesc": "Versión más nueva primero"
|
"versionIdDesc": "Versión más nueva primero",
|
||||||
|
"random": "Aleatorio",
|
||||||
|
"randomAction": "Aleatorizar (barajar)"
|
||||||
},
|
},
|
||||||
"refresh": {
|
"refresh": {
|
||||||
"title": "Actualizar lista de modelos",
|
"title": "Actualizar lista de modelos",
|
||||||
@@ -771,6 +780,8 @@
|
|||||||
"deleteAll": "Eliminar seleccionados",
|
"deleteAll": "Eliminar seleccionados",
|
||||||
"downloadMissingLoras": "Descargar LoRAs faltantes",
|
"downloadMissingLoras": "Descargar LoRAs faltantes",
|
||||||
"downloadExamples": "Descargar imágenes de ejemplo",
|
"downloadExamples": "Descargar imágenes de ejemplo",
|
||||||
|
"downloadMissingExamples": "Descargar faltantes",
|
||||||
|
"reprocessExamples": "Reprocesar todo",
|
||||||
"clear": "Limpiar selección",
|
"clear": "Limpiar selección",
|
||||||
"skipMetadataRefreshCount": "Omitir({count} modelos)",
|
"skipMetadataRefreshCount": "Omitir({count} modelos)",
|
||||||
"resumeMetadataRefreshCount": "Reanudar({count} modelos)",
|
"resumeMetadataRefreshCount": "Reanudar({count} modelos)",
|
||||||
@@ -806,6 +817,8 @@
|
|||||||
"sendToWorkflowReplace": "Enviar al flujo de trabajo (Reemplazar)",
|
"sendToWorkflowReplace": "Enviar al flujo de trabajo (Reemplazar)",
|
||||||
"openExamples": "Abrir carpeta de ejemplos",
|
"openExamples": "Abrir carpeta de ejemplos",
|
||||||
"downloadExamples": "Descargar imágenes de ejemplo",
|
"downloadExamples": "Descargar imágenes de ejemplo",
|
||||||
|
"downloadMissingExamples": "Descargar faltantes",
|
||||||
|
"reprocessExamples": "Reprocesar todo",
|
||||||
"replacePreview": "Reemplazar vista previa",
|
"replacePreview": "Reemplazar vista previa",
|
||||||
"setContentRating": "Establecer clasificación de contenido",
|
"setContentRating": "Establecer clasificación de contenido",
|
||||||
"moveToFolder": "Mover a carpeta",
|
"moveToFolder": "Mover a carpeta",
|
||||||
@@ -1548,6 +1561,7 @@
|
|||||||
"empty": "Aún no hay historial de versiones para este modelo.",
|
"empty": "Aún no hay historial de versiones para este modelo.",
|
||||||
"error": "No se pudieron cargar las versiones.",
|
"error": "No se pudieron cargar las versiones.",
|
||||||
"missingModelId": "Este modelo no tiene un ID de modelo de Civitai.",
|
"missingModelId": "Este modelo no tiene un ID de modelo de Civitai.",
|
||||||
|
"hfGroupInfo": "Este es un grupo de modelos de HuggingFace. Abra la biblioteca para ver todas las versiones en la cuadrícula.",
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"delete": "¿Eliminar esta versión de tu biblioteca?"
|
"delete": "¿Eliminar esta versión de tu biblioteca?"
|
||||||
},
|
},
|
||||||
@@ -1574,6 +1588,21 @@
|
|||||||
"downloadCsv": "Descargar CSV",
|
"downloadCsv": "Descargar CSV",
|
||||||
"columnModelName": "Nombre del modelo",
|
"columnModelName": "Nombre del modelo",
|
||||||
"columnError": "Error"
|
"columnError": "Error"
|
||||||
|
},
|
||||||
|
"downloadBatchSummary": {
|
||||||
|
"title": "Resumen de descarga por lotes",
|
||||||
|
"statSuccess": "Correctos",
|
||||||
|
"statFailed": "Fallidos",
|
||||||
|
"statTotal": "Total",
|
||||||
|
"successMessage": "Todos los {count} modelos se descargaron correctamente",
|
||||||
|
"completedWithErrors": "Completado con errores",
|
||||||
|
"failed": "Descarga fallida",
|
||||||
|
"failedItems": "Elementos fallidos ({count})",
|
||||||
|
"columnName": "Nombre del modelo",
|
||||||
|
"columnError": "Error",
|
||||||
|
"close": "Cerrar",
|
||||||
|
"copyReport": "Copiar informe",
|
||||||
|
"retryFailed": "Reintentar fallidos ({count})"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"modelTags": {
|
"modelTags": {
|
||||||
@@ -1750,7 +1779,13 @@
|
|||||||
"checkingUpdates": "Comprobando actualizaciones...",
|
"checkingUpdates": "Comprobando actualizaciones...",
|
||||||
"checkingMessage": "Por favor espera mientras comprobamos la última versión.",
|
"checkingMessage": "Por favor espera mientras comprobamos la última versión.",
|
||||||
"showNotifications": "Mostrar notificaciones de actualización",
|
"showNotifications": "Mostrar notificaciones de actualización",
|
||||||
"latestBadge": "Último",
|
"latestBadge": "Última",
|
||||||
|
"latestMain": "Rama main",
|
||||||
|
"channel": "Canal de actualizacion",
|
||||||
|
"channels": {
|
||||||
|
"release": "Release",
|
||||||
|
"nightly": "Nightly"
|
||||||
|
},
|
||||||
"updateProgress": {
|
"updateProgress": {
|
||||||
"preparing": "Preparando actualización...",
|
"preparing": "Preparando actualización...",
|
||||||
"installing": "Instalando actualización...",
|
"installing": "Instalando actualización...",
|
||||||
@@ -1771,6 +1806,15 @@
|
|||||||
"warning": "Advertencia: Las compilaciones nocturnas pueden contener características experimentales y podrían ser inestables.",
|
"warning": "Advertencia: Las compilaciones nocturnas pueden contener características experimentales y podrían ser inestables.",
|
||||||
"enable": "Habilitar actualizaciones nocturnas"
|
"enable": "Habilitar actualizaciones nocturnas"
|
||||||
},
|
},
|
||||||
|
"channelSwitch": {
|
||||||
|
"nightlyTitle": "Cambiar a canal Nightly",
|
||||||
|
"nightlyMessage": "Cambiar a Nightly inicializara un repositorio Git y seguira los ultimos commits de la rama main. Las actualizaciones son mas frecuentes pero pueden ser inestables. Puede volver a Release en cualquier momento.",
|
||||||
|
"releaseTitle": "Cambiar a canal Release",
|
||||||
|
"releaseMessage": "Cambiar a Release hara checkout de la ultima etiqueta de version estable. Puede volver a Nightly en cualquier momento.",
|
||||||
|
"switching": "Cambiando a canal {channel}...",
|
||||||
|
"completed": "Cambio a canal {channel} exitoso",
|
||||||
|
"failed": "Error al cambiar de canal"
|
||||||
|
},
|
||||||
"banners": {
|
"banners": {
|
||||||
"recent": "Notificaciones recientes",
|
"recent": "Notificaciones recientes",
|
||||||
"empty": "No hay banners recientes.",
|
"empty": "No hay banners recientes.",
|
||||||
@@ -2015,7 +2059,6 @@
|
|||||||
"presetNameTooLong": "El nombre del preajuste debe tener {max} caracteres o menos",
|
"presetNameTooLong": "El nombre del preajuste debe tener {max} caracteres o menos",
|
||||||
"presetNameInvalidChars": "El nombre del preajuste contiene caracteres inválidos",
|
"presetNameInvalidChars": "El nombre del preajuste contiene caracteres inválidos",
|
||||||
"presetNameExists": "Ya existe un preajuste con este nombre",
|
"presetNameExists": "Ya existe un preajuste con este nombre",
|
||||||
"maxPresetsReached": "Máximo {max} preajustes permitidos. Elimine uno para agregar más.",
|
|
||||||
"presetNotFound": "Preajuste no encontrado",
|
"presetNotFound": "Preajuste no encontrado",
|
||||||
"invalidPreset": "Datos de preajuste inválidos",
|
"invalidPreset": "Datos de preajuste inválidos",
|
||||||
"deletePresetFailed": "Error al eliminar el preajuste",
|
"deletePresetFailed": "Error al eliminar el preajuste",
|
||||||
|
|||||||
+46
-3
@@ -449,6 +449,12 @@
|
|||||||
"compact": "7 (1080p), 8 (2K), 10 (4K)"
|
"compact": "7 (1080p), 8 (2K), 10 (4K)"
|
||||||
},
|
},
|
||||||
"displayDensityWarning": "Attention : Des densités plus élevées peuvent causer des problèmes de performance sur les systèmes avec des ressources limitées.",
|
"displayDensityWarning": "Attention : Des densités plus élevées peuvent causer des problèmes de performance sur les systèmes avec des ressources limitées.",
|
||||||
|
"recipesLayout": "Disposition des recettes",
|
||||||
|
"recipesLayoutHelp": "Choisissez comment les cartes de recettes sont organisées : une grille uniforme ou une disposition masonry (style Pinterest) qui préserve le rapport d'aspect de chaque image.",
|
||||||
|
"recipesLayoutOptions": {
|
||||||
|
"grid": "Grille",
|
||||||
|
"masonry": "Masonry"
|
||||||
|
},
|
||||||
"showFolderSidebar": "Afficher la barre latérale des dossiers",
|
"showFolderSidebar": "Afficher la barre latérale des dossiers",
|
||||||
"showFolderSidebarHelp": "Activez ou désactivez la barre latérale de navigation des dossiers sur les pages de modèles. Lorsqu'elle est désactivée, la barre latérale et la zone de survol restent masquées.",
|
"showFolderSidebarHelp": "Activez ou désactivez la barre latérale de navigation des dossiers sur les pages de modèles. Lorsqu'elle est désactivée, la barre latérale et la zone de survol restent masquées.",
|
||||||
"cardInfoDisplay": "Affichage des informations de carte",
|
"cardInfoDisplay": "Affichage des informations de carte",
|
||||||
@@ -678,6 +684,7 @@
|
|||||||
"deepseek": "DeepSeek",
|
"deepseek": "DeepSeek",
|
||||||
"groq": "Groq",
|
"groq": "Groq",
|
||||||
"openrouter": "OpenRouter",
|
"openrouter": "OpenRouter",
|
||||||
|
"google": "Gemini",
|
||||||
"opencode-go": "OpenCode Go",
|
"opencode-go": "OpenCode Go",
|
||||||
"custom": "Personnalisé (compatible OpenAI)"
|
"custom": "Personnalisé (compatible OpenAI)"
|
||||||
},
|
},
|
||||||
@@ -714,7 +721,9 @@
|
|||||||
"versionsCount": "Versions locales",
|
"versionsCount": "Versions locales",
|
||||||
"versionsCountDesc": "Plus de versions d'abord",
|
"versionsCountDesc": "Plus de versions d'abord",
|
||||||
"versionsCountAsc": "Moins de versions d'abord",
|
"versionsCountAsc": "Moins de versions d'abord",
|
||||||
"versionIdDesc": "Version la plus récente d'abord"
|
"versionIdDesc": "Version la plus récente d'abord",
|
||||||
|
"random": "Aléatoire",
|
||||||
|
"randomAction": "Aléatoire (mélanger)"
|
||||||
},
|
},
|
||||||
"refresh": {
|
"refresh": {
|
||||||
"title": "Actualiser la liste des modèles",
|
"title": "Actualiser la liste des modèles",
|
||||||
@@ -771,6 +780,8 @@
|
|||||||
"deleteAll": "Supprimer la sélection",
|
"deleteAll": "Supprimer la sélection",
|
||||||
"downloadMissingLoras": "Télécharger les LoRAs manquants",
|
"downloadMissingLoras": "Télécharger les LoRAs manquants",
|
||||||
"downloadExamples": "Télécharger les images d'exemple",
|
"downloadExamples": "Télécharger les images d'exemple",
|
||||||
|
"downloadMissingExamples": "Télécharger les manquantes",
|
||||||
|
"reprocessExamples": "Tout retraiter",
|
||||||
"clear": "Effacer la sélection",
|
"clear": "Effacer la sélection",
|
||||||
"skipMetadataRefreshCount": "Ignorer({count} modèles)",
|
"skipMetadataRefreshCount": "Ignorer({count} modèles)",
|
||||||
"resumeMetadataRefreshCount": "Reprendre({count} modèles)",
|
"resumeMetadataRefreshCount": "Reprendre({count} modèles)",
|
||||||
@@ -806,6 +817,8 @@
|
|||||||
"sendToWorkflowReplace": "Envoyer vers le workflow (Remplacer)",
|
"sendToWorkflowReplace": "Envoyer vers le workflow (Remplacer)",
|
||||||
"openExamples": "Ouvrir le dossier d'exemples",
|
"openExamples": "Ouvrir le dossier d'exemples",
|
||||||
"downloadExamples": "Télécharger les images d'exemple",
|
"downloadExamples": "Télécharger les images d'exemple",
|
||||||
|
"downloadMissingExamples": "Télécharger les manquantes",
|
||||||
|
"reprocessExamples": "Tout retraiter",
|
||||||
"replacePreview": "Remplacer l'aperçu",
|
"replacePreview": "Remplacer l'aperçu",
|
||||||
"setContentRating": "Définir la classification du contenu",
|
"setContentRating": "Définir la classification du contenu",
|
||||||
"moveToFolder": "Déplacer vers un dossier",
|
"moveToFolder": "Déplacer vers un dossier",
|
||||||
@@ -1548,6 +1561,7 @@
|
|||||||
"empty": "Aucun historique de versions n'est disponible pour ce modèle pour le moment.",
|
"empty": "Aucun historique de versions n'est disponible pour ce modèle pour le moment.",
|
||||||
"error": "Échec du chargement des versions.",
|
"error": "Échec du chargement des versions.",
|
||||||
"missingModelId": "Ce modèle ne possède pas d'identifiant de modèle Civitai.",
|
"missingModelId": "Ce modèle ne possède pas d'identifiant de modèle Civitai.",
|
||||||
|
"hfGroupInfo": "Ceci est un groupe de modèles HuggingFace. Ouvrez la bibliothèque pour voir toutes les versions dans la grille.",
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"delete": "Supprimer cette version de votre bibliothèque ?"
|
"delete": "Supprimer cette version de votre bibliothèque ?"
|
||||||
},
|
},
|
||||||
@@ -1574,6 +1588,21 @@
|
|||||||
"downloadCsv": "Télécharger CSV",
|
"downloadCsv": "Télécharger CSV",
|
||||||
"columnModelName": "Nom du modèle",
|
"columnModelName": "Nom du modèle",
|
||||||
"columnError": "Erreur"
|
"columnError": "Erreur"
|
||||||
|
},
|
||||||
|
"downloadBatchSummary": {
|
||||||
|
"title": "Résumé du téléchargement groupé",
|
||||||
|
"statSuccess": "Réussis",
|
||||||
|
"statFailed": "Échoués",
|
||||||
|
"statTotal": "Total",
|
||||||
|
"successMessage": "Les {count} modèles ont été téléchargés avec succès",
|
||||||
|
"completedWithErrors": "Terminé avec des erreurs",
|
||||||
|
"failed": "Échec du téléchargement",
|
||||||
|
"failedItems": "Éléments échoués ({count})",
|
||||||
|
"columnName": "Nom du modèle",
|
||||||
|
"columnError": "Erreur",
|
||||||
|
"close": "Fermer",
|
||||||
|
"copyReport": "Copier le rapport",
|
||||||
|
"retryFailed": "Réessayer les échecs ({count})"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"modelTags": {
|
"modelTags": {
|
||||||
@@ -1750,7 +1779,13 @@
|
|||||||
"checkingUpdates": "Vérification des mises à jour...",
|
"checkingUpdates": "Vérification des mises à jour...",
|
||||||
"checkingMessage": "Veuillez patienter pendant la vérification de la dernière version.",
|
"checkingMessage": "Veuillez patienter pendant la vérification de la dernière version.",
|
||||||
"showNotifications": "Afficher les notifications de mise à jour",
|
"showNotifications": "Afficher les notifications de mise à jour",
|
||||||
"latestBadge": "Dernier",
|
"latestBadge": "Dernière",
|
||||||
|
"latestMain": "Branche main",
|
||||||
|
"channel": "Canal de mise a jour",
|
||||||
|
"channels": {
|
||||||
|
"release": "Release",
|
||||||
|
"nightly": "Nightly"
|
||||||
|
},
|
||||||
"updateProgress": {
|
"updateProgress": {
|
||||||
"preparing": "Préparation de la mise à jour...",
|
"preparing": "Préparation de la mise à jour...",
|
||||||
"installing": "Installation de la mise à jour...",
|
"installing": "Installation de la mise à jour...",
|
||||||
@@ -1771,6 +1806,15 @@
|
|||||||
"warning": "Attention : Les versions nightly peuvent contenir des fonctionnalités expérimentales et être instables.",
|
"warning": "Attention : Les versions nightly peuvent contenir des fonctionnalités expérimentales et être instables.",
|
||||||
"enable": "Activer les mises à jour nightly"
|
"enable": "Activer les mises à jour nightly"
|
||||||
},
|
},
|
||||||
|
"channelSwitch": {
|
||||||
|
"nightlyTitle": "Passer au canal Nightly",
|
||||||
|
"nightlyMessage": "Passer a Nightly initialisera un depot Git et suivra les derniers commits de la branche main. Les mises a jour sont plus frequentes mais peuvent etre instables. Vous pouvez revenir a Release a tout moment.",
|
||||||
|
"releaseTitle": "Passer au canal Release",
|
||||||
|
"releaseMessage": "Passer a Release passera au dernier tag de version stable. Vous pouvez revenir a Nightly a tout moment.",
|
||||||
|
"switching": "Passage au canal {channel}...",
|
||||||
|
"completed": "Basculement vers le canal {channel} reussi",
|
||||||
|
"failed": "Echec du changement de canal"
|
||||||
|
},
|
||||||
"banners": {
|
"banners": {
|
||||||
"recent": "Messages récents",
|
"recent": "Messages récents",
|
||||||
"empty": "Aucune bannière récente.",
|
"empty": "Aucune bannière récente.",
|
||||||
@@ -2015,7 +2059,6 @@
|
|||||||
"presetNameTooLong": "Le nom du préréglage doit contenir au maximum {max} caractères",
|
"presetNameTooLong": "Le nom du préréglage doit contenir au maximum {max} caractères",
|
||||||
"presetNameInvalidChars": "Le nom du préréglage contient des caractères invalides",
|
"presetNameInvalidChars": "Le nom du préréglage contient des caractères invalides",
|
||||||
"presetNameExists": "Un préréglage avec ce nom existe déjà",
|
"presetNameExists": "Un préréglage avec ce nom existe déjà",
|
||||||
"maxPresetsReached": "Maximum {max} préréglages autorisés. Supprimez-en un pour en ajouter plus.",
|
|
||||||
"presetNotFound": "Préréglage non trouvé",
|
"presetNotFound": "Préréglage non trouvé",
|
||||||
"invalidPreset": "Données de préréglage invalides",
|
"invalidPreset": "Données de préréglage invalides",
|
||||||
"deletePresetFailed": "Échec de la suppression du préréglage",
|
"deletePresetFailed": "Échec de la suppression du préréglage",
|
||||||
|
|||||||
+46
-3
@@ -449,6 +449,12 @@
|
|||||||
"compact": "7 (1080p), 8 (2K), 10 (4K)"
|
"compact": "7 (1080p), 8 (2K), 10 (4K)"
|
||||||
},
|
},
|
||||||
"displayDensityWarning": "אזהרה: צפיפויות גבוהות יותר עלולות לגרום לבעיות ביצועים במערכות עם משאבים מוגבלים.",
|
"displayDensityWarning": "אזהרה: צפיפויות גבוהות יותר עלולות לגרום לבעיות ביצועים במערכות עם משאבים מוגבלים.",
|
||||||
|
"recipesLayout": "פריסת מתכונים",
|
||||||
|
"recipesLayoutHelp": "בחר כיצד יסודרו כרטיסי המתכונים: רשת אחידה או פריסת Masonry (בסגנון Pinterest) השומרת על יחס הגובה-רוחב של כל תמונה.",
|
||||||
|
"recipesLayoutOptions": {
|
||||||
|
"grid": "רשת",
|
||||||
|
"masonry": "Masonry"
|
||||||
|
},
|
||||||
"showFolderSidebar": "הצג סרגל צד תיקיות",
|
"showFolderSidebar": "הצג סרגל צד תיקיות",
|
||||||
"showFolderSidebarHelp": "הפעל או כבה את סרגל הצד לניווט תיקיות בדפי המודל. כאשר הוא כבוי, סרגל הצד ואזור הריחוף נשארים מוסתרים.",
|
"showFolderSidebarHelp": "הפעל או כבה את סרגל הצד לניווט תיקיות בדפי המודל. כאשר הוא כבוי, סרגל הצד ואזור הריחוף נשארים מוסתרים.",
|
||||||
"cardInfoDisplay": "תצוגת מידע בכרטיס",
|
"cardInfoDisplay": "תצוגת מידע בכרטיס",
|
||||||
@@ -678,6 +684,7 @@
|
|||||||
"deepseek": "DeepSeek",
|
"deepseek": "DeepSeek",
|
||||||
"groq": "Groq",
|
"groq": "Groq",
|
||||||
"openrouter": "OpenRouter",
|
"openrouter": "OpenRouter",
|
||||||
|
"google": "Gemini",
|
||||||
"opencode-go": "OpenCode Go",
|
"opencode-go": "OpenCode Go",
|
||||||
"custom": "מותאם אישית (תואם OpenAI)"
|
"custom": "מותאם אישית (תואם OpenAI)"
|
||||||
},
|
},
|
||||||
@@ -714,7 +721,9 @@
|
|||||||
"versionsCount": "גרסאות מקומיות",
|
"versionsCount": "גרסאות מקומיות",
|
||||||
"versionsCountDesc": "הכי הרבה גרסאות ראשונות",
|
"versionsCountDesc": "הכי הרבה גרסאות ראשונות",
|
||||||
"versionsCountAsc": "הכי מעט גרסאות ראשונות",
|
"versionsCountAsc": "הכי מעט גרסאות ראשונות",
|
||||||
"versionIdDesc": "גרסה חדשה ביותר ראשונה"
|
"versionIdDesc": "גרסה חדשה ביותר ראשונה",
|
||||||
|
"random": "אקראי",
|
||||||
|
"randomAction": "ערבוב אקראי"
|
||||||
},
|
},
|
||||||
"refresh": {
|
"refresh": {
|
||||||
"title": "רענן רשימת מודלים",
|
"title": "רענן רשימת מודלים",
|
||||||
@@ -771,6 +780,8 @@
|
|||||||
"deleteAll": "מחק נבחרים",
|
"deleteAll": "מחק נבחרים",
|
||||||
"downloadMissingLoras": "הורדת LoRAs חסרים",
|
"downloadMissingLoras": "הורדת LoRAs חסרים",
|
||||||
"downloadExamples": "הורד תמונות דוגמה",
|
"downloadExamples": "הורד תמונות דוגמה",
|
||||||
|
"downloadMissingExamples": "הורדת חסרים",
|
||||||
|
"reprocessExamples": "עיבוד מחדש של הכול",
|
||||||
"clear": "נקה בחירה",
|
"clear": "נקה בחירה",
|
||||||
"skipMetadataRefreshCount": "דילוג({count} מודלים)",
|
"skipMetadataRefreshCount": "דילוג({count} מודלים)",
|
||||||
"resumeMetadataRefreshCount": "המשך({count} מודלים)",
|
"resumeMetadataRefreshCount": "המשך({count} מודלים)",
|
||||||
@@ -806,6 +817,8 @@
|
|||||||
"sendToWorkflowReplace": "שלח ל-Workflow (החלף)",
|
"sendToWorkflowReplace": "שלח ל-Workflow (החלף)",
|
||||||
"openExamples": "פתח תיקיית דוגמאות",
|
"openExamples": "פתח תיקיית דוגמאות",
|
||||||
"downloadExamples": "הורד תמונות דוגמה",
|
"downloadExamples": "הורד תמונות דוגמה",
|
||||||
|
"downloadMissingExamples": "הורדת חסרים",
|
||||||
|
"reprocessExamples": "עיבוד מחדש של הכול",
|
||||||
"replacePreview": "החלף תצוגה מקדימה",
|
"replacePreview": "החלף תצוגה מקדימה",
|
||||||
"setContentRating": "הגדר דירוג תוכן",
|
"setContentRating": "הגדר דירוג תוכן",
|
||||||
"moveToFolder": "העבר לתיקייה",
|
"moveToFolder": "העבר לתיקייה",
|
||||||
@@ -1548,6 +1561,7 @@
|
|||||||
"empty": "אין עדיין היסטוריית גרסאות למודל זה.",
|
"empty": "אין עדיין היסטוריית גרסאות למודל זה.",
|
||||||
"error": "טעינת הגרסאות נכשלה.",
|
"error": "טעינת הגרסאות נכשלה.",
|
||||||
"missingModelId": "למודל זה אין מזהה מודל של Civitai.",
|
"missingModelId": "למודל זה אין מזהה מודל של Civitai.",
|
||||||
|
"hfGroupInfo": "זוהי קבוצת דגמים של HuggingFace. פתח את הספרייה כדי לראות את כל הגרסאות ברשת.",
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"delete": "למחוק גרסה זו מהספרייה שלך?"
|
"delete": "למחוק גרסה זו מהספרייה שלך?"
|
||||||
},
|
},
|
||||||
@@ -1574,6 +1588,21 @@
|
|||||||
"downloadCsv": "הורד CSV",
|
"downloadCsv": "הורד CSV",
|
||||||
"columnModelName": "שם המודל",
|
"columnModelName": "שם המודל",
|
||||||
"columnError": "שגיאה"
|
"columnError": "שגיאה"
|
||||||
|
},
|
||||||
|
"downloadBatchSummary": {
|
||||||
|
"title": "סיכום הורדה בכמות",
|
||||||
|
"statSuccess": "הצליחו",
|
||||||
|
"statFailed": "נכשלו",
|
||||||
|
"statTotal": "סה\"כ",
|
||||||
|
"successMessage": "כל {count} הדגמים הורדו בהצלחה",
|
||||||
|
"completedWithErrors": "הושלם עם שגיאות",
|
||||||
|
"failed": "ההורדה נכשלה",
|
||||||
|
"failedItems": "פריטים שנכשלו ({count})",
|
||||||
|
"columnName": "שם הדגם",
|
||||||
|
"columnError": "שגיאה",
|
||||||
|
"close": "סגור",
|
||||||
|
"copyReport": "העתק דוח",
|
||||||
|
"retryFailed": "נסה שוב ({count})"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"modelTags": {
|
"modelTags": {
|
||||||
@@ -1750,7 +1779,13 @@
|
|||||||
"checkingUpdates": "בודק עדכונים...",
|
"checkingUpdates": "בודק עדכונים...",
|
||||||
"checkingMessage": "אנא המתן בזמן שאנו בודקים את הגרסה האחרונה.",
|
"checkingMessage": "אנא המתן בזמן שאנו בודקים את הגרסה האחרונה.",
|
||||||
"showNotifications": "הצג התראות עדכון",
|
"showNotifications": "הצג התראות עדכון",
|
||||||
"latestBadge": "עדכן",
|
"latestBadge": "אחרון",
|
||||||
|
"latestMain": "ענף main",
|
||||||
|
"channel": "ערוץ עדכון",
|
||||||
|
"channels": {
|
||||||
|
"release": "Release",
|
||||||
|
"nightly": "Nightly"
|
||||||
|
},
|
||||||
"updateProgress": {
|
"updateProgress": {
|
||||||
"preparing": "מכין עדכון...",
|
"preparing": "מכין עדכון...",
|
||||||
"installing": "מתקין עדכון...",
|
"installing": "מתקין עדכון...",
|
||||||
@@ -1771,6 +1806,15 @@
|
|||||||
"warning": "אזהרה: גרסאות ליליות עשויות להכיל תכונות ניסיוניות ועלולות להיות לא יציבות.",
|
"warning": "אזהרה: גרסאות ליליות עשויות להכיל תכונות ניסיוניות ועלולות להיות לא יציבות.",
|
||||||
"enable": "הפעל עדכונים ליליים"
|
"enable": "הפעל עדכונים ליליים"
|
||||||
},
|
},
|
||||||
|
"channelSwitch": {
|
||||||
|
"nightlyTitle": "מעבר לערוץ Nightly",
|
||||||
|
"nightlyMessage": "מעבר ל-Nightly יאתחל מאגר Git ויעקוב אחר הקומיטים האחרונים בענף main. העדכונים תכופים יותר אך עשויים להיות לא יציבים. ניתן לחזור ל-Release בכל עת.",
|
||||||
|
"releaseTitle": "מעבר לערוץ Release",
|
||||||
|
"releaseMessage": "מעבר ל-Release יעבור לתגית הגרסה היציבה האחרונה. ניתן לחזור ל-Nightly בכל עת.",
|
||||||
|
"switching": "מעבר לערוץ {channel}...",
|
||||||
|
"completed": "המעבר לערוץ {channel} הושלם",
|
||||||
|
"failed": "החלפת ערוץ נכשלה"
|
||||||
|
},
|
||||||
"banners": {
|
"banners": {
|
||||||
"recent": "הודעות אחרונות",
|
"recent": "הודעות אחרונות",
|
||||||
"empty": "אין כרגע באנרים אחרונים.",
|
"empty": "אין כרגע באנרים אחרונים.",
|
||||||
@@ -2015,7 +2059,6 @@
|
|||||||
"presetNameTooLong": "שם קביעה מראש חייב להיות {max} תווים או פחות",
|
"presetNameTooLong": "שם קביעה מראש חייב להיות {max} תווים או פחות",
|
||||||
"presetNameInvalidChars": "שם קביעה מראש מכיל תווים לא חוקיים",
|
"presetNameInvalidChars": "שם קביעה מראש מכיל תווים לא חוקיים",
|
||||||
"presetNameExists": "קביעה מראש עם שם זה כבר קיימת",
|
"presetNameExists": "קביעה מראש עם שם זה כבר קיימת",
|
||||||
"maxPresetsReached": "מותר מקסימום {max} קביעות מראש. מחק אחת כדי להוסיף עוד.",
|
|
||||||
"presetNotFound": "קביעה מראש לא נמצאה",
|
"presetNotFound": "קביעה מראש לא נמצאה",
|
||||||
"invalidPreset": "נתוני קביעה מראש לא חוקיים",
|
"invalidPreset": "נתוני קביעה מראש לא חוקיים",
|
||||||
"deletePresetFailed": "מחיקת קביעה מראש נכשלה",
|
"deletePresetFailed": "מחיקת קביעה מראש נכשלה",
|
||||||
|
|||||||
+45
-2
@@ -449,6 +449,12 @@
|
|||||||
"compact": "7(1080p)、8(2K)、10(4K)"
|
"compact": "7(1080p)、8(2K)、10(4K)"
|
||||||
},
|
},
|
||||||
"displayDensityWarning": "警告:高密度設定は、リソースが限られたシステムでパフォーマンスの問題を引き起こす可能性があります。",
|
"displayDensityWarning": "警告:高密度設定は、リソースが限られたシステムでパフォーマンスの問題を引き起こす可能性があります。",
|
||||||
|
"recipesLayout": "レシピのレイアウト",
|
||||||
|
"recipesLayoutHelp": "レシピカードの配置方法を選択:均一なグリッド、または各画像のアスペクト比を保持するメイソンリー(Pinterest スタイル)レイアウト。",
|
||||||
|
"recipesLayoutOptions": {
|
||||||
|
"grid": "グリッド",
|
||||||
|
"masonry": "メイソンリー"
|
||||||
|
},
|
||||||
"showFolderSidebar": "フォルダサイドバーを表示",
|
"showFolderSidebar": "フォルダサイドバーを表示",
|
||||||
"showFolderSidebarHelp": "モデルページのフォルダナビゲーションサイドバーを表示/非表示にします。無効にするとサイドバーとホバーエリアは表示されません。",
|
"showFolderSidebarHelp": "モデルページのフォルダナビゲーションサイドバーを表示/非表示にします。無効にするとサイドバーとホバーエリアは表示されません。",
|
||||||
"cardInfoDisplay": "カード情報表示",
|
"cardInfoDisplay": "カード情報表示",
|
||||||
@@ -678,6 +684,7 @@
|
|||||||
"deepseek": "DeepSeek",
|
"deepseek": "DeepSeek",
|
||||||
"groq": "Groq",
|
"groq": "Groq",
|
||||||
"openrouter": "OpenRouter",
|
"openrouter": "OpenRouter",
|
||||||
|
"google": "Gemini",
|
||||||
"opencode-go": "OpenCode Go",
|
"opencode-go": "OpenCode Go",
|
||||||
"custom": "カスタム(OpenAI 互換)"
|
"custom": "カスタム(OpenAI 互換)"
|
||||||
},
|
},
|
||||||
@@ -714,7 +721,9 @@
|
|||||||
"versionsCount": "ローカルバージョン数",
|
"versionsCount": "ローカルバージョン数",
|
||||||
"versionsCountDesc": "バージョン数の多い順",
|
"versionsCountDesc": "バージョン数の多い順",
|
||||||
"versionsCountAsc": "バージョン数の少ない順",
|
"versionsCountAsc": "バージョン数の少ない順",
|
||||||
"versionIdDesc": "最新バージョン順"
|
"versionIdDesc": "最新バージョン順",
|
||||||
|
"random": "ランダム",
|
||||||
|
"randomAction": "シャッフル(ランダム)"
|
||||||
},
|
},
|
||||||
"refresh": {
|
"refresh": {
|
||||||
"title": "モデルリストを更新",
|
"title": "モデルリストを更新",
|
||||||
@@ -771,6 +780,8 @@
|
|||||||
"deleteAll": "選択したものを削除",
|
"deleteAll": "選択したものを削除",
|
||||||
"downloadMissingLoras": "不足している LoRA をダウンロード",
|
"downloadMissingLoras": "不足している LoRA をダウンロード",
|
||||||
"downloadExamples": "例画像をダウンロード",
|
"downloadExamples": "例画像をダウンロード",
|
||||||
|
"downloadMissingExamples": "不足分をダウンロード",
|
||||||
|
"reprocessExamples": "すべて再処理",
|
||||||
"clear": "選択をクリア",
|
"clear": "選択をクリア",
|
||||||
"skipMetadataRefreshCount": "スキップ({count}モデル)",
|
"skipMetadataRefreshCount": "スキップ({count}モデル)",
|
||||||
"resumeMetadataRefreshCount": "再開({count}モデル)",
|
"resumeMetadataRefreshCount": "再開({count}モデル)",
|
||||||
@@ -806,6 +817,8 @@
|
|||||||
"sendToWorkflowReplace": "ワークフローに送信(置換)",
|
"sendToWorkflowReplace": "ワークフローに送信(置換)",
|
||||||
"openExamples": "例画像フォルダを開く",
|
"openExamples": "例画像フォルダを開く",
|
||||||
"downloadExamples": "例画像をダウンロード",
|
"downloadExamples": "例画像をダウンロード",
|
||||||
|
"downloadMissingExamples": "不足分をダウンロード",
|
||||||
|
"reprocessExamples": "すべて再処理",
|
||||||
"replacePreview": "プレビューを置換",
|
"replacePreview": "プレビューを置換",
|
||||||
"setContentRating": "コンテンツレーティングを設定",
|
"setContentRating": "コンテンツレーティングを設定",
|
||||||
"moveToFolder": "フォルダに移動",
|
"moveToFolder": "フォルダに移動",
|
||||||
@@ -1548,6 +1561,7 @@
|
|||||||
"empty": "このモデルにはまだバージョン履歴がありません。",
|
"empty": "このモデルにはまだバージョン履歴がありません。",
|
||||||
"error": "バージョンの読み込みに失敗しました。",
|
"error": "バージョンの読み込みに失敗しました。",
|
||||||
"missingModelId": "このモデルにはCivitaiのモデルIDがありません。",
|
"missingModelId": "このモデルにはCivitaiのモデルIDがありません。",
|
||||||
|
"hfGroupInfo": "これは HuggingFace モデルグループです。ライブラリを開いてグリッドですべてのバージョンを表示してください。",
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"delete": "このバージョンをライブラリから削除しますか?"
|
"delete": "このバージョンをライブラリから削除しますか?"
|
||||||
},
|
},
|
||||||
@@ -1574,6 +1588,21 @@
|
|||||||
"downloadCsv": "CSVをダウンロード",
|
"downloadCsv": "CSVをダウンロード",
|
||||||
"columnModelName": "モデル名",
|
"columnModelName": "モデル名",
|
||||||
"columnError": "エラー"
|
"columnError": "エラー"
|
||||||
|
},
|
||||||
|
"downloadBatchSummary": {
|
||||||
|
"title": "バッチダウンロードの概要",
|
||||||
|
"statSuccess": "成功",
|
||||||
|
"statFailed": "失敗",
|
||||||
|
"statTotal": "合計",
|
||||||
|
"successMessage": "{count} 個のモデルがすべて正常にダウンロードされました",
|
||||||
|
"completedWithErrors": "エラーありで完了",
|
||||||
|
"failed": "ダウンロードに失敗しました",
|
||||||
|
"failedItems": "失敗した項目({count})",
|
||||||
|
"columnName": "モデル名",
|
||||||
|
"columnError": "エラー",
|
||||||
|
"close": "閉じる",
|
||||||
|
"copyReport": "レポートをコピー",
|
||||||
|
"retryFailed": "失敗した項目を再試行({count})"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"modelTags": {
|
"modelTags": {
|
||||||
@@ -1751,6 +1780,12 @@
|
|||||||
"checkingMessage": "最新バージョンを確認しています。お待ちください。",
|
"checkingMessage": "最新バージョンを確認しています。お待ちください。",
|
||||||
"showNotifications": "更新通知を表示",
|
"showNotifications": "更新通知を表示",
|
||||||
"latestBadge": "最新",
|
"latestBadge": "最新",
|
||||||
|
"latestMain": "Main ブランチ",
|
||||||
|
"channel": "更新チャンネル",
|
||||||
|
"channels": {
|
||||||
|
"release": "リリース",
|
||||||
|
"nightly": "ナイトリー"
|
||||||
|
},
|
||||||
"updateProgress": {
|
"updateProgress": {
|
||||||
"preparing": "更新を準備中...",
|
"preparing": "更新を準備中...",
|
||||||
"installing": "更新をインストール中...",
|
"installing": "更新をインストール中...",
|
||||||
@@ -1771,6 +1806,15 @@
|
|||||||
"warning": "警告:ナイトリービルドには実験的機能が含まれており、不安定な場合があります。",
|
"warning": "警告:ナイトリービルドには実験的機能が含まれており、不安定な場合があります。",
|
||||||
"enable": "ナイトリー更新を有効にする"
|
"enable": "ナイトリー更新を有効にする"
|
||||||
},
|
},
|
||||||
|
"channelSwitch": {
|
||||||
|
"nightlyTitle": "ナイトリーチャンネルに切り替え",
|
||||||
|
"nightlyMessage": "ナイトリーに切り替えると、Gitリポジトリが初期化され、mainブランチの最新コミットを追跡します。更新頻度は高くなりますが、不安定な場合があります。いつでもリリース版に戻せます。",
|
||||||
|
"releaseTitle": "リリースチャンネルに切り替え",
|
||||||
|
"releaseMessage": "リリースに切り替えると、最新の安定版タグにチェックアウトされます。いつでもNightlyに戻せます。",
|
||||||
|
"switching": "{channel} チャンネルに切り替え中...",
|
||||||
|
"completed": "{channel} チャンネルに切り替えました",
|
||||||
|
"failed": "チャンネルの切り替えに失敗しました"
|
||||||
|
},
|
||||||
"banners": {
|
"banners": {
|
||||||
"recent": "最近の通知",
|
"recent": "最近の通知",
|
||||||
"empty": "最近のバナーはありません。",
|
"empty": "最近のバナーはありません。",
|
||||||
@@ -2015,7 +2059,6 @@
|
|||||||
"presetNameTooLong": "プリセット名は{max}文字以内にしてください",
|
"presetNameTooLong": "プリセット名は{max}文字以内にしてください",
|
||||||
"presetNameInvalidChars": "プリセット名に使用できない文字が含まれています",
|
"presetNameInvalidChars": "プリセット名に使用できない文字が含まれています",
|
||||||
"presetNameExists": "同じ名前のプリセットが既に存在します",
|
"presetNameExists": "同じ名前のプリセットが既に存在します",
|
||||||
"maxPresetsReached": "プリセットは最大{max}個までです。追加するには既存のものを削除してください。",
|
|
||||||
"presetNotFound": "プリセットが見つかりません",
|
"presetNotFound": "プリセットが見つかりません",
|
||||||
"invalidPreset": "無効なプリセットデータです",
|
"invalidPreset": "無効なプリセットデータです",
|
||||||
"deletePresetFailed": "プリセットの削除に失敗しました",
|
"deletePresetFailed": "プリセットの削除に失敗しました",
|
||||||
|
|||||||
+45
-2
@@ -449,6 +449,12 @@
|
|||||||
"compact": "7개 (1080p), 8개 (2K), 10개 (4K)"
|
"compact": "7개 (1080p), 8개 (2K), 10개 (4K)"
|
||||||
},
|
},
|
||||||
"displayDensityWarning": "경고: 높은 밀도는 리소스가 제한된 시스템에서 성능 문제를 일으킬 수 있습니다.",
|
"displayDensityWarning": "경고: 높은 밀도는 리소스가 제한된 시스템에서 성능 문제를 일으킬 수 있습니다.",
|
||||||
|
"recipesLayout": "레시피 레이아웃",
|
||||||
|
"recipesLayoutHelp": "레시피 카드의 배열 방식을 선택하세요: 균일한 그리드 또는 각 이미지의 종횡비를 유지하는 메이슨리(Pinterest 스타일) 레이아웃.",
|
||||||
|
"recipesLayoutOptions": {
|
||||||
|
"grid": "그리드",
|
||||||
|
"masonry": "메이슨리"
|
||||||
|
},
|
||||||
"showFolderSidebar": "폴더 사이드바 표시",
|
"showFolderSidebar": "폴더 사이드바 표시",
|
||||||
"showFolderSidebarHelp": "모델 페이지에서 폴더 탐색 사이드바를 켜거나 끕니다. 비활성화하면 사이드바와 호버 영역이 표시되지 않습니다.",
|
"showFolderSidebarHelp": "모델 페이지에서 폴더 탐색 사이드바를 켜거나 끕니다. 비활성화하면 사이드바와 호버 영역이 표시되지 않습니다.",
|
||||||
"cardInfoDisplay": "카드 정보 표시",
|
"cardInfoDisplay": "카드 정보 표시",
|
||||||
@@ -678,6 +684,7 @@
|
|||||||
"deepseek": "DeepSeek",
|
"deepseek": "DeepSeek",
|
||||||
"groq": "Groq",
|
"groq": "Groq",
|
||||||
"openrouter": "OpenRouter",
|
"openrouter": "OpenRouter",
|
||||||
|
"google": "Gemini",
|
||||||
"opencode-go": "OpenCode Go",
|
"opencode-go": "OpenCode Go",
|
||||||
"custom": "사용자 정의 (OpenAI 호환)"
|
"custom": "사용자 정의 (OpenAI 호환)"
|
||||||
},
|
},
|
||||||
@@ -714,7 +721,9 @@
|
|||||||
"versionsCount": "로컬 버전 수",
|
"versionsCount": "로컬 버전 수",
|
||||||
"versionsCountDesc": "버전 수 많은 순",
|
"versionsCountDesc": "버전 수 많은 순",
|
||||||
"versionsCountAsc": "버전 수 적은 순",
|
"versionsCountAsc": "버전 수 적은 순",
|
||||||
"versionIdDesc": "최신 버전순"
|
"versionIdDesc": "최신 버전순",
|
||||||
|
"random": "랜덤",
|
||||||
|
"randomAction": "셔플 (무작위)"
|
||||||
},
|
},
|
||||||
"refresh": {
|
"refresh": {
|
||||||
"title": "모델 목록 새로고침",
|
"title": "모델 목록 새로고침",
|
||||||
@@ -771,6 +780,8 @@
|
|||||||
"deleteAll": "선택된 항목 삭제",
|
"deleteAll": "선택된 항목 삭제",
|
||||||
"downloadMissingLoras": "누락된 LoRA 다운로드",
|
"downloadMissingLoras": "누락된 LoRA 다운로드",
|
||||||
"downloadExamples": "예시 이미지 다운로드",
|
"downloadExamples": "예시 이미지 다운로드",
|
||||||
|
"downloadMissingExamples": "누락된 것만 다운로드",
|
||||||
|
"reprocessExamples": "모두 다시 처리",
|
||||||
"clear": "선택 지우기",
|
"clear": "선택 지우기",
|
||||||
"skipMetadataRefreshCount": "건너뛰기({count}개 모델)",
|
"skipMetadataRefreshCount": "건너뛰기({count}개 모델)",
|
||||||
"resumeMetadataRefreshCount": "재개({count}개 모델)",
|
"resumeMetadataRefreshCount": "재개({count}개 모델)",
|
||||||
@@ -806,6 +817,8 @@
|
|||||||
"sendToWorkflowReplace": "워크플로로 전송 (교체)",
|
"sendToWorkflowReplace": "워크플로로 전송 (교체)",
|
||||||
"openExamples": "예시 폴더 열기",
|
"openExamples": "예시 폴더 열기",
|
||||||
"downloadExamples": "예시 이미지 다운로드",
|
"downloadExamples": "예시 이미지 다운로드",
|
||||||
|
"downloadMissingExamples": "누락된 것만 다운로드",
|
||||||
|
"reprocessExamples": "모두 다시 처리",
|
||||||
"replacePreview": "미리보기 교체",
|
"replacePreview": "미리보기 교체",
|
||||||
"setContentRating": "콘텐츠 등급 설정",
|
"setContentRating": "콘텐츠 등급 설정",
|
||||||
"moveToFolder": "폴더로 이동",
|
"moveToFolder": "폴더로 이동",
|
||||||
@@ -1548,6 +1561,7 @@
|
|||||||
"empty": "이 모델에는 아직 버전 기록이 없습니다.",
|
"empty": "이 모델에는 아직 버전 기록이 없습니다.",
|
||||||
"error": "버전을 불러오지 못했습니다.",
|
"error": "버전을 불러오지 못했습니다.",
|
||||||
"missingModelId": "이 모델에는 Civitai 모델 ID가 없습니다.",
|
"missingModelId": "이 모델에는 Civitai 모델 ID가 없습니다.",
|
||||||
|
"hfGroupInfo": "HuggingFace 모델 그룹입니다. 라이브러리를 열어 그리드에서 모든 버전을 확인하세요.",
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"delete": "이 버전을 라이브러리에서 삭제하시겠습니까?"
|
"delete": "이 버전을 라이브러리에서 삭제하시겠습니까?"
|
||||||
},
|
},
|
||||||
@@ -1574,6 +1588,21 @@
|
|||||||
"downloadCsv": "CSV 다운로드",
|
"downloadCsv": "CSV 다운로드",
|
||||||
"columnModelName": "모델 이름",
|
"columnModelName": "모델 이름",
|
||||||
"columnError": "오류"
|
"columnError": "오류"
|
||||||
|
},
|
||||||
|
"downloadBatchSummary": {
|
||||||
|
"title": "일괄 다운로드 요약",
|
||||||
|
"statSuccess": "성공",
|
||||||
|
"statFailed": "실패",
|
||||||
|
"statTotal": "전체",
|
||||||
|
"successMessage": "{count}개 모델이 모두 성공적으로 다운로드되었습니다",
|
||||||
|
"completedWithErrors": "오류와 함께 완료됨",
|
||||||
|
"failed": "다운로드 실패",
|
||||||
|
"failedItems": "실패한 항목 ({count})",
|
||||||
|
"columnName": "모델 이름",
|
||||||
|
"columnError": "오류",
|
||||||
|
"close": "닫기",
|
||||||
|
"copyReport": "보고서 복사",
|
||||||
|
"retryFailed": "실패 항목 재시도 ({count})"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"modelTags": {
|
"modelTags": {
|
||||||
@@ -1751,6 +1780,12 @@
|
|||||||
"checkingMessage": "최신 버전을 확인하는 동안 잠시 기다려주세요.",
|
"checkingMessage": "최신 버전을 확인하는 동안 잠시 기다려주세요.",
|
||||||
"showNotifications": "업데이트 알림 표시",
|
"showNotifications": "업데이트 알림 표시",
|
||||||
"latestBadge": "최신",
|
"latestBadge": "최신",
|
||||||
|
"latestMain": "Main 브랜치",
|
||||||
|
"channel": "업데이트 채널",
|
||||||
|
"channels": {
|
||||||
|
"release": "릴리스",
|
||||||
|
"nightly": "나이틀리"
|
||||||
|
},
|
||||||
"updateProgress": {
|
"updateProgress": {
|
||||||
"preparing": "업데이트 준비 중...",
|
"preparing": "업데이트 준비 중...",
|
||||||
"installing": "업데이트 설치 중...",
|
"installing": "업데이트 설치 중...",
|
||||||
@@ -1771,6 +1806,15 @@
|
|||||||
"warning": "경고: 나이틀리 빌드는 실험적 기능을 포함할 수 있으며 불안정할 수 있습니다.",
|
"warning": "경고: 나이틀리 빌드는 실험적 기능을 포함할 수 있으며 불안정할 수 있습니다.",
|
||||||
"enable": "나이틀리 업데이트 활성화"
|
"enable": "나이틀리 업데이트 활성화"
|
||||||
},
|
},
|
||||||
|
"channelSwitch": {
|
||||||
|
"nightlyTitle": "나이틀리 채널로 전환",
|
||||||
|
"nightlyMessage": "나이틀리로 전환하면 Git 저장소가 초기화되고 main 브랜치의 최신 커밋을 추적합니다. 업데이트 빈도는 높지만 불안정할 수 있습니다. 언제든지 릴리스로 돌아갈 수 있습니다.",
|
||||||
|
"releaseTitle": "릴리스 채널로 전환",
|
||||||
|
"releaseMessage": "릴리스로 전환하면 최신 안정 버전 태그로 체크아웃됩니다. 언제든지 나이틀리로 돌아갈 수 있습니다.",
|
||||||
|
"switching": "{channel} 채널로 전환 중...",
|
||||||
|
"completed": "{channel} 채널로 전환 완료",
|
||||||
|
"failed": "채널 전환 실패"
|
||||||
|
},
|
||||||
"banners": {
|
"banners": {
|
||||||
"recent": "최근 알림",
|
"recent": "최근 알림",
|
||||||
"empty": "최근 배너가 없습니다.",
|
"empty": "최근 배너가 없습니다.",
|
||||||
@@ -2015,7 +2059,6 @@
|
|||||||
"presetNameTooLong": "프리셋 이름은 {max}자 이하여야 합니다",
|
"presetNameTooLong": "프리셋 이름은 {max}자 이하여야 합니다",
|
||||||
"presetNameInvalidChars": "프리셋 이름에 유효하지 않은 문자가 포함되어 있습니다",
|
"presetNameInvalidChars": "프리셋 이름에 유효하지 않은 문자가 포함되어 있습니다",
|
||||||
"presetNameExists": "동일한 이름의 프리셋이 이미 존재합니다",
|
"presetNameExists": "동일한 이름의 프리셋이 이미 존재합니다",
|
||||||
"maxPresetsReached": "최대 {max}개의 프리셋만 허용됩니다. 더 추가하려면 기존 것을 삭제하세요.",
|
|
||||||
"presetNotFound": "프리셋을 찾을 수 없습니다",
|
"presetNotFound": "프리셋을 찾을 수 없습니다",
|
||||||
"invalidPreset": "잘못된 프리셋 데이터입니다",
|
"invalidPreset": "잘못된 프리셋 데이터입니다",
|
||||||
"deletePresetFailed": "프리셋 삭제에 실패했습니다",
|
"deletePresetFailed": "프리셋 삭제에 실패했습니다",
|
||||||
|
|||||||
+46
-3
@@ -449,6 +449,12 @@
|
|||||||
"compact": "7 (1080p), 8 (2K), 10 (4K)"
|
"compact": "7 (1080p), 8 (2K), 10 (4K)"
|
||||||
},
|
},
|
||||||
"displayDensityWarning": "Предупреждение: Высокая плотность может вызвать проблемы с производительностью на системах с ограниченными ресурсами.",
|
"displayDensityWarning": "Предупреждение: Высокая плотность может вызвать проблемы с производительностью на системах с ограниченными ресурсами.",
|
||||||
|
"recipesLayout": "Макет рецептов",
|
||||||
|
"recipesLayoutHelp": "Выберите, как располагаются карточки рецептов: единая сетка или masonry-макет (в стиле Pinterest), сохраняющий пропорции каждого изображения.",
|
||||||
|
"recipesLayoutOptions": {
|
||||||
|
"grid": "Сетка",
|
||||||
|
"masonry": "Masonry"
|
||||||
|
},
|
||||||
"showFolderSidebar": "Показывать боковую панель папок",
|
"showFolderSidebar": "Показывать боковую панель папок",
|
||||||
"showFolderSidebarHelp": "Включает или выключает боковую панель навигации по папкам на страницах моделей. При отключении панель и область наведения скрыты.",
|
"showFolderSidebarHelp": "Включает или выключает боковую панель навигации по папкам на страницах моделей. При отключении панель и область наведения скрыты.",
|
||||||
"cardInfoDisplay": "Отображение информации карточки",
|
"cardInfoDisplay": "Отображение информации карточки",
|
||||||
@@ -678,6 +684,7 @@
|
|||||||
"deepseek": "DeepSeek",
|
"deepseek": "DeepSeek",
|
||||||
"groq": "Groq",
|
"groq": "Groq",
|
||||||
"openrouter": "OpenRouter",
|
"openrouter": "OpenRouter",
|
||||||
|
"google": "Gemini",
|
||||||
"opencode-go": "OpenCode Go",
|
"opencode-go": "OpenCode Go",
|
||||||
"custom": "Пользовательский (совместимый с OpenAI)"
|
"custom": "Пользовательский (совместимый с OpenAI)"
|
||||||
},
|
},
|
||||||
@@ -714,7 +721,9 @@
|
|||||||
"versionsCount": "Локальные версии",
|
"versionsCount": "Локальные версии",
|
||||||
"versionsCountDesc": "Сначала больше версий",
|
"versionsCountDesc": "Сначала больше версий",
|
||||||
"versionsCountAsc": "Сначала меньше версий",
|
"versionsCountAsc": "Сначала меньше версий",
|
||||||
"versionIdDesc": "Сначала новые версии"
|
"versionIdDesc": "Сначала новые версии",
|
||||||
|
"random": "Случайно",
|
||||||
|
"randomAction": "Перемешать"
|
||||||
},
|
},
|
||||||
"refresh": {
|
"refresh": {
|
||||||
"title": "Обновить список моделей",
|
"title": "Обновить список моделей",
|
||||||
@@ -771,6 +780,8 @@
|
|||||||
"deleteAll": "Удалить выбранные",
|
"deleteAll": "Удалить выбранные",
|
||||||
"downloadMissingLoras": "Скачать отсутствующие LoRAs",
|
"downloadMissingLoras": "Скачать отсутствующие LoRAs",
|
||||||
"downloadExamples": "Загрузить примеры изображений",
|
"downloadExamples": "Загрузить примеры изображений",
|
||||||
|
"downloadMissingExamples": "Скачать недостающие",
|
||||||
|
"reprocessExamples": "Обработать всё заново",
|
||||||
"clear": "Очистить выбор",
|
"clear": "Очистить выбор",
|
||||||
"skipMetadataRefreshCount": "Пропустить({count} моделей)",
|
"skipMetadataRefreshCount": "Пропустить({count} моделей)",
|
||||||
"resumeMetadataRefreshCount": "Возобновить({count} моделей)",
|
"resumeMetadataRefreshCount": "Возобновить({count} моделей)",
|
||||||
@@ -806,6 +817,8 @@
|
|||||||
"sendToWorkflowReplace": "Отправить в Workflow (Заменить)",
|
"sendToWorkflowReplace": "Отправить в Workflow (Заменить)",
|
||||||
"openExamples": "Открыть папку примеров",
|
"openExamples": "Открыть папку примеров",
|
||||||
"downloadExamples": "Загрузить примеры изображений",
|
"downloadExamples": "Загрузить примеры изображений",
|
||||||
|
"downloadMissingExamples": "Скачать недостающие",
|
||||||
|
"reprocessExamples": "Обработать всё заново",
|
||||||
"replacePreview": "Заменить превью",
|
"replacePreview": "Заменить превью",
|
||||||
"setContentRating": "Установить рейтинг контента",
|
"setContentRating": "Установить рейтинг контента",
|
||||||
"moveToFolder": "Переместить в папку",
|
"moveToFolder": "Переместить в папку",
|
||||||
@@ -1548,6 +1561,7 @@
|
|||||||
"empty": "Для этой модели пока нет истории версий.",
|
"empty": "Для этой модели пока нет истории версий.",
|
||||||
"error": "Не удалось загрузить версии.",
|
"error": "Не удалось загрузить версии.",
|
||||||
"missingModelId": "У этой модели отсутствует идентификатор модели Civitai.",
|
"missingModelId": "У этой модели отсутствует идентификатор модели Civitai.",
|
||||||
|
"hfGroupInfo": "Это группа моделей HuggingFace. Откройте библиотеку, чтобы увидеть все версии в сетке.",
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"delete": "Удалить эту версию из библиотеки?"
|
"delete": "Удалить эту версию из библиотеки?"
|
||||||
},
|
},
|
||||||
@@ -1574,6 +1588,21 @@
|
|||||||
"downloadCsv": "Скачать CSV",
|
"downloadCsv": "Скачать CSV",
|
||||||
"columnModelName": "Имя модели",
|
"columnModelName": "Имя модели",
|
||||||
"columnError": "Ошибка"
|
"columnError": "Ошибка"
|
||||||
|
},
|
||||||
|
"downloadBatchSummary": {
|
||||||
|
"title": "Сводка пакетной загрузки",
|
||||||
|
"statSuccess": "Успешно",
|
||||||
|
"statFailed": "Ошибки",
|
||||||
|
"statTotal": "Всего",
|
||||||
|
"successMessage": "Все {count} моделей успешно загружены",
|
||||||
|
"completedWithErrors": "Завершено с ошибками",
|
||||||
|
"failed": "Не удалось загрузить",
|
||||||
|
"failedItems": "Неудачные элементы ({count})",
|
||||||
|
"columnName": "Имя модели",
|
||||||
|
"columnError": "Ошибка",
|
||||||
|
"close": "Закрыть",
|
||||||
|
"copyReport": "Скопировать отчёт",
|
||||||
|
"retryFailed": "Повторить неудачные ({count})"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"modelTags": {
|
"modelTags": {
|
||||||
@@ -1750,7 +1779,13 @@
|
|||||||
"checkingUpdates": "Проверка обновлений...",
|
"checkingUpdates": "Проверка обновлений...",
|
||||||
"checkingMessage": "Пожалуйста, подождите, пока мы проверяем последнюю версию.",
|
"checkingMessage": "Пожалуйста, подождите, пока мы проверяем последнюю версию.",
|
||||||
"showNotifications": "Показывать уведомления об обновлениях",
|
"showNotifications": "Показывать уведомления об обновлениях",
|
||||||
"latestBadge": "Последний",
|
"latestBadge": "Последняя",
|
||||||
|
"latestMain": "Ветка main",
|
||||||
|
"channel": "Канал обновлений",
|
||||||
|
"channels": {
|
||||||
|
"release": "Релиз",
|
||||||
|
"nightly": "Nightly"
|
||||||
|
},
|
||||||
"updateProgress": {
|
"updateProgress": {
|
||||||
"preparing": "Подготовка обновления...",
|
"preparing": "Подготовка обновления...",
|
||||||
"installing": "Установка обновления...",
|
"installing": "Установка обновления...",
|
||||||
@@ -1771,6 +1806,15 @@
|
|||||||
"warning": "Предупреждение: Ночные сборки могут содержать экспериментальные функции и могут быть нестабильными.",
|
"warning": "Предупреждение: Ночные сборки могут содержать экспериментальные функции и могут быть нестабильными.",
|
||||||
"enable": "Включить ночные обновления"
|
"enable": "Включить ночные обновления"
|
||||||
},
|
},
|
||||||
|
"channelSwitch": {
|
||||||
|
"nightlyTitle": "Переключиться на Nightly",
|
||||||
|
"nightlyMessage": "Переключение на Nightly инициализирует Git-репозиторий и отслеживает последние коммиты ветки main. Обновления чаще, но могут быть нестабильными. Вы можете вернуться к Release в любое время.",
|
||||||
|
"releaseTitle": "Переключиться на Release",
|
||||||
|
"releaseMessage": "Переключение на Release выполнит checkout последнего стабильного тега. Вы можете вернуться к Nightly в любое время.",
|
||||||
|
"switching": "Переключение на канал {channel}...",
|
||||||
|
"completed": "Успешно переключено на канал {channel}",
|
||||||
|
"failed": "Не удалось переключить канал"
|
||||||
|
},
|
||||||
"banners": {
|
"banners": {
|
||||||
"recent": "Недавние уведомления",
|
"recent": "Недавние уведомления",
|
||||||
"empty": "Недавних баннеров нет.",
|
"empty": "Недавних баннеров нет.",
|
||||||
@@ -2015,7 +2059,6 @@
|
|||||||
"presetNameTooLong": "Имя пресета должно содержать не более {max} символов",
|
"presetNameTooLong": "Имя пресета должно содержать не более {max} символов",
|
||||||
"presetNameInvalidChars": "Имя пресета содержит недопустимые символы",
|
"presetNameInvalidChars": "Имя пресета содержит недопустимые символы",
|
||||||
"presetNameExists": "Пресет с таким именем уже существует",
|
"presetNameExists": "Пресет с таким именем уже существует",
|
||||||
"maxPresetsReached": "Допустимо максимум {max} пресетов. Удалите один, чтобы добавить больше.",
|
|
||||||
"presetNotFound": "Пресет не найден",
|
"presetNotFound": "Пресет не найден",
|
||||||
"invalidPreset": "Недопустимые данные пресета",
|
"invalidPreset": "Недопустимые данные пресета",
|
||||||
"deletePresetFailed": "Не удалось удалить пресет",
|
"deletePresetFailed": "Не удалось удалить пресет",
|
||||||
|
|||||||
+45
-2
@@ -449,6 +449,12 @@
|
|||||||
"compact": "7(1080p),8(2K),10(4K)"
|
"compact": "7(1080p),8(2K),10(4K)"
|
||||||
},
|
},
|
||||||
"displayDensityWarning": "警告:高密度可能导致资源有限的系统性能下降。",
|
"displayDensityWarning": "警告:高密度可能导致资源有限的系统性能下降。",
|
||||||
|
"recipesLayout": "配方布局",
|
||||||
|
"recipesLayoutHelp": "选择配方卡片的排列方式:统一网格,或保留每张图片原始宽高比的瀑布流(Pinterest 风格)布局。",
|
||||||
|
"recipesLayoutOptions": {
|
||||||
|
"grid": "网格",
|
||||||
|
"masonry": "瀑布流"
|
||||||
|
},
|
||||||
"showFolderSidebar": "显示文件夹侧边栏",
|
"showFolderSidebar": "显示文件夹侧边栏",
|
||||||
"showFolderSidebarHelp": "在模型页面启用或禁用文件夹导航侧边栏。关闭后,侧边栏和悬停区域将保持隐藏。",
|
"showFolderSidebarHelp": "在模型页面启用或禁用文件夹导航侧边栏。关闭后,侧边栏和悬停区域将保持隐藏。",
|
||||||
"cardInfoDisplay": "卡片信息显示",
|
"cardInfoDisplay": "卡片信息显示",
|
||||||
@@ -678,6 +684,7 @@
|
|||||||
"deepseek": "DeepSeek",
|
"deepseek": "DeepSeek",
|
||||||
"groq": "Groq",
|
"groq": "Groq",
|
||||||
"openrouter": "OpenRouter",
|
"openrouter": "OpenRouter",
|
||||||
|
"google": "Gemini",
|
||||||
"opencode-go": "OpenCode Go",
|
"opencode-go": "OpenCode Go",
|
||||||
"custom": "自定义(OpenAI 兼容)"
|
"custom": "自定义(OpenAI 兼容)"
|
||||||
},
|
},
|
||||||
@@ -714,7 +721,9 @@
|
|||||||
"versionsCount": "本地版本数",
|
"versionsCount": "本地版本数",
|
||||||
"versionsCountDesc": "版本数从多到少",
|
"versionsCountDesc": "版本数从多到少",
|
||||||
"versionsCountAsc": "版本数从少到多",
|
"versionsCountAsc": "版本数从少到多",
|
||||||
"versionIdDesc": "最新版本优先"
|
"versionIdDesc": "最新版本优先",
|
||||||
|
"random": "随机",
|
||||||
|
"randomAction": "随机排序(洗牌)"
|
||||||
},
|
},
|
||||||
"refresh": {
|
"refresh": {
|
||||||
"title": "刷新模型列表",
|
"title": "刷新模型列表",
|
||||||
@@ -771,6 +780,8 @@
|
|||||||
"deleteAll": "删除已选",
|
"deleteAll": "删除已选",
|
||||||
"downloadMissingLoras": "下载缺失的 LoRAs",
|
"downloadMissingLoras": "下载缺失的 LoRAs",
|
||||||
"downloadExamples": "下载示例图片",
|
"downloadExamples": "下载示例图片",
|
||||||
|
"downloadMissingExamples": "下载缺失的",
|
||||||
|
"reprocessExamples": "重新处理全部",
|
||||||
"clear": "清除选择",
|
"clear": "清除选择",
|
||||||
"skipMetadataRefreshCount": "跳过({count} 个模型)",
|
"skipMetadataRefreshCount": "跳过({count} 个模型)",
|
||||||
"resumeMetadataRefreshCount": "恢复({count} 个模型)",
|
"resumeMetadataRefreshCount": "恢复({count} 个模型)",
|
||||||
@@ -806,6 +817,8 @@
|
|||||||
"sendToWorkflowReplace": "发送到工作流(替换)",
|
"sendToWorkflowReplace": "发送到工作流(替换)",
|
||||||
"openExamples": "打开示例文件夹",
|
"openExamples": "打开示例文件夹",
|
||||||
"downloadExamples": "下载示例图片",
|
"downloadExamples": "下载示例图片",
|
||||||
|
"downloadMissingExamples": "下载缺失的",
|
||||||
|
"reprocessExamples": "重新处理全部",
|
||||||
"replacePreview": "替换预览",
|
"replacePreview": "替换预览",
|
||||||
"setContentRating": "设置内容评级",
|
"setContentRating": "设置内容评级",
|
||||||
"moveToFolder": "移动到文件夹",
|
"moveToFolder": "移动到文件夹",
|
||||||
@@ -1548,6 +1561,7 @@
|
|||||||
"empty": "该模型还没有版本历史。",
|
"empty": "该模型还没有版本历史。",
|
||||||
"error": "加载版本失败。",
|
"error": "加载版本失败。",
|
||||||
"missingModelId": "该模型缺少 Civitai 模型 ID。",
|
"missingModelId": "该模型缺少 Civitai 模型 ID。",
|
||||||
|
"hfGroupInfo": "这是一个 HuggingFace 模型组。打开库页面即可在网格中查看所有版本。",
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"delete": "从库中删除此版本?"
|
"delete": "从库中删除此版本?"
|
||||||
},
|
},
|
||||||
@@ -1574,6 +1588,21 @@
|
|||||||
"downloadCsv": "下载 CSV",
|
"downloadCsv": "下载 CSV",
|
||||||
"columnModelName": "模型名称",
|
"columnModelName": "模型名称",
|
||||||
"columnError": "错误"
|
"columnError": "错误"
|
||||||
|
},
|
||||||
|
"downloadBatchSummary": {
|
||||||
|
"title": "批量下载摘要",
|
||||||
|
"statSuccess": "成功",
|
||||||
|
"statFailed": "失败",
|
||||||
|
"statTotal": "总数",
|
||||||
|
"successMessage": "全部 {count} 个模型下载成功",
|
||||||
|
"completedWithErrors": "已完成,但有错误",
|
||||||
|
"failed": "下载失败",
|
||||||
|
"failedItems": "失败项({count})",
|
||||||
|
"columnName": "模型名称",
|
||||||
|
"columnError": "错误",
|
||||||
|
"close": "关闭",
|
||||||
|
"copyReport": "复制报告",
|
||||||
|
"retryFailed": "重试失败项({count})"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"modelTags": {
|
"modelTags": {
|
||||||
@@ -1751,6 +1780,12 @@
|
|||||||
"checkingMessage": "请稍候,正在检查最新版本。",
|
"checkingMessage": "请稍候,正在检查最新版本。",
|
||||||
"showNotifications": "显示更新通知",
|
"showNotifications": "显示更新通知",
|
||||||
"latestBadge": "最新",
|
"latestBadge": "最新",
|
||||||
|
"latestMain": "Main 分支",
|
||||||
|
"channel": "更新频道",
|
||||||
|
"channels": {
|
||||||
|
"release": "稳定版",
|
||||||
|
"nightly": "Nightly"
|
||||||
|
},
|
||||||
"updateProgress": {
|
"updateProgress": {
|
||||||
"preparing": "正在准备更新...",
|
"preparing": "正在准备更新...",
|
||||||
"installing": "正在安装更新...",
|
"installing": "正在安装更新...",
|
||||||
@@ -1771,6 +1806,15 @@
|
|||||||
"warning": "警告:Nightly 版本可能包含实验性功能,可能不稳定。",
|
"warning": "警告:Nightly 版本可能包含实验性功能,可能不稳定。",
|
||||||
"enable": "启用 Nightly 更新"
|
"enable": "启用 Nightly 更新"
|
||||||
},
|
},
|
||||||
|
"channelSwitch": {
|
||||||
|
"nightlyTitle": "切换到 Nightly",
|
||||||
|
"nightlyMessage": "切换到 Nightly 将初始化 Git 仓库并跟踪 main 分支的最新提交。更新更频繁但可能不稳定,可随时切回稳定版。",
|
||||||
|
"releaseTitle": "切换到稳定版",
|
||||||
|
"releaseMessage": "切换到稳定版将检出最新的发布标签。可随时切换回每日构建版。",
|
||||||
|
"switching": "正在切换到 {channel} 频道...",
|
||||||
|
"completed": "已切换到 {channel} 频道",
|
||||||
|
"failed": "切换频道失败"
|
||||||
|
},
|
||||||
"banners": {
|
"banners": {
|
||||||
"recent": "最近的通知",
|
"recent": "最近的通知",
|
||||||
"empty": "暂无最近的横幅通知。",
|
"empty": "暂无最近的横幅通知。",
|
||||||
@@ -2015,7 +2059,6 @@
|
|||||||
"presetNameTooLong": "预设名称不能超过 {max} 个字符",
|
"presetNameTooLong": "预设名称不能超过 {max} 个字符",
|
||||||
"presetNameInvalidChars": "预设名称包含无效字符",
|
"presetNameInvalidChars": "预设名称包含无效字符",
|
||||||
"presetNameExists": "已存在同名预设",
|
"presetNameExists": "已存在同名预设",
|
||||||
"maxPresetsReached": "最多允许 {max} 个预设。删除一个以添加更多。",
|
|
||||||
"presetNotFound": "预设未找到",
|
"presetNotFound": "预设未找到",
|
||||||
"invalidPreset": "无效的预设数据",
|
"invalidPreset": "无效的预设数据",
|
||||||
"deletePresetFailed": "删除预设失败",
|
"deletePresetFailed": "删除预设失败",
|
||||||
|
|||||||
+46
-3
@@ -449,6 +449,12 @@
|
|||||||
"compact": "7(1080p)、8(2K)、10(4K)"
|
"compact": "7(1080p)、8(2K)、10(4K)"
|
||||||
},
|
},
|
||||||
"displayDensityWarning": "警告:較高密度可能導致資源有限的系統效能下降。",
|
"displayDensityWarning": "警告:較高密度可能導致資源有限的系統效能下降。",
|
||||||
|
"recipesLayout": "配方版面",
|
||||||
|
"recipesLayoutHelp": "選擇配方卡片的排列方式:統一網格,或保留每張圖片原始寬高比的瀑布流(Pinterest 風格)版面。",
|
||||||
|
"recipesLayoutOptions": {
|
||||||
|
"grid": "網格",
|
||||||
|
"masonry": "瀑布流"
|
||||||
|
},
|
||||||
"showFolderSidebar": "顯示資料夾側邊欄",
|
"showFolderSidebar": "顯示資料夾側邊欄",
|
||||||
"showFolderSidebarHelp": "在模型頁面啟用或停用資料夾導覽側邊欄。停用後,側邊欄與滑鼠懸停區域將保持隱藏。",
|
"showFolderSidebarHelp": "在模型頁面啟用或停用資料夾導覽側邊欄。停用後,側邊欄與滑鼠懸停區域將保持隱藏。",
|
||||||
"cardInfoDisplay": "卡片資訊顯示",
|
"cardInfoDisplay": "卡片資訊顯示",
|
||||||
@@ -678,6 +684,7 @@
|
|||||||
"deepseek": "DeepSeek",
|
"deepseek": "DeepSeek",
|
||||||
"groq": "Groq",
|
"groq": "Groq",
|
||||||
"openrouter": "OpenRouter",
|
"openrouter": "OpenRouter",
|
||||||
|
"google": "Gemini",
|
||||||
"opencode-go": "OpenCode Go",
|
"opencode-go": "OpenCode Go",
|
||||||
"custom": "自訂(OpenAI 相容)"
|
"custom": "自訂(OpenAI 相容)"
|
||||||
},
|
},
|
||||||
@@ -686,7 +693,7 @@
|
|||||||
"apiBasePlaceholder": "https://api.openai.com/v1",
|
"apiBasePlaceholder": "https://api.openai.com/v1",
|
||||||
"apiKey": "API 金鑰",
|
"apiKey": "API 金鑰",
|
||||||
"apiKeyHelp": "LLM 提供者的 API 金鑰。儲存在本地,除您選擇的 LLM 提供者外不會傳送到任何伺服器。",
|
"apiKeyHelp": "LLM 提供者的 API 金鑰。儲存在本地,除您選擇的 LLM 提供者外不會傳送到任何伺服器。",
|
||||||
"apiKeyPlaceholder": "[TODO: Translate] sk-...",
|
"apiKeyPlaceholder": "sk-...",
|
||||||
"apiKeyNotSet": "未設定",
|
"apiKeyNotSet": "未設定",
|
||||||
"apiKeyConfigured": "已設定",
|
"apiKeyConfigured": "已設定",
|
||||||
"apiKeySet": "設定",
|
"apiKeySet": "設定",
|
||||||
@@ -714,7 +721,9 @@
|
|||||||
"versionsCount": "本地版本數",
|
"versionsCount": "本地版本數",
|
||||||
"versionsCountDesc": "版本數從多到少",
|
"versionsCountDesc": "版本數從多到少",
|
||||||
"versionsCountAsc": "版本數從少到多",
|
"versionsCountAsc": "版本數從少到多",
|
||||||
"versionIdDesc": "最新版本優先"
|
"versionIdDesc": "最新版本優先",
|
||||||
|
"random": "隨機",
|
||||||
|
"randomAction": "隨機排序(洗牌)"
|
||||||
},
|
},
|
||||||
"refresh": {
|
"refresh": {
|
||||||
"title": "重新整理模型列表",
|
"title": "重新整理模型列表",
|
||||||
@@ -771,6 +780,8 @@
|
|||||||
"deleteAll": "刪除所選",
|
"deleteAll": "刪除所選",
|
||||||
"downloadMissingLoras": "下載缺失的 LoRAs",
|
"downloadMissingLoras": "下載缺失的 LoRAs",
|
||||||
"downloadExamples": "下載範例圖片",
|
"downloadExamples": "下載範例圖片",
|
||||||
|
"downloadMissingExamples": "下載缺少的",
|
||||||
|
"reprocessExamples": "重新處理全部",
|
||||||
"clear": "清除選取",
|
"clear": "清除選取",
|
||||||
"skipMetadataRefreshCount": "跳過({count} 個模型)",
|
"skipMetadataRefreshCount": "跳過({count} 個模型)",
|
||||||
"resumeMetadataRefreshCount": "恢復({count} 個模型)",
|
"resumeMetadataRefreshCount": "恢復({count} 個模型)",
|
||||||
@@ -806,6 +817,8 @@
|
|||||||
"sendToWorkflowReplace": "傳送到工作流(取代)",
|
"sendToWorkflowReplace": "傳送到工作流(取代)",
|
||||||
"openExamples": "開啟範例資料夾",
|
"openExamples": "開啟範例資料夾",
|
||||||
"downloadExamples": "下載範例圖片",
|
"downloadExamples": "下載範例圖片",
|
||||||
|
"downloadMissingExamples": "下載缺少的",
|
||||||
|
"reprocessExamples": "重新處理全部",
|
||||||
"replacePreview": "更換預覽圖",
|
"replacePreview": "更換預覽圖",
|
||||||
"setContentRating": "設定內容分級",
|
"setContentRating": "設定內容分級",
|
||||||
"moveToFolder": "移動到資料夾",
|
"moveToFolder": "移動到資料夾",
|
||||||
@@ -1548,6 +1561,7 @@
|
|||||||
"empty": "此模型尚無版本歷史。",
|
"empty": "此模型尚無版本歷史。",
|
||||||
"error": "載入版本失敗。",
|
"error": "載入版本失敗。",
|
||||||
"missingModelId": "此模型缺少 Civitai 模型 ID。",
|
"missingModelId": "此模型缺少 Civitai 模型 ID。",
|
||||||
|
"hfGroupInfo": "這是一個 HuggingFace 模型組。打開庫頁面即可在網格中查看所有版本。",
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"delete": "要從庫中刪除此版本嗎?"
|
"delete": "要從庫中刪除此版本嗎?"
|
||||||
},
|
},
|
||||||
@@ -1574,6 +1588,21 @@
|
|||||||
"downloadCsv": "下載 CSV",
|
"downloadCsv": "下載 CSV",
|
||||||
"columnModelName": "模型名稱",
|
"columnModelName": "模型名稱",
|
||||||
"columnError": "錯誤"
|
"columnError": "錯誤"
|
||||||
|
},
|
||||||
|
"downloadBatchSummary": {
|
||||||
|
"title": "批次下載摘要",
|
||||||
|
"statSuccess": "成功",
|
||||||
|
"statFailed": "失敗",
|
||||||
|
"statTotal": "總數",
|
||||||
|
"successMessage": "全部 {count} 個模型下載成功",
|
||||||
|
"completedWithErrors": "已完成,但有錯誤",
|
||||||
|
"failed": "下載失敗",
|
||||||
|
"failedItems": "失敗項目({count})",
|
||||||
|
"columnName": "模型名稱",
|
||||||
|
"columnError": "錯誤",
|
||||||
|
"close": "關閉",
|
||||||
|
"copyReport": "複製報告",
|
||||||
|
"retryFailed": "重試失敗項目({count})"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"modelTags": {
|
"modelTags": {
|
||||||
@@ -1751,6 +1780,12 @@
|
|||||||
"checkingMessage": "請稍候,正在檢查最新版本。",
|
"checkingMessage": "請稍候,正在檢查最新版本。",
|
||||||
"showNotifications": "顯示更新通知",
|
"showNotifications": "顯示更新通知",
|
||||||
"latestBadge": "最新",
|
"latestBadge": "最新",
|
||||||
|
"latestMain": "Main 分支",
|
||||||
|
"channel": "更新頻道",
|
||||||
|
"channels": {
|
||||||
|
"release": "稳定版",
|
||||||
|
"nightly": "Nightly"
|
||||||
|
},
|
||||||
"updateProgress": {
|
"updateProgress": {
|
||||||
"preparing": "正在準備更新...",
|
"preparing": "正在準備更新...",
|
||||||
"installing": "正在安裝更新...",
|
"installing": "正在安裝更新...",
|
||||||
@@ -1771,6 +1806,15 @@
|
|||||||
"warning": "警告:Nightly 版本可能包含實驗性功能且可能不穩定。",
|
"warning": "警告:Nightly 版本可能包含實驗性功能且可能不穩定。",
|
||||||
"enable": "啟用 Nightly 更新"
|
"enable": "啟用 Nightly 更新"
|
||||||
},
|
},
|
||||||
|
"channelSwitch": {
|
||||||
|
"nightlyTitle": "切换到 Nightly",
|
||||||
|
"nightlyMessage": "切换到 Nightly 将初始化 Git 仓库并跟踪 main 分支的最新提交。更新更频繁但可能不稳定,可随时切回稳定版。",
|
||||||
|
"releaseTitle": "切换到稳定版",
|
||||||
|
"releaseMessage": "切換到穩定版將檢出最新的發布標籤。可隨時切換回每日構建版。",
|
||||||
|
"switching": "正在切換到 {channel} 頻道...",
|
||||||
|
"completed": "已切換到 {channel} 頻道",
|
||||||
|
"failed": "切換頻道失敗"
|
||||||
|
},
|
||||||
"banners": {
|
"banners": {
|
||||||
"recent": "最新通知",
|
"recent": "最新通知",
|
||||||
"empty": "目前沒有最近的橫幅通知。",
|
"empty": "目前沒有最近的橫幅通知。",
|
||||||
@@ -2015,7 +2059,6 @@
|
|||||||
"presetNameTooLong": "預設名稱不能超過 {max} 個字元",
|
"presetNameTooLong": "預設名稱不能超過 {max} 個字元",
|
||||||
"presetNameInvalidChars": "預設名稱包含無效字元",
|
"presetNameInvalidChars": "預設名稱包含無效字元",
|
||||||
"presetNameExists": "已存在同名預設",
|
"presetNameExists": "已存在同名預設",
|
||||||
"maxPresetsReached": "最多允許 {max} 個預設。刪除一個以新增更多。",
|
|
||||||
"presetNotFound": "預設未找到",
|
"presetNotFound": "預設未找到",
|
||||||
"invalidPreset": "無效的預設資料",
|
"invalidPreset": "無效的預設資料",
|
||||||
"deletePresetFailed": "刪除預設失敗",
|
"deletePresetFailed": "刪除預設失敗",
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
"""Constants used by the metadata collector"""
|
"""Constants used by the metadata collector"""
|
||||||
|
|
||||||
|
# Sentinel value for clip_skip to distinguish "unconnected / widget default"
|
||||||
|
# from "user wired value 0". Both ComfyUI CLIPSetLastLayer (-24..-1) and
|
||||||
|
# A1111 conventions treat 0 as meaningless for clip skipping, but users may
|
||||||
|
# explicitly wire 0 to the overwrite node to express "no clip skip / default".
|
||||||
|
CLIP_SKIP_SENTINEL = -25
|
||||||
|
|
||||||
# Metadata categories
|
# Metadata categories
|
||||||
MODELS = "models"
|
MODELS = "models"
|
||||||
PROMPTS = "prompts"
|
PROMPTS = "prompts"
|
||||||
@@ -9,6 +15,14 @@ EMBEDDINGS = "embeddings"
|
|||||||
SIZE = "size"
|
SIZE = "size"
|
||||||
IMAGES = "images"
|
IMAGES = "images"
|
||||||
IS_SAMPLER = "is_sampler" # New constant to mark sampler nodes
|
IS_SAMPLER = "is_sampler" # New constant to mark sampler nodes
|
||||||
|
OVERWRITE = "overwrite" # Manual metadata overwrite from MetadataOverwriteLM node
|
||||||
|
|
||||||
|
# Field names that the MetadataOverwriteLM node and its extractor share
|
||||||
|
METADATA_OVERWRITE_FIELDS = (
|
||||||
|
"prompt", "negative_prompt", "seed", "steps", "cfg_scale",
|
||||||
|
"sampler", "scheduler", "model", "loras", "size",
|
||||||
|
"clip_skip", "additional_data",
|
||||||
|
)
|
||||||
|
|
||||||
# Complete list of categories to track
|
# Complete list of categories to track
|
||||||
METADATA_CATEGORIES = [MODELS, PROMPTS, SAMPLING, LORAS, EMBEDDINGS, SIZE, IMAGES]
|
METADATA_CATEGORIES = [MODELS, PROMPTS, SAMPLING, LORAS, EMBEDDINGS, SIZE, IMAGES, OVERWRITE]
|
||||||
|
|||||||
@@ -83,7 +83,8 @@ class MetadataHook:
|
|||||||
|
|
||||||
# Record inputs before execution
|
# Record inputs before execution
|
||||||
if node_id is not None:
|
if node_id is not None:
|
||||||
registry.record_node_execution(node_id, class_type, input_data_all, None)
|
return_types = getattr(obj, 'RETURN_TYPES', None)
|
||||||
|
registry.record_node_execution(node_id, class_type, input_data_all, None, return_types=return_types)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error collecting metadata (pre-execution): {str(e)}")
|
logger.error(f"Error collecting metadata (pre-execution): {str(e)}")
|
||||||
|
|
||||||
@@ -114,7 +115,8 @@ class MetadataHook:
|
|||||||
|
|
||||||
# Record outputs after execution
|
# Record outputs after execution
|
||||||
if node_id is not None:
|
if node_id is not None:
|
||||||
registry.update_node_execution(node_id, class_type, results)
|
return_types = getattr(obj, 'RETURN_TYPES', None)
|
||||||
|
registry.update_node_execution(node_id, class_type, results, return_types=return_types)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error collecting metadata (post-execution): {str(e)}")
|
logger.error(f"Error collecting metadata (post-execution): {str(e)}")
|
||||||
|
|
||||||
@@ -136,6 +138,9 @@ class MetadataHook:
|
|||||||
if hasattr(prompt, 'original_prompt'):
|
if hasattr(prompt, 'original_prompt'):
|
||||||
registry.set_current_prompt(prompt)
|
registry.set_current_prompt(prompt)
|
||||||
|
|
||||||
|
# Store extra_data for accessing full workflow node properties
|
||||||
|
registry.set_extra_data(extra_data)
|
||||||
|
|
||||||
# Execute the original function
|
# Execute the original function
|
||||||
return original_execute(*args, **kwargs)
|
return original_execute(*args, **kwargs)
|
||||||
|
|
||||||
@@ -163,7 +168,8 @@ class MetadataHook:
|
|||||||
class_type = obj.__class__.__name__
|
class_type = obj.__class__.__name__
|
||||||
node_id = unique_id
|
node_id = unique_id
|
||||||
if node_id is not None:
|
if node_id is not None:
|
||||||
registry.record_node_execution(node_id, class_type, input_data_all, None)
|
return_types = getattr(obj, 'RETURN_TYPES', None)
|
||||||
|
registry.record_node_execution(node_id, class_type, input_data_all, None, return_types=return_types)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error collecting metadata (pre-execution): {str(e)}")
|
logger.error(f"Error collecting metadata (pre-execution): {str(e)}")
|
||||||
|
|
||||||
@@ -180,7 +186,8 @@ class MetadataHook:
|
|||||||
class_type = obj.__class__.__name__
|
class_type = obj.__class__.__name__
|
||||||
node_id = unique_id
|
node_id = unique_id
|
||||||
if node_id is not None:
|
if node_id is not None:
|
||||||
registry.update_node_execution(node_id, class_type, results)
|
return_types = getattr(obj, 'RETURN_TYPES', None)
|
||||||
|
registry.update_node_execution(node_id, class_type, results, return_types=return_types)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error collecting metadata (post-execution): {str(e)}")
|
logger.error(f"Error collecting metadata (post-execution): {str(e)}")
|
||||||
|
|
||||||
@@ -202,6 +209,9 @@ class MetadataHook:
|
|||||||
if hasattr(prompt, 'original_prompt'):
|
if hasattr(prompt, 'original_prompt'):
|
||||||
registry.set_current_prompt(prompt)
|
registry.set_current_prompt(prompt)
|
||||||
|
|
||||||
|
# Store extra_data for accessing full workflow node properties
|
||||||
|
registry.set_extra_data(extra_data)
|
||||||
|
|
||||||
# Execute the original function
|
# Execute the original function
|
||||||
return await original_execute(*args, **kwargs)
|
return await original_execute(*args, **kwargs)
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,68 @@
|
|||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
from .constants import IMAGES
|
from .constants import IMAGES
|
||||||
|
|
||||||
# Check if running in standalone mode
|
# Check if running in standalone mode
|
||||||
standalone_mode = os.environ.get("LORA_MANAGER_STANDALONE", "0") == "1" or os.environ.get("HF_HUB_DISABLE_TELEMETRY", "0") == "0"
|
standalone_mode = os.environ.get("LORA_MANAGER_STANDALONE", "0") == "1" or os.environ.get("HF_HUB_DISABLE_TELEMETRY", "0") == "0"
|
||||||
|
|
||||||
from .constants import MODELS, PROMPTS, SAMPLING, LORAS, SIZE, IS_SAMPLER
|
from .constants import MODELS, PROMPTS, SAMPLING, LORAS, SIZE, IS_SAMPLER, OVERWRITE
|
||||||
|
from .node_extractors import NODE_EXTRACTORS
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# Keys that identify metadata hint marks stored in node.properties.lm_marker_role
|
||||||
|
_META_MARK_PREFIX = "meta_"
|
||||||
|
_MARK_PRIMARY_MODEL = "primary_model"
|
||||||
|
_MARK_PRIMARY_SAMPLER = "primary_sampler"
|
||||||
|
_MARK_POSITIVE_PROMPT = "positive_prompt"
|
||||||
|
_MARK_NEGATIVE_PROMPT = "negative_prompt"
|
||||||
|
|
||||||
class MetadataProcessor:
|
class MetadataProcessor:
|
||||||
"""Process and format collected metadata"""
|
"""Process and format collected metadata"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _get_user_marks(metadata):
|
||||||
|
"""Scan workflow nodes (from extra_data.extra_pnginfo.workflow) for user-assigned
|
||||||
|
metadata hint marks stored in node.properties.lm_marker_role.
|
||||||
|
|
||||||
|
Returns a dict mapping mark type keys to node IDs.
|
||||||
|
Example: {'primary_model': '42', 'primary_sampler': '17'}
|
||||||
|
"""
|
||||||
|
marks: dict[str, str] = {}
|
||||||
|
|
||||||
|
# Primary source: extra_data.extra_pnginfo.workflow.nodes (has full properties)
|
||||||
|
extra_data = metadata.get("extra_data")
|
||||||
|
if extra_data and isinstance(extra_data, dict):
|
||||||
|
extra_pnginfo = extra_data.get("extra_pnginfo", {})
|
||||||
|
if isinstance(extra_pnginfo, dict):
|
||||||
|
workflow = extra_pnginfo.get("workflow", {})
|
||||||
|
nodes = workflow.get("nodes", [])
|
||||||
|
for node in nodes:
|
||||||
|
node_id = str(node.get("id", ""))
|
||||||
|
role = node.get("properties", {}).get("lm_marker_role", "")
|
||||||
|
if role.startswith(_META_MARK_PREFIX):
|
||||||
|
mark_type = role[len(_META_MARK_PREFIX):]
|
||||||
|
if mark_type in marks:
|
||||||
|
logger.warning(
|
||||||
|
"Duplicate meta hint '%s': node %s (previous: %s), "
|
||||||
|
"last match wins",
|
||||||
|
mark_type, node_id, marks[mark_type],
|
||||||
|
)
|
||||||
|
marks[mark_type] = node_id
|
||||||
|
|
||||||
|
# Fallback: try prompt.original_prompt (API-only submissions may not have workflow)
|
||||||
|
if not marks:
|
||||||
|
prompt = metadata.get("current_prompt")
|
||||||
|
if prompt and getattr(prompt, "original_prompt", None):
|
||||||
|
for node_id, node_data in prompt.original_prompt.items():
|
||||||
|
role = node_data.get("properties", {}).get("lm_marker_role", "")
|
||||||
|
if role.startswith(_META_MARK_PREFIX):
|
||||||
|
mark_type = role[len(_META_MARK_PREFIX):]
|
||||||
|
marks[mark_type] = node_id
|
||||||
|
|
||||||
|
return marks
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def find_primary_sampler(metadata, downstream_id=None):
|
def find_primary_sampler(metadata, downstream_id=None):
|
||||||
"""
|
"""
|
||||||
@@ -471,17 +524,54 @@ class MetadataProcessor:
|
|||||||
"checkpoint": None,
|
"checkpoint": None,
|
||||||
"loras": "",
|
"loras": "",
|
||||||
"size": None,
|
"size": None,
|
||||||
"clip_skip": None
|
"clip_skip": None,
|
||||||
|
"additional_data": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get the prompt object for node relationship tracing
|
# Get the prompt object for node relationship tracing
|
||||||
prompt = metadata.get("current_prompt")
|
prompt = metadata.get("current_prompt")
|
||||||
|
|
||||||
# Find the primary KSampler node
|
# ---- User marks: override heuristic inference with user-assigned hints ----
|
||||||
|
user_marks = MetadataProcessor._get_user_marks(metadata)
|
||||||
|
|
||||||
|
# Find the primary KSampler node (user mark takes priority)
|
||||||
|
primary_sampler_id = None
|
||||||
|
primary_sampler = None
|
||||||
|
if _MARK_PRIMARY_SAMPLER in user_marks:
|
||||||
|
marked_id = user_marks[_MARK_PRIMARY_SAMPLER]
|
||||||
|
sampler_data = metadata.get(SAMPLING, {}).get(marked_id)
|
||||||
|
if sampler_data and sampler_data.get(IS_SAMPLER):
|
||||||
|
primary_sampler_id = marked_id
|
||||||
|
primary_sampler = sampler_data
|
||||||
|
else:
|
||||||
|
logger.warning(
|
||||||
|
"User-marked primary sampler %s has no runtime metadata, "
|
||||||
|
"falling back to heuristic",
|
||||||
|
marked_id,
|
||||||
|
)
|
||||||
|
if primary_sampler is None:
|
||||||
primary_sampler_id, primary_sampler = MetadataProcessor.find_primary_sampler(metadata, id)
|
primary_sampler_id, primary_sampler = MetadataProcessor.find_primary_sampler(metadata, id)
|
||||||
|
|
||||||
# Directly get checkpoint from metadata instead of tracing
|
# Resolve checkpoint / model (user mark takes priority)
|
||||||
# Pass primary_sampler_id to avoid redundant calculation
|
if _MARK_PRIMARY_MODEL in user_marks:
|
||||||
|
marked_id = user_marks[_MARK_PRIMARY_MODEL]
|
||||||
|
if marked_id in metadata.get(MODELS, {}):
|
||||||
|
params["checkpoint"] = metadata[MODELS][marked_id].get("name")
|
||||||
|
else:
|
||||||
|
extra_data = metadata.get("extra_data")
|
||||||
|
extra_pnginfo = extra_data.get("extra_pnginfo", {}) if extra_data and isinstance(extra_data, dict) else {}
|
||||||
|
workflow = extra_pnginfo.get("workflow", {}) if isinstance(extra_pnginfo, dict) else {}
|
||||||
|
node_type = "unknown"
|
||||||
|
for n in workflow.get("nodes", []):
|
||||||
|
if str(n.get("id", "")) == marked_id:
|
||||||
|
node_type = n.get("type", "unknown")
|
||||||
|
break
|
||||||
|
logger.warning(
|
||||||
|
"User-marked primary model %s (type=%s, registered=%s) has no runtime metadata, "
|
||||||
|
"falling back to heuristic",
|
||||||
|
marked_id, node_type, node_type in NODE_EXTRACTORS,
|
||||||
|
)
|
||||||
|
if params["checkpoint"] is None:
|
||||||
checkpoint = MetadataProcessor.find_primary_checkpoint(metadata, id, primary_sampler_id)
|
checkpoint = MetadataProcessor.find_primary_checkpoint(metadata, id, primary_sampler_id)
|
||||||
if checkpoint:
|
if checkpoint:
|
||||||
params["checkpoint"] = checkpoint
|
params["checkpoint"] = checkpoint
|
||||||
@@ -540,6 +630,21 @@ class MetadataProcessor:
|
|||||||
# For SamplerCustom, handle any additional parameters
|
# For SamplerCustom, handle any additional parameters
|
||||||
MetadataProcessor.handle_custom_advanced_sampler(metadata, prompt, primary_sampler_id, params)
|
MetadataProcessor.handle_custom_advanced_sampler(metadata, prompt, primary_sampler_id, params)
|
||||||
|
|
||||||
|
# ---- User marks: override prompts with explicitly tagged nodes ----
|
||||||
|
prompts_data = metadata.get(PROMPTS, {})
|
||||||
|
if _MARK_POSITIVE_PROMPT in user_marks:
|
||||||
|
pos_id = user_marks[_MARK_POSITIVE_PROMPT]
|
||||||
|
if pos_id in prompts_data:
|
||||||
|
prompt_text = prompts_data[pos_id].get("text") or prompts_data[pos_id].get("positive_text")
|
||||||
|
if prompt_text:
|
||||||
|
params["prompt"] = prompt_text
|
||||||
|
if _MARK_NEGATIVE_PROMPT in user_marks:
|
||||||
|
neg_id = user_marks[_MARK_NEGATIVE_PROMPT]
|
||||||
|
if neg_id in prompts_data:
|
||||||
|
prompt_text = prompts_data[neg_id].get("text") or prompts_data[neg_id].get("negative_text")
|
||||||
|
if prompt_text:
|
||||||
|
params["negative_prompt"] = prompt_text
|
||||||
|
|
||||||
# Size extraction is same for all sampler types
|
# Size extraction is same for all sampler types
|
||||||
# Check if the sampler itself has size information (from latent_image)
|
# Check if the sampler itself has size information (from latent_image)
|
||||||
if primary_sampler_id in metadata.get(SIZE, {}):
|
if primary_sampler_id in metadata.get(SIZE, {}):
|
||||||
@@ -569,6 +674,25 @@ class MetadataProcessor:
|
|||||||
if params["clip_skip"] is None:
|
if params["clip_skip"] is None:
|
||||||
params["clip_skip"] = "1"
|
params["clip_skip"] = "1"
|
||||||
|
|
||||||
|
# ---- Apply manual metadata overwrites ----
|
||||||
|
for overwrite_info in metadata.get(OVERWRITE, {}).values():
|
||||||
|
overwrite_params = overwrite_info.get("parameters", {})
|
||||||
|
for key, value in overwrite_params.items():
|
||||||
|
if key == "clip_skip":
|
||||||
|
# Accept any value from overwrite node (sentinel -25 already
|
||||||
|
# filtered upstream). Needed because falsy check treats 0
|
||||||
|
# as "not set" even though 0 is a valid wired input here.
|
||||||
|
params[key] = value
|
||||||
|
elif value: # truthy check — only overwrite when user provided a real value
|
||||||
|
params[key] = value
|
||||||
|
|
||||||
|
# Bridge: the overwrite node exposes the field as "model" (more accurate),
|
||||||
|
# but the internal pipeline key remains "checkpoint" for backward compatibility
|
||||||
|
# with A1111 metadata format and downstream consumers.
|
||||||
|
if params.get("model"):
|
||||||
|
params["checkpoint"] = params["model"]
|
||||||
|
del params["model"]
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
from nodes import NODE_CLASS_MAPPINGS # type: ignore
|
from nodes import NODE_CLASS_MAPPINGS # type: ignore
|
||||||
from .node_extractors import NODE_EXTRACTORS, GenericNodeExtractor
|
from .node_extractors import NODE_EXTRACTORS, GenericNodeExtractor
|
||||||
from .constants import METADATA_CATEGORIES, IMAGES
|
from .constants import METADATA_CATEGORIES, IMAGES, OVERWRITE
|
||||||
|
|
||||||
|
|
||||||
class MetadataRegistry:
|
class MetadataRegistry:
|
||||||
@@ -61,6 +61,7 @@ class MetadataRegistry:
|
|||||||
{
|
{
|
||||||
"execution_order": [],
|
"execution_order": [],
|
||||||
"current_prompt": None, # Will store the prompt object
|
"current_prompt": None, # Will store the prompt object
|
||||||
|
"extra_data": None, # Will store the API extra_data for workflow metadata
|
||||||
"timestamp": time.time(),
|
"timestamp": time.time(),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -75,6 +76,11 @@ class MetadataRegistry:
|
|||||||
# Store the prompt in the metadata for later relationship tracing
|
# Store the prompt in the metadata for later relationship tracing
|
||||||
self.prompt_metadata[self.current_prompt_id]["current_prompt"] = prompt
|
self.prompt_metadata[self.current_prompt_id]["current_prompt"] = prompt
|
||||||
|
|
||||||
|
def set_extra_data(self, extra_data):
|
||||||
|
"""Store the API extra_data (contains extra_pnginfo.workflow with node properties)"""
|
||||||
|
if self.current_prompt_id and self.current_prompt_id in self.prompt_metadata:
|
||||||
|
self.prompt_metadata[self.current_prompt_id]["extra_data"] = extra_data
|
||||||
|
|
||||||
def get_metadata(self, prompt_id=None):
|
def get_metadata(self, prompt_id=None):
|
||||||
"""Get collected metadata for a prompt"""
|
"""Get collected metadata for a prompt"""
|
||||||
key = prompt_id if prompt_id is not None else self.current_prompt_id
|
key = prompt_id if prompt_id is not None else self.current_prompt_id
|
||||||
@@ -122,20 +128,28 @@ class MetadataRegistry:
|
|||||||
cache_key = f"{node_id}:{class_type}"
|
cache_key = f"{node_id}:{class_type}"
|
||||||
|
|
||||||
# Check if this node type is relevant for metadata collection
|
# Check if this node type is relevant for metadata collection
|
||||||
if class_type in NODE_EXTRACTORS:
|
if class_type in NODE_EXTRACTORS or cache_key in self.node_cache:
|
||||||
# Check if we have cached metadata for this node
|
# Check if we have cached metadata for this node
|
||||||
if cache_key in self.node_cache:
|
if cache_key in self.node_cache:
|
||||||
cached_data = self.node_cache[cache_key]
|
cached_data = self.node_cache[cache_key]
|
||||||
|
|
||||||
|
# Detect bypass (mode=4) / mute (mode=2) — these nodes
|
||||||
|
# were intentionally disabled and should not contribute
|
||||||
|
# overwrite values from a previous execution's cache.
|
||||||
|
node_mode = node_data.get("mode", 0)
|
||||||
|
node_is_disabled = node_mode in (2, 4)
|
||||||
|
|
||||||
# Apply cached metadata to the current metadata
|
# Apply cached metadata to the current metadata
|
||||||
for category in self.metadata_categories:
|
for category in self.metadata_categories:
|
||||||
|
if category == OVERWRITE and node_is_disabled:
|
||||||
|
continue
|
||||||
if category in cached_data and node_id in cached_data[category]:
|
if category in cached_data and node_id in cached_data[category]:
|
||||||
if node_id not in metadata[category]:
|
if node_id not in metadata[category]:
|
||||||
metadata[category][node_id] = cached_data[category][
|
metadata[category][node_id] = cached_data[category][
|
||||||
node_id
|
node_id
|
||||||
]
|
]
|
||||||
|
|
||||||
def record_node_execution(self, node_id, class_type, inputs, outputs):
|
def record_node_execution(self, node_id, class_type, inputs, outputs, return_types=None):
|
||||||
"""Record information about a node's execution"""
|
"""Record information about a node's execution"""
|
||||||
if not self.current_prompt_id:
|
if not self.current_prompt_id:
|
||||||
return
|
return
|
||||||
@@ -158,17 +172,18 @@ class MetadataRegistry:
|
|||||||
|
|
||||||
# Extract node-specific metadata
|
# Extract node-specific metadata
|
||||||
extractor = NODE_EXTRACTORS.get(class_type, GenericNodeExtractor)
|
extractor = NODE_EXTRACTORS.get(class_type, GenericNodeExtractor)
|
||||||
extractor.extract(
|
if extractor is GenericNodeExtractor:
|
||||||
node_id,
|
extractor.extract(node_id, processed_inputs, outputs,
|
||||||
processed_inputs,
|
|
||||||
outputs,
|
|
||||||
self.prompt_metadata[self.current_prompt_id],
|
self.prompt_metadata[self.current_prompt_id],
|
||||||
)
|
return_types=return_types)
|
||||||
|
else:
|
||||||
|
extractor.extract(node_id, processed_inputs, outputs,
|
||||||
|
self.prompt_metadata[self.current_prompt_id])
|
||||||
|
|
||||||
# Cache this node's metadata
|
# Cache this node's metadata
|
||||||
self._cache_node_metadata(node_id, class_type)
|
self._cache_node_metadata(node_id, class_type)
|
||||||
|
|
||||||
def update_node_execution(self, node_id, class_type, outputs):
|
def update_node_execution(self, node_id, class_type, outputs, return_types=None):
|
||||||
"""Update node metadata with output information"""
|
"""Update node metadata with output information"""
|
||||||
if not self.current_prompt_id:
|
if not self.current_prompt_id:
|
||||||
return
|
return
|
||||||
@@ -179,8 +194,16 @@ class MetadataRegistry:
|
|||||||
# Use the same extractor to update with outputs
|
# Use the same extractor to update with outputs
|
||||||
extractor = NODE_EXTRACTORS.get(class_type, GenericNodeExtractor)
|
extractor = NODE_EXTRACTORS.get(class_type, GenericNodeExtractor)
|
||||||
if hasattr(extractor, "update"):
|
if hasattr(extractor, "update"):
|
||||||
|
if extractor is GenericNodeExtractor:
|
||||||
extractor.update(
|
extractor.update(
|
||||||
node_id, processed_outputs, self.prompt_metadata[self.current_prompt_id]
|
node_id, processed_outputs,
|
||||||
|
self.prompt_metadata[self.current_prompt_id],
|
||||||
|
return_types=return_types,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
extractor.update(
|
||||||
|
node_id, processed_outputs,
|
||||||
|
self.prompt_metadata[self.current_prompt_id],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Update the cached metadata for this node
|
# Update the cached metadata for this node
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import json
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .constants import MODELS, PROMPTS, SAMPLING, LORAS, SIZE, IMAGES, IS_SAMPLER
|
from .constants import MODELS, PROMPTS, SAMPLING, LORAS, SIZE, IMAGES, IS_SAMPLER, OVERWRITE
|
||||||
|
from .overwrite_utils import collect_overwrite_params
|
||||||
|
|
||||||
|
|
||||||
def _store_checkpoint_metadata(metadata, node_id, model_name):
|
def _store_checkpoint_metadata(metadata, node_id, model_name):
|
||||||
@@ -31,10 +32,77 @@ class NodeMetadataExtractor:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
class GenericNodeExtractor(NodeMetadataExtractor):
|
class GenericNodeExtractor(NodeMetadataExtractor):
|
||||||
"""Default extractor for nodes without specific handling"""
|
"""Fallback extractor with type-signature-based detection.
|
||||||
|
|
||||||
|
When a node is not in the NODE_EXTRACTORS registry, the hook layer
|
||||||
|
passes ``return_types`` from ``obj.RETURN_TYPES``:
|
||||||
|
|
||||||
|
* ``MODEL`` output: common input fields (ckpt_name, unet_name, etc.)
|
||||||
|
are checked for a model file name and stored as checkpoint metadata.
|
||||||
|
* ``CONDITIONING`` output: common text input fields are checked for
|
||||||
|
prompt text and stored as prompt metadata.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Input field names that carry a model path in loader-style nodes.
|
||||||
|
_MODEL_NAME_FIELDS = (
|
||||||
|
"ckpt_name", "unet_name", "model_path", "model_name", "gguf_name",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Extensions used by checkpoint_scanner.py — only record values that look
|
||||||
|
# like real model filenames to avoid capturing unrelated string fields.
|
||||||
|
_MODEL_EXTENSIONS = {
|
||||||
|
".ckpt", ".pt", ".pt2", ".bin", ".pth", ".safetensors", ".pkl", ".sft", ".gguf",
|
||||||
|
}
|
||||||
|
|
||||||
|
# Input field names that may carry prompt text in encoder-style nodes.
|
||||||
|
_TEXT_FIELDS = ("text", "clip_l", "t5xxl", "prompt", "positive", "negative")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def extract(node_id, inputs, outputs, metadata):
|
def extract(node_id, inputs, outputs, metadata, return_types=None):
|
||||||
pass
|
if return_types is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
# — MODEL loader detection (checkpoint / UNET / GGUF) —
|
||||||
|
if "MODEL" in return_types or any("MODEL" in str(t) for t in return_types):
|
||||||
|
for field in GenericNodeExtractor._MODEL_NAME_FIELDS:
|
||||||
|
val = inputs.get(field)
|
||||||
|
if val and isinstance(val, str) and val.strip():
|
||||||
|
name = val.strip()
|
||||||
|
if not any(name.lower().endswith(ext) for ext in GenericNodeExtractor._MODEL_EXTENSIONS):
|
||||||
|
continue
|
||||||
|
_store_checkpoint_metadata(metadata, node_id, name)
|
||||||
|
return
|
||||||
|
|
||||||
|
# — CONDITIONING encoder detection (CLIPTextEncode, Flux, custom) —
|
||||||
|
if "CONDITIONING" in return_types or any("CONDITIONING" in str(t) for t in return_types):
|
||||||
|
text = None
|
||||||
|
for field in GenericNodeExtractor._TEXT_FIELDS:
|
||||||
|
val = inputs.get(field)
|
||||||
|
if val and isinstance(val, str) and val.strip():
|
||||||
|
text = val.strip()
|
||||||
|
break
|
||||||
|
if text:
|
||||||
|
prompt_data = metadata.setdefault(PROMPTS, {})
|
||||||
|
prompt_data[node_id] = {
|
||||||
|
"text": text,
|
||||||
|
"node_id": node_id,
|
||||||
|
}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def update(node_id, outputs, metadata, return_types=None):
|
||||||
|
if return_types is None:
|
||||||
|
return
|
||||||
|
if "CONDITIONING" not in return_types and not any(
|
||||||
|
"CONDITIONING" in str(t) for t in return_types
|
||||||
|
):
|
||||||
|
return
|
||||||
|
if node_id not in metadata.get(PROMPTS, {}):
|
||||||
|
return
|
||||||
|
if outputs and isinstance(outputs, list) and len(outputs) > 0:
|
||||||
|
if isinstance(outputs[0], tuple) and len(outputs[0]) > 0:
|
||||||
|
cond = outputs[0][0]
|
||||||
|
if cond is not None:
|
||||||
|
metadata[PROMPTS][node_id]["conditioning"] = cond
|
||||||
|
|
||||||
class CheckpointLoaderExtractor(NodeMetadataExtractor):
|
class CheckpointLoaderExtractor(NodeMetadataExtractor):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -1154,6 +1222,28 @@ class CR_ApplyControlNetStackExtractor(NodeMetadataExtractor):
|
|||||||
metadata[PROMPTS][node_id]["positive_encoded"] = transformed_positive
|
metadata[PROMPTS][node_id]["positive_encoded"] = transformed_positive
|
||||||
metadata[PROMPTS][node_id]["negative_encoded"] = transformed_negative
|
metadata[PROMPTS][node_id]["negative_encoded"] = transformed_negative
|
||||||
|
|
||||||
|
class MetadataOverwriteExtractor(NodeMetadataExtractor):
|
||||||
|
"""Extract manually specified metadata from MetadataOverwriteLM node.
|
||||||
|
|
||||||
|
Stores truthy input values under the OVERWRITE category so that
|
||||||
|
extract_generation_params can merge them over the inferred params.
|
||||||
|
"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def extract(node_id, inputs, outputs, metadata):
|
||||||
|
if not inputs:
|
||||||
|
return
|
||||||
|
|
||||||
|
overwrite_params = collect_overwrite_params(inputs)
|
||||||
|
|
||||||
|
if overwrite_params:
|
||||||
|
metadata.setdefault(OVERWRITE, {})
|
||||||
|
metadata[OVERWRITE][node_id] = {
|
||||||
|
"parameters": overwrite_params,
|
||||||
|
"node_id": node_id,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Registry of node-specific extractors
|
# Registry of node-specific extractors
|
||||||
# Keys are node class names
|
# Keys are node class names
|
||||||
NODE_EXTRACTORS = {
|
NODE_EXTRACTORS = {
|
||||||
@@ -1221,5 +1311,7 @@ NODE_EXTRACTORS = {
|
|||||||
"CFGGuider": CFGGuiderExtractor, # Add CFGGuider
|
"CFGGuider": CFGGuiderExtractor, # Add CFGGuider
|
||||||
# Image
|
# Image
|
||||||
"VAEDecode": VAEDecodeExtractor, # Added VAEDecode extractor
|
"VAEDecode": VAEDecodeExtractor, # Added VAEDecode extractor
|
||||||
|
# Metadata overwrite
|
||||||
|
"MetadataOverwriteLM": MetadataOverwriteExtractor,
|
||||||
# Add other nodes as needed
|
# Add other nodes as needed
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
"""Shared helpers for Metadata Overwrite node metadata collection.
|
||||||
|
|
||||||
|
Used by both the MetadataOverwriteLM node (execution time) and the
|
||||||
|
MetadataOverwriteExtractor (hook time) so the conversion/filtering logic
|
||||||
|
cannot drift between the two paths.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from typing import Any, Dict
|
||||||
|
|
||||||
|
from ..utils.utils import model_patcher_to_name
|
||||||
|
from .constants import CLIP_SKIP_SENTINEL, METADATA_OVERWRITE_FIELDS
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def collect_overwrite_params(values: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
|
"""Convert node input values into non-default overwrite parameters.
|
||||||
|
|
||||||
|
For most fields, a falsy value (empty string, 0) means "not set" and is
|
||||||
|
skipped. clip_skip uses a dedicated sentinel (-25) so that a wired value
|
||||||
|
of 0 is preserved. The ``model`` field accepts either a manual string or
|
||||||
|
a wired MODEL (ModelPatcher) connection; in the latter case the source
|
||||||
|
model name is extracted from the patcher's ``cached_patcher_init`` and
|
||||||
|
stored as a ComfyUI-style relative path.
|
||||||
|
"""
|
||||||
|
result: Dict[str, Any] = {}
|
||||||
|
for key in METADATA_OVERWRITE_FIELDS:
|
||||||
|
value = values.get(key)
|
||||||
|
if key == "model" and not isinstance(value, str):
|
||||||
|
value = model_patcher_to_name(value)
|
||||||
|
if value is None:
|
||||||
|
logger.warning(
|
||||||
|
"Could not extract model name from wired MODEL input "
|
||||||
|
"(no cached_patcher_init); model metadata overwrite skipped"
|
||||||
|
)
|
||||||
|
if key == "clip_skip":
|
||||||
|
if value != CLIP_SKIP_SENTINEL:
|
||||||
|
result[key] = value
|
||||||
|
elif value:
|
||||||
|
result[key] = value
|
||||||
|
return result
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
"""Create Hook LoRA (LoraManager) — multi-LoRA hook node compatible with ComfyUI's built-in hook pipeline.
|
||||||
|
|
||||||
|
Produces ``("HOOKS",)`` output that chains seamlessly with downstream hook consumers
|
||||||
|
(ConditioningSetProperties, SetHookKeyframes, CombineHooks, SetClipHooks, etc.).
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
|
from ..utils.utils import get_lora_info_absolute
|
||||||
|
from .utils import (
|
||||||
|
FlexibleOptionalInputType,
|
||||||
|
any_type,
|
||||||
|
apply_lora_syntax_format,
|
||||||
|
get_loras_list,
|
||||||
|
)
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class CreateHookLoraLM:
|
||||||
|
NAME = "Create Hook LoRA (LoraManager)"
|
||||||
|
CATEGORY = "Lora Manager/hooks"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(cls):
|
||||||
|
return {
|
||||||
|
"required": {
|
||||||
|
"text": (
|
||||||
|
"AUTOCOMPLETE_TEXT_LORAS",
|
||||||
|
{
|
||||||
|
"placeholder": "Search LoRAs to add...",
|
||||||
|
"tooltip": (
|
||||||
|
"Search and select LoRAs. Each LoRA gets its own "
|
||||||
|
"model/clip strength. Hooks chain with prev_hooks."
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"optional": FlexibleOptionalInputType(any_type),
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_TYPES = ("HOOKS", "STRING", "STRING")
|
||||||
|
RETURN_NAMES = ("HOOKS", "trigger_words", "active_loras")
|
||||||
|
FUNCTION = "create_hook"
|
||||||
|
|
||||||
|
def create_hook(self, text: str, **kwargs):
|
||||||
|
"""Create a HookGroup from the selected LoRAs, chained with prev_hooks.
|
||||||
|
|
||||||
|
Each active LoRA from the widget is loaded and wrapped in a WeightHook
|
||||||
|
via :func:`comfy.hooks.create_hook_lora`. All hooks are combined into a
|
||||||
|
single group and returned alongside trigger words and a human-readable
|
||||||
|
summary of the active LoRAs.
|
||||||
|
"""
|
||||||
|
del text # used by the frontend widget only
|
||||||
|
|
||||||
|
# Lazy imports: comfy is not available in CI/test environment at module level
|
||||||
|
import comfy.hooks # type: ignore # noqa: C0415
|
||||||
|
import comfy.utils # type: ignore # noqa: C0415
|
||||||
|
|
||||||
|
prev_hooks: comfy.hooks.HookGroup | None = kwargs.get("prev_hooks")
|
||||||
|
|
||||||
|
hook_group = prev_hooks.clone() if prev_hooks is not None else comfy.hooks.HookGroup()
|
||||||
|
|
||||||
|
all_trigger_words: list[str] = []
|
||||||
|
active_loras: list[tuple[str, float, float]] = []
|
||||||
|
|
||||||
|
for lora in get_loras_list(kwargs):
|
||||||
|
if not lora.get("active", False):
|
||||||
|
continue
|
||||||
|
|
||||||
|
lora_name = apply_lora_syntax_format(lora["name"])
|
||||||
|
model_strength = float(lora["strength"])
|
||||||
|
clip_strength = float(lora.get("clipStrength", model_strength))
|
||||||
|
|
||||||
|
# Skip useless no-op entries (both strengths are zero)
|
||||||
|
if model_strength == 0.0 and clip_strength == 0.0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
lora_path, trigger_words = get_lora_info_absolute(lora_name)
|
||||||
|
if not lora_path or not os.path.isfile(lora_path):
|
||||||
|
logger.warning("LoRA '%s' not found — skipping", lora_name)
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
lora_weights = comfy.utils.load_torch_file(lora_path, safe_load=True)
|
||||||
|
|
||||||
|
lora_hooks = comfy.hooks.create_hook_lora(
|
||||||
|
lora=lora_weights,
|
||||||
|
strength_model=model_strength,
|
||||||
|
strength_clip=clip_strength,
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
logger.exception("Failed to load LoRA '%s' — skipping", lora_name)
|
||||||
|
continue
|
||||||
|
hook_group = hook_group.clone_and_combine(lora_hooks)
|
||||||
|
|
||||||
|
active_loras.append((lora_name, model_strength, clip_strength))
|
||||||
|
all_trigger_words.extend(trigger_words)
|
||||||
|
|
||||||
|
# Format trigger words (group mode separator)
|
||||||
|
trigger_words_text = ",, ".join(all_trigger_words) if all_trigger_words else ""
|
||||||
|
|
||||||
|
# Format active LoRAs summary
|
||||||
|
formatted_loras = []
|
||||||
|
for name, model_s, clip_s in active_loras:
|
||||||
|
if abs(model_s - clip_s) > 0.001:
|
||||||
|
formatted_loras.append(
|
||||||
|
f"<lora:{name}:{model_s}:{clip_s}>"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
formatted_loras.append(f"<lora:{name}:{model_s}>")
|
||||||
|
active_loras_text = " ".join(formatted_loras)
|
||||||
|
|
||||||
|
return (hook_group, trigger_words_text, active_loras_text)
|
||||||
@@ -1,26 +1,102 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import inspect
|
||||||
|
import re
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
_STACK_INPUT_PATTERN = re.compile(r"^lora_stack(?:_([ab])|(\d+))$")
|
||||||
|
|
||||||
|
|
||||||
|
def _is_stack_input(name: str) -> bool:
|
||||||
|
return bool(_STACK_INPUT_PATTERN.match(name))
|
||||||
|
|
||||||
|
|
||||||
|
def _stack_slot_number(name: str) -> int:
|
||||||
|
"""Numeric slot used to order stack inputs; legacy a/b map to 1/2."""
|
||||||
|
match = _STACK_INPUT_PATTERN.match(name)
|
||||||
|
if not match:
|
||||||
|
return -1
|
||||||
|
letter, digits = match.group(1), match.group(2)
|
||||||
|
if digits is not None:
|
||||||
|
return int(digits)
|
||||||
|
return 1 if letter == "a" else 2
|
||||||
|
|
||||||
|
|
||||||
|
class _LoraStackOptionalInputs:
|
||||||
|
"""Lookup that preserves explicit optional inputs and dynamic lora_stack slots."""
|
||||||
|
|
||||||
|
def __init__(self, explicit_inputs: dict[str, tuple[str, dict[str, Any]]]) -> None:
|
||||||
|
self._explicit_inputs = explicit_inputs
|
||||||
|
|
||||||
|
def __contains__(self, item: object) -> bool:
|
||||||
|
if not isinstance(item, str):
|
||||||
|
return False
|
||||||
|
return item in self._explicit_inputs or _is_stack_input(item)
|
||||||
|
|
||||||
|
def __getitem__(self, key: str) -> tuple[str, dict[str, Any]]:
|
||||||
|
if key in self._explicit_inputs:
|
||||||
|
return self._explicit_inputs[key]
|
||||||
|
if _is_stack_input(key):
|
||||||
|
return (
|
||||||
|
"LORA_STACK",
|
||||||
|
{
|
||||||
|
"tooltip": "A LoRA stack to combine. Connect to add more inputs.",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
raise KeyError(key)
|
||||||
|
|
||||||
|
|
||||||
class LoraStackCombinerLM:
|
class LoraStackCombinerLM:
|
||||||
NAME = "Lora Stack Combiner (LoraManager)"
|
NAME = "Lora Stack Combiner (LoraManager)"
|
||||||
CATEGORY = "Lora Manager/stackers"
|
CATEGORY = "Lora Manager/stackers"
|
||||||
|
DESCRIPTION = (
|
||||||
|
"Combines multiple LoRA stacks into a single stack. "
|
||||||
|
"Supports dynamic inputs: connect a stack to add more inputs."
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
return {
|
optional_inputs: dict[str, tuple[str, dict[str, Any]]] = {
|
||||||
"required": {
|
"lora_stack1": (
|
||||||
"lora_stack_a": ("LORA_STACK",),
|
"LORA_STACK",
|
||||||
"lora_stack_b": ("LORA_STACK",),
|
{
|
||||||
|
"tooltip": "A LoRA stack to combine. Connect to add more inputs.",
|
||||||
},
|
},
|
||||||
|
),
|
||||||
|
"lora_stack2": (
|
||||||
|
"LORA_STACK",
|
||||||
|
{
|
||||||
|
"tooltip": "A LoRA stack to combine. Connect to add more inputs.",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
stack = inspect.stack()
|
||||||
|
if len(stack) > 2 and stack[2].function == "get_input_info":
|
||||||
|
optional_inputs = _LoraStackOptionalInputs(optional_inputs) # type: ignore[assignment]
|
||||||
|
|
||||||
|
return {
|
||||||
|
"required": {},
|
||||||
|
"optional": optional_inputs,
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_TYPES = ("LORA_STACK",)
|
RETURN_TYPES = ("LORA_STACK",)
|
||||||
RETURN_NAMES = ("LORA_STACK",)
|
RETURN_NAMES = ("LORA_STACK",)
|
||||||
FUNCTION = "combine_stacks"
|
FUNCTION = "combine_stacks"
|
||||||
|
|
||||||
def combine_stacks(self, lora_stack_a, lora_stack_b):
|
def combine_stacks(self, lora_stack1=None, lora_stack2=None, **kwargs):
|
||||||
combined_stack = []
|
stacks = {
|
||||||
|
"lora_stack1": lora_stack1,
|
||||||
|
"lora_stack2": lora_stack2,
|
||||||
|
}
|
||||||
|
for key, value in kwargs.items():
|
||||||
|
if _is_stack_input(key) and value is not None:
|
||||||
|
stacks[key] = value
|
||||||
|
|
||||||
if lora_stack_a:
|
combined_stack = []
|
||||||
combined_stack.extend(lora_stack_a)
|
for key in sorted(stacks, key=_stack_slot_number):
|
||||||
if lora_stack_b:
|
stack = stacks[key]
|
||||||
combined_stack.extend(lora_stack_b)
|
if stack:
|
||||||
|
combined_stack.extend(stack)
|
||||||
|
|
||||||
return (combined_stack,)
|
return (combined_stack,)
|
||||||
|
|||||||
@@ -0,0 +1,169 @@
|
|||||||
|
"""Metadata Overwrite node — allows users to manually specify generation parameters
|
||||||
|
that override the automatically collected/inferred metadata.
|
||||||
|
|
||||||
|
Most inputs have falsy defaults (empty string / 0) which are skipped.
|
||||||
|
clip_skip uses a sentinel default (-25) so that a wired value of 0 is
|
||||||
|
preserved — both ComfyUI and A1111 conventions have no meaningful 0 value,
|
||||||
|
but users may wire 0 to express "no clip skip / default".
|
||||||
|
"""
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from ..metadata_collector.constants import CLIP_SKIP_SENTINEL as _CLIP_SKIP_SENTINEL
|
||||||
|
from ..metadata_collector.overwrite_utils import collect_overwrite_params
|
||||||
|
|
||||||
|
|
||||||
|
class MetadataOverwriteLM:
|
||||||
|
NAME = "Metadata Overwrite (LoraManager)"
|
||||||
|
CATEGORY = "Lora Manager/utils"
|
||||||
|
DESCRIPTION = (
|
||||||
|
"Manually specify generation parameters to override automatically collected "
|
||||||
|
"metadata. Only filled/connected inputs will take effect — empty defaults "
|
||||||
|
"are ignored."
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(cls) -> dict[str, Any]:
|
||||||
|
return {
|
||||||
|
"optional": {
|
||||||
|
"prompt": (
|
||||||
|
"STRING",
|
||||||
|
{
|
||||||
|
"default": "",
|
||||||
|
"multiline": True,
|
||||||
|
"tooltip": "Positive prompt. Only overwrites when non-empty.",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
"negative_prompt": (
|
||||||
|
"STRING",
|
||||||
|
{
|
||||||
|
"default": "",
|
||||||
|
"multiline": True,
|
||||||
|
"tooltip": "Negative prompt. Only overwrites when non-empty.",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
"seed": (
|
||||||
|
"INT",
|
||||||
|
{
|
||||||
|
"default": 0,
|
||||||
|
"min": 0,
|
||||||
|
"max": 0xFFFFFFFFFFFFFFFF,
|
||||||
|
"control_after_generate": False,
|
||||||
|
"tooltip": "Seed value. Only overwrites when > 0.",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
"steps": (
|
||||||
|
"INT",
|
||||||
|
{
|
||||||
|
"default": 0,
|
||||||
|
"min": 0,
|
||||||
|
"max": 10000,
|
||||||
|
"tooltip": "Number of steps. Only overwrites when > 0.",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
"cfg_scale": (
|
||||||
|
"FLOAT",
|
||||||
|
{
|
||||||
|
"default": 0.0,
|
||||||
|
"min": 0.0,
|
||||||
|
"max": 100.0,
|
||||||
|
"tooltip": "CFG scale. Only overwrites when > 0.",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
"sampler": (
|
||||||
|
"STRING",
|
||||||
|
{
|
||||||
|
"default": "",
|
||||||
|
"tooltip": "Sampler name. Only overwrites when non-empty.",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
"scheduler": (
|
||||||
|
"STRING",
|
||||||
|
{
|
||||||
|
"default": "",
|
||||||
|
"tooltip": "Scheduler name. Only overwrites when non-empty.",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
"model": (
|
||||||
|
"STRING,MODEL",
|
||||||
|
{
|
||||||
|
"default": "",
|
||||||
|
"widgetType": "STRING",
|
||||||
|
"tooltip": (
|
||||||
|
"The checkpoint or diffusion model (UNet) used "
|
||||||
|
"for generation. Fill in the name manually or "
|
||||||
|
"connect a MODEL output — the model name is then "
|
||||||
|
"extracted automatically. Only overwrites when "
|
||||||
|
"non-empty."
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
"loras": (
|
||||||
|
"STRING",
|
||||||
|
{
|
||||||
|
"default": "",
|
||||||
|
"multiline": True,
|
||||||
|
"tooltip": (
|
||||||
|
"LoRA syntax, e.g. <lora:name:strength> "
|
||||||
|
"or <lora:name:model_strength:clip_strength>, "
|
||||||
|
"separated by spaces. Only overwrites when non-empty."
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
"size": (
|
||||||
|
"STRING",
|
||||||
|
{
|
||||||
|
"default": "",
|
||||||
|
"tooltip": (
|
||||||
|
"Image size in WIDTHxHEIGHT format (e.g. 512x768). "
|
||||||
|
"Only overwrites when non-empty."
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
"clip_skip": (
|
||||||
|
"INT",
|
||||||
|
{
|
||||||
|
"default": _CLIP_SKIP_SENTINEL,
|
||||||
|
"min": -25,
|
||||||
|
"max": 24,
|
||||||
|
"tooltip": (
|
||||||
|
"Clip skip (ComfyUI: -24..-1, A1111: 1+). "
|
||||||
|
"Default -25 means not set — any other value "
|
||||||
|
"overwrites."
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
"additional_data": (
|
||||||
|
"STRING",
|
||||||
|
{
|
||||||
|
"default": "",
|
||||||
|
"multiline": True,
|
||||||
|
"tooltip": (
|
||||||
|
"Additional data to embed in the image metadata. "
|
||||||
|
"Inserted between Clip skip and Model hash in the "
|
||||||
|
"A1111-compatible parameters string. "
|
||||||
|
'Example: "Copyright": "Some license info"'
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_TYPES = ("METADATA",)
|
||||||
|
RETURN_NAMES = ("metadata",)
|
||||||
|
FUNCTION = "collect_metadata"
|
||||||
|
OUTPUT_NODE = True
|
||||||
|
|
||||||
|
def collect_metadata(self, **kwargs: Any) -> tuple[dict[str, Any]]:
|
||||||
|
"""Collect non-default input values into a metadata dict.
|
||||||
|
|
||||||
|
For most fields, a falsy value (empty string, 0) means "not set"
|
||||||
|
and is skipped. clip_skip uses a dedicated sentinel (-25) so that
|
||||||
|
a wired value of 0 is preserved and reaches the metadata pipeline.
|
||||||
|
|
||||||
|
The ``model`` field accepts either a manual string or a wired MODEL
|
||||||
|
(ModelPatcher) connection; in the latter case the underlying model
|
||||||
|
name is extracted from the patcher's ``cached_patcher_init`` and
|
||||||
|
stored as a ComfyUI-style relative path.
|
||||||
|
"""
|
||||||
|
return (collect_overwrite_params(kwargs),)
|
||||||
+350
-118
@@ -16,6 +16,156 @@ from PIL import Image, PngImagePlugin
|
|||||||
import piexif
|
import piexif
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
# Civitai-compatible sampler name mapping: ComfyUI internal → A1111 display name
|
||||||
|
CIVITAI_SAMPLER_MAP = {
|
||||||
|
"euler": "Euler",
|
||||||
|
"euler_ancestral": "Euler a",
|
||||||
|
"lms": "LMS",
|
||||||
|
"heun": "Heun",
|
||||||
|
"dpm_2": "DPM2",
|
||||||
|
"dpm_2_ancestral": "DPM2 a",
|
||||||
|
"dpmpp_2s_ancestral": "DPM++ 2S a",
|
||||||
|
"dpmpp_2m": "DPM++ 2M",
|
||||||
|
"dpmpp_sde": "DPM++ SDE",
|
||||||
|
"dpmpp_sde_gpu": "DPM++ SDE",
|
||||||
|
"dpmpp_2m_sde": "DPM++ 2M SDE",
|
||||||
|
"dpmpp_2m_sde_gpu": "DPM++ 2M SDE",
|
||||||
|
"dpmpp_3m_sde": "DPM++ 3M SDE",
|
||||||
|
"dpm_fast": "DPM fast",
|
||||||
|
"dpm_adaptive": "DPM adaptive",
|
||||||
|
"ddim": "DDIM",
|
||||||
|
"plms": "PLMS",
|
||||||
|
"uni_pc_bh2": "UniPC",
|
||||||
|
"uni_pc": "UniPC",
|
||||||
|
"lcm": "LCM",
|
||||||
|
}
|
||||||
|
|
||||||
|
# Base model display name → AIR URN slug
|
||||||
|
# Sourced from civitai source: src/shared/constants/basemodel.constants.ts
|
||||||
|
BASE_MODEL_AIR_SLUG = {
|
||||||
|
# Stable Diffusion family
|
||||||
|
"SD 1.4": "sd1",
|
||||||
|
"SD 1.5": "sd1",
|
||||||
|
"SD 1.5 LCM": "sd1",
|
||||||
|
"SD 1.5 Hyper": "sd1",
|
||||||
|
"SD 2.0": "sd2",
|
||||||
|
"SD 2.0 768": "sd2",
|
||||||
|
"SD 2.1": "sd2",
|
||||||
|
"SD 2.1 768": "sd2",
|
||||||
|
"SD 2.1 Unclip": "sd2",
|
||||||
|
"SD 3.0": "sd3",
|
||||||
|
"SD 3.5": "sd35",
|
||||||
|
"SD 3.5 Large": "sd35",
|
||||||
|
"SD 3.5 Large Turbo": "sd35",
|
||||||
|
"SD 3.5 Medium": "sd35",
|
||||||
|
"SDXL 0.9": "sdxl",
|
||||||
|
"SDXL 1.0": "sdxl",
|
||||||
|
"SDXL 1.0 LCM": "sdxl",
|
||||||
|
"SDXL Lightning": "sdxl",
|
||||||
|
"SDXL Hyper": "sdxl",
|
||||||
|
"SDXL Turbo": "sdxl",
|
||||||
|
"SDXL Distilled": "sdxldistilled",
|
||||||
|
"Stable Cascade": "scascade",
|
||||||
|
"Stable Video Diffusion": "svd",
|
||||||
|
"SVD": "svd",
|
||||||
|
"SVD XT": "svdxt",
|
||||||
|
|
||||||
|
# SDXL community fine-tunes
|
||||||
|
"Pony": "pony",
|
||||||
|
"Pony Diffusion": "pony",
|
||||||
|
"Illustrious": "illustrious",
|
||||||
|
"NoobAI": "noobai",
|
||||||
|
"Animagine": "illustrious",
|
||||||
|
|
||||||
|
# Flux family
|
||||||
|
"Flux.1": "flux1",
|
||||||
|
"Flux.1 D": "flux1",
|
||||||
|
"Flux.1 S": "flux1",
|
||||||
|
"Flux.1 Krea": "fluxkrea",
|
||||||
|
"Flux.1 Kontext": "flux1kontext",
|
||||||
|
"Flux.2": "flux2",
|
||||||
|
"Flux.2 D": "flux2",
|
||||||
|
"Flux.2 Klein 9B": "flux2klein_9b",
|
||||||
|
"Flux.2 Klein 9B Base": "flux2klein_9b_base",
|
||||||
|
"Flux.2 Klein 4B": "flux2klein_4b",
|
||||||
|
"Flux.2 Klein 4B Base": "flux2klein_4b_base",
|
||||||
|
|
||||||
|
# Other image models (sorted alphabetically)
|
||||||
|
"AuraFlow": "auraflow",
|
||||||
|
"Chroma": "chroma",
|
||||||
|
"HiDream": "hidream",
|
||||||
|
"HiDream-O1": "hidream-o1",
|
||||||
|
"Hunyuan DiT": "hydit1",
|
||||||
|
"Hunyuan Video": "hyv1",
|
||||||
|
"Kolors": "kolors",
|
||||||
|
"Lumina": "lumina",
|
||||||
|
"Mochi": "mochi",
|
||||||
|
"ODOR": "odor",
|
||||||
|
"PixArt Alpha": "pixarta",
|
||||||
|
"PixArt Sigma": "pixarte",
|
||||||
|
"Playground v2": "playgroundv2",
|
||||||
|
"Playground v2.5": "playgroundv2",
|
||||||
|
"Pony Diffusion V7": "ponyv7",
|
||||||
|
|
||||||
|
# Video models
|
||||||
|
"CogVideoX": "cogvideox",
|
||||||
|
"LTX Video": "ltxv",
|
||||||
|
"LTX Video 2": "ltxv2",
|
||||||
|
"LTX Video 2.3": "ltxv23",
|
||||||
|
"Wan Video": "wanvideo",
|
||||||
|
"Wan Video 1.3B T2V": "wanvideo_13b_t2v",
|
||||||
|
"Wan Video 14B T2V": "wanvideo_14b_t2v",
|
||||||
|
"Wan Video 14B I2V 480p": "wanvideo_14b_i2v_480p",
|
||||||
|
"Wan Video 14B I2V 720p": "wanvideo_14b_i2v_720p",
|
||||||
|
|
||||||
|
# Third-party / proprietary image models
|
||||||
|
"Boogu": "boogu",
|
||||||
|
"Ernie": "ernie",
|
||||||
|
"Grok": "grok",
|
||||||
|
"HappyHorse": "happyhorse",
|
||||||
|
"Ideogram": "ideogram",
|
||||||
|
"Ideogram 4.0": "ideogram",
|
||||||
|
"Imagen": "imagen4",
|
||||||
|
"Imagen 4": "imagen4",
|
||||||
|
"Krea": "krea2",
|
||||||
|
"Krea 2": "krea2",
|
||||||
|
"Lens": "lens",
|
||||||
|
"MAI": "mai",
|
||||||
|
"Nano Banana": "nanobanana",
|
||||||
|
"OpenAI": "openai",
|
||||||
|
"Reve": "reve",
|
||||||
|
"Reve 2": "reve",
|
||||||
|
"Reve 2.1": "reve",
|
||||||
|
"Seedream": "seedream",
|
||||||
|
"Sora": "sora2",
|
||||||
|
"Sora 2": "sora2",
|
||||||
|
"Veo": "veo3",
|
||||||
|
"Veo 2": "veo3",
|
||||||
|
"Veo 3": "veo3",
|
||||||
|
"ZImageTurbo": "zimageturbo",
|
||||||
|
"ZImageBase": "zimagebase",
|
||||||
|
"ZImage": "zimagebase",
|
||||||
|
|
||||||
|
# Third-party video models
|
||||||
|
"Hailuo by MiniMax": "minimax",
|
||||||
|
"Haiper": "haiper",
|
||||||
|
"Kling": "kling",
|
||||||
|
"Lightricks": "lightricks",
|
||||||
|
"Seedance": "seedance",
|
||||||
|
"Vidu": "vidu",
|
||||||
|
|
||||||
|
# Qwen family
|
||||||
|
"Qwen": "qwen",
|
||||||
|
"Qwen 2": "qwen2",
|
||||||
|
|
||||||
|
# Anima
|
||||||
|
"Anima": "anima",
|
||||||
|
|
||||||
|
# Special
|
||||||
|
"Upscaler": "upscaler",
|
||||||
|
"Other": "other",
|
||||||
|
}
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@@ -70,11 +220,29 @@ class SaveImageLM:
|
|||||||
"tooltip": "Compression quality for JPEG and lossy WebP formats (1-100). Higher values mean better quality but larger files.",
|
"tooltip": "Compression quality for JPEG and lossy WebP formats (1-100). Higher values mean better quality but larger files.",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
"webp_method": (
|
||||||
|
"INT",
|
||||||
|
{
|
||||||
|
"default": 6,
|
||||||
|
"min": 0,
|
||||||
|
"max": 6,
|
||||||
|
"tooltip": "WebP compression method (0-6). 0=fastest/largest, 6=slowest/smallest. Only applies when file_format is 'webp'.",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
"jpeg_subsampling": (
|
||||||
|
"INT",
|
||||||
|
{
|
||||||
|
"default": 0,
|
||||||
|
"min": 0,
|
||||||
|
"max": 2,
|
||||||
|
"tooltip": "JPEG chroma subsampling level. 0=4:4:4 (best quality), 1=4:2:2, 2=4:2:0 (smallest files). Only applies when file_format is 'jpeg'.",
|
||||||
|
},
|
||||||
|
),
|
||||||
"embed_workflow": (
|
"embed_workflow": (
|
||||||
"BOOLEAN",
|
"BOOLEAN",
|
||||||
{
|
{
|
||||||
"default": False,
|
"default": False,
|
||||||
"tooltip": "Embeds the complete workflow data into the image metadata. Only works with PNG and WebP formats.",
|
"tooltip": "When enabled, saved images store the complete workflow. Drag the image back into ComfyUI to restore the original node graph. PNG and WebP only.",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
"save_with_metadata": (
|
"save_with_metadata": (
|
||||||
@@ -84,6 +252,13 @@ class SaveImageLM:
|
|||||||
"tooltip": "When enabled, embeds generation parameters into the saved image metadata. Disable to skip writing generation metadata.",
|
"tooltip": "When enabled, embeds generation parameters into the saved image metadata. Disable to skip writing generation metadata.",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
"add_loras_to_prompt": (
|
||||||
|
"BOOLEAN",
|
||||||
|
{
|
||||||
|
"default": False,
|
||||||
|
"tooltip": "When enabled, appends the LoRA syntax line (e.g. <lora:name:strength>) after the positive prompt in the saved metadata.",
|
||||||
|
},
|
||||||
|
),
|
||||||
"add_counter_to_filename": (
|
"add_counter_to_filename": (
|
||||||
"BOOLEAN",
|
"BOOLEAN",
|
||||||
{
|
{
|
||||||
@@ -142,148 +317,197 @@ class SaveImageLM:
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def format_metadata(self, metadata_dict):
|
def _resolve_model_cache_entry(self, scanner_type: str, name: str):
|
||||||
"""Format metadata in the requested format similar to userComment example"""
|
"""Resolve model hash, civitai metadata, and base_model from scanner cache.
|
||||||
if not metadata_dict:
|
Returns (hash_str, civitai_dict, base_model_str). All values are empty defaults when not found."""
|
||||||
return ""
|
scanner = ServiceRegistry.get_service_sync(scanner_type)
|
||||||
|
if scanner is None or not name:
|
||||||
|
return "", {}, ""
|
||||||
|
|
||||||
# Helper function to only add parameter if value is not None
|
entry = self._get_cached_model_by_name(scanner, name)
|
||||||
def add_param_if_not_none(param_list, label, value):
|
if entry is None:
|
||||||
if value is not None:
|
basename = os.path.splitext(os.path.basename(name))[0]
|
||||||
param_list.append(f"{label}: {value}")
|
hash_val = scanner.get_hash_by_filename(basename)
|
||||||
|
return (hash_val or "").lower(), {}, ""
|
||||||
|
|
||||||
|
hash_val = (entry.get("sha256") or "").lower()
|
||||||
|
civitai = entry.get("civitai") or {}
|
||||||
|
base_model = entry.get("base_model") or ""
|
||||||
|
return hash_val, civitai, base_model
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _get_civitai_sampler_name(sampler_name: str, scheduler: str) -> str:
|
||||||
|
if sampler_name in CIVITAI_SAMPLER_MAP:
|
||||||
|
civitai_name = CIVITAI_SAMPLER_MAP[sampler_name]
|
||||||
|
if scheduler == "karras":
|
||||||
|
civitai_name += " Karras"
|
||||||
|
elif scheduler == "exponential":
|
||||||
|
civitai_name += " Exponential"
|
||||||
|
return civitai_name
|
||||||
|
else:
|
||||||
|
if scheduler and scheduler != "normal":
|
||||||
|
return f"{sampler_name}_{scheduler}"
|
||||||
|
return sampler_name
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _build_air_string(base_model: str, model_type: str, model_id: int, version_id: int) -> str:
|
||||||
|
slug = BASE_MODEL_AIR_SLUG.get(base_model, "other")
|
||||||
|
type_lower = model_type.lower() if model_type else "other"
|
||||||
|
return f"urn:air:{slug}:{type_lower}:civitai:{model_id}@{version_id}"
|
||||||
|
|
||||||
|
def format_metadata(self, metadata_dict: dict, add_loras_to_prompt: bool = False) -> str:
|
||||||
|
"""Format metadata as A1111-compatible parameters string with Hashes JSON and Civitai resources."""
|
||||||
|
if not metadata_dict: return ""
|
||||||
|
|
||||||
# Extract the prompt and negative prompt
|
|
||||||
prompt = metadata_dict.get("prompt", "")
|
prompt = metadata_dict.get("prompt", "")
|
||||||
negative_prompt = metadata_dict.get("negative_prompt", "")
|
negative_prompt = metadata_dict.get("negative_prompt", "")
|
||||||
|
steps = metadata_dict.get("steps")
|
||||||
# Extract loras from the prompt if present
|
cfg = metadata_dict.get("guidance")
|
||||||
|
if cfg is None:
|
||||||
|
cfg = metadata_dict.get("cfg_scale")
|
||||||
|
if cfg is None:
|
||||||
|
cfg = metadata_dict.get("cfg")
|
||||||
|
seed = metadata_dict.get("seed")
|
||||||
|
size = metadata_dict.get("size")
|
||||||
|
sampler = metadata_dict.get("sampler") or ""
|
||||||
|
scheduler = metadata_dict.get("scheduler") or "normal"
|
||||||
|
checkpoint = metadata_dict.get("checkpoint") or ""
|
||||||
loras_text = metadata_dict.get("loras", "")
|
loras_text = metadata_dict.get("loras", "")
|
||||||
lora_hashes = {}
|
clip_skip = metadata_dict.get("clip_skip")
|
||||||
|
|
||||||
# If loras are found, add them on a new line after the prompt
|
# Parse LoRA entries from <lora:name:strength> format
|
||||||
|
lora_entries: list[tuple[str, float]] = []
|
||||||
if loras_text:
|
if loras_text:
|
||||||
prompt_with_loras = f"{prompt}\n{loras_text}"
|
for match in re.findall(r"<lora:([^:]+):([^>]+)>", loras_text):
|
||||||
|
lora_name, strength_str = match
|
||||||
|
try:
|
||||||
|
strength = float(strength_str)
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
strength = 1.0
|
||||||
|
lora_entries.append((lora_name, strength))
|
||||||
|
|
||||||
# Extract lora names from the format <lora:name:strength>
|
# Resolve checkpoint hash and Civitai data from local cache
|
||||||
lora_matches = re.findall(r"<lora:([^:]+):([^>]+)>", loras_text)
|
ckpt_hash, ckpt_civitai, ckpt_base_model = "", {}, ""
|
||||||
|
ckpt_display_name = ""
|
||||||
|
if checkpoint:
|
||||||
|
ckpt_hash, ckpt_civitai, ckpt_base_model = self._resolve_model_cache_entry(
|
||||||
|
"checkpoint_scanner", checkpoint
|
||||||
|
)
|
||||||
|
ckpt_display_name = os.path.splitext(os.path.basename(checkpoint))[0]
|
||||||
|
|
||||||
# Get hash for each lora
|
# Resolve LoRA hash and Civitai data from local cache
|
||||||
for lora_name, strength in lora_matches:
|
loras_data: list[dict] = []
|
||||||
hash_value = self.get_lora_hash(lora_name)
|
for lora_name, strength in lora_entries:
|
||||||
if hash_value:
|
lora_hash, lora_civitai, lora_base_model = self._resolve_model_cache_entry(
|
||||||
lora_hashes[lora_name] = hash_value
|
"lora_scanner", lora_name
|
||||||
else:
|
)
|
||||||
prompt_with_loras = prompt
|
loras_data.append({
|
||||||
|
"name": lora_name,
|
||||||
|
"strength": strength,
|
||||||
|
"hash": lora_hash,
|
||||||
|
"civitai": lora_civitai,
|
||||||
|
"base_model": lora_base_model,
|
||||||
|
})
|
||||||
|
|
||||||
# Format the first part (prompt and loras)
|
# Build Hashes JSON (A1111 / Civitai standard format)
|
||||||
metadata_parts = [prompt_with_loras]
|
hashes: dict[str, str] = {}
|
||||||
|
if ckpt_hash:
|
||||||
|
hashes["model"] = ckpt_hash[:10].upper()
|
||||||
|
for lora in loras_data:
|
||||||
|
if lora["hash"]:
|
||||||
|
hashes[f"LORA:{lora['name']}"] = lora["hash"][:10].upper()
|
||||||
|
|
||||||
# Add negative prompt
|
# Build Civitai resources JSON array
|
||||||
if negative_prompt:
|
civitai_resources: list[dict] = []
|
||||||
metadata_parts.append(f"Negative prompt: {negative_prompt}")
|
if ckpt_civitai.get("id", 0) > 0:
|
||||||
|
ckpt_resource: dict = {}
|
||||||
|
ckpt_type = (ckpt_civitai.get("model") or {}).get("type", "Checkpoint")
|
||||||
|
model_id = ckpt_civitai.get("modelId", 0)
|
||||||
|
version_id = ckpt_civitai.get("id", 0)
|
||||||
|
if model_id and version_id:
|
||||||
|
ckpt_resource["air"] = self._build_air_string(
|
||||||
|
ckpt_base_model, ckpt_type, int(model_id), int(version_id)
|
||||||
|
)
|
||||||
|
elif version_id:
|
||||||
|
ckpt_resource["modelVersionId"] = int(version_id)
|
||||||
|
if ckpt_civitai.get("name"):
|
||||||
|
ckpt_resource["versionName"] = ckpt_civitai["name"]
|
||||||
|
if ckpt_resource:
|
||||||
|
civitai_resources.append(ckpt_resource)
|
||||||
|
|
||||||
# Format the second part (generation parameters)
|
for lora in loras_data:
|
||||||
params = []
|
lora_civitai = lora["civitai"]
|
||||||
|
if not lora_civitai or lora_civitai.get("id", 0) <= 0:
|
||||||
|
continue
|
||||||
|
lora_resource: dict = {"weight": lora["strength"]}
|
||||||
|
lora_type = (lora_civitai.get("model") or {}).get("type", "LORA")
|
||||||
|
model_id = lora_civitai.get("modelId", 0)
|
||||||
|
version_id = lora_civitai.get("id", 0)
|
||||||
|
if model_id and version_id:
|
||||||
|
lora_resource["air"] = self._build_air_string(
|
||||||
|
lora["base_model"], lora_type, int(model_id), int(version_id)
|
||||||
|
)
|
||||||
|
elif version_id:
|
||||||
|
lora_resource["modelVersionId"] = int(version_id)
|
||||||
|
if lora_civitai.get("name"):
|
||||||
|
lora_resource["versionName"] = lora_civitai["name"]
|
||||||
|
civitai_resources.append(lora_resource)
|
||||||
|
|
||||||
# Add standard parameters in the correct order
|
sampler_name = CIVITAI_SAMPLER_MAP.get(sampler, sampler) if sampler else None
|
||||||
if "steps" in metadata_dict:
|
|
||||||
add_param_if_not_none(params, "Steps", metadata_dict.get("steps"))
|
|
||||||
|
|
||||||
# Combine sampler and scheduler information
|
|
||||||
sampler_name = None
|
|
||||||
scheduler_name = None
|
|
||||||
|
|
||||||
if "sampler" in metadata_dict:
|
|
||||||
sampler = metadata_dict.get("sampler")
|
|
||||||
# Convert ComfyUI sampler names to user-friendly names
|
|
||||||
sampler_mapping = {
|
|
||||||
"euler": "Euler",
|
|
||||||
"euler_ancestral": "Euler a",
|
|
||||||
"dpm_2": "DPM2",
|
|
||||||
"dpm_2_ancestral": "DPM2 a",
|
|
||||||
"heun": "Heun",
|
|
||||||
"dpm_fast": "DPM fast",
|
|
||||||
"dpm_adaptive": "DPM adaptive",
|
|
||||||
"lms": "LMS",
|
|
||||||
"dpmpp_2s_ancestral": "DPM++ 2S a",
|
|
||||||
"dpmpp_sde": "DPM++ SDE",
|
|
||||||
"dpmpp_sde_gpu": "DPM++ SDE",
|
|
||||||
"dpmpp_2m": "DPM++ 2M",
|
|
||||||
"dpmpp_2m_sde": "DPM++ 2M SDE",
|
|
||||||
"dpmpp_2m_sde_gpu": "DPM++ 2M SDE",
|
|
||||||
"ddim": "DDIM",
|
|
||||||
}
|
|
||||||
sampler_name = sampler_mapping.get(sampler, sampler)
|
|
||||||
|
|
||||||
if "scheduler" in metadata_dict:
|
|
||||||
scheduler = metadata_dict.get("scheduler")
|
|
||||||
scheduler_mapping = {
|
scheduler_mapping = {
|
||||||
"normal": "Simple",
|
"normal": "Normal",
|
||||||
"karras": "Karras",
|
"karras": "Karras",
|
||||||
"exponential": "Exponential",
|
"exponential": "Exponential",
|
||||||
"sgm_uniform": "SGM Uniform",
|
"sgm_uniform": "SGM Uniform",
|
||||||
"sgm_quadratic": "SGM Quadratic",
|
"sgm_quadratic": "SGM Quadratic",
|
||||||
}
|
}
|
||||||
scheduler_name = scheduler_mapping.get(scheduler, scheduler)
|
scheduler_name = scheduler_mapping.get(scheduler, scheduler) if scheduler else None
|
||||||
|
|
||||||
# Add combined sampler and scheduler information
|
# Build output lines
|
||||||
|
prompt_line = prompt if prompt else ""
|
||||||
|
if add_loras_to_prompt and loras_text:
|
||||||
|
prompt_line = f"{prompt_line}\n{loras_text}" if prompt_line else loras_text
|
||||||
|
lines = [prompt_line] if prompt_line else [""]
|
||||||
|
if negative_prompt:
|
||||||
|
lines.append(f"Negative prompt: {negative_prompt}")
|
||||||
|
|
||||||
|
params: list[str] = []
|
||||||
|
if steps is not None:
|
||||||
|
params.append(f"Steps: {steps}")
|
||||||
if sampler_name:
|
if sampler_name:
|
||||||
if scheduler_name:
|
if scheduler_name:
|
||||||
params.append(f"Sampler: {sampler_name} {scheduler_name}")
|
params.append(f"Sampler: {sampler_name} {scheduler_name}")
|
||||||
else:
|
else:
|
||||||
params.append(f"Sampler: {sampler_name}")
|
params.append(f"Sampler: {sampler_name}")
|
||||||
|
if cfg is not None:
|
||||||
# CFG scale (Use guidance if available, otherwise fall back to cfg_scale or cfg)
|
params.append(f"CFG scale: {cfg}")
|
||||||
if "guidance" in metadata_dict:
|
if seed is not None:
|
||||||
add_param_if_not_none(params, "CFG scale", metadata_dict.get("guidance"))
|
params.append(f"Seed: {seed}")
|
||||||
elif "cfg_scale" in metadata_dict:
|
if size:
|
||||||
add_param_if_not_none(params, "CFG scale", metadata_dict.get("cfg_scale"))
|
params.append(f"Size: {size}")
|
||||||
elif "cfg" in metadata_dict:
|
if clip_skip is not None:
|
||||||
add_param_if_not_none(params, "CFG scale", metadata_dict.get("cfg"))
|
try:
|
||||||
|
params.append(f"Clip skip: {abs(int(clip_skip))}")
|
||||||
# Seed
|
except (ValueError, TypeError):
|
||||||
if "seed" in metadata_dict:
|
pass
|
||||||
add_param_if_not_none(params, "Seed", metadata_dict.get("seed"))
|
additional_data = metadata_dict.get("additional_data", "")
|
||||||
|
if additional_data:
|
||||||
# Size
|
params.append(additional_data)
|
||||||
if "size" in metadata_dict:
|
if ckpt_hash:
|
||||||
add_param_if_not_none(params, "Size", metadata_dict.get("size"))
|
params.append(f"Model hash: {ckpt_hash[:10].upper()}")
|
||||||
|
if ckpt_display_name:
|
||||||
# Model info
|
params.append(f"Model: {ckpt_display_name}")
|
||||||
if "checkpoint" in metadata_dict:
|
if hashes:
|
||||||
# Ensure checkpoint is a string before processing
|
params.append(f"Hashes: {json.dumps(hashes, separators=(',', ':'))}")
|
||||||
checkpoint = metadata_dict.get("checkpoint")
|
params.append("Version: ComfyUI")
|
||||||
if checkpoint is not None:
|
if civitai_resources:
|
||||||
# Get model hash
|
|
||||||
model_hash = self.get_checkpoint_hash(checkpoint)
|
|
||||||
|
|
||||||
# Extract basename without path
|
|
||||||
checkpoint_name = os.path.basename(checkpoint)
|
|
||||||
# Remove extension if present
|
|
||||||
checkpoint_name = os.path.splitext(checkpoint_name)[0]
|
|
||||||
|
|
||||||
# Add model hash if available
|
|
||||||
if model_hash:
|
|
||||||
params.append(
|
params.append(
|
||||||
f"Model hash: {model_hash[:10]}, Model: {checkpoint_name}"
|
f"Civitai resources: {json.dumps(civitai_resources, separators=(',', ':'))}"
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
params.append(f"Model: {checkpoint_name}")
|
|
||||||
|
|
||||||
# Add LoRA hashes if available
|
lines.append(", ".join(params))
|
||||||
if lora_hashes:
|
return "\n".join(lines)
|
||||||
lora_hash_parts = []
|
|
||||||
for lora_name, hash_value in lora_hashes.items():
|
|
||||||
lora_hash_parts.append(f"{lora_name}: {hash_value[:10]}")
|
|
||||||
|
|
||||||
if lora_hash_parts:
|
|
||||||
params.append(f'Lora hashes: "{", ".join(lora_hash_parts)}"')
|
|
||||||
|
|
||||||
# Combine all parameters with commas
|
|
||||||
metadata_parts.append(", ".join(params))
|
|
||||||
|
|
||||||
# Join all parts with a new line
|
|
||||||
return "\n".join(metadata_parts)
|
|
||||||
|
|
||||||
# credit to nkchocoai
|
# credit to nkchocoai
|
||||||
# Add format_filename method to handle pattern substitution
|
# Add format_filename method to handle pattern substitution
|
||||||
@@ -573,10 +797,13 @@ class SaveImageLM:
|
|||||||
extra_pnginfo=None,
|
extra_pnginfo=None,
|
||||||
lossless_webp=True,
|
lossless_webp=True,
|
||||||
quality=100,
|
quality=100,
|
||||||
|
webp_method=6,
|
||||||
|
jpeg_subsampling=0,
|
||||||
embed_workflow=False,
|
embed_workflow=False,
|
||||||
save_with_metadata=True,
|
save_with_metadata=True,
|
||||||
add_counter_to_filename=True,
|
add_counter_to_filename=True,
|
||||||
save_as_recipe=False,
|
save_as_recipe=False,
|
||||||
|
add_loras_to_prompt=False,
|
||||||
):
|
):
|
||||||
"""Save images with metadata"""
|
"""Save images with metadata"""
|
||||||
results = []
|
results = []
|
||||||
@@ -585,7 +812,7 @@ class SaveImageLM:
|
|||||||
raw_metadata = get_metadata()
|
raw_metadata = get_metadata()
|
||||||
metadata_dict = MetadataProcessor.to_dict(raw_metadata, id)
|
metadata_dict = MetadataProcessor.to_dict(raw_metadata, id)
|
||||||
|
|
||||||
metadata = self.format_metadata(metadata_dict)
|
metadata = self.format_metadata(metadata_dict, add_loras_to_prompt)
|
||||||
|
|
||||||
# Process filename_prefix with pattern substitution
|
# Process filename_prefix with pattern substitution
|
||||||
filename_prefix = self.format_filename(filename_prefix, metadata_dict)
|
filename_prefix = self.format_filename(filename_prefix, metadata_dict)
|
||||||
@@ -627,15 +854,14 @@ class SaveImageLM:
|
|||||||
elif file_format == "jpeg":
|
elif file_format == "jpeg":
|
||||||
file = base_filename + ".jpg"
|
file = base_filename + ".jpg"
|
||||||
file_extension = ".jpg"
|
file_extension = ".jpg"
|
||||||
save_kwargs = {"quality": quality, "optimize": True}
|
save_kwargs = {"quality": quality, "optimize": True, "subsampling": jpeg_subsampling}
|
||||||
elif file_format == "webp":
|
elif file_format == "webp":
|
||||||
file = base_filename + ".webp"
|
file = base_filename + ".webp"
|
||||||
file_extension = ".webp"
|
file_extension = ".webp"
|
||||||
# Add optimization param to control performance
|
|
||||||
save_kwargs = {
|
save_kwargs = {
|
||||||
"quality": quality,
|
"quality": quality,
|
||||||
"lossless": lossless_webp,
|
"lossless": lossless_webp,
|
||||||
"method": 0,
|
"method": webp_method,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Unsupported file format: {file_format}")
|
raise ValueError(f"Unsupported file format: {file_format}")
|
||||||
@@ -722,10 +948,13 @@ class SaveImageLM:
|
|||||||
extra_pnginfo=None,
|
extra_pnginfo=None,
|
||||||
lossless_webp=True,
|
lossless_webp=True,
|
||||||
quality=100,
|
quality=100,
|
||||||
|
webp_method=6,
|
||||||
|
jpeg_subsampling=0,
|
||||||
embed_workflow=False,
|
embed_workflow=False,
|
||||||
save_with_metadata=True,
|
save_with_metadata=True,
|
||||||
add_counter_to_filename=True,
|
add_counter_to_filename=True,
|
||||||
save_as_recipe=False,
|
save_as_recipe=False,
|
||||||
|
add_loras_to_prompt=False,
|
||||||
):
|
):
|
||||||
"""Process and save image with metadata"""
|
"""Process and save image with metadata"""
|
||||||
# Make sure the output directory exists
|
# Make sure the output directory exists
|
||||||
@@ -751,10 +980,13 @@ class SaveImageLM:
|
|||||||
extra_pnginfo,
|
extra_pnginfo,
|
||||||
lossless_webp,
|
lossless_webp,
|
||||||
quality,
|
quality,
|
||||||
|
webp_method,
|
||||||
|
jpeg_subsampling,
|
||||||
embed_workflow,
|
embed_workflow,
|
||||||
save_with_metadata,
|
save_with_metadata,
|
||||||
add_counter_to_filename,
|
add_counter_to_filename,
|
||||||
save_as_recipe,
|
save_as_recipe,
|
||||||
|
add_loras_to_prompt,
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -7,6 +7,21 @@ from ..utils.utils import get_checkpoint_info_absolute, _format_model_name_for_c
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def _reload_gguf_unet(
|
||||||
|
unet_path: str, weight_dtype: str, disable_dynamic: bool = False
|
||||||
|
) -> object:
|
||||||
|
"""Reload a GGUF diffusion model from disk (cached_patcher_init factory).
|
||||||
|
|
||||||
|
Mirrors the GGUF branch of UNETLoaderLM.load_unet so ModelPatcher
|
||||||
|
deepclone/dynamic machinery can rebuild GGUF models with the correct
|
||||||
|
GGMLOps. ``disable_dynamic`` is accepted for signature compatibility
|
||||||
|
with core ComfyUI loaders.
|
||||||
|
"""
|
||||||
|
loader = UNETLoaderLM()
|
||||||
|
model, = loader._load_gguf_unet(unet_path, unet_path, weight_dtype)
|
||||||
|
return model
|
||||||
|
|
||||||
|
|
||||||
class UNETLoaderLM:
|
class UNETLoaderLM:
|
||||||
"""UNET Loader with support for extra folder paths
|
"""UNET Loader with support for extra folder paths
|
||||||
|
|
||||||
@@ -196,6 +211,12 @@ class UNETLoaderLM:
|
|||||||
# Wrap with GGUFModelPatcher
|
# Wrap with GGUFModelPatcher
|
||||||
model = GGUFModelPatcher.clone(model)
|
model = GGUFModelPatcher.clone(model)
|
||||||
|
|
||||||
|
# Register a reload factory so the MODEL carries its source path
|
||||||
|
# (cached_patcher_init) like core ComfyUI loaders do — required
|
||||||
|
# for model-name extraction downstream and for ModelPatcher
|
||||||
|
# deepclone/dynamic machinery.
|
||||||
|
model.cached_patcher_init = (_reload_gguf_unet, (unet_path, weight_dtype))
|
||||||
|
|
||||||
return (model,)
|
return (model,)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -1562,6 +1562,11 @@ class SettingsHandler:
|
|||||||
{"success": False, "error": validation_error}
|
{"success": False, "error": validation_error}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if key == "update_channel" and value not in ("release", "nightly"):
|
||||||
|
return web.json_response(
|
||||||
|
{"success": False, "error": "update_channel must be 'release' or 'nightly'"}
|
||||||
|
)
|
||||||
|
|
||||||
if value == "__DELETE__" and key in (
|
if value == "__DELETE__" and key in (
|
||||||
"proxy_username",
|
"proxy_username",
|
||||||
"proxy_password",
|
"proxy_password",
|
||||||
@@ -2585,6 +2590,8 @@ class ModelLibraryHandler:
|
|||||||
status=400,
|
status=400,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cursor = request.query.get("cursor")
|
||||||
|
|
||||||
metadata_provider = await self._metadata_provider_factory()
|
metadata_provider = await self._metadata_provider_factory()
|
||||||
if not metadata_provider:
|
if not metadata_provider:
|
||||||
return web.json_response(
|
return web.json_response(
|
||||||
@@ -2593,7 +2600,7 @@ class ModelLibraryHandler:
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
models = await metadata_provider.get_user_models(username)
|
result = await metadata_provider.get_user_models(username, cursor)
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
return web.json_response(
|
return web.json_response(
|
||||||
{
|
{
|
||||||
@@ -2603,14 +2610,35 @@ class ModelLibraryHandler:
|
|||||||
status=501,
|
status=501,
|
||||||
)
|
)
|
||||||
|
|
||||||
if models is None:
|
if result is None:
|
||||||
return web.json_response(
|
return web.json_response(
|
||||||
{"success": False, "error": "Failed to fetch user models"},
|
{"success": False, "error": "Failed to fetch user models"},
|
||||||
status=502,
|
status=502,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if isinstance(result, dict):
|
||||||
|
models = result.get("items")
|
||||||
|
next_cursor = result.get("nextCursor")
|
||||||
|
else:
|
||||||
|
# Defensive: tolerate providers that still return a raw list
|
||||||
|
models = result
|
||||||
|
next_cursor = None
|
||||||
|
|
||||||
if not isinstance(models, list):
|
if not isinstance(models, list):
|
||||||
models = []
|
models = []
|
||||||
|
if next_cursor is not None and not isinstance(next_cursor, str):
|
||||||
|
next_cursor = str(next_cursor)
|
||||||
|
|
||||||
|
estimated_total = None
|
||||||
|
if cursor is None:
|
||||||
|
get_count = getattr(metadata_provider, "get_creator_model_count", None)
|
||||||
|
if get_count is not None:
|
||||||
|
try:
|
||||||
|
estimated_total = await get_count(username)
|
||||||
|
except Exception: # best-effort only
|
||||||
|
estimated_total = None
|
||||||
|
if not isinstance(estimated_total, int):
|
||||||
|
estimated_total = None
|
||||||
|
|
||||||
lora_scanner = await self._service_registry.get_lora_scanner()
|
lora_scanner = await self._service_registry.get_lora_scanner()
|
||||||
checkpoint_scanner = await self._service_registry.get_checkpoint_scanner()
|
checkpoint_scanner = await self._service_registry.get_checkpoint_scanner()
|
||||||
@@ -2630,6 +2658,7 @@ class ModelLibraryHandler:
|
|||||||
versions: list[dict] = []
|
versions: list[dict] = []
|
||||||
history_service = await self._get_download_history_service()
|
history_service = await self._get_download_history_service()
|
||||||
model_ids: list[int] = []
|
model_ids: list[int] = []
|
||||||
|
model_count = 0
|
||||||
for model in models:
|
for model in models:
|
||||||
try:
|
try:
|
||||||
model_ids.append(int(model.get("id")))
|
model_ids.append(int(model.get("id")))
|
||||||
@@ -2663,6 +2692,8 @@ class ModelLibraryHandler:
|
|||||||
if model_type not in normalized_allowed_types:
|
if model_type not in normalized_allowed_types:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
model_count += 1
|
||||||
|
|
||||||
scanner = type_scanner_map.get(model_type)
|
scanner = type_scanner_map.get(model_type)
|
||||||
if scanner is None:
|
if scanner is None:
|
||||||
return web.json_response(
|
return web.json_response(
|
||||||
@@ -2728,7 +2759,15 @@ class ModelLibraryHandler:
|
|||||||
)
|
)
|
||||||
|
|
||||||
return web.json_response(
|
return web.json_response(
|
||||||
{"success": True, "username": username, "versions": versions}
|
{
|
||||||
|
"success": True,
|
||||||
|
"username": username,
|
||||||
|
"versions": versions,
|
||||||
|
"modelCount": model_count,
|
||||||
|
"nextCursor": next_cursor,
|
||||||
|
"hasMore": next_cursor is not None,
|
||||||
|
"estimatedTotal": estimated_total,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
except Exception as exc: # pragma: no cover - defensive logging
|
except Exception as exc: # pragma: no cover - defensive logging
|
||||||
logger.error("Failed to get Civitai user models: %s", exc, exc_info=True)
|
logger.error("Failed to get Civitai user models: %s", exc, exc_info=True)
|
||||||
|
|||||||
@@ -394,12 +394,14 @@ class ModelListingHandler:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# View-local-versions filter: show all local versions of a specific model
|
# View-local-versions filter: show all local versions of a specific model
|
||||||
|
# Accepts either a CivitAI modelId (int) or a HF group key like "hf:user/repo"
|
||||||
civitai_model_id = request.query.get("civitai_model_id")
|
civitai_model_id = request.query.get("civitai_model_id")
|
||||||
if civitai_model_id is not None:
|
if civitai_model_id is not None:
|
||||||
try:
|
try:
|
||||||
civitai_model_id = int(civitai_model_id)
|
civitai_model_id = int(civitai_model_id)
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
civitai_model_id = None
|
# Keep as string — could be an HF group key (e.g. "hf:user/repo")
|
||||||
|
pass
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"page": page,
|
"page": page,
|
||||||
@@ -537,6 +539,7 @@ class ModelManagementHandler:
|
|||||||
# Update model_data with new hash
|
# Update model_data with new hash
|
||||||
model_data["sha256"] = sha256
|
model_data["sha256"] = sha256
|
||||||
model_data["hash_status"] = "completed"
|
model_data["hash_status"] = "completed"
|
||||||
|
hash_status = "completed"
|
||||||
else:
|
else:
|
||||||
return web.json_response(
|
return web.json_response(
|
||||||
{"success": False, "error": "No SHA256 hash found"}, status=400
|
{"success": False, "error": "No SHA256 hash found"}, status=400
|
||||||
@@ -544,6 +547,32 @@ class ModelManagementHandler:
|
|||||||
|
|
||||||
await MetadataManager.hydrate_model_data(model_data)
|
await MetadataManager.hydrate_model_data(model_data)
|
||||||
|
|
||||||
|
# hydrate_model_data replaces model_data with .metadata.json content,
|
||||||
|
# which may lack sha256. Restore from cache and persist the fix.
|
||||||
|
if not model_data.get("sha256"):
|
||||||
|
if sha256:
|
||||||
|
model_data["sha256"] = sha256
|
||||||
|
model_data["hash_status"] = model_data.get("hash_status", hash_status)
|
||||||
|
data_to_save = model_data.copy()
|
||||||
|
data_to_save.pop("folder", None)
|
||||||
|
await MetadataManager.save_metadata(file_path, data_to_save)
|
||||||
|
else:
|
||||||
|
sha256 = await calculate_sha256(file_path)
|
||||||
|
if sha256:
|
||||||
|
model_data["sha256"] = sha256.lower()
|
||||||
|
model_data["hash_status"] = "completed"
|
||||||
|
data_to_save = model_data.copy()
|
||||||
|
data_to_save.pop("folder", None)
|
||||||
|
await MetadataManager.save_metadata(file_path, data_to_save)
|
||||||
|
else:
|
||||||
|
return web.json_response(
|
||||||
|
{
|
||||||
|
"success": False,
|
||||||
|
"error": "Failed to compute SHA256 hash for model",
|
||||||
|
},
|
||||||
|
status=500,
|
||||||
|
)
|
||||||
|
|
||||||
success, error = await self._metadata_sync.fetch_and_update_model(
|
success, error = await self._metadata_sync.fetch_and_update_model(
|
||||||
sha256=model_data["sha256"],
|
sha256=model_data["sha256"],
|
||||||
file_path=file_path,
|
file_path=file_path,
|
||||||
@@ -566,7 +595,12 @@ class ModelManagementHandler:
|
|||||||
{"success": False, "error": OFFLINE_FRIENDLY_MESSAGE},
|
{"success": False, "error": OFFLINE_FRIENDLY_MESSAGE},
|
||||||
status=503,
|
status=503,
|
||||||
)
|
)
|
||||||
self._logger.error("Error fetching from CivitAI: %s", exc, exc_info=True)
|
self._logger.error(
|
||||||
|
"Error fetching from CivitAI for %s: %s",
|
||||||
|
locals().get("file_path", "unknown"),
|
||||||
|
exc,
|
||||||
|
exc_info=True,
|
||||||
|
)
|
||||||
return web.json_response({"success": False, "error": str(exc)}, status=500)
|
return web.json_response({"success": False, "error": str(exc)}, status=500)
|
||||||
|
|
||||||
async def relink_civitai(self, request: web.Request) -> web.Response:
|
async def relink_civitai(self, request: web.Request) -> web.Response:
|
||||||
@@ -1454,8 +1488,73 @@ class ModelQueryHandler:
|
|||||||
search = request.query.get("search", "").strip()
|
search = request.query.get("search", "").strip()
|
||||||
limit = min(int(request.query.get("limit", "15")), 100)
|
limit = min(int(request.query.get("limit", "15")), 100)
|
||||||
offset = max(0, int(request.query.get("offset", "0")))
|
offset = max(0, int(request.query.get("offset", "0")))
|
||||||
|
|
||||||
|
folder = request.query.get("folder")
|
||||||
|
recursive = request.query.get("recursive", "true").lower() == "true"
|
||||||
|
base_models = list(request.query.getall("base_model", []))
|
||||||
|
model_types = list(request.query.getall("model_type", []))
|
||||||
|
|
||||||
|
tag_filters: Dict[str, str] = {}
|
||||||
|
for tag in request.query.getall("tag_include", []):
|
||||||
|
if tag:
|
||||||
|
tag_filters[tag] = "include"
|
||||||
|
for tag in request.query.getall("tag_exclude", []):
|
||||||
|
if tag:
|
||||||
|
tag_filters[tag] = "exclude"
|
||||||
|
|
||||||
|
auto_tag_filters: Dict[str, str] = {}
|
||||||
|
for tag in request.query.getall("auto_tag_include", []):
|
||||||
|
if tag:
|
||||||
|
auto_tag_filters[tag] = "include"
|
||||||
|
for tag in request.query.getall("auto_tag_exclude", []):
|
||||||
|
if tag:
|
||||||
|
auto_tag_filters[tag] = "exclude"
|
||||||
|
|
||||||
|
tag_logic = request.query.get("tag_logic", "any").lower()
|
||||||
|
if tag_logic not in ("any", "all"):
|
||||||
|
tag_logic = "any"
|
||||||
|
|
||||||
|
credit_required = request.query.get("credit_required")
|
||||||
|
if credit_required is not None:
|
||||||
|
credit_required = credit_required.lower() not in ("false", "0", "")
|
||||||
|
|
||||||
|
allow_selling_generated_content = request.query.get(
|
||||||
|
"allow_selling_generated_content"
|
||||||
|
)
|
||||||
|
if allow_selling_generated_content is not None:
|
||||||
|
allow_selling_generated_content = (
|
||||||
|
allow_selling_generated_content.lower() not in ("false", "0", "")
|
||||||
|
)
|
||||||
|
|
||||||
|
# The presence of the recursive param (always sent by the loras
|
||||||
|
# widget when filter mode is on) signals that the filter pipeline
|
||||||
|
# must run even when no concrete filter is set, so global settings
|
||||||
|
# like show_only_sfw stay consistent with the list endpoint.
|
||||||
|
apply_filters = (
|
||||||
|
"recursive" in request.query
|
||||||
|
or folder is not None
|
||||||
|
or bool(base_models)
|
||||||
|
or bool(model_types)
|
||||||
|
or bool(tag_filters)
|
||||||
|
or bool(auto_tag_filters)
|
||||||
|
or credit_required is not None
|
||||||
|
or allow_selling_generated_content is not None
|
||||||
|
)
|
||||||
|
|
||||||
matching_paths = await self._service.search_relative_paths(
|
matching_paths = await self._service.search_relative_paths(
|
||||||
search, limit, offset
|
search,
|
||||||
|
limit,
|
||||||
|
offset,
|
||||||
|
folder=folder,
|
||||||
|
recursive=recursive,
|
||||||
|
base_models=base_models,
|
||||||
|
model_types=model_types,
|
||||||
|
tags=tag_filters,
|
||||||
|
auto_tags=auto_tag_filters,
|
||||||
|
tag_logic=tag_logic,
|
||||||
|
credit_required=credit_required,
|
||||||
|
allow_selling_generated_content=allow_selling_generated_content,
|
||||||
|
apply_filters=apply_filters,
|
||||||
)
|
)
|
||||||
return web.json_response(
|
return web.json_response(
|
||||||
{"success": True, "relative_paths": matching_paths}
|
{"success": True, "relative_paths": matching_paths}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import asyncio
|
|||||||
import tempfile
|
import tempfile
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Awaitable, Callable, Dict, List, Mapping, Optional
|
from typing import Any, Awaitable, Callable, Dict, List, Mapping, Optional, Tuple
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
|
||||||
@@ -44,6 +44,22 @@ EnsureDependenciesCallable = Callable[[], Awaitable[None]]
|
|||||||
RecipeScannerGetter = Callable[[], Any]
|
RecipeScannerGetter = Callable[[], Any]
|
||||||
CivitaiClientGetter = Callable[[], Any]
|
CivitaiClientGetter = Callable[[], Any]
|
||||||
|
|
||||||
|
# Cap concurrent preview-dimension reads across requests. With a cold LRU
|
||||||
|
# cache one page can touch up to page_size image files; 16 balances SSD and
|
||||||
|
# HDD throughput without starving the event loop.
|
||||||
|
_DIMS_READ_SEMAPHORE = asyncio.Semaphore(16)
|
||||||
|
|
||||||
|
|
||||||
|
async def _read_preview_dims(path: str) -> Optional[Tuple[int, int]]:
|
||||||
|
"""Read preview dimensions off the event loop under the concurrency cap.
|
||||||
|
|
||||||
|
PIL I/O runs in a worker thread so it never blocks the event loop, and the
|
||||||
|
semaphore bounds how many files are opened at once even when many list
|
||||||
|
requests land together.
|
||||||
|
"""
|
||||||
|
async with _DIMS_READ_SEMAPHORE:
|
||||||
|
return await asyncio.to_thread(ExifUtils.get_image_dimensions, path)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class RecipeHandlerSet:
|
class RecipeHandlerSet:
|
||||||
@@ -246,7 +262,8 @@ class RecipeListingHandler:
|
|||||||
recursive=recursive,
|
recursive=recursive,
|
||||||
)
|
)
|
||||||
|
|
||||||
for item in result.get("items", []):
|
items = result.get("items", [])
|
||||||
|
for item in items:
|
||||||
file_path = item.get("file_path")
|
file_path = item.get("file_path")
|
||||||
if file_path:
|
if file_path:
|
||||||
item["file_url"] = self.format_recipe_file_url(file_path)
|
item["file_url"] = self.format_recipe_file_url(file_path)
|
||||||
@@ -255,6 +272,26 @@ class RecipeListingHandler:
|
|||||||
item.setdefault("loras", [])
|
item.setdefault("loras", [])
|
||||||
item.setdefault("base_model", "")
|
item.setdefault("base_model", "")
|
||||||
|
|
||||||
|
# Batch preview dimension reads with asyncio.gather. The previous
|
||||||
|
# loop awaited asyncio.to_thread once per item, so a page_size=100
|
||||||
|
# request submitted 100 sequential thread calls (50-300ms cold-page
|
||||||
|
# latency). gather runs them concurrently while the semaphore caps
|
||||||
|
# disk opens; dimensions stay omitted (not null) when a preview has
|
||||||
|
# no readable size (video, missing file).
|
||||||
|
to_read = [
|
||||||
|
(i, item.get("file_path"))
|
||||||
|
for i, item in enumerate(items)
|
||||||
|
if item.get("file_path")
|
||||||
|
]
|
||||||
|
if to_read:
|
||||||
|
dims_list = await asyncio.gather(
|
||||||
|
*(_read_preview_dims(path) for _, path in to_read)
|
||||||
|
)
|
||||||
|
for (idx, _), dims in zip(to_read, dims_list):
|
||||||
|
if dims:
|
||||||
|
item = items[idx]
|
||||||
|
item["width"], item["height"] = dims
|
||||||
|
|
||||||
return web.json_response(result)
|
return web.json_response(result)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self._logger.error("Error retrieving recipes: %s", exc, exc_info=True)
|
self._logger.error("Error retrieving recipes: %s", exc, exc_info=True)
|
||||||
|
|||||||
+300
-32
@@ -38,6 +38,84 @@ def _clean_excludes() -> List[str]:
|
|||||||
return excludes
|
return excludes
|
||||||
|
|
||||||
|
|
||||||
|
def _stage_preserved_items(plugin_root: str) -> tuple[str, list[str]]:
|
||||||
|
"""Move preserved user-data items to a temp directory outside *plugin_root*.
|
||||||
|
|
||||||
|
This ensures that ``git reset --hard``, ``git clean -fd``, and ZIP-based
|
||||||
|
replacement cannot touch these files even when ``-e`` exclusion patterns
|
||||||
|
are mishandled (e.g. on Windows where forward-slash patterns may not
|
||||||
|
match backslash-prefixed paths in some Git builds, or where file locks
|
||||||
|
prevent deletion/recreation).
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
``(backup_root, staged_names)``: the temp directory path and the
|
||||||
|
list of item names that were successfully moved.
|
||||||
|
"""
|
||||||
|
backup_root = tempfile.mkdtemp(prefix='lora_manager_update_')
|
||||||
|
staged: list[str] = []
|
||||||
|
for name in _PRESERVE_DIRS:
|
||||||
|
src = os.path.join(plugin_root, name)
|
||||||
|
if not os.path.lexists(src):
|
||||||
|
continue
|
||||||
|
dst = os.path.join(backup_root, name)
|
||||||
|
try:
|
||||||
|
shutil.move(src, dst)
|
||||||
|
staged.append(name)
|
||||||
|
logger.debug("Staged '%s' for update safety", name)
|
||||||
|
except OSError:
|
||||||
|
# ``shutil.move`` may fail on Windows if a file handle inside
|
||||||
|
# the directory is still open (e.g. a SQLite WAL file). Fall
|
||||||
|
# back to copy-then-remove.
|
||||||
|
logger.debug("Move failed for '%s', falling back to copy", name)
|
||||||
|
try:
|
||||||
|
if os.path.isdir(src) and not os.path.islink(src):
|
||||||
|
shutil.copytree(src, dst, symlinks=True)
|
||||||
|
shutil.rmtree(src, ignore_errors=True)
|
||||||
|
else:
|
||||||
|
shutil.copy2(src, dst)
|
||||||
|
os.remove(src)
|
||||||
|
staged.append(name)
|
||||||
|
logger.info("Copied (then removed) '%s' for update safety", name)
|
||||||
|
except Exception as exc:
|
||||||
|
logger.warning(
|
||||||
|
"Could not stage '%s': %s (will rely on git -e / skip lists)", name, exc
|
||||||
|
)
|
||||||
|
return backup_root, staged
|
||||||
|
|
||||||
|
|
||||||
|
def _restore_preserved_items(plugin_root: str, backup_root: str, staged: list[str]) -> None:
|
||||||
|
"""Move staged items back from *backup_root* into *plugin_root*.
|
||||||
|
|
||||||
|
Any leftover placeholder at the destination (created by git checkout or
|
||||||
|
ZIP extraction) is removed before the move.
|
||||||
|
"""
|
||||||
|
for name in staged:
|
||||||
|
src = os.path.join(backup_root, name)
|
||||||
|
dst = os.path.join(plugin_root, name)
|
||||||
|
try:
|
||||||
|
if os.path.lexists(dst):
|
||||||
|
if os.path.isdir(dst) and not os.path.islink(dst):
|
||||||
|
shutil.rmtree(dst, ignore_errors=True)
|
||||||
|
else:
|
||||||
|
os.remove(dst)
|
||||||
|
shutil.move(src, dst)
|
||||||
|
logger.debug("Restored '%s' after update", name)
|
||||||
|
except OSError:
|
||||||
|
logger.debug("Move failed restoring '%s', falling back to copy", name)
|
||||||
|
try:
|
||||||
|
if os.path.isdir(src) and not os.path.islink(src):
|
||||||
|
shutil.copytree(src, dst, symlinks=True, dirs_exist_ok=True)
|
||||||
|
shutil.rmtree(src, ignore_errors=True)
|
||||||
|
else:
|
||||||
|
shutil.copy2(src, dst)
|
||||||
|
os.remove(src)
|
||||||
|
logger.info("Copied '%s' back after update", name)
|
||||||
|
except Exception as exc:
|
||||||
|
logger.error("Failed to restore '%s': %s", name, exc)
|
||||||
|
shutil.rmtree(backup_root, ignore_errors=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class UpdateRoutes:
|
class UpdateRoutes:
|
||||||
"""Routes for handling plugin update checks"""
|
"""Routes for handling plugin update checks"""
|
||||||
|
|
||||||
@@ -47,6 +125,7 @@ class UpdateRoutes:
|
|||||||
app.router.add_get('/api/lm/check-updates', UpdateRoutes.check_updates)
|
app.router.add_get('/api/lm/check-updates', UpdateRoutes.check_updates)
|
||||||
app.router.add_get('/api/lm/version-info', UpdateRoutes.get_version_info)
|
app.router.add_get('/api/lm/version-info', UpdateRoutes.get_version_info)
|
||||||
app.router.add_post('/api/lm/perform-update', UpdateRoutes.perform_update)
|
app.router.add_post('/api/lm/perform-update', UpdateRoutes.perform_update)
|
||||||
|
app.router.add_post('/api/lm/switch-channel', UpdateRoutes.switch_channel)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def check_updates(request):
|
async def check_updates(request):
|
||||||
@@ -65,10 +144,17 @@ class UpdateRoutes:
|
|||||||
|
|
||||||
# Fetch remote version from GitHub
|
# Fetch remote version from GitHub
|
||||||
if nightly:
|
if nightly:
|
||||||
remote_version, changelog = await UpdateRoutes._get_nightly_version()
|
local_hash = git_info.get('short_hash', '')
|
||||||
releases = None
|
nightly_version, releases_result = await asyncio.gather(
|
||||||
|
UpdateRoutes._get_nightly_version(local_hash),
|
||||||
|
UpdateRoutes._get_remote_version()
|
||||||
|
)
|
||||||
|
remote_version, _, behind_by, commit_date = nightly_version
|
||||||
|
_, changelog, releases = releases_result
|
||||||
else:
|
else:
|
||||||
remote_version, changelog, releases = await UpdateRoutes._get_remote_version()
|
remote_version, changelog, releases = await UpdateRoutes._get_remote_version()
|
||||||
|
behind_by = 0
|
||||||
|
commit_date = ''
|
||||||
|
|
||||||
# Compare versions
|
# Compare versions
|
||||||
if nightly:
|
if nightly:
|
||||||
@@ -81,6 +167,10 @@ class UpdateRoutes:
|
|||||||
remote_version.replace('v', '')
|
remote_version.replace('v', '')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
plugin_root = os.path.dirname(os.path.dirname(current_dir))
|
||||||
|
has_git = os.path.exists(os.path.join(plugin_root, '.git'))
|
||||||
|
|
||||||
response_data = {
|
response_data = {
|
||||||
'success': True,
|
'success': True,
|
||||||
'current_version': local_version,
|
'current_version': local_version,
|
||||||
@@ -88,13 +178,13 @@ class UpdateRoutes:
|
|||||||
'update_available': update_available,
|
'update_available': update_available,
|
||||||
'changelog': changelog,
|
'changelog': changelog,
|
||||||
'git_info': git_info,
|
'git_info': git_info,
|
||||||
'nightly': nightly
|
'nightly': nightly,
|
||||||
|
'has_git': has_git,
|
||||||
|
'releases': releases,
|
||||||
|
'behind_by': behind_by,
|
||||||
|
'commit_date': commit_date
|
||||||
}
|
}
|
||||||
|
|
||||||
# Include releases list for stable mode
|
|
||||||
if releases is not None:
|
|
||||||
response_data['releases'] = releases
|
|
||||||
|
|
||||||
return web.json_response(response_data)
|
return web.json_response(response_data)
|
||||||
|
|
||||||
except NETWORK_EXCEPTIONS as e:
|
except NETWORK_EXCEPTIONS as e:
|
||||||
@@ -126,9 +216,14 @@ class UpdateRoutes:
|
|||||||
# Format: version-short_hash
|
# Format: version-short_hash
|
||||||
version_string = f"{local_version}-{short_hash}"
|
version_string = f"{local_version}-{short_hash}"
|
||||||
|
|
||||||
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
plugin_root = os.path.dirname(os.path.dirname(current_dir))
|
||||||
|
has_git = os.path.exists(os.path.join(plugin_root, '.git'))
|
||||||
|
|
||||||
return web.json_response({
|
return web.json_response({
|
||||||
'success': True,
|
'success': True,
|
||||||
'version': version_string
|
'version': version_string,
|
||||||
|
'has_git': has_git
|
||||||
})
|
})
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -156,20 +251,22 @@ class UpdateRoutes:
|
|||||||
if os.path.exists(settings_path):
|
if os.path.exists(settings_path):
|
||||||
with open(settings_path, 'r', encoding='utf-8') as f:
|
with open(settings_path, 'r', encoding='utf-8') as f:
|
||||||
settings_backup = f.read()
|
settings_backup = f.read()
|
||||||
logger.info("Backed up settings.json")
|
logger.debug("Backed up settings.json (%d bytes)", len(settings_backup))
|
||||||
|
|
||||||
|
staged_backup_dir, staged_items = _stage_preserved_items(plugin_root)
|
||||||
|
try:
|
||||||
git_folder = os.path.join(plugin_root, '.git')
|
git_folder = os.path.join(plugin_root, '.git')
|
||||||
if os.path.exists(git_folder):
|
if os.path.exists(git_folder):
|
||||||
# Git update
|
|
||||||
success, new_version = await UpdateRoutes._perform_git_update(plugin_root, nightly)
|
success, new_version = await UpdateRoutes._perform_git_update(plugin_root, nightly)
|
||||||
else:
|
else:
|
||||||
# Fallback: Download ZIP and replace files
|
|
||||||
success, new_version = await UpdateRoutes._download_and_replace_zip(plugin_root)
|
success, new_version = await UpdateRoutes._download_and_replace_zip(plugin_root)
|
||||||
|
finally:
|
||||||
|
_restore_preserved_items(plugin_root, staged_backup_dir, staged_items)
|
||||||
|
|
||||||
if settings_backup and success:
|
if settings_backup and success:
|
||||||
with open(settings_path, 'w', encoding='utf-8') as f:
|
with open(settings_path, 'w', encoding='utf-8') as f:
|
||||||
f.write(settings_backup)
|
f.write(settings_backup)
|
||||||
logger.info("Restored settings.json")
|
logger.debug("Restored settings.json content (%d bytes)", len(settings_backup))
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
return web.json_response({
|
return web.json_response({
|
||||||
@@ -190,6 +287,164 @@ class UpdateRoutes:
|
|||||||
'error': str(e)
|
'error': str(e)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
async def switch_channel(request):
|
||||||
|
"""
|
||||||
|
Switch between release and nightly update channels.
|
||||||
|
|
||||||
|
ZIP/CNR install → Nightly: git init + checkout main (one-way upgrade)
|
||||||
|
Git install → Release: git checkout latest tag (.git preserved)
|
||||||
|
ZIP/CNR install → Release: ZIP download (no .git, stays in ZIP mode)
|
||||||
|
Git install → Nightly: git checkout main + pull
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
body = await request.json() if request.has_body else {}
|
||||||
|
channel = body.get('channel', '')
|
||||||
|
|
||||||
|
if channel not in ('release', 'nightly'):
|
||||||
|
return web.json_response({
|
||||||
|
'success': False,
|
||||||
|
'error': f'Invalid channel: {channel}. Must be "release" or "nightly".'
|
||||||
|
})
|
||||||
|
|
||||||
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
plugin_root = os.path.dirname(os.path.dirname(current_dir))
|
||||||
|
|
||||||
|
settings_path = ensure_settings_file(logger)
|
||||||
|
settings_backup = None
|
||||||
|
if os.path.exists(settings_path):
|
||||||
|
with open(settings_path, 'r', encoding='utf-8') as f:
|
||||||
|
settings_backup = f.read()
|
||||||
|
logger.debug("Backed up settings.json before channel switch (%d bytes)", len(settings_backup))
|
||||||
|
|
||||||
|
staged_backup_dir, staged_items = _stage_preserved_items(plugin_root)
|
||||||
|
try:
|
||||||
|
git_folder = os.path.join(plugin_root, '.git')
|
||||||
|
|
||||||
|
if channel == 'nightly':
|
||||||
|
git_backup = None
|
||||||
|
if os.path.exists(git_folder):
|
||||||
|
git_backup = UpdateRoutes._backup_git(git_folder, 'nightly')
|
||||||
|
|
||||||
|
success = False
|
||||||
|
new_version = ''
|
||||||
|
try:
|
||||||
|
if os.path.exists(git_folder):
|
||||||
|
success, new_version = await UpdateRoutes._perform_git_update(
|
||||||
|
plugin_root, nightly=True
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
success, new_version = UpdateRoutes._init_git_repo(plugin_root)
|
||||||
|
finally:
|
||||||
|
UpdateRoutes._restore_git(git_backup, git_folder, success, 'nightly')
|
||||||
|
else:
|
||||||
|
success = False
|
||||||
|
new_version = ''
|
||||||
|
if os.path.exists(git_folder):
|
||||||
|
success, new_version = await UpdateRoutes._perform_git_update(
|
||||||
|
plugin_root, nightly=False
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
tracking_file = os.path.join(plugin_root, '.tracking')
|
||||||
|
if os.path.exists(tracking_file):
|
||||||
|
os.remove(tracking_file)
|
||||||
|
success, new_version = await UpdateRoutes._download_and_replace_zip(plugin_root)
|
||||||
|
finally:
|
||||||
|
_restore_preserved_items(plugin_root, staged_backup_dir, staged_items)
|
||||||
|
|
||||||
|
if settings_backup and success:
|
||||||
|
with open(settings_path, 'w', encoding='utf-8') as f:
|
||||||
|
f.write(settings_backup)
|
||||||
|
logger.debug("Restored settings.json content after channel switch (%d bytes)", len(settings_backup))
|
||||||
|
|
||||||
|
if success:
|
||||||
|
return web.json_response({
|
||||||
|
'success': True,
|
||||||
|
'channel': channel,
|
||||||
|
'new_version': new_version,
|
||||||
|
'message': f'Switched to {channel} channel'
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
return web.json_response({
|
||||||
|
'success': False,
|
||||||
|
'error': f'Failed to switch to {channel} channel'
|
||||||
|
})
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("Failed to switch channel: %s", e, exc_info=True)
|
||||||
|
return web.json_response({
|
||||||
|
'success': False,
|
||||||
|
'error': str(e)
|
||||||
|
})
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _init_git_repo(plugin_root: str) -> tuple[bool, str]:
|
||||||
|
"""
|
||||||
|
Initialize a Git repository in a ZIP-installed plugin folder.
|
||||||
|
Clones the remote history and checks out main branch.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
import git
|
||||||
|
except ImportError:
|
||||||
|
logger.error(
|
||||||
|
"GitPython is not available: cannot initialize git repo. "
|
||||||
|
"Install git or set $GIT_PYTHON_GIT_EXECUTABLE to the git binary path."
|
||||||
|
)
|
||||||
|
return False, ""
|
||||||
|
|
||||||
|
clean_excludes = _clean_excludes()
|
||||||
|
|
||||||
|
try:
|
||||||
|
repo = git.Repo.init(plugin_root)
|
||||||
|
origin = repo.create_remote(
|
||||||
|
'origin',
|
||||||
|
'https://github.com/willmiao/ComfyUI-Lora-Manager.git'
|
||||||
|
)
|
||||||
|
origin.fetch()
|
||||||
|
|
||||||
|
repo.create_head('main', origin.refs.main)
|
||||||
|
repo.git.checkout('main', '--force')
|
||||||
|
repo.git.reset('--hard')
|
||||||
|
repo.git.clean('-fd', *clean_excludes)
|
||||||
|
|
||||||
|
tracking_file = os.path.join(plugin_root, '.tracking')
|
||||||
|
if os.path.exists(tracking_file):
|
||||||
|
os.remove(tracking_file)
|
||||||
|
logger.info("Removed .tracking file (now in git mode)")
|
||||||
|
|
||||||
|
new_version = f"main-{repo.head.commit.hexsha[:7]}"
|
||||||
|
logger.info("Initialized git repo on main branch: %s", new_version)
|
||||||
|
return True, new_version
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("Failed to initialize git repo: %s", e, exc_info=True)
|
||||||
|
return False, ""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _backup_git(git_folder, label):
|
||||||
|
try:
|
||||||
|
backup_dir = tempfile.mkdtemp()
|
||||||
|
backup = os.path.join(backup_dir, '.git')
|
||||||
|
shutil.copytree(git_folder, backup)
|
||||||
|
logger.info("Backed up .git before switching to %s", label)
|
||||||
|
return backup
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("Failed to backup .git before %s switch: %s", label, e)
|
||||||
|
return None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _restore_git(git_backup, git_folder, success, label):
|
||||||
|
if git_backup and not success:
|
||||||
|
try:
|
||||||
|
if os.path.exists(git_folder):
|
||||||
|
shutil.rmtree(git_folder)
|
||||||
|
shutil.copytree(git_backup, git_folder)
|
||||||
|
logger.info("Restored .git after failed %s switch", label)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("Failed to restore .git after %s switch: %s", label, e)
|
||||||
|
if git_backup:
|
||||||
|
shutil.rmtree(os.path.dirname(git_backup), ignore_errors=True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def _download_and_replace_zip(plugin_root: str) -> tuple[bool, str]:
|
async def _download_and_replace_zip(plugin_root: str) -> tuple[bool, str]:
|
||||||
"""
|
"""
|
||||||
@@ -244,8 +499,7 @@ class UpdateRoutes:
|
|||||||
except Exception:
|
except Exception:
|
||||||
logger.debug("Could not close downloaded-version history database", exc_info=True)
|
logger.debug("Could not close downloaded-version history database", exc_info=True)
|
||||||
|
|
||||||
# Skip settings.json, civitai, model cache and runtime cache folders
|
UpdateRoutes._clean_plugin_folder(plugin_root, skip_files=list(_PRESERVE_DIRS))
|
||||||
UpdateRoutes._clean_plugin_folder(plugin_root, skip_files=['settings.json', 'civitai', 'model_cache', 'cache', 'wildcards', 'backups', 'stats'])
|
|
||||||
|
|
||||||
# Extract ZIP to temp dir
|
# Extract ZIP to temp dir
|
||||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||||
@@ -255,7 +509,7 @@ class UpdateRoutes:
|
|||||||
extracted_root = next(os.scandir(tmp_dir)).path
|
extracted_root = next(os.scandir(tmp_dir)).path
|
||||||
|
|
||||||
# Copy files, skipping user data that should be preserved
|
# Copy files, skipping user data that should be preserved
|
||||||
skip_items = {'settings.json', 'civitai', 'wildcards', 'backups', 'stats'}
|
skip_items = set(_PRESERVE_DIRS)
|
||||||
for item in os.listdir(extracted_root):
|
for item in os.listdir(extracted_root):
|
||||||
if item in skip_items:
|
if item in skip_items:
|
||||||
continue
|
continue
|
||||||
@@ -272,7 +526,7 @@ class UpdateRoutes:
|
|||||||
# for ComfyUI Manager to work properly
|
# for ComfyUI Manager to work properly
|
||||||
tracking_info_file = os.path.join(plugin_root, '.tracking')
|
tracking_info_file = os.path.join(plugin_root, '.tracking')
|
||||||
tracking_files = []
|
tracking_files = []
|
||||||
skip_tracked = {'civitai', 'wildcards', 'backups', 'stats'}
|
skip_tracked = set(_PRESERVE_DIRS) - {'settings.json'}
|
||||||
for root, dirs, files in os.walk(extracted_root):
|
for root, dirs, files in os.walk(extracted_root):
|
||||||
# Skip user data directories and their contents
|
# Skip user data directories and their contents
|
||||||
rel_root = os.path.relpath(root, extracted_root)
|
rel_root = os.path.relpath(root, extracted_root)
|
||||||
@@ -296,6 +550,7 @@ class UpdateRoutes:
|
|||||||
logger.error(f"ZIP update failed: {e}", exc_info=True)
|
logger.error(f"ZIP update failed: {e}", exc_info=True)
|
||||||
return False, ""
|
return False, ""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def _clean_plugin_folder(plugin_root, skip_files=None):
|
def _clean_plugin_folder(plugin_root, skip_files=None):
|
||||||
skip_files = skip_files or []
|
skip_files = skip_files or []
|
||||||
for item in os.listdir(plugin_root):
|
for item in os.listdir(plugin_root):
|
||||||
@@ -308,41 +563,54 @@ class UpdateRoutes:
|
|||||||
os.remove(path)
|
os.remove(path)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def _get_nightly_version() -> tuple[str, List[str]]:
|
async def _get_nightly_version(local_hash: str = "") -> tuple[str, List[str], int, str]:
|
||||||
"""
|
|
||||||
Fetch latest commit from main branch
|
|
||||||
"""
|
|
||||||
repo_owner = "willmiao"
|
repo_owner = "willmiao"
|
||||||
repo_name = "ComfyUI-Lora-Manager"
|
repo_name = "ComfyUI-Lora-Manager"
|
||||||
|
|
||||||
# Use GitHub API to fetch the latest commit from main branch
|
|
||||||
github_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/commits/main"
|
github_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/commits/main"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
downloader = await get_downloader()
|
downloader = await get_downloader()
|
||||||
success, data = await downloader.make_request('GET', github_url, custom_headers={'Accept': 'application/vnd.github+json'})
|
success, data = await downloader.make_request(
|
||||||
|
'GET', github_url,
|
||||||
|
custom_headers={'Accept': 'application/vnd.github+json'}
|
||||||
|
)
|
||||||
|
|
||||||
if not success:
|
if not success:
|
||||||
logger.warning(f"Failed to fetch GitHub commit: {data}")
|
logger.warning("Failed to fetch GitHub commit: %s", data)
|
||||||
return "main", []
|
return "main", [], 0, ""
|
||||||
|
|
||||||
commit_sha = data.get('sha', '')[:7] # Short hash
|
commit_sha = data.get('sha', '')[:7]
|
||||||
commit_message = data.get('commit', {}).get('message', '')
|
commit_message = data.get('commit', {}).get('message', '')
|
||||||
|
commit_date = data.get('commit', {}).get('committer', {}).get('date', '')[:10]
|
||||||
|
|
||||||
# Format as "main-{short_hash}"
|
|
||||||
version = f"main-{commit_sha}"
|
version = f"main-{commit_sha}"
|
||||||
|
|
||||||
# Use commit message as changelog
|
|
||||||
changelog = [commit_message] if commit_message else []
|
changelog = [commit_message] if commit_message else []
|
||||||
|
|
||||||
return version, changelog
|
behind_by = 0
|
||||||
|
if local_hash and local_hash not in ('unknown', 'stable'):
|
||||||
|
compare_url = (
|
||||||
|
f"https://api.github.com/repos/{repo_owner}/{repo_name}"
|
||||||
|
f"/compare/{local_hash}...main"
|
||||||
|
)
|
||||||
|
c_ok, c_data = await downloader.make_request(
|
||||||
|
'GET', compare_url,
|
||||||
|
custom_headers={'Accept': 'application/vnd.github+json'}
|
||||||
|
)
|
||||||
|
if c_ok:
|
||||||
|
if c_data.get('status') in ('ahead', 'diverged'):
|
||||||
|
behind_by = c_data.get('ahead_by', 0)
|
||||||
|
else:
|
||||||
|
behind_by = c_data.get('behind_by', 0)
|
||||||
|
|
||||||
|
return version, changelog, behind_by, commit_date
|
||||||
|
|
||||||
except NETWORK_EXCEPTIONS as e:
|
except NETWORK_EXCEPTIONS as e:
|
||||||
logger.warning("Unable to reach GitHub for nightly version: %s", e)
|
logger.warning("Unable to reach GitHub for nightly version: %s", e)
|
||||||
return "main", []
|
return "main", [], 0, ""
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error fetching nightly version: {e}", exc_info=True)
|
logger.error("Error fetching nightly version: %s", e, exc_info=True)
|
||||||
return "main", []
|
return "main", [], 0, ""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _compare_nightly_versions(local_git_info: Dict[str, str], remote_version: str) -> bool:
|
def _compare_nightly_versions(local_git_info: Dict[str, str], remote_version: str) -> bool:
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
import asyncio
|
import asyncio
|
||||||
import re
|
import re
|
||||||
from typing import Any, Dict, List, Optional, Type, TYPE_CHECKING
|
import random
|
||||||
|
from typing import Any, Dict, List, Optional, Type, Union, TYPE_CHECKING
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
@@ -109,12 +110,15 @@ class BaseModelService(ABC):
|
|||||||
if civitai_model_id is not None:
|
if civitai_model_id is not None:
|
||||||
sorted_data = [
|
sorted_data = [
|
||||||
item for item in sorted_data
|
item for item in sorted_data
|
||||||
if self._extract_model_id(item) == civitai_model_id
|
if self._extract_group_key(item) == civitai_model_id
|
||||||
]
|
]
|
||||||
# VLM mode: always sort by version ID descending (newest version first),
|
# VLM mode: always sort by version ID descending (newest version first),
|
||||||
# regardless of the current sort_by preference.
|
# regardless of the current sort_by preference.
|
||||||
|
# Fall back to modified timestamp for non-CivitAI sources.
|
||||||
sorted_data.sort(
|
sorted_data.sort(
|
||||||
key=lambda x: self._extract_version_id(x) or 0,
|
key=lambda x: self._extract_version_id(x)
|
||||||
|
or x.get("modified", 0)
|
||||||
|
or 0,
|
||||||
reverse=True,
|
reverse=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -129,18 +133,21 @@ class BaseModelService(ABC):
|
|||||||
ufs = self.settings.get("version_grouping", "same_base")
|
ufs = self.settings.get("version_grouping", "same_base")
|
||||||
group_by_base = ufs == "same_base"
|
group_by_base = ufs == "same_base"
|
||||||
|
|
||||||
dedup_map = {} # (modelId [,base_model]) -> (item, version_id)
|
dedup_map = {} # (modelId [,base_model]) -> (item, version_or_modified)
|
||||||
version_counter = {} # same-key -> count
|
version_counter = {} # same-key -> count
|
||||||
standalone = []
|
standalone = []
|
||||||
for item in sorted_data:
|
for item in sorted_data:
|
||||||
mid = self._extract_model_id(item)
|
mid = self._extract_group_key(item)
|
||||||
if mid is None:
|
if mid is None:
|
||||||
standalone.append(item)
|
standalone.append(item)
|
||||||
continue
|
continue
|
||||||
key = (mid, item.get("base_model") or "") if group_by_base else mid
|
key = (mid, item.get("base_model") or "") if group_by_base else mid
|
||||||
# Count all versions per key
|
# Count all versions per key
|
||||||
version_counter[key] = version_counter.get(key, 0) + 1
|
version_counter[key] = version_counter.get(key, 0) + 1
|
||||||
vid = self._extract_version_id(item) or 0
|
# Prefer CivitAI version_id; fall back to modified timestamp
|
||||||
|
vid = self._extract_version_id(item)
|
||||||
|
if vid is None:
|
||||||
|
vid = item.get("modified", 0) or 0
|
||||||
if key not in dedup_map or vid > dedup_map[key][1]:
|
if key not in dedup_map or vid > dedup_map[key][1]:
|
||||||
dedup_map[key] = (item, vid)
|
dedup_map[key] = (item, vid)
|
||||||
# Attach version_count to each surviving grouped item (shallow copy
|
# Attach version_count to each surviving grouped item (shallow copy
|
||||||
@@ -174,16 +181,19 @@ class BaseModelService(ABC):
|
|||||||
model_groups: Dict[Any, List[Dict]] = {}
|
model_groups: Dict[Any, List[Dict]] = {}
|
||||||
ungrouped_standalone: List[Dict] = []
|
ungrouped_standalone: List[Dict] = []
|
||||||
for item in sorted_data:
|
for item in sorted_data:
|
||||||
mid = self._extract_model_id(item)
|
mid = self._extract_group_key(item)
|
||||||
if mid is None:
|
if mid is None:
|
||||||
ungrouped_standalone.append(item)
|
ungrouped_standalone.append(item)
|
||||||
continue
|
continue
|
||||||
key = (mid, item.get("base_model") or "") if group_by_base else mid
|
key = (mid, item.get("base_model") or "") if group_by_base else mid
|
||||||
model_groups.setdefault(key, []).append(item)
|
model_groups.setdefault(key, []).append(item)
|
||||||
# Sort versions within each group by version id descending
|
# Sort versions within each group by version id (descending);
|
||||||
|
# fall back to modified timestamp for non-CivitAI sources.
|
||||||
for items in model_groups.values():
|
for items in model_groups.values():
|
||||||
items.sort(
|
items.sort(
|
||||||
key=lambda x: self._extract_version_id(x) or 0,
|
key=lambda x: self._extract_version_id(x)
|
||||||
|
or x.get("modified", 0)
|
||||||
|
or 0,
|
||||||
reverse=True,
|
reverse=True,
|
||||||
)
|
)
|
||||||
# Sort groups by version count
|
# Sort groups by version count
|
||||||
@@ -381,6 +391,12 @@ class BaseModelService(ABC):
|
|||||||
(item.get("model_name") or item.get("file_name") or "").lower(),
|
(item.get("model_name") or item.get("file_name") or "").lower(),
|
||||||
item.get("file_path", "").lower(),
|
item.get("file_path", "").lower(),
|
||||||
)
|
)
|
||||||
|
elif key_name == "random":
|
||||||
|
# Seeded random shuffle: same seed -> same order (stable pagination)
|
||||||
|
rng = random.Random(sort_params.seed or "random")
|
||||||
|
result = list(data)
|
||||||
|
rng.shuffle(result)
|
||||||
|
return result
|
||||||
elif key_name == "size":
|
elif key_name == "size":
|
||||||
key_fn = lambda item: (
|
key_fn = lambda item: (
|
||||||
int(item.get("size", 0) or 0),
|
int(item.get("size", 0) or 0),
|
||||||
@@ -697,6 +713,33 @@ class BaseModelService(ABC):
|
|||||||
|
|
||||||
return annotated
|
return annotated
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _extract_hf_group_key(item: Dict) -> Optional[str]:
|
||||||
|
"""Extract `hf:{owner}/{repo}` from item's ``hf_url``, or None."""
|
||||||
|
hf_url = item.get("hf_url") if isinstance(item, dict) else None
|
||||||
|
if not hf_url or not isinstance(hf_url, str):
|
||||||
|
return None
|
||||||
|
m = re.match(
|
||||||
|
r"https?://huggingface\.co/([^/]+/[^/]+)", hf_url.strip()
|
||||||
|
)
|
||||||
|
if not m:
|
||||||
|
return None
|
||||||
|
return f"hf:{m.group(1)}"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _extract_group_key(item: Dict) -> Union[int, str, None]:
|
||||||
|
"""Return the group identity key: CivitAI modelId (int) or HF repo (str).
|
||||||
|
|
||||||
|
Preference order:
|
||||||
|
1. CivitAI ``modelId`` (int)
|
||||||
|
2. HF repo identity ``hf:{owner}/{repo}`` (str)
|
||||||
|
3. ``None`` (no known grouping source)
|
||||||
|
"""
|
||||||
|
mid = BaseModelService._extract_model_id(item)
|
||||||
|
if mid is not None:
|
||||||
|
return mid
|
||||||
|
return BaseModelService._extract_hf_group_key(item)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _extract_model_id(item: Dict) -> Optional[int]:
|
def _extract_model_id(item: Dict) -> Optional[int]:
|
||||||
civitai = item.get("civitai") if isinstance(item, dict) else None
|
civitai = item.get("civitai") if isinstance(item, dict) else None
|
||||||
@@ -1216,19 +1259,87 @@ class BaseModelService(ABC):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def search_relative_paths(
|
async def search_relative_paths(
|
||||||
self, search_term: str, limit: int = 15, offset: int = 0
|
self,
|
||||||
|
search_term: str,
|
||||||
|
limit: int = 15,
|
||||||
|
offset: int = 0,
|
||||||
|
*,
|
||||||
|
folder: Optional[str] = None,
|
||||||
|
folder_include: Optional[list] = None,
|
||||||
|
folder_exclude: Optional[list] = None,
|
||||||
|
base_models: Optional[list] = None,
|
||||||
|
model_types: Optional[list] = None,
|
||||||
|
tags: Optional[dict] = None,
|
||||||
|
auto_tags: Optional[dict] = None,
|
||||||
|
tag_logic: str = "any",
|
||||||
|
credit_required: Optional[bool] = None,
|
||||||
|
allow_selling_generated_content: Optional[bool] = None,
|
||||||
|
recursive: bool = True,
|
||||||
|
apply_filters: bool = False,
|
||||||
) -> List[str]:
|
) -> List[str]:
|
||||||
"""Search model relative file paths for autocomplete functionality"""
|
"""Search model relative file paths for autocomplete functionality.
|
||||||
|
|
||||||
|
Optional filter kwargs mirror the filters used by the list endpoint
|
||||||
|
(/api/lm/{prefix}/list). When no filter kwargs are provided the
|
||||||
|
behavior is identical to plain token-based path matching.
|
||||||
|
"""
|
||||||
cache = await self.scanner.get_cached_data()
|
cache = await self.scanner.get_cached_data()
|
||||||
include_terms, exclude_terms = self._parse_search_tokens(search_term)
|
include_terms, exclude_terms = self._parse_search_tokens(search_term)
|
||||||
|
|
||||||
|
data = cache.raw_data
|
||||||
|
has_filters = any(
|
||||||
|
[
|
||||||
|
apply_filters,
|
||||||
|
folder is not None,
|
||||||
|
folder_include,
|
||||||
|
folder_exclude,
|
||||||
|
base_models,
|
||||||
|
model_types,
|
||||||
|
tags,
|
||||||
|
auto_tags,
|
||||||
|
credit_required is not None,
|
||||||
|
allow_selling_generated_content is not None,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
if has_filters:
|
||||||
|
# Auto-tags are not stored in the scanner cache — they are computed
|
||||||
|
# on the fly. Pre-compute them only when an auto-tag filter is
|
||||||
|
# active to avoid mutating cache entries unnecessarily.
|
||||||
|
if auto_tags:
|
||||||
|
from .auto_tag_service import extract_auto_tags
|
||||||
|
|
||||||
|
for item in data:
|
||||||
|
if not item.get("auto_tags"):
|
||||||
|
item["auto_tags"] = extract_auto_tags(item)
|
||||||
|
|
||||||
|
criteria = FilterCriteria(
|
||||||
|
folder=folder,
|
||||||
|
folder_include=folder_include,
|
||||||
|
folder_exclude=folder_exclude,
|
||||||
|
base_models=base_models,
|
||||||
|
model_types=model_types,
|
||||||
|
tags=tags,
|
||||||
|
auto_tags=auto_tags,
|
||||||
|
search_options={"recursive": recursive},
|
||||||
|
tag_logic=tag_logic,
|
||||||
|
)
|
||||||
|
data = self.filter_set.apply(data, criteria)
|
||||||
|
if credit_required is not None:
|
||||||
|
data = await self._apply_credit_required_filter(
|
||||||
|
data, credit_required
|
||||||
|
)
|
||||||
|
if allow_selling_generated_content is not None:
|
||||||
|
data = await self._apply_allow_selling_filter(
|
||||||
|
data, allow_selling_generated_content
|
||||||
|
)
|
||||||
|
|
||||||
matching_paths = []
|
matching_paths = []
|
||||||
|
|
||||||
# Get model roots for path calculation
|
# Get model roots for path calculation
|
||||||
model_roots = self.scanner.get_model_roots()
|
model_roots = self.scanner.get_model_roots()
|
||||||
|
|
||||||
# Collect all matching paths first (needed for proper sorting and offset)
|
# Collect all matching paths first (needed for proper sorting and offset)
|
||||||
for model in cache.raw_data:
|
for model in data:
|
||||||
file_path = model.get("file_path", "")
|
file_path = model.get("file_path", "")
|
||||||
if not file_path:
|
if not file_path:
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import asyncio
|
|||||||
import copy
|
import copy
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from typing import Any, Optional, Dict, Tuple, List, Sequence
|
from typing import Any, Optional, Dict, Tuple, List, Sequence
|
||||||
from .connectivity_guard import (
|
from .connectivity_guard import (
|
||||||
@@ -19,6 +20,12 @@ from ..utils.civitai_utils import resolve_license_payload
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# Best-effort cache for creator model counts, keyed by lowercase username.
|
||||||
|
# Values are (monotonic timestamp, count or None); None results are cached
|
||||||
|
# too so repeated failures don't hammer the API.
|
||||||
|
_CREATOR_COUNT_CACHE_TTL_SECONDS = 600
|
||||||
|
_creator_model_count_cache: Dict[str, Tuple[float, Optional[int]]] = {}
|
||||||
|
|
||||||
|
|
||||||
class CivitaiClient:
|
class CivitaiClient:
|
||||||
_instance = None
|
_instance = None
|
||||||
@@ -743,17 +750,34 @@ class CivitaiClient:
|
|||||||
|
|
||||||
return all_versions if all_versions else None
|
return all_versions if all_versions else None
|
||||||
|
|
||||||
async def get_user_models(self, username: str) -> Optional[List[Dict]]:
|
async def get_user_models(
|
||||||
"""Fetch all models for a specific Civitai user."""
|
self, username: str, cursor: Optional[str] = None
|
||||||
|
) -> Optional[Dict[str, Any]]:
|
||||||
|
"""Fetch one page (up to 100 models) for a specific Civitai user.
|
||||||
|
|
||||||
|
Returns ``{"items": [...], "nextCursor": <str|None>}`` on success,
|
||||||
|
or None on failure. Pass ``cursor`` (from a previous response's
|
||||||
|
``nextCursor``) to fetch subsequent pages.
|
||||||
|
"""
|
||||||
if not username:
|
if not username:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
params: Dict[str, Any] = {
|
||||||
|
"username": username,
|
||||||
|
"nsfw": "true",
|
||||||
|
"limit": 100,
|
||||||
|
"sort": "Newest",
|
||||||
|
"period": "AllTime",
|
||||||
|
}
|
||||||
|
if cursor:
|
||||||
|
params["cursor"] = cursor
|
||||||
|
|
||||||
try:
|
try:
|
||||||
success, result = await self._make_request(
|
success, result = await self._make_request(
|
||||||
"GET",
|
"GET",
|
||||||
f"{self.base_url}/models",
|
f"{self.base_url}/models",
|
||||||
use_auth=True,
|
use_auth=True,
|
||||||
params={"username": username, "nsfw": "true"},
|
params=params,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not success:
|
if not success:
|
||||||
@@ -765,7 +789,7 @@ class CivitaiClient:
|
|||||||
|
|
||||||
items = result.get("items") if isinstance(result, dict) else None
|
items = result.get("items") if isinstance(result, dict) else None
|
||||||
if not isinstance(items, list):
|
if not isinstance(items, list):
|
||||||
return []
|
items = []
|
||||||
|
|
||||||
for model in items:
|
for model in items:
|
||||||
versions = model.get("modelVersions")
|
versions = model.get("modelVersions")
|
||||||
@@ -774,9 +798,68 @@ class CivitaiClient:
|
|||||||
for version in versions:
|
for version in versions:
|
||||||
self._remove_comfy_metadata(version)
|
self._remove_comfy_metadata(version)
|
||||||
|
|
||||||
return items
|
next_cursor: Optional[str] = None
|
||||||
|
metadata = result.get("metadata") if isinstance(result, dict) else None
|
||||||
|
if isinstance(metadata, dict):
|
||||||
|
raw_cursor = metadata.get("nextCursor")
|
||||||
|
if raw_cursor is not None:
|
||||||
|
next_cursor = str(raw_cursor)
|
||||||
|
|
||||||
|
return {"items": items, "nextCursor": next_cursor}
|
||||||
except RateLimitError:
|
except RateLimitError:
|
||||||
raise
|
raise
|
||||||
except Exception as exc: # pragma: no cover - defensive logging
|
except Exception as exc: # pragma: no cover - defensive logging
|
||||||
logger.error("Error fetching models for %s: %s", username, exc)
|
logger.error("Error fetching models for %s: %s", username, exc)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
async def get_creator_model_count(self, username: str) -> Optional[int]:
|
||||||
|
"""Best-effort lookup of a creator's published model count.
|
||||||
|
|
||||||
|
Uses the ``/creators`` endpoint (a contains-match query), picking the
|
||||||
|
entry whose username matches exactly (case-insensitive). Returns None
|
||||||
|
on any failure; never raises. Results (including None) are cached
|
||||||
|
for ``_CREATOR_COUNT_CACHE_TTL_SECONDS``.
|
||||||
|
"""
|
||||||
|
if not username:
|
||||||
|
return None
|
||||||
|
|
||||||
|
cache_key = username.lower()
|
||||||
|
cached = _creator_model_count_cache.get(cache_key)
|
||||||
|
if cached is not None:
|
||||||
|
cached_at, cached_count = cached
|
||||||
|
if time.monotonic() - cached_at < _CREATOR_COUNT_CACHE_TTL_SECONDS:
|
||||||
|
return cached_count
|
||||||
|
|
||||||
|
count: Optional[int] = None
|
||||||
|
try:
|
||||||
|
success, result = await self._make_request(
|
||||||
|
"GET",
|
||||||
|
f"{self.base_url}/creators",
|
||||||
|
use_auth=True,
|
||||||
|
params={"query": username, "limit": 10},
|
||||||
|
)
|
||||||
|
|
||||||
|
if success and isinstance(result, dict):
|
||||||
|
creators = result.get("items")
|
||||||
|
if isinstance(creators, list):
|
||||||
|
for creator in creators:
|
||||||
|
if not isinstance(creator, dict):
|
||||||
|
continue
|
||||||
|
creator_name = creator.get("username")
|
||||||
|
if not isinstance(creator_name, str):
|
||||||
|
continue
|
||||||
|
if creator_name.lower() != cache_key:
|
||||||
|
continue
|
||||||
|
model_count = creator.get("modelCount")
|
||||||
|
if isinstance(model_count, (int, float)) and not isinstance(
|
||||||
|
model_count, bool
|
||||||
|
):
|
||||||
|
count = int(model_count)
|
||||||
|
break
|
||||||
|
except Exception as exc: # best-effort only, never propagate
|
||||||
|
logger.debug(
|
||||||
|
"Failed to fetch creator model count for %s: %s", username, exc
|
||||||
|
)
|
||||||
|
|
||||||
|
_creator_model_count_cache[cache_key] = (time.monotonic(), count)
|
||||||
|
return count
|
||||||
|
|||||||
@@ -1389,7 +1389,17 @@ class DownloadManager:
|
|||||||
|
|
||||||
# Update save directory with relative path if provided
|
# Update save directory with relative path if provided
|
||||||
if relative_path:
|
if relative_path:
|
||||||
|
base_save_dir = save_dir
|
||||||
save_dir = os.path.join(save_dir, relative_path)
|
save_dir = os.path.join(save_dir, relative_path)
|
||||||
|
# Security: validate path containment after joining
|
||||||
|
resolved_dir = os.path.abspath(os.path.normpath(save_dir))
|
||||||
|
base_dir = os.path.abspath(os.path.normpath(base_save_dir))
|
||||||
|
if not resolved_dir.startswith(base_dir + os.sep) and resolved_dir != base_dir:
|
||||||
|
logger.warning(
|
||||||
|
"Path traversal detected: %s escapes %s",
|
||||||
|
resolved_dir, base_dir,
|
||||||
|
)
|
||||||
|
return {"success": False, "error": "Download path is outside allowed directory"}
|
||||||
# Create directory if it doesn't exist
|
# Create directory if it doesn't exist
|
||||||
os.makedirs(save_dir, exist_ok=True)
|
os.makedirs(save_dir, exist_ok=True)
|
||||||
|
|
||||||
@@ -1827,6 +1837,9 @@ class DownloadManager:
|
|||||||
model_tags, model_type
|
model_tags, model_type
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not first_tag:
|
||||||
|
first_tag = "no tags" # Default if no tags available
|
||||||
|
|
||||||
# Format the template with available data
|
# Format the template with available data
|
||||||
formatted_path = path_template
|
formatted_path = path_template
|
||||||
formatted_path = formatted_path.replace("{base_model}", mapped_base_model)
|
formatted_path = formatted_path.replace("{base_model}", mapped_base_model)
|
||||||
@@ -1842,6 +1855,15 @@ class DownloadManager:
|
|||||||
if model_type == "embedding":
|
if model_type == "embedding":
|
||||||
formatted_path = formatted_path.replace(" ", "_")
|
formatted_path = formatted_path.replace(" ", "_")
|
||||||
|
|
||||||
|
# Sanitize the resolved path to prevent path traversal:
|
||||||
|
# - Strip leading slashes (prevents os.path.join from treating path as absolute)
|
||||||
|
# - Collapse double slashes from empty placeholder substitutions
|
||||||
|
# - Strip trailing slashes for cleanliness
|
||||||
|
formatted_path = formatted_path.lstrip("/")
|
||||||
|
while "//" in formatted_path:
|
||||||
|
formatted_path = formatted_path.replace("//", "/")
|
||||||
|
formatted_path = formatted_path.rstrip("/")
|
||||||
|
|
||||||
return formatted_path
|
return formatted_path
|
||||||
|
|
||||||
async def _execute_download(
|
async def _execute_download(
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class DownloadQueueService:
|
|||||||
_instance: Optional[DownloadQueueService] = None
|
_instance: Optional[DownloadQueueService] = None
|
||||||
_class_lock: asyncio.Lock = asyncio.Lock()
|
_class_lock: asyncio.Lock = asyncio.Lock()
|
||||||
|
|
||||||
_SCHEMA = """
|
_SCHEMA_TABLES = """
|
||||||
CREATE TABLE IF NOT EXISTS download_queue (
|
CREATE TABLE IF NOT EXISTS download_queue (
|
||||||
download_id TEXT PRIMARY KEY,
|
download_id TEXT PRIMARY KEY,
|
||||||
model_id INTEGER,
|
model_id INTEGER,
|
||||||
@@ -74,6 +74,9 @@ class DownloadQueueService:
|
|||||||
);
|
);
|
||||||
CREATE INDEX IF NOT EXISTS idx_dh_completed ON download_history(completed_at DESC);
|
CREATE INDEX IF NOT EXISTS idx_dh_completed ON download_history(completed_at DESC);
|
||||||
CREATE INDEX IF NOT EXISTS idx_dh_status ON download_history(status);
|
CREATE INDEX IF NOT EXISTS idx_dh_status ON download_history(status);
|
||||||
|
"""
|
||||||
|
|
||||||
|
_CREATE_UNIQUE_INDEX = """
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_dh_download_id
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_dh_download_id
|
||||||
ON download_history(download_id) WHERE download_id IS NOT NULL;
|
ON download_history(download_id) WHERE download_id IS NOT NULL;
|
||||||
"""
|
"""
|
||||||
@@ -115,10 +118,39 @@ class DownloadQueueService:
|
|||||||
if self._schema_initialized:
|
if self._schema_initialized:
|
||||||
return
|
return
|
||||||
with self._connect() as conn:
|
with self._connect() as conn:
|
||||||
conn.executescript(self._SCHEMA)
|
conn.executescript(self._SCHEMA_TABLES)
|
||||||
|
|
||||||
|
# Creating the unique index on download_history.download_id can
|
||||||
|
# fail if pre-existing rows have duplicate values (e.g. from a
|
||||||
|
# previous version that lacked the index). Deduplicate first so
|
||||||
|
# that the migration does not crash on startup.
|
||||||
|
if not self._index_exists(conn, "idx_dh_download_id"):
|
||||||
|
self._remove_duplicate_download_ids(conn)
|
||||||
|
conn.executescript(self._CREATE_UNIQUE_INDEX)
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
self._schema_initialized = True
|
self._schema_initialized = True
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _index_exists(conn: sqlite3.Connection, name: str) -> bool:
|
||||||
|
return conn.execute(
|
||||||
|
"SELECT 1 FROM sqlite_master WHERE type='index' AND name=?",
|
||||||
|
(name,),
|
||||||
|
).fetchone() is not None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _remove_duplicate_download_ids(conn: sqlite3.Connection) -> None:
|
||||||
|
conn.execute("""
|
||||||
|
DELETE FROM download_history
|
||||||
|
WHERE id NOT IN (
|
||||||
|
SELECT MIN(id)
|
||||||
|
FROM download_history
|
||||||
|
WHERE download_id IS NOT NULL
|
||||||
|
GROUP BY download_id
|
||||||
|
)
|
||||||
|
AND download_id IS NOT NULL
|
||||||
|
""")
|
||||||
|
|
||||||
def get_database_path(self) -> str:
|
def get_database_path(self) -> str:
|
||||||
"""Return the resolved database file path."""
|
"""Return the resolved database file path."""
|
||||||
return self._db_path
|
return self._db_path
|
||||||
|
|||||||
@@ -201,6 +201,11 @@ PROVIDER_PRESETS: Dict[str, Dict[str, Any]] = {
|
|||||||
"api_base": "https://openrouter.ai/api/v1",
|
"api_base": "https://openrouter.ai/api/v1",
|
||||||
"requires_key": True,
|
"requires_key": True,
|
||||||
},
|
},
|
||||||
|
"google": {
|
||||||
|
"name": "Gemini",
|
||||||
|
"api_base": "https://generativelanguage.googleapis.com/v1beta/openai",
|
||||||
|
"requires_key": True,
|
||||||
|
},
|
||||||
"opencode-go": {
|
"opencode-go": {
|
||||||
"name": "OpenCode Go",
|
"name": "OpenCode Go",
|
||||||
"api_base": "https://opencode.ai/zen/go/v1",
|
"api_base": "https://opencode.ai/zen/go/v1",
|
||||||
@@ -566,18 +571,52 @@ class LLMService:
|
|||||||
if effective_max is None:
|
if effective_max is None:
|
||||||
effective_max = 4096
|
effective_max = 4096
|
||||||
|
|
||||||
|
# Use json_schema (not json_object) for broader provider compatibility:
|
||||||
|
# LM Studio and some other OpenAI-compatible servers reject
|
||||||
|
# json_object but accept json_schema. {"type": "object"} is
|
||||||
|
# functionally equivalent — it accepts any JSON object without
|
||||||
|
# constraining specific fields.
|
||||||
|
response_format = {
|
||||||
|
"type": "json_schema",
|
||||||
|
"json_schema": {
|
||||||
|
"name": "metadata",
|
||||||
|
"schema": {"type": "object"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
result = await self.chat_completion(
|
result = await self.chat_completion(
|
||||||
messages=messages,
|
messages=messages,
|
||||||
model=model,
|
model=model,
|
||||||
temperature=temperature,
|
temperature=temperature,
|
||||||
response_format={"type": "json_object"},
|
response_format=response_format,
|
||||||
|
max_tokens=effective_max,
|
||||||
|
)
|
||||||
|
except LLMResponseError as e:
|
||||||
|
# Only fall back when the provider rejects the response_format
|
||||||
|
# type value (e.g. "'response_format.type' must be..."). Avoid
|
||||||
|
# catching unrelated 400 errors whose body happens to mention
|
||||||
|
# "response_format" (e.g. "model does not support
|
||||||
|
# response_format restrictions on this endpoint").
|
||||||
|
if "'response_format.type'" not in str(e).lower():
|
||||||
|
raise
|
||||||
|
logger.info(
|
||||||
|
"Provider rejected response_format, retrying without it. "
|
||||||
|
"Falling back to prompt-only JSON mode. Error: %s",
|
||||||
|
e,
|
||||||
|
)
|
||||||
|
result = await self.chat_completion(
|
||||||
|
messages=messages,
|
||||||
|
model=model,
|
||||||
|
temperature=temperature,
|
||||||
|
response_format=None,
|
||||||
max_tokens=effective_max,
|
max_tokens=effective_max,
|
||||||
)
|
)
|
||||||
|
|
||||||
content = result.get("content", "") or ""
|
content = result.get("content", "") or ""
|
||||||
if not content:
|
if not content:
|
||||||
raise LLMResponseError(
|
raise LLMResponseError(
|
||||||
"LLM returned empty content in json_object mode. "
|
"LLM returned empty content. "
|
||||||
f"Raw response: {json.dumps(result)[:500]}"
|
f"Raw response: {json.dumps(result)[:500]}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+21
-12
@@ -1,6 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
|
import random
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
from typing import Any, Dict, List, Optional, Tuple
|
from typing import Any, Dict, List, Optional, Tuple
|
||||||
@@ -38,8 +39,8 @@ class ModelCache:
|
|||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
self._lock = asyncio.Lock()
|
self._lock = asyncio.Lock()
|
||||||
# Cache for last sort: (sort_key, order) -> sorted list
|
# Cache for last sort: (sort_key, order, seed) -> sorted list
|
||||||
self._last_sort: Tuple[str, str] = (None, None)
|
self._last_sort: Tuple[Optional[str], str, Optional[str]] = (None, "asc", None)
|
||||||
self._last_sorted_data: List[Dict] = []
|
self._last_sorted_data: List[Dict] = []
|
||||||
self._normalize_raw_data()
|
self._normalize_raw_data()
|
||||||
self.name_display_mode = self._normalize_display_mode(self.name_display_mode)
|
self.name_display_mode = self._normalize_display_mode(self.name_display_mode)
|
||||||
@@ -203,9 +204,9 @@ class ModelCache:
|
|||||||
async def resort(self):
|
async def resort(self):
|
||||||
"""Resort cached data according to last sort mode if set"""
|
"""Resort cached data according to last sort mode if set"""
|
||||||
async with self._lock:
|
async with self._lock:
|
||||||
if self._last_sort != (None, None):
|
if self._last_sort[0] is not None:
|
||||||
sort_key, order = self._last_sort
|
sort_key, order, seed = self._last_sort
|
||||||
sorted_data = self._sort_data(self.raw_data, sort_key, order)
|
sorted_data = self._sort_data(self.raw_data, sort_key, order, seed)
|
||||||
self._last_sorted_data = sorted_data
|
self._last_sorted_data = sorted_data
|
||||||
# Update folder list
|
# Update folder list
|
||||||
# else: do nothing
|
# else: do nothing
|
||||||
@@ -218,7 +219,7 @@ class ModelCache:
|
|||||||
self.folders = sorted(list(all_folders), key=lambda x: x.lower())
|
self.folders = sorted(list(all_folders), key=lambda x: x.lower())
|
||||||
self.rebuild_version_index()
|
self.rebuild_version_index()
|
||||||
|
|
||||||
def _sort_data(self, data: List[Dict], sort_key: str, order: str) -> List[Dict]:
|
def _sort_data(self, data: List[Dict], sort_key: str, order: str, seed: Optional[str] = None) -> List[Dict]:
|
||||||
"""Sort data by sort_key and order"""
|
"""Sort data by sort_key and order"""
|
||||||
start_time = time.perf_counter()
|
start_time = time.perf_counter()
|
||||||
reverse = (order == 'desc')
|
reverse = (order == 'desc')
|
||||||
@@ -265,6 +266,13 @@ class ModelCache:
|
|||||||
),
|
),
|
||||||
reverse=reverse
|
reverse=reverse
|
||||||
)
|
)
|
||||||
|
elif sort_key == 'random':
|
||||||
|
# Random shuffle seeded for stable pagination: the same seed
|
||||||
|
# always yields the same order, so successive page requests
|
||||||
|
# stay consistent while browsing.
|
||||||
|
rng = random.Random(seed or 'random')
|
||||||
|
result = list(data)
|
||||||
|
rng.shuffle(result)
|
||||||
elif sort_key == 'versions_count':
|
elif sort_key == 'versions_count':
|
||||||
# Pre-dedup sort: fall back to name sort.
|
# Pre-dedup sort: fall back to name sort.
|
||||||
# Actual re-sort by version_count happens in get_paginated_data after dedup.
|
# Actual re-sort by version_count happens in get_paginated_data after dedup.
|
||||||
@@ -285,15 +293,16 @@ class ModelCache:
|
|||||||
logger.debug("ModelCache._sort_data(%s, %s) for %d items took %.3fs", sort_key, order, len(data), duration)
|
logger.debug("ModelCache._sort_data(%s, %s) for %d items took %.3fs", sort_key, order, len(data), duration)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def get_sorted_data(self, sort_key: str = 'name', order: str = 'asc') -> List[Dict]:
|
async def get_sorted_data(self, sort_key: str = 'name', order: str = 'asc', seed: Optional[str] = None) -> List[Dict]:
|
||||||
"""Get sorted data by sort_key and order, using cache if possible"""
|
"""Get sorted data by sort_key and order, using cache if possible"""
|
||||||
async with self._lock:
|
async with self._lock:
|
||||||
if (sort_key, order) == self._last_sort:
|
cache_key = (sort_key, order, seed)
|
||||||
|
if cache_key == self._last_sort:
|
||||||
return self._last_sorted_data
|
return self._last_sorted_data
|
||||||
|
|
||||||
start_time = time.perf_counter()
|
start_time = time.perf_counter()
|
||||||
sorted_data = self._sort_data(self.raw_data, sort_key, order)
|
sorted_data = self._sort_data(self.raw_data, sort_key, order, seed)
|
||||||
self._last_sort = (sort_key, order)
|
self._last_sort = cache_key
|
||||||
self._last_sorted_data = sorted_data
|
self._last_sorted_data = sorted_data
|
||||||
|
|
||||||
duration = time.perf_counter() - start_time
|
duration = time.perf_counter() - start_time
|
||||||
@@ -313,8 +322,8 @@ class ModelCache:
|
|||||||
self.name_display_mode = normalized
|
self.name_display_mode = normalized
|
||||||
|
|
||||||
if self._last_sort[0] == 'name':
|
if self._last_sort[0] == 'name':
|
||||||
sort_key, order = self._last_sort
|
sort_key, order, seed = self._last_sort
|
||||||
self._last_sorted_data = self._sort_data(self.raw_data, sort_key, order)
|
self._last_sorted_data = self._sort_data(self.raw_data, sort_key, order, seed)
|
||||||
|
|
||||||
async def update_preview_url(self, file_path: str, preview_url: str, preview_nsfw_level: int) -> bool:
|
async def update_preview_url(self, file_path: str, preview_url: str, preview_nsfw_level: int) -> bool:
|
||||||
"""Update preview_url for a specific model in all cached data
|
"""Update preview_url for a specific model in all cached data
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from abc import ABC, abstractmethod
|
|||||||
from ..utils.utils import calculate_relative_path_for_model, remove_empty_dirs
|
from ..utils.utils import calculate_relative_path_for_model, remove_empty_dirs
|
||||||
from ..utils.constants import AUTO_ORGANIZE_BATCH_SIZE
|
from ..utils.constants import AUTO_ORGANIZE_BATCH_SIZE
|
||||||
from ..services.settings_manager import get_settings_manager
|
from ..services.settings_manager import get_settings_manager
|
||||||
|
from ..services.model_lifecycle_service import _require_path_in_library_roots
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -493,6 +494,9 @@ class ModelMoveService:
|
|||||||
Dictionary with move result
|
Dictionary with move result
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
_require_path_in_library_roots(file_path, self.scanner, label="Source path")
|
||||||
|
_require_path_in_library_roots(target_path, self.scanner, label="Target path")
|
||||||
|
|
||||||
if use_default_paths:
|
if use_default_paths:
|
||||||
# Find the model in cache to get metadata
|
# Find the model in cache to get metadata
|
||||||
cache = await self.scanner.get_cached_data()
|
cache = await self.scanner.get_cached_data()
|
||||||
|
|||||||
@@ -48,6 +48,36 @@ async def delete_model_artifacts(
|
|||||||
return deleted
|
return deleted
|
||||||
|
|
||||||
|
|
||||||
|
def _require_path_in_library_roots(file_path: str, scanner, *, label: str = "path") -> None:
|
||||||
|
"""Raise ``ValueError`` if *file_path* is not inside a configured model root.
|
||||||
|
|
||||||
|
Uses ``os.path.abspath()`` (NOT ``realpath``) to resolve ``..`` and ``.``
|
||||||
|
while preserving symlinks — this keeps the check in business-path space.
|
||||||
|
Skips when the scanner does not expose ``get_model_roots`` or the list
|
||||||
|
is empty.
|
||||||
|
"""
|
||||||
|
|
||||||
|
roots = None
|
||||||
|
if hasattr(scanner, "get_model_roots"):
|
||||||
|
try:
|
||||||
|
roots = scanner.get_model_roots()
|
||||||
|
except NotImplementedError:
|
||||||
|
roots = None
|
||||||
|
if not roots:
|
||||||
|
return
|
||||||
|
|
||||||
|
resolved = os.path.abspath(os.path.normpath(file_path))
|
||||||
|
|
||||||
|
for root in roots:
|
||||||
|
root_resolved = os.path.abspath(os.path.normpath(root))
|
||||||
|
if resolved == root_resolved or resolved.startswith(root_resolved + os.sep):
|
||||||
|
return
|
||||||
|
|
||||||
|
raise ValueError(
|
||||||
|
f"{label} '{file_path}' is outside configured library directories"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ModelLifecycleService:
|
class ModelLifecycleService:
|
||||||
"""Co-ordinate destructive and mutating model operations."""
|
"""Co-ordinate destructive and mutating model operations."""
|
||||||
|
|
||||||
@@ -74,6 +104,8 @@ class ModelLifecycleService:
|
|||||||
if not file_path:
|
if not file_path:
|
||||||
raise ValueError("Model path is required")
|
raise ValueError("Model path is required")
|
||||||
|
|
||||||
|
_require_path_in_library_roots(file_path, self._scanner, label="File path")
|
||||||
|
|
||||||
cache = await self._scanner.get_cached_data()
|
cache = await self._scanner.get_cached_data()
|
||||||
|
|
||||||
cached_entry = None
|
cached_entry = None
|
||||||
@@ -182,6 +214,8 @@ class ModelLifecycleService:
|
|||||||
if not file_path:
|
if not file_path:
|
||||||
raise ValueError("Model path is required")
|
raise ValueError("Model path is required")
|
||||||
|
|
||||||
|
_require_path_in_library_roots(file_path, self._scanner, label="File path")
|
||||||
|
|
||||||
metadata_path = os.path.splitext(file_path)[0] + ".metadata.json"
|
metadata_path = os.path.splitext(file_path)[0] + ".metadata.json"
|
||||||
metadata = await self._metadata_loader(metadata_path)
|
metadata = await self._metadata_loader(metadata_path)
|
||||||
metadata["exclude"] = True
|
metadata["exclude"] = True
|
||||||
@@ -229,6 +263,8 @@ class ModelLifecycleService:
|
|||||||
if not file_path:
|
if not file_path:
|
||||||
raise ValueError("Model path is required")
|
raise ValueError("Model path is required")
|
||||||
|
|
||||||
|
_require_path_in_library_roots(file_path, self._scanner, label="File path")
|
||||||
|
|
||||||
if not os.path.exists(file_path):
|
if not os.path.exists(file_path):
|
||||||
raise ValueError("Model file does not exist")
|
raise ValueError("Model file does not exist")
|
||||||
|
|
||||||
@@ -270,6 +306,9 @@ class ModelLifecycleService:
|
|||||||
if not file_paths:
|
if not file_paths:
|
||||||
raise ValueError("No file paths provided for deletion")
|
raise ValueError("No file paths provided for deletion")
|
||||||
|
|
||||||
|
for path in file_paths:
|
||||||
|
_require_path_in_library_roots(path, self._scanner, label="File path")
|
||||||
|
|
||||||
return await self._scanner.bulk_delete_models(file_paths)
|
return await self._scanner.bulk_delete_models(file_paths)
|
||||||
|
|
||||||
async def rename_model(
|
async def rename_model(
|
||||||
@@ -280,6 +319,8 @@ class ModelLifecycleService:
|
|||||||
if not file_path or not new_file_name:
|
if not file_path or not new_file_name:
|
||||||
raise ValueError("File path and new file name are required")
|
raise ValueError("File path and new file name are required")
|
||||||
|
|
||||||
|
_require_path_in_library_roots(file_path, self._scanner, label="File path")
|
||||||
|
|
||||||
invalid_chars = {"/", "\\", ":", "*", "?", '"', "<", ">", "|"}
|
invalid_chars = {"/", "\\", ":", "*", "?", '"', "<", ">", "|"}
|
||||||
if any(char in new_file_name for char in invalid_chars):
|
if any(char in new_file_name for char in invalid_chars):
|
||||||
raise ValueError("Invalid characters in file name")
|
raise ValueError("Invalid characters in file name")
|
||||||
|
|||||||
@@ -143,10 +143,18 @@ class ModelMetadataProvider(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
async def get_user_models(self, username: str) -> Optional[List[Dict]]:
|
async def get_user_models(self, username: str, cursor: Optional[str] = None) -> Optional[Dict]:
|
||||||
"""Fetch models owned by the specified user"""
|
"""Fetch one page of models owned by the specified user.
|
||||||
|
|
||||||
|
Returns ``{"items": [...], "nextCursor": <str|None>}`` on success,
|
||||||
|
or None when unsupported/failed. ``cursor`` continues a previous page.
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
async def get_creator_model_count(self, username: str) -> Optional[int]:
|
||||||
|
"""Published model count for the user; None when unsupported."""
|
||||||
|
return None
|
||||||
|
|
||||||
class CivitaiModelMetadataProvider(ModelMetadataProvider):
|
class CivitaiModelMetadataProvider(ModelMetadataProvider):
|
||||||
"""Provider that uses Civitai API for metadata"""
|
"""Provider that uses Civitai API for metadata"""
|
||||||
|
|
||||||
@@ -175,8 +183,11 @@ class CivitaiModelMetadataProvider(ModelMetadataProvider):
|
|||||||
async def get_model_version_info(self, version_id: str) -> Tuple[Optional[Dict], Optional[str]]:
|
async def get_model_version_info(self, version_id: str) -> Tuple[Optional[Dict], Optional[str]]:
|
||||||
return await self.client.get_model_version_info(version_id)
|
return await self.client.get_model_version_info(version_id)
|
||||||
|
|
||||||
async def get_user_models(self, username: str) -> Optional[List[Dict]]:
|
async def get_user_models(self, username: str, cursor: Optional[str] = None) -> Optional[Dict]:
|
||||||
return await self.client.get_user_models(username)
|
return await self.client.get_user_models(username, cursor)
|
||||||
|
|
||||||
|
async def get_creator_model_count(self, username: str) -> Optional[int]:
|
||||||
|
return await self.client.get_creator_model_count(username)
|
||||||
|
|
||||||
class CivArchiveModelMetadataProvider(ModelMetadataProvider):
|
class CivArchiveModelMetadataProvider(ModelMetadataProvider):
|
||||||
"""Provider that uses CivArchive API for metadata"""
|
"""Provider that uses CivArchive API for metadata"""
|
||||||
@@ -196,7 +207,7 @@ class CivArchiveModelMetadataProvider(ModelMetadataProvider):
|
|||||||
async def get_model_version_info(self, version_id: str) -> Tuple[Optional[Dict], Optional[str]]:
|
async def get_model_version_info(self, version_id: str) -> Tuple[Optional[Dict], Optional[str]]:
|
||||||
return await self.client.get_model_version_info(version_id)
|
return await self.client.get_model_version_info(version_id)
|
||||||
|
|
||||||
async def get_user_models(self, username: str) -> Optional[List[Dict]]:
|
async def get_user_models(self, username: str, cursor: Optional[str] = None) -> Optional[Dict]:
|
||||||
"""Not supported by CivArchive provider"""
|
"""Not supported by CivArchive provider"""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -347,7 +358,7 @@ class SQLiteModelMetadataProvider(ModelMetadataProvider):
|
|||||||
version_data = await self._get_version_with_model_data(db, model_id, version_id)
|
version_data = await self._get_version_with_model_data(db, model_id, version_id)
|
||||||
return version_data, None
|
return version_data, None
|
||||||
|
|
||||||
async def get_user_models(self, username: str) -> Optional[List[Dict]]:
|
async def get_user_models(self, username: str, cursor: Optional[str] = None) -> Optional[Dict]:
|
||||||
"""Listing models by username is not supported for archive database"""
|
"""Listing models by username is not supported for archive database"""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -602,13 +613,14 @@ class FallbackMetadataProvider(ModelMetadataProvider):
|
|||||||
continue
|
continue
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def get_user_models(self, username: str) -> Optional[List[Dict]]:
|
async def get_user_models(self, username: str, cursor: Optional[str] = None) -> Optional[Dict]:
|
||||||
for provider, label in self._iter_providers():
|
for provider, label in self._iter_providers():
|
||||||
try:
|
try:
|
||||||
result = await self._call_with_rate_limit(
|
result = await self._call_with_rate_limit(
|
||||||
label,
|
label,
|
||||||
provider.get_user_models,
|
provider.get_user_models,
|
||||||
username,
|
username,
|
||||||
|
cursor=cursor,
|
||||||
)
|
)
|
||||||
if result is not None:
|
if result is not None:
|
||||||
return result
|
return result
|
||||||
@@ -624,6 +636,19 @@ class FallbackMetadataProvider(ModelMetadataProvider):
|
|||||||
continue
|
continue
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
async def get_creator_model_count(self, username: str) -> Optional[int]:
|
||||||
|
for provider, label in self._iter_providers():
|
||||||
|
try:
|
||||||
|
result = await provider.get_creator_model_count(username)
|
||||||
|
if result is not None:
|
||||||
|
return result
|
||||||
|
except Exception as e:
|
||||||
|
logger.debug(
|
||||||
|
"Provider %s failed for get_creator_model_count: %s", label, e
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
return None
|
||||||
|
|
||||||
def _iter_providers(self):
|
def _iter_providers(self):
|
||||||
return zip(self.providers, self._provider_labels)
|
return zip(self.providers, self._provider_labels)
|
||||||
|
|
||||||
@@ -704,13 +729,17 @@ class RateLimitRetryingProvider(ModelMetadataProvider):
|
|||||||
version_id,
|
version_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_user_models(self, username: str) -> Optional[List[Dict]]:
|
async def get_user_models(self, username: str, cursor: Optional[str] = None) -> Optional[Dict]:
|
||||||
return await self._rate_limit_helper.run(
|
return await self._rate_limit_helper.run(
|
||||||
self._label,
|
self._label,
|
||||||
self._provider.get_user_models,
|
self._provider.get_user_models,
|
||||||
username,
|
username,
|
||||||
|
cursor=cursor,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def get_creator_model_count(self, username: str) -> Optional[int]:
|
||||||
|
return await self._provider.get_creator_model_count(username)
|
||||||
|
|
||||||
class ModelMetadataProviderManager:
|
class ModelMetadataProviderManager:
|
||||||
"""Manager for selecting and using model metadata providers"""
|
"""Manager for selecting and using model metadata providers"""
|
||||||
|
|
||||||
@@ -776,10 +805,20 @@ class ModelMetadataProviderManager:
|
|||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def get_user_models(self, username: str, provider_name: str = None) -> Optional[List[Dict]]:
|
async def get_user_models(
|
||||||
"""Fetch models owned by the specified user"""
|
self,
|
||||||
|
username: str,
|
||||||
|
provider_name: str = None,
|
||||||
|
cursor: Optional[str] = None,
|
||||||
|
) -> Optional[Dict]:
|
||||||
|
"""Fetch one page of models owned by the specified user"""
|
||||||
provider = self._get_provider(provider_name)
|
provider = self._get_provider(provider_name)
|
||||||
return await provider.get_user_models(username)
|
return await provider.get_user_models(username, cursor)
|
||||||
|
|
||||||
|
async def get_creator_model_count(self, username: str, provider_name: str = None) -> Optional[int]:
|
||||||
|
"""Best-effort published model count for the specified user"""
|
||||||
|
provider = self._get_provider(provider_name)
|
||||||
|
return await provider.get_creator_model_count(username)
|
||||||
|
|
||||||
def _get_provider(self, provider_name: str = None) -> ModelMetadataProvider:
|
def _get_provider(self, provider_name: str = None) -> ModelMetadataProvider:
|
||||||
"""Get provider by name or default provider"""
|
"""Get provider by name or default provider"""
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ class SortParams:
|
|||||||
|
|
||||||
key: str
|
key: str
|
||||||
order: str
|
order: str
|
||||||
|
seed: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
@@ -116,7 +117,7 @@ class ModelCacheRepository:
|
|||||||
async def fetch_sorted(self, params: SortParams) -> List[Dict[str, Any]]:
|
async def fetch_sorted(self, params: SortParams) -> List[Dict[str, Any]]:
|
||||||
"""Fetch cached data pre-sorted according to ``params``."""
|
"""Fetch cached data pre-sorted according to ``params``."""
|
||||||
cache = await self.get_cache()
|
cache = await self.get_cache()
|
||||||
return await cache.get_sorted_data(params.key, params.order)
|
return await cache.get_sorted_data(params.key, params.order, params.seed)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse_sort(sort_by: str) -> SortParams:
|
def parse_sort(sort_by: str) -> SortParams:
|
||||||
@@ -132,10 +133,17 @@ class ModelCacheRepository:
|
|||||||
sort_key = sort_by.strip().lower() or "name"
|
sort_key = sort_by.strip().lower() or "name"
|
||||||
order = "asc"
|
order = "asc"
|
||||||
|
|
||||||
if order not in ("asc", "desc"):
|
seed = None
|
||||||
|
if sort_key == "random":
|
||||||
|
# Random sort: the portion after ':' is the shuffle seed.
|
||||||
|
# A stable seed keeps paginated requests consistent; order is
|
||||||
|
# meaningless for a random shuffle.
|
||||||
|
seed = order if order and order not in ("asc", "desc") else None
|
||||||
|
order = "asc"
|
||||||
|
elif order not in ("asc", "desc"):
|
||||||
order = "asc"
|
order = "asc"
|
||||||
|
|
||||||
return SortParams(key=sort_key, order=order)
|
return SortParams(key=sort_key, order=order, seed=seed)
|
||||||
|
|
||||||
|
|
||||||
class ModelFilterSet:
|
class ModelFilterSet:
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from ..utils.metadata_manager import MetadataManager
|
|||||||
from ..utils.civitai_utils import resolve_license_info
|
from ..utils.civitai_utils import resolve_license_info
|
||||||
from .model_cache import ModelCache
|
from .model_cache import ModelCache
|
||||||
from .model_hash_index import ModelHashIndex
|
from .model_hash_index import ModelHashIndex
|
||||||
from .model_lifecycle_service import delete_model_artifacts
|
from .model_lifecycle_service import delete_model_artifacts, _require_path_in_library_roots
|
||||||
from .service_registry import ServiceRegistry
|
from .service_registry import ServiceRegistry
|
||||||
from .websocket_manager import ws_manager
|
from .websocket_manager import ws_manager
|
||||||
from .persistent_model_cache import get_persistent_cache
|
from .persistent_model_cache import get_persistent_cache
|
||||||
@@ -927,6 +927,25 @@ class ModelScanner:
|
|||||||
# Update cache data
|
# Update cache data
|
||||||
self._cache.raw_data = [item for item in self._cache.raw_data if item['file_path'] not in missing_files]
|
self._cache.raw_data = [item for item in self._cache.raw_data if item['file_path'] not in missing_files]
|
||||||
|
|
||||||
|
dedup_removed = 0
|
||||||
|
seen_paths: set = set()
|
||||||
|
deduped: list = []
|
||||||
|
for item in reversed(self._cache.raw_data):
|
||||||
|
path = item.get('file_path', '')
|
||||||
|
if path not in seen_paths:
|
||||||
|
seen_paths.add(path)
|
||||||
|
deduped.append(item)
|
||||||
|
else:
|
||||||
|
for tag in item.get('tags', []):
|
||||||
|
if tag in self._tags_count:
|
||||||
|
self._tags_count[tag] = max(0, self._tags_count[tag] - 1)
|
||||||
|
if self._tags_count[tag] == 0:
|
||||||
|
del self._tags_count[tag]
|
||||||
|
dedup_removed += 1
|
||||||
|
if dedup_removed > 0:
|
||||||
|
self._cache.raw_data = list(reversed(deduped))
|
||||||
|
total_removed += dedup_removed
|
||||||
|
|
||||||
# Resort cache if changes were made
|
# Resort cache if changes were made
|
||||||
if total_added > 0 or total_removed > 0:
|
if total_added > 0 or total_removed > 0:
|
||||||
# Update folders list
|
# Update folders list
|
||||||
@@ -1352,18 +1371,25 @@ class ModelScanner:
|
|||||||
# Update folder in metadata
|
# Update folder in metadata
|
||||||
metadata_dict['folder'] = folder
|
metadata_dict['folder'] = folder
|
||||||
|
|
||||||
# Add to cache
|
file_path = metadata_dict.get('file_path', '')
|
||||||
|
if file_path:
|
||||||
|
old_entries = [item for item in self._cache.raw_data if item.get('file_path') == file_path]
|
||||||
|
for old_entry in old_entries:
|
||||||
|
for tag in old_entry.get('tags', []):
|
||||||
|
if tag in self._tags_count:
|
||||||
|
self._tags_count[tag] = max(0, self._tags_count[tag] - 1)
|
||||||
|
if self._tags_count[tag] == 0:
|
||||||
|
del self._tags_count[tag]
|
||||||
|
self._hash_index.remove_by_path(file_path)
|
||||||
|
self._cache.raw_data = [item for item in self._cache.raw_data if item.get('file_path') != file_path]
|
||||||
|
|
||||||
|
for tag in metadata_dict.get('tags', []):
|
||||||
|
self._tags_count[tag] = self._tags_count.get(tag, 0) + 1
|
||||||
|
|
||||||
self._cache.raw_data.append(metadata_dict)
|
self._cache.raw_data.append(metadata_dict)
|
||||||
self._cache.add_to_version_index(metadata_dict)
|
|
||||||
|
|
||||||
# Resort cache data
|
|
||||||
await self._cache.resort()
|
await self._cache.resort()
|
||||||
|
|
||||||
# Update folders list
|
|
||||||
all_folders = set(self._cache.folders)
|
|
||||||
all_folders.add(folder)
|
|
||||||
self._cache.folders = sorted(list(all_folders), key=lambda x: x.lower())
|
|
||||||
|
|
||||||
# Update the hash index
|
# Update the hash index
|
||||||
self._hash_index.add_entry(metadata_dict['sha256'], metadata_dict['file_path'])
|
self._hash_index.add_entry(metadata_dict['sha256'], metadata_dict['file_path'])
|
||||||
await self._persist_current_cache()
|
await self._persist_current_cache()
|
||||||
@@ -1395,6 +1421,9 @@ class ModelScanner:
|
|||||||
base_name = os.path.splitext(os.path.basename(source_path))[0]
|
base_name = os.path.splitext(os.path.basename(source_path))[0]
|
||||||
source_dir = os.path.dirname(source_path)
|
source_dir = os.path.dirname(source_path)
|
||||||
|
|
||||||
|
_require_path_in_library_roots(source_path, self, label="Source path")
|
||||||
|
_require_path_in_library_roots(target_path, self, label="Target path")
|
||||||
|
|
||||||
os.makedirs(target_path, exist_ok=True)
|
os.makedirs(target_path, exist_ok=True)
|
||||||
|
|
||||||
def get_source_hash():
|
def get_source_hash():
|
||||||
@@ -1723,7 +1752,7 @@ class ModelScanner:
|
|||||||
# ---- Conditional resort (only when sort-key fields changed) ----
|
# ---- Conditional resort (only when sort-key fields changed) ----
|
||||||
need_resort = False
|
need_resort = False
|
||||||
_last = cache._last_sort
|
_last = cache._last_sort
|
||||||
sort_key: Optional[str] = _last[0] if _last != (None, None) else None
|
sort_key: Optional[str] = _last[0] if _last[0] is not None else None
|
||||||
if sort_key == "name":
|
if sort_key == "name":
|
||||||
if (
|
if (
|
||||||
old_model_name != desired_entry.get("model_name", "")
|
old_model_name != desired_entry.get("model_name", "")
|
||||||
@@ -1971,6 +2000,8 @@ class ModelScanner:
|
|||||||
break
|
break
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
_require_path_in_library_roots(file_path, self, label="File path")
|
||||||
|
|
||||||
target_dir = os.path.dirname(file_path)
|
target_dir = os.path.dirname(file_path)
|
||||||
base_name = os.path.basename(file_path)
|
base_name = os.path.basename(file_path)
|
||||||
file_name, main_extension = os.path.splitext(base_name)
|
file_name, main_extension = os.path.splitext(base_name)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ from .checkpoint_scanner import CheckpointScanner
|
|||||||
from .settings_manager import get_settings_manager
|
from .settings_manager import get_settings_manager
|
||||||
from .recipes.errors import RecipeNotFoundError
|
from .recipes.errors import RecipeNotFoundError
|
||||||
from ..utils.civitai_utils import extract_civitai_image_id
|
from ..utils.civitai_utils import extract_civitai_image_id
|
||||||
from ..utils.utils import calculate_recipe_fingerprint, fuzzy_match
|
from ..utils.utils import calculate_recipe_fingerprint
|
||||||
from natsort import natsorted
|
from natsort import natsorted
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
@@ -1020,13 +1020,16 @@ class RecipeScanner:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
result = self._fts_index.search(search, fields)
|
result = self._fts_index.search(search, fields)
|
||||||
# Return None if empty to trigger fuzzy fallback
|
# Return empty set for empty FTS results — do NOT fall back to
|
||||||
# Empty FTS results may indicate query syntax issues or need for fuzzy matching
|
# Python fuzzy matching, which freezes the server with 10k+ recipes.
|
||||||
|
# FTS5 prefix matching with unicode61 tokenizer correctly handles
|
||||||
|
# compound tokens (e.g. "illustrious" matches "path/illustrious/model").
|
||||||
|
# If FTS returns nothing, there are genuinely no matching recipes.
|
||||||
if not result:
|
if not result:
|
||||||
return None
|
return set()
|
||||||
return result
|
return result
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.debug("FTS search failed, falling back to fuzzy search: %s", exc)
|
logger.debug("FTS search failed, falling back to title-only search: %s", exc)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _update_fts_index_for_recipe(
|
def _update_fts_index_for_recipe(
|
||||||
@@ -2079,49 +2082,14 @@ class RecipeScanner:
|
|||||||
if str(item.get("id", "")) in fts_matching_ids
|
if str(item.get("id", "")) in fts_matching_ids
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
# Fallback to fuzzy_match (slower but always available)
|
# FTS index not yet built — return empty rather than
|
||||||
# Build the search predicate based on search options
|
# scanning 42k+ items in Python. The FTS background build
|
||||||
def matches_search(item):
|
# finishes in seconds; by the time a user navigates here
|
||||||
# Search in title if enabled
|
# and types a search, it is already available.
|
||||||
if search_options.get("title", True):
|
logger.debug(
|
||||||
if fuzzy_match(str(item.get("title", "")), search):
|
"FTS index not ready — search '%s' returning empty", search
|
||||||
return True
|
)
|
||||||
|
filtered_data = []
|
||||||
# Search in tags if enabled
|
|
||||||
if search_options.get("tags", True) and "tags" in item:
|
|
||||||
for tag in item["tags"]:
|
|
||||||
if fuzzy_match(tag, search):
|
|
||||||
return True
|
|
||||||
|
|
||||||
# Search in lora file names if enabled
|
|
||||||
if search_options.get("lora_name", True) and "loras" in item:
|
|
||||||
for lora in item["loras"]:
|
|
||||||
if fuzzy_match(str(lora.get("file_name", "")), search):
|
|
||||||
return True
|
|
||||||
|
|
||||||
# Search in lora model names if enabled
|
|
||||||
if search_options.get("lora_model", True) and "loras" in item:
|
|
||||||
for lora in item["loras"]:
|
|
||||||
if fuzzy_match(str(lora.get("modelName", "")), search):
|
|
||||||
return True
|
|
||||||
|
|
||||||
# Search in prompt and negative_prompt if enabled
|
|
||||||
if search_options.get("prompt", True) and "gen_params" in item:
|
|
||||||
gen_params = item["gen_params"]
|
|
||||||
if fuzzy_match(str(gen_params.get("prompt", "")), search):
|
|
||||||
return True
|
|
||||||
if fuzzy_match(
|
|
||||||
str(gen_params.get("negative_prompt", "")), search
|
|
||||||
):
|
|
||||||
return True
|
|
||||||
|
|
||||||
# No match found
|
|
||||||
return False
|
|
||||||
|
|
||||||
# Filter the data using the search predicate
|
|
||||||
filtered_data = [
|
|
||||||
item for item in filtered_data if matches_search(item)
|
|
||||||
]
|
|
||||||
|
|
||||||
# Apply additional filters
|
# Apply additional filters
|
||||||
if filters:
|
if filters:
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ DEFAULT_SETTINGS: Dict[str, Any] = {
|
|||||||
"mature_blur_level": "R",
|
"mature_blur_level": "R",
|
||||||
"autoplay_on_hover": False,
|
"autoplay_on_hover": False,
|
||||||
"display_density": "default",
|
"display_density": "default",
|
||||||
|
"recipes_layout": "grid",
|
||||||
"card_info_display": "always",
|
"card_info_display": "always",
|
||||||
"include_trigger_words": False,
|
"include_trigger_words": False,
|
||||||
"compact_mode": False,
|
"compact_mode": False,
|
||||||
@@ -1473,10 +1474,12 @@ class SettingsManager:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
common_root = os.path.commonpath([source, target])
|
common_root = os.path.commonpath([source, target])
|
||||||
except ValueError as exc:
|
except ValueError:
|
||||||
raise ValueError("Invalid recipes path change") from exc
|
# Windows: paths on different drives share no common root.
|
||||||
|
# A cross-drive move is valid, so treat it as no common root.
|
||||||
|
common_root = None
|
||||||
|
|
||||||
if common_root == source:
|
if common_root is not None and common_root == source:
|
||||||
raise ValueError("Recipes path cannot be moved into a nested directory")
|
raise ValueError("Recipes path cannot be moved into a nested directory")
|
||||||
|
|
||||||
planned_recipe_updates: Dict[str, Dict[str, Any]] = {}
|
planned_recipe_updates: Dict[str, Dict[str, Any]] = {}
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ class BulkMetadataRefreshUseCase:
|
|||||||
if sha256:
|
if sha256:
|
||||||
model["sha256"] = sha256
|
model["sha256"] = sha256
|
||||||
model["hash_status"] = "completed"
|
model["hash_status"] = "completed"
|
||||||
|
hash_status = "completed"
|
||||||
else:
|
else:
|
||||||
self._logger.error(f"Failed to calculate hash for {file_path}")
|
self._logger.error(f"Failed to calculate hash for {file_path}")
|
||||||
failures.append({"name": model.get("model_name", file_path or "Unknown"), "error": "Failed to calculate hash"})
|
failures.append({"name": model.get("model_name", file_path or "Unknown"), "error": "Failed to calculate hash"})
|
||||||
@@ -148,6 +149,16 @@ class BulkMetadataRefreshUseCase:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
await MetadataManager.hydrate_model_data(model)
|
await MetadataManager.hydrate_model_data(model)
|
||||||
|
|
||||||
|
# hydrate_model_data replaces model with .metadata.json content,
|
||||||
|
# which may lack sha256. Restore from cache and persist the fix.
|
||||||
|
if not model.get("sha256"):
|
||||||
|
model["sha256"] = sha256
|
||||||
|
model["hash_status"] = model.get("hash_status", hash_status)
|
||||||
|
data_to_save = model.copy()
|
||||||
|
data_to_save.pop("folder", None)
|
||||||
|
await MetadataManager.save_metadata(file_path, data_to_save)
|
||||||
|
|
||||||
result, error_msg = await self._metadata_sync.fetch_and_update_model(
|
result, error_msg = await self._metadata_sync.fetch_and_update_model(
|
||||||
sha256=model["sha256"],
|
sha256=model["sha256"],
|
||||||
file_path=model["file_path"],
|
file_path=model["file_path"],
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ logger = logging.getLogger(__name__)
|
|||||||
_WILDCARD_PATTERN = re.compile(r"__([\w\s.\-+/*\\]+?)__")
|
_WILDCARD_PATTERN = re.compile(r"__([\w\s.\-+/*\\]+?)__")
|
||||||
_OPTION_PATTERN = re.compile(r"{([^{}]*?)}")
|
_OPTION_PATTERN = re.compile(r"{([^{}]*?)}")
|
||||||
_TRIGGER_WORD_PATTERN = re.compile(r"^trigger_words\d+$")
|
_TRIGGER_WORD_PATTERN = re.compile(r"^trigger_words\d+$")
|
||||||
_WEIGHTED_OPTION_PATTERN = re.compile(r"^\s*([0-9.]+)::")
|
_WEIGHTED_OPTION_PATTERN = re.compile(r"^\s*-?\d+(\.\d+)?::")
|
||||||
_NUMERIC_PATTERN = re.compile(r"^-?\d+(\.\d+)?$")
|
_NUMERIC_PATTERN = re.compile(r"^-?\d+(\.\d+)?$")
|
||||||
|
|
||||||
|
|
||||||
@@ -390,7 +390,7 @@ class WildcardService:
|
|||||||
) -> str | None:
|
) -> str | None:
|
||||||
keyword = _normalize_wildcard_key(raw_key)
|
keyword = _normalize_wildcard_key(raw_key)
|
||||||
if keyword in wildcard_dict:
|
if keyword in wildcard_dict:
|
||||||
return rng.choice(wildcard_dict[keyword])
|
return self._pick_weighted_or_plain(wildcard_dict[keyword], rng)
|
||||||
|
|
||||||
if "*" in keyword:
|
if "*" in keyword:
|
||||||
regex_pattern = keyword.replace("*", ".*").replace("+", r"\+")
|
regex_pattern = keyword.replace("*", ".*").replace("+", r"\+")
|
||||||
@@ -400,7 +400,7 @@ class WildcardService:
|
|||||||
if compiled.match(key):
|
if compiled.match(key):
|
||||||
aggregated.extend(values)
|
aggregated.extend(values)
|
||||||
if aggregated:
|
if aggregated:
|
||||||
return rng.choice(aggregated)
|
return self._pick_weighted_or_plain(aggregated, rng)
|
||||||
|
|
||||||
if "/" not in keyword:
|
if "/" not in keyword:
|
||||||
fallback_keyword = _normalize_wildcard_key(f"*/{keyword}")
|
fallback_keyword = _normalize_wildcard_key(f"*/{keyword}")
|
||||||
@@ -409,6 +409,39 @@ class WildcardService:
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def _pick_weighted_or_plain(
|
||||||
|
self, values: list[str], rng: random.Random
|
||||||
|
) -> str:
|
||||||
|
"""Pick a value from the list, respecting N::weight prefix if present.
|
||||||
|
|
||||||
|
When any value in the list uses the ``N::value`` weighted syntax with a
|
||||||
|
weight different from 1, the pick uses weighted random selection. When
|
||||||
|
no such weighting is present, a plain ``rng.choice`` is used (preserving
|
||||||
|
backward compatibility for unweighted wildcard files).
|
||||||
|
|
||||||
|
In either case the ``N::`` prefix is always stripped from the returned
|
||||||
|
value, matching the behaviour of ``{...}`` option groups.
|
||||||
|
"""
|
||||||
|
# Fast path: skip weighting logic entirely when no :: syntax exists
|
||||||
|
if not any("::" in v for v in values):
|
||||||
|
return rng.choice(values)
|
||||||
|
|
||||||
|
weighted_options: list[tuple[float, str]] = []
|
||||||
|
for value in values:
|
||||||
|
weight = 1.0
|
||||||
|
parts = value.split("::", 1)
|
||||||
|
if len(parts) == 2 and _is_numeric_string(parts[0].strip()):
|
||||||
|
weight = float(parts[0].strip())
|
||||||
|
weighted_options.append((weight, value))
|
||||||
|
|
||||||
|
any_weighted = any(w != 1.0 for w, _ in weighted_options)
|
||||||
|
if any_weighted:
|
||||||
|
picked = self._weighted_choice(weighted_options, rng)
|
||||||
|
else:
|
||||||
|
picked = rng.choice(values)
|
||||||
|
|
||||||
|
return self._strip_weight_prefix(picked)
|
||||||
|
|
||||||
|
|
||||||
def is_trigger_words_input(name: str) -> bool:
|
def is_trigger_words_input(name: str) -> bool:
|
||||||
return bool(_TRIGGER_WORD_PATTERN.match(name))
|
return bool(_TRIGGER_WORD_PATTERN.match(name))
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ NODE_TYPES = {
|
|||||||
"Lora Loader (LoraManager)": 1,
|
"Lora Loader (LoraManager)": 1,
|
||||||
"Lora Stacker (LoraManager)": 2,
|
"Lora Stacker (LoraManager)": 2,
|
||||||
"WanVideo Lora Select (LoraManager)": 3,
|
"WanVideo Lora Select (LoraManager)": 3,
|
||||||
|
"Create Hook LoRA (LoraManager)": 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Default ComfyUI node color when bgcolor is null
|
# Default ComfyUI node color when bgcolor is null
|
||||||
|
|||||||
@@ -14,11 +14,16 @@ from ..services.service_registry import ServiceRegistry
|
|||||||
from ..utils.example_images_paths import (
|
from ..utils.example_images_paths import (
|
||||||
ExampleImagePathResolver,
|
ExampleImagePathResolver,
|
||||||
ensure_library_root_exists,
|
ensure_library_root_exists,
|
||||||
|
get_example_images_root,
|
||||||
|
is_hash_folder,
|
||||||
uses_library_scoped_folders,
|
uses_library_scoped_folders,
|
||||||
)
|
)
|
||||||
from ..utils.metadata_manager import MetadataManager
|
from ..utils.metadata_manager import MetadataManager
|
||||||
from .example_images_processor import ExampleImagesProcessor
|
from .example_images_processor import ExampleImagesProcessor
|
||||||
from .example_images_metadata import MetadataUpdater
|
from .example_images_metadata import (
|
||||||
|
MetadataUpdater,
|
||||||
|
update_cache_from_metadata,
|
||||||
|
)
|
||||||
from ..services.downloader import get_downloader
|
from ..services.downloader import get_downloader
|
||||||
from ..services.settings_manager import get_settings_manager
|
from ..services.settings_manager import get_settings_manager
|
||||||
|
|
||||||
@@ -87,6 +92,13 @@ class _DownloadProgress(dict):
|
|||||||
return snapshot
|
return snapshot
|
||||||
|
|
||||||
|
|
||||||
|
# When fewer candidates than this remain in check_pending_models, probe each
|
||||||
|
# model folder directly (preserving legacy-folder migration semantics). Above
|
||||||
|
# it, build a folder index with a single directory scan so libraries with
|
||||||
|
# 100k+ models do not pay one syscall per candidate.
|
||||||
|
_BULK_LOOKUP_THRESHOLD = 1000
|
||||||
|
|
||||||
|
|
||||||
def _model_directory_has_files(path: str) -> bool:
|
def _model_directory_has_files(path: str) -> bool:
|
||||||
"""Return True when the provided directory exists and contains entries."""
|
"""Return True when the provided directory exists and contains entries."""
|
||||||
|
|
||||||
@@ -103,6 +115,36 @@ def _model_directory_has_files(path: str) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def _build_example_folder_index(output_dir: str) -> dict[str, bool]:
|
||||||
|
"""Build a ``{hash: has_files}`` index for a library's example-image folders.
|
||||||
|
|
||||||
|
A single directory scan over the library root replaces ``O(candidates)``
|
||||||
|
per-folder ``os.scandir`` calls, which is required for libraries with
|
||||||
|
100k+ models. Each hash folder is classified by whether it contains any
|
||||||
|
entries, matching the semantics of ``_model_directory_has_files``.
|
||||||
|
"""
|
||||||
|
|
||||||
|
index: dict[str, bool] = {}
|
||||||
|
if not output_dir or not os.path.isdir(output_dir):
|
||||||
|
return index
|
||||||
|
|
||||||
|
try:
|
||||||
|
with os.scandir(output_dir) as entries:
|
||||||
|
for entry in entries:
|
||||||
|
name = entry.name
|
||||||
|
if not entry.is_dir() or not is_hash_folder(name):
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
with os.scandir(entry.path) as subentries:
|
||||||
|
index[name.lower()] = any(subentries)
|
||||||
|
except OSError:
|
||||||
|
index[name.lower()] = False
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return index
|
||||||
|
|
||||||
|
|
||||||
class DownloadManager:
|
class DownloadManager:
|
||||||
"""Manages downloading example images for models."""
|
"""Manages downloading example images for models."""
|
||||||
|
|
||||||
@@ -130,6 +172,7 @@ class DownloadManager:
|
|||||||
model_types = data.get("model_types", ["lora", "checkpoint"])
|
model_types = data.get("model_types", ["lora", "checkpoint"])
|
||||||
delay = float(data.get("delay", 0.2))
|
delay = float(data.get("delay", 0.2))
|
||||||
force = data.get("force", False)
|
force = data.get("force", False)
|
||||||
|
model_hashes = data.get("model_hashes", [])
|
||||||
|
|
||||||
# Step 2: Validate configuration (fast lookup)
|
# Step 2: Validate configuration (fast lookup)
|
||||||
settings_manager = get_settings_manager()
|
settings_manager = get_settings_manager()
|
||||||
@@ -199,6 +242,7 @@ class DownloadManager:
|
|||||||
delay,
|
delay,
|
||||||
active_library,
|
active_library,
|
||||||
force,
|
force,
|
||||||
|
model_hashes,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -410,14 +454,49 @@ class DownloadManager:
|
|||||||
# Calculate pending count: check which models actually need processing.
|
# Calculate pending count: check which models actually need processing.
|
||||||
# A model is pending if it has a hash, is not already processed or known-failed,
|
# A model is pending if it has a hash, is not already processed or known-failed,
|
||||||
# and its folder doesn't exist or is empty.
|
# and its folder doesn't exist or is empty.
|
||||||
pending_hashes = set()
|
candidate_hashes = [
|
||||||
for model_hash, model_name in all_models_with_hash:
|
model_hash
|
||||||
if model_hash not in processed_models and model_hash not in failed_models:
|
for model_hash, _ in all_models_with_hash
|
||||||
|
if model_hash not in processed_models
|
||||||
|
and model_hash not in failed_models
|
||||||
|
]
|
||||||
|
|
||||||
|
pending_hashes: set[str] = set()
|
||||||
|
# For small candidate counts the existing per-folder check is fine
|
||||||
|
# and handles legacy folder migration.
|
||||||
|
# For large libraries, scan the library root once and do set lookups.
|
||||||
|
if len(candidate_hashes) <= _BULK_LOOKUP_THRESHOLD or not output_dir:
|
||||||
|
for model_hash in candidate_hashes:
|
||||||
model_dir = ExampleImagePathResolver.get_model_folder(
|
model_dir = ExampleImagePathResolver.get_model_folder(
|
||||||
model_hash, active_library
|
model_hash, active_library
|
||||||
)
|
)
|
||||||
if not _model_directory_has_files(model_dir):
|
if not _model_directory_has_files(model_dir):
|
||||||
pending_hashes.add(model_hash)
|
pending_hashes.add(model_hash)
|
||||||
|
else:
|
||||||
|
folder_index = await asyncio.get_event_loop().run_in_executor(
|
||||||
|
None, _build_example_folder_index, output_dir
|
||||||
|
)
|
||||||
|
# In multi-library mode, folders that have not been consolidated
|
||||||
|
# into the library root yet (startup migration skipped, failed
|
||||||
|
# move, or created at the legacy path afterwards) still live at
|
||||||
|
# the legacy root/<hash> location. Only scan that root when at
|
||||||
|
# least one candidate is missing from the library-root index, so
|
||||||
|
# the fully-consolidated case does not pay an extra directory
|
||||||
|
# pass on every call.
|
||||||
|
if uses_library_scoped_folders() and any(
|
||||||
|
not folder_index.get(model_hash, False)
|
||||||
|
for model_hash in candidate_hashes
|
||||||
|
):
|
||||||
|
legacy_root = get_example_images_root()
|
||||||
|
if legacy_root and legacy_root != output_dir:
|
||||||
|
legacy_index = await asyncio.get_event_loop().run_in_executor(
|
||||||
|
None, _build_example_folder_index, legacy_root
|
||||||
|
)
|
||||||
|
for hash_key, has_files in legacy_index.items():
|
||||||
|
folder_index.setdefault(hash_key, has_files)
|
||||||
|
for model_hash in candidate_hashes:
|
||||||
|
if not folder_index.get(model_hash, False):
|
||||||
|
pending_hashes.add(model_hash)
|
||||||
|
|
||||||
pending_count = len(pending_hashes)
|
pending_count = len(pending_hashes)
|
||||||
|
|
||||||
@@ -500,8 +579,9 @@ class DownloadManager:
|
|||||||
delay,
|
delay,
|
||||||
library_name,
|
library_name,
|
||||||
force: bool = False,
|
force: bool = False,
|
||||||
|
model_hashes: list[str] | None = None,
|
||||||
):
|
):
|
||||||
"""Download example images for all models."""
|
"""Download example images for all models (or only the given hashes)."""
|
||||||
|
|
||||||
downloader = await get_downloader()
|
downloader = await get_downloader()
|
||||||
|
|
||||||
@@ -529,6 +609,18 @@ class DownloadManager:
|
|||||||
if model.get("sha256"):
|
if model.get("sha256"):
|
||||||
all_models.append((scanner_type, model, scanner))
|
all_models.append((scanner_type, model, scanner))
|
||||||
|
|
||||||
|
# Restrict to the requested hashes when provided (empty = all models).
|
||||||
|
# Explicit targets are a directed user request, so previously failed
|
||||||
|
# models are retried instead of skipped.
|
||||||
|
explicit_targets = bool(model_hashes)
|
||||||
|
if model_hashes:
|
||||||
|
hash_set = {h.lower() for h in model_hashes}
|
||||||
|
all_models = [
|
||||||
|
(scanner_type, model, scanner)
|
||||||
|
for scanner_type, model, scanner in all_models
|
||||||
|
if model.get("sha256", "").lower() in hash_set
|
||||||
|
]
|
||||||
|
|
||||||
# Update total count
|
# Update total count
|
||||||
self._progress["total"] = len(all_models)
|
self._progress["total"] = len(all_models)
|
||||||
logger.debug(f"Found {self._progress['total']} models to process")
|
logger.debug(f"Found {self._progress['total']} models to process")
|
||||||
@@ -552,6 +644,7 @@ class DownloadManager:
|
|||||||
downloader,
|
downloader,
|
||||||
library_name,
|
library_name,
|
||||||
force,
|
force,
|
||||||
|
explicit_targets,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Update progress
|
# Update progress
|
||||||
@@ -648,6 +741,7 @@ class DownloadManager:
|
|||||||
downloader,
|
downloader,
|
||||||
library_name,
|
library_name,
|
||||||
force: bool = False,
|
force: bool = False,
|
||||||
|
explicit_targets: bool = False,
|
||||||
):
|
):
|
||||||
"""Process a single model download."""
|
"""Process a single model download."""
|
||||||
|
|
||||||
@@ -670,8 +764,9 @@ class DownloadManager:
|
|||||||
self._progress["current_model"] = f"{model_name} ({model_hash[:8]})"
|
self._progress["current_model"] = f"{model_name} ({model_hash[:8]})"
|
||||||
await self._broadcast_progress(status="running")
|
await self._broadcast_progress(status="running")
|
||||||
|
|
||||||
# Skip if already in failed models (unless force mode is enabled)
|
# Skip if already in failed models (unless force mode is enabled or
|
||||||
if not force and model_hash in self._progress["failed_models"]:
|
# the model was explicitly targeted by hash)
|
||||||
|
if not force and not explicit_targets and model_hash in self._progress["failed_models"]:
|
||||||
logger.debug(f"Skipping known failed model: {model_name}")
|
logger.debug(f"Skipping known failed model: {model_name}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -680,6 +775,10 @@ class DownloadManager:
|
|||||||
)
|
)
|
||||||
existing_files = _model_directory_has_files(model_dir)
|
existing_files = _model_directory_has_files(model_dir)
|
||||||
|
|
||||||
|
# Model-level guard: a populated folder counts as done. Explicitly
|
||||||
|
# targeted models bypass it so the per-image existence pre-check can
|
||||||
|
# fill individual gaps without re-fetching existing files.
|
||||||
|
if not explicit_targets:
|
||||||
# Skip if already processed AND directory exists with files
|
# Skip if already processed AND directory exists with files
|
||||||
if model_hash in self._progress["processed_models"]:
|
if model_hash in self._progress["processed_models"]:
|
||||||
if existing_files:
|
if existing_files:
|
||||||
@@ -807,7 +906,7 @@ class DownloadManager:
|
|||||||
model_name,
|
model_name,
|
||||||
)
|
)
|
||||||
# Clear failed_models so non-force runs can retry
|
# Clear failed_models so non-force runs can retry
|
||||||
if force and model_hash in self._progress["failed_models"]:
|
if (force or explicit_targets) and model_hash in self._progress["failed_models"]:
|
||||||
self._progress["failed_models"].discard(model_hash)
|
self._progress["failed_models"].discard(model_hash)
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Removed {model_name} from failed_models after force retry with rate-limited images"
|
f"Removed {model_name} from failed_models after force retry with rate-limited images"
|
||||||
@@ -827,7 +926,7 @@ class DownloadManager:
|
|||||||
)
|
)
|
||||||
elif success:
|
elif success:
|
||||||
self._progress["processed_models"].add(model_hash)
|
self._progress["processed_models"].add(model_hash)
|
||||||
if force and model_hash in self._progress["failed_models"]:
|
if (force or explicit_targets) and model_hash in self._progress["failed_models"]:
|
||||||
self._progress["failed_models"].discard(model_hash)
|
self._progress["failed_models"].discard(model_hash)
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Removed {model_name} from failed_models after successful force retry"
|
f"Removed {model_name} from failed_models after successful force retry"
|
||||||
@@ -1343,8 +1442,8 @@ class DownloadManager:
|
|||||||
await MetadataManager.save_metadata(file_path, model_copy)
|
await MetadataManager.save_metadata(file_path, model_copy)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await scanner.update_single_model_cache(
|
await update_cache_from_metadata(
|
||||||
file_path, file_path, model_data
|
scanner, file_path, model_copy
|
||||||
)
|
)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@@ -28,6 +29,31 @@ if TYPE_CHECKING: # pragma: no cover - import for type checkers only
|
|||||||
from ..services.settings_manager import SettingsManager
|
from ..services.settings_manager import SettingsManager
|
||||||
|
|
||||||
|
|
||||||
|
async def update_cache_from_metadata(
|
||||||
|
scanner: Any, file_path: str, metadata: Dict[str, Any]
|
||||||
|
) -> bool:
|
||||||
|
"""Update the scanner cache from a metadata dict using the in-place sync path.
|
||||||
|
|
||||||
|
``sync_cache_from_metadata`` patches the existing cache entry incrementally
|
||||||
|
(tag/hash/version indexes, targeted single-row SQL update) and only resorts
|
||||||
|
when a sort-key field changed. This avoids the ``O(n)`` full-list resort and
|
||||||
|
full cache rewrite that ``update_single_model_cache`` performs on every call,
|
||||||
|
which is critical for libraries with 100k+ models.
|
||||||
|
|
||||||
|
Falls back to the legacy full update when the scanner does not expose an
|
||||||
|
async ``sync_cache_from_metadata`` method.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
``True`` if the cache entry was updated, ``False`` otherwise.
|
||||||
|
"""
|
||||||
|
|
||||||
|
sync_method = getattr(scanner, "sync_cache_from_metadata", None)
|
||||||
|
if inspect.iscoroutinefunction(sync_method):
|
||||||
|
return await sync_method(file_path, metadata)
|
||||||
|
|
||||||
|
return await scanner.update_single_model_cache(file_path, file_path, metadata)
|
||||||
|
|
||||||
|
|
||||||
def _build_metadata_sync_service(settings_manager: "SettingsManager") -> MetadataSyncService:
|
def _build_metadata_sync_service(settings_manager: "SettingsManager") -> MetadataSyncService:
|
||||||
"""Construct a metadata sync service bound to the provided settings."""
|
"""Construct a metadata sync service bound to the provided settings."""
|
||||||
|
|
||||||
@@ -103,7 +129,7 @@ class MetadataUpdater:
|
|||||||
progress['refreshed_models'].add(model_hash)
|
progress['refreshed_models'].add(model_hash)
|
||||||
|
|
||||||
async def update_cache_func(old_path, new_path, metadata):
|
async def update_cache_func(old_path, new_path, metadata):
|
||||||
return await scanner.update_single_model_cache(old_path, new_path, metadata)
|
return await update_cache_from_metadata(scanner, new_path, metadata)
|
||||||
|
|
||||||
await MetadataManager.hydrate_model_data(model_data)
|
await MetadataManager.hydrate_model_data(model_data)
|
||||||
success, error = await _get_metadata_sync_service().fetch_and_update_model(
|
success, error = await _get_metadata_sync_service().fetch_and_update_model(
|
||||||
@@ -234,6 +260,7 @@ class MetadataUpdater:
|
|||||||
|
|
||||||
# Save metadata to .metadata.json file
|
# Save metadata to .metadata.json file
|
||||||
file_path = model.get('file_path')
|
file_path = model.get('file_path')
|
||||||
|
model_copy: Optional[Dict[str, Any]] = None
|
||||||
try:
|
try:
|
||||||
model_copy = model.copy()
|
model_copy = model.copy()
|
||||||
model_copy.pop('folder', None)
|
model_copy.pop('folder', None)
|
||||||
@@ -242,13 +269,17 @@ class MetadataUpdater:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to save metadata for {model.get('model_name')}: {str(e)}")
|
logger.error(f"Failed to save metadata for {model.get('model_name')}: {str(e)}")
|
||||||
|
|
||||||
# Save updated metadata to scanner cache
|
# Save updated metadata to scanner cache. sync_cache_from_metadata
|
||||||
success = await scanner.update_single_model_cache(file_path, file_path, model)
|
# returns False both for "already in sync" and for actual failures,
|
||||||
if success:
|
# so the cache sync result is deliberately not treated as an error;
|
||||||
|
# the return value reflects whether the metadata was persisted.
|
||||||
|
if file_path and model_copy is not None:
|
||||||
|
await update_cache_from_metadata(scanner, file_path, model_copy)
|
||||||
logger.info(f"Successfully updated metadata for {model.get('model_name')} with {len(images)} local examples")
|
logger.info(f"Successfully updated metadata for {model.get('model_name')} with {len(images)} local examples")
|
||||||
return True
|
return True
|
||||||
else:
|
|
||||||
logger.warning(f"Failed to update metadata for {model.get('model_name')}")
|
logger.warning(f"Failed to update metadata for {model.get('model_name')}")
|
||||||
|
return False
|
||||||
|
|
||||||
return False
|
return False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -336,6 +367,7 @@ class MetadataUpdater:
|
|||||||
|
|
||||||
# Save metadata to .metadata.json file
|
# Save metadata to .metadata.json file
|
||||||
file_path = model_data.get('file_path')
|
file_path = model_data.get('file_path')
|
||||||
|
model_copy: Optional[Dict[str, Any]] = None
|
||||||
if file_path:
|
if file_path:
|
||||||
try:
|
try:
|
||||||
model_copy = model_data.copy()
|
model_copy = model_data.copy()
|
||||||
@@ -346,8 +378,8 @@ class MetadataUpdater:
|
|||||||
logger.error(f"Failed to save metadata: {str(e)}")
|
logger.error(f"Failed to save metadata: {str(e)}")
|
||||||
|
|
||||||
# Save updated metadata to scanner cache
|
# Save updated metadata to scanner cache
|
||||||
if file_path:
|
if file_path and model_copy is not None:
|
||||||
await scanner.update_single_model_cache(file_path, file_path, model_data)
|
await update_cache_from_metadata(scanner, file_path, model_copy)
|
||||||
|
|
||||||
# Get regular images array (might be None)
|
# Get regular images array (might be None)
|
||||||
regular_images = civitai_data.get('images', [])
|
regular_images = civitai_data.get('images', [])
|
||||||
@@ -475,13 +507,19 @@ class MetadataUpdater:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
model_folder = get_model_folder(model_hash)
|
model_folder = get_model_folder(model_hash)
|
||||||
if not model_folder:
|
if not model_folder or not os.path.isdir(model_folder):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
civitai = getattr(metadata, "civitai", None)
|
civitai = getattr(metadata, "civitai", None)
|
||||||
if not isinstance(civitai, dict):
|
if not isinstance(civitai, dict):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# Read the directory listing once so every image entry reuses it.
|
||||||
|
try:
|
||||||
|
dir_entries = os.listdir(model_folder)
|
||||||
|
except OSError:
|
||||||
|
dir_entries = []
|
||||||
|
|
||||||
has_changes = False
|
has_changes = False
|
||||||
|
|
||||||
custom_images = civitai.get("customImages")
|
custom_images = civitai.get("customImages")
|
||||||
@@ -493,22 +531,13 @@ class MetadataUpdater:
|
|||||||
if not img_id:
|
if not img_id:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not os.path.isdir(model_folder):
|
|
||||||
stale.append(idx)
|
|
||||||
else:
|
|
||||||
found = False
|
|
||||||
try:
|
|
||||||
prefix = f"custom_{img_id}"
|
prefix = f"custom_{img_id}"
|
||||||
for fname in os.listdir(model_folder):
|
found = any(
|
||||||
if fname.startswith(prefix) and os.path.isfile(
|
f.startswith(prefix) and os.path.isfile(
|
||||||
os.path.join(model_folder, fname)
|
os.path.join(model_folder, f)
|
||||||
):
|
)
|
||||||
found = True
|
for f in dir_entries
|
||||||
break
|
)
|
||||||
except OSError:
|
|
||||||
stale.append(idx)
|
|
||||||
continue
|
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
stale.append(idx)
|
stale.append(idx)
|
||||||
|
|
||||||
@@ -532,21 +561,8 @@ class MetadataUpdater:
|
|||||||
# is gone.
|
# is gone.
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not os.path.isdir(model_folder):
|
|
||||||
stale.append(idx)
|
|
||||||
else:
|
|
||||||
found = False
|
|
||||||
try:
|
|
||||||
prefix = f"image_{idx}."
|
prefix = f"image_{idx}."
|
||||||
for fname in os.listdir(model_folder):
|
if not any(f.startswith(prefix) for f in dir_entries):
|
||||||
if fname.startswith(prefix):
|
|
||||||
found = True
|
|
||||||
break
|
|
||||||
except OSError:
|
|
||||||
stale.append(idx)
|
|
||||||
continue
|
|
||||||
|
|
||||||
if not found:
|
|
||||||
stale.append(idx)
|
stale.append(idx)
|
||||||
|
|
||||||
if stale:
|
if stale:
|
||||||
|
|||||||
@@ -3,11 +3,19 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
|
import shutil
|
||||||
from ..services.settings_manager import get_settings_manager
|
from ..services.settings_manager import get_settings_manager
|
||||||
from ..services.service_registry import ServiceRegistry
|
from ..services.service_registry import ServiceRegistry
|
||||||
from ..utils.example_images_paths import iter_library_roots
|
from ..utils.example_images_paths import (
|
||||||
|
get_example_images_root,
|
||||||
|
is_hash_folder,
|
||||||
|
iter_library_roots,
|
||||||
|
uses_library_scoped_folders,
|
||||||
|
_library_folder_has_only_hash_dirs,
|
||||||
|
)
|
||||||
from ..utils.metadata_manager import MetadataManager
|
from ..utils.metadata_manager import MetadataManager
|
||||||
from ..utils.example_images_processor import ExampleImagesProcessor
|
from ..utils.example_images_processor import ExampleImagesProcessor
|
||||||
|
from ..utils.example_images_metadata import update_cache_from_metadata
|
||||||
from ..utils.constants import SUPPORTED_MEDIA_EXTENSIONS
|
from ..utils.constants import SUPPORTED_MEDIA_EXTENSIONS
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -36,6 +44,90 @@ settings = _SettingsProxy()
|
|||||||
class ExampleImagesMigration:
|
class ExampleImagesMigration:
|
||||||
"""Handles migrations for example images naming conventions"""
|
"""Handles migrations for example images naming conventions"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _consolidate_library_folders():
|
||||||
|
"""Move hash folders from library-named subdirectories back to root.
|
||||||
|
|
||||||
|
When a user switches from multi-library mode back to single-library
|
||||||
|
mode, example images previously stored under e.g.
|
||||||
|
``<root>/default/<hash>/`` need to be moved back to
|
||||||
|
``<root>/<hash>/``. Running this once at startup removes the need
|
||||||
|
for ``get_model_folder()`` to perform directory scans on every
|
||||||
|
request.
|
||||||
|
"""
|
||||||
|
if uses_library_scoped_folders():
|
||||||
|
return
|
||||||
|
|
||||||
|
root = get_example_images_root()
|
||||||
|
if not root or not os.path.isdir(root):
|
||||||
|
return
|
||||||
|
|
||||||
|
moved: list[str] = []
|
||||||
|
cleaned: list[str] = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
for entry in os.listdir(root):
|
||||||
|
# Fast regex checks first — no filesystem I/O.
|
||||||
|
if is_hash_folder(entry) or entry == "_deleted":
|
||||||
|
continue
|
||||||
|
|
||||||
|
entry_path = os.path.join(root, entry)
|
||||||
|
if not os.path.isdir(entry_path):
|
||||||
|
continue
|
||||||
|
if not _library_folder_has_only_hash_dirs(entry_path):
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
for hash_entry in os.listdir(entry_path):
|
||||||
|
hash_path = os.path.join(entry_path, hash_entry)
|
||||||
|
if not os.path.isdir(hash_path) or not is_hash_folder(hash_entry):
|
||||||
|
continue
|
||||||
|
target = os.path.join(root, hash_entry)
|
||||||
|
if not os.path.exists(target):
|
||||||
|
try:
|
||||||
|
shutil.move(hash_path, target)
|
||||||
|
moved.append(hash_entry)
|
||||||
|
except (OSError, shutil.Error) as exc:
|
||||||
|
logger.error(
|
||||||
|
"Failed to move '%s' → '%s': %s",
|
||||||
|
hash_path, target, exc,
|
||||||
|
)
|
||||||
|
except OSError as exc:
|
||||||
|
logger.error(
|
||||||
|
"Failed to list library subdirectory '%s': %s",
|
||||||
|
entry_path, exc,
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
remaining = os.listdir(entry_path)
|
||||||
|
except OSError:
|
||||||
|
remaining = []
|
||||||
|
if not remaining:
|
||||||
|
try:
|
||||||
|
os.rmdir(entry_path)
|
||||||
|
cleaned.append(entry)
|
||||||
|
except OSError as exc:
|
||||||
|
logger.debug(
|
||||||
|
"Could not remove empty library dir '%s': %s",
|
||||||
|
entry_path, exc,
|
||||||
|
)
|
||||||
|
except OSError as exc:
|
||||||
|
logger.error(
|
||||||
|
"Failed to list example images root during consolidation: %s",
|
||||||
|
exc,
|
||||||
|
)
|
||||||
|
|
||||||
|
if moved:
|
||||||
|
logger.info(
|
||||||
|
"Consolidated %d example image folder(s) to root",
|
||||||
|
len(moved),
|
||||||
|
)
|
||||||
|
if cleaned:
|
||||||
|
logger.info(
|
||||||
|
"Removed %d empty library directories",
|
||||||
|
len(cleaned),
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def check_and_run_migrations():
|
async def check_and_run_migrations():
|
||||||
"""Check if migrations are needed and run them in background"""
|
"""Check if migrations are needed and run them in background"""
|
||||||
@@ -44,6 +136,10 @@ class ExampleImagesMigration:
|
|||||||
logger.debug("No example images path configured or path doesn't exist, skipping migrations")
|
logger.debug("No example images path configured or path doesn't exist, skipping migrations")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Run library-to-root consolidation once at startup so the hot
|
||||||
|
# path (get_model_folder) stays a pure-path computation.
|
||||||
|
ExampleImagesMigration._consolidate_library_folders()
|
||||||
|
|
||||||
for library_name, library_path in iter_library_roots():
|
for library_name, library_path in iter_library_roots():
|
||||||
if not library_path or not os.path.exists(library_path):
|
if not library_path or not os.path.exists(library_path):
|
||||||
continue
|
continue
|
||||||
@@ -326,7 +422,7 @@ class ExampleImagesMigration:
|
|||||||
await MetadataManager.save_metadata(file_path, model_copy)
|
await MetadataManager.save_metadata(file_path, model_copy)
|
||||||
|
|
||||||
# Update scanner cache
|
# Update scanner cache
|
||||||
await scanner.update_single_model_cache(file_path, file_path, model_metadata)
|
await update_cache_from_metadata(scanner, file_path, model_copy)
|
||||||
|
|
||||||
updated_models += 1
|
updated_models += 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -83,7 +83,12 @@ def ensure_library_root_exists(library_name: Optional[str] = None) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def get_model_folder(model_hash: str, library_name: Optional[str] = None) -> str:
|
def get_model_folder(model_hash: str, library_name: Optional[str] = None) -> str:
|
||||||
"""Return the folder path for a model's example images."""
|
"""Return the folder path for a model's example images.
|
||||||
|
|
||||||
|
Multi-library ↔ single-library consolidation is handled once at startup by
|
||||||
|
``ExampleImagesMigration._consolidate_library_folders`` — this function is a
|
||||||
|
pure path computation on the hot path (no directory scans).
|
||||||
|
"""
|
||||||
|
|
||||||
if not model_hash:
|
if not model_hash:
|
||||||
return ""
|
return ""
|
||||||
@@ -113,35 +118,6 @@ def get_model_folder(model_hash: str, library_name: Optional[str] = None) -> str
|
|||||||
exc,
|
exc,
|
||||||
)
|
)
|
||||||
return legacy_folder
|
return legacy_folder
|
||||||
elif not os.path.exists(resolved_folder):
|
|
||||||
# Reverse migration: when consolidating from multi-library to
|
|
||||||
# single-library mode (e.g. after "default" was cleaned up), look
|
|
||||||
# for existing example images inside library-named subdirectories
|
|
||||||
# and bring them back to the root level.
|
|
||||||
root = get_example_images_root()
|
|
||||||
if root:
|
|
||||||
try:
|
|
||||||
for entry in os.listdir(root):
|
|
||||||
entry_path = os.path.join(root, entry)
|
|
||||||
if not os.path.isdir(entry_path):
|
|
||||||
continue
|
|
||||||
if is_hash_folder(entry) or entry == "_deleted":
|
|
||||||
continue
|
|
||||||
if not _library_folder_has_only_hash_dirs(entry_path):
|
|
||||||
continue
|
|
||||||
legacy = os.path.join(entry_path, normalized_hash)
|
|
||||||
if os.path.exists(legacy):
|
|
||||||
shutil.move(legacy, resolved_folder)
|
|
||||||
logger.info(
|
|
||||||
"Consolidated example images from '%s' to '%s'",
|
|
||||||
legacy, resolved_folder,
|
|
||||||
)
|
|
||||||
break
|
|
||||||
except OSError as exc:
|
|
||||||
logger.error(
|
|
||||||
"Failed to consolidate example images during "
|
|
||||||
"library merge: %s", exc,
|
|
||||||
)
|
|
||||||
|
|
||||||
return resolved_folder
|
return resolved_folder
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from ..utils.constants import SUPPORTED_MEDIA_EXTENSIONS
|
|||||||
from ..services.service_registry import ServiceRegistry
|
from ..services.service_registry import ServiceRegistry
|
||||||
from ..services.settings_manager import get_settings_manager
|
from ..services.settings_manager import get_settings_manager
|
||||||
from ..utils.example_images_paths import get_model_folder, get_model_relative_path
|
from ..utils.example_images_paths import get_model_folder, get_model_relative_path
|
||||||
from .example_images_metadata import MetadataUpdater
|
from .example_images_metadata import MetadataUpdater, update_cache_from_metadata
|
||||||
from ..utils.metadata_manager import MetadataManager
|
from ..utils.metadata_manager import MetadataManager
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -113,6 +113,26 @@ class ExampleImagesProcessor:
|
|||||||
message = str(error).lower()
|
message = str(error).lower()
|
||||||
return '404' in message or 'file not found' in message
|
return '404' in message or 'file not found' in message
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _example_image_file_exists(model_dir: str, index: int, media_type_hint: str | None = None) -> bool:
|
||||||
|
"""Return True when the file that would be written for a media index already exists.
|
||||||
|
|
||||||
|
The final filename (``image_{index}{extension}``) depends on the downloaded
|
||||||
|
content, so the extension cannot be known ahead of time. The post-download
|
||||||
|
check skips the write when the exact target file exists; this pre-check
|
||||||
|
approximates that with the candidate extensions for the media type (videos
|
||||||
|
only when the metadata hints at a video) so the network request is avoided
|
||||||
|
for files that already exist on disk.
|
||||||
|
"""
|
||||||
|
if media_type_hint == "video":
|
||||||
|
extensions = SUPPORTED_MEDIA_EXTENSIONS['videos']
|
||||||
|
else:
|
||||||
|
extensions = SUPPORTED_MEDIA_EXTENSIONS['images']
|
||||||
|
return any(
|
||||||
|
os.path.exists(os.path.join(model_dir, f"image_{index}{ext}"))
|
||||||
|
for ext in extensions
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def download_model_images(model_hash, model_name, model_images, model_dir, optimize, downloader):
|
async def download_model_images(model_hash, model_name, model_images, model_dir, optimize, downloader):
|
||||||
"""Download images for a single model
|
"""Download images for a single model
|
||||||
@@ -140,6 +160,11 @@ class ExampleImagesProcessor:
|
|||||||
if optimize and 'civitai.com' in image_url:
|
if optimize and 'civitai.com' in image_url:
|
||||||
image_url = ExampleImagesProcessor.get_civitai_optimized_url(image_url)
|
image_url = ExampleImagesProcessor.get_civitai_optimized_url(image_url)
|
||||||
|
|
||||||
|
# Skip the download when the file already exists on disk
|
||||||
|
if ExampleImagesProcessor._example_image_file_exists(model_dir, i, image.get("type")):
|
||||||
|
logger.debug("File already exists, skipping download for %s", image_url)
|
||||||
|
continue
|
||||||
|
|
||||||
# Download the file first to determine the actual file type
|
# Download the file first to determine the actual file type
|
||||||
try:
|
try:
|
||||||
logger.debug(f"Downloading media file {i} for {model_name}")
|
logger.debug(f"Downloading media file {i} for {model_name}")
|
||||||
@@ -229,6 +254,11 @@ class ExampleImagesProcessor:
|
|||||||
if optimize and 'civitai.com' in image_url:
|
if optimize and 'civitai.com' in image_url:
|
||||||
image_url = ExampleImagesProcessor.get_civitai_optimized_url(image_url)
|
image_url = ExampleImagesProcessor.get_civitai_optimized_url(image_url)
|
||||||
|
|
||||||
|
# Skip the download when the file already exists on disk
|
||||||
|
if ExampleImagesProcessor._example_image_file_exists(model_dir, i, image.get("type")):
|
||||||
|
logger.debug("File already exists, skipping download for %s", image_url)
|
||||||
|
continue
|
||||||
|
|
||||||
async def _attempt_download() -> tuple:
|
async def _attempt_download() -> tuple:
|
||||||
logger.debug("Downloading media file %s for %s", i, model_name)
|
logger.debug("Downloading media file %s for %s", i, model_name)
|
||||||
return await downloader.download_to_memory(
|
return await downloader.download_to_memory(
|
||||||
@@ -644,7 +674,7 @@ class ExampleImagesProcessor:
|
|||||||
}, status=500)
|
}, status=500)
|
||||||
|
|
||||||
# Update cache
|
# Update cache
|
||||||
await scanner.update_single_model_cache(file_path, file_path, model_data)
|
await update_cache_from_metadata(scanner, file_path, model_data)
|
||||||
|
|
||||||
# Get regular images array (might be None)
|
# Get regular images array (might be None)
|
||||||
regular_images = civitai_data.get('images', [])
|
regular_images = civitai_data.get('images', [])
|
||||||
@@ -759,7 +789,7 @@ class ExampleImagesProcessor:
|
|||||||
model_copy = model_data.copy()
|
model_copy = model_data.copy()
|
||||||
model_copy.pop('folder', None)
|
model_copy.pop('folder', None)
|
||||||
await MetadataManager.save_metadata(file_path, model_copy)
|
await MetadataManager.save_metadata(file_path, model_copy)
|
||||||
await scanner.update_single_model_cache(file_path, file_path, model_data)
|
await update_cache_from_metadata(scanner, file_path, model_copy)
|
||||||
|
|
||||||
return web.json_response({
|
return web.json_response({
|
||||||
'success': True,
|
'success': True,
|
||||||
|
|||||||
+37
-1
@@ -1,9 +1,10 @@
|
|||||||
|
import functools
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional, Tuple
|
||||||
|
|
||||||
import piexif
|
import piexif
|
||||||
from PIL import Image, PngImagePlugin
|
from PIL import Image, PngImagePlugin
|
||||||
@@ -17,6 +18,22 @@ except ImportError:
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@functools.lru_cache(maxsize=2048)
|
||||||
|
def _get_image_dimensions_cached(path: str, _mtime_ns: int, _size: int) -> Optional[Tuple[int, int]]:
|
||||||
|
"""Return ``(width, height)`` for ``path``, or ``None`` on any failure.
|
||||||
|
|
||||||
|
The ``_mtime_ns`` and ``_size`` arguments are part of the cache key only;
|
||||||
|
they invalidate the entry when the file is replaced with a new image, so a
|
||||||
|
stale preview never serves outdated dimensions.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
with Image.open(path) as img:
|
||||||
|
return img.size
|
||||||
|
except Exception:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class ExifUtils:
|
class ExifUtils:
|
||||||
"""Utility functions for working with EXIF data in images"""
|
"""Utility functions for working with EXIF data in images"""
|
||||||
|
|
||||||
@@ -422,6 +439,25 @@ class ExifUtils:
|
|||||||
# Metadata is in the middle of the string
|
# Metadata is in the middle of the string
|
||||||
return user_comment[:recipe_marker_index] + user_comment[next_line_index:]
|
return user_comment[:recipe_marker_index] + user_comment[next_line_index:]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_image_dimensions(image_path: str) -> Optional[Tuple[int, int]]:
|
||||||
|
"""Return ``(width, height)`` for an image, or ``None`` if unavailable.
|
||||||
|
|
||||||
|
Video containers (``.mp4``/``.webm``/``.avi``) and formats PIL cannot
|
||||||
|
read (``.avif``/``.jxl``) return ``None`` before PIL is invoked.
|
||||||
|
Missing or corrupt files return ``None``. Never raises.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
ext = os.path.splitext(image_path)[1].lower()
|
||||||
|
if ext in ('.mp4', '.webm', '.avi', '.avif', '.jxl'):
|
||||||
|
return None
|
||||||
|
stat = os.stat(image_path)
|
||||||
|
return _get_image_dimensions_cached(
|
||||||
|
image_path, stat.st_mtime_ns, stat.st_size
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def optimize_image(image_data, target_width=250, format='webp', quality=85, preserve_metadata=False):
|
def optimize_image(image_data, target_width=250, format='webp', quality=85, preserve_metadata=False):
|
||||||
"""
|
"""
|
||||||
|
|||||||
+54
-1
@@ -1,7 +1,7 @@
|
|||||||
from difflib import SequenceMatcher
|
from difflib import SequenceMatcher
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from typing import Dict
|
from typing import Any, Dict, List, Optional
|
||||||
from ..services.service_registry import ServiceRegistry
|
from ..services.service_registry import ServiceRegistry
|
||||||
from ..config import config
|
from ..config import config
|
||||||
from ..services.settings_manager import get_settings_manager
|
from ..services.settings_manager import get_settings_manager
|
||||||
@@ -294,6 +294,53 @@ def _format_model_name_for_comfyui(file_path: str, model_roots: list) -> str:
|
|||||||
return os.path.basename(file_path)
|
return os.path.basename(file_path)
|
||||||
|
|
||||||
|
|
||||||
|
def model_patcher_to_name(model_patcher: Any) -> Optional[str]:
|
||||||
|
"""Extract a ComfyUI-style model name from a MODEL (ModelPatcher) object.
|
||||||
|
|
||||||
|
Core ComfyUI loaders record the absolute weight file path on the patcher's
|
||||||
|
``cached_patcher_init`` attribute:
|
||||||
|
- load_checkpoint_guess_config -> (fn, (ckpt_path, ...), index)
|
||||||
|
- load_diffusion_model -> (fn, (unet_path, model_options))
|
||||||
|
Patcher clones (LoRA loaders, model merges, ...) preserve the attribute,
|
||||||
|
so the name is recoverable anywhere downstream of a core loader — including
|
||||||
|
from LoRA Manager's own loaders (CheckpointLoaderLM / UNETLoaderLM), which
|
||||||
|
call the same core load functions.
|
||||||
|
|
||||||
|
The absolute path is converted to the ComfyUI-style relative name used by
|
||||||
|
the metadata pipeline (covering standard ComfyUI roots and LoRA Manager
|
||||||
|
extra folder paths).
|
||||||
|
|
||||||
|
Returns None when the path cannot be recovered (e.g. third-party loaders
|
||||||
|
that never set ``cached_patcher_init``).
|
||||||
|
"""
|
||||||
|
init = getattr(model_patcher, "cached_patcher_init", None)
|
||||||
|
if not isinstance(init, (tuple, list)) or len(init) < 2:
|
||||||
|
return None
|
||||||
|
args = init[1]
|
||||||
|
abs_path = args[0] if args else None
|
||||||
|
if not isinstance(abs_path, str) or not abs_path:
|
||||||
|
return None
|
||||||
|
return _abs_model_path_to_name(abs_path)
|
||||||
|
|
||||||
|
|
||||||
|
def _abs_model_path_to_name(abs_path: str) -> str:
|
||||||
|
"""Convert an absolute model path to a ComfyUI-style relative name.
|
||||||
|
|
||||||
|
Tries standard ComfyUI model roots plus LoRA Manager extra folder paths;
|
||||||
|
falls back to the bare filename.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
roots: List[str] = list(config.base_models_roots or [])
|
||||||
|
roots.extend(config.extra_checkpoints_roots or [])
|
||||||
|
roots.extend(config.extra_unet_roots or [])
|
||||||
|
formatted = _format_model_name_for_comfyui(abs_path, roots)
|
||||||
|
if formatted:
|
||||||
|
return formatted
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return os.path.basename(abs_path)
|
||||||
|
|
||||||
|
|
||||||
def fuzzy_match(text: str, pattern: str, threshold: float = 0.85) -> bool:
|
def fuzzy_match(text: str, pattern: str, threshold: float = 0.85) -> bool:
|
||||||
"""
|
"""
|
||||||
Check if text matches pattern using fuzzy matching.
|
Check if text matches pattern using fuzzy matching.
|
||||||
@@ -488,6 +535,12 @@ def calculate_relative_path_for_model(
|
|||||||
if model_type == "embedding":
|
if model_type == "embedding":
|
||||||
formatted_path = formatted_path.replace(" ", "_")
|
formatted_path = formatted_path.replace(" ", "_")
|
||||||
|
|
||||||
|
# Sanitize the resolved path to prevent path traversal
|
||||||
|
formatted_path = formatted_path.lstrip("/")
|
||||||
|
while "//" in formatted_path:
|
||||||
|
formatted_path = formatted_path.replace("//", "/")
|
||||||
|
formatted_path = formatted_path.rstrip("/")
|
||||||
|
|
||||||
return formatted_path
|
return formatted_path
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "comfyui-lora-manager"
|
name = "comfyui-lora-manager"
|
||||||
description = "Revolutionize your workflow with the ultimate LoRA companion for ComfyUI!"
|
description = "Revolutionize your workflow with the ultimate LoRA companion for ComfyUI!"
|
||||||
version = "1.1.8"
|
version = "1.2.0"
|
||||||
license = {file = "LICENSE"}
|
license = {file = "LICENSE"}
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aiohttp",
|
"aiohttp",
|
||||||
|
|||||||
@@ -31,6 +31,10 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.card-grid.masonry-layout .model-card {
|
||||||
|
aspect-ratio: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.model-card:hover {
|
.model-card:hover {
|
||||||
transform: translateY(-2px);
|
transform: translateY(-2px);
|
||||||
box-shadow: var(--shadow-md);
|
box-shadow: var(--shadow-md);
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/* Batch Download Summary Modal — component styles only.
|
||||||
|
Stat cards and failure table styles are shared with the metadata refresh
|
||||||
|
result modal (metadata-refresh-result.css) and are not redefined here. */
|
||||||
|
|
||||||
|
.download-batch-summary-modal {
|
||||||
|
max-width: 700px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--space-2);
|
||||||
|
margin: var(--space-2) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-header i {
|
||||||
|
font-size: 1.4em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-header.success i {
|
||||||
|
color: var(--color-success);
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-header.warning i {
|
||||||
|
color: var(--color-warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-header.error i {
|
||||||
|
color: var(--color-error);
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-title {
|
||||||
|
font-weight: var(--weight-semibold);
|
||||||
|
color: var(--lora-text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-hint {
|
||||||
|
margin-left: auto;
|
||||||
|
font-size: var(--text-xs);
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-retry {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--space-1);
|
||||||
|
background: var(--lora-accent, #4f46e5);
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
padding: var(--space-2) var(--space-3);
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: var(--weight-semibold);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-retry:hover {
|
||||||
|
background: var(--lora-accent-hover, #4338ca);
|
||||||
|
}
|
||||||
|
|
||||||
|
.failure-link {
|
||||||
|
color: var(--lora-accent, #4f46e5);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.failure-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
@@ -1,4 +1,35 @@
|
|||||||
/* Import Modal Styles */
|
/* Import Modal Styles */
|
||||||
|
|
||||||
|
/* Sticky footer layout: fixed header, scrollable step content, pinned action buttons.
|
||||||
|
Ensures Back/Import buttons stay visible on short viewports (e.g. 1080p or 150% zoom). */
|
||||||
|
#importModal .modal-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden; /* The active step scrolls instead of the whole modal */
|
||||||
|
}
|
||||||
|
|
||||||
|
#importModal .modal-header {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#importModal .import-step {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-height: 0; /* Allow the step to shrink and scroll within the flex container */
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
scrollbar-gutter: stable;
|
||||||
|
}
|
||||||
|
|
||||||
|
#importModal .import-step .modal-actions {
|
||||||
|
position: sticky;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 1;
|
||||||
|
background: var(--lora-surface);
|
||||||
|
border-top: 1px solid var(--lora-border);
|
||||||
|
padding-top: var(--space-2);
|
||||||
|
padding-bottom: var(--space-1);
|
||||||
|
}
|
||||||
|
|
||||||
.import-step {
|
.import-step {
|
||||||
margin: var(--space-2) 0;
|
margin: var(--space-2) 0;
|
||||||
transition: none !important;
|
transition: none !important;
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ body.modal-open {
|
|||||||
.support-section,
|
.support-section,
|
||||||
.changelog-section,
|
.changelog-section,
|
||||||
.update-info,
|
.update-info,
|
||||||
|
.update-channels,
|
||||||
.info-item,
|
.info-item,
|
||||||
.path-preview {
|
.path-preview {
|
||||||
background: var(--surface-subtle);
|
background: var(--surface-subtle);
|
||||||
|
|||||||
@@ -93,15 +93,13 @@
|
|||||||
.update-content {
|
.update-content {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: var(--space-3);
|
gap: var(--space-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.update-info {
|
.update-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border-radius: var(--border-radius-sm);
|
|
||||||
padding: var(--space-3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.update-info .version-info {
|
.update-info .version-info {
|
||||||
@@ -175,7 +173,6 @@
|
|||||||
border: 1px solid var(--lora-border);
|
border: 1px solid var(--lora-border);
|
||||||
border-radius: var(--border-radius-sm);
|
border-radius: var(--border-radius-sm);
|
||||||
padding: var(--space-2);
|
padding: var(--space-2);
|
||||||
margin: var(--space-2) 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-theme="dark"] .update-progress {
|
[data-theme="dark"] .update-progress {
|
||||||
@@ -233,11 +230,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Changelog section */
|
/* Changelog section */
|
||||||
.changelog-section {
|
|
||||||
border-radius: var(--border-radius-sm);
|
|
||||||
padding: var(--space-3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.changelog-section h3 {
|
.changelog-section h3 {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
margin-bottom: var(--space-2);
|
margin-bottom: var(--space-2);
|
||||||
@@ -349,6 +341,131 @@
|
|||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Channel Toggle */
|
||||||
|
.update-channels {
|
||||||
|
}
|
||||||
|
|
||||||
|
.channels-label {
|
||||||
|
font-size: 0.9em;
|
||||||
|
color: var(--text-color);
|
||||||
|
opacity: 0.8;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-toggle {
|
||||||
|
display: flex;
|
||||||
|
gap: 0;
|
||||||
|
background: var(--lora-surface);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 3px;
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 8px 20px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--text-secondary, #999);
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.9em;
|
||||||
|
font-weight: 500;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-btn:hover {
|
||||||
|
color: var(--text-primary, #ddd);
|
||||||
|
background: rgba(255, 255, 255, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-btn.active {
|
||||||
|
background: var(--lora-accent, #4285F4);
|
||||||
|
color: #fff;
|
||||||
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-btn.active i {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-btn i {
|
||||||
|
font-size: 0.85em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Channel Switch Confirmation Overlay */
|
||||||
|
.channel-switch-overlay {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.6);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 10000;
|
||||||
|
backdrop-filter: blur(2px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-switch-dialog {
|
||||||
|
background: var(--lora-surface);
|
||||||
|
border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 28px 32px;
|
||||||
|
max-width: 420px;
|
||||||
|
width: 90%;
|
||||||
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-switch-dialog h3 {
|
||||||
|
margin: 0 0 12px;
|
||||||
|
font-size: 1.1em;
|
||||||
|
color: var(--text-primary, #eee);
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-switch-dialog p {
|
||||||
|
margin: 0 0 24px;
|
||||||
|
font-size: 0.9em;
|
||||||
|
color: var(--text-secondary, #aaa);
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-switch-actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-switch-cancel {
|
||||||
|
padding: 8px 18px;
|
||||||
|
border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
|
||||||
|
border-radius: 6px;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--text-secondary, #aaa);
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-switch-cancel:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-switch-confirm {
|
||||||
|
padding: 8px 18px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: var(--lora-accent, #4285F4);
|
||||||
|
color: #fff;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.9em;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-switch-confirm:hover {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
|
||||||
/* Update preferences section */
|
/* Update preferences section */
|
||||||
.update-preferences {
|
.update-preferences {
|
||||||
border-top: 1px solid var(--lora-border);
|
border-top: 1px solid var(--lora-border);
|
||||||
|
|||||||
@@ -145,13 +145,14 @@
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
right: 20px;
|
right: 20px;
|
||||||
top: 50px; /* Position below header */
|
top: 50px; /* Position below header */
|
||||||
width: 366px;
|
width: 420px;
|
||||||
background-color: var(--card-bg);
|
background-color: var(--card-bg);
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
border-radius: var(--border-radius-base);
|
border-radius: var(--border-radius-base);
|
||||||
box-shadow: var(--shadow-md);
|
box-shadow: var(--shadow-md);
|
||||||
z-index: var(--z-overlay);
|
z-index: var(--z-overlay);
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
|
box-sizing: border-box; /* Include padding in max-height calculation */
|
||||||
transition: transform 0.3s ease, opacity 0.3s ease;
|
transition: transform 0.3s ease, opacity 0.3s ease;
|
||||||
transform-origin: top right;
|
transform-origin: top right;
|
||||||
max-height: calc(100vh - 70px); /* Adjusted for header height */
|
max-height: calc(100vh - 70px); /* Adjusted for header height */
|
||||||
@@ -563,7 +564,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
max-width: 120px; /* Prevent long names from breaking layout */
|
max-width: 180px; /* Prevent long names from breaking layout */
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
@import 'components/sidebar.css'; /* Add sidebar component */
|
@import 'components/sidebar.css'; /* Add sidebar component */
|
||||||
@import 'components/media-viewer.css';
|
@import 'components/media-viewer.css';
|
||||||
@import 'components/metadata-refresh-result.css';
|
@import 'components/metadata-refresh-result.css';
|
||||||
|
@import 'components/download-batch-summary.css';
|
||||||
|
|
||||||
.initialization-notice {
|
.initialization-notice {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -49,10 +49,6 @@ export const MODEL_CONFIG = {
|
|||||||
* @returns {Object} Object containing all API endpoints for the model type
|
* @returns {Object} Object containing all API endpoints for the model type
|
||||||
*/
|
*/
|
||||||
export function getApiEndpoints(modelType) {
|
export function getApiEndpoints(modelType) {
|
||||||
if (!Object.values(MODEL_TYPES).includes(modelType)) {
|
|
||||||
throw new Error(`Invalid model type: ${modelType}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// Base CRUD operations
|
// Base CRUD operations
|
||||||
list: `/api/lm/${modelType}/list`,
|
list: `/api/lm/${modelType}/list`,
|
||||||
@@ -188,7 +184,8 @@ export const DOWNLOAD_ENDPOINTS = {
|
|||||||
downloadGet: '/api/lm/download-model-get',
|
downloadGet: '/api/lm/download-model-get',
|
||||||
cancelGet: '/api/lm/cancel-download-get',
|
cancelGet: '/api/lm/cancel-download-get',
|
||||||
progress: '/api/lm/download-progress',
|
progress: '/api/lm/download-progress',
|
||||||
exampleImages: '/api/lm/force-download-example-images' // New endpoint for downloading example images
|
exampleImages: '/api/lm/force-download-example-images', // Re-process example images ignoring previous status
|
||||||
|
exampleImagesMissing: '/api/lm/download-example-images' // Download only missing example images
|
||||||
};
|
};
|
||||||
|
|
||||||
// Hugging Face API endpoints
|
// Hugging Face API endpoints
|
||||||
|
|||||||
@@ -1641,7 +1641,7 @@ export class BaseModelApiClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadExampleImages(modelHashes, modelTypes = null) {
|
async downloadExampleImages(modelHashes, modelTypes = null, { force = true } = {}) {
|
||||||
let ws = null;
|
let ws = null;
|
||||||
|
|
||||||
await state.loadingManager.showWithProgress(async (loading) => {
|
await state.loadingManager.showWithProgress(async (loading) => {
|
||||||
@@ -1700,8 +1700,13 @@ export class BaseModelApiClient {
|
|||||||
// Determine optimize setting
|
// Determine optimize setting
|
||||||
const optimize = state.global?.settings?.optimize_example_images ?? true;
|
const optimize = state.global?.settings?.optimize_example_images ?? true;
|
||||||
|
|
||||||
|
// force=false routes to the regular endpoint, which skips already-processed models
|
||||||
|
const endpoint = force
|
||||||
|
? DOWNLOAD_ENDPOINTS.exampleImages
|
||||||
|
: DOWNLOAD_ENDPOINTS.exampleImagesMissing;
|
||||||
|
|
||||||
// Make the API request to start the download process
|
// Make the API request to start the download process
|
||||||
const response = await fetch(DOWNLOAD_ENDPOINTS.exampleImages, {
|
const response = await fetch(endpoint, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
@@ -1710,6 +1715,7 @@ export class BaseModelApiClient {
|
|||||||
model_hashes: modelHashes,
|
model_hashes: modelHashes,
|
||||||
output_dir: outputDir,
|
output_dir: outputDir,
|
||||||
optimize: optimize,
|
optimize: optimize,
|
||||||
|
force: force,
|
||||||
model_types: modelTypes || [this.apiConfig.config.singularName]
|
model_types: modelTypes || [this.apiConfig.config.singularName]
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -137,11 +137,10 @@ export class BulkContextMenu extends BaseContextMenu {
|
|||||||
downloadMissingLorasItem.style.display = currentModelType === 'recipes' ? 'flex' : 'none';
|
downloadMissingLorasItem.style.display = currentModelType === 'recipes' ? 'flex' : 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
const downloadExampleImagesItem = this.menu.querySelector('[data-action="download-example-images"]');
|
const downloadExampleImagesSubmenu = this.menu.querySelector('[data-has-submenu="download-example-images"]');
|
||||||
if (downloadExampleImagesItem) {
|
if (downloadExampleImagesSubmenu) {
|
||||||
// Show on model pages (loras, checkpoints, embeddings), hide on recipes
|
// Show on model pages (loras, checkpoints, embeddings), hide on recipes
|
||||||
const modelPages = ['loras', 'checkpoints', 'embeddings'];
|
downloadExampleImagesSubmenu.style.display = ['loras', 'checkpoints', 'embeddings'].includes(currentModelType) ? 'flex' : 'none';
|
||||||
downloadExampleImagesItem.style.display = modelPages.includes(currentModelType) ? 'flex' : 'none';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const skipMetadataRefreshItem = this.menu.querySelector('[data-action="skip-metadata-refresh"]');
|
const skipMetadataRefreshItem = this.menu.querySelector('[data-action="skip-metadata-refresh"]');
|
||||||
@@ -294,8 +293,11 @@ export class BulkContextMenu extends BaseContextMenu {
|
|||||||
case 'download-missing-loras':
|
case 'download-missing-loras':
|
||||||
this.handleDownloadMissingLoras();
|
this.handleDownloadMissingLoras();
|
||||||
break;
|
break;
|
||||||
|
case 'download-missing-example-images':
|
||||||
|
this.handleDownloadExampleImages({ force: false });
|
||||||
|
break;
|
||||||
case 'download-example-images':
|
case 'download-example-images':
|
||||||
this.handleDownloadExampleImages();
|
this.handleDownloadExampleImages({ force: true });
|
||||||
break;
|
break;
|
||||||
case 'clear':
|
case 'clear':
|
||||||
bulkManager.clearSelection();
|
bulkManager.clearSelection();
|
||||||
@@ -340,7 +342,7 @@ export class BulkContextMenu extends BaseContextMenu {
|
|||||||
await bulkMissingLoraDownloadManager.downloadMissingLoras(selectedRecipes);
|
await bulkMissingLoraDownloadManager.downloadMissingLoras(selectedRecipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleDownloadExampleImages() {
|
async handleDownloadExampleImages({ force = true } = {}) {
|
||||||
if (state.selectedModels.size === 0) {
|
if (state.selectedModels.size === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -361,7 +363,7 @@ export class BulkContextMenu extends BaseContextMenu {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const apiClient = getModelApiClient();
|
const apiClient = getModelApiClient();
|
||||||
await apiClient.downloadExampleImages([...hashes]);
|
await apiClient.downloadExampleImages([...hashes], null, { force });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Bulk download example images failed:', error);
|
console.error('Bulk download example images failed:', error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -347,7 +347,10 @@ export const ModelContextMenuMixin = {
|
|||||||
openExampleImagesFolder(this.currentCard.dataset.sha256);
|
openExampleImagesFolder(this.currentCard.dataset.sha256);
|
||||||
return true;
|
return true;
|
||||||
case 'download-examples':
|
case 'download-examples':
|
||||||
this.downloadExampleImages();
|
this.downloadExampleImages(false);
|
||||||
|
return true;
|
||||||
|
case 'download-examples-force':
|
||||||
|
this.downloadExampleImages(true);
|
||||||
return true;
|
return true;
|
||||||
case 'civitai':
|
case 'civitai':
|
||||||
if (this.currentCard.dataset.from_civitai === 'true') {
|
if (this.currentCard.dataset.from_civitai === 'true') {
|
||||||
@@ -378,7 +381,7 @@ export const ModelContextMenuMixin = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Download example images method
|
// Download example images method
|
||||||
async downloadExampleImages() {
|
async downloadExampleImages(force = false) {
|
||||||
const modelHash = this.currentCard.dataset.sha256;
|
const modelHash = this.currentCard.dataset.sha256;
|
||||||
if (!modelHash) {
|
if (!modelHash) {
|
||||||
showToast('toast.contextMenu.missingHash', {}, 'error');
|
showToast('toast.contextMenu.missingHash', {}, 'error');
|
||||||
@@ -387,7 +390,7 @@ export const ModelContextMenuMixin = {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const apiClient = getModelApiClient();
|
const apiClient = getModelApiClient();
|
||||||
await apiClient.downloadExampleImages([modelHash]);
|
await apiClient.downloadExampleImages([modelHash], null, { force });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error downloading example images:', error);
|
console.error('Error downloading example images:', error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,8 +260,9 @@ export class RecipeContextMenu extends BaseContextMenu {
|
|||||||
strength: lora.strength || 1.0,
|
strength: lora.strength || 1.0,
|
||||||
|
|
||||||
// Model identifiers
|
// Model identifiers
|
||||||
|
modelId: lora.modelId || lora.model_id || civitaiInfo.modelId,
|
||||||
hash: modelFile?.hashes?.SHA256?.toLowerCase() || lora.hash,
|
hash: modelFile?.hashes?.SHA256?.toLowerCase() || lora.hash,
|
||||||
modelVersionId: civitaiInfo.id || lora.modelVersionId,
|
id: civitaiInfo.id || lora.modelVersionId,
|
||||||
|
|
||||||
// Metadata
|
// Metadata
|
||||||
thumbnailUrl: civitaiInfo.images?.[0]?.url || '',
|
thumbnailUrl: civitaiInfo.images?.[0]?.url || '',
|
||||||
|
|||||||
@@ -0,0 +1,340 @@
|
|||||||
|
import { translate } from '../utils/i18nHelpers.js';
|
||||||
|
import { showToast, openHuggingFace } from '../utils/uiHelpers.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escape HTML entities in a string to prevent injection when interpolating into innerHTML.
|
||||||
|
* Safe for both text content and attribute values (quotes are escaped too).
|
||||||
|
* @param {string} str - The string to escape
|
||||||
|
* @returns {string} - The escaped string
|
||||||
|
*/
|
||||||
|
function _escapeHtml(str) {
|
||||||
|
if (!str) return '';
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.textContent = str;
|
||||||
|
return div.innerHTML.replace(/"/g, '"').replace(/'/g, ''');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve the display name of a failed download entry.
|
||||||
|
* Prefers the resolved name carried on the entry, then known item fields,
|
||||||
|
* then derives a name from the item URL as a last resort.
|
||||||
|
* @param {Object} entry - The failed entry ({ item, error, name? })
|
||||||
|
* @returns {string} - The best available display name
|
||||||
|
*/
|
||||||
|
function _resolveItemName(entry) {
|
||||||
|
if (entry?.name) {
|
||||||
|
return entry.name;
|
||||||
|
}
|
||||||
|
const item = entry?.item ?? entry;
|
||||||
|
const direct = item?.displayName || item?.name || item?.file_name || item?.filename || item?.selectedVersion?.name;
|
||||||
|
if (direct) {
|
||||||
|
return direct;
|
||||||
|
}
|
||||||
|
if (item?.url) {
|
||||||
|
try {
|
||||||
|
const segments = new URL(item.url).pathname.split('/').filter(Boolean);
|
||||||
|
if (segments.length > 0) {
|
||||||
|
return decodeURIComponent(segments[segments.length - 1]);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Unparseable URL — fall through to 'Unknown'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 'Unknown';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve the URL to open for a failed item — always the original item URL.
|
||||||
|
* @param {Object} item - The failed item payload
|
||||||
|
* @returns {string|null} - A URL string, or null when nothing is available
|
||||||
|
*/
|
||||||
|
function _resolveItemUrl(item) {
|
||||||
|
return item?.url || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format a raw failure error into a concise human-readable message.
|
||||||
|
* Unwraps JSON envelopes and extracts HTTP status/body details when present.
|
||||||
|
* @param {*} error - The raw error (usually a string)
|
||||||
|
* @returns {string} - The formatted error message
|
||||||
|
*/
|
||||||
|
function _formatError(error) {
|
||||||
|
if (!error) {
|
||||||
|
return 'Unknown error';
|
||||||
|
}
|
||||||
|
let base = typeof error === 'string' ? error : String(error);
|
||||||
|
|
||||||
|
// Unwrap JSON envelope: { "success": false, "error": "...", ... }
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(base);
|
||||||
|
if (parsed && typeof parsed.error === 'string' && parsed.error) {
|
||||||
|
base = parsed.error;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Not a JSON envelope — keep the raw string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract HTTP status and JSON body details, e.g. "status=403 body={...}"
|
||||||
|
let result = base;
|
||||||
|
const statusMatch = base.match(/status=(\d{3})/);
|
||||||
|
const bodyMatch = base.match(/body=(\{.*\})/s);
|
||||||
|
if (bodyMatch) {
|
||||||
|
try {
|
||||||
|
const body = JSON.parse(bodyMatch[1]);
|
||||||
|
const detail = (typeof body?.message === 'string' && body.message)
|
||||||
|
|| (typeof body?.error === 'string' && body.error)
|
||||||
|
|| null;
|
||||||
|
if (detail) {
|
||||||
|
const status = statusMatch ? statusMatch[1] : null;
|
||||||
|
result = `${status ? `HTTP ${status} — ` : ''}${detail}`;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Body is not valid JSON — keep the base string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Truncate overly long messages
|
||||||
|
if (result.length > 220) {
|
||||||
|
result = result.slice(0, 220) + '…';
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a plain-text report of the batch download results.
|
||||||
|
* @param {number} total - Total number of models attempted
|
||||||
|
* @param {number} completed - Number of models successfully downloaded
|
||||||
|
* @param {Array} failedItems - Array of failed items ({ item, error })
|
||||||
|
* @returns {string} - The report text
|
||||||
|
*/
|
||||||
|
function _buildReportText(total, completed, failedItems) {
|
||||||
|
const lines = [
|
||||||
|
'=== Batch Download Report ===',
|
||||||
|
`Date: ${new Date().toLocaleString()}`,
|
||||||
|
`Total: ${total}`,
|
||||||
|
`Successfully downloaded: ${completed}`,
|
||||||
|
`Failed: ${failedItems.length}`,
|
||||||
|
'',
|
||||||
|
];
|
||||||
|
if (failedItems.length > 0) {
|
||||||
|
lines.push('--- Failed Items ---');
|
||||||
|
failedItems.forEach((entry, i) => {
|
||||||
|
const name = _resolveItemName(entry);
|
||||||
|
const error = _formatError(entry?.error);
|
||||||
|
lines.push(`${i + 1}. ${name} — ${error}`);
|
||||||
|
const itemUrl = _resolveItemUrl(entry?.item ?? entry);
|
||||||
|
if (itemUrl) {
|
||||||
|
lines.push(` URL: ${itemUrl}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
lines.push('');
|
||||||
|
}
|
||||||
|
lines.push('====================');
|
||||||
|
return lines.join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a successful clipboard write: confirm via toast and briefly swap the
|
||||||
|
* trigger button to a "Copied!" state.
|
||||||
|
* @param {HTMLElement|null} btn - The button that triggered the copy action
|
||||||
|
*/
|
||||||
|
function _onCopyReportSuccess(btn) {
|
||||||
|
showToast('toast.api.copiedToClipboard', {}, 'success');
|
||||||
|
if (btn) {
|
||||||
|
const origHTML = btn.innerHTML;
|
||||||
|
btn.innerHTML = '<i class="fas fa-check"></i> Copied!';
|
||||||
|
setTimeout(() => { btn.innerHTML = origHTML; }, 2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fallback for environments without the async Clipboard API (e.g. insecure
|
||||||
|
* contexts over LAN http where `navigator.clipboard` is undefined): copy via a
|
||||||
|
* hidden textarea and `document.execCommand('copy')`.
|
||||||
|
* @param {string} text - The report text to copy
|
||||||
|
*/
|
||||||
|
function _copyReportWithExecCommand(text) {
|
||||||
|
const textarea = document.createElement('textarea');
|
||||||
|
textarea.value = text;
|
||||||
|
document.body.appendChild(textarea);
|
||||||
|
textarea.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
document.body.removeChild(textarea);
|
||||||
|
showToast('toast.api.copiedToClipboard', {}, 'success');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy the batch download report to the clipboard.
|
||||||
|
* Uses the async Clipboard API when available, otherwise falls back to a hidden
|
||||||
|
* textarea + execCommand so the action still works in insecure contexts.
|
||||||
|
* @param {HTMLElement} btn - The button that triggered the copy action
|
||||||
|
* @param {number} total - Total number of models attempted
|
||||||
|
* @param {number} completed - Number of models successfully downloaded
|
||||||
|
* @param {Array} failedItems - Array of failed items
|
||||||
|
*/
|
||||||
|
function _copyReport(btn, total, completed, failedItems) {
|
||||||
|
const text = _buildReportText(total, completed, failedItems);
|
||||||
|
if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
|
||||||
|
navigator.clipboard.writeText(text)
|
||||||
|
.then(() => _onCopyReportSuccess(btn))
|
||||||
|
.catch(() => _copyReportWithExecCommand(text));
|
||||||
|
} else {
|
||||||
|
_copyReportWithExecCommand(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the batch download summary modal after a batch download completes.
|
||||||
|
* Mirrors the Metadata Fetch Summary modal lifecycle: the modal element is
|
||||||
|
* appended directly to document.body and removed on close; it is not
|
||||||
|
* registered with ModalManager.
|
||||||
|
* @param {Object} options - Summary options
|
||||||
|
* @param {number} options.total - Total number of models attempted
|
||||||
|
* @param {number} options.completed - Number of models successfully downloaded
|
||||||
|
* @param {Array} options.failedItems - Array of failed items ({ item, error })
|
||||||
|
* @param {Function} options.onRetry - Callback invoked with failedItems to retry the failed subset
|
||||||
|
*/
|
||||||
|
export function showDownloadBatchSummary({ total, completed, failedItems, onRetry }) {
|
||||||
|
const failures = failedItems || [];
|
||||||
|
const failedCount = failures.length;
|
||||||
|
|
||||||
|
// 3-state summary header semantics (mirrors BatchImportManager results header)
|
||||||
|
let headerState;
|
||||||
|
let headerIcon;
|
||||||
|
let headerText;
|
||||||
|
if (completed === 0) {
|
||||||
|
headerState = 'error';
|
||||||
|
headerIcon = 'fa-times-circle';
|
||||||
|
headerText = translate('modals.downloadBatchSummary.failed', {}, 'Download failed');
|
||||||
|
} else if (failedCount > 0) {
|
||||||
|
headerState = 'warning';
|
||||||
|
headerIcon = 'fa-exclamation-circle';
|
||||||
|
headerText = translate('modals.downloadBatchSummary.completedWithErrors', {}, 'Completed with errors');
|
||||||
|
} else {
|
||||||
|
headerState = 'success';
|
||||||
|
headerIcon = 'fa-check-circle';
|
||||||
|
headerText = translate('modals.downloadBatchSummary.successMessage', { count: completed }, 'All ' + completed + ' models downloaded successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build failure table rows
|
||||||
|
const failureRows = failures.map((entry, i) => {
|
||||||
|
const item = entry?.item ?? entry;
|
||||||
|
const name = _resolveItemName(entry);
|
||||||
|
const itemUrl = _resolveItemUrl(item);
|
||||||
|
const rawError = entry?.error ? String(entry.error) : '';
|
||||||
|
const error = _formatError(entry?.error);
|
||||||
|
const nameCell = itemUrl
|
||||||
|
? `<td class="failure-name"><a href="#" class="failure-link" data-action="open-model" data-index="${i}" title="${_escapeHtml(itemUrl)}">${_escapeHtml(name)}</a></td>`
|
||||||
|
: `<td class="failure-name" title="${_escapeHtml(name)}">${_escapeHtml(name)}</td>`;
|
||||||
|
return `<tr>
|
||||||
|
<td class="failure-index">${i + 1}</td>
|
||||||
|
${nameCell}
|
||||||
|
<td class="failure-error" title="${_escapeHtml(rawError)}">${_escapeHtml(error)}</td>
|
||||||
|
</tr>`;
|
||||||
|
}).join('');
|
||||||
|
|
||||||
|
const modalHtml = `
|
||||||
|
<div id="downloadBatchSummaryModal" class="modal" style="display: block;">
|
||||||
|
<div class="modal-content download-batch-summary-modal">
|
||||||
|
<button class="close" data-action="close-modal">×</button>
|
||||||
|
|
||||||
|
<h2>${translate('modals.downloadBatchSummary.title', {}, 'Batch Download Summary')}</h2>
|
||||||
|
|
||||||
|
<div class="summary-header ${headerState}">
|
||||||
|
<i class="fas ${headerIcon}"></i>
|
||||||
|
<span class="summary-title">${headerText}</span>
|
||||||
|
<span class="summary-hint">${completed}/${total}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="refresh-summary-stats">
|
||||||
|
<div class="stat-card stat-card-success">
|
||||||
|
<div class="stat-card-body">
|
||||||
|
<span class="stat-card-label">${translate('modals.downloadBatchSummary.statSuccess', {}, 'Success')}</span>
|
||||||
|
<span class="stat-card-value">${completed}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card stat-card-failure">
|
||||||
|
<div class="stat-card-body">
|
||||||
|
<span class="stat-card-label">${translate('modals.downloadBatchSummary.statFailed', {}, 'Failed')}</span>
|
||||||
|
<span class="stat-card-value">${failedCount}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card stat-card-total">
|
||||||
|
<div class="stat-card-body">
|
||||||
|
<span class="stat-card-label">${translate('modals.downloadBatchSummary.statTotal', {}, 'Total')}</span>
|
||||||
|
<span class="stat-card-value">${total}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
${failedCount > 0 ? `
|
||||||
|
<div class="refresh-failures-section">
|
||||||
|
<h4><i class="fas fa-exclamation-triangle"></i> ${translate('modals.downloadBatchSummary.failedItems', { count: failedCount }, 'Failed Items (' + failedCount + ')')}</h4>
|
||||||
|
<div class="failure-table-wrapper">
|
||||||
|
<table class="failure-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>#</th>
|
||||||
|
<th>${translate('modals.downloadBatchSummary.columnName', {}, 'Model Name')}</th>
|
||||||
|
<th>${translate('modals.downloadBatchSummary.columnError', {}, 'Error')}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>${failureRows}</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
` : `
|
||||||
|
<div class="refresh-success-message">
|
||||||
|
<i class="fas fa-check-circle"></i> ${translate('modals.downloadBatchSummary.successMessage', { count: completed }, 'All ' + completed + ' models downloaded successfully')}
|
||||||
|
</div>
|
||||||
|
`}
|
||||||
|
|
||||||
|
<div class="modal-actions">
|
||||||
|
${failedCount > 0 ? `
|
||||||
|
<button class="btn-retry" data-action="retry-failed"><i class="fas fa-redo"></i> ${translate('modals.downloadBatchSummary.retryFailed', { count: failedCount }, 'Retry Failed (' + failedCount + ')')}</button>
|
||||||
|
<button class="secondary-btn" data-action="copy-report"><i class="fas fa-copy"></i> ${translate('modals.downloadBatchSummary.copyReport', {}, 'Copy Report')}</button>
|
||||||
|
` : ''}
|
||||||
|
<button class="cancel-btn" data-action="close-modal">${translate('modals.downloadBatchSummary.close', {}, 'Close')}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
const existing = document.getElementById('downloadBatchSummaryModal');
|
||||||
|
if (existing) existing.remove();
|
||||||
|
|
||||||
|
const container = document.createElement('div');
|
||||||
|
container.innerHTML = modalHtml;
|
||||||
|
const modal = container.firstElementChild;
|
||||||
|
document.body.appendChild(modal);
|
||||||
|
|
||||||
|
modal.addEventListener('click', (e) => {
|
||||||
|
const actionEl = e.target.closest('[data-action]');
|
||||||
|
const action = actionEl?.dataset.action;
|
||||||
|
if (!action) return;
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
switch (action) {
|
||||||
|
case 'close-modal':
|
||||||
|
modal.remove();
|
||||||
|
break;
|
||||||
|
case 'retry-failed':
|
||||||
|
modal.remove();
|
||||||
|
if (typeof onRetry === 'function') {
|
||||||
|
onRetry(failures);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'copy-report':
|
||||||
|
_copyReport(actionEl, total, completed, failures);
|
||||||
|
break;
|
||||||
|
case 'open-model': {
|
||||||
|
// Keep the modal open; just open the item's original URL in a new tab
|
||||||
|
const entry = failures[Number(actionEl.dataset.index)];
|
||||||
|
const item = entry?.item;
|
||||||
|
if (!item?.url) break;
|
||||||
|
openHuggingFace(item.url);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
import { showToast } from '../utils/uiHelpers.js';
|
import { showToast } from '../utils/uiHelpers.js';
|
||||||
import { RecipeCard } from './RecipeCard.js';
|
import { RecipeCard } from './RecipeCard.js';
|
||||||
import { state, getCurrentPageState } from '../state/index.js';
|
import { state, getCurrentPageState } from '../state/index.js';
|
||||||
|
import { recreateVirtualScroll } from '../utils/infiniteScroll.js';
|
||||||
|
|
||||||
export class DuplicatesManager {
|
export class DuplicatesManager {
|
||||||
constructor(recipeManager) {
|
constructor(recipeManager) {
|
||||||
@@ -71,7 +72,7 @@ export class DuplicatesManager {
|
|||||||
this.updateSelectedCount();
|
this.updateSelectedCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
exitDuplicateMode() {
|
async exitDuplicateMode() {
|
||||||
this.inDuplicateMode = false;
|
this.inDuplicateMode = false;
|
||||||
this.selectedForDeletion.clear();
|
this.selectedForDeletion.clear();
|
||||||
|
|
||||||
@@ -94,9 +95,17 @@ export class DuplicatesManager {
|
|||||||
recipeGrid.innerHTML = '';
|
recipeGrid.innerHTML = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-enable virtual scrolling
|
// Re-enable virtual scrolling, or apply a layout switch deferred
|
||||||
|
// while duplicates mode was active (enabling the old scroller first
|
||||||
|
// would let its pending rAF render repopulate the grid after the
|
||||||
|
// new scroller is created, leaving orphaned/overlapping cards).
|
||||||
|
if (state.pendingLayoutRecreate) {
|
||||||
|
state.pendingLayoutRecreate = false;
|
||||||
|
await recreateVirtualScroll('recipes');
|
||||||
|
} else if (state.virtualScroller) {
|
||||||
state.virtualScroller.enable();
|
state.virtualScroller.enable();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
renderDuplicateGroups() {
|
renderDuplicateGroups() {
|
||||||
const recipeGrid = document.getElementById('recipeGrid');
|
const recipeGrid = document.getElementById('recipeGrid');
|
||||||
|
|||||||
@@ -1421,6 +1421,7 @@ class RecipeModal {
|
|||||||
strength: lora.strength || 1.0,
|
strength: lora.strength || 1.0,
|
||||||
|
|
||||||
// Model identifiers
|
// Model identifiers
|
||||||
|
modelId: lora.modelId || lora.model_id || civitaiInfo.modelId,
|
||||||
hash: modelFile?.hashes?.SHA256?.toLowerCase() || lora.hash,
|
hash: modelFile?.hashes?.SHA256?.toLowerCase() || lora.hash,
|
||||||
id: civitaiInfo.id || lora.modelVersionId,
|
id: civitaiInfo.id || lora.modelVersionId,
|
||||||
|
|
||||||
|
|||||||
@@ -108,10 +108,20 @@ export class PageControls {
|
|||||||
const sortSelect = document.getElementById('sortSelect');
|
const sortSelect = document.getElementById('sortSelect');
|
||||||
if (sortSelect) {
|
if (sortSelect) {
|
||||||
initSortDropdown(sortSelect);
|
initSortDropdown(sortSelect);
|
||||||
sortSelect.value = this.pageState.sortBy;
|
this.applySortToSelect(this.pageState.sortBy);
|
||||||
sortSelect.addEventListener('change', async (e) => {
|
sortSelect.addEventListener('change', async (e) => {
|
||||||
this.pageState.sortBy = e.target.value;
|
let value = e.target.value;
|
||||||
this.saveSortPreference(e.target.value);
|
if (value.startsWith('random')) {
|
||||||
|
// Every pick of Random reshuffles the list: generate a
|
||||||
|
// fresh seed so the backend keeps a stable order across
|
||||||
|
// paginated requests.
|
||||||
|
value = this._randomizeSortValue();
|
||||||
|
}
|
||||||
|
this.pageState.sortBy = value;
|
||||||
|
this.saveSortPreference(value);
|
||||||
|
// Reset the seeded Random option when switching away from
|
||||||
|
// Random, or re-apply the fresh seed when picking it again.
|
||||||
|
this.applySortToSelect(value);
|
||||||
await this.resetAndReload();
|
await this.resetAndReload();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -312,6 +322,44 @@ export class PageControls {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply a sort value to the native sort <select>, keeping the Random
|
||||||
|
* option's value in sync when the persisted value carries a seed
|
||||||
|
* (e.g. "random:abc123"). Must be used instead of assigning
|
||||||
|
* sortSelect.value directly whenever the value may be a seeded random
|
||||||
|
* sort, otherwise the native select has no matching option.
|
||||||
|
* @param {string} sortValue - Sort value like "name:asc" or "random:<seed>"
|
||||||
|
*/
|
||||||
|
applySortToSelect(sortValue) {
|
||||||
|
const sortSelect = document.getElementById('sortSelect');
|
||||||
|
if (!sortSelect) return;
|
||||||
|
const randomOpt = sortSelect.querySelector('option[value="random"], option[value^="random:"]');
|
||||||
|
if (randomOpt) {
|
||||||
|
randomOpt.value = String(sortValue).startsWith('random') ? sortValue : 'random';
|
||||||
|
}
|
||||||
|
sortSelect.value = sortValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a fresh seeded random sort value ("random:<seed>") and keep
|
||||||
|
* the native <select> in sync so its value matches the persisted sort
|
||||||
|
* string and the dropdown shows the selected label.
|
||||||
|
* @returns {string} The new sort value, e.g. "random:abc123xyz"
|
||||||
|
*/
|
||||||
|
_randomizeSortValue() {
|
||||||
|
const seed = Math.random().toString(36).slice(2, 12);
|
||||||
|
const value = `random:${seed}`;
|
||||||
|
const sortSelect = document.getElementById('sortSelect');
|
||||||
|
if (sortSelect) {
|
||||||
|
const randomOpt = sortSelect.querySelector('option[value="random"], option[value^="random:"]');
|
||||||
|
if (randomOpt) {
|
||||||
|
randomOpt.value = value;
|
||||||
|
}
|
||||||
|
sortSelect.value = value;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load sort preference from storage
|
* Load sort preference from storage
|
||||||
*/
|
*/
|
||||||
@@ -326,10 +374,7 @@ export class PageControls {
|
|||||||
// Handle legacy format conversion
|
// Handle legacy format conversion
|
||||||
const convertedSort = this.convertLegacySortFormat(savedSort);
|
const convertedSort = this.convertLegacySortFormat(savedSort);
|
||||||
this.pageState.sortBy = convertedSort;
|
this.pageState.sortBy = convertedSort;
|
||||||
const sortSelect = document.getElementById('sortSelect');
|
this.applySortToSelect(convertedSort);
|
||||||
if (sortSelect) {
|
|
||||||
sortSelect.value = convertedSort;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,9 +568,9 @@ export class PageControls {
|
|||||||
this.pageState.sortBy = restoredSort;
|
this.pageState.sortBy = restoredSort;
|
||||||
this.saveSortPreference(restoredSort);
|
this.saveSortPreference(restoredSort);
|
||||||
this._removeVlmSortOption();
|
this._removeVlmSortOption();
|
||||||
|
this.applySortToSelect(restoredSort);
|
||||||
const sortSelect = document.getElementById('sortSelect');
|
const sortSelect = document.getElementById('sortSelect');
|
||||||
if (sortSelect) {
|
if (sortSelect) {
|
||||||
sortSelect.value = restoredSort;
|
|
||||||
sortSelect.disabled = false;
|
sortSelect.disabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -575,10 +620,7 @@ export class PageControls {
|
|||||||
const savedGroupedSort = getStorageItem(groupedKey);
|
const savedGroupedSort = getStorageItem(groupedKey);
|
||||||
if (savedGroupedSort) {
|
if (savedGroupedSort) {
|
||||||
this.pageState.sortBy = savedGroupedSort;
|
this.pageState.sortBy = savedGroupedSort;
|
||||||
const sortSelect = document.getElementById('sortSelect');
|
this.applySortToSelect(savedGroupedSort);
|
||||||
if (sortSelect) {
|
|
||||||
sortSelect.value = savedGroupedSort;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Leaving group mode: persist current sort for next time, restore non-group sort
|
// Leaving group mode: persist current sort for next time, restore non-group sort
|
||||||
@@ -586,10 +628,7 @@ export class PageControls {
|
|||||||
const savedNormalSort = getStorageItem(`${this.pageType}_sort`);
|
const savedNormalSort = getStorageItem(`${this.pageType}_sort`);
|
||||||
if (savedNormalSort) {
|
if (savedNormalSort) {
|
||||||
this.pageState.sortBy = savedNormalSort;
|
this.pageState.sortBy = savedNormalSort;
|
||||||
const sortSelect = document.getElementById('sortSelect');
|
this.applySortToSelect(savedNormalSort);
|
||||||
if (sortSelect) {
|
|
||||||
sortSelect.value = savedNormalSort;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -874,7 +913,7 @@ export class PageControls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sortSelect) {
|
if (sortSelect) {
|
||||||
sortSelect.value = this.pageState.sortBy;
|
this.applySortToSelect(this.pageState.sortBy);
|
||||||
}
|
}
|
||||||
if (searchInput) {
|
if (searchInput) {
|
||||||
searchInput.value = this.pageState.filters?.search || '';
|
searchInput.value = this.pageState.filters?.search || '';
|
||||||
|
|||||||
@@ -96,7 +96,16 @@ export function initSortDropdown(select) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const choose = (value) => {
|
const choose = (value) => {
|
||||||
if (select.value === value) return;
|
if (select.value === value) {
|
||||||
|
// Re-picking the already-selected option is normally a no-op,
|
||||||
|
// matching native <select> behavior. The seeded Random sort is
|
||||||
|
// the exception: clicking it again should reshuffle, so let the
|
||||||
|
// change handler (PageControls) generate a fresh seed.
|
||||||
|
if (String(value).startsWith('random')) {
|
||||||
|
select.dispatchEvent(new Event('change', { bubbles: true }));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
select.value = value;
|
select.value = value;
|
||||||
select.dispatchEvent(new Event('change', { bubbles: true }));
|
select.dispatchEvent(new Event('change', { bubbles: true }));
|
||||||
};
|
};
|
||||||
@@ -277,9 +286,10 @@ export function initSortDropdown(select) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rebuild the menu when <option>s change (VLM adds/removes a temporary
|
// Rebuild the menu when <option>s change (VLM adds/removes a temporary
|
||||||
// option at runtime).
|
// option at runtime, and the seeded Random sort option gets a new value
|
||||||
|
// attribute each time it is picked).
|
||||||
const observer = new MutationObserver(() => buildMenu());
|
const observer = new MutationObserver(() => buildMenu());
|
||||||
observer.observe(select, { childList: true });
|
observer.observe(select, { childList: true, subtree: true, attributes: true, attributeFilter: ['value'] });
|
||||||
|
|
||||||
buildMenu();
|
buildMenu();
|
||||||
group.dataset.sortReady = '1';
|
group.dataset.sortReady = '1';
|
||||||
|
|||||||
@@ -489,6 +489,12 @@ export function createModelCard(model, modelType) {
|
|||||||
const modelId = civitaiData?.modelId ?? civitaiData?.model_id;
|
const modelId = civitaiData?.modelId ?? civitaiData?.model_id;
|
||||||
if (modelId !== undefined && modelId !== null && modelId !== '') {
|
if (modelId !== undefined && modelId !== null && modelId !== '') {
|
||||||
card.dataset.modelId = modelId;
|
card.dataset.modelId = modelId;
|
||||||
|
} else if (model.hf_url) {
|
||||||
|
// For HF-only models, derive a group key from hf_url for version grouping
|
||||||
|
const match = model.hf_url.match(/https?:\/\/huggingface\.co\/([^/]+\/[^/]+)/);
|
||||||
|
if (match) {
|
||||||
|
card.dataset.modelId = 'hf:' + match[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoRA specific data
|
// LoRA specific data
|
||||||
|
|||||||
@@ -473,7 +473,14 @@ export async function showModelModal(model, modelType) {
|
|||||||
const loadingExamplesText = translate('modals.model.loading.examples', {}, 'Loading examples...');
|
const loadingExamplesText = translate('modals.model.loading.examples', {}, 'Loading examples...');
|
||||||
|
|
||||||
const loadingVersionsText = translate('modals.model.loading.versions', {}, 'Loading versions...');
|
const loadingVersionsText = translate('modals.model.loading.versions', {}, 'Loading versions...');
|
||||||
const civitaiModelId = modelWithFullData.civitai?.modelId || '';
|
// Use CivitAI modelId, or derive HF group key for HF-only models
|
||||||
|
let civitaiModelId = modelWithFullData.civitai?.modelId || '';
|
||||||
|
if (!civitaiModelId && modelWithFullData.hf_url) {
|
||||||
|
const match = modelWithFullData.hf_url.match(/https?:\/\/huggingface\.co\/([^/]+\/[^/]+)/);
|
||||||
|
if (match) {
|
||||||
|
civitaiModelId = 'hf:' + match[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
const civitaiVersionId = modelWithFullData.civitai?.id || '';
|
const civitaiVersionId = modelWithFullData.civitai?.id || '';
|
||||||
const navAriaLabel = translate('modals.model.navigation.label', {}, 'Model navigation');
|
const navAriaLabel = translate('modals.model.navigation.label', {}, 'Model navigation');
|
||||||
const previousTitle = translate('modals.model.navigation.previousWithShortcut', {}, 'Previous model (←)');
|
const previousTitle = translate('modals.model.navigation.previousWithShortcut', {}, 'Previous model (←)');
|
||||||
@@ -885,7 +892,8 @@ function setupEventHandlers(filePath, modelType) {
|
|||||||
case 'view-creator':
|
case 'view-creator':
|
||||||
const username = target.dataset.username;
|
const username = target.dataset.username;
|
||||||
if (username) {
|
if (username) {
|
||||||
window.open(`https://civitai.com/user/${username}`, '_blank');
|
const host = state.global.settings.civitai_host || 'civitai.com';
|
||||||
|
window.open(`https://${host}/user/${username}`, '_blank');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'open-file-location':
|
case 'open-file-location':
|
||||||
|
|||||||
@@ -950,6 +950,26 @@ export function initVersionsTab({
|
|||||||
renderErrorState(container, translate('modals.model.versions.missingModelId', {}, 'This model is missing a Civitai model id.'));
|
renderErrorState(container, translate('modals.model.versions.missingModelId', {}, 'This model is missing a Civitai model id.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// HF group keys (e.g. "hf:user/repo") are not real CivitAI model IDs —
|
||||||
|
// skip the remote API call and show a helpful message instead.
|
||||||
|
const isHfGroupKey = typeof modelId === 'string' && modelId.startsWith('hf:');
|
||||||
|
if (isHfGroupKey) {
|
||||||
|
controller.isLoading = false;
|
||||||
|
controller.hasLoaded = true;
|
||||||
|
controller.record = null;
|
||||||
|
const hfMsg = translate(
|
||||||
|
'modals.model.versions.hfGroupInfo',
|
||||||
|
{},
|
||||||
|
'This is a HuggingFace model group. Open the library to see all versions in the grid.'
|
||||||
|
);
|
||||||
|
container.innerHTML = `
|
||||||
|
<div class="versions-empty-state">
|
||||||
|
<i class="fas fa-info-circle"></i>
|
||||||
|
<p>${escapeHtml(hfMsg)}</p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (controller.hasLoaded && !forceRefresh) {
|
if (controller.hasLoaded && !forceRefresh) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ export class BulkManager {
|
|||||||
|
|
||||||
// Drag detection properties
|
// Drag detection properties
|
||||||
this.dragThreshold = 5; // Pixels to move before considering it a drag
|
this.dragThreshold = 5; // Pixels to move before considering it a drag
|
||||||
|
this.dragDelayMs = 100; // Minimum hold time before a drag is treated as a marquee
|
||||||
|
this.minMarqueeSize = 10; // Minimum drag box (px) before a marquee counts as a selection
|
||||||
this.mouseDownTime = 0;
|
this.mouseDownTime = 0;
|
||||||
this.mouseDownPosition = { x: 0, y: 0 };
|
this.mouseDownPosition = { x: 0, y: 0 };
|
||||||
|
|
||||||
@@ -88,7 +90,7 @@ export class BulkManager {
|
|||||||
moveAll: true,
|
moveAll: true,
|
||||||
autoOrganize: false,
|
autoOrganize: false,
|
||||||
deleteAll: true,
|
deleteAll: true,
|
||||||
setContentRating: false,
|
setContentRating: true,
|
||||||
skipMetadataRefresh: false,
|
skipMetadataRefresh: false,
|
||||||
setFavorite: true,
|
setFavorite: true,
|
||||||
unfavorite: true,
|
unfavorite: true,
|
||||||
@@ -173,6 +175,19 @@ export class BulkManager {
|
|||||||
});
|
});
|
||||||
|
|
||||||
eventManager.addHandler('mousemove', 'bulkManager-marquee-move', (e) => {
|
eventManager.addHandler('mousemove', 'bulkManager-marquee-move', (e) => {
|
||||||
|
// Only track marquee/drag while the left button is physically held.
|
||||||
|
// mouseup can be missed (release outside the window, focus loss, driver quirks),
|
||||||
|
// so mousemove must verify the button state itself instead of relying on it.
|
||||||
|
if (!(e.buttons & 1)) {
|
||||||
|
if (this.isMarqueeActive) {
|
||||||
|
this.endMarqueeSelection(e);
|
||||||
|
} else {
|
||||||
|
this.mouseDownTime = 0;
|
||||||
|
this.isDragging = false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.isMarqueeActive) {
|
if (this.isMarqueeActive) {
|
||||||
this.lastClientX = e.clientX;
|
this.lastClientX = e.clientX;
|
||||||
this.lastClientY = e.clientY;
|
this.lastClientY = e.clientY;
|
||||||
@@ -184,7 +199,10 @@ export class BulkManager {
|
|||||||
const dy = e.clientY - this.mouseDownPosition.y;
|
const dy = e.clientY - this.mouseDownPosition.y;
|
||||||
const distance = Math.sqrt(dx * dx + dy * dy);
|
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
if (distance >= this.dragThreshold) {
|
// Require both enough movement AND enough hold time so quick
|
||||||
|
// click jitter from micro-movement input devices is not a marquee.
|
||||||
|
const heldTime = Date.now() - this.mouseDownTime;
|
||||||
|
if (heldTime >= this.dragDelayMs && distance >= this.dragThreshold) {
|
||||||
this.isDragging = true;
|
this.isDragging = true;
|
||||||
this.startMarqueeSelection(e, true);
|
this.startMarqueeSelection(e, true);
|
||||||
}
|
}
|
||||||
@@ -1510,14 +1528,18 @@ export class BulkManager {
|
|||||||
let failureCount = 0;
|
let failureCount = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const apiClient = getModelApiClient();
|
const isRecipesPage = state.currentPageType === 'recipes';
|
||||||
for (const filePath of targets) {
|
for (const filePath of targets) {
|
||||||
if (cancelled) {
|
if (cancelled) {
|
||||||
showToast('toast.api.operationCancelled', {}, 'info');
|
showToast('toast.api.operationCancelled', {}, 'info');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await apiClient.saveModelMetadata(filePath, { preview_nsfw_level: level });
|
if (isRecipesPage) {
|
||||||
|
await updateRecipeMetadata(filePath, { preview_nsfw_level: level });
|
||||||
|
} else {
|
||||||
|
await getModelApiClient().saveModelMetadata(filePath, { preview_nsfw_level: level });
|
||||||
|
}
|
||||||
successCount++;
|
successCount++;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
failureCount++;
|
failureCount++;
|
||||||
@@ -1958,9 +1980,31 @@ export class BulkManager {
|
|||||||
// Remove visual feedback class
|
// Remove visual feedback class
|
||||||
document.body.classList.remove('marquee-selecting');
|
document.body.classList.remove('marquee-selecting');
|
||||||
|
|
||||||
|
// Compute the actual drag box size in document coordinates, matching how
|
||||||
|
// updateMarqueeSelectionFromPosition tracks the rectangle. Client-space
|
||||||
|
// size would wrongly flag auto-scroll marquees (tiny pointer movement,
|
||||||
|
// large document-space box) as accidental clicks.
|
||||||
|
const container = document.querySelector('.page-content');
|
||||||
|
const scrollX = container?.scrollLeft || 0;
|
||||||
|
const scrollY = container?.scrollTop || 0;
|
||||||
|
const dragWidth = Math.abs((e.clientX + scrollX) - this.marqueeStartDoc.x);
|
||||||
|
const dragHeight = Math.abs((e.clientY + scrollY) - this.marqueeStartDoc.y);
|
||||||
|
const isTinyMarquee = dragWidth < this.minMarqueeSize && dragHeight < this.minMarqueeSize;
|
||||||
|
|
||||||
// Get selection count
|
// Get selection count
|
||||||
const selectionCount = state.selectedModels.size;
|
const selectionCount = state.selectedModels.size;
|
||||||
|
|
||||||
|
// A tiny box (e.g. click jitter that happened to graze a card) is treated
|
||||||
|
// as an accidental click: undo any selection and leave bulk mode.
|
||||||
|
if (isTinyMarquee) {
|
||||||
|
this.clearSelection();
|
||||||
|
if (state.bulkMode) {
|
||||||
|
this.toggleBulkMode();
|
||||||
|
}
|
||||||
|
this.initialSelectedModels.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If no models were selected, exit bulk mode
|
// If no models were selected, exit bulk mode
|
||||||
if (selectionCount === 0) {
|
if (selectionCount === 0) {
|
||||||
if (state.bulkMode) {
|
if (state.bulkMode) {
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ import { getModelApiClient, resetAndReload } from '../api/modelApiFactory.js';
|
|||||||
import { getStorageItem, setStorageItem } from '../utils/storageHelpers.js';
|
import { getStorageItem, setStorageItem } from '../utils/storageHelpers.js';
|
||||||
import { FolderTreeManager } from '../components/FolderTreeManager.js';
|
import { FolderTreeManager } from '../components/FolderTreeManager.js';
|
||||||
import { translate } from '../utils/i18nHelpers.js';
|
import { translate } from '../utils/i18nHelpers.js';
|
||||||
import { extractCivitaiModelUrlParts } from '../utils/civitaiUtils.js';
|
import { buildCivitaiUrl, extractCivitaiModelUrlParts, normalizeCivitaiPageHost } from '../utils/civitaiUtils.js';
|
||||||
import { formatFileSize } from '../utils/formatters.js';
|
import { formatFileSize } from '../utils/formatters.js';
|
||||||
|
import { showDownloadBatchSummary } from '../components/DownloadBatchSummaryModal.js';
|
||||||
|
|
||||||
export class DownloadManager {
|
export class DownloadManager {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -158,6 +159,7 @@ export class DownloadManager {
|
|||||||
this.modelVersionId = null;
|
this.modelVersionId = null;
|
||||||
this.source = null;
|
this.source = null;
|
||||||
this.selectedFile = null;
|
this.selectedFile = null;
|
||||||
|
this._isDiffusionModel = false;
|
||||||
|
|
||||||
this.selectedFolder = '';
|
this.selectedFolder = '';
|
||||||
this.batchModels = [];
|
this.batchModels = [];
|
||||||
@@ -233,6 +235,9 @@ export class DownloadManager {
|
|||||||
|
|
||||||
if (this.modelVersionId) {
|
if (this.modelVersionId) {
|
||||||
this.currentVersion = this.versions.find(v => v.id.toString() === this.modelVersionId);
|
this.currentVersion = this.versions.find(v => v.id.toString() === this.modelVersionId);
|
||||||
|
} else {
|
||||||
|
// No explicit version id in the URL → default to the latest version (Civitai returns newest first)
|
||||||
|
this.currentVersion = this.versions[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showVersionStep();
|
this.showVersionStep();
|
||||||
@@ -426,6 +431,9 @@ export class DownloadManager {
|
|||||||
await this.retrieveVersionsForModel(this.modelId, this.source);
|
await this.retrieveVersionsForModel(this.modelId, this.source);
|
||||||
if (this.modelVersionId) {
|
if (this.modelVersionId) {
|
||||||
this.currentVersion = this.versions.find(v => v.id.toString() === this.modelVersionId);
|
this.currentVersion = this.versions.find(v => v.id.toString() === this.modelVersionId);
|
||||||
|
} else {
|
||||||
|
// No explicit version id → default to the latest version (Civitai returns newest first)
|
||||||
|
this.currentVersion = this.versions[0];
|
||||||
}
|
}
|
||||||
this.showVersionStep();
|
this.showVersionStep();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -746,7 +754,7 @@ export class DownloadManager {
|
|||||||
this.selectedFile?.id, this.selectedFile?.name, this.selectedFile?.type, this.selectedFile?.metadata);
|
this.selectedFile?.id, this.selectedFile?.name, this.selectedFile?.type, this.selectedFile?.metadata);
|
||||||
|
|
||||||
document.getElementById('fileSelectionStep').style.display = 'none';
|
document.getElementById('fileSelectionStep').style.display = 'none';
|
||||||
document.getElementById('locationStep').style.display = 'block';
|
document.getElementById('downloadLocationStep').style.display = 'block';
|
||||||
this.proceedToLocationContent();
|
this.proceedToLocationContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -780,31 +788,47 @@ export class DownloadManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
document.querySelectorAll('.download-step').forEach(step => step.style.display = 'none');
|
document.querySelectorAll('.download-step').forEach(step => step.style.display = 'none');
|
||||||
document.getElementById('locationStep').style.display = 'block';
|
document.getElementById('downloadLocationStep').style.display = 'block';
|
||||||
await this.proceedToLocationContent();
|
await this.proceedToLocationContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
async proceedToLocationContent() {
|
async proceedToLocationContent() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Fetch model roots
|
const _isDiffusionModel = this.selectedFile
|
||||||
const rootsData = await this.apiClient.fetchModelRoots();
|
? (this.selectedFile.type === 'UNet' || this.selectedFile.type === 'Diffusion Model')
|
||||||
|
: (this.currentVersion?.files || []).some(
|
||||||
|
f => f.type === 'UNet' || f.type === 'Diffusion Model'
|
||||||
|
);
|
||||||
|
this._isDiffusionModel = _isDiffusionModel;
|
||||||
|
|
||||||
|
let rootsData;
|
||||||
|
if (this._isDiffusionModel && this.apiClient.modelType === 'checkpoints') {
|
||||||
|
rootsData = await this.apiClient.fetchModelRoots('diffusion_model');
|
||||||
|
} else {
|
||||||
|
rootsData = await this.apiClient.fetchModelRoots();
|
||||||
|
}
|
||||||
const modelRoot = document.getElementById('modelRoot');
|
const modelRoot = document.getElementById('modelRoot');
|
||||||
modelRoot.innerHTML = rootsData.roots.map(root =>
|
modelRoot.innerHTML = rootsData.roots.map(root =>
|
||||||
`<option value="${root}">${root}</option>`
|
`<option value="${root}">${root}</option>`
|
||||||
).join('');
|
).join('');
|
||||||
|
|
||||||
// Set default root if available
|
const singularType = this._isDiffusionModel
|
||||||
const singularType = this.apiClient.modelType.replace(/s$/, '');
|
? 'unet'
|
||||||
|
: this.apiClient.modelType.replace(/s$/, '');
|
||||||
const defaultRootKey = `default_${singularType}_root`;
|
const defaultRootKey = `default_${singularType}_root`;
|
||||||
const defaultRoot = state.global.settings[defaultRootKey];
|
const defaultRoot = state.global.settings[defaultRootKey];
|
||||||
console.log(`Default root for ${this.apiClient.modelType}:`, defaultRoot);
|
console.log(`Default root for ${singularType}:`, defaultRoot);
|
||||||
console.log('Available roots:', rootsData.roots);
|
console.log('Available roots:', rootsData.roots);
|
||||||
if (defaultRoot && rootsData.roots.includes(defaultRoot)) {
|
if (defaultRoot && rootsData.roots.includes(defaultRoot)) {
|
||||||
console.log(`Setting default root: ${defaultRoot}`);
|
console.log(`Setting default root: ${defaultRoot}`);
|
||||||
modelRoot.value = defaultRoot;
|
modelRoot.value = defaultRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const subtypeDisplay = this._isDiffusionModel ? 'Diffusion Model' : this.apiClient.apiConfig.config.displayName;
|
||||||
|
document.getElementById('modelRootLabel').textContent =
|
||||||
|
translate('modals.download.selectTypeRoot', { type: subtypeDisplay });
|
||||||
|
|
||||||
// Set autocomplete="off" on folderPath input
|
// Set autocomplete="off" on folderPath input
|
||||||
const folderPathInput = document.getElementById('folderPath');
|
const folderPathInput = document.getElementById('folderPath');
|
||||||
if (folderPathInput) {
|
if (folderPathInput) {
|
||||||
@@ -861,6 +885,26 @@ export class DownloadManager {
|
|||||||
this.updateTargetPath();
|
this.updateTargetPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Synthesize a clickable URL for a single-download failure entry.
|
||||||
|
* Single downloads have no pasted URL, so the modal link is derived from
|
||||||
|
* the model/version ids (CivitAI) or the HF repo/file (HuggingFace).
|
||||||
|
*/
|
||||||
|
_buildSingleItemUrl({ modelId, versionId, source, repo = null, filename = null }) {
|
||||||
|
if (source === 'huggingface' && repo) {
|
||||||
|
const base = `https://huggingface.co/${encodeURI(repo)}`;
|
||||||
|
return filename ? `${base}/blob/${encodeURI('main')}/${encodeURI(filename)}` : base;
|
||||||
|
}
|
||||||
|
if (modelId) {
|
||||||
|
return buildCivitaiUrl({
|
||||||
|
modelId,
|
||||||
|
versionId,
|
||||||
|
host: normalizeCivitaiPageHost(state?.global?.settings?.civitai_host),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
async executeDownloadWithProgress({
|
async executeDownloadWithProgress({
|
||||||
modelId,
|
modelId,
|
||||||
versionId,
|
versionId,
|
||||||
@@ -879,6 +923,7 @@ export class DownloadManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const displayName = versionName || `#${versionId}`;
|
const displayName = versionName || `#${versionId}`;
|
||||||
|
const retryParams = { modelId, versionId, versionName, modelRoot, targetFolder, useDefaultPaths, source, fileParams, closeModal: false };
|
||||||
let ws = null;
|
let ws = null;
|
||||||
let updateProgress = () => { };
|
let updateProgress = () => { };
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
@@ -967,6 +1012,26 @@ export class DownloadManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!response?.success) {
|
||||||
|
this.loadingManager.setStatus(translate('modals.download.status.finalizing'));
|
||||||
|
showDownloadBatchSummary({
|
||||||
|
total: 1,
|
||||||
|
completed: 0,
|
||||||
|
failedItems: [{
|
||||||
|
item: {
|
||||||
|
modelId,
|
||||||
|
versionId,
|
||||||
|
source,
|
||||||
|
url: this._buildSingleItemUrl({ modelId, versionId, source }),
|
||||||
|
},
|
||||||
|
error: response?.error || 'Unknown error',
|
||||||
|
name: displayName,
|
||||||
|
}],
|
||||||
|
onRetry: () => this.executeDownloadWithProgress(retryParams),
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
showToast('toast.loras.downloadCompleted', {}, 'success');
|
showToast('toast.loras.downloadCompleted', {}, 'success');
|
||||||
|
|
||||||
if (closeModal) {
|
if (closeModal) {
|
||||||
@@ -1001,7 +1066,21 @@ export class DownloadManager {
|
|||||||
console.log('Download cancelled by user:', downloadId);
|
console.log('Download cancelled by user:', downloadId);
|
||||||
} else {
|
} else {
|
||||||
console.error('Failed to download model version:', error);
|
console.error('Failed to download model version:', error);
|
||||||
showToast('toast.downloads.downloadError', { message: error?.message }, 'error');
|
showDownloadBatchSummary({
|
||||||
|
total: 1,
|
||||||
|
completed: 0,
|
||||||
|
failedItems: [{
|
||||||
|
item: {
|
||||||
|
modelId,
|
||||||
|
versionId,
|
||||||
|
source,
|
||||||
|
url: this._buildSingleItemUrl({ modelId, versionId, source }),
|
||||||
|
},
|
||||||
|
error: error?.message || 'Unknown error',
|
||||||
|
name: displayName,
|
||||||
|
}],
|
||||||
|
onRetry: () => this.executeDownloadWithProgress(retryParams),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -1016,14 +1095,16 @@ export class DownloadManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async _downloadHfSingle({ modelRoot, targetFolder, useDefaultPaths }) {
|
async _downloadHfSingle({ modelRoot, targetFolder, useDefaultPaths, files = null }) {
|
||||||
modalManager.closeModal('downloadModal');
|
modalManager.closeModal('downloadModal');
|
||||||
this.loadingManager.restoreProgressBar();
|
this.loadingManager.restoreProgressBar();
|
||||||
const totalFiles = this.hfSelectedFiles.length;
|
const filesToDownload = files || this.hfSelectedFiles;
|
||||||
|
const totalFiles = filesToDownload.length;
|
||||||
const updateProgress = this.loadingManager.showDownloadProgress(totalFiles);
|
const updateProgress = this.loadingManager.showDownloadProgress(totalFiles);
|
||||||
|
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
let currentDownloadId = null;
|
let currentDownloadId = null;
|
||||||
|
const failedFiles = [];
|
||||||
|
|
||||||
this.loadingManager.showCancelButton(async () => {
|
this.loadingManager.showCancelButton(async () => {
|
||||||
if (cancelled) return;
|
if (cancelled) return;
|
||||||
@@ -1042,7 +1123,7 @@ export class DownloadManager {
|
|||||||
for (let i = 0; i < totalFiles; i++) {
|
for (let i = 0; i < totalFiles; i++) {
|
||||||
if (cancelled) break;
|
if (cancelled) break;
|
||||||
|
|
||||||
const filename = this.hfSelectedFiles[i];
|
const filename = filesToDownload[i];
|
||||||
updateProgress(0, completedDownloads, filename);
|
updateProgress(0, completedDownloads, filename);
|
||||||
this.loadingManager.setStatus(`Downloading ${filename}...`);
|
this.loadingManager.setStatus(`Downloading ${filename}...`);
|
||||||
|
|
||||||
@@ -1088,6 +1169,31 @@ export class DownloadManager {
|
|||||||
if (response?.success) {
|
if (response?.success) {
|
||||||
completedDownloads++;
|
completedDownloads++;
|
||||||
updateProgress(100, completedDownloads, filename);
|
updateProgress(100, completedDownloads, filename);
|
||||||
|
} else {
|
||||||
|
failedFiles.push({
|
||||||
|
item: {
|
||||||
|
source: 'huggingface',
|
||||||
|
repo: this.hfRepoId,
|
||||||
|
filename,
|
||||||
|
url: this._buildSingleItemUrl({ source: 'huggingface', repo: this.hfRepoId, filename }),
|
||||||
|
},
|
||||||
|
error: response?.error || 'Unknown error',
|
||||||
|
name: filename,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (!cancelled) {
|
||||||
|
console.error(`Failed to download HF file ${filename}:`, err);
|
||||||
|
failedFiles.push({
|
||||||
|
item: {
|
||||||
|
source: 'huggingface',
|
||||||
|
repo: this.hfRepoId,
|
||||||
|
filename,
|
||||||
|
url: this._buildSingleItemUrl({ source: 'huggingface', repo: this.hfRepoId, filename }),
|
||||||
|
},
|
||||||
|
error: err?.message || 'Unknown error',
|
||||||
|
name: filename,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
ws.close();
|
ws.close();
|
||||||
@@ -1097,11 +1203,27 @@ export class DownloadManager {
|
|||||||
if (cancelled) {
|
if (cancelled) {
|
||||||
showToast('toast.downloads.downloadStopped', {}, 'info',
|
showToast('toast.downloads.downloadStopped', {}, 'info',
|
||||||
`Download cancelled. ${completedDownloads} item(s) completed.`);
|
`Download cancelled. ${completedDownloads} item(s) completed.`);
|
||||||
} else {
|
|
||||||
showToast('toast.loras.downloadCompleted', {}, 'success');
|
|
||||||
}
|
|
||||||
await resetAndReload(true);
|
await resetAndReload(true);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
if (failedFiles.length === 0) {
|
||||||
|
showToast('toast.loras.downloadCompleted', {}, 'success');
|
||||||
|
await resetAndReload(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
showDownloadBatchSummary({
|
||||||
|
total: totalFiles,
|
||||||
|
completed: completedDownloads,
|
||||||
|
failedItems: failedFiles,
|
||||||
|
onRetry: () => this._downloadHfSingle({
|
||||||
|
modelRoot,
|
||||||
|
targetFolder,
|
||||||
|
useDefaultPaths,
|
||||||
|
files: failedFiles.map((f) => f.item.filename),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
await resetAndReload(true);
|
||||||
|
return false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
console.error('Failed to download HF model:', error);
|
console.error('Failed to download HF model:', error);
|
||||||
@@ -1441,7 +1563,7 @@ export class DownloadManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
backToVersions() {
|
backToVersions() {
|
||||||
document.getElementById('locationStep').style.display = 'none';
|
document.getElementById('downloadLocationStep').style.display = 'none';
|
||||||
if (this.isBatchMode) {
|
if (this.isBatchMode) {
|
||||||
document.getElementById('batchPreviewStep').style.display = 'block';
|
document.getElementById('batchPreviewStep').style.display = 'block';
|
||||||
} else {
|
} else {
|
||||||
@@ -1531,6 +1653,10 @@ export class DownloadManager {
|
|||||||
|
|
||||||
modalManager.closeModal('downloadModal');
|
modalManager.closeModal('downloadModal');
|
||||||
|
|
||||||
|
return this.executeBatchDownload(downloadItems, { modelRoot, targetFolder, useDefaultPaths });
|
||||||
|
}
|
||||||
|
|
||||||
|
async executeBatchDownload(downloadItems, { modelRoot, targetFolder, useDefaultPaths }) {
|
||||||
const batchDownloadId = Date.now().toString();
|
const batchDownloadId = Date.now().toString();
|
||||||
const wsProtocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
|
const wsProtocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
|
||||||
const ws = new WebSocket(`${wsProtocol}${window.location.host}/ws/download-progress?id=${batchDownloadId}`);
|
const ws = new WebSocket(`${wsProtocol}${window.location.host}/ws/download-progress?id=${batchDownloadId}`);
|
||||||
@@ -1541,6 +1667,7 @@ export class DownloadManager {
|
|||||||
let completedDownloads = 0;
|
let completedDownloads = 0;
|
||||||
let failedDownloads = 0;
|
let failedDownloads = 0;
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
|
const failedItems = [];
|
||||||
|
|
||||||
loadingManager.showCancelButton(async () => {
|
loadingManager.showCancelButton(async () => {
|
||||||
if (cancelled) return;
|
if (cancelled) return;
|
||||||
@@ -1641,6 +1768,7 @@ export class DownloadManager {
|
|||||||
|
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
failedDownloads++;
|
failedDownloads++;
|
||||||
|
failedItems.push({ item, error: response.error || 'Unknown error', name });
|
||||||
} else {
|
} else {
|
||||||
completedDownloads++;
|
completedDownloads++;
|
||||||
updateProgress(100, completedDownloads, '');
|
updateProgress(100, completedDownloads, '');
|
||||||
@@ -1649,6 +1777,7 @@ export class DownloadManager {
|
|||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
console.error(`Failed to download ${name}:`, err);
|
console.error(`Failed to download ${name}:`, err);
|
||||||
failedDownloads++;
|
failedDownloads++;
|
||||||
|
failedItems.push({ item, error: err?.message || 'Unknown error', name });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1662,10 +1791,15 @@ export class DownloadManager {
|
|||||||
} else if (failedDownloads === 0) {
|
} else if (failedDownloads === 0) {
|
||||||
showToast('toast.loras.allDownloadSuccessful', { count: completedDownloads }, 'success');
|
showToast('toast.loras.allDownloadSuccessful', { count: completedDownloads }, 'success');
|
||||||
} else {
|
} else {
|
||||||
showToast('toast.loras.downloadPartialSuccess', {
|
showDownloadBatchSummary({
|
||||||
completed: completedDownloads,
|
|
||||||
total: downloadItems.length,
|
total: downloadItems.length,
|
||||||
}, 'warning');
|
completed: completedDownloads,
|
||||||
|
failedItems,
|
||||||
|
onRetry: (failed) => this.executeBatchDownload(
|
||||||
|
failed.map((f) => f.item),
|
||||||
|
{ modelRoot, targetFolder, useDefaultPaths }
|
||||||
|
),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await resetAndReload(true);
|
await resetAndReload(true);
|
||||||
@@ -1776,13 +1910,15 @@ export class DownloadManager {
|
|||||||
const modelRoot = document.getElementById('modelRoot').value;
|
const modelRoot = document.getElementById('modelRoot').value;
|
||||||
const config = this.apiClient.apiConfig.config;
|
const config = this.apiClient.apiConfig.config;
|
||||||
|
|
||||||
let fullPath = modelRoot || translate('modals.download.selectTypeRoot', { type: config.displayName });
|
const subtypeDisplay = this._isDiffusionModel ? 'Diffusion Model' : config.displayName;
|
||||||
|
let fullPath = modelRoot || translate('modals.download.selectTypeRoot', { type: subtypeDisplay });
|
||||||
|
|
||||||
if (modelRoot) {
|
if (modelRoot) {
|
||||||
if (this.useDefaultPath) {
|
if (this.useDefaultPath) {
|
||||||
// Show actual template path
|
|
||||||
try {
|
try {
|
||||||
const singularType = this.apiClient.modelType.replace(/s$/, '');
|
const singularType = this._isDiffusionModel
|
||||||
|
? 'unet'
|
||||||
|
: this.apiClient.modelType.replace(/s$/, '');
|
||||||
const templates = state.global.settings.download_path_templates;
|
const templates = state.global.settings.download_path_templates;
|
||||||
const template = templates[singularType];
|
const template = templates[singularType];
|
||||||
fullPath += `/${template}`;
|
fullPath += `/${template}`;
|
||||||
|
|||||||
@@ -729,10 +729,12 @@ export class FilterManager {
|
|||||||
const pageState = getCurrentPageState();
|
const pageState = getCurrentPageState();
|
||||||
const storageKey = `${this.currentPage}_filters`;
|
const storageKey = `${this.currentPage}_filters`;
|
||||||
|
|
||||||
// Save filters to localStorage (exclude EMPTY_WILDCARD_MARKER)
|
// Save filters to localStorage (exclude EMPTY_WILDCARD_MARKER and transient search)
|
||||||
const filtersSnapshot = this.cloneFilters();
|
const filtersSnapshot = this.cloneFilters();
|
||||||
// Don't persist EMPTY_WILDCARD_MARKER - it's a runtime-only marker
|
// Don't persist EMPTY_WILDCARD_MARKER - it's a runtime-only marker
|
||||||
filtersSnapshot.baseModel = filtersSnapshot.baseModel.filter(m => m !== EMPTY_WILDCARD_MARKER);
|
filtersSnapshot.baseModel = filtersSnapshot.baseModel.filter(m => m !== EMPTY_WILDCARD_MARKER);
|
||||||
|
// Don't persist search - it's transient and managed by SearchManager
|
||||||
|
delete filtersSnapshot.search;
|
||||||
setStorageItem(storageKey, filtersSnapshot);
|
setStorageItem(storageKey, filtersSnapshot);
|
||||||
|
|
||||||
// Update state with current filters
|
// Update state with current filters
|
||||||
@@ -984,6 +986,7 @@ export class FilterManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cloneFilters() {
|
cloneFilters() {
|
||||||
|
const pageState = getCurrentPageState();
|
||||||
return {
|
return {
|
||||||
...this.filters,
|
...this.filters,
|
||||||
baseModel: [...(this.filters.baseModel || [])],
|
baseModel: [...(this.filters.baseModel || [])],
|
||||||
@@ -991,7 +994,8 @@ export class FilterManager {
|
|||||||
autoTags: { ...(this.filters.autoTags || {}) },
|
autoTags: { ...(this.filters.autoTags || {}) },
|
||||||
license: { ...(this.filters.license || {}) },
|
license: { ...(this.filters.license || {}) },
|
||||||
modelTypes: [...(this.filters.modelTypes || [])],
|
modelTypes: [...(this.filters.modelTypes || [])],
|
||||||
tagLogic: this.filters.tagLogic || 'any'
|
tagLogic: this.filters.tagLogic || 'any',
|
||||||
|
search: pageState?.filters?.search ?? ''
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { state } from '../state/index.js';
|
|||||||
// Constants for preset management
|
// Constants for preset management
|
||||||
const PRESETS_STORAGE_VERSION = 'v1';
|
const PRESETS_STORAGE_VERSION = 'v1';
|
||||||
const MAX_PRESET_NAME_LENGTH = 30;
|
const MAX_PRESET_NAME_LENGTH = 30;
|
||||||
const MAX_PRESETS_COUNT = 10;
|
|
||||||
|
|
||||||
// Marker for when wildcard patterns resolve to no matches
|
// Marker for when wildcard patterns resolve to no matches
|
||||||
// This ensures we return empty results instead of all models
|
// This ensures we return empty results instead of all models
|
||||||
@@ -362,15 +361,6 @@ export class FilterPresetManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (presets.length >= MAX_PRESETS_COUNT) {
|
|
||||||
showToast(
|
|
||||||
translate('toast.error.maxPresetsReached', { max: MAX_PRESETS_COUNT }, `Maximum ${MAX_PRESETS_COUNT} presets allowed. Delete one to add more.`),
|
|
||||||
{},
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const preset = {
|
const preset = {
|
||||||
name: trimmedName,
|
name: trimmedName,
|
||||||
filters: this.filterManager.cloneFilters(),
|
filters: this.filterManager.cloneFilters(),
|
||||||
@@ -613,17 +603,6 @@ export class FilterPresetManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check max presets limit before showing input
|
|
||||||
const presets = this.loadPresets();
|
|
||||||
if (presets.length >= MAX_PRESETS_COUNT) {
|
|
||||||
showToast(
|
|
||||||
translate('toast.error.maxPresetsReached', { max: MAX_PRESETS_COUNT }, `Maximum ${MAX_PRESETS_COUNT} presets allowed. Delete one to add more.`),
|
|
||||||
{},
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.isInlineNamingActive = true;
|
this.isInlineNamingActive = true;
|
||||||
|
|
||||||
const presetsContainer = document.getElementById('filterPresets');
|
const presetsContainer = document.getElementById('filterPresets');
|
||||||
|
|||||||
@@ -1017,6 +1017,12 @@ export class SettingsManager {
|
|||||||
displayDensitySelect.value = state.global.settings.display_density || 'default';
|
displayDensitySelect.value = state.global.settings.display_density || 'default';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set recipes layout setting
|
||||||
|
const recipesLayoutSelect = document.getElementById('recipesLayout');
|
||||||
|
if (recipesLayoutSelect) {
|
||||||
|
recipesLayoutSelect.value = state.global.settings.recipes_layout || 'grid';
|
||||||
|
}
|
||||||
|
|
||||||
// Set card info display setting
|
// Set card info display setting
|
||||||
const cardInfoDisplaySelect = document.getElementById('cardInfoDisplay');
|
const cardInfoDisplaySelect = document.getElementById('cardInfoDisplay');
|
||||||
if (cardInfoDisplaySelect) {
|
if (cardInfoDisplaySelect) {
|
||||||
@@ -1517,11 +1523,20 @@ export class SettingsManager {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showNoRootsPlaceholder(select) {
|
||||||
|
select.innerHTML = '';
|
||||||
|
const option = document.createElement('option');
|
||||||
|
option.value = '';
|
||||||
|
option.textContent = translate('settings.folderSettings.noDefault', {}, 'No Default');
|
||||||
|
select.appendChild(option);
|
||||||
|
select.disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
async loadLoraRoots() {
|
async loadLoraRoots() {
|
||||||
try {
|
|
||||||
const defaultLoraRootSelect = document.getElementById('defaultLoraRoot');
|
const defaultLoraRootSelect = document.getElementById('defaultLoraRoot');
|
||||||
if (!defaultLoraRootSelect) return;
|
if (!defaultLoraRootSelect) return;
|
||||||
|
|
||||||
|
try {
|
||||||
// Fetch lora roots
|
// Fetch lora roots
|
||||||
const response = await fetch('/api/lm/loras/roots');
|
const response = await fetch('/api/lm/loras/roots');
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@@ -1530,10 +1545,12 @@ export class SettingsManager {
|
|||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (!data.roots || data.roots.length === 0) {
|
if (!data.roots || data.roots.length === 0) {
|
||||||
throw new Error('No LoRA roots found');
|
this.showNoRootsPlaceholder(defaultLoraRootSelect);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultLoraRootSelect.innerHTML = '';
|
defaultLoraRootSelect.innerHTML = '';
|
||||||
|
defaultLoraRootSelect.disabled = false;
|
||||||
|
|
||||||
// Add options for each root
|
// Add options for each root
|
||||||
data.roots.forEach(root => {
|
data.roots.forEach(root => {
|
||||||
@@ -1548,15 +1565,16 @@ export class SettingsManager {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading LoRA roots:', error);
|
console.error('Error loading LoRA roots:', error);
|
||||||
|
this.showNoRootsPlaceholder(defaultLoraRootSelect);
|
||||||
showToast('toast.settings.loraRootsFailed', { message: error.message }, 'error');
|
showToast('toast.settings.loraRootsFailed', { message: error.message }, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadCheckpointRoots() {
|
async loadCheckpointRoots() {
|
||||||
try {
|
|
||||||
const defaultCheckpointRootSelect = document.getElementById('defaultCheckpointRoot');
|
const defaultCheckpointRootSelect = document.getElementById('defaultCheckpointRoot');
|
||||||
if (!defaultCheckpointRootSelect) return;
|
if (!defaultCheckpointRootSelect) return;
|
||||||
|
|
||||||
|
try {
|
||||||
// Fetch checkpoint roots (checkpoint paths only, not unet)
|
// Fetch checkpoint roots (checkpoint paths only, not unet)
|
||||||
const response = await fetch('/api/lm/checkpoints/checkpoints_roots');
|
const response = await fetch('/api/lm/checkpoints/checkpoints_roots');
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@@ -1565,10 +1583,12 @@ export class SettingsManager {
|
|||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (!data.roots || data.roots.length === 0) {
|
if (!data.roots || data.roots.length === 0) {
|
||||||
throw new Error('No checkpoint roots found');
|
this.showNoRootsPlaceholder(defaultCheckpointRootSelect);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultCheckpointRootSelect.innerHTML = '';
|
defaultCheckpointRootSelect.innerHTML = '';
|
||||||
|
defaultCheckpointRootSelect.disabled = false;
|
||||||
|
|
||||||
// Add options for each root
|
// Add options for each root
|
||||||
data.roots.forEach(root => {
|
data.roots.forEach(root => {
|
||||||
@@ -1583,15 +1603,16 @@ export class SettingsManager {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading checkpoint roots:', error);
|
console.error('Error loading checkpoint roots:', error);
|
||||||
|
this.showNoRootsPlaceholder(defaultCheckpointRootSelect);
|
||||||
showToast('toast.settings.checkpointRootsFailed', { message: error.message }, 'error');
|
showToast('toast.settings.checkpointRootsFailed', { message: error.message }, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadUnetRoots() {
|
async loadUnetRoots() {
|
||||||
try {
|
|
||||||
const defaultUnetRootSelect = document.getElementById('defaultUnetRoot');
|
const defaultUnetRootSelect = document.getElementById('defaultUnetRoot');
|
||||||
if (!defaultUnetRootSelect) return;
|
if (!defaultUnetRootSelect) return;
|
||||||
|
|
||||||
|
try {
|
||||||
// Fetch unet roots (diffusion model paths only)
|
// Fetch unet roots (diffusion model paths only)
|
||||||
const response = await fetch('/api/lm/checkpoints/unet_roots');
|
const response = await fetch('/api/lm/checkpoints/unet_roots');
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@@ -1600,10 +1621,12 @@ export class SettingsManager {
|
|||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (!data.roots || data.roots.length === 0) {
|
if (!data.roots || data.roots.length === 0) {
|
||||||
throw new Error('No diffusion model roots found');
|
this.showNoRootsPlaceholder(defaultUnetRootSelect);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultUnetRootSelect.innerHTML = '';
|
defaultUnetRootSelect.innerHTML = '';
|
||||||
|
defaultUnetRootSelect.disabled = false;
|
||||||
|
|
||||||
// Add options for each root
|
// Add options for each root
|
||||||
data.roots.forEach(root => {
|
data.roots.forEach(root => {
|
||||||
@@ -1618,15 +1641,16 @@ export class SettingsManager {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading diffusion model roots:', error);
|
console.error('Error loading diffusion model roots:', error);
|
||||||
|
this.showNoRootsPlaceholder(defaultUnetRootSelect);
|
||||||
showToast('toast.settings.unetRootsFailed', { message: error.message }, 'error');
|
showToast('toast.settings.unetRootsFailed', { message: error.message }, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadEmbeddingRoots() {
|
async loadEmbeddingRoots() {
|
||||||
try {
|
|
||||||
const defaultEmbeddingRootSelect = document.getElementById('defaultEmbeddingRoot');
|
const defaultEmbeddingRootSelect = document.getElementById('defaultEmbeddingRoot');
|
||||||
if (!defaultEmbeddingRootSelect) return;
|
if (!defaultEmbeddingRootSelect) return;
|
||||||
|
|
||||||
|
try {
|
||||||
// Fetch embedding roots
|
// Fetch embedding roots
|
||||||
const response = await fetch('/api/lm/embeddings/roots');
|
const response = await fetch('/api/lm/embeddings/roots');
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@@ -1635,10 +1659,12 @@ export class SettingsManager {
|
|||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (!data.roots || data.roots.length === 0) {
|
if (!data.roots || data.roots.length === 0) {
|
||||||
throw new Error('No embedding roots found');
|
this.showNoRootsPlaceholder(defaultEmbeddingRootSelect);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultEmbeddingRootSelect.innerHTML = '';
|
defaultEmbeddingRootSelect.innerHTML = '';
|
||||||
|
defaultEmbeddingRootSelect.disabled = false;
|
||||||
|
|
||||||
// Add options for each root
|
// Add options for each root
|
||||||
data.roots.forEach(root => {
|
data.roots.forEach(root => {
|
||||||
@@ -1653,6 +1679,7 @@ export class SettingsManager {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading embedding roots:', error);
|
console.error('Error loading embedding roots:', error);
|
||||||
|
this.showNoRootsPlaceholder(defaultEmbeddingRootSelect);
|
||||||
showToast('toast.settings.embeddingRootsFailed', { message: error.message }, 'error');
|
showToast('toast.settings.embeddingRootsFailed', { message: error.message }, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2267,6 +2294,13 @@ export class SettingsManager {
|
|||||||
// Apply frontend settings immediately
|
// Apply frontend settings immediately
|
||||||
this.applyFrontendSettings();
|
this.applyFrontendSettings();
|
||||||
|
|
||||||
|
// Dispatch layout change event; the scroller instance is about to be rebuilt,
|
||||||
|
// so calculateLayout() must NOT run on the old instance here
|
||||||
|
if (settingKey === 'recipes_layout') {
|
||||||
|
window.dispatchEvent(new CustomEvent('lm:recipes-layout-changed'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Recalculate layout when display density changes
|
// Recalculate layout when display density changes
|
||||||
if (settingKey === 'display_density' && state.virtualScroller) {
|
if (settingKey === 'display_density' && state.virtualScroller) {
|
||||||
state.virtualScroller.calculateLayout();
|
state.virtualScroller.calculateLayout();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
setStoredVersionInfo,
|
setStoredVersionInfo,
|
||||||
isVersionMatch
|
isVersionMatch
|
||||||
} from '../utils/storageHelpers.js';
|
} from '../utils/storageHelpers.js';
|
||||||
|
import { state } from '../state/index.js';
|
||||||
import { bannerService } from './BannerService.js';
|
import { bannerService } from './BannerService.js';
|
||||||
import { translate } from '../utils/i18nHelpers.js';
|
import { translate } from '../utils/i18nHelpers.js';
|
||||||
|
|
||||||
@@ -24,7 +25,11 @@ export class UpdateService {
|
|||||||
this.updateNotificationsEnabled = getStorageItem('show_update_notifications', true);
|
this.updateNotificationsEnabled = getStorageItem('show_update_notifications', true);
|
||||||
this.lastCheckTime = parseInt(getStorageItem('last_update_check') || '0');
|
this.lastCheckTime = parseInt(getStorageItem('last_update_check') || '0');
|
||||||
this.isUpdating = false;
|
this.isUpdating = false;
|
||||||
this.nightlyMode = getStorageItem('nightly_updates', false);
|
this.channelMode = null;
|
||||||
|
this.hasGit = false;
|
||||||
|
this.nightlyNotifyDate = getStorageItem('nightly_notify_date', '');
|
||||||
|
this.nightlyBadgeShown = false;
|
||||||
|
this.progressKeepVisible = false;
|
||||||
this.currentVersionInfo = null;
|
this.currentVersionInfo = null;
|
||||||
this.versionMismatch = false;
|
this.versionMismatch = false;
|
||||||
this.activeNotificationTab = 'updates';
|
this.activeNotificationTab = 'updates';
|
||||||
@@ -49,43 +54,180 @@ export class UpdateService {
|
|||||||
updateBtn.addEventListener('click', () => this.performUpdate());
|
updateBtn.addEventListener('click', () => this.performUpdate());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register event listener for nightly update toggle
|
this.wireChannelButtons();
|
||||||
const nightlyCheckbox = document.getElementById('nightlyUpdateToggle');
|
|
||||||
if (nightlyCheckbox) {
|
|
||||||
nightlyCheckbox.checked = this.nightlyMode;
|
|
||||||
nightlyCheckbox.addEventListener('change', (e) => {
|
|
||||||
this.nightlyMode = e.target.checked;
|
|
||||||
setStorageItem('nightly_updates', e.target.checked);
|
|
||||||
this.updateNightlyWarning();
|
|
||||||
this.updateModalContent();
|
|
||||||
// Re-check for updates when switching channels
|
|
||||||
this.manualCheckForUpdates();
|
|
||||||
});
|
|
||||||
this.updateNightlyWarning();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setupNotificationCenter();
|
this.setupNotificationCenter();
|
||||||
window.addEventListener('lm:banner-history-updated', this.handleBannerHistoryUpdated);
|
window.addEventListener('lm:banner-history-updated', this.handleBannerHistoryUpdated);
|
||||||
this.updateTabBadges();
|
this.updateTabBadges();
|
||||||
|
|
||||||
// Perform update check if needed
|
// Perform update check if needed
|
||||||
|
this.checkVersionInfo().then(() => {
|
||||||
this.checkForUpdates().then(() => {
|
this.checkForUpdates().then(() => {
|
||||||
// Ensure badges are updated after checking
|
|
||||||
this.updateBadgeVisibility();
|
this.updateBadgeVisibility();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Immediately update modal content with current values (even if from default)
|
|
||||||
this.updateModalContent();
|
this.updateModalContent();
|
||||||
|
|
||||||
// Check version info for mismatch after loading basic info
|
|
||||||
this.checkVersionInfo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNightlyWarning() {
|
wireChannelButtons() {
|
||||||
const warning = document.getElementById('nightlyWarning');
|
const releaseBtn = document.getElementById('channelRelease');
|
||||||
if (warning) {
|
const nightlyBtn = document.getElementById('channelNightly');
|
||||||
warning.style.display = this.nightlyMode ? 'flex' : 'none';
|
if (releaseBtn) {
|
||||||
|
releaseBtn.addEventListener('click', () => this.switchChannel('release'));
|
||||||
}
|
}
|
||||||
|
if (nightlyBtn) {
|
||||||
|
nightlyBtn.addEventListener('click', () => this.switchChannel('nightly'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async switchChannel(channel) {
|
||||||
|
if (channel === this.channelMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.isUpdating) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.hasGit && channel === 'nightly') {
|
||||||
|
const confirmed = await this._confirmChannelSwitch(
|
||||||
|
'update.channelSwitch.nightlyTitle',
|
||||||
|
'update.channelSwitch.nightlyMessage'
|
||||||
|
);
|
||||||
|
if (!confirmed) return;
|
||||||
|
}
|
||||||
|
if (this.hasGit && channel === 'release') {
|
||||||
|
const confirmed = await this._confirmChannelSwitch(
|
||||||
|
'update.channelSwitch.releaseTitle',
|
||||||
|
'update.channelSwitch.releaseMessage'
|
||||||
|
);
|
||||||
|
if (!confirmed) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.isUpdating = true;
|
||||||
|
this.showUpdateProgress(true);
|
||||||
|
this.updateProgress(10, translate('update.channelSwitch.switching', { channel }));
|
||||||
|
|
||||||
|
const response = await fetch('/api/lm/switch-channel', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ channel })
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (data.success) {
|
||||||
|
this.channelMode = channel;
|
||||||
|
// Persist channel preference to settings.json
|
||||||
|
fetch('/api/lm/settings', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ update_channel: channel })
|
||||||
|
}).then(r => {
|
||||||
|
if (!r.ok) console.warn('Failed to persist update channel:', r.status);
|
||||||
|
}).catch(e => console.warn('Failed to persist update channel:', e));
|
||||||
|
await this.checkForUpdates({ force: true });
|
||||||
|
this.updateModalContent();
|
||||||
|
this.updateChannelUI();
|
||||||
|
this._showSwitchCompleteMessage(data.new_version);
|
||||||
|
this.progressKeepVisible = true;
|
||||||
|
} else {
|
||||||
|
throw new Error(data.error || translate('update.channelSwitch.failed'));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Channel switch failed:', error);
|
||||||
|
this.updateProgress(0, translate('update.channelSwitch.failed'));
|
||||||
|
} finally {
|
||||||
|
if (this.progressKeepVisible) {
|
||||||
|
this.isUpdating = false;
|
||||||
|
this.progressKeepVisible = false;
|
||||||
|
} else {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.showUpdateProgress(false);
|
||||||
|
this.isUpdating = false;
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateChannelUI() {
|
||||||
|
const releaseBtn = document.getElementById('channelRelease');
|
||||||
|
const nightlyBtn = document.getElementById('channelNightly');
|
||||||
|
|
||||||
|
if (releaseBtn) {
|
||||||
|
releaseBtn.classList.toggle('active', this.channelMode === 'release');
|
||||||
|
}
|
||||||
|
if (nightlyBtn) {
|
||||||
|
nightlyBtn.classList.toggle('active', this.channelMode === 'nightly');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_resolveChannelFromSettings() {
|
||||||
|
const stored = state?.global?.settings?.update_channel;
|
||||||
|
if (stored === 'nightly' || stored === 'release') {
|
||||||
|
return stored;
|
||||||
|
}
|
||||||
|
if (!this.hasGit) {
|
||||||
|
return 'release';
|
||||||
|
}
|
||||||
|
if (this.gitInfo?.branch === 'detached') {
|
||||||
|
return 'release';
|
||||||
|
}
|
||||||
|
return 'nightly';
|
||||||
|
}
|
||||||
|
|
||||||
|
async _confirmChannelSwitch(titleKey, messageKey) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const title = translate(titleKey);
|
||||||
|
const message = translate(messageKey);
|
||||||
|
const cancelText = translate('common.cancel');
|
||||||
|
const confirmText = translate('common.confirm');
|
||||||
|
|
||||||
|
const overlay = document.createElement('div');
|
||||||
|
overlay.className = 'channel-switch-overlay';
|
||||||
|
overlay.innerHTML = `
|
||||||
|
<div class="channel-switch-dialog">
|
||||||
|
<h3>${title}</h3>
|
||||||
|
<p>${message}</p>
|
||||||
|
<div class="channel-switch-actions">
|
||||||
|
<button class="secondary-btn channel-switch-cancel">${cancelText}</button>
|
||||||
|
<button class="primary-btn channel-switch-confirm">${confirmText}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
const dismiss = (result) => {
|
||||||
|
document.removeEventListener('keydown', onKeydown);
|
||||||
|
overlay.remove();
|
||||||
|
resolve(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onKeydown = (e) => {
|
||||||
|
if (e.key === 'Escape') {
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
dismiss(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
document.addEventListener('keydown', onKeydown, { capture: true });
|
||||||
|
|
||||||
|
overlay.addEventListener('click', (e) => {
|
||||||
|
if (e.target === overlay) {
|
||||||
|
dismiss(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
overlay.querySelector('.channel-switch-cancel').addEventListener('click', () => {
|
||||||
|
dismiss(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
overlay.querySelector('.channel-switch-confirm').addEventListener('click', () => {
|
||||||
|
dismiss(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
document.body.appendChild(overlay);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setupNotificationCenter() {
|
setupNotificationCenter() {
|
||||||
@@ -355,6 +497,18 @@ export class UpdateService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async checkForUpdates({ force = false } = {}) {
|
async checkForUpdates({ force = false } = {}) {
|
||||||
|
let needsMigration = false;
|
||||||
|
if (this.channelMode === null) {
|
||||||
|
const stored = state?.global?.settings?.update_channel;
|
||||||
|
if (stored === 'nightly' || stored === 'release') {
|
||||||
|
this.channelMode = stored;
|
||||||
|
} else if (!this.hasGit) {
|
||||||
|
this.channelMode = 'release';
|
||||||
|
needsMigration = true;
|
||||||
|
}
|
||||||
|
// hasGit=true with no stored value: wait for gitInfo.branch
|
||||||
|
}
|
||||||
|
|
||||||
if (!force && !this.updateNotificationsEnabled) {
|
if (!force && !this.updateNotificationsEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -373,7 +527,8 @@ export class UpdateService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Call backend API to check for updates with nightly flag
|
// Call backend API to check for updates with nightly flag
|
||||||
const response = await fetch(`/api/lm/check-updates?nightly=${this.nightlyMode}`);
|
const nightly = (this.channelMode ?? (this.hasGit ? 'nightly' : 'release')) === 'nightly';
|
||||||
|
const response = await fetch(`/api/lm/check-updates?nightly=${nightly}`);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
@@ -381,17 +536,35 @@ export class UpdateService {
|
|||||||
this.latestVersion = data.latest_version || "v0.0.0";
|
this.latestVersion = data.latest_version || "v0.0.0";
|
||||||
this.updateInfo = data;
|
this.updateInfo = data;
|
||||||
this.gitInfo = data.git_info || this.gitInfo;
|
this.gitInfo = data.git_info || this.gitInfo;
|
||||||
|
this.hasGit = data.has_git || false;
|
||||||
|
|
||||||
// Explicitly set update availability based on version comparison
|
if (needsMigration || this.channelMode === null) {
|
||||||
this.updateAvailable = this.isNewerVersion(this.latestVersion, this.currentVersion);
|
this.channelMode = this._resolveChannelFromSettings();
|
||||||
|
if (state?.global?.settings) {
|
||||||
|
state.global.settings.update_channel = this.channelMode;
|
||||||
|
}
|
||||||
|
fetch('/api/lm/settings', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ update_channel: this.channelMode })
|
||||||
|
}).then(r => {
|
||||||
|
if (!r.ok) console.warn('Failed to persist update channel:', r.status);
|
||||||
|
}).catch(e => console.warn('Failed to persist update channel:', e));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateAvailable = data.update_available;
|
||||||
|
|
||||||
|
// Nightly channel: surface the update badge at most once per calendar day.
|
||||||
|
if (this.updateAvailable && this.channelMode === 'nightly' && this.nightlyNotifyDate !== this._getTodayKey()) {
|
||||||
|
this._markNightlyNotified();
|
||||||
|
}
|
||||||
|
|
||||||
// Update last check time
|
|
||||||
this.lastCheckTime = now;
|
this.lastCheckTime = now;
|
||||||
setStorageItem('last_update_check', now.toString());
|
setStorageItem('last_update_check', now.toString());
|
||||||
|
|
||||||
// Update UI
|
|
||||||
this.updateBadgeVisibility();
|
this.updateBadgeVisibility();
|
||||||
this.updateModalContent();
|
this.updateModalContent();
|
||||||
|
this.updateChannelUI();
|
||||||
|
|
||||||
console.log("Update check complete:", {
|
console.log("Update check complete:", {
|
||||||
currentVersion: this.currentVersion,
|
currentVersion: this.currentVersion,
|
||||||
@@ -436,6 +609,28 @@ export class UpdateService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_getTodayKey() {
|
||||||
|
const now = new Date();
|
||||||
|
const month = String(now.getMonth() + 1).padStart(2, '0');
|
||||||
|
const day = String(now.getDate()).padStart(2, '0');
|
||||||
|
return `${now.getFullYear()}-${month}-${day}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
_isNightlyBadgeAllowed() {
|
||||||
|
if (this.channelMode !== 'nightly') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Keep the badge visible for the rest of the session once shown, but do
|
||||||
|
// not show it again on later sessions within the same calendar day.
|
||||||
|
return this.nightlyNotifyDate !== this._getTodayKey() || this.nightlyBadgeShown;
|
||||||
|
}
|
||||||
|
|
||||||
|
_markNightlyNotified() {
|
||||||
|
this.nightlyNotifyDate = this._getTodayKey();
|
||||||
|
this.nightlyBadgeShown = true;
|
||||||
|
setStorageItem('nightly_notify_date', this.nightlyNotifyDate);
|
||||||
|
}
|
||||||
|
|
||||||
updateBadgeVisibility() {
|
updateBadgeVisibility() {
|
||||||
const updateToggle = document.querySelector('.update-toggle');
|
const updateToggle = document.querySelector('.update-toggle');
|
||||||
const updateBadge = document.querySelector('.update-toggle .update-badge');
|
const updateBadge = document.querySelector('.update-toggle .update-badge');
|
||||||
@@ -443,9 +638,12 @@ export class UpdateService {
|
|||||||
? bannerService.getUnreadBannerCount()
|
? bannerService.getUnreadBannerCount()
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
|
// Force updating badges visibility based on current state
|
||||||
|
const shouldShowUpdate = this.updateNotificationsEnabled && this.updateAvailable && this._isNightlyBadgeAllowed();
|
||||||
|
|
||||||
if (updateToggle) {
|
if (updateToggle) {
|
||||||
let tooltipKey = 'header.actions.notifications';
|
let tooltipKey = 'header.actions.notifications';
|
||||||
if (this.updateNotificationsEnabled && this.updateAvailable) {
|
if (shouldShowUpdate) {
|
||||||
tooltipKey = 'update.updateAvailable';
|
tooltipKey = 'update.updateAvailable';
|
||||||
} else if (unreadBanners > 0) {
|
} else if (unreadBanners > 0) {
|
||||||
tooltipKey = 'update.tabs.messages';
|
tooltipKey = 'update.tabs.messages';
|
||||||
@@ -453,8 +651,6 @@ export class UpdateService {
|
|||||||
updateToggle.title = translate(tooltipKey);
|
updateToggle.title = translate(tooltipKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force updating badges visibility based on current state
|
|
||||||
const shouldShowUpdate = this.updateNotificationsEnabled && this.updateAvailable;
|
|
||||||
const shouldShow = shouldShowUpdate || unreadBanners > 0;
|
const shouldShow = shouldShowUpdate || unreadBanners > 0;
|
||||||
|
|
||||||
if (updateBadge) {
|
if (updateBadge) {
|
||||||
@@ -482,9 +678,32 @@ export class UpdateService {
|
|||||||
|
|
||||||
if (currentVersionEl) currentVersionEl.textContent = this.currentVersion;
|
if (currentVersionEl) currentVersionEl.textContent = this.currentVersion;
|
||||||
|
|
||||||
|
const newVersionLabel = modal.querySelector('.new-version .label');
|
||||||
|
if (newVersionLabel) {
|
||||||
|
newVersionLabel.textContent = (this.updateInfo?.nightly)
|
||||||
|
? `${translate('update.latestMain')}:`
|
||||||
|
: `${translate('update.newVersion')}:`;
|
||||||
|
}
|
||||||
|
|
||||||
if (newVersionEl) {
|
if (newVersionEl) {
|
||||||
|
if (this.updateInfo?.nightly) {
|
||||||
|
const behind = this.updateInfo.behind_by || 0;
|
||||||
|
const remoteHash = this.latestVersion.replace('main-', '');
|
||||||
|
const localHash = this.gitInfo.short_hash || '';
|
||||||
|
const date = this.updateInfo.commit_date || '';
|
||||||
|
const datePart = date ? ` · ${date}` : '';
|
||||||
|
|
||||||
|
if (behind > 0) {
|
||||||
|
newVersionEl.textContent = `${behind} commit${behind !== 1 ? 's' : ''} behind main (${remoteHash}${datePart})`;
|
||||||
|
} else if (localHash !== remoteHash) {
|
||||||
|
newVersionEl.textContent = `Behind main (${remoteHash}${datePart})`;
|
||||||
|
} else {
|
||||||
|
newVersionEl.textContent = `Up to date (${remoteHash}${datePart})`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
newVersionEl.textContent = this.latestVersion;
|
newVersionEl.textContent = this.latestVersion;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update update button state
|
// Update update button state
|
||||||
const updateBtn = modal.querySelector('#updateBtn');
|
const updateBtn = modal.querySelector('#updateBtn');
|
||||||
@@ -599,10 +818,14 @@ export class UpdateService {
|
|||||||
// Update GitHub link to point to the specific release if available
|
// Update GitHub link to point to the specific release if available
|
||||||
const githubLink = modal.querySelector('.update-link');
|
const githubLink = modal.querySelector('.update-link');
|
||||||
if (githubLink && this.latestVersion) {
|
if (githubLink && this.latestVersion) {
|
||||||
|
if (this.updateInfo?.nightly) {
|
||||||
|
githubLink.href = 'https://github.com/willmiao/ComfyUI-Lora-Manager/commits/main';
|
||||||
|
} else {
|
||||||
const versionTag = this.latestVersion.replace(/^v/, '');
|
const versionTag = this.latestVersion.replace(/^v/, '');
|
||||||
githubLink.href = `https://github.com/willmiao/ComfyUI-Lora-Manager/releases/tag/v${versionTag}`;
|
githubLink.href = `https://github.com/willmiao/ComfyUI-Lora-Manager/releases/tag/v${versionTag}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async performUpdate() {
|
async performUpdate() {
|
||||||
if (!this.updateAvailable || this.isUpdating) {
|
if (!this.updateAvailable || this.isUpdating) {
|
||||||
@@ -623,7 +846,7 @@ export class UpdateService {
|
|||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
nightly: this.nightlyMode
|
nightly: this.channelMode === 'nightly'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -699,6 +922,25 @@ export class UpdateService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_showSwitchCompleteMessage(version) {
|
||||||
|
this.showUpdateProgress(true);
|
||||||
|
this.updateProgress(100, '');
|
||||||
|
const progressText = document.getElementById('updateProgressText');
|
||||||
|
if (progressText) {
|
||||||
|
progressText.innerHTML = `
|
||||||
|
<div style="text-align: center; color: var(--lora-success);">
|
||||||
|
<i class="fas fa-check-circle" style="margin-right: 8px;"></i>
|
||||||
|
${translate('update.completion.successMessage', { version })}
|
||||||
|
<br><br>
|
||||||
|
<div style="opacity: 0.95; color: var(--lora-error); font-size: 1em;">
|
||||||
|
${translate('update.completion.restartMessage')}<br>
|
||||||
|
${translate('update.completion.reloadMessage')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
showUpdateCompleteMessage(newVersion) {
|
showUpdateCompleteMessage(newVersion) {
|
||||||
const modal = document.getElementById('updateModal');
|
const modal = document.getElementById('updateModal');
|
||||||
if (!modal) return;
|
if (!modal) return;
|
||||||
@@ -771,6 +1013,7 @@ export class UpdateService {
|
|||||||
|
|
||||||
// Update the modal content immediately with current data
|
// Update the modal content immediately with current data
|
||||||
this.updateModalContent();
|
this.updateModalContent();
|
||||||
|
this.updateChannelUI();
|
||||||
this.renderRecentBanners();
|
this.renderRecentBanners();
|
||||||
|
|
||||||
// Show the modal with current data
|
// Show the modal with current data
|
||||||
@@ -801,8 +1044,8 @@ export class UpdateService {
|
|||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
this.currentVersionInfo = data.version;
|
this.currentVersionInfo = data.version;
|
||||||
|
this.hasGit = data.has_git || false;
|
||||||
|
|
||||||
// Check if version matches stored version
|
|
||||||
this.versionMismatch = !isVersionMatch(this.currentVersionInfo);
|
this.versionMismatch = !isVersionMatch(this.currentVersionInfo);
|
||||||
|
|
||||||
if (this.versionMismatch) {
|
if (this.versionMismatch) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { translate } from '../../utils/i18nHelpers.js';
|
|||||||
import { getModelApiClient } from '../../api/modelApiFactory.js';
|
import { getModelApiClient } from '../../api/modelApiFactory.js';
|
||||||
import { MODEL_TYPES } from '../../api/apiConfig.js';
|
import { MODEL_TYPES } from '../../api/apiConfig.js';
|
||||||
import { getStorageItem } from '../../utils/storageHelpers.js';
|
import { getStorageItem } from '../../utils/storageHelpers.js';
|
||||||
|
import { state } from '../../state/index.js';
|
||||||
|
|
||||||
export class DownloadManager {
|
export class DownloadManager {
|
||||||
constructor(importManager) {
|
constructor(importManager) {
|
||||||
@@ -125,11 +126,25 @@ export class DownloadManager {
|
|||||||
showToast('toast.recipes.nameSaved', { name: this.importManager.recipeName }, 'success');
|
showToast('toast.recipes.nameSaved', { name: this.importManager.recipeName }, 'success');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close modal
|
|
||||||
modalManager.closeModal('importModal');
|
modalManager.closeModal('importModal');
|
||||||
|
|
||||||
// Refresh the recipe
|
if (isDownloadOnly && state.virtualScroller) {
|
||||||
window.recipeManager.loadRecipes(true);
|
const recipeId = this.importManager.recipeId;
|
||||||
|
try {
|
||||||
|
const detailRes = await fetch(`/api/lm/recipe/${encodeURIComponent(recipeId)}`);
|
||||||
|
if (detailRes.ok) {
|
||||||
|
const updated = await detailRes.json();
|
||||||
|
state.virtualScroller.updateSingleItem(updated.file_path, updated);
|
||||||
|
} else {
|
||||||
|
throw new Error(`API returned ${detailRes.status}`);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Failed to update recipe card in-place, falling back to reload:', e);
|
||||||
|
await window.recipeManager.loadRecipes({ resetPage: true, preserveScroll: true });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
window.recipeManager.loadRecipes({ resetPage: true, preserveScroll: true });
|
||||||
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
|
|||||||
@@ -47,11 +47,8 @@ export class ImportStepManager {
|
|||||||
targetStep.offsetHeight;
|
targetStep.offsetHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scroll modal content to top
|
// Scroll the active step back to top (steps scroll independently of the modal shell)
|
||||||
const modalContent = document.querySelector('#importModal .modal-content');
|
targetStep.scrollTop = 0;
|
||||||
if (modalContent) {
|
|
||||||
modalContent.scrollTop = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-1
@@ -7,7 +7,7 @@ import { state, getCurrentPageState } from './state/index.js';
|
|||||||
import { getStorageItem, setStorageItem, getSessionItem, removeSessionItem } from './utils/storageHelpers.js';
|
import { getStorageItem, setStorageItem, getSessionItem, removeSessionItem } from './utils/storageHelpers.js';
|
||||||
import { RecipeContextMenu } from './components/ContextMenu/index.js';
|
import { RecipeContextMenu } from './components/ContextMenu/index.js';
|
||||||
import { DuplicatesManager } from './components/DuplicatesManager.js';
|
import { DuplicatesManager } from './components/DuplicatesManager.js';
|
||||||
import { refreshVirtualScroll } from './utils/infiniteScroll.js';
|
import { refreshVirtualScroll, recreateVirtualScroll } from './utils/infiniteScroll.js';
|
||||||
import { refreshRecipes, RecipeSidebarApiClient } from './api/recipeApi.js';
|
import { refreshRecipes, RecipeSidebarApiClient } from './api/recipeApi.js';
|
||||||
import { sidebarManager } from './components/SidebarManager.js';
|
import { sidebarManager } from './components/SidebarManager.js';
|
||||||
import { initSortDropdown } from './components/controls/SortDropdown.js';
|
import { initSortDropdown } from './components/controls/SortDropdown.js';
|
||||||
@@ -272,6 +272,20 @@ class RecipeManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rebuild the scroller on layout switch; in duplicates mode defer until
|
||||||
|
// exitDuplicateMode re-enables the scroller (direct recreation would dispose
|
||||||
|
// the old instance while initializeVirtualScroll skips duplicates mode)
|
||||||
|
window.addEventListener('lm:recipes-layout-changed', () => {
|
||||||
|
const pageState = getCurrentPageState();
|
||||||
|
if (pageState.duplicatesMode) {
|
||||||
|
state.pendingLayoutRecreate = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof recreateVirtualScroll === 'function') {
|
||||||
|
recreateVirtualScroll('recipes');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Initialize dropdown functionality for refresh button
|
// Initialize dropdown functionality for refresh button
|
||||||
this.initDropdowns();
|
this.initDropdowns();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ const DEFAULT_SETTINGS_BASE = Object.freeze({
|
|||||||
card_blur_amount: 8,
|
card_blur_amount: 8,
|
||||||
autoplay_on_hover: false,
|
autoplay_on_hover: false,
|
||||||
display_density: 'default',
|
display_density: 'default',
|
||||||
|
recipes_layout: 'grid',
|
||||||
card_info_display: 'always',
|
card_info_display: 'always',
|
||||||
model_name_display: 'model_name',
|
model_name_display: 'model_name',
|
||||||
lora_syntax_format: 'legacy',
|
lora_syntax_format: 'legacy',
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -483,10 +483,18 @@ export class VirtualScroller {
|
|||||||
element.style.width = `${this.itemWidth}px`;
|
element.style.width = `${this.itemWidth}px`;
|
||||||
element.style.height = `${this.itemHeight}px`;
|
element.style.height = `${this.itemHeight}px`;
|
||||||
|
|
||||||
// Remove max-width constraint from model-card to allow dynamic sizing
|
// Remove max-width/min-width constraints from the model-card to allow
|
||||||
const modelCard = element.querySelector('.model-card');
|
// dynamic sizing. The card is either the item element itself (e.g.
|
||||||
|
// RecipeCard returns the .model-card root) or a descendant (ModelCard).
|
||||||
|
// Without this, the CSS min-width of 200px forces compact-density cards
|
||||||
|
// wider than their allocated column, and the last column gets clipped
|
||||||
|
// by the grid's overflow-x: hidden.
|
||||||
|
const modelCard = element.classList.contains('model-card')
|
||||||
|
? element
|
||||||
|
: element.querySelector('.model-card');
|
||||||
if (modelCard) {
|
if (modelCard) {
|
||||||
modelCard.style.maxWidth = 'none';
|
modelCard.style.maxWidth = 'none';
|
||||||
|
modelCard.style.minWidth = '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
|
|||||||
@@ -333,6 +333,7 @@ export const PATH_TEMPLATE_PLACEHOLDERS = [
|
|||||||
export const DEFAULT_PATH_TEMPLATES = {
|
export const DEFAULT_PATH_TEMPLATES = {
|
||||||
lora: '{base_model}/{first_tag}',
|
lora: '{base_model}/{first_tag}',
|
||||||
checkpoint: '{base_model}',
|
checkpoint: '{base_model}',
|
||||||
|
unet: '{base_model}',
|
||||||
embedding: '{first_tag}'
|
embedding: '{first_tag}'
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -369,21 +370,24 @@ export function getMatureBlurThreshold(settings = {}) {
|
|||||||
export const NODE_TYPES = {
|
export const NODE_TYPES = {
|
||||||
LORA_LOADER: 1,
|
LORA_LOADER: 1,
|
||||||
LORA_STACKER: 2,
|
LORA_STACKER: 2,
|
||||||
WAN_VIDEO_LORA_SELECT: 3
|
WAN_VIDEO_LORA_SELECT: 3,
|
||||||
|
HOOK_LORA: 4
|
||||||
};
|
};
|
||||||
|
|
||||||
// Node type names to IDs mapping
|
// Node type names to IDs mapping
|
||||||
export const NODE_TYPE_NAMES = {
|
export const NODE_TYPE_NAMES = {
|
||||||
"Lora Loader (LoraManager)": NODE_TYPES.LORA_LOADER,
|
"Lora Loader (LoraManager)": NODE_TYPES.LORA_LOADER,
|
||||||
"Lora Stacker (LoraManager)": NODE_TYPES.LORA_STACKER,
|
"Lora Stacker (LoraManager)": NODE_TYPES.LORA_STACKER,
|
||||||
"WanVideo Lora Select (LoraManager)": NODE_TYPES.WAN_VIDEO_LORA_SELECT
|
"WanVideo Lora Select (LoraManager)": NODE_TYPES.WAN_VIDEO_LORA_SELECT,
|
||||||
|
"Create Hook LoRA (LoraManager)": NODE_TYPES.HOOK_LORA
|
||||||
};
|
};
|
||||||
|
|
||||||
// Node type icons
|
// Node type icons
|
||||||
export const NODE_TYPE_ICONS = {
|
export const NODE_TYPE_ICONS = {
|
||||||
[NODE_TYPES.LORA_LOADER]: "fas fa-l",
|
[NODE_TYPES.LORA_LOADER]: "fas fa-l",
|
||||||
[NODE_TYPES.LORA_STACKER]: "fas fa-s",
|
[NODE_TYPES.LORA_STACKER]: "fas fa-s",
|
||||||
[NODE_TYPES.WAN_VIDEO_LORA_SELECT]: "fas fa-w"
|
[NODE_TYPES.WAN_VIDEO_LORA_SELECT]: "fas fa-w",
|
||||||
|
[NODE_TYPES.HOOK_LORA]: "fas fa-h"
|
||||||
};
|
};
|
||||||
|
|
||||||
// Default ComfyUI node color when bgcolor is null
|
// Default ComfyUI node color when bgcolor is null
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { state, getCurrentPageState } from '../state/index.js';
|
import { state, getCurrentPageState } from '../state/index.js';
|
||||||
import { VirtualScroller } from './VirtualScroller.js';
|
import { VirtualScroller } from './VirtualScroller.js';
|
||||||
|
import { MasonryScroller } from './MasonryScroller.js';
|
||||||
import { createModelCard, setupModelCardEventDelegation } from '../components/shared/ModelCard.js';
|
import { createModelCard, setupModelCardEventDelegation } from '../components/shared/ModelCard.js';
|
||||||
import { getModelApiClient } from '../api/modelApiFactory.js';
|
import { getModelApiClient } from '../api/modelApiFactory.js';
|
||||||
import { showToast } from './uiHelpers.js';
|
import { showToast } from './uiHelpers.js';
|
||||||
@@ -141,8 +142,14 @@ async function initializeVirtualScroll(pageType) {
|
|||||||
throw new Error(`Required components not available for ${pageType} page`);
|
throw new Error(`Required components not available for ${pageType} page`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Masonry applies to the recipes page only; the read pattern mirrors
|
||||||
|
// VirtualScroller.js (display_density).
|
||||||
|
const useMasonry = pageType === 'recipes'
|
||||||
|
&& (state.global.settings?.recipes_layout ?? 'grid') === 'masonry';
|
||||||
|
const ScrollerClass = useMasonry ? MasonryScroller : VirtualScroller;
|
||||||
|
|
||||||
// Initialize virtual scroller with renamed container elements
|
// Initialize virtual scroller with renamed container elements
|
||||||
state.virtualScroller = new VirtualScroller({
|
state.virtualScroller = new ScrollerClass({
|
||||||
gridElement: grid,
|
gridElement: grid,
|
||||||
containerElement: gridContainer,
|
containerElement: gridContainer,
|
||||||
scrollContainer: scrollContainer,
|
scrollContainer: scrollContainer,
|
||||||
@@ -250,3 +257,19 @@ export async function refreshVirtualScroll(options = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rebuild the virtual scroller from scratch (used for layout switching).
|
||||||
|
// refreshVirtualScroll only resets the existing instance, so it cannot swap
|
||||||
|
// the scroller class. Keyboard navigation must be cleaned up first:
|
||||||
|
// setupKeyboardNavigation appends a new document keydown listener on every
|
||||||
|
// initializeVirtualScroll call and never removes the previous one.
|
||||||
|
export async function recreateVirtualScroll(pageType) {
|
||||||
|
cleanupKeyboardNavigation();
|
||||||
|
|
||||||
|
if (state.virtualScroller) {
|
||||||
|
state.virtualScroller.dispose();
|
||||||
|
state.virtualScroller = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
await initializeVirtualScroll(pageType);
|
||||||
|
}
|
||||||
|
|||||||
@@ -356,6 +356,8 @@ export function updatePanelPositions() {
|
|||||||
|
|
||||||
if (filterPanel) {
|
if (filterPanel) {
|
||||||
filterPanel.style.top = `${topPosition}px`;
|
filterPanel.style.top = `${topPosition}px`;
|
||||||
|
// Clamp panel height to the viewport below the header
|
||||||
|
filterPanel.style.maxHeight = `calc(100vh - ${topPosition + 10}px)`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust panel horizontal position based on the search container
|
// Adjust panel horizontal position based on the search container
|
||||||
|
|||||||
@@ -32,7 +32,12 @@
|
|||||||
<div class="context-menu-separator menu-section-break"></div>
|
<div class="context-menu-separator menu-section-break"></div>
|
||||||
<!-- Media / Preview -->
|
<!-- Media / Preview -->
|
||||||
<div class="context-menu-item" data-action="preview"><i class="fas fa-folder-open"></i> {{ t('loras.contextMenu.openExamples') }}</div>
|
<div class="context-menu-item" data-action="preview"><i class="fas fa-folder-open"></i> {{ t('loras.contextMenu.openExamples') }}</div>
|
||||||
<div class="context-menu-item" data-action="download-examples"><i class="fas fa-download"></i> {{ t('loras.contextMenu.downloadExamples') }}</div>
|
<div class="context-menu-item has-submenu" data-has-submenu="download-examples"><i class="fas fa-download"></i> {{ t('loras.contextMenu.downloadExamples') }} <i class="fas fa-chevron-right submenu-arrow"></i>
|
||||||
|
<div class="context-submenu">
|
||||||
|
<div class="context-menu-item" data-action="download-examples"><i class="fas fa-download"></i> {{ t('loras.contextMenu.downloadMissingExamples') }}</div>
|
||||||
|
<div class="context-menu-item" data-action="download-examples-force"><i class="fas fa-redo-alt"></i> {{ t('loras.contextMenu.reprocessExamples') }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="context-menu-item" data-action="replace-preview"><i class="fas fa-image"></i> {{ t('loras.contextMenu.replacePreview') }}</div>
|
<div class="context-menu-item" data-action="replace-preview"><i class="fas fa-image"></i> {{ t('loras.contextMenu.replacePreview') }}</div>
|
||||||
<div class="context-menu-separator menu-section-break"></div>
|
<div class="context-menu-separator menu-section-break"></div>
|
||||||
<!-- Attributes -->
|
<!-- Attributes -->
|
||||||
|
|||||||
@@ -44,8 +44,18 @@
|
|||||||
<div class="context-menu-item" data-action="preview">
|
<div class="context-menu-item" data-action="preview">
|
||||||
<i class="fas fa-folder-open"></i> <span>{{ t('loras.contextMenu.openExamples') }}</span>
|
<i class="fas fa-folder-open"></i> <span>{{ t('loras.contextMenu.openExamples') }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="context-menu-item has-submenu" data-has-submenu="download-examples">
|
||||||
|
<i class="fas fa-download"></i>
|
||||||
|
<span>{{ t('loras.contextMenu.downloadExamples') }}</span>
|
||||||
|
<i class="fas fa-chevron-right submenu-arrow"></i>
|
||||||
|
<div class="context-submenu">
|
||||||
<div class="context-menu-item" data-action="download-examples">
|
<div class="context-menu-item" data-action="download-examples">
|
||||||
<i class="fas fa-download"></i> <span>{{ t('loras.contextMenu.downloadExamples') }}</span>
|
<i class="fas fa-download"></i> <span>{{ t('loras.contextMenu.downloadMissingExamples') }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="context-menu-item" data-action="download-examples-force">
|
||||||
|
<i class="fas fa-redo-alt"></i> <span>{{ t('loras.contextMenu.reprocessExamples') }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="context-menu-item" data-action="replace-preview">
|
<div class="context-menu-item" data-action="replace-preview">
|
||||||
<i class="fas fa-image"></i> <span>{{ t('loras.contextMenu.replacePreview') }}</span>
|
<i class="fas fa-image"></i> <span>{{ t('loras.contextMenu.replacePreview') }}</span>
|
||||||
@@ -136,8 +146,18 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="context-menu-section" data-section="download">
|
<div class="context-menu-section" data-section="download">
|
||||||
<div class="context-menu-section-header">{{ t('loras.bulkOperations.sections.download') }}</div>
|
<div class="context-menu-section-header">{{ t('loras.bulkOperations.sections.download') }}</div>
|
||||||
|
<div class="context-menu-item has-submenu" data-has-submenu="download-example-images">
|
||||||
|
<i class="fas fa-download"></i>
|
||||||
|
<span>{{ t('loras.bulkOperations.downloadExamples') }}</span>
|
||||||
|
<i class="fas fa-chevron-right submenu-arrow"></i>
|
||||||
|
<div class="context-submenu">
|
||||||
|
<div class="context-menu-item" data-action="download-missing-example-images">
|
||||||
|
<i class="fas fa-download"></i> <span>{{ t('loras.bulkOperations.downloadMissingExamples') }}</span>
|
||||||
|
</div>
|
||||||
<div class="context-menu-item" data-action="download-example-images">
|
<div class="context-menu-item" data-action="download-example-images">
|
||||||
<i class="fas fa-download"></i> <span>{{ t('loras.bulkOperations.downloadExamples') }}</span>
|
<i class="fas fa-redo-alt"></i> <span>{{ t('loras.bulkOperations.reprocessExamples') }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="context-menu-item" data-action="download-missing-loras">
|
<div class="context-menu-item" data-action="download-missing-loras">
|
||||||
<i class="fas fa-download"></i> <span>{{ t('loras.bulkOperations.downloadMissingLoras') }}</span>
|
<i class="fas fa-download"></i> <span>{{ t('loras.bulkOperations.downloadMissingLoras') }}</span>
|
||||||
|
|||||||
@@ -48,6 +48,11 @@
|
|||||||
<option value="versions_count:asc">{{ t('loras.controls.sort.versionsCountAsc', default='Fewest versions first') }}</option>
|
<option value="versions_count:asc">{{ t('loras.controls.sort.versionsCountAsc', default='Fewest versions first') }}</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if page_id != 'recipes' %}
|
||||||
|
<optgroup label="{{ t('loras.controls.sort.random', default='Random') }}">
|
||||||
|
<option value="random">{{ t('loras.controls.sort.randomAction', default='Randomize (shuffle)') }}</option>
|
||||||
|
</optgroup>
|
||||||
|
{% endif %}
|
||||||
{% if page_id == 'recipes' %}
|
{% if page_id == 'recipes' %}
|
||||||
<optgroup label="{{ t('recipes.controls.sort.lorasCount') }}">
|
<optgroup label="{{ t('recipes.controls.sort.lorasCount') }}">
|
||||||
<option value="loras_count:desc">{{ t('recipes.controls.sort.lorasCountDesc') }}</option>
|
<option value="loras_count:desc">{{ t('recipes.controls.sort.lorasCountDesc') }}</option>
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Step 3: Location Selection -->
|
<!-- Step 3: Location Selection -->
|
||||||
<div class="download-step" id="locationStep" style="display: none;">
|
<div class="download-step" id="downloadLocationStep" style="display: none;">
|
||||||
<div class="location-selection">
|
<div class="location-selection">
|
||||||
<!-- Path preview with inline toggle -->
|
<!-- Path preview with inline toggle -->
|
||||||
<div class="path-preview">
|
<div class="path-preview">
|
||||||
|
|||||||
@@ -202,6 +202,7 @@
|
|||||||
<option value="deepseek">{{ t('settings.aiProvider.providerOptions.deepseek') }}</option>
|
<option value="deepseek">{{ t('settings.aiProvider.providerOptions.deepseek') }}</option>
|
||||||
<option value="groq">{{ t('settings.aiProvider.providerOptions.groq') }}</option>
|
<option value="groq">{{ t('settings.aiProvider.providerOptions.groq') }}</option>
|
||||||
<option value="openrouter">{{ t('settings.aiProvider.providerOptions.openrouter') }}</option>
|
<option value="openrouter">{{ t('settings.aiProvider.providerOptions.openrouter') }}</option>
|
||||||
|
<option value="google">{{ t('settings.aiProvider.providerOptions.google') }}</option>
|
||||||
<option value="opencode-go">{{ t('settings.aiProvider.providerOptions.opencode-go') }}</option>
|
<option value="opencode-go">{{ t('settings.aiProvider.providerOptions.opencode-go') }}</option>
|
||||||
<option value="custom">{{ t('settings.aiProvider.providerOptions.custom') }}</option>
|
<option value="custom">{{ t('settings.aiProvider.providerOptions.custom') }}</option>
|
||||||
</select>
|
</select>
|
||||||
@@ -625,6 +626,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-item">
|
||||||
|
<div class="setting-row">
|
||||||
|
<div class="setting-info">
|
||||||
|
<label for="recipesLayout">
|
||||||
|
{{ t('settings.layoutSettings.recipesLayout') }}
|
||||||
|
<i class="fas fa-info-circle info-icon" data-tooltip="{{ t('settings.layoutSettings.recipesLayoutHelp') }}"></i>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="setting-control select-control">
|
||||||
|
<select id="recipesLayout" onchange="settingsManager.saveSelectSetting('recipesLayout', 'recipes_layout')">
|
||||||
|
<option value="grid">{{ t('settings.layoutSettings.recipesLayoutOptions.grid') }}</option>
|
||||||
|
<option value="masonry">{{ t('settings.layoutSettings.recipesLayoutOptions.masonry') }}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="setting-item">
|
<div class="setting-item">
|
||||||
<div class="setting-row">
|
<div class="setting-row">
|
||||||
<div class="setting-info">
|
<div class="setting-info">
|
||||||
|
|||||||
@@ -19,6 +19,20 @@
|
|||||||
<div class="notification-panels">
|
<div class="notification-panels">
|
||||||
<div class="notification-panel active" id="updatesPanel" role="tabpanel" aria-labelledby="updatesTab" aria-hidden="false" tabindex="0" data-notification-panel="updates">
|
<div class="notification-panel active" id="updatesPanel" role="tabpanel" aria-labelledby="updatesTab" aria-hidden="false" tabindex="0" data-notification-panel="updates">
|
||||||
<div class="update-content">
|
<div class="update-content">
|
||||||
|
|
||||||
|
<!-- Channel Selector -->
|
||||||
|
<div class="update-channels" id="updateChannels">
|
||||||
|
<div class="channels-label">{{ t('update.channel') }}</div>
|
||||||
|
<div class="channel-toggle">
|
||||||
|
<button type="button" class="channel-btn" data-channel="release" id="channelRelease">
|
||||||
|
<i class="fas fa-tag"></i> {{ t('update.channels.release') }}
|
||||||
|
</button>
|
||||||
|
<button type="button" class="channel-btn" data-channel="nightly" id="channelNightly">
|
||||||
|
<i class="fas fa-moon"></i> {{ t('update.channels.nightly') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="update-info">
|
<div class="update-info">
|
||||||
<div class="version-info">
|
<div class="version-info">
|
||||||
<div class="current-version">
|
<div class="current-version">
|
||||||
|
|||||||
@@ -32,7 +32,12 @@
|
|||||||
<div class="context-menu-separator menu-section-break"></div>
|
<div class="context-menu-separator menu-section-break"></div>
|
||||||
<!-- Media / Preview -->
|
<!-- Media / Preview -->
|
||||||
<div class="context-menu-item" data-action="preview"><i class="fas fa-folder-open"></i> {{ t('loras.contextMenu.openExamples') }}</div>
|
<div class="context-menu-item" data-action="preview"><i class="fas fa-folder-open"></i> {{ t('loras.contextMenu.openExamples') }}</div>
|
||||||
<div class="context-menu-item" data-action="download-examples"><i class="fas fa-download"></i> {{ t('loras.contextMenu.downloadExamples') }}</div>
|
<div class="context-menu-item has-submenu" data-has-submenu="download-examples"><i class="fas fa-download"></i> {{ t('loras.contextMenu.downloadExamples') }} <i class="fas fa-chevron-right submenu-arrow"></i>
|
||||||
|
<div class="context-submenu">
|
||||||
|
<div class="context-menu-item" data-action="download-examples"><i class="fas fa-download"></i> {{ t('loras.contextMenu.downloadMissingExamples') }}</div>
|
||||||
|
<div class="context-menu-item" data-action="download-examples-force"><i class="fas fa-redo-alt"></i> {{ t('loras.contextMenu.reprocessExamples') }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="context-menu-item" data-action="replace-preview"><i class="fas fa-image"></i> {{ t('loras.contextMenu.replacePreview') }}</div>
|
<div class="context-menu-item" data-action="replace-preview"><i class="fas fa-image"></i> {{ t('loras.contextMenu.replacePreview') }}</div>
|
||||||
<div class="context-menu-separator menu-section-break"></div>
|
<div class="context-menu-separator menu-section-break"></div>
|
||||||
<!-- Attributes -->
|
<!-- Attributes -->
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ sys.modules['comfy.utils'] = comfy_mock.utils
|
|||||||
sys.modules['comfy.sd'] = comfy_mock.sd
|
sys.modules['comfy.sd'] = comfy_mock.sd
|
||||||
sys.modules['comfy.model_management'] = comfy_mock.model_management
|
sys.modules['comfy.model_management'] = comfy_mock.model_management
|
||||||
sys.modules['comfy.comfy_types'] = comfy_mock.comfy_types
|
sys.modules['comfy.comfy_types'] = comfy_mock.comfy_types
|
||||||
|
sys.modules['comfy.hooks'] = MockModule("comfy.hooks")
|
||||||
|
|
||||||
execution_mock = MockModule("execution")
|
execution_mock = MockModule("execution")
|
||||||
execution_mock.PromptExecutor = mock.MagicMock()
|
execution_mock.PromptExecutor = mock.MagicMock()
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ vi.mock('../../../static/js/state/index.js', () => {
|
|||||||
vi.mock('../../../static/js/utils/infiniteScroll.js', () => ({
|
vi.mock('../../../static/js/utils/infiniteScroll.js', () => ({
|
||||||
captureScrollPosition: captureScrollPositionMock,
|
captureScrollPosition: captureScrollPositionMock,
|
||||||
restoreScrollPosition: restoreScrollPositionMock,
|
restoreScrollPosition: restoreScrollPositionMock,
|
||||||
|
recreateVirtualScroll: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1666,4 +1666,374 @@ describe('AutoComplete widget interactions', () => {
|
|||||||
// Entire phrase should be replaced with selected tag
|
// Entire phrase should be replaced with selected tag
|
||||||
expect(input.value).toBe('looking_to_the_side,');
|
expect(input.value).toBe('looking_to_the_side,');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('shows /af command for loras when active-filters autocomplete is off (default)', async () => {
|
||||||
|
const input = document.createElement('textarea');
|
||||||
|
input.value = '/';
|
||||||
|
input.selectionStart = input.value.length;
|
||||||
|
document.body.append(input);
|
||||||
|
|
||||||
|
caretHelperInstance.getBeforeCursor.mockReturnValue('/');
|
||||||
|
caretHelperInstance.getCursorOffset.mockReturnValue({ left: 15, top: 25 });
|
||||||
|
|
||||||
|
const { AutoComplete } = await import(AUTOCOMPLETE_MODULE);
|
||||||
|
const autoComplete = new AutoComplete(input, 'loras', { showPreview: false, minChars: 1 });
|
||||||
|
|
||||||
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
|
||||||
|
const commandNames = autoComplete.items.map((item) => item.command);
|
||||||
|
expect(commandNames).toContain('/af');
|
||||||
|
expect(commandNames).not.toContain('/noaf');
|
||||||
|
expect(commandNames).toContain('/activefilters');
|
||||||
|
expect(commandNames).not.toContain('/noactivefilters');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not trigger preview for command items when selecting the loras command list', async () => {
|
||||||
|
// Regression: with showPreview enabled (the default for loras widgets), the
|
||||||
|
// auto-selected first command item was passed to showPreviewForItem() as a
|
||||||
|
// relative path, crashing on relativePath.split.
|
||||||
|
const input = document.createElement('textarea');
|
||||||
|
input.value = '/';
|
||||||
|
input.selectionStart = input.value.length;
|
||||||
|
document.body.append(input);
|
||||||
|
|
||||||
|
caretHelperInstance.getBeforeCursor.mockReturnValue('/');
|
||||||
|
caretHelperInstance.getCursorOffset.mockReturnValue({ left: 15, top: 25 });
|
||||||
|
|
||||||
|
const { AutoComplete } = await import(AUTOCOMPLETE_MODULE);
|
||||||
|
const autoComplete = new AutoComplete(input, 'loras', { showPreview: true, minChars: 1 });
|
||||||
|
|
||||||
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
|
||||||
|
// Allow the async preview tooltip import to resolve
|
||||||
|
await Promise.resolve();
|
||||||
|
await Promise.resolve();
|
||||||
|
|
||||||
|
const commandNames = autoComplete.items.map((item) => item.command);
|
||||||
|
expect(commandNames).toContain('/af');
|
||||||
|
expect(previewTooltipMock.show).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows /noaf command for loras when active-filters autocomplete is on', async () => {
|
||||||
|
settingGetMock.mockImplementation((key) => {
|
||||||
|
if (key === 'loramanager.lora_active_filters_autocomplete') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
const input = document.createElement('textarea');
|
||||||
|
input.value = '/';
|
||||||
|
input.selectionStart = input.value.length;
|
||||||
|
document.body.append(input);
|
||||||
|
|
||||||
|
caretHelperInstance.getBeforeCursor.mockReturnValue('/');
|
||||||
|
caretHelperInstance.getCursorOffset.mockReturnValue({ left: 15, top: 25 });
|
||||||
|
|
||||||
|
const { AutoComplete } = await import(AUTOCOMPLETE_MODULE);
|
||||||
|
const autoComplete = new AutoComplete(input, 'loras', { showPreview: false, minChars: 1 });
|
||||||
|
|
||||||
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
|
||||||
|
const commandNames = autoComplete.items.map((item) => item.command);
|
||||||
|
expect(commandNames).toContain('/noaf');
|
||||||
|
expect(commandNames).not.toContain('/af');
|
||||||
|
expect(commandNames).toContain('/noactivefilters');
|
||||||
|
expect(commandNames).not.toContain('/activefilters');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('toggles the active-filters setting when /activefilters alias is used', async () => {
|
||||||
|
const input = document.createElement('textarea');
|
||||||
|
input.value = '/activefilters';
|
||||||
|
input.selectionStart = input.value.length;
|
||||||
|
input.focus = vi.fn();
|
||||||
|
input.setSelectionRange = vi.fn();
|
||||||
|
document.body.append(input);
|
||||||
|
|
||||||
|
caretHelperInstance.getBeforeCursor.mockReturnValue('/activefilters');
|
||||||
|
caretHelperInstance.getCursorOffset.mockReturnValue({ left: 15, top: 25 });
|
||||||
|
|
||||||
|
const { AutoComplete } = await import(AUTOCOMPLETE_MODULE);
|
||||||
|
const autoComplete = new AutoComplete(input, 'loras', { showPreview: false, minChars: 1 });
|
||||||
|
|
||||||
|
const commandResult = autoComplete._parseCommandInput('/activefilters');
|
||||||
|
expect(commandResult.command).toBeDefined();
|
||||||
|
expect(commandResult.command.type).toBe('toggle_setting');
|
||||||
|
expect(commandResult.command.value).toBe(true);
|
||||||
|
|
||||||
|
await autoComplete._handleToggleSettingCommand(commandResult.command);
|
||||||
|
|
||||||
|
expect(settingSetMock).toHaveBeenCalledWith('loramanager.lora_active_filters_autocomplete', true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('toggles the active-filters setting when /af is accepted', async () => {
|
||||||
|
const input = document.createElement('textarea');
|
||||||
|
input.value = '/';
|
||||||
|
input.selectionStart = input.value.length;
|
||||||
|
input.focus = vi.fn();
|
||||||
|
input.setSelectionRange = vi.fn();
|
||||||
|
document.body.append(input);
|
||||||
|
|
||||||
|
caretHelperInstance.getBeforeCursor.mockReturnValue('/');
|
||||||
|
caretHelperInstance.getCursorOffset.mockReturnValue({ left: 15, top: 25 });
|
||||||
|
|
||||||
|
const { AutoComplete } = await import(AUTOCOMPLETE_MODULE);
|
||||||
|
const autoComplete = new AutoComplete(input, 'loras', { showPreview: false, minChars: 1 });
|
||||||
|
|
||||||
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
|
||||||
|
const afItem = autoComplete.items.find((item) => item.command === '/af');
|
||||||
|
expect(afItem).toBeDefined();
|
||||||
|
|
||||||
|
// Simulate the input being cleared after the command is accepted so the
|
||||||
|
// cleared-token input event does not re-trigger command parsing.
|
||||||
|
caretHelperInstance.getBeforeCursor.mockReturnValue('');
|
||||||
|
await autoComplete._handleToggleSettingCommand(afItem);
|
||||||
|
|
||||||
|
expect(settingSetMock).toHaveBeenCalledWith('loramanager.lora_active_filters_autocomplete', true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('appends active filter params to loras autocomplete requests when enabled', async () => {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
|
||||||
|
settingGetMock.mockImplementation((key) => {
|
||||||
|
if (key === 'loramanager.lora_active_filters_autocomplete') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
localStorage.setItem('lora_manager_loras_filters', JSON.stringify({
|
||||||
|
baseModel: ['SD 1.5'],
|
||||||
|
tags: { anime: 'include', nsfw: 'exclude', __no_tags__: 'exclude' },
|
||||||
|
autoTags: { I2V: 'include' },
|
||||||
|
modelTypes: ['standard'],
|
||||||
|
tagLogic: 'all',
|
||||||
|
license: { noCredit: 'include', allowSelling: 'exclude' },
|
||||||
|
}));
|
||||||
|
localStorage.setItem('lora_manager_loras_activeFolder', 'MyLoras');
|
||||||
|
localStorage.setItem('lora_manager_loras_recursiveSearch', 'true');
|
||||||
|
|
||||||
|
fetchApiMock.mockResolvedValue({
|
||||||
|
json: () => Promise.resolve({ success: true, relative_paths: ['models/example.safetensors'] }),
|
||||||
|
});
|
||||||
|
|
||||||
|
caretHelperInstance.getBeforeCursor.mockReturnValue('example');
|
||||||
|
caretHelperInstance.getCursorOffset.mockReturnValue({ left: 15, top: 25 });
|
||||||
|
|
||||||
|
const input = document.createElement('textarea');
|
||||||
|
document.body.append(input);
|
||||||
|
|
||||||
|
const { AutoComplete } = await import(AUTOCOMPLETE_MODULE);
|
||||||
|
new AutoComplete(input, 'loras', { debounceDelay: 0, showPreview: false, minChars: 1 });
|
||||||
|
|
||||||
|
input.value = 'example';
|
||||||
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
|
||||||
|
await vi.runAllTimersAsync();
|
||||||
|
await Promise.resolve();
|
||||||
|
|
||||||
|
const calledUrl = fetchApiMock.mock.calls[0][0];
|
||||||
|
expect(calledUrl).toContain('/lm/loras/relative-paths?search=example&limit=100');
|
||||||
|
expect(calledUrl).toContain('folder=MyLoras');
|
||||||
|
expect(calledUrl).toContain('recursive=true');
|
||||||
|
expect(calledUrl).toContain('tag_include=anime');
|
||||||
|
expect(calledUrl).toContain('tag_exclude=nsfw');
|
||||||
|
expect(calledUrl).toContain('tag_exclude=__no_tags__');
|
||||||
|
expect(calledUrl).toContain('auto_tag_include=I2V');
|
||||||
|
expect(calledUrl).toContain('tag_logic=all');
|
||||||
|
expect(calledUrl).toContain('credit_required=false');
|
||||||
|
expect(calledUrl).toContain('allow_selling_generated_content=false');
|
||||||
|
const parsed = new URL(calledUrl, 'https://example.com');
|
||||||
|
expect(parsed.searchParams.get('base_model')).toBe('SD 1.5');
|
||||||
|
expect(parsed.searchParams.get('model_type')).toBe('standard');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('keeps the default loras autocomplete URL when active-filters mode is off', async () => {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
|
||||||
|
fetchApiMock.mockResolvedValue({
|
||||||
|
json: () => Promise.resolve({ success: true, relative_paths: ['models/example.safetensors'] }),
|
||||||
|
});
|
||||||
|
|
||||||
|
caretHelperInstance.getBeforeCursor.mockReturnValue('example');
|
||||||
|
caretHelperInstance.getCursorOffset.mockReturnValue({ left: 15, top: 25 });
|
||||||
|
|
||||||
|
const input = document.createElement('textarea');
|
||||||
|
document.body.append(input);
|
||||||
|
|
||||||
|
const { AutoComplete } = await import(AUTOCOMPLETE_MODULE);
|
||||||
|
new AutoComplete(input, 'loras', { debounceDelay: 0, showPreview: false, minChars: 1 });
|
||||||
|
|
||||||
|
input.value = 'example';
|
||||||
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
|
||||||
|
await vi.runAllTimersAsync();
|
||||||
|
await Promise.resolve();
|
||||||
|
|
||||||
|
expect(fetchApiMock).toHaveBeenCalledWith('/lm/loras/relative-paths?search=example&limit=100');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('sends the filter-pipeline signal even when no filters are stored', async () => {
|
||||||
|
// Regression: with filter mode on but no folder/filters stored, the request
|
||||||
|
// carried no params, so the backend skipped the filter pipeline and global
|
||||||
|
// settings like show_only_sfw diverged from the list endpoint.
|
||||||
|
vi.useFakeTimers();
|
||||||
|
|
||||||
|
settingGetMock.mockImplementation((key) => {
|
||||||
|
if (key === 'loramanager.lora_active_filters_autocomplete') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
localStorage.removeItem('lora_manager_loras_filters');
|
||||||
|
localStorage.removeItem('lora_manager_loras_activeFolder');
|
||||||
|
localStorage.removeItem('lora_manager_loras_recursiveSearch');
|
||||||
|
|
||||||
|
fetchApiMock.mockResolvedValue({
|
||||||
|
json: () => Promise.resolve({ success: true, relative_paths: ['models/example.safetensors'] }),
|
||||||
|
});
|
||||||
|
|
||||||
|
caretHelperInstance.getBeforeCursor.mockReturnValue('example');
|
||||||
|
caretHelperInstance.getCursorOffset.mockReturnValue({ left: 15, top: 25 });
|
||||||
|
|
||||||
|
const input = document.createElement('textarea');
|
||||||
|
document.body.append(input);
|
||||||
|
|
||||||
|
const { AutoComplete } = await import(AUTOCOMPLETE_MODULE);
|
||||||
|
new AutoComplete(input, 'loras', { debounceDelay: 0, showPreview: false, minChars: 1 });
|
||||||
|
|
||||||
|
input.value = 'example';
|
||||||
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
|
||||||
|
await vi.runAllTimersAsync();
|
||||||
|
await Promise.resolve();
|
||||||
|
|
||||||
|
const calledUrl = fetchApiMock.mock.calls[0][0];
|
||||||
|
expect(calledUrl).toContain('recursive=true');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('omits folder param when active folder is root and recursion is enabled', async () => {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
|
||||||
|
settingGetMock.mockImplementation((key) => {
|
||||||
|
if (key === 'loramanager.lora_active_filters_autocomplete') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
localStorage.setItem('lora_manager_loras_filters', JSON.stringify({
|
||||||
|
baseModel: ['SD 1.5'],
|
||||||
|
tags: { anime: 'include' },
|
||||||
|
}));
|
||||||
|
localStorage.setItem('lora_manager_loras_activeFolder', '');
|
||||||
|
localStorage.removeItem('lora_manager_loras_recursiveSearch');
|
||||||
|
|
||||||
|
fetchApiMock.mockResolvedValue({
|
||||||
|
json: () => Promise.resolve({ success: true, relative_paths: ['models/example.safetensors'] }),
|
||||||
|
});
|
||||||
|
|
||||||
|
caretHelperInstance.getBeforeCursor.mockReturnValue('example');
|
||||||
|
caretHelperInstance.getCursorOffset.mockReturnValue({ left: 15, top: 25 });
|
||||||
|
|
||||||
|
const input = document.createElement('textarea');
|
||||||
|
document.body.append(input);
|
||||||
|
|
||||||
|
const { AutoComplete } = await import(AUTOCOMPLETE_MODULE);
|
||||||
|
new AutoComplete(input, 'loras', { debounceDelay: 0, showPreview: false, minChars: 1 });
|
||||||
|
|
||||||
|
input.value = 'example';
|
||||||
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
|
||||||
|
await vi.runAllTimersAsync();
|
||||||
|
await Promise.resolve();
|
||||||
|
|
||||||
|
const calledUrl = fetchApiMock.mock.calls[0][0];
|
||||||
|
expect(calledUrl).not.toContain('folder=');
|
||||||
|
expect(calledUrl).toContain('recursive=true');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('sends an empty folder param for root with recursion disabled, mirroring the page list', async () => {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
|
||||||
|
settingGetMock.mockImplementation((key) => {
|
||||||
|
if (key === 'loramanager.lora_active_filters_autocomplete') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
localStorage.setItem('lora_manager_loras_filters', JSON.stringify({
|
||||||
|
baseModel: ['SD 1.5'],
|
||||||
|
tags: { anime: 'include' },
|
||||||
|
}));
|
||||||
|
localStorage.setItem('lora_manager_loras_activeFolder', '');
|
||||||
|
localStorage.setItem('lora_manager_loras_recursiveSearch', 'false');
|
||||||
|
|
||||||
|
fetchApiMock.mockResolvedValue({
|
||||||
|
json: () => Promise.resolve({ success: true, relative_paths: ['models/example.safetensors'] }),
|
||||||
|
});
|
||||||
|
|
||||||
|
caretHelperInstance.getBeforeCursor.mockReturnValue('example');
|
||||||
|
caretHelperInstance.getCursorOffset.mockReturnValue({ left: 15, top: 25 });
|
||||||
|
|
||||||
|
const input = document.createElement('textarea');
|
||||||
|
document.body.append(input);
|
||||||
|
|
||||||
|
const { AutoComplete } = await import(AUTOCOMPLETE_MODULE);
|
||||||
|
new AutoComplete(input, 'loras', { debounceDelay: 0, showPreview: false, minChars: 1 });
|
||||||
|
|
||||||
|
input.value = 'example';
|
||||||
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
|
||||||
|
await vi.runAllTimersAsync();
|
||||||
|
await Promise.resolve();
|
||||||
|
|
||||||
|
const calledUrl = fetchApiMock.mock.calls[0][0];
|
||||||
|
expect(calledUrl).toContain('folder=');
|
||||||
|
expect(calledUrl).toContain('recursive=false');
|
||||||
|
const parsed = new URL(calledUrl, 'https://example.com');
|
||||||
|
expect(parsed.searchParams.get('folder')).toBe('');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('applies the active folder even when no filter-panel filters are set', async () => {
|
||||||
|
// Regression: folder was skipped when lora_manager_loras_filters was
|
||||||
|
// missing because the filters key gate returned early.
|
||||||
|
vi.useFakeTimers();
|
||||||
|
|
||||||
|
settingGetMock.mockImplementation((key) => {
|
||||||
|
if (key === 'loramanager.lora_active_filters_autocomplete') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
localStorage.removeItem('lora_manager_loras_filters');
|
||||||
|
localStorage.setItem('lora_manager_loras_activeFolder', 'Flux.1 D/style');
|
||||||
|
|
||||||
|
fetchApiMock.mockResolvedValue({
|
||||||
|
json: () => Promise.resolve({ success: true, relative_paths: ['Flux.1 D/style/3D_Fairytales.safetensors'] }),
|
||||||
|
});
|
||||||
|
|
||||||
|
caretHelperInstance.getBeforeCursor.mockReturnValue('3D');
|
||||||
|
caretHelperInstance.getCursorOffset.mockReturnValue({ left: 15, top: 25 });
|
||||||
|
|
||||||
|
const input = document.createElement('textarea');
|
||||||
|
document.body.append(input);
|
||||||
|
|
||||||
|
const { AutoComplete } = await import(AUTOCOMPLETE_MODULE);
|
||||||
|
new AutoComplete(input, 'loras', { debounceDelay: 0, showPreview: false, minChars: 1 });
|
||||||
|
|
||||||
|
input.value = '3D';
|
||||||
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
|
||||||
|
await vi.runAllTimersAsync();
|
||||||
|
await Promise.resolve();
|
||||||
|
|
||||||
|
const calledUrl = fetchApiMock.mock.calls[0][0];
|
||||||
|
expect(calledUrl).toContain('folder=Flux.1+D%2Fstyle');
|
||||||
|
expect(calledUrl).toContain('recursive=true');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2155,4 +2155,35 @@ describe('Interaction-level regression coverage', () => {
|
|||||||
excludedItem.dispatchEvent(new Event('click', { bubbles: true }));
|
excludedItem.dispatchEvent(new Event('click', { bubbles: true }));
|
||||||
expect(window.pageControls.enterExcludedView).toHaveBeenCalledTimes(1);
|
expect(window.pageControls.enterExcludedView).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('routes single-model example downloads to missing-only and force paths', async () => {
|
||||||
|
document.body.innerHTML = `
|
||||||
|
<div id="loraContextMenu" class="context-menu">
|
||||||
|
<div class="context-menu-item has-submenu" data-has-submenu="download-examples">
|
||||||
|
<div class="context-submenu">
|
||||||
|
<div class="context-menu-item" data-action="download-examples"></div>
|
||||||
|
<div class="context-menu-item" data-action="download-examples-force"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
const { LoraContextMenu } = await import('../../../static/js/components/ContextMenu/LoraContextMenu.js');
|
||||||
|
const contextMenu = new LoraContextMenu();
|
||||||
|
|
||||||
|
const card = document.createElement('div');
|
||||||
|
card.className = 'model-card';
|
||||||
|
card.dataset.filepath = '/models/test.safetensors';
|
||||||
|
card.dataset.sha256 = 'abc123hash';
|
||||||
|
document.body.appendChild(card);
|
||||||
|
|
||||||
|
contextMenu.showMenu(100, 100, card);
|
||||||
|
|
||||||
|
document.querySelector('[data-action="download-examples"]').dispatchEvent(new Event('click', { bubbles: true }));
|
||||||
|
expect(downloadExampleImagesApiMock).toHaveBeenCalledWith(['abc123hash'], null, { force: false });
|
||||||
|
|
||||||
|
contextMenu.showMenu(100, 100, card);
|
||||||
|
document.querySelector('[data-action="download-examples-force"]').dispatchEvent(new Event('click', { bubbles: true }));
|
||||||
|
expect(downloadExampleImagesApiMock).toHaveBeenCalledWith(['abc123hash'], null, { force: true });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user