Compare commits

...
3 Commits
Author SHA1 Message Date
ketle-manandClaude Sonnet 4.6 3190cc1443 feat: Models table sort, Gallery Load GenUI, GenerateUI Save button, help update (v0.3.35)
- Models tab: click column header to sort table (asc▲/desc▼/clear); active column highlighted in accent color; E/D label for Enable/Disable column
- Gallery tab: Load GenUI button loads embedded workflow into GenerateUI tab; Metadata button restyled green; warning toast if no workflow or unsupported format
- GenerateUI tab: Save button at right end of subtab row; filename dialog defaults to current workflow name; saves to Workflow tab via import API
- Help: Models tab note and Troubleshooting entry added for model loading error after move/delete (requires Hard Reset or ComfyUI restart)
- README and DEVLOG updated for v0.3.35

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 10:27:46 +09:00
ketle-manandClaude Sonnet 4.6 070e378314 feat: Models table Type/BaseModel columns, modal delete, bulk move, B/S fix, Gallery-Metadata link (v0.3.34)
- Table view: add CivitAI Type and Base Model columns between Subdirectory and Extension
- Detail modal: Delete button removes model file + all sidecar files
- Bulk action bar: file move operation (model + sidecars) with subfolder create; 3-row layout (Group/Badge/File); Select button green; dropdown width 330px; Delete Files moved to File row right end; X button removed
- B/S buttons (Checkpoint/LoRA table+card): targeted active-class toggle instead of full grid re-render; renderModelGrid only called when showBatchOnly filter is active
- Backend: GET /api/wfm/models/subdirs and POST /api/wfm/models/move with path traversal protection and _VALID_MODEL_TYPES whitelist
- Gallery: Alt+click or Metadata button opens selected image in Metadata tab via loadFileIntoMetadataTab()
- Help and DEVLOG updated

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 16:11:22 +09:00
ketle-manandClaude Sonnet 4.6 dbc9ff0820 fix: LoRA pane load overwrite, tab reset, Stack group visibility, CLIPTextEncodeEditPlus mapping, Stack Apply trigger words (v0.3.33)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 00:49:21 +09:00
15 changed files with 916 additions and 88 deletions
+119
View File
@@ -1,5 +1,124 @@
# DEVLOG - ComfyUI-Workflow-Studio
## 2026-06-10: v0.3.35 — テーブルソート・Load GenUI・ワークフロー保存
### 変更内容
#### Modelsタブ テーブルビュー: 列ヘッダークリックでソート(`static/js/models-tab.js`, `static/css/main.css`)
- `state` に `sortColumn`(null または列キー)と `sortDir`(`"asc"` / `"desc"`)を追加
- `sortModels(models)` 関数を追加:ソート列に応じて ★・ファイル名・サブディレクトリ・Type・Base Model・拡張子・Tags・Memo・E/D の各キーで昇降順ソートを実行
- `filterModels()` の末尾で `sortModels()` を呼び出し、フィルタ後の全ビューに適用
- `thSortHtml(label, col, extraClass, extraStyle)` ヘルパーを追加:アクティブ列はアクセントカラー(`--wfm-accent`)に変色し ▲/▼ 矢印を表示
- `renderTableView` のヘッダーをすべて `thSortHtml` ベースに変更。クリックで asc → desc → 解除のサイクル
- Enable/Disable 列の空ヘッダーを **E/D** に変更
- `.wfm-table-th-sortable` CSS を追加(`cursor: pointer`、`-webkit-user-select: none`、`white-space: nowrap`、ホバー時アクセントカラー)
#### ギャラリータブ: Load GenUI ボタン追加(`templates/index.html`, `static/js/gallery-tab.js`, `static/css/gallery-tab.css`)
- 詳細パネルのタブナビに **Load GenUI**(青)ボタン(`wfm-gallery-load-genui-btn`)を Metadata ボタンの右隣に追加
- `gallery-tab.js` に `loadWorkflowIntoEditor` を `generate-tab.js` からインポート
- クリック時の動作:画像未選択 → warning トースト / ワークフロー未埋め込み → warning トースト / 非対応フォーマット → `loadWorkflowIntoEditor` 内でトースト表示 / 成功時 → GenerateUI タブへ自動切り替え
- **Metadata** ボタンに `wfm-gallery-action-btn-green` クラスを追加し緑色背景に変更
- `gallery-tab.css` に `.wfm-gallery-action-btn-green`(緑)・`.wfm-gallery-action-btn-primary`(`--wfm-primary` 青)スタイルを追加:`padding`・`border-radius`・`align-self: center`・`margin` を共通指定
#### GenerateUIタブ: Save ボタン追加(`templates/index.html`, `static/js/generate-tab.js`)
- `wfm-gen-subtab-nav` の右端(`margin-left:auto`)に **Save** ボタン(`wfm-gen-save-btn`、`wfm-btn-primary`)を設置
- `generate-tab.js` のインポートに `openModal`・`closeModal` を追加
- `saveCurrentWorkflow()` 関数を追加:
- ワークフロー未ロード時は warning トースト
- モーダルでファイル名を入力(デフォルト: 現在のワークフロー名)。Enter キーでも確定可能
- `comfyUI.currentWorkflow` を JSON シリアライズして `File` オブジェクトを生成、`POST /api/wfm/workflows/import` で Workflow タブに保存
- 保存成功後 `wfm-gen-wf-name` の表示・`dataset.filename` を新ファイル名に更新
- エラー時はトーストでメッセージ表示
#### ヘルプ更新(`templates/index.html`)
- GenerateUI Tab(`wfm-help-gen-2`):Save ボタンの説明を追加
- Gallery Tab(`wfm-help-gallery-8/10`):「Metadata tab」→「JSON tab」に表記修正;`wfm-help-gallery-12/13` として Metadata(緑)・Load GenUI(青)ボタンの説明を新規追加
- Models Tab(`wfm-help-models-2`):テーブルヘッダークリックソートと E/D 列の説明を追記
---
## 2026-06-09: v0.3.34 — Modelsタブ テーブルビュー強化・バルク操作改善
### 変更内容
#### テーブルビュー: Type / Base Model 列追加(`static/js/models-tab.js`, `static/css/main.css`)
- `renderTableView` にて Subdirectory と Extension 列の間に **Type** / **Base Model** 列を追加
- データは `state.civitaiCache[sha256]` から取得(追加API呼び出しなし)
- `.wfm-table-th-civtype` / `.wfm-table-td-civtype`(70px)、`.wfm-table-th-basemodel` / `.wfm-table-td-basemodel`(110px)を追加
- `.wfm-table-th-filename` / `.wfm-table-td-filename` の `max-width` を 160px に制限し、overflow ellipsis 適用
#### モーダル: Delete ボタン追加(`static/js/models-tab.js`)
- 詳細モーダルにモデル削除ボタンを設置
- `POST /api/wfm/models/delete` を呼び出してモデルファイル本体および全サイドカーファイル(`.preview.png`、`.json`、`.civitai.info`、`.metadata.json`、`.cm-info.json` など)を削除
- 削除後にローカルステート(`modelsByType`、`modelMetadata`、`disabledModels`、`selectedModels`)を差分更新して `renderModelGrid()` を呼び出す
#### バルクアクションバー: ファイル移動機能追加(`static/js/models-tab.js`, `static/css/main.css`)
- `fetchSubdirs()` 関数追加:`GET /api/wfm/models/subdirs?type=` でルート直下のサブフォルダ一覧を取得し `state.subdirs` にキャッシュ
- `bulkMoveModels(destSubdir)` 関数追加:`POST /api/wfm/models/move` で選択モデルをサブフォルダへ移動(サイドカーファイルも同時移動)。ローカルステートのキー(`modelsByType`、`modelMetadata`、`disabledModels`)を移動後の相対パスに更新
- 移動後に `fetchSubdirs()` → `renderDirFilter()` → `renderModelGrid()` → `renderBulkActionBar()` を連続実行
#### バルクアクションバー: UI再構成(`static/js/models-tab.js`, `static/css/main.css`)
- バーを **ヘッダー行**(件数表示・Deselect All・Favorite 操作)+**3行グリッド**(Group / Badge / File)に再構成
- **Group 行**:グループ選択ドロップダウン・Add / Remove ボタン・新規グループ名入力・Create & Add
- **Badge 行**:バッジ選択ドロップダウン・+Badge / −Badge ボタン
- **File 行**:移動先フォルダ選択ドロップダウン・Move ボタン・新規フォルダ名入力・Create & Move・Delete Files(行右端)
- Select ボタンを緑色(`.wfm-btn-success`)に変更(`templates/index.html`)
- X(Clear Selection)ボタンを削除。Deselect All のみを使用
- 各ドロップダウン幅を 110px → 330px に拡大
#### バックエンド: subdirs / move エンドポイント追加(`py/services/models_service.py`, `py/routes/models_routes.py`)
- `ModelsService.get_subdirs(model_type)` — ルート直下のディレクトリ名一覧を返す
- `ModelsService.move_models(model_type, model_names, dest_subdir)` — モデルと全サイドカーを `shutil.move` で移動。パストラバーサル防止(`..` チェック・セパレーター禁止・絶対パス禁止・`resolve().relative_to()` containment検証)・上書き防止を実装
- `GET /api/wfm/models/subdirs`、`POST /api/wfm/models/move` ルートを登録。`_VALID_MODEL_TYPES` frozenset でモデルタイプをホワイトリスト検証
- `_SIDECAR_EXTENSIONS` に `.metadata.json`、`.cm-info.json` を追加(delete / move 両操作に反映)
#### B/S ボタン: 行移動バグ修正(`static/js/models-tab.js`)
- `toggleBatch` / `toggleStack` から `renderModelGrid()` 呼び出しを削除
- テーブルビュー・カードビュー両方の B / S ボタンハンドラーを `async` に変更し、`await` 後にボタンの `active` クラスのみを差分更新(`classList.toggle`)
- `state.showBatchOnly` フィルター有効時(バッチから外すと行が消えるべき場合)のみ `renderModelGrid()` を呼び出す
#### ギャラリー → Metadata タブ連携(`static/js/gallery-tab.js`, `static/js/metadata-tab.js`)
- `metadata-tab.js` に `loadFileIntoMetadataTab(file)` をエクスポート:Metadata タブへ切り替えてファイルを読み込む外部 API
- `gallery-tab.js` に `openImageInMetadataTab(img)` を追加:画像を fetch してバイナリを Metadata タブに渡す
- ギャラリー画像カード(サムネイル・テーブル両ビュー)で **Alt+クリック** すると Metadata タブで開く
- 詳細パネルに **Metadata ボタン** を追加(`index.html` の `wfm-gallery-open-metadata-btn`):選択中の画像を Metadata タブで開く
- 詳細タブ切り替えロジックを修正(`data-detail-tab` を持つボタンのみ active/display を切り替え、Metadata ボタンを除外)
#### ヘルプ更新(`templates/index.html`)
- Models Tab ヘルプ(`wfm-help-models-2`、`-6`、`-7`、`-11`)を今回の変更に合わせて更新
---
## 2026-06-09: v0.3.33 — LoRAペイン・ワークフロー解析バグ修正
### 変更内容
#### LoRAペイン:ワークフロー読み込み時のLoraManager上書き防止(`static/js/comfyui-editor.js`)
- `renderLoraPane` 末尾にあった「Auto-apply Stack to LoraManager on load」ブロックを削除
- ワークフロー読み込み時にModelタブのStackグループ内容が `inputs.loras` / `inputs.text` を上書きし、RAW JSONが変わるバグを修正
- Apply ボタン押下時のみStackがLoraManagerに書き込まれる正しい動作に
#### LoRAペイン:🔄ボタン押下でSingleタブに戻るバグ修正(`static/js/comfyui-editor.js`)
- `renderLoraPane` 呼び出し前に現在のアクティブタブを `_prevActiveTab` に保存
- `el.innerHTML` 再構築後にタブ状態(activeクラス・display)を復元する処理を追加
- 🔄ボタン・モデルタブ切り替えによる再レンダリング後もStackタブに留まるよう修正
#### ModelsタブCheckpointへのStackグループ非表示(`static/js/models-tab.js`)
- `loadModelsForCurrentType` のグループロード後、`STACK_MODEL_TYPES`(lora のみ)に含まれないタイプでは `state.modelGroups["Stack"]` をメモリ上から削除
- Checkpointなどのタイプでグループフィルターおよびサイドパネルのグループ管理にStackが表示されなくなった
#### CLIPTextEncodeEditPlus ウィジェット値マッピング修正(`static/js/comfyui-workflow.js`)
- `convertUiToApi` でUIスロット入力にリンクが接続されている場合(`linkedSlotNames`)、`widgets_values` のインデックスを進めないよう変更
- 従来は `object_info` の STRING 型オプション入力(`text1` 等)がウィジェット名リストに含まれ、リンクあり判定でインデックスがズレていた
- `widgets_values: ["girl", "+af", ""]` で `text_edit="girl"` / `mode="+af"` が正しくマッピングされるよう修正
#### Stack Apply時のTrigger Words処理修正(`static/js/comfyui-editor.js`)
- Applyクリックハンドラー内でトリガーワードをレンダリング時のスナップショット変数から取得していたため、チェックボックス変更が反映されないバグを修正
- `currentAllTriggers` / `currentActiveTriggers` を Apply 時点で `_stackActive` + `metadata` + `civitaiCache` から動的に再計算するよう変更
- 修正前の不具合:1回目ApplyはLORA SYNTAXのみ(TRIGGER WORDSなし)、2回目で追加される / モデル無効でApply後もTRIGGER WORDSが残る
---
## 2026-06-08: v0.3.32 — Lora Loader (LoraManager) LoRA検出対応・ライブラリ機能拡張
### 変更内容
+23 -5
View File
@@ -5,7 +5,7 @@ A comprehensive workflow management and generation UI plugin for [ComfyUI](https
Browse, organize, and execute workflows directly from a dedicated studio interface — without switching between windows or manually editing JSON.
![Workflow Studio](https://img.shields.io/badge/ComfyUI-Custom_Node-blue)
![Version](https://img.shields.io/badge/version-0.3.32-green)
![Version](https://img.shields.io/badge/version-0.3.35-green)
## Screenshots
@@ -48,6 +48,7 @@ Browse, organize, and execute workflows directly from a dedicated studio interfa
### GenerateUI Tab (v0.3.5)
- **5-tab layout** — Input / Model / Settings / Feeder / Batch tabs; Input, Model, and Settings each include a Raw JSON column on the right for instant preview and direct editing
- **Save button** — located at the right end of the subtab row; opens a filename dialog (default: current workflow name) and saves the current workflow as a `.json` file to the Workflow tab via the import API
- **Input tab** — Prompt (top) and Image drag-and-drop (bottom) in the left column; Raw JSON (540px) in the right column
- **Model tab** — Checkpoint, VAE, LoRA, ControlNet, UNET, TextEncoder selectors with filter; Raw JSON on the right
- **Settings tab** — KSampler and Latent Image side by side at 50% width each; Raw JSON on the right
@@ -127,6 +128,7 @@ Requires the **[comfyui-image-feeder](https://github.com/ketle-man/comfyui-image
- **Favorites** — star images inline without reopening the detail panel
- **Detail panel** — view filename, path, tags, groups, and metadata in a slide-out panel
- **Workflow viewer** — Metadata tab displays workflow JSON from PNG embedded data (`prompt` / `workflow` keys) or from workflow saved by the Generate UI tab
- **Load GenUI button** — loads the embedded ComfyUI workflow from the selected image directly into the GenerateUI tab; shows a warning toast if no workflow is embedded or the format is unsupported; Metadata button is styled green, Load GenUI button uses the primary accent color
- **Workflow auto-save** — images generated from the Generate UI tab have their workflow automatically saved to gallery metadata
- **Output folder configurable** — set the scanned output folder from Settings tab
- **Performance** — folder-level mtime cache (30s TTL) for fast incremental refresh; tree expansion state preserved across folder operations
@@ -141,7 +143,8 @@ Requires the **[comfyui-image-feeder](https://github.com/ketle-man/comfyui-image
### Models Tab (v0.2.3)
- **Model Browser** — browse all installed ComfyUI models (Checkpoint, LoRA, VAE, ControlNet, UNET, TextEncoder, Hypernetwork, Embedding) with sub-tab switching
- **Thumbnail / Table views** — switch between view modes with pagination (24 items per page)
- **Thumbnail / Table views** — switch between view modes with pagination (24 items per page); Table view includes **Type** and **Base Model** columns sourced from cached CivitAI data, displayed between the Subdirectory and Extension columns; Enable/Disable column labeled **E/D**
- **Table column sort** — click any column header to sort ascending (▲), click again for descending (▼), click a third time to clear; active column highlighted in accent color
- **Search & Filter** — full-text search, filter by tags, groups, and favorites
- **User-defined badges** — assign free-label badges to models; badge colors shared with the Workflow tab palette
- **Side panel tabs** — opens to CivitAI tab by default when a model is selected; Info (file path display with click-to-copy, tags, memo), Groups management, CivitAI integration
@@ -149,13 +152,16 @@ Requires the **[comfyui-image-feeder](https://github.com/ketle-man/comfyui-image
- **CivitAI panel — Info / Sample sub-tabs** — Info tab shows model details (name, type, base model, hash, trigger words, tags, description); Sample tab shows all sample images (count shown in tab label); clicking any image opens the full-size version in a new tab
- **CivitAI panel states** — three distinct states: not yet checked (fetch button), checked but not found on CivitAI (re-check button with notice), and found (full info display); clicking the CivitAI tab always refreshes to the latest state
- **Batch CivitAI fetch** — one-click batch fetch using `POST /model-versions/by-hash` (up to 100 models per request) with SSE progress streaming; previews are auto-saved for models without one
- **Detail modal** — preview image, CivitAI info, thumbnail change via file upload
- **Detail modal** — preview image, CivitAI info, thumbnail change via file upload; **Delete** button permanently removes the model file and all associated sidecar files (preview images, `.json`, `.civitai.info`, `.metadata.json`, `.cm-info.json`)
- **GenUI Model button** — apply the selected model directly to the corresponding node in GenerateUI's current workflow (Checkpoint, LoRA, VAE, ControlNet, UNET, TextEncoder)
- **Group management** — create, rename, delete groups and assign/remove models; groups are scoped per model type (checkpoint groups only appear in the Checkpoint tab)
- **Group management** — create, rename, delete groups and assign/remove models; groups are scoped per model type (checkpoint groups only appear in the Checkpoint tab); Checkpoint and LoRA tabs include **B (Batch)** and **S (Stack)** quick-assign buttons per card/row for one-click group membership toggle without grid re-render
- **Table view memo** — memo column displayed in table view for quick reference
- **Preview images** — auto-detect `{model_stem}.preview.png` next to model files
- **Enable / Disable models** — hide models from ComfyUI by renaming the file extension (`.disabled` suffix); toggle per card (⏸ button), per group (Enable All / Disable All), or filter by status (All / Enabled / Disabled)
- **Multi-select & bulk operations** — enter selection mode to check multiple models; bulk action bar supports: **Deselect All** (clear all without exiting select mode), **★ Favorite / ☆ Unfavorite** (toggle favorites for all selected), **Add / Remove from Group**, **Create & Add** (new group), **+Badge / −Badge** (apply or remove a badge from all selected), and permanent **Delete Files** (model file + preview images + sidecar files such as `.json` / `.info`)
- **Multi-select & bulk operations** — click the green **Select** button to enter selection mode and check multiple models; the bulk action bar is organized in three rows:
- **Group row** — select an existing group and **Add** / **Remove**, or type a new name and **Create & Add**
- **Badge row** — select a badge and **+Badge** / **−Badge** to apply or remove from all selected
- **File row** — select a destination subfolder (or type a new folder name and create it) then **Move** to relocate the model file with all sidecar files; **Delete Files** (right end) permanently removes selected models and all associated files
### AI TOOL Tab (v0.3.14)
- **3-pane layout** — Translation (40%) | TOOLS (40%) | Settings (20%); all panes always visible simultaneously; no sub-tab switching required
@@ -280,6 +286,18 @@ Click the **camera icon** (next to the W button) in ComfyUI's top bar to capture
## Changelog
### v0.3.35
- **Models tab — Table column sort** — click any column header to sort ascending (▲), click again for descending (▼), click a third time to clear; active column name highlighted in accent color; Enable/Disable column header now labeled **E/D**
- **Gallery tab — Load GenUI button** — new button to the right of the Metadata button in the detail panel; loads the embedded ComfyUI workflow from the selected image directly into the GenerateUI tab; warning toast shown if no workflow is embedded or the format is unsupported; Metadata button restyled green, Load GenUI uses primary accent color
- **GenerateUI tab — Save button** — new button at the right end of the subtab row; opens a filename dialog (default: current workflow name) and saves the current workflow as a `.json` file to the Workflow tab via the import API; workflow name label updates to the saved filename on success
### v0.3.33
- **LoRA pane — workflow load no longer overwrites LoraManager** — removed the auto-apply block that replaced `inputs.loras` / `inputs.text` with Stack group contents on every workflow load; Stack is now applied only when the Apply button is pressed
- **LoRA pane — 🔄 button no longer resets to Single tab** — active tab state is saved before `innerHTML` rebuild and restored afterwards; staying on Stack tab after refresh
- **Models tab — Stack group hidden for non-LoRA types** — when switching to Checkpoint or other non-LoRA types, the Stack group is now excluded from the group filter dropdown and side-panel group management (LoRA-only concept)
- **CLIPTextEncodeEditPlus widget mapping fix** — `convertUiToApi` no longer advances `wIdx` for UI slot inputs that have an actual link, preventing index misalignment when `object_info` lists optional STRING inputs (e.g. `text1`) before widget inputs (e.g. `text_edit`); fixes `+af` appearing as the positive prompt instead of the edit text
- **Stack Apply — trigger words now applied correctly on first press** — trigger words (`currentAllTriggers` / `currentActiveTriggers`) are now recomputed at click time from the latest `_stackActive` + `metadata` + `civitaiCache`; previously used a stale snapshot captured at render time, causing trigger words to be missing on the first Apply and to linger after disabling a model
### v0.3.32
- **Lora Loader (LoraManager) LoRA detection** — I tab and Metadata tab now correctly detect LoRAs from `Lora Loader (LoraManager)` nodes in API format (`inputs.loras.__value__`); `strength`/`clipStrength` stored as strings (e.g. `"0.20"`) are now parsed correctly
- **LoraManager node placement — LoRA syntax** — placing a `Lora Loader (LoraManager)` node via drag now also updates the `text` widget with `<lora:name:strength>` syntax (previously only the `loras` array widget was set)
+45
View File
@@ -31,6 +31,8 @@ def setup_routes(app: web.Application):
app.router.add_post("/api/wfm/models/toggle", handle_toggle_model)
app.router.add_post("/api/wfm/models/group-toggle", handle_toggle_group)
app.router.add_post("/api/wfm/models/delete", handle_delete_models)
app.router.add_get("/api/wfm/models/subdirs", handle_get_subdirs)
app.router.add_post("/api/wfm/models/move", handle_move_models)
# ── Model Metadata ─────────────────────────────────────────
@@ -571,3 +573,46 @@ async def handle_delete_models(request: web.Request) -> web.Response:
except Exception as e:
logger.error("Error in delete_models: %s", e)
return web.json_response({"error": str(e)}, status=500)
_VALID_MODEL_TYPES = frozenset(
["checkpoint", "lora", "vae", "controlnet", "unet", "textencoder", "hypernetwork", "embedding"]
)
async def handle_get_subdirs(request: web.Request) -> web.Response:
"""GET /api/wfm/models/subdirs?type=checkpoint
Returns list of root-level subdirectory names for the given model type.
"""
try:
model_type = request.rel_url.query.get("type", "")
if model_type not in _VALID_MODEL_TYPES:
return web.json_response({"error": "Invalid model type"}, status=400)
result = await asyncio.to_thread(_service.get_subdirs, model_type)
return web.json_response(result)
except Exception as e:
return web.json_response({"error": str(e)}, status=500)
async def handle_move_models(request: web.Request) -> web.Response:
"""POST /api/wfm/models/move
Body: { "model_type": "checkpoint", "model_names": [...], "dest": "sdxl" }
dest: "" = root, or a root-level subfolder name (no path separators, no "..").
"""
try:
body = await request.json()
model_type = body.get("model_type", "")
model_names = body.get("model_names", [])
dest_subdir = body.get("dest", "")
if model_type not in _VALID_MODEL_TYPES:
return web.json_response({"error": "Invalid model type"}, status=400)
if not isinstance(model_names, list) or not model_names:
return web.json_response({"error": "model_names must be a non-empty list"}, status=400)
if not isinstance(dest_subdir, str):
return web.json_response({"error": "dest must be a string"}, status=400)
result = await asyncio.to_thread(_service.move_models, model_type, model_names, dest_subdir)
return web.json_response(result)
except Exception as e:
logger.error("Error in move_models: %s", e)
return web.json_response({"error": str(e)}, status=500)
+125 -1
View File
@@ -2,6 +2,7 @@
import json
import logging
import shutil
from datetime import datetime, timezone
from pathlib import Path
@@ -17,7 +18,7 @@ _PREVIEW_EXTENSIONS = [".preview.png", ".preview.jpg", ".preview.jpeg", ".previe
_SIDECAR_EXTENSIONS = [
".preview.png", ".preview.jpg", ".preview.jpeg", ".preview.webp",
".png", ".jpg", ".jpeg", ".webp",
".json", ".civitai.info", ".info",
".metadata.json", ".cm-info.json", ".json", ".civitai.info", ".info",
]
_DISABLED_SUFFIX = ".disabled"
@@ -274,3 +275,126 @@ class ModelsService:
self._save_metadata(data)
return {"deleted": deleted}
def get_subdirs(self, model_type):
"""Return sorted list of root-level subdirectory names for a model type."""
dirs = _get_model_dirs(model_type)
subdirs = set()
for d in dirs:
if not d.is_dir():
continue
for item in d.iterdir():
if item.is_dir():
subdirs.add(item.name)
return sorted(subdirs)
def move_models(self, model_type, model_names, dest_subdir):
"""Move model files + sidecar files to dest_subdir (root-level subfolder name).
dest_subdir: "" = model root, "sdxl" = <root>/sdxl/
Creates the destination directory if it does not exist.
Updates metadata keys to reflect new paths.
Returns {"moved": [{"from": ..., "to": ...}], "errors": [...]}
"""
# Validate dest_subdir: must be a plain folder name (no separators, no "..", not absolute)
if dest_subdir:
if ".." in dest_subdir:
return {"moved": [], "errors": [{"model": "*", "error": "Invalid destination: '..' not allowed"}]}
if "/" in dest_subdir or "\\" in dest_subdir:
return {"moved": [], "errors": [{"model": "*", "error": "Invalid destination: must be a single folder name"}]}
if Path(dest_subdir).is_absolute():
return {"moved": [], "errors": [{"model": "*", "error": "Invalid destination: absolute paths not allowed"}]}
moved = []
errors = []
model_dirs = _get_model_dirs(model_type)
meta_data = self._load_metadata()
meta_changed = False
for model_name in model_names:
if ".." in model_name:
errors.append({"model": model_name, "error": "Invalid model name"})
continue
path, _is_enabled = self.find_model_file(model_type, model_name)
if path is None:
errors.append({"model": model_name, "error": f"Model not found: {model_name}"})
continue
try:
# Determine which root dir this model lives in
root_dir = None
for d in model_dirs:
try:
path.relative_to(d)
root_dir = d
break
except ValueError:
pass
if root_dir is None:
errors.append({"model": model_name, "error": "Cannot determine root directory"})
continue
# Destination directory — verify it stays within root_dir after resolution
dest_dir = root_dir / dest_subdir if dest_subdir else root_dir
try:
dest_dir.resolve().relative_to(root_dir.resolve())
except ValueError:
errors.append({"model": model_name, "error": "Destination is outside model root"})
continue
dest_dir.mkdir(parents=True, exist_ok=True)
# Original filename without .disabled suffix
orig_name = path.name
if orig_name.endswith(_DISABLED_SUFFIX):
orig_name = orig_name[: -len(_DISABLED_SUFFIX)]
stem = Path(orig_name).stem
new_path = dest_dir / path.name
if new_path.resolve() == path.resolve():
errors.append({"model": model_name, "error": "Already in destination"})
continue
# Refuse to overwrite an existing file
if new_path.exists():
errors.append({"model": model_name, "error": f"Destination already exists: {path.name}"})
continue
# Move the model file
shutil.move(str(path), str(new_path))
logger.info("Moved model: %s → %s", path, new_path)
# Move all sidecar files (skip if destination already exists)
for ext in _SIDECAR_EXTENSIONS:
sidecar = path.parent / (stem + ext)
if sidecar.is_file():
sidecar_dest = dest_dir / (stem + ext)
if sidecar_dest.exists():
logger.warning("Sidecar destination exists, skipping: %s", sidecar_dest)
continue
try:
shutil.move(str(sidecar), str(sidecar_dest))
except Exception as se:
logger.warning("Could not move sidecar %s: %s", sidecar, se)
# Compute new logical model name (relative to root, forward slashes)
new_rel = str(new_path.relative_to(root_dir)).replace("\\", "/")
if new_rel.endswith(_DISABLED_SUFFIX):
new_rel = new_rel[: -len(_DISABLED_SUFFIX)]
# Update metadata key
if model_name in meta_data:
meta_data[new_rel] = meta_data.pop(model_name)
meta_changed = True
moved.append({"from": model_name, "to": new_rel})
except Exception as e:
logger.error("Error moving model %s: %s", model_name, e)
errors.append({"model": model_name, "error": str(e)})
if meta_changed:
self._save_metadata(meta_data)
return {"moved": moved, "errors": errors}
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui-workflow-studio"
description = "A comprehensive workflow management and generation UI plugin for ComfyUI. Browse, organize, and execute workflows from a dedicated studio interface."
version = "0.3.32"
version = "0.3.35"
license = "MIT"
requires-python = ">= 3.10"
dependencies = ["jinja2"]
+35
View File
@@ -602,6 +602,41 @@
background: rgba(255,255,255,0.2);
}
/* ── 詳細パネル アクションボタン (タブナビ内) ────────────────── */
.wfm-gallery-action-btn-green,
.wfm-gallery-action-btn-primary {
padding: 4px 10px !important;
border-radius: 4px !important;
border-style: solid !important;
border-width: 1px !important;
cursor: pointer !important;
font-size: 12px !important;
white-space: nowrap;
align-self: center;
margin: 2px 3px;
}
.wfm-gallery-action-btn-green {
background: var(--wfm-success, #22c55e) !important;
color: #fff !important;
border-color: var(--wfm-success, #22c55e) !important;
}
.wfm-gallery-action-btn-green:hover {
background: #16a34a !important;
border-color: #16a34a !important;
}
.wfm-gallery-action-btn-primary {
background: var(--wfm-primary) !important;
color: #fff !important;
border-color: var(--wfm-primary) !important;
}
.wfm-gallery-action-btn-primary:hover {
background: var(--wfm-primary-hover) !important;
border-color: var(--wfm-primary-hover) !important;
}
/* ── ファイル操作ボタン (詳細パネル) ─────────────────────────── */
.wfm-gallery-file-actions {
+88 -2
View File
@@ -4102,6 +4102,14 @@ body {
width: 30px;
}
.wfm-table-th-filename,
.wfm-table-td-filename {
max-width: 160px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.wfm-table-th-subdir,
.wfm-table-td-subdir {
width: 80px;
@@ -4111,6 +4119,26 @@ body {
white-space: nowrap;
}
.wfm-table-th-civtype,
.wfm-table-td-civtype {
width: 70px;
max-width: 70px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 0.85em;
}
.wfm-table-th-basemodel,
.wfm-table-td-basemodel {
width: 110px;
max-width: 110px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 0.85em;
}
.wfm-table-th-ext,
.wfm-table-td-ext {
width: 60px;
@@ -4226,6 +4254,17 @@ body {
}
/* Table sort header */
.wfm-table-th-sortable {
cursor: pointer;
-webkit-user-select: none;
user-select: none;
white-space: nowrap;
}
.wfm-table-th-sortable:hover {
color: var(--wfm-accent, #6366f1);
}
/* Table view toggle cell */
.wfm-table-td-toggle {
text-align: center;
@@ -4297,13 +4336,45 @@ body {
}
.wfm-bulk-bar {
display: flex;
align-items: center;
gap: 8px;
flex-direction: column;
gap: 4px;
padding: 6px 12px;
background: rgba(108, 142, 245, 0.12);
border-bottom: 1px solid rgba(108, 142, 245, 0.3);
}
.wfm-bulk-header {
display: flex;
align-items: center;
gap: 6px;
flex-wrap: wrap;
}
.wfm-bulk-rows {
display: flex;
flex-direction: column;
gap: 3px;
}
.wfm-bulk-row {
display: flex;
align-items: center;
gap: 4px;
}
.wfm-bulk-row-label {
font-size: 12px;
color: var(--wfm-text-secondary);
width: 44px;
flex-shrink: 0;
text-align: right;
}
.wfm-bulk-select {
width: 330px !important;
max-width: 330px !important;
font-size: 12px !important;
padding: 2px 4px !important;
}
.wfm-bulk-input {
width: 110px !important;
font-size: 12px;
}
.wfm-bulk-count {
font-size: 13px;
color: #a0a8c0;
@@ -4314,6 +4385,21 @@ body {
height: 18px;
background: rgba(255, 255, 255, 0.15);
margin: 0 4px;
flex-shrink: 0;
}
.wfm-btn-success {
background: #22c55e;
color: #fff;
border-color: #16a34a;
}
.wfm-btn-success:hover {
background: #16a34a;
border-color: #15803d;
}
.wfm-btn-success.active {
background: #16a34a;
border-color: #15803d;
box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.4);
}
/* ── Batch Tab ──────────────────────────────────────────────────── */
+26 -20
View File
@@ -359,6 +359,8 @@ export const comfyEditor = {
</div>`;
}).join("");
const _prevActiveTab = el.querySelector(".wfm-lora-tab-btn.active")?.dataset?.tab || "single";
el.innerHTML = `
<div class="wfm-lora-tab-header">
<button class="wfm-lora-tab-btn active" data-tab="single">Single</button>
@@ -448,6 +450,14 @@ export const comfyEditor = {
});
});
// Restore previously active tab after re-render
if (_prevActiveTab === "stack") {
el.querySelector('[data-tab="single"]')?.classList.remove("active");
el.querySelector('[data-tab="stack"]')?.classList.add("active");
document.getElementById("wfm-lora-panel-single").style.display = "none";
document.getElementById("wfm-lora-panel-stack").style.display = "";
}
// ── Single: filter ───────────────────────────────────
document.getElementById("wfm-lora-filter")?.addEventListener("input", (e) => {
const filter = e.target.value.toLowerCase();
@@ -614,19 +624,31 @@ export const comfyEditor = {
if (!posTextarea) return;
const effectiveSyntax = _buildLoraSyntax(stackModels);
// Recompute trigger words at apply-time using the current _stackActive state
const currentAllTriggers = [];
const currentActiveTriggers = [];
stackModels.forEach((m) => {
const sha = (metadata[m] || {}).sha256;
const civInfo = sha && civitaiCache[sha];
if (civInfo?.trainedWords?.length) {
currentAllTriggers.push(...civInfo.trainedWords);
if (_stackActive[m] !== false) currentActiveTriggers.push(...civInfo.trainedWords);
}
});
let cleaned = posTextarea.value;
for (const m of stackModels) {
const stem = _loraBasename(m).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
cleaned = cleaned.replace(new RegExp(`,?\\s*<lora:${stem}:[^>]*>`, "gi"), "");
}
if (allStackTriggers.length > 0) {
const wordSet = new Set(allStackTriggers.map(w => w.trim().toLowerCase()));
if (currentAllTriggers.length > 0) {
const wordSet = new Set(currentAllTriggers.map(w => w.trim().toLowerCase()));
cleaned = cleaned.split(",").map(p => p.trim()).filter(p => p && !wordSet.has(p.toLowerCase())).join(", ");
}
cleaned = cleaned.replace(/,\s*$/, "").trim();
if (effectiveSyntax) {
const append = activeTriggerWords.length > 0
? `${effectiveSyntax}, ${activeTriggerWords.join(", ")}`
const append = currentActiveTriggers.length > 0
? `${effectiveSyntax}, ${currentActiveTriggers.join(", ")}`
: effectiveSyntax;
posTextarea.value = cleaned ? `${cleaned}, ${append}` : append;
} else {
@@ -652,22 +674,6 @@ export const comfyEditor = {
}
});
// ── Auto-apply Stack to LoraManager on load ──────────
if (defaultStackTarget && stackModels.length > 0 && comfyUI.currentWorkflow?.[defaultStackTarget]) {
const targetNode = loraNodes.find((n) => String(n.id) === String(defaultStackTarget));
if (targetNode?.is_lora_manager) {
const loraValue = stackModels.map((m) => {
const stem = _loraBasename(m);
const str = _stackStrengths[m] || { m: 1.0, c: 1.0 };
const active = _stackActive[m] !== false;
return { name: stem, strength: str.m, active, expanded: false, clipStrength: str.c, locked: false };
});
comfyUI.currentWorkflow[defaultStackTarget].inputs.loras = { __value__: loraValue };
comfyUI.currentWorkflow[defaultStackTarget].inputs.text = _buildLoraManagerSyntax(stackModels);
_syncRawJson();
}
}
// Initial single tab display
_refreshLoraSingleDynamic(metadata, civitaiCache);
},
+12 -5
View File
@@ -295,10 +295,15 @@ export const comfyWorkflow = {
const nodeLinks = linkMap[node.id] || {};
const inputDefs = node.inputs || [];
const linkedInputNames = new Set();
// UI slot inputs with an actual link don't have a widget value entry in
// widgets_values (modern ComfyUI format). Track these separately so the
// widget-mapping loop won't advance wIdx for them.
const linkedSlotNames = new Set();
inputDefs.forEach((inp, idx) => {
if (nodeLinks[idx]) {
inputs[inp.name] = nodeLinks[idx];
linkedInputNames.add(inp.name);
linkedSlotNames.add(inp.name);
}
});
@@ -336,13 +341,15 @@ export const comfyWorkflow = {
const expectedType = widgetTypes[nIdx];
// Skip if this input is already linked
if (linkedInputNames.has(name)) {
// Still consume widget value(s) since widgets_values
// includes entries for linked inputs too
wIdx++;
// Also skip control_after_generate if present
if (wIdx < widgets.length && _isExtraWidgetValue(widgets[wIdx], expectedType)) {
if (!linkedSlotNames.has(name)) {
// Not a UI slot input — old-style linked input that still
// occupies a slot in widgets_values; consume it.
wIdx++;
if (wIdx < widgets.length && _isExtraWidgetValue(widgets[wIdx], expectedType)) {
wIdx++;
}
}
// UI slot inputs with a real link have no widget value entry — don't advance wIdx.
continue;
}
// Check if current widget value matches expected type
+58 -5
View File
@@ -5,6 +5,8 @@
import { showToast } from "./app.js";
import { t } from "./i18n.js";
import { loadFileIntoMetadataTab } from "./metadata-tab.js";
import { loadWorkflowIntoEditor } from "./generate-tab.js";
// ── 定数 ─────────────────────────────────────────────────────
@@ -65,6 +67,18 @@ function formatDate(mtime) {
return new Date(mtime * 1000).toLocaleString();
}
async function openImageInMetadataTab(img) {
try {
const res = await fetch(API.serveImage(img.path));
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const blob = await res.blob();
const file = new File([blob], img.filename, { type: blob.type || "image/png" });
await loadFileIntoMetadataTab(file);
} catch (e) {
showToast(`Metadata error: ${e.message}`, "error");
}
}
// ── フォルダツリー ────────────────────────────────────────────
function _getExpandedPaths() {
@@ -302,8 +316,13 @@ function createThumbCard(img) {
});
card.appendChild(favBtn);
// クリック: 詳細表示 / Ctrl+クリック: 複数選択
// クリック: 詳細表示 / Ctrl+クリック: 複数選択 / Alt+クリック: Metadataタブで開く
card.addEventListener("click", (e) => {
if (e.altKey) {
e.preventDefault();
openImageInMetadataTab(img);
return;
}
if (e.ctrlKey || e.metaKey) {
// 複数選択トグル
if (state.selectedImages.has(img.path)) {
@@ -394,8 +413,13 @@ function createTable(images) {
tr.appendChild(tdDate);
tr.appendChild(tdTags);
// クリック: 詳細表示 / Ctrl+クリック: 複数選択
// クリック: 詳細表示 / Ctrl+クリック: 複数選択 / Alt+クリック: Metadataタブで開く
tr.addEventListener("click", (e) => {
if (e.altKey) {
e.preventDefault();
openImageInMetadataTab(img);
return;
}
if (e.ctrlKey || e.metaKey) {
if (state.selectedImages.has(img.path)) {
state.selectedImages.delete(img.path);
@@ -1263,10 +1287,39 @@ function bindEvents() {
performDeleteImages([state.selectedImage.path]);
});
// 詳細タブ切り替え
document.querySelectorAll(".wfm-gallery-detail-tab-btn").forEach(btn => {
// MetadataタブボタンをJSONに改名(テンプレートとの二重保証)
const metaTabBtn = document.querySelector('.wfm-gallery-detail-tab-btn[data-detail-tab="meta"]');
if (metaTabBtn) metaTabBtn.textContent = "JSON";
// Metadataボタン: 選択画像をMetadataタブで開く
document.getElementById("wfm-gallery-open-metadata-btn")?.addEventListener("click", () => {
if (!state.selectedImage) {
showToast("Please select an image first", "error");
return;
}
openImageInMetadataTab(state.selectedImage);
});
// Load in GenerateUI ボタン: 埋め込みワークフローをGenerateUIタブに読み込む
document.getElementById("wfm-gallery-load-genui-btn")?.addEventListener("click", async () => {
if (!state.selectedImage) {
showToast("Please select an image first", "error");
return;
}
if (!state.embeddedWorkflow) {
showToast("No ComfyUI workflow embedded in this image.", "warning");
return;
}
const loaded = await loadWorkflowIntoEditor(state.embeddedWorkflow, state.selectedImage.filename);
if (loaded !== false) {
document.querySelector('.wfm-tab[data-tab="generate"]')?.click();
}
});
// 詳細タブ切り替え(Metadataボタンはタブではないので除外)
document.querySelectorAll(".wfm-gallery-detail-tab-btn[data-detail-tab]").forEach(btn => {
btn.addEventListener("click", () => {
document.querySelectorAll(".wfm-gallery-detail-tab-btn").forEach(b => b.classList.remove("active"));
document.querySelectorAll(".wfm-gallery-detail-tab-btn[data-detail-tab]").forEach(b => b.classList.remove("active"));
btn.classList.add("active");
const tabId = btn.dataset.detailTab;
document.querySelectorAll(".wfm-gallery-detail-tab-content").forEach(c => c.style.display = "none");
+82 -1
View File
@@ -2,7 +2,7 @@
* GenerateUI Tab - Workflow execution with parameter editing
*/
import { showToast } from "./app.js";
import { showToast, openModal, closeModal } from "./app.js";
import { comfyUI } from "./comfyui-client.js";
import { comfyWorkflow } from "./comfyui-workflow.js";
import { comfyEditor } from "./comfyui-editor.js";
@@ -103,6 +103,84 @@ function updateStatus(connected) {
}
}
// ============================================
// Workflow Save
// ============================================
async function saveCurrentWorkflow() {
if (!comfyUI.currentWorkflow) {
showToast("No workflow loaded", "warning");
return;
}
const currentFilename = document.getElementById("wfm-gen-wf-name")?.dataset?.filename || "";
const defaultStem = currentFilename.replace(/\.json$/, "") || "workflow";
const html = `
<div style="display:flex;flex-direction:column;gap:14px;min-width:300px;">
<div>
<label style="font-size:12px;color:var(--wfm-text-secondary);display:block;margin-bottom:4px;">Filename</label>
<div style="display:flex;align-items:center;gap:6px;">
<input type="text" id="wfm-save-wf-name" class="wfm-input" value="${defaultStem}" style="flex:1;" placeholder="workflow name">
<span style="color:var(--wfm-text-secondary);font-size:13px;">.json</span>
</div>
</div>
<div style="display:flex;gap:8px;justify-content:flex-end;">
<button class="wfm-btn wfm-btn-sm" id="wfm-save-wf-cancel-btn">Cancel</button>
<button class="wfm-btn wfm-btn-sm wfm-btn-primary" id="wfm-save-wf-confirm-btn">Save</button>
</div>
</div>`;
openModal("Save Workflow", html);
setTimeout(() => {
const input = document.getElementById("wfm-save-wf-name");
if (input) { input.focus(); input.select(); }
}, 50);
document.getElementById("wfm-save-wf-cancel-btn")?.addEventListener("click", () => closeModal());
const doSave = async () => {
const input = document.getElementById("wfm-save-wf-name");
const stem = input?.value?.trim();
if (!stem) {
showToast("Please enter a filename", "warning");
return;
}
const filename = stem.endsWith(".json") ? stem : `${stem}.json`;
try {
const blob = new Blob(
[JSON.stringify(comfyUI.currentWorkflow, null, 2)],
{ type: "application/json" }
);
const file = new File([blob], filename, { type: "application/json" });
const fd = new FormData();
fd.append("files", file);
const res = await fetch("/api/wfm/workflows/import", { method: "POST", body: fd });
const data = await res.json();
const ng = (data.results || []).filter(r => r.status === "error");
if (ng.length) {
showToast(`Save failed: ${ng[0].message || "unknown error"}`, "error");
return;
}
closeModal();
const nameEl = document.getElementById("wfm-gen-wf-name");
if (nameEl) {
nameEl.textContent = filename;
nameEl.dataset.filename = filename;
}
showToast(`Saved: ${filename}`, "success");
} catch (err) {
showToast(`Save error: ${err.message}`, "error");
}
};
document.getElementById("wfm-save-wf-confirm-btn")?.addEventListener("click", doSave);
document.getElementById("wfm-save-wf-name")?.addEventListener("keydown", (e) => {
if (e.key === "Enter") doSave();
});
}
// ============================================
// Workflow Loading
// ============================================
@@ -1412,6 +1490,9 @@ export async function initGenerateTab() {
_renderBatchPreview();
});
// Save workflow button
document.getElementById("wfm-gen-save-btn")?.addEventListener("click", () => saveCurrentWorkflow());
document.getElementById("wfm-gen-reset-workflow-btn")?.addEventListener("click", async () => {
const filename = document.getElementById("wfm-gen-wf-name")?.dataset?.filename;
if (!filename || !filename.endsWith(".json")) {
+24
View File
@@ -300,6 +300,12 @@ const LANGUAGES = {
modelBulkDeleteConfirm: "Permanently delete {count} model file(s) and their preview images? This cannot be undone.",
modelBulkDeleteDone: "model file(s) deleted",
modelBulkDeleteError: "Failed to delete some models",
modelBulkMoveRoot: "(Root)",
modelBulkMoveBtn: "Move",
modelBulkMoveNewFolder: "New folder name",
modelBulkMoveCreateMove: "Create & Move",
modelBulkMoveDone: "model(s) moved",
modelBulkMoveError: "Failed to move some models",
modelBulkDeselectAll: "Deselect All",
modelBulkFavAdd: "★ Favorite",
modelBulkFavRemove: "☆ Unfavorite",
@@ -485,6 +491,7 @@ const LANGUAGES = {
helpModels9: "User-defined badges: assign free-label badges with custom colors shared with the Workflow tab",
helpModels10: "Enable/Disable models: toggle visibility in ComfyUI by renaming file extension (.disabled suffix). Disable per model (⏸ button on each card) or per group (Enable All / Disable All in Group panel). Changes take effect after ComfyUI refresh.",
helpModels11: "Multi-select & bulk operations: click Select to enter selection mode, check multiple models, then use the bulk action bar to add/remove from groups or permanently delete files (model file + preview images + sidecar files such as .json/.info).",
helpModels12: "After moving or deleting models, ComfyUI may fail to load them because it caches the old file paths. Perform a Hard Reset from the ComfyUI menu (Queue → Hard Reset) or restart ComfyUI to refresh the model cache.",
helpGalleryTitle: "Gallery Tab",
helpGallery1: "Browse images in the ComfyUI output folder — set the folder path in Settings > Gallery Output Folder",
helpGallery2: "3-column layout: folder tree (left) | image grid (center) | detail panel (right)",
@@ -532,6 +539,7 @@ const LANGUAGES = {
helpTrouble3: "Workflows not showing: Click refresh button, check if loadable in ComfyUI, try restarting browser/ComfyUI",
helpTrouble4: "Image generation fails: Check if specified models exist in ComfyUI, verify connection, try restarting",
helpTrouble5: "LoRA Stack fails with 'No such file or directory' error: The LoRA may not be recognized by comfyui-lora-manager (known issue). Try a different LoRA or check if the file appears in Lora Manager's own UI",
helpTrouble6: "Model loading error after moving or deleting models: ComfyUI caches file paths and may still reference old locations. Perform a Hard Reset from the ComfyUI menu (Queue → Hard Reset) or restart ComfyUI to clear the cache.",
helpSupportTitle: "Support",
helpSupportDesc: "If you find this plugin useful, please consider supporting its development!",
helpGithubDesc: "Report issues, request features, and contribute",
@@ -971,6 +979,12 @@ const LANGUAGES = {
modelBulkDeleteConfirm: "{count}件のモデルファイルとプレビュー画像を完全に削除しますか?この操作は取り消せません。",
modelBulkDeleteDone: "件のモデルファイルを削除しました",
modelBulkDeleteError: "一部のモデルの削除に失敗しました",
modelBulkMoveRoot: "(ルート)",
modelBulkMoveBtn: "移動",
modelBulkMoveNewFolder: "新規フォルダ名",
modelBulkMoveCreateMove: "作成して移動",
modelBulkMoveDone: "件のモデルを移動しました",
modelBulkMoveError: "一部のモデルの移動に失敗しました",
modelBulkDeselectAll: "選択解除",
modelBulkFavAdd: "★ お気に入り追加",
modelBulkFavRemove: "☆ お気に入り解除",
@@ -1156,6 +1170,7 @@ const LANGUAGES = {
helpModels9: "ユーザー定義バッジ:自由ラベルのバッジをモデルに付与(Workflowタブと色パレットを共有)",
helpModels10: "モデルの有効/無効切り替え:拡張子リネーム(.disabledサフィックス)でComfyUIへの表示を制御。各カードの⏸ボタンで単体操作、グループパネルの「全て有効化 / 全て無効化」でグループ一括操作。変更はComfyUIリフレッシュ後に反映。",
helpModels11: "複数選択と一括操作:「選択」ボタンで選択モードに入り複数モデルにチェックを入れると、一括操作バーからグループへの追加/削除、またはファイルの完全削除(モデルファイル+プレビュー画像+.json/.infoなどのサイドカーファイル)が行えます。",
helpModels12: "モデルの移動・削除後はComfyUIが古いパスをキャッシュしているためモデル読み込みエラーが発生することがあります。ComfyUIメニューのHard Reset(Queue → Hard Reset)またはComfyUIを再起動してモデルキャッシュを更新してください。",
helpGalleryTitle: "Galleryタブ",
helpGallery1: "ComfyUIの出力フォルダ内画像を閲覧 — Settings > Gallery Output Folder でフォルダパスを設定可能",
helpGallery2: "3カラムレイアウト: フォルダツリー (左) | 画像グリッド (中央) | 詳細パネル (右)",
@@ -1203,6 +1218,7 @@ const LANGUAGES = {
helpTrouble3: "ワークフローが表示されない:更新ボタン押下、ComfyUIで読み込めるか確認、ブラウザ・ComfyUI再起動",
helpTrouble4: "画像生成が失敗する:指定モデルの存在確認、ComfyUI接続確認、再起動",
helpTrouble5: "LoRAスタック実行時に「No such file or directory」エラー:comfyui-lora-managerが該当LoRAを認識していない可能性があります(既知の問題)。別のLoRAを試すか、Lora Manager自体のUIで該当ファイルが表示されるか確認してください",
helpTrouble6: "モデルの移動・削除後にモデル読み込みエラーが発生する:ComfyUIがファイルパスをキャッシュしており、古い場所を参照することがあります。ComfyUIメニューのHard Reset(Queue → Hard Reset)またはComfyUIを再起動してキャッシュをクリアしてください。",
helpSupportTitle: "サポート",
helpSupportDesc: "このプラグインが役に立ったら、開発を支援していただけると嬉しいです!",
helpGithubDesc: "バグ報告、機能リクエスト、コントリビュート",
@@ -1638,6 +1654,12 @@ const LANGUAGES = {
modelBulkDeleteConfirm: "永久删除 {count} 个模型文件及其预览图?此操作无法撤销。",
modelBulkDeleteDone: "个模型文件已删除",
modelBulkDeleteError: "部分模型删除失败",
modelBulkMoveRoot: "(根目录)",
modelBulkMoveBtn: "移动",
modelBulkMoveNewFolder: "新建文件夹名",
modelBulkMoveCreateMove: "创建并移动",
modelBulkMoveDone: "个模型已移动",
modelBulkMoveError: "部分模型移动失败",
modelBulkDeselectAll: "取消全选",
modelBulkFavAdd: "★ 收藏",
modelBulkFavRemove: "☆ 取消收藏",
@@ -1823,6 +1845,7 @@ const LANGUAGES = {
helpModels9: "用户自定义徽章:为模型添加自由标签徽章(颜色调色板与Workflow标签共享)",
helpModels10: "模型启用/禁用:通过重命名文件扩展名(添加.disabled后缀)控制ComfyUI中的显示。点击每个卡片上的⏸按钮单独操作,或在分组面板中使用「全部启用/全部禁用」进行批量操作。更改在刷新ComfyUI后生效。",
helpModels11: "多选与批量操作:点击「选择」按钮进入选择模式,勾选多个模型后,可通过批量操作栏将其添加/移出分组,或永久删除文件(模型文件+预览图+.json/.info等附属文件)。",
helpModels12: "移动或删除模型后,ComfyUI可能因缓存旧路径而无法加载模型。请通过ComfyUI菜单执行Hard Reset(Queue → Hard Reset)或重启ComfyUI以刷新模型缓存。",
helpGalleryTitle: "图库标签页 (Gallery)",
helpGallery1: "浏览 ComfyUI 输出文件夹中的图像 — 可以在 设置 > 图库输出文件夹 中设置文件夹路径",
helpGallery2: "三列布局:文件夹树(左) | 图像网格(中) | 详情面板(右)",
@@ -1870,6 +1893,7 @@ const LANGUAGES = {
helpTrouble3: "工作流不显示:点击刷新按钮、确认能在ComfyUI中加载、尝试重启浏览器/ComfyUI",
helpTrouble4: "图片生成失败:确认指定模型存在、验证ComfyUI连接、尝试重启",
helpTrouble5: "LoRA Stack出现「No such file or directory」错误:该LoRA可能未被comfyui-lora-manager识别(已知问题)。请尝试其他LoRA,或检查该文件是否显示在Lora Manager自身的界面中",
helpTrouble6: "移动或删除模型后出现模型加载错误:ComfyUI会缓存文件路径,可能仍引用旧位置。请通过ComfyUI菜单执行Hard Reset(Queue → Hard Reset)或重启ComfyUI以清除缓存。",
helpSupportTitle: "支持",
helpSupportDesc: "如果您觉得这个插件有用,请考虑支持它的开发!",
helpGithubDesc: "报告问题、请求功能和贡献代码",
+11
View File
@@ -550,6 +550,15 @@ function renderSection(sectionEl, listEl, items, buildFn) {
for (const item of items) listEl.appendChild(buildFn(item));
}
// ── External API ──────────────────────────────────────────────
let _externalHandleFile = null;
export async function loadFileIntoMetadataTab(file) {
document.querySelector('.wfm-tab[data-tab="metadata"]')?.click();
await new Promise(r => setTimeout(r, 0));
if (_externalHandleFile) await _externalHandleFile(file);
}
// ── Tab initialization ────────────────────────────────────────
export function initMetadataTab() {
const dropZone = document.getElementById("wfm-meta-drop");
@@ -743,6 +752,8 @@ export function initMetadataTab() {
if (setTextareaValue("wfm-preset-neg", text)) flashBtn(this);
});
_externalHandleFile = handleFile;
// Drag & Drop
dropZone.addEventListener("dragover", e => { e.preventDefault(); e.stopPropagation(); dropZone.classList.add("drag-over"); });
dropZone.addEventListener("dragleave", e => { e.stopPropagation(); dropZone.classList.remove("drag-over"); });
+251 -39
View File
@@ -31,6 +31,7 @@ const state = {
allModelGroups: {}, // { type: { groupName: [models] } } — all types
civitaiCache: {},
disabledModels: {}, // { type: Set<modelName> }
subdirs: [],
selectMode: false,
selectedModels: new Set(),
searchText: "",
@@ -46,6 +47,8 @@ const state = {
selectedModel: null,
loaded: {},
currentPage: 0,
sortColumn: null, // "fav" | "filename" | "subdir" | "civtype" | "basemodel" | "ext" | "tags" | "memo" | "enabled"
sortDir: "asc", // "asc" | "desc"
};
@@ -342,25 +345,43 @@ function renderBulkActionBar() {
bar.style.display = "flex";
bar.innerHTML = `
<span class="wfm-bulk-count">${count} ${t("modelSelected")}</span>
<button class="wfm-btn wfm-btn-sm" id="wfm-bulk-deselect-all-btn">${t("modelBulkDeselectAll")}</button>
<span class="wfm-bulk-sep">|</span>
<button class="wfm-btn wfm-btn-sm" id="wfm-bulk-fav-add-btn" title="${t("modelBulkFavAdd")}">${t("modelBulkFavAdd")}</button>
<button class="wfm-btn wfm-btn-sm" id="wfm-bulk-fav-remove-btn" title="${t("modelBulkFavRemove")}">${t("modelBulkFavRemove")}</button>
<span class="wfm-bulk-sep">|</span>
<select id="wfm-bulk-group-select" class="wfm-select" style="font-size:12px;">${groupOptions}</select>
<button class="wfm-btn wfm-btn-sm wfm-btn-primary" id="wfm-bulk-add-btn"${noGroups ? " disabled" : ""}>${t("modelBulkAddGroup")}</button>
<button class="wfm-btn wfm-btn-sm wfm-btn-danger" id="wfm-bulk-remove-btn"${noGroups ? " disabled" : ""}>${t("modelBulkRemoveGroup")}</button>
<span class="wfm-bulk-sep">|</span>
<input type="text" id="wfm-bulk-new-group-input" class="wfm-search-input" style="width:120px;font-size:12px;" placeholder="${t("modelsGroupName")}">
<button class="wfm-btn wfm-btn-sm" id="wfm-bulk-create-add-btn">${t("modelBulkCreateAdd")}</button>
<span class="wfm-bulk-sep">|</span>
<select id="wfm-bulk-badge-select" class="wfm-select" style="font-size:12px;">${badgeOptions}</select>
<button class="wfm-btn wfm-btn-sm wfm-btn-primary" id="wfm-bulk-badge-apply-btn"${noBadges ? " disabled" : ""}>${t("modelBulkBadgeApply")}</button>
<button class="wfm-btn wfm-btn-sm wfm-btn-danger" id="wfm-bulk-badge-remove-btn"${noBadges ? " disabled" : ""}>${t("modelBulkBadgeRemove")}</button>
<span class="wfm-bulk-sep">|</span>
<button class="wfm-btn wfm-btn-sm" id="wfm-bulk-clear-btn" title="Clear selection">&times;</button>
<button class="wfm-btn wfm-btn-sm wfm-btn-danger" id="wfm-bulk-delete-btn" style="margin-left:4px;">${t("modelBulkDelete")}</button>
<div class="wfm-bulk-header">
<span class="wfm-bulk-count">${count} ${t("modelSelected")}</span>
<button class="wfm-btn wfm-btn-sm" id="wfm-bulk-deselect-all-btn">${t("modelBulkDeselectAll")}</button>
<span class="wfm-bulk-sep"></span>
<button class="wfm-btn wfm-btn-sm" id="wfm-bulk-fav-add-btn">${t("modelBulkFavAdd")}</button>
<button class="wfm-btn wfm-btn-sm" id="wfm-bulk-fav-remove-btn">${t("modelBulkFavRemove")}</button>
</div>
<div class="wfm-bulk-rows">
<div class="wfm-bulk-row">
<span class="wfm-bulk-row-label">Group:</span>
<select id="wfm-bulk-group-select" class="wfm-select wfm-bulk-select">${groupOptions}</select>
<button class="wfm-btn wfm-btn-sm wfm-btn-primary" id="wfm-bulk-add-btn"${noGroups ? " disabled" : ""}>${t("modelBulkAddGroup")}</button>
<button class="wfm-btn wfm-btn-sm wfm-btn-danger" id="wfm-bulk-remove-btn"${noGroups ? " disabled" : ""}>${t("modelBulkRemoveGroup")}</button>
<span class="wfm-bulk-sep"></span>
<input type="text" id="wfm-bulk-new-group-input" class="wfm-search-input wfm-bulk-input" placeholder="${t("modelsGroupName")}">
<button class="wfm-btn wfm-btn-sm" id="wfm-bulk-create-add-btn">${t("modelBulkCreateAdd")}</button>
</div>
<div class="wfm-bulk-row">
<span class="wfm-bulk-row-label">Badge:</span>
<select id="wfm-bulk-badge-select" class="wfm-select wfm-bulk-select">${badgeOptions}</select>
<button class="wfm-btn wfm-btn-sm wfm-btn-primary" id="wfm-bulk-badge-apply-btn"${noBadges ? " disabled" : ""}>${t("modelBulkBadgeApply")}</button>
<button class="wfm-btn wfm-btn-sm wfm-btn-danger" id="wfm-bulk-badge-remove-btn"${noBadges ? " disabled" : ""}>${t("modelBulkBadgeRemove")}</button>
</div>
<div class="wfm-bulk-row">
<span class="wfm-bulk-row-label">File:</span>
<select id="wfm-bulk-move-select" class="wfm-select wfm-bulk-select">
<option value="">${t("modelBulkMoveRoot")}</option>
${state.subdirs.map((d) => `<option value="${escapeHtml(d)}">${escapeHtml(d)}</option>`).join("")}
</select>
<button class="wfm-btn wfm-btn-sm" id="wfm-bulk-move-btn">${t("modelBulkMoveBtn")}</button>
<span class="wfm-bulk-sep"></span>
<input type="text" id="wfm-bulk-new-dir-input" class="wfm-search-input wfm-bulk-input" placeholder="${t("modelBulkMoveNewFolder")}">
<button class="wfm-btn wfm-btn-sm" id="wfm-bulk-mkdir-move-btn">${t("modelBulkMoveCreateMove")}</button>
<span style="flex:1"></span>
<button class="wfm-btn wfm-btn-sm wfm-btn-danger" id="wfm-bulk-delete-btn">${t("modelBulkDelete")}</button>
</div>
</div>
`;
document.getElementById("wfm-bulk-deselect-all-btn")?.addEventListener("click", clearSelection);
@@ -389,7 +410,16 @@ function renderBulkActionBar() {
const label = document.getElementById("wfm-bulk-badge-select")?.value;
if (label) bulkApplyBadge(label, false);
});
document.getElementById("wfm-bulk-clear-btn")?.addEventListener("click", clearSelection);
document.getElementById("wfm-bulk-move-btn")?.addEventListener("click", () => {
const dest = document.getElementById("wfm-bulk-move-select")?.value || "";
bulkMoveModels(dest);
});
document.getElementById("wfm-bulk-mkdir-move-btn")?.addEventListener("click", () => {
const input = document.getElementById("wfm-bulk-new-dir-input");
const name = input?.value.trim();
if (!name) return;
bulkMoveModels(name);
});
document.getElementById("wfm-bulk-delete-btn")?.addEventListener("click", bulkDeleteModels);
}
@@ -494,6 +524,58 @@ async function bulkDeleteModels() {
}
}
async function fetchSubdirs() {
try {
const res = await fetch(`/api/wfm/models/subdirs?type=${encodeURIComponent(state.activeModelType)}`);
state.subdirs = res.ok ? await res.json() : [];
} catch { state.subdirs = []; }
}
async function bulkMoveModels(destSubdir) {
const model_names = [...state.selectedModels];
if (model_names.length === 0) return;
try {
const res = await fetch("/api/wfm/models/move", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ model_type: state.activeModelType, model_names, dest: destSubdir }),
});
const data = await res.json();
const okCount = data.moved?.length || 0;
const errCount = data.errors?.length || 0;
if (okCount > 0) {
data.moved.forEach(({ from, to }) => {
const list = state.modelsByType[state.activeModelType];
const idx = list.indexOf(from);
if (idx !== -1) list[idx] = to;
if (state.modelMetadata[from]) {
state.modelMetadata[to] = state.modelMetadata[from];
delete state.modelMetadata[from];
}
const ds = state.disabledModels[state.activeModelType];
if (ds && ds.has(from)) { ds.delete(from); ds.add(to); }
state.selectedModels.delete(from);
});
if (state.selectedModel && data.moved.some((m) => m.from === state.selectedModel)) {
state.selectedModel = null;
const titleEl = document.getElementById("wfm-models-panel-title");
if (titleEl) titleEl.textContent = "";
}
showToast(`${okCount} ${t("modelBulkMoveDone")}`, "success");
await fetchSubdirs();
renderDirFilter();
renderModelGrid();
renderBulkActionBar();
}
if (errCount > 0) {
showToast(`${t("modelBulkMoveError")}: ${data.errors[0].error}`, "error");
}
} catch (err) {
showToast(`${t("modelBulkMoveError")}: ${err.message}`, "error");
}
}
// ── Enable / Disable helpers ──────────────────────────────
function isModelDisabled(modelName) {
@@ -657,7 +739,53 @@ function filterModels() {
});
}
return models;
return sortModels(models);
}
function sortModels(models) {
if (!state.sortColumn) return models;
return [...models].sort((a, b) => {
const metaA = state.modelMetadata[a] || {};
const metaB = state.modelMetadata[b] || {};
let va, vb;
switch (state.sortColumn) {
case "fav":
va = metaA.favorite ? 1 : 0; vb = metaB.favorite ? 1 : 0; break;
case "filename": {
const pa = parseModelPath(a); const pb = parseModelPath(b);
va = pa.name.toLowerCase(); vb = pb.name.toLowerCase(); break;
}
case "subdir": {
const pa = parseModelPath(a); const pb = parseModelPath(b);
va = pa.dir.toLowerCase(); vb = pb.dir.toLowerCase(); break;
}
case "civtype": {
const civA = metaA.sha256 && state.civitaiCache[metaA.sha256];
const civB = metaB.sha256 && state.civitaiCache[metaB.sha256];
va = (civA?.type || "").toLowerCase(); vb = (civB?.type || "").toLowerCase(); break;
}
case "basemodel": {
const civA = metaA.sha256 && state.civitaiCache[metaA.sha256];
const civB = metaB.sha256 && state.civitaiCache[metaB.sha256];
va = (civA?.baseModel || "").toLowerCase(); vb = (civB?.baseModel || "").toLowerCase(); break;
}
case "ext": {
const pa = parseModelPath(a); const pb = parseModelPath(b);
va = getExtension(pa.name).toLowerCase(); vb = getExtension(pb.name).toLowerCase(); break;
}
case "tags":
va = (metaA.tags || []).join(", ").toLowerCase();
vb = (metaB.tags || []).join(", ").toLowerCase(); break;
case "memo":
va = (metaA.memo || "").toLowerCase(); vb = (metaB.memo || "").toLowerCase(); break;
case "enabled":
va = isModelDisabled(a) ? 1 : 0; vb = isModelDisabled(b) ? 1 : 0; break;
default: return 0;
}
if (va < vb) return state.sortDir === "asc" ? -1 : 1;
if (va > vb) return state.sortDir === "asc" ? 1 : -1;
return 0;
});
}
function getAllTags() {
@@ -935,13 +1063,19 @@ function renderThumbView(grid, models) {
const placeholder = card.querySelector(".wfm-card-thumb-placeholder");
loadPreviewImage(img, placeholder, modelName);
card.querySelector(".wfm-batch-btn")?.addEventListener("click", (e) => {
card.querySelector(".wfm-batch-btn")?.addEventListener("click", async (e) => {
e.stopPropagation();
toggleBatch(modelName);
await toggleBatch(modelName);
if (state.showBatchOnly) {
renderModelGrid();
} else {
e.currentTarget.classList.toggle("active", isInBatch(modelName));
}
});
card.querySelector(".wfm-stack-btn")?.addEventListener("click", (e) => {
card.querySelector(".wfm-stack-btn")?.addEventListener("click", async (e) => {
e.stopPropagation();
toggleStack(modelName);
await toggleStack(modelName);
e.currentTarget.classList.toggle("active", isInStack(modelName));
});
card.querySelector(".wfm-fav-btn").addEventListener("click", (e) => {
e.stopPropagation();
@@ -972,6 +1106,14 @@ function renderThumbView(grid, models) {
// ── Table View ────────────────────────────────────────────
function thSortHtml(label, col, extraClass = "", extraStyle = "") {
const isActive = state.sortColumn === col;
const arrow = isActive ? (state.sortDir === "asc" ? " ▲" : " ▼") : "";
const activeStyle = isActive ? "color:var(--wfm-accent,#6366f1);" : "";
const cls = ["wfm-table-th-sortable", extraClass].filter(Boolean).join(" ");
return `<th class="${cls}" data-sort-col="${col}" style="${activeStyle}${extraStyle}">${label}${arrow}</th>`;
}
function renderTableView(grid, models) {
const showBatchBtn = ["checkpoint", "lora"].includes(state.activeModelType);
const showStackBtn = state.activeModelType === "lora";
@@ -980,6 +1122,10 @@ function renderTableView(grid, models) {
const meta = state.modelMetadata[modelName] || {};
const { dir, name } = parseModelPath(modelName);
const ext = getExtension(name);
const sha256 = meta.sha256;
const civitai = sha256 && state.civitaiCache[sha256];
const civitaiType = civitai ? (civitai.type || "") : "";
const civitaiBaseModel = civitai ? (civitai.baseModel || "") : "";
const disabled = isModelDisabled(modelName);
const isChecked = state.selectMode && state.selectedModels.has(modelName);
const favIcon = meta.favorite ? "&#9733;" : "&#9734;";
@@ -996,8 +1142,10 @@ function renderTableView(grid, models) {
${checkCell}
<td class="wfm-models-table-fav" title="Favorite">${favIcon}</td>
<td class="wfm-table-td-thumb"><img class="wfm-table-thumb" style="display:none" /></td>
<td title="${escapeHtml(modelName)}">${escapeHtml(name)}</td>
<td class="wfm-table-td-filename" title="${escapeHtml(modelName)}">${escapeHtml(name)}</td>
<td class="wfm-table-td-subdir">${escapeHtml(dir)}</td>
<td class="wfm-table-td-civtype" title="${escapeHtml(civitaiType)}">${escapeHtml(civitaiType)}</td>
<td class="wfm-table-td-basemodel" title="${escapeHtml(civitaiBaseModel)}">${escapeHtml(civitaiBaseModel)}</td>
<td class="wfm-table-td-ext">${escapeHtml(ext)}</td>
<td>${escapeHtml(tagsStr)}</td>
<td class="wfm-table-td-memo" title="${escapeHtml(memo)}">${escapeHtml(memo)}</td>
@@ -1011,14 +1159,16 @@ function renderTableView(grid, models) {
const checkTh = state.selectMode ? `<th style="width:24px;"></th>` : "";
grid.innerHTML = `<table class="wfm-models-table"><thead><tr>
${checkTh}
<th style="width:30px;">&#9733;</th>
${thSortHtml("&#9733;", "fav", "", "width:30px;text-align:center;")}
<th style="width:40px;"></th>
<th>${t("modelsFileName")}</th>
<th class="wfm-table-th-subdir">${t("modelsSubdir")}</th>
<th class="wfm-table-th-ext">${t("modelsExt")}</th>
<th>${t("modelsTags")}</th>
<th>${t("modelsMemo")}</th>
<th style="width:50px;"></th>
${thSortHtml(t("modelsFileName"), "filename", "wfm-table-th-filename")}
${thSortHtml(t("modelsSubdir"), "subdir", "wfm-table-th-subdir")}
${thSortHtml(t("civitaiType"), "civtype", "wfm-table-th-civtype")}
${thSortHtml(t("civitaiBaseModel"), "basemodel", "wfm-table-th-basemodel")}
${thSortHtml(t("modelsExt"), "ext", "wfm-table-th-ext")}
${thSortHtml(t("modelsTags"), "tags")}
${thSortHtml(t("modelsMemo"), "memo")}
${thSortHtml("E/D", "enabled", "", "width:50px;text-align:center;")}
${showBatchBtn ? `<th style="width:30px;">B</th>` : ""}
${showStackBtn ? `<th style="width:30px;">S</th>` : ""}
</tr></thead><tbody>${rows}</tbody></table>`;
@@ -1045,13 +1195,37 @@ function renderTableView(grid, models) {
e.stopPropagation();
toggleModelEnable(mn);
});
row.querySelector(".wfm-batch-btn")?.addEventListener("click", (e) => {
row.querySelector(".wfm-batch-btn")?.addEventListener("click", async (e) => {
e.stopPropagation();
toggleBatch(mn);
await toggleBatch(mn);
if (state.showBatchOnly) {
renderModelGrid();
} else {
e.currentTarget.classList.toggle("active", isInBatch(mn));
}
});
row.querySelector(".wfm-stack-btn")?.addEventListener("click", (e) => {
row.querySelector(".wfm-stack-btn")?.addEventListener("click", async (e) => {
e.stopPropagation();
toggleStack(mn);
await toggleStack(mn);
e.currentTarget.classList.toggle("active", isInStack(mn));
});
});
grid.querySelectorAll(".wfm-table-th-sortable").forEach((th) => {
th.addEventListener("click", () => {
const col = th.dataset.sortCol;
if (state.sortColumn === col) {
if (state.sortDir === "asc") {
state.sortDir = "desc";
} else {
state.sortColumn = null;
state.sortDir = "asc";
}
} else {
state.sortColumn = col;
state.sortDir = "asc";
}
renderModelGrid();
});
});
}
@@ -1073,7 +1247,6 @@ async function toggleBatch(modelName) {
state.modelGroups["Batch"] = batch;
state.allModelGroups[state.activeModelType] = state.modelGroups;
await saveModelGroups(state.modelGroups);
renderModelGrid();
}
async function clearBatchGroup() {
@@ -1103,7 +1276,6 @@ async function toggleStack(modelName) {
state.modelGroups["Stack"] = stack;
state.allModelGroups[state.activeModelType] = state.modelGroups;
await saveModelGroups(state.modelGroups);
renderModelGrid();
}
async function clearStackGroup() {
@@ -1182,6 +1354,7 @@ function openDetailModal(modelName) {
${GENUI_TYPE_MAP[state.activeModelType]
? `<button class="wfm-btn wfm-btn-sm" id="wfm-modal-genui-model" title="${t("modelsGenUITitle")}">${t("modelsGenUIBtn")}</button>`
: ""}
<button class="wfm-btn wfm-btn-sm wfm-btn-danger" id="wfm-modal-model-delete" style="margin-left:auto;">${t("modelsDelete")}</button>
</div>
</div>
</div>`;
@@ -1236,6 +1409,41 @@ function openDetailModal(modelName) {
applyToGenUI(modelName, state.activeModelType);
});
// Delete model button
document.getElementById("wfm-modal-model-delete")?.addEventListener("click", async () => {
const confirmMsg = t("modelBulkDeleteConfirm").replace("{count}", "1");
if (!confirm(confirmMsg)) return;
try {
const res = await fetch("/api/wfm/models/delete", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ model_type: state.activeModelType, model_names: [modelName] }),
});
const data = await res.json();
if (data.errors?.length > 0) {
showToast(`${t("modelBulkDeleteError")}: ${data.errors[0].error}`, "error");
return;
}
showToast(`${getStem(name)} ${t("modelBulkDeleteDone")}`, "success");
closeModal();
const list = state.modelsByType[state.activeModelType];
const idx = list.indexOf(modelName);
if (idx !== -1) list.splice(idx, 1);
delete state.modelMetadata[modelName];
const ds = state.disabledModels[state.activeModelType];
if (ds) ds.delete(modelName);
state.selectedModels.delete(modelName);
if (state.selectedModel === modelName) {
state.selectedModel = null;
const titleEl = document.getElementById("wfm-models-panel-title");
if (titleEl) titleEl.textContent = "";
}
renderModelGrid();
} catch (err) {
showToast(`${t("modelBulkDeleteError")}: ${err.message}`, "error");
}
});
// Change thumbnail
const changeBtn = document.getElementById("wfm-modal-change-thumb");
const thumbFile = document.getElementById("wfm-modal-thumb-file");
@@ -1833,11 +2041,13 @@ async function loadModelsForCurrentType() {
state.modelGroups["Stack"] = [];
await saveModelGroups(state.modelGroups);
}
if (!STACK_MODEL_TYPES.includes(type)) delete state.modelGroups["Stack"];
state.allModelGroups[type] = state.modelGroups;
renderTagFilter();
renderDirFilter();
renderGroupFilter();
renderModelGrid();
fetchSubdirs();
return;
}
@@ -1860,6 +2070,7 @@ async function loadModelsForCurrentType() {
groups["Stack"] = [];
await saveModelGroups(groups);
}
if (!STACK_MODEL_TYPES.includes(type)) delete groups["Stack"];
state.modelGroups = groups;
state.allModelGroups[type] = groups;
@@ -1874,6 +2085,7 @@ async function loadModelsForCurrentType() {
renderDirFilter();
renderGroupFilter();
renderModelGrid();
fetchSubdirs();
} catch (err) {
console.error("Failed to load models:", err);
if (placeholder) placeholder.textContent = t("modelsLoadError");
+16 -9
View File
@@ -209,7 +209,7 @@
<button id="wfm-models-civitai-batch-btn" class="wfm-btn wfm-btn-sm" title="Fetch CivitAI info for all models">CivitAI</button>
<span id="wfm-models-civitai-progress" style="font-size:12px;color:var(--wfm-text-secondary);"></span>
<button id="wfm-models-badge-settings-btn" class="wfm-btn wfm-btn-sm" title="Badge settings">&#9881; Badge</button>
<button id="wfm-models-select-btn" class="wfm-btn wfm-btn-sm" title="Multi-select models">Select</button>
<button id="wfm-models-select-btn" class="wfm-btn wfm-btn-sm wfm-btn-success" title="Multi-select models">Select</button>
<button id="wfm-models-batch-clear-btn" class="wfm-btn wfm-btn-sm" title="Clear all batch entries">BC</button>
<button id="wfm-models-stack-clear-btn" class="wfm-btn wfm-btn-sm" title="Clear all stack entries (Lora)">SC</button>
</div>
@@ -271,6 +271,7 @@
<button class="wfm-gen-subtab-btn" data-subtab="settings">Settings</button>
<button class="wfm-gen-subtab-btn" data-subtab="feeder">Feeder</button>
<button class="wfm-gen-subtab-btn" data-subtab="batch">Batch</button>
<button id="wfm-gen-save-btn" class="wfm-btn wfm-btn-sm wfm-btn-primary" style="margin-left:auto;" title="Save current workflow to Workflow tab">Save</button>
</div>
<!-- Tab: Input — left sub-col: Prompt/Image (tabbed), right sub-col: Raw JSON -->
@@ -960,7 +961,7 @@
<h3>GenerateUI Tab</h3>
<ul>
<li id="wfm-help-gen-1">Connect/disconnect ComfyUI and check connection status</li>
<li id="wfm-help-gen-2">Load workflows from Workflow tab (App format .app.json not supported); Reset Workflow button re-reads the current workflow file from disk and reloads the editor</li>
<li id="wfm-help-gen-2">Load workflows from Workflow tab (App format .app.json not supported); Reset Workflow button re-reads the current workflow file from disk and reloads the editor; <b>Save</b> button (right end of the tab bar) saves the current workflow — including any edits made in the editor — as a new .json file to the Workflow tab; a filename dialog appears with the current workflow name as the default</li>
<li id="wfm-help-gen-3">5-tab layout — Input (Prompt + Image), Model, Settings, Feeder, Batch — Input/Model/Settings each include a Raw JSON column for instant preview and direct editing</li>
<li id="wfm-help-gen-4">Input tab: inner tabs — Prompt (positive/negative textboxes with doubled height) and Image (drag-and-drop upload); switch between tabs with the tab bar at the top of the left column</li>
<li id="wfm-help-gen-5">Model tab: Checkpoint, VAE, LoRA, ControlNet, UNET, TextEncoder selectors with filter; LoRA Stack — Apply writes all active LoRAs to the target node and simultaneously inserts LoRA syntax and CivitAI trigger words into the Positive prompt; re-applying updates the prompt by removing inactive LoRAs and re-adding active ones</li>
@@ -1073,10 +1074,12 @@
<li id="wfm-help-gallery-5">Folder tree: click to load images, expand with ▶; "+ New" creates a subfolder inside the selected folder, "Del" deletes it with all contents</li>
<li id="wfm-help-gallery-6">Multi-select with Ctrl+click — bulk operations: Add to Group, Favorite All, Unfavorite All, Move To..., Delete</li>
<li id="wfm-help-gallery-7">Detail panel — Info tab: filename, size, date, tags (add/remove), memo; "Move To..." moves the image to another folder, "Delete" removes it permanently</li>
<li id="wfm-help-gallery-8">Detail panel — Metadata tab: displays workflow JSON from PNG embedded data (prompt / workflow keys) or from metadata saved by the Generate UI tab; one-click clipboard copy</li>
<li id="wfm-help-gallery-8">Detail panel — JSON tab: displays workflow JSON from PNG embedded data (prompt / workflow keys) or from metadata saved by the Generate UI tab; one-click clipboard copy</li>
<li id="wfm-help-gallery-9">Detail panel — Groups tab: create, assign, remove, rename, and delete groups per image</li>
<li id="wfm-help-gallery-10">Workflow auto-save: images generated in the Generate UI tab automatically have their workflow saved to gallery metadata and shown in the Metadata tab</li>
<li id="wfm-help-gallery-10">Workflow auto-save: images generated in the Generate UI tab automatically have their workflow saved to gallery metadata and shown in the JSON tab</li>
<li id="wfm-help-gallery-11">Supports PNG (tEXt/iTXt), JPEG, WebP, GIF; workflow extraction reads ComfyUI prompt and workflow keys embedded in PNG metadata</li>
<li id="wfm-help-gallery-12"><b>Metadata</b> button (green, in the detail panel tab bar): opens the selected image in the Metadata tab for full embedded-data inspection; Alt+click on any image thumbnail has the same effect</li>
<li id="wfm-help-gallery-13"><b>Load GenUI</b> button (blue, in the detail panel tab bar): loads the embedded ComfyUI workflow from the selected image directly into the GenerateUI tab and switches to it; shows a warning toast if no workflow is embedded or the format is not supported</li>
</ul>
</div>
</div>
@@ -1086,16 +1089,17 @@
<h3>Models Tab</h3>
<ul>
<li id="wfm-help-models-1">Browse installed models: Checkpoint, LoRA, VAE, ControlNet, UNET, TextEncoder, Hypernetwork, Embedding with sub-tab switching</li>
<li id="wfm-help-models-2">Thumbnail, Card, and Table view modes with pagination</li>
<li id="wfm-help-models-2">Thumbnail, Card, and Table view modes with pagination; Table view shows Type and Base Model columns sourced from CivitAI data alongside filename, subdirectory, and extension; <b>column headers are clickable to sort</b> — click once for ascending (▲), again for descending (▼), a third time to clear the sort; the <b>E/D</b> column sorts by enable/disable status</li>
<li id="wfm-help-models-3">Search, tag filter, group filter, favorites filter, and status filter (All / Enabled only / Disabled only)</li>
<li id="wfm-help-models-4">Side panel: opens to CivitAI tab by default when a model is selected; Info (file path, tags, memo), Groups management, CivitAI integration</li>
<li id="wfm-help-models-5">CivitAI integration: fetch model info by SHA256 hash, batch fetch per model type</li>
<li id="wfm-help-models-6">Detail modal: preview image, CivitAI info (base model, trained words, tags), thumbnail change — upload any image format to replace the preview; changes take effect immediately without restarting ComfyUI; broken/empty preview files are automatically skipped</li>
<li id="wfm-help-models-7">Group management: create, rename, delete groups and assign/remove models</li>
<li id="wfm-help-models-6">Detail modal: preview image, CivitAI info (base model, trained words, tags), thumbnail change — upload any image format to replace the preview; changes take effect immediately without restarting ComfyUI; broken/empty preview files are automatically skipped; Delete button permanently removes the model file and all associated sidecar files</li>
<li id="wfm-help-models-7">Group management: create, rename, delete groups and assign/remove models; Checkpoint and LoRA tabs support B (Batch) and S (Stack) quick-assign buttons per model in both card and table views</li>
<li id="wfm-help-models-8">GenUI Model button: apply the selected model to the corresponding node in GenerateUI's current workflow (Checkpoint / LoRA / VAE / ControlNet / UNET / TextEncoder)</li>
<li id="wfm-help-models-9">User-defined badges: assign free-label badges with custom colors shared with the Workflow tab</li>
<li id="wfm-help-models-10">Enable/Disable models: toggle visibility in ComfyUI by renaming file extension (.disabled suffix). Disable per model (⏸ button on each card) or per group (Enable All / Disable All in Group panel). Changes take effect after ComfyUI refresh.</li>
<li id="wfm-help-models-11">Multi-select &amp; bulk operations: click Select to enter selection mode, then check multiple models; the bulk action bar provides: Deselect All — clear all selections without exiting select mode; ★ Favorite / ☆ Unfavorite — toggle favorites for all selected models; Add to Group / Remove from Group — assign or remove from an existing group; Create &amp; Add — type a new group name and add all selected; +Badge / −Badge — apply or remove a badge from all selected; Delete Files — permanently remove model files, preview images, and sidecar files (.json/.info)</li>
<li id="wfm-help-models-11">Multi-select &amp; bulk operations: click Select (green) to enter selection mode, then check multiple models; the bulk action bar is organized into three rows — <b>Group row:</b> select an existing group and Add/Remove, or type a new name and Create &amp; Add; <b>Badge row:</b> select a badge and +Badge / −Badge to apply or remove; <b>File row:</b> select a destination subfolder (or type a new folder name) and Move to relocate model files with all sidecar files (.preview.png, .json, .civitai.info, etc.), Delete Files to permanently remove selected models; header row provides Deselect All and ★/☆ Favorite toggles</li>
<li id="wfm-help-models-12">After moving or deleting models, ComfyUI may fail to load them because it caches the old file paths. Perform a Hard Reset from the ComfyUI menu (Queue → Hard Reset) or restart ComfyUI to refresh the model cache.</li>
</ul>
</div>
</div>
@@ -1158,6 +1162,7 @@
<li id="wfm-help-trouble-3">Workflows not showing: Click refresh button, check if loadable in ComfyUI, try restarting browser/ComfyUI</li>
<li id="wfm-help-trouble-4">Image generation fails: Check if specified models exist in ComfyUI, verify connection, try restarting</li>
<li id="wfm-help-trouble-5">LoRA Stack fails with "No such file or directory" error: The LoRA may not be recognized by comfyui-lora-manager (known issue). Try a different LoRA or check if the file appears in Lora Manager's own UI</li>
<li id="wfm-help-trouble-6">Model loading error after moving or deleting models: ComfyUI caches file paths and may still reference old locations. Perform a Hard Reset from the ComfyUI menu (Queue → Hard Reset) or restart ComfyUI to clear the cache.</li>
</ul>
</div>
</div>
@@ -1266,8 +1271,10 @@
<!-- タブナビ -->
<div class="wfm-side-tab-nav">
<button class="wfm-gallery-detail-tab-btn active" data-detail-tab="info">Info</button>
<button class="wfm-gallery-detail-tab-btn" data-detail-tab="meta">Metadata</button>
<button class="wfm-gallery-detail-tab-btn" data-detail-tab="meta">JSON</button>
<button class="wfm-gallery-detail-tab-btn" data-detail-tab="group">Groups</button>
<button id="wfm-gallery-open-metadata-btn" class="wfm-gallery-detail-tab-btn wfm-gallery-action-btn-green" title="Open in Metadata tab (or Alt+click image)">Metadata</button>
<button id="wfm-gallery-load-genui-btn" class="wfm-gallery-detail-tab-btn wfm-gallery-action-btn-primary" title="Load workflow into GenerateUI">Load GenUI</button>
</div>
<!-- Info タブ -->
<div id="wfm-gallery-detail-info" class="wfm-gallery-detail-tab-content active">