Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3bee0ee09 | ||
|
|
3dc593da4e | ||
|
|
aa8c8f73fe | ||
|
|
281fba373c | ||
|
|
2b84c69ef9 | ||
|
|
7523892bc2 | ||
|
|
d8fc1b62a3 | ||
|
|
f2162844fb |
@@ -1,5 +1,430 @@
|
||||
# DEVLOG - ComfyUI-Workflow-Studio
|
||||
|
||||
## 2026-06-22: v0.3.48 — ギャラリータブ 画像ダウンロード・一括エクスポート機能追加
|
||||
|
||||
**変更ファイル**: `templates/index.html`, `static/js/gallery-tab.js`, `static/css/gallery-tab.css`, `py/routes/gallery_routes.py`, `static/js/i18n.js`
|
||||
|
||||
### 詳細パネルの画像プレビューにダウンロード機能を追加
|
||||
|
||||
- プレビュー画像にマウスホバーでダウンロードアイコン(⬇)をオーバーレイ表示
|
||||
- クリックで単一画像をダウンロード(ファイル名はオリジナルを保持)
|
||||
- CSS: `.wfm-gallery-preview-wrapper`, `.wfm-gallery-preview-overlay`, `.wfm-gallery-download-btn` を追加
|
||||
|
||||
### 複数選択バーに「エクスポート」ボタンを追加
|
||||
|
||||
- 複数選択した画像をZIPファイルにしてダウンロード可能
|
||||
- ファイル名: `gallery_export_<タイムスタンプ>.zip`
|
||||
- Backend: `POST /wfm/gallery/images/export-zip` エンドポイント実装
|
||||
- リクエスト: `{ "paths": [...] }` (画像パスリスト)
|
||||
- レスポンス: ZIP ファイルをバイナリで返送
|
||||
- セキュリティ: `_check_path_allowed()` でパストラバーサル防止
|
||||
|
||||
### i18n対応
|
||||
|
||||
- 英語: "Export" / "Download started" / "Export completed. ZIP file is downloading."
|
||||
- 日本語: "エクスポート" / "ダウンロード開始" / "エクスポート完了。ZIPファイルをダウンロード中です。"
|
||||
- 中国語: "导出" / "下载开始" / "导出完成。正在下载 ZIP 文件。"
|
||||
|
||||
### ヘルプテキスト更新
|
||||
|
||||
- ヘルプ wfm-help-gallery-6: 複数選択バー説明に "Export" を追加
|
||||
- ヘルプ wfm-help-gallery-7: 詳細パネル説明にダウンロードアイコンについての記述を追加
|
||||
|
||||
---
|
||||
|
||||
## 2026-06-22: v0.3.47 — モデルタブ ファイル移動後グループ状態修正
|
||||
|
||||
**変更ファイル**: `static/js/models-tab.js`
|
||||
|
||||
### モデル移動後のグループ状態不整合を修正
|
||||
|
||||
`bulkMoveModels` でモデルをサブディレクトリ間移動した際、Python側(`move_models`)はグループメンバーの名前を `from → to` に更新していたが、JS の `state.modelGroups` が更新されていなかった。
|
||||
|
||||
このため移動直後にグループフィルターで絞り込むと、移動したモデルが消えてしまう(旧名で参照されるため一致しなくなる)問題があった。
|
||||
|
||||
- `data.moved.forEach` ループ内で `state.modelGroups` の各グループメンバーを `from → to` でリネーム
|
||||
- サーバーが `_groups` を更新する処理と対称的なクライアント側更新
|
||||
- `state.modelGroups` と `state.allModelGroups[type]` は同一オブジェクト参照のためインプレース更新で両方に反映される
|
||||
- Generate タブ Batch の `_batchGroupState.groups` はサーバーから毎回取得するため影響なし
|
||||
|
||||
---
|
||||
|
||||
## 2026-06-21: v0.3.46 — プロンプトタブ AI Assistant LM Studio対応・設定タブ AI Assistant設定に変更
|
||||
|
||||
**変更ファイル**: `static/js/settings-tab.js`, `static/js/prompt-tab.js`, `static/js/i18n.js`, `templates/index.html`
|
||||
|
||||
### 設定タブ「AI Assistant設定(プロンプトタブ)」
|
||||
|
||||
設定タブの「Ollama設定(プロンプトタブ)」セクションを AI TOOL タブの SETTINGS ペインと同等の内容に変更。
|
||||
|
||||
- セクション名を **「AI Assistant設定(プロンプトタブ)」** に変更
|
||||
- **バックエンド選択ラジオ(Ollama / LM Studio)** を追加
|
||||
- **API URL 入力** — バックエンド切替時にプレースホルダーが自動変更(Ollama: `http://localhost:11434`、LM Studio: `http://localhost:1234`)
|
||||
- **モデル選択 + Refresh** — 選択中のバックエンドへ直接接続してモデル一覧を取得
|
||||
- **Test ボタン** — バックエンドへ直接接続テスト
|
||||
- **Save ボタン** — 設定を localStorage `wfm_prompt_ai_settings` に保存(サーバーAPI不要)
|
||||
- AI TOOL タブの設定(`wfm_ai_settings`)とは独立した設定キーを使用
|
||||
|
||||
### プロンプトタブ AI Assistant LM Studio対応
|
||||
|
||||
Python プロキシルート(`/api/wfm/ollama/*`)依存を廃止し、AI TOOL タブと同方式のブラウザから直接バックエンドAPIを呼び出す実装に変更。
|
||||
|
||||
- Ollama: `{url}/api/tags`(モデル一覧)、`{url}/api/chat`(チャット)
|
||||
- LM Studio: `{url}/v1/models`(モデル一覧)、`{url}/v1/chat/completions`(チャット)
|
||||
- 画像添付(ビジョンモデル)も両バックエンド対応 — Ollama形式(`images`フィールド)を LM Studio形式(`content`配列の`image_url`)に自動変換
|
||||
- 設定タブで保存したモデルを初期選択として表示
|
||||
- ウェルカムメッセージの "AI Assistant (Ollama)" 表記を削除
|
||||
|
||||
### バックエンド変更時の自動モデル再取得
|
||||
|
||||
設定タブでバックエンドを変更した後にプロンプトタブですぐ送信しようとすると、ドロップダウンに旧バックエンドのモデル名が残ったまま送信されモデル未認識エラーが発生する問題を修正。
|
||||
|
||||
- `_promptAiBackendForModels` 変数にモデル一覧取得時のバックエンドを記録
|
||||
- `sendMessage()` の冒頭で現在設定と比較し、バックエンドが変わっていた場合は自動でモデル一覧をリフレッシュしてから送信
|
||||
- モデル一覧表示に `[ollama]` / `[lmstudio]` のバックエンド名を付記
|
||||
|
||||
### i18n 更新(EN/JA/ZH)
|
||||
|
||||
- `ollamaSettings` → "AI Assistant Settings (Prompt Tab)"
|
||||
- `ollamaUrl` → "API URL"(汎用)
|
||||
- `saveOllama` → "Save AI Assistant Settings"
|
||||
- `ollamaSaved` → "AI Assistant settings saved"
|
||||
- `helpPrompt1` — "Ollama" → "Ollama / LM Studio"・設定場所の説明を追記
|
||||
- `helpSettings5` — バックエンド選択・URL・モデル・接続テストの説明に更新
|
||||
- `helpTrouble2` — "Ollamaに接続できない" → "AIアシスタントに接続できない(Ollama/LM Studio両対応)"
|
||||
|
||||
---
|
||||
|
||||
## 2026-06-21: v0.3.45 — グループ孤立エントリ自動クリーンアップ・Galleryタブ Shift+クリック範囲選択
|
||||
|
||||
**変更ファイル**: `py/services/models_service.py`, `py/services/gallery_service.py`, `py/services/gallery_metadata.py`, `static/js/gallery-tab.js`, `static/js/i18n.js`
|
||||
|
||||
### グループ孤立エントリ自動クリーンアップ
|
||||
|
||||
ファイルをアプリ外(OS)で移動・削除した際にグループデータに残る孤立エントリを自動的に除去する仕組みを追加。
|
||||
|
||||
#### Modelsタブ
|
||||
|
||||
- `models_service.py` に `_scan_model_names(model_type)` を追加 — `_get_model_dirs` の全ディレクトリを `rglob` で走査し、有効なモデルファイル名のセットを返す(`.disabled` サフィックスを除いた相対パス)
|
||||
- `get_model_groups(model_type)` に自動クリーンアップを追加 — タイプ指定時にファイルスキャンを実行し、存在しないモデル名をグループから除去;変更があった場合のみ保存
|
||||
- `move_models()` でグループエントリを即時更新 — アプリ内での移動時に `renames` リストを収集し、`_groups[model_type]` 内の旧パスを新パスに一括書き換え
|
||||
|
||||
#### Galleryタブ(フォルダ表示)
|
||||
|
||||
- `gallery_metadata.py` に `cleanup_stale_images(folder_path, existing_paths)` を追加 — `folder_path` 配下のメタデータキーのうち `existing_paths` に含まれないものを削除して保存
|
||||
- `gallery_service.py` の `list_images()` で `_scan_folder` 直後にクリーンアップを呼ぶ — スキャン結果の `abs_path` セットを渡すため、60秒 TTL キャッシュとフォルダ mtime 変化検知に連動して自動実行
|
||||
|
||||
#### Galleryタブ(グループ画像一覧)
|
||||
|
||||
- `gallery_metadata.py` に `remove_stale_paths_from_group(group_name, stale_paths)` を追加 — 孤立パスをグループから一括削除し1回の保存で完結
|
||||
- `gallery_service.py` の `list_images_in_group()` で `Path.is_file()` チェックを追加 — FeederタブのGalleryモード(`GET /wfm/gallery/groups/{name}/images`)呼び出し時に孤立パスをグループから自動除去して既存ファイルのみ返す
|
||||
|
||||
#### 各タブのクリーンアップトリガー
|
||||
|
||||
| タブ | トリガー | 対象 |
|
||||
|---|---|---|
|
||||
| Modelsタブ | タブ切替・モデルタイプ変更時 | 全グループから存在しないモデル名を削除 |
|
||||
| Modelsタブ(アプリ内移動) | `move_models` API 呼び出し時 | グループ内パスを即時更新 |
|
||||
| Galleryタブ(フォルダUI) | フォルダ表示時(mtime 変化 or 60秒後) | フォルダ内の孤立メタデータエントリを削除 |
|
||||
| Galleryタブ(Feederモード) | グループ画像一覧取得時 | グループから孤立パスを削除 |
|
||||
|
||||
### GalleryタブのShift+クリック範囲選択
|
||||
|
||||
- `state` に `lastSelectionIndex: -1` を追加(Shift 選択のアンカーインデックス)
|
||||
- `createThumbCard()` / `createTable()` に `data-path` 属性を追加
|
||||
- `_applySelectionToDOM()` ヘルパーを追加 — `state.selectedImages` を元に描画済み要素の `multi-selected` クラスを一括同期;ページング未描画の要素はスクロールで描画される際に `createThumbCard` が自動で反映
|
||||
- サムネイルビュー・テーブルビューのクリックハンドラを更新:
|
||||
- Shift+クリック: アンカーから現在位置まで `state.images` のインデックス範囲で一括追加
|
||||
- Ctrl+クリック: 個別トグル(既存)+アンカー更新
|
||||
- 通常クリック: 詳細表示(既存)+アンカー更新
|
||||
- `lastSelectionIndex` リセット箇所: フォルダ切替時・`loadImages()` 完了時(ソート/フィルタ変更後も含む)・一括解除ボタン押下時
|
||||
- `i18n.js` の `helpGallery6`(EN/JA/ZH)を更新して Shift+クリック範囲選択を追記
|
||||
|
||||
---
|
||||
|
||||
## 2026-06-21: v0.3.44 — Galleryタブ高速化・比較モード・バルク強化・バルクバーUI整理
|
||||
|
||||
**変更ファイル**: `py/services/gallery_service.py`, `py/routes/gallery_routes.py`, `static/js/gallery-tab.js`, `static/css/gallery-tab.css`, `templates/index.html`, `static/js/app.js`, `static/js/i18n.js`
|
||||
|
||||
### フェーズ2-A: サーバーサイドサムネイル生成
|
||||
|
||||
- `gallery_service.py` に `serve_thumbnail(path, width=256)` を追加
|
||||
- Pillow で画像を 256px JPEG に縮小し `data/thumb_cache/` にキャッシュ(キー: `md5(path:mtime:width)`)
|
||||
- GIF はアニメーション保持のため元ファイルをそのまま返す;Pillow 未インストール時は元ファイルにフォールバック
|
||||
- `GET /wfm/gallery/image/thumb?path=...&w=256` エンドポイントを `gallery_routes.py` に追加(Cache-Control 24時間)
|
||||
- `gallery-tab.js` のサムネイルビュー・テーブルビューを `/image/serve` → `/image/thumb` に切り替え;ライトボックス・詳細プレビューは引き続き元画像を使用
|
||||
|
||||
### フェーズ2-B: 無限スクロールページング
|
||||
|
||||
- モジュールレベル変数 `PAGE_SIZE=50`, `_renderedCount`, `_scrollObserver` を追加
|
||||
- `renderImages()` をリファクタリング: 初回は50枚のみ DOM に追加し、末尾にセンチネル div を配置
|
||||
- `IntersectionObserver`(rootMargin 300px)がセンチネルを検出するたびに次の50枚を追加
|
||||
- 全枚数を描画し終えたらオブザーバーを切断してセンチネルを削除
|
||||
- `renderImages()` 呼び出し(フォルダ切替・フィルタ変更・ソート変更)のたびに自動リセット
|
||||
|
||||
### フェーズ3-A: バルクAPIエンドポイント
|
||||
|
||||
- `gallery_service.py` に `bulk_set_favorite(paths, value)` と `bulk_group_op(paths, group, action)` を追加
|
||||
- `POST /wfm/gallery/bulk/favorite`, `POST /wfm/gallery/bulk/group` を `gallery_routes.py` に追加
|
||||
- フロントエンドの `bulkSetFavorite()` / `bulkAddToGroup()` を N並列個別リクエスト → 単一バルクリクエストに変更
|
||||
|
||||
### フェーズ3-B: 画像比較モード
|
||||
|
||||
- Ctrl+クリックで2〜4枚選択すると Bulk Bar に「比較」ボタンが出現
|
||||
- `openCompare(paths)` 関数を追加: `--compare-cols` CSS カスタムプロパティで列数を動的制御した CSS Grid サイドバイサイドライトボックス
|
||||
- 閉じるボタンは `position:fixed; top:16px; right:16px` で配置し `overflow:auto` コンテナによるクリッピングを防止
|
||||
- i18n: `galleryBulkCompare`(EN/JA/ZH)追加
|
||||
|
||||
### フェーズ3-C: プロンプト全文検索
|
||||
|
||||
- `get_image_metadata()` 実行時に PNG/JPEG 埋め込みテキスト(`workflow` キーを除く文字列フィールド)を連結して `metadata.json` の `prompt_cache` に保存
|
||||
- `list_images()` の検索フィルタに `prompt_cache` を追加(ファイル名・メモ・タグに加えて)
|
||||
- 検索プレースホルダを「名前・タグ・プロンプトで検索...」に更新(EN/JA/ZH)
|
||||
- ヘルプ `helpGallery4` を更新して prompt 検索対応を明記
|
||||
|
||||
### バルクバーUI整理
|
||||
|
||||
- ドロップダウンプレースホルダ「グループに追加...」→「グループ選択」
|
||||
- 「追加」ボタン → 「グループに追加」
|
||||
- 「グループから削除」ボタンを「グループに追加」の右隣に新規追加
|
||||
- `bulkRemoveFromGroup()` 関数を追加(`POST /wfm/gallery/bulk/group` の `action:"remove"` を使用)
|
||||
- `removedNImagesFromGroup` i18n キー追加(EN/JA/ZH)
|
||||
- 「削除」ボタン → 「ファイル削除」(グループ削除との混同を防ぐ)
|
||||
- ヘルプ `helpGallery6`, `helpGallery7` を更新
|
||||
|
||||
---
|
||||
|
||||
## 2026-06-21: ヘルプタブ改善 — Gallery mode 多言語対応・フォント拡大・検索機能追加
|
||||
|
||||
**変更ファイル**: `templates/index.html`, `static/js/app.js`, `static/js/i18n.js`, `static/css/main.css`
|
||||
|
||||
### Gallery mode の多言語対応
|
||||
|
||||
Feeder サブタブの Gallery mode セクション(h4 見出し・説明文・リスト6項目)が英語のハードコードのままだったのを i18n 対応に変更。
|
||||
|
||||
**修正(`templates/index.html`)**
|
||||
- `<h4 id="wfm-help-feeder-imgloop-title">` と `<p id="wfm-help-feeder-imgloop-desc">` を追加(Image Loop mode 見出し・説明文を i18n 化)
|
||||
- `<h4 id="wfm-help-feeder-gal-title">` と `<p id="wfm-help-feeder-gal-desc">` を追加
|
||||
- Gallery mode 6項目に `id="wfm-help-feeder-gal-1"` 〜 `id="wfm-help-feeder-gal-6"` を付与
|
||||
|
||||
**修正(`static/js/app.js`)**
|
||||
- `helpIdMap` に `helpFeederImgloopTitle` / `helpFeederImgloopDesc` / `helpFeederGalTitle` / `helpFeederGalDesc` / `helpFeederGal1`〜`helpFeederGal6` を追加
|
||||
|
||||
**修正(`static/js/i18n.js`)**
|
||||
- `helpFeederDesc`: 「2モード切り替え」の説明に EN/JA/ZH で更新
|
||||
- `helpFeederImgloopTitle` / `helpFeederImgloopDesc`: Image Loop mode 見出し・説明を EN/JA/ZH で追加
|
||||
- `helpFeederGalTitle` / `helpFeederGalDesc` / `helpFeederGal1`〜`helpFeederGal6`: Gallery mode 全項目を EN/JA/ZH で追加
|
||||
- `helpSearchPlaceholder`: 検索ボックスのプレースホルダーを EN/JA/ZH で追加
|
||||
|
||||
### ヘルプ全体フォントを 1.5 倍に変更
|
||||
|
||||
**修正(`static/css/main.css`)**
|
||||
- `.wfm-help-nav-item`: 12px → 18px
|
||||
- `.wfm-help-sidebar` 幅: 170px → 220px(フォント拡大に伴う調整)
|
||||
- `.wfm-help-card h3`: 14px → 21px
|
||||
- `.wfm-help-card h4`: 18px(新規追加)
|
||||
- `.wfm-help-card p`: 20px(新規追加)
|
||||
- `.wfm-help-card li`: 13px → 20px
|
||||
- `.wfm-help-link-title`: 15px → 23px
|
||||
- `.wfm-help-link-desc`: 12px → 18px
|
||||
- `.wfm-help-thanks`: 13px → 20px
|
||||
- `.wfm-help-support-card > p`: 14px → 21px
|
||||
|
||||
### ヘルプタブに検索機能を追加
|
||||
|
||||
**修正(`templates/index.html`)**
|
||||
- サイドバーの `.wfm-help-nav` 上部に `<input id="wfm-help-search">` を追加
|
||||
|
||||
**修正(`static/js/app.js`)**
|
||||
- `_onHelpSearch()`: 入力テキストで全ヘルプページの `textContent` を検索。マッチしないナビゲーションボタンは `search-hidden` クラスで非表示。マッチするページが1つでもあれば最初にマッチしたページを自動表示
|
||||
|
||||
**修正(`static/css/main.css`)**
|
||||
- `.wfm-help-search-wrap` / `.wfm-help-search` / `.wfm-help-search:focus` / `.wfm-help-nav-item.search-hidden` のスタイルを追加
|
||||
|
||||
---
|
||||
|
||||
## 2026-06-21: Send to Canvas — window.opener経由のキャンバス直接ロード対応
|
||||
|
||||
**背景**: SPAは `window.open(url, "_blank")` でComfyUIとは別タブとして開かれる。同一オリジンの別タブでは `window.opener` 経由でComfyUIウィンドウのJavaScriptに直接アクセスできる。従来の「タイトルドラッグ(Send to Canvas)」はSPAウィンドウ→ComfyUIウィンドウのクロスウィンドウDnDだったが、`dragover` イベント中はブラウザのセキュリティ制限でカスタムMIMEタイプが `DataTransfer.types` に含まれず `e.preventDefault()` が呼ばれないため `drop` イベントがキャンバスに届かなかった(Wタブ内DnDは同一ウィンドウなので `app.handleFile` が機能していた)。
|
||||
|
||||
**修正(`web/comfyui/node_sets_menu.js`)**
|
||||
- `window.wfmReceiveWorkflow(data)` グローバル関数を追加: `loadDataOnCanvas(data)` → `app.handleFile(file)` 経由でワークフローをキャンバスにロード(UI/API形式どちらも対応)
|
||||
- WタブのAPI形式アイテムのグレーアウト(`wfm-nlp-item--disabled` クラス・`draggable=false`・title属性)を削除 → 全フォーマットでDnD・ダブルクリック対応
|
||||
|
||||
**修正(`static/js/workflow-tab.js`)**
|
||||
- `sendToCanvas()`: `window.opener.wfmReceiveWorkflow` が存在する場合は直接呼び出す(UI/API形式両対応)。存在しない場合(ブックマーク等から直接開いた場合)はlocalStorageフォールバック(UI形式のみ、API形式はエラートーストで案内)
|
||||
- サイドパネル・詳細モーダルのSend to CanvasボタンのAPI形式 `disabled` 属性を削除
|
||||
|
||||
**修正(`static/js/gallery-tab.js`)**
|
||||
- `_updateCopyCanvasBtn()`: API形式による `disabled` 制限を削除(workflow存在チェックのみ)
|
||||
- Copy & Send Canvasクリックハンドラ: `window.opener.wfmReceiveWorkflow` 優先に変更(フォールバックはlocalStorage + タイトルドラッグ)
|
||||
|
||||
**修正(`static/js/i18n.js`)**
|
||||
- `apiFormatCanvasNoOpener` キーを追加(EN/JA/ZH): window.openerなしでAPI形式を送ろうとした場合のエラーガイドメッセージ
|
||||
- `helpGallery8` / `helpSidepanel17` を新しい動作(直接送信・フォールバック説明)に合わせて更新(3言語)
|
||||
|
||||
---
|
||||
|
||||
## 2026-06-20: API形式ワークフローのキャンバス読み込み修正・画像メタデータ埋め込み修正
|
||||
|
||||
### API形式ワークフローをキャンバスへドラッグすると空になる問題を修正
|
||||
|
||||
**症状**: Workflowタブ「Send to Canvas」やLibraryからのDnDで、API形式(`_api.json`)のワークフローをComfyUIキャンバスへドロップすると空のグラフになる。ファイルエクスプローラーからのドロップは正常。
|
||||
|
||||
**原因**: `app.loadGraphData()` はUIフォーマット(`{nodes:[...], links:[...]}`)を期待するが、API形式(`{nodeId: {class_type, inputs}}`)が渡されていた。
|
||||
|
||||
**修正(`web/comfyui/node_sets_menu.js`)**
|
||||
- `isApiWorkflowFormat(data)`: API形式かUI形式かを判定するヘルパーを追加
|
||||
- `convertApiToUiWorkflow(api)`: API形式→UI形式に変換するヘルパーを追加(ノードはグリッド自動配置、リンクタイプは `"*"`、`last_node_id`/`last_link_id` を正しく設定)
|
||||
- `loadWorkflowOnCanvas`: `fetchWorkflowRaw` 後にAPI形式を検出・変換してから `app.loadGraphData()` を呼ぶよう修正
|
||||
- `pendingRaw` ドロップハンドラ: Send to Canvas経由のタイトルDnD時にも同様の変換を挿入
|
||||
|
||||
**修正(`static/js/workflow-tab.js`)**
|
||||
- `sendToCanvas()`: `comfyWorkflow.detectFormat` でフォーマット判定し、API形式なら `comfyWorkflow.convertApiToUi()` でUI形式に変換してからlocalStorageに保存
|
||||
|
||||
**修正(`static/js/gallery-tab.js`)**
|
||||
- `comfyWorkflow` を `comfyui-workflow.js` からimport追加
|
||||
- 「Copy & Send Canvas」ハンドラ: クリップボードにはオリジナルJSON(API形式のまま)をコピーしつつ、localStorage保存前にAPI→UI変換を適用
|
||||
|
||||
---
|
||||
|
||||
### 生成UIタブから生成した画像にワークフローメタデータが含まれない問題を修正
|
||||
|
||||
**症状**: 生成UIタブ(およびFeederタブ)から実行した画像生成で、SaveImageノードが保存するPNGに `workflow` テキストチャンクが埋め込まれず、GalleryタブでのWorkflow表示や他ツールでのメタデータ読み込みができない。
|
||||
|
||||
**原因**: `comfyui-client.js` の `queuePrompt()` が ComfyUI の `/prompt` エンドポイントに `extra_data` を渡していなかった。ComfyUIのSaveImageノードは `extra_data.extra_pnginfo.workflow` を受け取ってPNGの `workflow` テキストチャンクに埋め込むが、これが未設定のため埋め込みが行われなかった。
|
||||
|
||||
**修正(`static/js/comfyui-client.js`)**
|
||||
- `queuePrompt(workflow, extraData = null)`: `extraData` 引数を追加。存在する場合に `body.extra_data` として `/prompt` リクエストに含める
|
||||
- `generate()`: `queuePrompt` 呼び出し時に `{ extra_pnginfo: { workflow } }` を渡し、SaveImageノードがワークフロー(API形式)をPNGメタデータとして埋め込むよう修正
|
||||
|
||||
---
|
||||
|
||||
## 2026-06-20: セキュリティ修正(XSS・パスバリデーション)
|
||||
|
||||
### 修正内容
|
||||
|
||||
**XSS — タグ名がエスケープなしで `innerHTML` に挿入される(`static/js/gallery-tab.js`)**
|
||||
- `createTable` (L425): `tdTags.innerHTML` のタグ名を `escapeHtml` でエスケープ
|
||||
- `renderTagsDisplay` (L605): タグ名と `data-tag` 属性を `escapeHtml` でエスケープ
|
||||
- 悪意あるタグ名(例: `<img onerror=...>`)を保存→表示したときに JS が実行される問題
|
||||
|
||||
**XSS — ファイル名がエスケープなしで `innerHTML` に挿入される(`static/js/gallery-tab.js`)**
|
||||
- `loadImageDetail` (L566): `alt="${img.filename}"` を `escapeHtml` でエスケープ
|
||||
- `openLightbox` (L1175-1176): `alt` 属性とライトボックスフッターの両方をエスケープ
|
||||
|
||||
**XSS — エラーメッセージが `innerHTML` に未エスケープ(`static/js/gallery-tab.js`)**
|
||||
- フォルダツリーエラー (L139, L155) と 画像グリッドエラー (L263) を `escapeHtml` でエスケープ
|
||||
- サーバーエラーメッセージにパス名等の特殊文字が含まれる場合の対策
|
||||
|
||||
**メタデータ書き込みエンドポイントにパスバリデーション追加(`py/services/gallery_service.py`)**
|
||||
- `save_image_meta`, `toggle_favorite`, `add_to_group`, `remove_from_group` に `_check_path_allowed()` を追加
|
||||
- delete/move など他の書き込みエンドポイントには既にあったが、これら4メソッドのみ漏れていた
|
||||
- 修正により `gallery_metadata.json` に許可ルート外のパス文字列が書き込まれるのを防止
|
||||
|
||||
**`list_folder_tree` が `_allowed_root` を任意パスで上書きできる問題(`py/routes/gallery_routes.py`)**
|
||||
- `gallery_routes.py` のモジュールロード時に `_init_allowed_root()` を呼び出し、保存済み `gallery_output_dir`(なければ ComfyUI デフォルト output ディレクトリ)で `_allowed_root` を初期化
|
||||
- `_allowed_root` が起動直後に設定済みになるため、`list_folder_tree` の `if self._allowed_root is None` ブランチが発火せず、任意パスによる上書き不可
|
||||
- 副次効果として、Gallery タブを一度も開かない状態でも `serve_image` が正常動作(→ Feeder Gallery モードでの 404 バグ修正に直結)
|
||||
|
||||
**`escapeHtml` にシングルクォートのエスケープを追加(`static/js/util.js`)**
|
||||
- `'` → `'` を追加
|
||||
- 現在の使用箇所はすべて二重引用符属性のため即時影響はないが、将来の誤用を防止
|
||||
|
||||
---
|
||||
|
||||
## 2026-06-20: WFS_GalleryFeeder — ComfyUI キャンバス上コントロール追加
|
||||
|
||||
### 新規ファイル(`web/comfyui/gallery_feeder_extension.js`)
|
||||
`app.registerExtension` を使い、ComfyUI キャンバス上の `WFS_GalleryFeeder` ノードに直接コントロールを追加。
|
||||
|
||||
- **After Gen** コンボ(`loop` / `increment` / `fixed`): `serialize: false` で prompt には含まれない
|
||||
- **▶ Run ボタン**: グループ画像を取得 → `index` ウィジェットを更新 → `app.queuePrompt` → 完了待ち → 繰り返し
|
||||
- **■ Stop ボタン**: `app.api.interrupt()` で現在の生成を中断し、ループフラグをクリア
|
||||
- `waitForExecution()`: `executing` (null)・`execution_interrupted`・`execution_error` の3イベントを購読して1プロンプトの完了を Promise で待つ
|
||||
- `onRemoved` フックでノード削除時にループを自動停止・状態をクリーンアップ
|
||||
|
||||
---
|
||||
|
||||
## 2026-06-20: __Feeder__ グループ保護 + サムネイル F ボタン + seed バグ修正
|
||||
|
||||
### `__Feeder__` グループの予約済み保護
|
||||
|
||||
**サーバーサイド(`py/routes/gallery_routes.py`)**
|
||||
- `_RESERVED_GROUPS = {"__Feeder__"}` 定数を追加
|
||||
- `rename_group` / `delete_group` エンドポイントで予約グループへの操作を 403 で拒否
|
||||
|
||||
**クライアントサイド(`static/js/gallery-tab.js`)**
|
||||
- グループ管理ドロップダウンで `__Feeder__` を選択したとき、リネーム・削除ボタンを `disabled` に
|
||||
- セレクトオプションに 🔒 プレフィックスを追加して視覚的に区別
|
||||
- `change` イベントリスナーで動的に切り替え
|
||||
|
||||
### ギャラリーサムネイル「F」オーバーレイボタン(`static/js/gallery-tab.js`, `static/css/gallery-tab.css`)
|
||||
- モデルタブの「B」バッチ登録ボタンと同様の位置(カード左上)に「F」ボタンを追加
|
||||
- `inFeeder` 初期状態は `img.groups` 配列から判定(`list_images()` が返す `groups` フィールドを使用)
|
||||
- クリックで `__Feeder__` グループへの追加 / 除外をトグル(APIコール + in-memory キャッシュ更新)
|
||||
- アクティブ時はシアン色 (`#38bdf8`)、ホバー時のみ表示(active 時は常時表示)
|
||||
|
||||
**i18n(`static/js/i18n.js`)**
|
||||
- 英/日/中に `addedToFeeder` / `removedFromFeeder` キーを追加
|
||||
|
||||
### seed バリデーションエラー修正(`py/nodes/gallery_feeder_node.py`)
|
||||
**症状**: Feeder run 実行時に "Prompt outputs failed validation" エラーが発生
|
||||
|
||||
**原因**: `comfyui-client.js` の `applySeedToWorkflow()` がグラフ内の全ノードの seed を `Number.MAX_SAFE_INTEGER`(約 9×10¹⁵)以下のランダム値に上書きする。`WFS_GalleryFeeder` が宣言していた `max: 0x7FFFFFFF`(約 2.1×10⁹)を大幅に超えるため、ComfyUI の `validate_prompt()` が `value_bigger_than_max` でリジェクト。
|
||||
|
||||
**修正**: seed の `max` を `0x7FFFFFFF` → `0xffffffffffffffff`(KSampler と同値)に変更。
|
||||
|
||||
---
|
||||
|
||||
## 2026-06-20: Gallery Feeder 機能追加(WFS_GalleryFeeder ノード)
|
||||
|
||||
### 概要
|
||||
Feeder タブにギャラリー連携モードを追加。外部プラグイン(comfyui-image-feeder)に依存せず、本プラグイン単独でギャラリーグループの画像を連続生成ループに利用できるようになった。
|
||||
|
||||
### 新規ノード(`py/nodes/gallery_feeder_node.py`)
|
||||
- **`WFS_GalleryFeeder`**(Workflow Studio カテゴリ)
|
||||
- 入力: `group_name` (STRING), `index` (INT), `sort_mode` (COMBO: filename_asc/filename_desc/random), `seed` (INT)
|
||||
- 出力: `IMAGE`
|
||||
- `gallery_metadata.json` を直接読み込み、指定グループの画像を `index % len(images)` で1枚出力
|
||||
- ファイルの存在チェックつき(削除済み画像はスキップ)
|
||||
- `IS_CHANGED` で毎回実行(インデックスが変わるためキャッシュ無効化)
|
||||
- データファイルの場所は `Path(__file__)` ベースで自動解決(ComfyUI のパス構成に依存しない)
|
||||
|
||||
### ノード登録(`__init__.py`)
|
||||
- `WFS_GalleryFeeder` を `_NODE_MODULES` に追加(`"Gallery Feeder (WFS)"` として表示)
|
||||
- あわせて既存の `WFS_PromptText` のディスプレイ名がハードコードされていたバグを修正(`_NODE_MODULES` にディスプレイ名を持たせる構造に変更)
|
||||
|
||||
### Feeder グループ管理(`py/services/gallery_metadata.py`, `py/services/gallery_service.py`)
|
||||
- `clear_group(group_name)`: グループ内の全画像を除外(グループ自体は残す)
|
||||
- `ensure_group(name)`: グループが存在しない場合のみ作成
|
||||
|
||||
### API エンドポイント(`py/routes/gallery_routes.py`)
|
||||
- `POST /wfm/gallery/groups/{name}/clear` — グループの全画像を除外(FC ボタン用)
|
||||
- `POST /wfm/gallery/groups/ensure` — グループが存在しない場合のみ作成(Feeder タブ初期化時に `__Feeder__` を自動作成)
|
||||
|
||||
### ギャラリータブ FC ボタン(`static/js/gallery-tab.js`, `templates/index.html`)
|
||||
- `FEEDER_GROUP = "__Feeder__"` 定数を export
|
||||
- `ensureFeederGroup()` を export(Feeder タブ初期化時に呼び出す)
|
||||
- `clearFeederGroup()`: `/wfm/gallery/groups/__Feeder__/clear` を呼び出してグループをクリア
|
||||
- ギャラリーツールバーのグループフィルタ横に **[FC]** ボタンを追加(BC/SC ボタンと同様の位置)
|
||||
- API 定数に `groupEnsure`, `groupClear`, `groupImages` を追加
|
||||
|
||||
### Feeder タブ Gallery モード(`static/js/feeder-tab.js`, `templates/index.html`)
|
||||
- 左ペイン上部に **[Image Loop] / [Gallery]** のモード切り替えボタンを追加(`localStorage` に保存)
|
||||
- **Image Loop モード**(既存機能): 変更なし
|
||||
- **Gallery モード**(新機能):
|
||||
- 左ペイン: `WFS_GalleryFeeder` ノード選択・Apply・グループ選択・Sort Mode / Index / Seed・After gen (Loop/Increment/Fixed)・Run/Stop
|
||||
- 中央ペイン: 選択グループの画像グリッド(`/wfm/gallery/image/serve` でサムネイル表示)。クリックで Index を更新
|
||||
- 右ペイン: プレビュー(既存と共通)
|
||||
- Run ループ: JS 側でインデックスを管理(WebSocket sync 不要)。Increment モードで末尾到達時に自動停止
|
||||
- タブ初期化時に `ensureFeederGroup()` を呼び出して `__Feeder__` グループを自動作成
|
||||
|
||||
### i18n(`static/js/i18n.js`)
|
||||
- 英・日・中に3キー追加: `feederGalNoNode`, `feederGalEmptyGroup`, `feederGroupCleared`
|
||||
|
||||
---
|
||||
|
||||
## 2026-06-19: Generate UI — ImpactWildcardEncode/Processor プロンプト検出バグ修正(v0.3.41)
|
||||
|
||||
### 修正内容(`static/js/comfyui-workflow.js`)
|
||||
|
||||
@@ -13,12 +13,12 @@ A comprehensive workflow, asset management, and generation UI plugin for [ComfyU
|
||||
|
||||
**📚 Workflow Studio Library** — a multi-function side panel for smooth ComfyUI integration
|
||||
- Drag & drop models, nodes, prompts, and workflows straight onto the canvas
|
||||
- **Send to Canvas**: click "Send to Canvas" (Workflow tab) or "Copy & Send Canvas" (Gallery tab) — the panel title highlights blue; drag it onto the canvas to load the workflow
|
||||
- **Send to Canvas**: click "Send to Canvas" (Workflow tab) or "Copy & Send Canvas" (Gallery tab) to send the workflow directly to the ComfyUI canvas — UI and API formats both supported
|
||||
- View metadata from images / JSON, then drop the detected models and prompts onto the canvas
|
||||
- Built-in AI tools (translation and more)
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
## Screenshots
|
||||
|
||||
@@ -58,7 +58,7 @@ A comprehensive workflow, asset management, and generation UI plugin for [ComfyU
|
||||
- **Side panel tabs** — Thumbnail preview, JSON viewer with syntax highlighting, and Group management
|
||||
- **Badge management** — add, rename, delete badges with custom colors shared with the Models tab (⚙ Badge button)
|
||||
- **AI summary** — generate workflow descriptions using Ollama
|
||||
- **Import / Export** — import workflows from files or clipboard; **Send to Canvas** button stores the selected workflow for title-drag onto the ComfyUI canvas
|
||||
- **Import / Export** — import workflows from files or clipboard; **Send to Canvas** button sends the selected workflow directly to the ComfyUI canvas (UI and API formats both supported)
|
||||
- **Default view setting** — persist your preferred view mode (Thumbnail / Table)
|
||||
|
||||
### Canvas Snapshot (v0.1.2)
|
||||
@@ -84,8 +84,10 @@ A comprehensive workflow, asset management, and generation UI plugin for [ComfyU
|
||||
- **UI-to-API conversion** — automatic conversion supporting subgraphs (nested workflows), COMBO types, and display-only node exclusion; improved analysis covers SDXL multi-hop CONDITIONING chains, CLIPTextEncodeSDXL, SDXLPromptStyler, KSamplerAdvanced, and more
|
||||
- **Eagle integration** — auto-save generated images to [Eagle](https://eagle.cool/) with metadata
|
||||
|
||||
### Feeder subtab (v0.3.5)
|
||||
Requires the **[comfyui-image-feeder](https://github.com/ketle-man/comfyui-image-feeder)** custom node.
|
||||
### Feeder subtab (v0.3.5 / v0.3.42)
|
||||
Two independent modes selectable via **[Image Loop] / [Gallery]** toggle buttons at the top of the left pane (persisted in `localStorage`).
|
||||
|
||||
**Image Loop mode** — requires the **[comfyui-image-feeder](https://github.com/ketle-man/comfyui-image-feeder)** custom node.
|
||||
- **ImageFeeder node control** — select the target node from a dropdown auto-populated from the loaded workflow; edit all node parameters (Directory, Sort Mode, Index, Start/End Index, Batch Size, Seed, Use Selection) and Apply to the workflow
|
||||
- **Image library** — 3-pane layout: folder tree (left) browsing `user/default/image-loop-data/`, image grid with checkbox selection (center), preview panel with resolution and file size (right)
|
||||
- **Selection management** — check individual images; All / None buttons for the current folder; selected files are reflected in `selected_files` on Apply
|
||||
@@ -97,6 +99,13 @@ Requires the **[comfyui-image-feeder](https://github.com/ketle-man/comfyui-image
|
||||
- **Index sync** — after each generation the node returns `next_index` via WebSocket (`image_loop_node_sync`); the Index field updates automatically
|
||||
- **Seed** — Run loop uses the right-pane seed setting (Random / Fixed / Increment / Decrement); the node's own Seed field only affects random sort order
|
||||
|
||||
**Gallery mode** (v0.3.42) — no external plugin required; uses the built-in **WFS_GalleryFeeder** custom node.
|
||||
- **WFS_GalleryFeeder node** — reads images directly from a Gallery group and outputs them one at a time; inputs: `group_name`, `index`, `sort_mode` (filename_asc / filename_desc / random), `seed`
|
||||
- **Node & group selector** — pick the WFS_GalleryFeeder node from the loaded workflow and choose which Gallery group to feed images from; `__Feeder__` group is auto-created on first open
|
||||
- **Image grid** — center pane shows all images in the selected group; click any image to update the Index to that position
|
||||
- **After Gen modes** — Loop (wrap at end and continue indefinitely), Increment (stop automatically when last image is reached), Fixed (always use the same index)
|
||||
- **Run / Stop controls** — left pane Run / Stop buttons manage the generation loop; After Gen combo (loop / increment / fixed), ▶ Run, and ■ Stop widgets are also available directly on the WFS_GalleryFeeder node in the ComfyUI canvas (`gallery_feeder_extension.js`)
|
||||
|
||||
### Prompt Tab
|
||||
- **3-column layout** — AI Assistant (left), Presets/Preset Manager tab-panel (center), Wildcard support (right)
|
||||
- **AI chat assistant** — powered by [Ollama](https://ollama.com/), generate and refine prompts interactively
|
||||
@@ -138,21 +147,25 @@ Requires the **[comfyui-image-feeder](https://github.com/ketle-man/comfyui-image
|
||||
- **Wildcard Integration** — link the WFS wildcard directory to ComfyUI-Impact-Pack's `wildcards/` directory (directory junction on Windows, symlink on other OS); existing WFS wildcard files are automatically migrated; requires [ComfyUI-Impact-Pack](https://github.com/ltdrdata/ComfyUI-Impact-Pack)
|
||||
- **Language** — English / Japanese / Chinese
|
||||
|
||||
### Gallery Tab (v0.3.1)
|
||||
### Gallery Tab (v0.3.44)
|
||||
- **Image browser** — browse ComfyUI output images (Thumbnail / Table views) with server-side scanning optimized for 6,000+ image libraries
|
||||
- **Thumbnail / Table views** — switch view modes; Favorites column shown leftmost in Table view
|
||||
- **Folder management** — create subfolders ("+ New") or delete the selected folder with all contents ("Del") from the folder tree header
|
||||
- **File operations** — move or delete individual images from the detail panel's Info tab; bulk Move To... and Delete from the multi-select bar
|
||||
- **Multi-select** — Ctrl+click to select multiple images; Bulk Bar appears for batch operations (group, favorite, move, delete)
|
||||
- **File operations** — move or delete individual images from the detail panel's Info tab; bulk Move To..., Export, and Delete File from the multi-select bar
|
||||
- **Download** — hover over the image preview in the detail panel to reveal a download icon (⬇); click to download the single image
|
||||
- **Multi-select** — Ctrl+click to select multiple images; Bulk Bar appears for batch operations: select group → "Add to Group" / "Remove from Group"; Favorite All / Unfavorite All; Compare (2–4 images); Move To...; **Export** (downloads all selected images as a ZIP file); Delete File
|
||||
- **Image Compare** — select 2–4 images with Ctrl+click, then click "Compare" in the Bulk Bar to open a side-by-side lightbox; grid adapts to the number of selected images
|
||||
- **Prompt search** — text search covers filename, tags, memo, and prompt text (A1111 `parameters` field cached on first detail panel open)
|
||||
- **Server-side filtering** — filter by group, favorites, or tags with fast server-side set lookup (no full rescan)
|
||||
- **Group management** — create, rename, delete groups and assign/remove images using the same 4-section panel as Models tab
|
||||
- **Group management** — create, rename, delete groups and assign/remove images using the same 4-section panel as Models tab; **`__Feeder__`** is a reserved group (🔒 prefix) that cannot be renamed or deleted; used by the Feeder Gallery mode to define the generation queue; **FC** button in the toolbar clears all members without deleting the group
|
||||
- **Thumbnail F button** — cyan overlay button (top-left of each image card) toggles the image's membership in the `__Feeder__` group; cyan and always-visible when the image is in the group; visible on hover only when inactive
|
||||
- **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; **Copy & Send Canvas** button copies the JSON to the clipboard and stores it for title-drag to the ComfyUI canvas
|
||||
- **Workflow viewer** — Metadata tab displays workflow JSON from PNG embedded data (`prompt` / `workflow` keys) or from workflow saved by the Generate UI tab; **Copy & Send Canvas** button copies the JSON to the clipboard and sends the workflow directly to the ComfyUI canvas (UI and API formats both supported)
|
||||
- **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
|
||||
- **Performance** — server-side 256px JPEG thumbnail generation with disk cache (`data/thumb_cache/`); infinite-scroll paging (50 images per page, IntersectionObserver); folder-level mtime cache (60s TTL); bulk operations use single-request API endpoints
|
||||
|
||||
### Nodes Tab (v0.1.7)
|
||||
- **Node Browser** — browse all installed ComfyUI nodes from `/object_info` API with Card/Table views
|
||||
@@ -222,7 +235,7 @@ Requires the **[comfyui-image-feeder](https://github.com/ketle-man/comfyui-image
|
||||
- **Drag & drop workflows** — drag a workflow onto the canvas to load it
|
||||
- **Drag & drop nodes** — drag nodes/node sets onto the canvas to place them
|
||||
- **Drag & drop prompts** — drag a preset onto the canvas to create a WFS_PromptText node with positive/negative prompts
|
||||
- **Title drag (Send to Canvas)** — after clicking "Send to Canvas" (Workflow tab toolbar / detail modal) or "Copy & Send Canvas" (Gallery tab JSON panel), the "Workflow Studio Library" title highlights blue with a green ● indicator; drag the title onto the canvas to load the stored workflow; title resets automatically after loading
|
||||
- **Send to Canvas** — clicking "Send to Canvas" (Workflow tab toolbar / detail modal) or "Copy & Send Canvas" (Gallery tab JSON panel) sends the workflow directly to the ComfyUI canvas via `window.opener` (UI and API formats both supported); if Workflow Studio was opened from a bookmark instead of the ComfyUI toolbar, UI-format workflows fall back to title drag (panel title highlights blue with a green ● — drag it onto the canvas to load)
|
||||
- **Copy prompts** — copy individual positive (P) or negative (N) prompts from sidebar items
|
||||
- **Double-click** — load workflows or place nodes without dragging
|
||||
- **Search** — search within each sub-tab to quickly find items
|
||||
@@ -321,6 +334,48 @@ Click the **camera icon** (next to the W button) in ComfyUI's top bar to capture
|
||||
|
||||
## Changelog
|
||||
|
||||
### v0.3.47
|
||||
- **Models tab — fix stale group state after file move** — when models were moved to a subdirectory via "Move To...", `state.modelGroups` in the JS client was not updated to reflect the new model paths; the group filter view would lose the moved models immediately after the operation. Now the client-side group membership is updated in sync with the server-side rename (mirrors the existing Python `move_models` logic). Generate tab Batch groups are unaffected as they always fetch fresh from the server.
|
||||
|
||||
### v0.3.46
|
||||
- **Prompt tab AI Assistant — LM Studio support** — switched from Python proxy (`/api/wfm/ollama/*`) to direct browser-to-backend API calls (same pattern as the AI TOOL tab); supports Ollama (`/api/chat`) and LM Studio (`/v1/chat/completions`); image attachments are automatically converted to the correct format per backend
|
||||
- **Settings tab — AI Assistant Settings (Prompt Tab)** — renamed from "Ollama Settings"; added backend selector (Ollama / LM Studio), URL input with per-backend placeholder, model select with Refresh, and Test button; settings saved to localStorage `wfm_prompt_ai_settings` (independent of AI TOOL tab settings)
|
||||
- **Auto-refresh on backend change** — if the backend is switched in Settings tab while Prompt tab is already open, `sendMessage()` now detects the mismatch and automatically re-fetches the model list before sending; model status shows the active backend name (`[ollama]` / `[lmstudio]`)
|
||||
- **Help text updated** (EN/JA/ZH) — Prompt tab, Settings tab, and Troubleshooting sections updated to reflect Ollama / LM Studio dual-backend support
|
||||
|
||||
### v0.3.45
|
||||
- **Group auto-cleanup — Models tab** — stale group entries (models that no longer exist on disk) are automatically removed when the Models tab is loaded or the model type is switched; models moved within the app via "Move To..." also update their group membership immediately
|
||||
- **Group auto-cleanup — Gallery tab (folder view)** — metadata entries for missing files are cleaned up each time a folder is scanned (`list_images`), synchronized with the 60s TTL + folder-mtime cache
|
||||
- **Group auto-cleanup — Gallery tab (group image list)** — `list_images_in_group` (used by the Feeder tab Gallery mode) now filters out non-existent paths and removes them from the group in a single write operation
|
||||
- **Gallery tab — Shift+click range selection** — Shift+click selects all images between the last clicked item (anchor) and the current item; works in both thumbnail and table views; anchor is updated on Ctrl+click and regular click; resets on folder change, image reload, and Deselect All; help text updated (EN/JA/ZH)
|
||||
|
||||
### v0.3.44
|
||||
- **Gallery tab — server-side thumbnail generation** — `GET /wfm/gallery/image/thumb?path=...&w=256` endpoint generates 256px JPEG thumbnails via Pillow and caches them to `data/thumb_cache/` keyed by `md5(path:mtime:width)`; GIF served as-is to preserve animation; falls back to the original file if Pillow is unavailable; thumbnail view and table view both switched from `/image/serve` to `/image/thumb`
|
||||
- **Gallery tab — infinite-scroll paging** — thumbnail view renders 50 images initially; an IntersectionObserver sentinel (rootMargin 300px) appends the next page on scroll; sentinel is disconnected and removed when all images are rendered; paging resets on every `renderImages()` call (folder change, filter, sort)
|
||||
- **Gallery tab — bulk API endpoints** — `POST /wfm/gallery/bulk/favorite` and `POST /wfm/gallery/bulk/group` handle favorite set and group add/remove for any number of images in a single request; replaced N-parallel individual fetches in `bulkSetFavorite()` and `bulkAddToGroup()`
|
||||
- **Gallery tab — image compare mode** — Ctrl+click 2–4 images, then click "Compare" in the Bulk Bar to open a side-by-side lightbox; CSS grid adapts to the image count via `--compare-cols` custom property; close button is `position:fixed` at the top-right corner to avoid `overflow:auto` clipping
|
||||
- **Gallery tab — "Remove from Group" bulk button** — new button in the Bulk Bar (right of "Add to Group"); uses the same group selector dropdown; calls `POST /wfm/gallery/bulk/group` with `action:"remove"`
|
||||
- **Gallery tab — bulk bar UI labels** — dropdown placeholder "Add to Group..." → "Select Group"; "Add" button → "Add to Group"; "Delete" button → "Delete File" (distinguishes file deletion from group removal)
|
||||
- **Gallery tab — prompt search** — text search now covers A1111 `parameters` text embedded in PNG/JPEG metadata; prompt text is extracted on first detail-panel open and stored as `prompt_cache` in `metadata.json`; subsequent `list_images` searches include `prompt_cache` without re-reading image files
|
||||
- **Help tab — Gallery mode i18n** — Feeder subtab Gallery mode section (h4, description, 6 bullet points) now translated to Japanese and Chinese via `i18n.js`
|
||||
- **Help tab — font size ×1.5** — nav items, headings, body text, link cards, and support card text all scaled up in `main.css`
|
||||
- **Help tab — search box** — live search input above the nav sidebar filters matching pages and auto-clicks the first result; placeholder text localized (EN/JA/ZH)
|
||||
|
||||
### v0.3.43
|
||||
- **Send to Canvas — direct canvas load via `window.opener`** — clicking "Send to Canvas" (Workflow tab) or "Copy & Send Canvas" (Gallery tab) now sends the workflow directly to the ComfyUI canvas without requiring a title drag; uses `window.opener.wfmReceiveWorkflow()` registered by `node_sets_menu.js` via `app.handleFile()`; both UI and API formats are supported; fallback to localStorage + title drag when `window.opener` is unavailable (e.g. opened from a bookmark), UI-format only
|
||||
- **Workflow Studio Library — API-format DnD enabled** — API-format workflows in the W (Workflows) sub-tab are no longer grayed out; drag & drop and double-click now work for all formats via `app.handleFile()`
|
||||
|
||||
### v0.3.42
|
||||
- **Feeder tab — Gallery mode** — new [Image Loop] / [Gallery] toggle in the Feeder tab; Gallery mode drives a WFS_GalleryFeeder node without any external plugin: node selector, group select, sort mode / index / seed, After Gen (Loop / Increment / Fixed), Run / Stop; center pane shows the selected group's images — click any image to jump to that index; `__Feeder__` group is auto-created on first open
|
||||
- **WFS_GalleryFeeder custom node** — new ComfyUI node (Workflow Studio category) that reads images from a Gallery group and outputs one `IMAGE` at a time; inputs: `group_name`, `index`, `sort_mode` (filename_asc / filename_desc / random), `seed`; skips missing files; `IS_CHANGED` ensures re-execution on every queue
|
||||
- **WFS_GalleryFeeder — ComfyUI canvas controls** — `gallery_feeder_extension.js` adds After Gen combo (loop / increment / fixed), ▶ Run button, and ■ Stop button as non-serialized widgets directly on the node in the ComfyUI canvas; manages per-node loop state with `waitForExecution()` Promise pattern; `onRemoved` hook auto-stops the loop on node deletion
|
||||
- **Gallery tab — thumbnail F button** — cyan overlay button (top-left of each image card) toggles `__Feeder__` group membership; active state is always visible in cyan, inactive shows only on hover; initial state derived from `img.groups` returned by `list_images()`
|
||||
- **Gallery tab — `__Feeder__` reserved group** — shown with 🔒 prefix in group dropdowns; rename and delete blocked server-side (403) and client-side (buttons disabled); **FC** toolbar button clears all group members without deleting the group
|
||||
- **Security: XSS fixes in `gallery-tab.js`** — tag names, filenames, and server error messages now escaped via `escapeHtml()` before insertion into `innerHTML` (tag badge list, detail panel `alt` attributes, lightbox footer, folder tree errors, grid errors); `util.js` `escapeHtml` updated to also escape single quotes (`'` → `'`)
|
||||
- **Security: path validation in `gallery_service.py`** — `save_image_meta`, `toggle_favorite`, `add_to_group`, `remove_from_group` now call `_check_path_allowed()` before any file operation; previously these four methods were missing the guard that other write methods already had
|
||||
- **Security: `_init_allowed_root()` in `gallery_routes.py`** — `_allowed_root` is now initialized at module load from saved `gallery_output_dir` (falls back to ComfyUI default output dir); prevents `list_folder_tree` from overriding `_allowed_root` via a crafted `?root=` request, and also fixes serve_image returning 404 in Feeder Gallery mode before the Gallery tab is opened
|
||||
- **Bug fix: WFS_GalleryFeeder seed validation error** — seed `max` changed from `0x7FFFFFFF` to `0xffffffffffffffff` (matching KSampler); `applySeedToWorkflow()` was writing values exceeding the old max, causing `value_bigger_than_max` validation failures
|
||||
|
||||
### v0.3.41
|
||||
- **Generate UI — ImpactWildcardEncode / ImpactWildcardProcessor prompt detection** — fixed: wildcard text inputs from comfy-impact-pack nodes were not shown in the Prompt tab of Generate UI
|
||||
- `CLIPTextEncodeEditPlus` node (used as the text encoder in these workflows) now correctly propagates positive/negative roles upstream to ImpactWildcard nodes via BFS
|
||||
@@ -655,7 +710,8 @@ ComfyUI-Workflow-Studio/
|
||||
│ ├── wfm.py # Main class & route registration
|
||||
│ ├── config.py # Path configuration
|
||||
│ ├── nodes/
|
||||
│ │ └── prompt_text.py # WFS_PromptText custom node (positive/negative prompt)
|
||||
│ │ ├── prompt_text.py # WFS_PromptText custom node (positive/negative prompt)
|
||||
│ │ └── gallery_feeder_node.py # WFS_GalleryFeeder custom node (gallery group → IMAGE)
|
||||
│ ├── routes/
|
||||
│ │ ├── workflow_routes.py # Workflow CRUD & analysis API
|
||||
│ │ ├── nodes_routes.py # Nodes metadata & node sets API
|
||||
@@ -682,21 +738,25 @@ ComfyUI-Workflow-Studio/
|
||||
│ ├── app.js # App initialization & routing
|
||||
│ ├── workflow-tab.js # Workflow browser
|
||||
│ ├── generate-tab.js # Generation UI
|
||||
│ ├── feeder-tab.js # Feeder subtab (ImageFeeder node control + image library)
|
||||
│ ├── feeder-tab.js # Feeder subtab (Image Loop + Gallery modes)
|
||||
│ ├── gallery-tab.js # Gallery tab (image browser, groups, metadata)
|
||||
│ ├── tagger-tab.js # Tagger tab (WD Tagger, DeepDanbooru, Ollama VLM)
|
||||
│ ├── prompt-tab.js # AI assistant & presets
|
||||
│ ├── metadata-tab.js # Metadata extraction & display (PNG/WebP/JSON)
|
||||
│ ├── settings-tab.js # Settings panel
|
||||
│ ├── comfyui-client.js # ComfyUI WebSocket/API client
|
||||
│ ├── nodes-tab.js # Node browser & node sets
|
||||
│ ├── models-tab.js # Model browser & CivitAI integration
|
||||
│ ├── ai-tab.js # AI TOOL tab (Translation | TOOLS/VLM | Settings — Ollama / LM Studio)
|
||||
│ ├── ai-tab.js # AI TOOL tab (Translation | Chat | TOOLS/VLM | Settings)
|
||||
│ ├── comfyui-workflow.js # UI-to-API format conversion
|
||||
│ ├── comfyui-editor.js # Dynamic parameter editor
|
||||
│ ├── json-highlight.js # JSON syntax highlighting
|
||||
│ ├── util.js # Shared utilities (escapeHtml, readJsonStorage, getSettings)
|
||||
│ └── i18n.js # Internationalization
|
||||
├── web/comfyui/
|
||||
│ ├── top_menu_extension.js # ComfyUI menu bar integration
|
||||
│ └── node_sets_menu.js # Workflow Studio Library side panel
|
||||
│ ├── node_sets_menu.js # Workflow Studio Library side panel
|
||||
│ └── gallery_feeder_extension.js # WFS_GalleryFeeder canvas widgets (After Gen / Run / Stop)
|
||||
└── data/ # Fallback data dir (used when ComfyUI user/default/ is not found)
|
||||
```
|
||||
|
||||
@@ -715,3 +775,6 @@ MIT License
|
||||
- [ComfyUI-Lora-Manager](https://github.com/willmiao/ComfyUI-Lora-Manager) — Plugin architecture and UI pattern reference
|
||||
- [Ollama](https://ollama.com/) for local LLM inference
|
||||
- [Eagle](https://eagle.cool/) for image management
|
||||
- [Pillow (PIL Fork)](https://python-pillow.org/) — server-side thumbnail generation (`data/thumb_cache/`)
|
||||
- [ComfyUI-Gallery](https://github.com/PanicTitan/ComfyUI-Gallery) by PanicTitan — thumbnail grid UX reference
|
||||
- [infinite-image-browsing](https://github.com/zanllp/sd-webui-infinite-image-browsing) by zanllp — thumbnail caching and index strategy reference
|
||||
|
||||
+4
-3
@@ -9,15 +9,16 @@ WorkflowStudio.add_routes()
|
||||
|
||||
# Register custom nodes (isolated loading)
|
||||
_NODE_MODULES = {
|
||||
"WFS_PromptText": (".py.nodes.prompt_text", "WFS_PromptText"),
|
||||
"WFS_PromptText": (".py.nodes.prompt_text", "WFS_PromptText", "Prompt Text (WFS)"),
|
||||
"WFS_GalleryFeeder": (".py.nodes.gallery_feeder_node", "WFS_GalleryFeeder", "Gallery Feeder (WFS)"),
|
||||
}
|
||||
|
||||
for _name, (_mod_path, _cls_name) in _NODE_MODULES.items():
|
||||
for _name, (_mod_path, _cls_name, _display_name) in _NODE_MODULES.items():
|
||||
try:
|
||||
import importlib
|
||||
_mod = importlib.import_module(_mod_path, package=__name__)
|
||||
NODE_CLASS_MAPPINGS[_name] = getattr(_mod, _cls_name)
|
||||
NODE_DISPLAY_NAME_MAPPINGS[_name] = "Prompt Text (WFS)"
|
||||
NODE_DISPLAY_NAME_MAPPINGS[_name] = _display_name
|
||||
except Exception as _e:
|
||||
print(f"[WARNING] Workflow Studio: Failed to load '{_name}': {_e}")
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
"""WFS_GalleryFeeder – Feeds images from a gallery group into a workflow."""
|
||||
import json
|
||||
import random
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Feeder専用グループ名(gallery_metadata.json 内で予約される)
|
||||
FEEDER_GROUP = "__Feeder__"
|
||||
|
||||
|
||||
class WFS_GalleryFeeder:
|
||||
"""Gallery グループ内の画像をインデックス順に1枚ずつ出力するノード。"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"group_name": ("STRING", {"default": FEEDER_GROUP}),
|
||||
"index": ("INT", {"default": 0, "min": 0, "max": 99999}),
|
||||
"sort_mode": (["filename_asc", "filename_desc", "random"],),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("image",)
|
||||
FUNCTION = "execute"
|
||||
CATEGORY = "Workflow Studio"
|
||||
OUTPUT_NODE = False
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, **kwargs):
|
||||
# 毎回実行させる(インデックスが変わるため)
|
||||
return float("NaN")
|
||||
|
||||
def execute(self, group_name: str, index: int, sort_mode: str, seed: int):
|
||||
import torch
|
||||
import numpy as np
|
||||
from PIL import Image as PILImage
|
||||
|
||||
paths = self._get_sorted_paths(group_name, sort_mode, seed)
|
||||
if not paths:
|
||||
logger.warning("WFS_GalleryFeeder: group '%s' is empty or not found", group_name)
|
||||
return (torch.zeros(1, 64, 64, 3),)
|
||||
|
||||
img_path = paths[index % len(paths)]
|
||||
try:
|
||||
img = PILImage.open(img_path).convert("RGB")
|
||||
except Exception as e:
|
||||
logger.error("WFS_GalleryFeeder: failed to load '%s': %s", img_path, e)
|
||||
return (torch.zeros(1, 64, 64, 3),)
|
||||
|
||||
arr = np.array(img, dtype=np.float32) / 255.0
|
||||
tensor = torch.from_numpy(arr).unsqueeze(0)
|
||||
return (tensor,)
|
||||
|
||||
# ── 内部ヘルパー ──────────────────────────────────────────────
|
||||
|
||||
def _get_sorted_paths(self, group_name: str, sort_mode: str, seed: int) -> list[str]:
|
||||
metadata_file = self._find_metadata_file()
|
||||
if not metadata_file.exists():
|
||||
return []
|
||||
try:
|
||||
with open(metadata_file, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
except Exception as e:
|
||||
logger.error("WFS_GalleryFeeder: metadata read error: %s", e)
|
||||
return []
|
||||
|
||||
paths = [
|
||||
key for key, meta in data.get("images", {}).items()
|
||||
if group_name in meta.get("groups", []) and Path(key).exists()
|
||||
]
|
||||
|
||||
if sort_mode == "filename_asc":
|
||||
paths.sort(key=lambda p: Path(p).name.lower())
|
||||
elif sort_mode == "filename_desc":
|
||||
paths.sort(key=lambda p: Path(p).name.lower(), reverse=True)
|
||||
elif sort_mode == "random":
|
||||
rng = random.Random(seed)
|
||||
rng.shuffle(paths)
|
||||
|
||||
return paths
|
||||
|
||||
@staticmethod
|
||||
def _find_metadata_file() -> Path:
|
||||
# py/nodes/ -> py/ -> plugin root -> ComfyUI/custom_nodes/ -> ComfyUI root
|
||||
plugin_root = Path(__file__).resolve().parent.parent.parent
|
||||
comfyui_root = plugin_root.parent.parent
|
||||
user_default = comfyui_root / "user" / "default"
|
||||
if user_default.is_dir():
|
||||
return user_default / "Workflow-Studio" / "gallery_metadata.json"
|
||||
return plugin_root / "data" / "gallery_metadata.json"
|
||||
@@ -15,26 +15,62 @@ logger = logging.getLogger(__name__)
|
||||
_service = GalleryService(DATA_DIR)
|
||||
|
||||
|
||||
def _init_allowed_root() -> None:
|
||||
"""起動時に保存済みの出力ディレクトリで _allowed_root を初期化する。
|
||||
Gallery タブを開く前に Feeder タブの Gallery モードが serve_image を呼んでも
|
||||
404 にならないようにするために必要。"""
|
||||
try:
|
||||
settings_file = DATA_DIR / "settings.json"
|
||||
if settings_file.exists():
|
||||
with open(settings_file, "r", encoding="utf-8") as f:
|
||||
settings = json.load(f)
|
||||
saved_root = settings.get("gallery_output_dir", "").strip()
|
||||
if saved_root and Path(saved_root).is_dir():
|
||||
_service.update_output_root(saved_root)
|
||||
return
|
||||
except Exception as e:
|
||||
logger.warning("GalleryRoutes: failed to load saved gallery root: %s", e)
|
||||
|
||||
# フォールバック: ComfyUI のデフォルト output フォルダ
|
||||
try:
|
||||
import folder_paths # type: ignore
|
||||
output_dir = folder_paths.get_output_directory()
|
||||
if output_dir and Path(output_dir).is_dir():
|
||||
_service.update_output_root(output_dir)
|
||||
except Exception as e:
|
||||
logger.warning("GalleryRoutes: failed to get ComfyUI output dir: %s", e)
|
||||
|
||||
|
||||
_init_allowed_root()
|
||||
|
||||
|
||||
def setup_routes(app: web.Application):
|
||||
app.router.add_get("/wfm/gallery/folders", list_folders)
|
||||
app.router.add_get("/wfm/gallery/images", list_images)
|
||||
app.router.add_get("/wfm/gallery/image/meta", get_image_meta)
|
||||
app.router.add_get("/wfm/gallery/image/workflow", get_image_workflow)
|
||||
app.router.add_get("/wfm/gallery/image/serve", serve_image)
|
||||
app.router.add_get("/wfm/gallery/image/thumb", serve_thumb)
|
||||
app.router.add_post("/wfm/gallery/image/meta", save_image_meta)
|
||||
app.router.add_post("/wfm/gallery/image/favorite", toggle_favorite)
|
||||
app.router.add_get("/wfm/gallery/groups", list_groups)
|
||||
app.router.add_post("/wfm/gallery/groups", create_group)
|
||||
app.router.add_put("/wfm/gallery/groups/{name}", rename_group)
|
||||
app.router.add_delete("/wfm/gallery/groups/{name}", delete_group)
|
||||
app.router.add_post("/wfm/gallery/groups/ensure", ensure_group)
|
||||
app.router.add_post("/wfm/gallery/groups/{name}/add", add_to_group)
|
||||
app.router.add_post("/wfm/gallery/groups/{name}/remove", remove_from_group)
|
||||
app.router.add_post("/wfm/gallery/groups/{name}/clear", clear_group_images)
|
||||
app.router.add_get("/wfm/gallery/groups/{name}/images", list_group_images)
|
||||
# バルク操作
|
||||
app.router.add_post("/wfm/gallery/bulk/favorite", bulk_favorite)
|
||||
app.router.add_post("/wfm/gallery/bulk/group", bulk_group)
|
||||
# フォルダ・ファイル操作
|
||||
app.router.add_post("/wfm/gallery/folder", create_folder_route)
|
||||
app.router.add_delete("/wfm/gallery/folder", delete_folder_route)
|
||||
app.router.add_post("/wfm/gallery/images/delete", delete_images_route)
|
||||
app.router.add_post("/wfm/gallery/images/move", move_images_route)
|
||||
app.router.add_post("/wfm/gallery/images/export-zip", export_images_zip)
|
||||
|
||||
|
||||
# ──────────────────────────────────────────────────────────────
|
||||
@@ -127,6 +163,70 @@ async def serve_image(request: web.Request) -> web.Response:
|
||||
})
|
||||
|
||||
|
||||
async def serve_thumb(request: web.Request) -> web.Response:
|
||||
"""サムネイル配信。Pillowで縮小したJPEGをディスクキャッシュして返す。"""
|
||||
path = request.rel_url.query.get("path", "")
|
||||
if not path:
|
||||
return web.Response(status=400)
|
||||
try:
|
||||
width = int(request.rel_url.query.get("w", "256"))
|
||||
width = max(32, min(512, width))
|
||||
except ValueError:
|
||||
width = 256
|
||||
|
||||
thumb_path = _service.serve_thumbnail(path, width)
|
||||
if thumb_path is None:
|
||||
return web.Response(status=404)
|
||||
|
||||
ext = thumb_path.suffix.lower()
|
||||
if ext in (".jpg", ".jpeg"):
|
||||
content_type = "image/jpeg"
|
||||
elif ext == ".gif":
|
||||
content_type = "image/gif"
|
||||
else:
|
||||
content_type = mimetypes.guess_type(str(thumb_path))[0] or "image/jpeg"
|
||||
|
||||
return web.FileResponse(thumb_path, headers={
|
||||
"Content-Type": content_type,
|
||||
"Cache-Control": "max-age=86400",
|
||||
})
|
||||
|
||||
|
||||
# ──────────────────────────────────────────────────────────────
|
||||
# バルク操作
|
||||
# ──────────────────────────────────────────────────────────────
|
||||
|
||||
async def bulk_favorite(request: web.Request) -> web.Response:
|
||||
"""POST /wfm/gallery/bulk/favorite — 複数画像のお気に入りを一括設定"""
|
||||
try:
|
||||
body = await request.json()
|
||||
paths = body.get("paths", [])
|
||||
value = bool(body.get("value", True))
|
||||
if not paths:
|
||||
return web.json_response({"error": "paths required"}, status=400)
|
||||
result = _service.bulk_set_favorite(paths, value)
|
||||
return web.json_response(result)
|
||||
except Exception as e:
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
|
||||
|
||||
async def bulk_group(request: web.Request) -> web.Response:
|
||||
"""POST /wfm/gallery/bulk/group — 複数画像のグループ追加/削除を一括処理"""
|
||||
try:
|
||||
body = await request.json()
|
||||
paths = body.get("paths", [])
|
||||
group = body.get("group", "").strip()
|
||||
action = body.get("action", "add") # "add" or "remove"
|
||||
if not paths or not group:
|
||||
return web.json_response({"error": "paths and group required"}, status=400)
|
||||
if action not in ("add", "remove"):
|
||||
return web.json_response({"error": "action must be 'add' or 'remove'"}, status=400)
|
||||
result = _service.bulk_group_op(paths, group, action)
|
||||
return web.json_response(result)
|
||||
except Exception as e:
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
|
||||
|
||||
async def save_image_meta(request: web.Request) -> web.Response:
|
||||
try:
|
||||
body = await request.json()
|
||||
@@ -174,10 +274,15 @@ async def create_group(request: web.Request) -> web.Response:
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
|
||||
|
||||
_RESERVED_GROUPS = {"__Feeder__"}
|
||||
|
||||
|
||||
async def rename_group(request: web.Request) -> web.Response:
|
||||
"""PUT /wfm/gallery/groups/{name} - グループ名変更"""
|
||||
try:
|
||||
old_name = request.match_info.get("name", "")
|
||||
if old_name in _RESERVED_GROUPS:
|
||||
return web.json_response({"error": f"Group '{old_name}' is reserved and cannot be renamed"}, status=403)
|
||||
body = await request.json()
|
||||
new_name = body.get("new_name", "").strip()
|
||||
if not old_name or not new_name:
|
||||
@@ -192,6 +297,8 @@ async def rename_group(request: web.Request) -> web.Response:
|
||||
|
||||
async def delete_group(request: web.Request) -> web.Response:
|
||||
name = request.match_info.get("name", "")
|
||||
if name in _RESERVED_GROUPS:
|
||||
return web.json_response({"error": f"Group '{name}' is reserved and cannot be deleted"}, status=403)
|
||||
ok = _service.delete_group(name)
|
||||
return web.json_response({"ok": ok})
|
||||
|
||||
@@ -224,6 +331,28 @@ async def list_group_images(request: web.Request) -> web.Response:
|
||||
return web.json_response({"images": images})
|
||||
|
||||
|
||||
async def clear_group_images(request: web.Request) -> web.Response:
|
||||
"""POST /wfm/gallery/groups/{name}/clear - グループ内の全画像を除外"""
|
||||
name = request.match_info.get("name", "")
|
||||
if not name:
|
||||
return web.json_response({"error": "name required"}, status=400)
|
||||
ok = _service.clear_group(name)
|
||||
return web.json_response({"ok": ok})
|
||||
|
||||
|
||||
async def ensure_group(request: web.Request) -> web.Response:
|
||||
"""POST /wfm/gallery/groups/ensure - グループが存在しない場合のみ作成"""
|
||||
try:
|
||||
body = await request.json()
|
||||
name = body.get("name", "").strip()
|
||||
if not name:
|
||||
return web.json_response({"error": "name required"}, status=400)
|
||||
_service.ensure_group(name)
|
||||
return web.json_response({"ok": True})
|
||||
except Exception as e:
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
|
||||
|
||||
# ──────────────────────────────────────────────────────────────
|
||||
# フォルダ・ファイル操作
|
||||
# ──────────────────────────────────────────────────────────────
|
||||
@@ -280,3 +409,37 @@ async def move_images_route(request: web.Request) -> web.Response:
|
||||
return web.json_response(result)
|
||||
except Exception as e:
|
||||
return web.json_response({"moved": [], "errors": [str(e)]}, status=500)
|
||||
|
||||
|
||||
async def export_images_zip(request: web.Request) -> web.Response:
|
||||
"""POST /wfm/gallery/images/export-zip - 複数画像をZIPファイルにしてダウンロード"""
|
||||
import zipfile
|
||||
import io
|
||||
|
||||
try:
|
||||
body = await request.json()
|
||||
paths = body.get("paths", [])
|
||||
if not paths:
|
||||
return web.json_response({"error": "paths required"}, status=400)
|
||||
|
||||
# ZIPファイルをメモリ上に作成
|
||||
zip_buffer = io.BytesIO()
|
||||
with zipfile.ZipFile(zip_buffer, "w", zipfile.ZIP_DEFLATED) as zf:
|
||||
for path in paths:
|
||||
file_path = Path(path)
|
||||
# セキュリティ: 許可されたディレクトリ内のみ
|
||||
if not _service._check_path_allowed(file_path):
|
||||
continue
|
||||
if file_path.exists() and file_path.is_file():
|
||||
# ファイル名のみをアーカイブに入れる(パス情報は含めない)
|
||||
zf.write(file_path, arcname=file_path.name)
|
||||
|
||||
zip_buffer.seek(0)
|
||||
return web.Response(
|
||||
body=zip_buffer.getvalue(),
|
||||
content_type="application/zip",
|
||||
headers={"Content-Disposition": "attachment; filename=gallery_export.zip"}
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error("Error exporting images to ZIP: %s", e)
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
|
||||
@@ -117,6 +117,18 @@ class GalleryMetadataStore:
|
||||
result.append(key)
|
||||
return result
|
||||
|
||||
def remove_stale_paths_from_group(self, group_name: str, stale_paths: list) -> int:
|
||||
"""存在しないパスをグループから一括削除する(1回の保存で完結)"""
|
||||
stale_set = {self._normalize_path(p) for p in stale_paths}
|
||||
count = 0
|
||||
for key, meta in self._data["images"].items():
|
||||
if key in stale_set and group_name in meta.get("groups", []):
|
||||
meta["groups"] = [g for g in meta["groups"] if g != group_name]
|
||||
count += 1
|
||||
if count:
|
||||
self._save_to_disk()
|
||||
return count
|
||||
|
||||
def get_group_member_set(self, group_name: str) -> set:
|
||||
"""グループメンバーのパスをsetで返す(高速フィルタ用)"""
|
||||
return {
|
||||
@@ -124,6 +136,19 @@ class GalleryMetadataStore:
|
||||
if group_name in meta.get("groups", [])
|
||||
}
|
||||
|
||||
def clear_group(self, group_name: str) -> bool:
|
||||
"""グループ内の全画像を除外する(グループ自体は残す)"""
|
||||
for meta in self._data["images"].values():
|
||||
if group_name in meta.get("groups", []):
|
||||
meta["groups"] = [g for g in meta["groups"] if g != group_name]
|
||||
return self._save_to_disk()
|
||||
|
||||
def ensure_group(self, name: str) -> bool:
|
||||
"""グループが存在しない場合のみ作成する"""
|
||||
if any(g["name"] == name for g in self._data.get("groups", [])):
|
||||
return True
|
||||
return self.create_group(name)
|
||||
|
||||
def delete(self, image_path: str) -> bool:
|
||||
"""画像のメタデータエントリを削除する"""
|
||||
key = self._normalize_path(image_path)
|
||||
@@ -140,3 +165,22 @@ class GalleryMetadataStore:
|
||||
self._data["images"][new_key] = self._data["images"].pop(old_key)
|
||||
return self._save_to_disk()
|
||||
return True
|
||||
|
||||
def cleanup_stale_images(self, folder_path: str, existing_paths: set) -> int:
|
||||
"""folder_path 配下の存在しないファイルのメタデータを削除する。
|
||||
existing_paths: そのフォルダの現在のファイルパス集合(_normalize_path 済み)
|
||||
"""
|
||||
folder_key = self._normalize_path(folder_path)
|
||||
if not folder_key.endswith("/"):
|
||||
folder_key += "/"
|
||||
stale = [
|
||||
key for key in self._data["images"]
|
||||
if key.startswith(folder_key) and key not in existing_paths
|
||||
]
|
||||
if not stale:
|
||||
return 0
|
||||
for key in stale:
|
||||
del self._data["images"][key]
|
||||
self._save_to_disk()
|
||||
logger.info("Cleaned up %d stale metadata entries from %s", len(stale), folder_path)
|
||||
return len(stale)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Gallery Service - outputフォルダの画像管理、メタデータ閲覧
|
||||
"""
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
import mimetypes
|
||||
@@ -26,7 +27,7 @@ _PNG_CHUNK_MAX = 32 * 1024 * 1024
|
||||
_JPEG_READ_MAX = 64 * 1024 * 1024
|
||||
|
||||
# フォルダキャッシュのTTL秒(フォルダmtimeが同じでも念のため)
|
||||
_CACHE_TTL = 30.0
|
||||
_CACHE_TTL = 60.0
|
||||
|
||||
|
||||
class _FolderCache:
|
||||
@@ -187,6 +188,10 @@ class GalleryService:
|
||||
# os.scandir() でファイル情報を一括取得(stat()の個別呼び出しを排除)
|
||||
raw_entries = self._scan_folder(folder)
|
||||
|
||||
# 孤立メタデータを自動クリーンアップ(移動・削除されたファイルの残骸を除去)
|
||||
existing_paths = {abs_path for _, abs_path, _, _ in raw_entries}
|
||||
self.metadata_store.cleanup_stale_images(str(folder), existing_paths)
|
||||
|
||||
results = []
|
||||
for name, abs_path, size, mtime in raw_entries:
|
||||
# グループフィルタ(サーバーサイド)
|
||||
@@ -217,13 +222,14 @@ class GalleryService:
|
||||
"groups": meta.get("groups", []),
|
||||
}
|
||||
|
||||
# 検索フィルタ
|
||||
# 検索フィルタ(ファイル名・メモ・タグ・キャッシュ済みプロンプト)
|
||||
if search:
|
||||
s = search.lower()
|
||||
if not (
|
||||
s in name.lower()
|
||||
or s in item["memo"].lower()
|
||||
or any(s in t.lower() for t in tags)
|
||||
or s in meta.get("prompt_cache", "").lower()
|
||||
):
|
||||
continue
|
||||
|
||||
@@ -262,6 +268,14 @@ class GalleryService:
|
||||
|
||||
saved = self.metadata_store.get(str(path))
|
||||
|
||||
# workflow キーを除く文字列フィールドをプロンプトキャッシュとして保存(検索用)
|
||||
prompt_text = " ".join(
|
||||
str(v) for k, v in embedded.items()
|
||||
if k != "workflow" and isinstance(v, str) and len(v) < 50_000
|
||||
).strip()
|
||||
if prompt_text and prompt_text != saved.get("prompt_cache", ""):
|
||||
self.metadata_store.save(str(path), {"prompt_cache": prompt_text})
|
||||
|
||||
stat = path.stat()
|
||||
return {
|
||||
"filename": path.name,
|
||||
@@ -384,14 +398,42 @@ class GalleryService:
|
||||
# ──────────────────────────────────────────────────────────────
|
||||
|
||||
def save_image_meta(self, image_path: str, data: dict) -> bool:
|
||||
if not self._check_path_allowed(Path(image_path).resolve()):
|
||||
return False
|
||||
return self.metadata_store.save(image_path, data)
|
||||
|
||||
def toggle_favorite(self, image_path: str) -> bool:
|
||||
if not self._check_path_allowed(Path(image_path).resolve()):
|
||||
return False
|
||||
meta = self.metadata_store.get(image_path)
|
||||
new_val = not meta.get("favorite", False)
|
||||
self.metadata_store.save(image_path, {"favorite": new_val})
|
||||
return new_val
|
||||
|
||||
def bulk_set_favorite(self, paths: list[str], value: bool) -> dict:
|
||||
"""複数画像のお気に入りを一括設定する"""
|
||||
ok = fail = 0
|
||||
for p in paths:
|
||||
if not self._check_path_allowed(Path(p).resolve()):
|
||||
fail += 1
|
||||
continue
|
||||
if self.metadata_store.save(p, {"favorite": value}):
|
||||
ok += 1
|
||||
else:
|
||||
fail += 1
|
||||
return {"ok": ok, "fail": fail}
|
||||
|
||||
def bulk_group_op(self, paths: list[str], group_name: str, action: str = "add") -> dict:
|
||||
"""複数画像のグループ追加 / 削除を一括処理する。action は "add" または "remove"。"""
|
||||
ok = fail = 0
|
||||
for p in paths:
|
||||
success = self.add_to_group(p, group_name) if action == "add" else self.remove_from_group(p, group_name)
|
||||
if success:
|
||||
ok += 1
|
||||
else:
|
||||
fail += 1
|
||||
return {"ok": ok, "fail": fail}
|
||||
|
||||
# ──────────────────────────────────────────────────────────────
|
||||
# グループ管理
|
||||
# ──────────────────────────────────────────────────────────────
|
||||
@@ -409,6 +451,8 @@ class GalleryService:
|
||||
return self.metadata_store.delete_group(name)
|
||||
|
||||
def add_to_group(self, image_path: str, group_name: str) -> bool:
|
||||
if not self._check_path_allowed(Path(image_path).resolve()):
|
||||
return False
|
||||
meta = self.metadata_store.get(image_path)
|
||||
groups = meta.get("groups", [])
|
||||
if group_name not in groups:
|
||||
@@ -417,12 +461,26 @@ class GalleryService:
|
||||
return True
|
||||
|
||||
def remove_from_group(self, image_path: str, group_name: str) -> bool:
|
||||
if not self._check_path_allowed(Path(image_path).resolve()):
|
||||
return False
|
||||
meta = self.metadata_store.get(image_path)
|
||||
groups = [g for g in meta.get("groups", []) if g != group_name]
|
||||
return self.metadata_store.save(image_path, {"groups": groups})
|
||||
|
||||
def list_images_in_group(self, group_name: str) -> list[str]:
|
||||
return self.metadata_store.list_images_in_group(group_name)
|
||||
all_paths = self.metadata_store.list_images_in_group(group_name)
|
||||
existing = [p for p in all_paths if Path(p).is_file()]
|
||||
stale = [p for p in all_paths if not Path(p).is_file()]
|
||||
if stale:
|
||||
self.metadata_store.remove_stale_paths_from_group(group_name, stale)
|
||||
logger.info("Cleaned up %d stale paths from group '%s'", len(stale), group_name)
|
||||
return existing
|
||||
|
||||
def clear_group(self, group_name: str) -> bool:
|
||||
return self.metadata_store.clear_group(group_name)
|
||||
|
||||
def ensure_group(self, name: str) -> bool:
|
||||
return self.metadata_store.ensure_group(name)
|
||||
|
||||
# ──────────────────────────────────────────────────────────────
|
||||
# 画像配信
|
||||
@@ -539,3 +597,46 @@ class GalleryService:
|
||||
logger.warning("serve_image: path not allowed: %s", p)
|
||||
return None
|
||||
return p
|
||||
|
||||
def serve_thumbnail(self, image_path: str, width: int = 256) -> Path | None:
|
||||
"""縮小サムネイルのPathを返す。
|
||||
ディスクキャッシュがあればそれを返し、なければPillowで生成して保存する。
|
||||
GIFはアニメーション保持のため元ファイルをそのまま返す。
|
||||
Pillowが使えない場合は元ファイルにフォールバック。
|
||||
"""
|
||||
p = Path(image_path).resolve()
|
||||
if not p.is_file():
|
||||
return None
|
||||
if p.suffix.lower() not in IMAGE_EXTENSIONS:
|
||||
return None
|
||||
if not self._check_path_allowed(p):
|
||||
logger.warning("serve_thumbnail: path not allowed: %s", p)
|
||||
return None
|
||||
|
||||
# GIF はアニメーション保持のためそのまま返す
|
||||
if p.suffix.lower() == ".gif":
|
||||
return p
|
||||
|
||||
try:
|
||||
mtime = int(p.stat().st_mtime * 1000)
|
||||
except OSError:
|
||||
return None
|
||||
|
||||
cache_key = hashlib.md5(f"{p}:{mtime}:{width}".encode()).hexdigest()
|
||||
cache_dir = self.data_dir / "thumb_cache"
|
||||
cache_dir.mkdir(exist_ok=True)
|
||||
thumb_path = cache_dir / f"{cache_key}.jpg"
|
||||
|
||||
if thumb_path.exists():
|
||||
return thumb_path
|
||||
|
||||
try:
|
||||
from PIL import Image
|
||||
with Image.open(p) as img:
|
||||
img = img.convert("RGB")
|
||||
img.thumbnail((width, width), Image.LANCZOS)
|
||||
img.save(thumb_path, "JPEG", quality=85, optimize=True)
|
||||
return thumb_path
|
||||
except Exception as e:
|
||||
logger.warning("serve_thumbnail: failed for %s: %s", p, e)
|
||||
return p # フォールバック: 元ファイル
|
||||
|
||||
@@ -110,6 +110,25 @@ class ModelsService:
|
||||
self._save_metadata(data)
|
||||
return entry
|
||||
|
||||
def _scan_model_names(self, model_type: str) -> set:
|
||||
"""モデルタイプの全ファイル名をスキャンして返す(相対パス、/区切り、.disabled除く)"""
|
||||
dirs = _get_model_dirs(model_type)
|
||||
names = set()
|
||||
for d in dirs:
|
||||
if not d.is_dir():
|
||||
continue
|
||||
for f in d.rglob("*"):
|
||||
if not f.is_file():
|
||||
continue
|
||||
try:
|
||||
rel = str(f.relative_to(d)).replace("\\", "/")
|
||||
if rel.endswith(_DISABLED_SUFFIX):
|
||||
rel = rel[: -len(_DISABLED_SUFFIX)]
|
||||
names.add(rel)
|
||||
except ValueError:
|
||||
pass
|
||||
return names
|
||||
|
||||
def get_model_groups(self, model_type=None):
|
||||
data = self._load_metadata()
|
||||
raw = data.get("_groups", {})
|
||||
@@ -123,7 +142,23 @@ class ModelsService:
|
||||
raw = {}
|
||||
|
||||
if model_type:
|
||||
return raw.get(model_type, {})
|
||||
groups = raw.get(model_type, {})
|
||||
valid_names = self._scan_model_names(model_type)
|
||||
cleaned = {}
|
||||
dirty = False
|
||||
for g_name, members in groups.items():
|
||||
filtered = [m for m in members if m in valid_names]
|
||||
cleaned[g_name] = filtered
|
||||
if len(filtered) != len(members):
|
||||
dirty = True
|
||||
if dirty:
|
||||
removed = sum(len(groups[g]) - len(cleaned[g]) for g in groups)
|
||||
logger.info("Cleaned up %d stale group entries for model_type=%s", removed, model_type)
|
||||
if not isinstance(data.get("_groups"), dict):
|
||||
data["_groups"] = {}
|
||||
data["_groups"][model_type] = cleaned
|
||||
self._save_metadata(data)
|
||||
return cleaned
|
||||
return raw
|
||||
|
||||
def save_model_groups(self, groups, model_type):
|
||||
@@ -311,6 +346,7 @@ class ModelsService:
|
||||
|
||||
meta_data = self._load_metadata()
|
||||
meta_changed = False
|
||||
renames = [] # [(old_name, new_name)]
|
||||
|
||||
for model_name in model_names:
|
||||
if ".." in model_name:
|
||||
@@ -389,11 +425,28 @@ class ModelsService:
|
||||
meta_changed = True
|
||||
|
||||
moved.append({"from": model_name, "to": new_rel})
|
||||
renames.append((model_name, new_rel))
|
||||
|
||||
except Exception as e:
|
||||
logger.error("Error moving model %s: %s", model_name, e)
|
||||
errors.append({"model": model_name, "error": str(e)})
|
||||
|
||||
# Update group entries for renamed/moved models
|
||||
if renames:
|
||||
groups_for_type = meta_data.get("_groups", {}).get(model_type, {})
|
||||
groups_dirty = False
|
||||
for old_name, new_name in renames:
|
||||
for members in groups_for_type.values():
|
||||
for i, m in enumerate(members):
|
||||
if m == old_name:
|
||||
members[i] = new_name
|
||||
groups_dirty = True
|
||||
if groups_dirty:
|
||||
if not isinstance(meta_data.get("_groups"), dict):
|
||||
meta_data["_groups"] = {}
|
||||
meta_data["_groups"][model_type] = groups_for_type
|
||||
meta_changed = True
|
||||
|
||||
if meta_changed:
|
||||
self._save_metadata(meta_data)
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "comfyui-workflow-studio"
|
||||
description = "A comprehensive workflow, asset management, and generation UI plugin for ComfyUI. Manage workflows, models, images, and prompts; batch generation and Image Feeder in the GenerateUI tab; library side panel with canvas drag & drop and AI tools."
|
||||
version = "0.3.41"
|
||||
version = "0.3.47"
|
||||
license = "MIT"
|
||||
requires-python = ">= 3.10"
|
||||
dependencies = ["jinja2"]
|
||||
|
||||
@@ -219,6 +219,43 @@
|
||||
color: #fbbf24;
|
||||
}
|
||||
|
||||
/* Feederグループボタン(サムネイルカード左上) */
|
||||
.wfm-gallery-thumb-feeder-btn {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
left: 4px;
|
||||
background: rgba(0,0,0,0.5);
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
line-height: 1;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
color: rgba(255,255,255,0.6);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s, color 0.15s;
|
||||
}
|
||||
|
||||
.wfm-gallery-thumb-card:hover .wfm-gallery-thumb-feeder-btn {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.wfm-gallery-thumb-feeder-btn.active {
|
||||
color: #38bdf8;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.wfm-gallery-thumb-feeder-btn:hover {
|
||||
background: rgba(0,0,0,0.75);
|
||||
color: #38bdf8;
|
||||
}
|
||||
|
||||
/* テーブルビューのお気に入りボタン */
|
||||
.wfm-gallery-table-fav-btn {
|
||||
background: none;
|
||||
@@ -378,6 +415,15 @@
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.wfm-gallery-preview-wrapper {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.wfm-gallery-detail-img {
|
||||
max-width: 100%;
|
||||
max-height: 200px;
|
||||
@@ -385,6 +431,43 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wfm-gallery-preview-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0,0,0,0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
|
||||
.wfm-gallery-preview-wrapper:hover .wfm-gallery-preview-overlay {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.wfm-gallery-download-btn {
|
||||
background: var(--wfm-accent, #4f8ef7);
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.wfm-gallery-download-btn:hover {
|
||||
background: var(--wfm-accent-hover, #3f7fe7);
|
||||
}
|
||||
|
||||
/* タブコンテンツ */
|
||||
.wfm-gallery-detail-tab-content {
|
||||
flex: 1;
|
||||
@@ -602,6 +685,57 @@
|
||||
background: rgba(255,255,255,0.2);
|
||||
}
|
||||
|
||||
/* ── 画像比較ライトボックス ──────────────────────────────────── */
|
||||
|
||||
.wfm-lightbox-compare .wfm-lightbox-compare-inner {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
max-width: 96vw;
|
||||
max-height: 92vh;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.wfm-lightbox-compare-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(var(--compare-cols, 2), 1fr);
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.wfm-lightbox-compare-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.wfm-lightbox-compare-img {
|
||||
max-width: calc(92vw / var(--compare-cols, 2) - 12px);
|
||||
max-height: 78vh;
|
||||
object-fit: contain;
|
||||
border-radius: 4px;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.wfm-lightbox-compare-label {
|
||||
color: rgba(255,255,255,0.75);
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.wfm-lightbox-compare-close {
|
||||
position: fixed;
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
z-index: 10001;
|
||||
}
|
||||
|
||||
/* ── 詳細パネル アクションボタン行 ───────────────────────────── */
|
||||
|
||||
.wfm-gallery-detail-action-row {
|
||||
|
||||
+41
-8
@@ -2992,7 +2992,7 @@ body {
|
||||
}
|
||||
|
||||
.wfm-help-sidebar {
|
||||
width: 170px;
|
||||
width: 220px;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -3006,12 +3006,36 @@ body {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.wfm-help-search-wrap {
|
||||
padding: 8px 8px 4px;
|
||||
}
|
||||
|
||||
.wfm-help-search {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
background: var(--wfm-bg);
|
||||
border: 1px solid var(--wfm-border);
|
||||
color: var(--wfm-text);
|
||||
border-radius: 4px;
|
||||
padding: 5px 8px;
|
||||
font-size: 16px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.wfm-help-search:focus {
|
||||
border-color: var(--wfm-primary);
|
||||
}
|
||||
|
||||
.wfm-help-nav-item.search-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.wfm-help-nav-item {
|
||||
display: block;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
padding: 7px 14px;
|
||||
font-size: 12px;
|
||||
font-size: 18px;
|
||||
background: none;
|
||||
border: none;
|
||||
border-left: 2px solid transparent;
|
||||
@@ -3065,19 +3089,28 @@ body {
|
||||
}
|
||||
|
||||
.wfm-help-card h3 {
|
||||
font-size: 14px;
|
||||
font-size: 21px;
|
||||
font-weight: 600;
|
||||
color: var(--wfm-primary);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.wfm-help-card h4 {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.wfm-help-card p {
|
||||
font-size: 20px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.wfm-help-card ul {
|
||||
margin: 0;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.wfm-help-card li {
|
||||
font-size: 13px;
|
||||
font-size: 20px;
|
||||
color: var(--wfm-text-secondary);
|
||||
line-height: 1.8;
|
||||
}
|
||||
@@ -3088,7 +3121,7 @@ body {
|
||||
}
|
||||
|
||||
.wfm-help-support-card > p {
|
||||
font-size: 14px;
|
||||
font-size: 21px;
|
||||
color: var(--wfm-text-secondary);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
@@ -3135,18 +3168,18 @@ body {
|
||||
}
|
||||
|
||||
.wfm-help-link-title {
|
||||
font-size: 15px;
|
||||
font-size: 23px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.wfm-help-link-desc {
|
||||
font-size: 12px;
|
||||
font-size: 18px;
|
||||
color: var(--wfm-text-secondary);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.wfm-help-thanks {
|
||||
font-size: 13px;
|
||||
font-size: 20px;
|
||||
color: var(--wfm-text-secondary);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@@ -207,6 +207,8 @@ function applyI18nToHtml() {
|
||||
}
|
||||
const galleryBulkGroupAdd = document.getElementById("wfm-gallery-bulk-group-add");
|
||||
if (galleryBulkGroupAdd) galleryBulkGroupAdd.textContent = t("galleryBulkAdd");
|
||||
const galleryBulkGroupRemove = document.getElementById("wfm-gallery-bulk-group-remove");
|
||||
if (galleryBulkGroupRemove) galleryBulkGroupRemove.textContent = t("galleryBulkGroupRemove");
|
||||
const galleryBulkFav = document.getElementById("wfm-gallery-bulk-fav");
|
||||
if (galleryBulkFav) galleryBulkFav.textContent = t("galleryBulkFavAll");
|
||||
const galleryBulkUnfav = document.getElementById("wfm-gallery-bulk-unfav");
|
||||
@@ -353,11 +355,18 @@ function applyI18nToHtml() {
|
||||
"wfm-help-gen-15": "helpGen15",
|
||||
"wfm-help-feeder-title": "helpFeederTitle",
|
||||
"wfm-help-feeder-desc": "helpFeederDesc",
|
||||
"wfm-help-feeder-imgloop-title": "helpFeederImgloopTitle",
|
||||
"wfm-help-feeder-imgloop-desc": "helpFeederImgloopDesc",
|
||||
"wfm-help-feeder-1": "helpFeeder1", "wfm-help-feeder-2": "helpFeeder2",
|
||||
"wfm-help-feeder-3": "helpFeeder3", "wfm-help-feeder-4": "helpFeeder4",
|
||||
"wfm-help-feeder-5": "helpFeeder5", "wfm-help-feeder-6": "helpFeeder6",
|
||||
"wfm-help-feeder-7": "helpFeeder7", "wfm-help-feeder-8": "helpFeeder8",
|
||||
"wfm-help-feeder-9": "helpFeeder9",
|
||||
"wfm-help-feeder-gal-title": "helpFeederGalTitle",
|
||||
"wfm-help-feeder-gal-desc": "helpFeederGalDesc",
|
||||
"wfm-help-feeder-gal-1": "helpFeederGal1", "wfm-help-feeder-gal-2": "helpFeederGal2",
|
||||
"wfm-help-feeder-gal-3": "helpFeederGal3", "wfm-help-feeder-gal-4": "helpFeederGal4",
|
||||
"wfm-help-feeder-gal-5": "helpFeederGal5", "wfm-help-feeder-gal-6": "helpFeederGal6",
|
||||
"wfm-help-prompt-1": "helpPrompt1", "wfm-help-prompt-2": "helpPrompt2",
|
||||
"wfm-help-prompt-3": "helpPrompt3", "wfm-help-prompt-4": "helpPrompt4",
|
||||
"wfm-help-prompt-5": "helpPrompt5", "wfm-help-prompt-6": "helpPrompt6",
|
||||
@@ -425,6 +434,41 @@ function applyI18nToHtml() {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.textContent = t(key);
|
||||
}
|
||||
|
||||
// Search box placeholder
|
||||
const helpSearch = document.getElementById("wfm-help-search");
|
||||
if (helpSearch) {
|
||||
helpSearch.placeholder = t("helpSearchPlaceholder");
|
||||
helpSearch.addEventListener("input", _onHelpSearch);
|
||||
}
|
||||
}
|
||||
|
||||
function _onHelpSearch(e) {
|
||||
const q = e.target.value.trim().toLowerCase();
|
||||
const navItems = document.querySelectorAll("[data-help-page]");
|
||||
if (!q) {
|
||||
navItems.forEach(btn => btn.classList.remove("search-hidden"));
|
||||
return;
|
||||
}
|
||||
|
||||
const matchedPages = new Set();
|
||||
document.querySelectorAll(".wfm-help-page").forEach(page => {
|
||||
const pageId = page.id.replace("wfm-help-page-", "");
|
||||
if (page.textContent.toLowerCase().includes(q)) matchedPages.add(pageId);
|
||||
});
|
||||
|
||||
let firstBtn = null;
|
||||
navItems.forEach(btn => {
|
||||
const pageId = btn.dataset.helpPage;
|
||||
if (matchedPages.has(pageId)) {
|
||||
btn.classList.remove("search-hidden");
|
||||
if (!firstBtn) firstBtn = btn;
|
||||
} else {
|
||||
btn.classList.add("search-hidden");
|
||||
}
|
||||
});
|
||||
|
||||
if (firstBtn && !firstBtn.classList.contains("active")) firstBtn.click();
|
||||
}
|
||||
|
||||
// ============================================
|
||||
|
||||
@@ -168,14 +168,16 @@ export const comfyUI = {
|
||||
},
|
||||
|
||||
// Generation
|
||||
async queuePrompt(workflow) {
|
||||
async queuePrompt(workflow, extraData = null) {
|
||||
const body = {
|
||||
prompt: workflow,
|
||||
client_id: this.clientId,
|
||||
};
|
||||
if (extraData) body.extra_data = extraData;
|
||||
const res = await fetch(`${this.baseUrl}/prompt`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
prompt: workflow,
|
||||
client_id: this.clientId,
|
||||
}),
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const err = await res.json().catch(() => ({}));
|
||||
@@ -275,8 +277,8 @@ export const comfyUI = {
|
||||
throw new Error("Failed to connect WebSocket");
|
||||
}
|
||||
|
||||
// Queue prompt
|
||||
const result = await this.queuePrompt(workflow);
|
||||
// Queue prompt — pass workflow as extra_pnginfo so SaveImage embeds it in PNG metadata
|
||||
const result = await this.queuePrompt(workflow, { extra_pnginfo: { workflow } });
|
||||
this.currentPromptId = result.prompt_id;
|
||||
|
||||
// Track progress
|
||||
|
||||
+365
-22
@@ -1,18 +1,29 @@
|
||||
/**
|
||||
* Feeder Tab - ImageFeeder node control with embedded image library
|
||||
* Feeder Tab - ImageFeeder node control (Image Loop mode)
|
||||
* + WFS_GalleryFeeder node control (Gallery mode)
|
||||
*/
|
||||
|
||||
import { comfyUI } from "./comfyui-client.js";
|
||||
import { showToast } from "./app.js";
|
||||
import { t } from "./i18n.js";
|
||||
import { FEEDER_GROUP, ensureFeederGroup } from "./gallery-tab.js";
|
||||
|
||||
// ── Module State ──────────────────────────────────────────────────
|
||||
const _s = {
|
||||
dir: "", // current folder relative path
|
||||
images: [], // filenames in current folder
|
||||
selected: new Set(),// selected filenames (across all interactions)
|
||||
dir: "", // current folder relative path (loop mode)
|
||||
images: [], // filenames in current folder (loop mode)
|
||||
selected: new Set(),// selected filenames (loop mode)
|
||||
presets: {}, // {presetName: {directory, selected_files}}
|
||||
running: false, // feeder run loop active
|
||||
mode: localStorage.getItem("wfm_feeder_mode") || "loop", // "loop" | "gallery"
|
||||
};
|
||||
|
||||
// Gallery mode state
|
||||
const _gs = {
|
||||
groups: [], // [{name}]
|
||||
group: FEEDER_GROUP, // selected group name
|
||||
images: [], // absolute paths in selected group
|
||||
idx: 0, // current index
|
||||
};
|
||||
|
||||
// ── Node helpers ──────────────────────────────────────────────────
|
||||
@@ -25,12 +36,40 @@ function _feederNodes() {
|
||||
.map(([id, n]) => ({ id, title: n._meta?.title || `ImageFeeder` }));
|
||||
}
|
||||
|
||||
function _galFeederNodes() {
|
||||
const wf = comfyUI.currentWorkflow;
|
||||
if (!wf) return [];
|
||||
return Object.entries(wf)
|
||||
.filter(([, n]) => n?.class_type === "WFS_GalleryFeeder")
|
||||
.map(([id, n]) => ({ id, title: n._meta?.title || `GalleryFeeder` }));
|
||||
}
|
||||
|
||||
export function refreshFeederNodeList() {
|
||||
const sel = document.getElementById("wfm-feeder-node-sel");
|
||||
if (_s.mode === "gallery") {
|
||||
_refreshGalNodeList();
|
||||
} else {
|
||||
const sel = document.getElementById("wfm-feeder-node-sel");
|
||||
if (!sel) return;
|
||||
const nodes = _feederNodes();
|
||||
if (nodes.length === 0) {
|
||||
sel.innerHTML = `<option value="">-- No ImageFeeder node --</option>`;
|
||||
return;
|
||||
}
|
||||
const prevVal = sel.value;
|
||||
sel.innerHTML = nodes.map(n =>
|
||||
`<option value="${n.id}">${n.title} (ID:${n.id})</option>`
|
||||
).join("");
|
||||
if (prevVal && nodes.find(n => n.id === prevVal)) sel.value = prevVal;
|
||||
_loadFromNode(sel.value || nodes[0].id);
|
||||
}
|
||||
}
|
||||
|
||||
function _refreshGalNodeList() {
|
||||
const sel = document.getElementById("wfm-feeder-gal-node-sel");
|
||||
if (!sel) return;
|
||||
const nodes = _feederNodes();
|
||||
const nodes = _galFeederNodes();
|
||||
if (nodes.length === 0) {
|
||||
sel.innerHTML = `<option value="">-- No ImageFeeder node --</option>`;
|
||||
sel.innerHTML = `<option value="">-- No WFS_GalleryFeeder node --</option>`;
|
||||
return;
|
||||
}
|
||||
const prevVal = sel.value;
|
||||
@@ -38,7 +77,7 @@ export function refreshFeederNodeList() {
|
||||
`<option value="${n.id}">${n.title} (ID:${n.id})</option>`
|
||||
).join("");
|
||||
if (prevVal && nodes.find(n => n.id === prevVal)) sel.value = prevVal;
|
||||
_loadFromNode(sel.value || nodes[0].id);
|
||||
_loadFromGalNode(sel.value || nodes[0].id);
|
||||
}
|
||||
|
||||
function _loadFromNode(nodeId) {
|
||||
@@ -55,7 +94,6 @@ function _loadFromNode(nodeId) {
|
||||
_setVal("wfm-feeder-seed", inp.seed ?? 0);
|
||||
_setCheck("wfm-feeder-use-sel", inp.use_selection ?? true);
|
||||
|
||||
// Restore selected_files
|
||||
_s.selected.clear();
|
||||
try {
|
||||
const arr = JSON.parse(inp.selected_files || "[]");
|
||||
@@ -73,6 +111,24 @@ function _loadFromNode(nodeId) {
|
||||
_updateStatus();
|
||||
}
|
||||
|
||||
function _loadFromGalNode(nodeId) {
|
||||
const wf = comfyUI.currentWorkflow;
|
||||
if (!wf?.[nodeId]) return;
|
||||
const inp = wf[nodeId].inputs || {};
|
||||
|
||||
const group = inp.group_name || FEEDER_GROUP;
|
||||
_setVal("wfm-feeder-gal-sort", inp.sort_mode || "filename_asc");
|
||||
_setVal("wfm-feeder-gal-index", inp.index ?? 0);
|
||||
_setVal("wfm-feeder-gal-seed", inp.seed ?? 0);
|
||||
_gs.idx = inp.index ?? 0;
|
||||
|
||||
if (_gs.group !== group) {
|
||||
_gs.group = group;
|
||||
_setGalGroupSelect(group);
|
||||
_loadGalImages(group);
|
||||
}
|
||||
}
|
||||
|
||||
function _applyToWorkflow() {
|
||||
const nodeId = document.getElementById("wfm-feeder-node-sel")?.value;
|
||||
const wf = comfyUI.currentWorkflow;
|
||||
@@ -84,6 +140,17 @@ function _applyToWorkflow() {
|
||||
showToast(t("appliedToWorkflow"), "success");
|
||||
}
|
||||
|
||||
function _applyGalToWorkflow() {
|
||||
const nodeId = document.getElementById("wfm-feeder-gal-node-sel")?.value;
|
||||
const wf = comfyUI.currentWorkflow;
|
||||
if (!nodeId || !wf?.[nodeId]) {
|
||||
showToast(t("feederGalNoNode"), "error");
|
||||
return;
|
||||
}
|
||||
_applyToGalNode(nodeId);
|
||||
showToast(t("appliedToWorkflow"), "success");
|
||||
}
|
||||
|
||||
// ── Run Loop ──────────────────────────────────────────────────────
|
||||
|
||||
function _setRunUI(running) {
|
||||
@@ -93,6 +160,13 @@ function _setRunUI(running) {
|
||||
if (stopBtn) stopBtn.disabled = !running;
|
||||
}
|
||||
|
||||
function _setGalRunUI(running) {
|
||||
const runBtn = document.getElementById("wfm-feeder-gal-run-btn");
|
||||
const stopBtn = document.getElementById("wfm-feeder-gal-stop-btn");
|
||||
if (runBtn) runBtn.disabled = running;
|
||||
if (stopBtn) stopBtn.disabled = !running;
|
||||
}
|
||||
|
||||
function _applyToNode(nodeId) {
|
||||
const wf = comfyUI.currentWorkflow;
|
||||
const inp = wf[nodeId].inputs;
|
||||
@@ -107,6 +181,15 @@ function _applyToNode(nodeId) {
|
||||
inp.selected_files = JSON.stringify([..._s.selected]);
|
||||
}
|
||||
|
||||
function _applyToGalNode(nodeId) {
|
||||
const wf = comfyUI.currentWorkflow;
|
||||
const inp = wf[nodeId].inputs;
|
||||
inp.group_name = _gs.group;
|
||||
inp.index = _gs.idx;
|
||||
inp.sort_mode = document.getElementById("wfm-feeder-gal-sort")?.value || "filename_asc";
|
||||
inp.seed = parseInt(document.getElementById("wfm-feeder-gal-seed")?.value) || 0;
|
||||
}
|
||||
|
||||
async function _startRun() {
|
||||
if (_s.running) return;
|
||||
if (!comfyUI.currentWorkflow) { showToast(t("noWorkflowLoaded"), "error"); return; }
|
||||
@@ -118,7 +201,6 @@ async function _startRun() {
|
||||
return;
|
||||
}
|
||||
|
||||
// WebSocket を先に接続してノード sync メッセージを受け取れるようにする
|
||||
const wsOk = await comfyUI.connectWebSocket();
|
||||
if (!wsOk) { showToast(t("wsConnectionFailed"), "error"); return; }
|
||||
|
||||
@@ -129,7 +211,6 @@ async function _startRun() {
|
||||
const progressText = document.getElementById("wfm-gen-progress-text");
|
||||
const resultImg = document.getElementById("wfm-gen-result-img");
|
||||
|
||||
// image_loop_node_sync メッセージを捕捉するリスナー
|
||||
let _lastSync = null;
|
||||
const _syncHandler = (ev) => {
|
||||
try {
|
||||
@@ -157,7 +238,6 @@ async function _startRun() {
|
||||
if (progressBar) progressBar.style.width = "0%";
|
||||
if (progressText) progressText.textContent = `#${++count} 0%`;
|
||||
|
||||
// 右ペインのseed設定を使用(KSamplerに適用される)
|
||||
const seedMode = document.getElementById("wfm-gen-seed-mode")?.value || "random";
|
||||
const seedValue = parseInt(document.getElementById("wfm-gen-seed-value")?.value) || -1;
|
||||
|
||||
@@ -173,7 +253,6 @@ async function _startRun() {
|
||||
}
|
||||
);
|
||||
|
||||
// 右ペインのseed表示を更新(通常の生成と同じ挙動)
|
||||
const seedEl = document.getElementById("wfm-gen-seed-value");
|
||||
if (seedEl) seedEl.value = seed;
|
||||
|
||||
@@ -187,7 +266,6 @@ async function _startRun() {
|
||||
|
||||
if (!_s.running) break;
|
||||
|
||||
// control after generate: ノードから返された next_index を反映
|
||||
const control = document.getElementById("wfm-feeder-control-after")?.value || "loop";
|
||||
if (control === "fixed") {
|
||||
// index を変えない
|
||||
@@ -199,7 +277,6 @@ async function _startRun() {
|
||||
showToast(t("feederComplete", count), "success");
|
||||
break;
|
||||
}
|
||||
// loop: has_next=false でも次は index=0 からなので続行
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
@@ -219,7 +296,104 @@ async function _stopRun() {
|
||||
showToast(t("feederStopped"), "info");
|
||||
}
|
||||
|
||||
// ── Folder Tree ───────────────────────────────────────────────────
|
||||
// ── Gallery Mode Run Loop ─────────────────────────────────────────
|
||||
|
||||
async function _startGalRun() {
|
||||
if (_s.running) return;
|
||||
if (!comfyUI.currentWorkflow) { showToast(t("noWorkflowLoaded"), "error"); return; }
|
||||
if (!comfyUI.connected) { showToast(t("notConnectedToComfyUI"), "error"); return; }
|
||||
|
||||
const nodeId = document.getElementById("wfm-feeder-gal-node-sel")?.value;
|
||||
if (!nodeId || !comfyUI.currentWorkflow[nodeId]) {
|
||||
showToast(t("feederGalNoNode"), "error");
|
||||
return;
|
||||
}
|
||||
if (_gs.images.length === 0) {
|
||||
showToast(t("feederGalEmptyGroup"), "error");
|
||||
return;
|
||||
}
|
||||
|
||||
const wsOk = await comfyUI.connectWebSocket();
|
||||
if (!wsOk) { showToast(t("wsConnectionFailed"), "error"); return; }
|
||||
|
||||
_s.running = true;
|
||||
_setGalRunUI(true);
|
||||
|
||||
const progressBar = document.getElementById("wfm-gen-progress-bar");
|
||||
const progressText = document.getElementById("wfm-gen-progress-text");
|
||||
const resultImg = document.getElementById("wfm-gen-result-img");
|
||||
const indexEl = document.getElementById("wfm-feeder-gal-index");
|
||||
|
||||
const total = _gs.images.length;
|
||||
let count = 0;
|
||||
try {
|
||||
while (_s.running) {
|
||||
_applyToGalNode(nodeId);
|
||||
|
||||
if (progressBar) progressBar.style.width = "0%";
|
||||
if (progressText) progressText.textContent = `#${++count} [${_gs.idx + 1}/${total}] 0%`;
|
||||
|
||||
const seedMode = document.getElementById("wfm-gen-seed-mode")?.value || "random";
|
||||
const seedValue = parseInt(document.getElementById("wfm-gen-seed-value")?.value) || -1;
|
||||
|
||||
const { images, seed } = await comfyUI.generate(
|
||||
{ ...comfyUI.currentWorkflow },
|
||||
{
|
||||
seedMode,
|
||||
seedValue,
|
||||
onProgress: (pct) => {
|
||||
if (progressBar) progressBar.style.width = `${(pct * 100).toFixed(1)}%`;
|
||||
if (progressText) progressText.textContent = `#${count} [${_gs.idx + 1}/${total}] ${(pct * 100).toFixed(0)}%`;
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const seedEl = document.getElementById("wfm-gen-seed-value");
|
||||
if (seedEl) seedEl.value = seed;
|
||||
|
||||
if (progressBar) progressBar.style.width = "100%";
|
||||
|
||||
if (images.length > 0 && resultImg) {
|
||||
const blob = await comfyUI.getImageBlob(images[0]);
|
||||
resultImg.src = URL.createObjectURL(blob);
|
||||
resultImg.style.display = "block";
|
||||
}
|
||||
|
||||
if (!_s.running) break;
|
||||
|
||||
const control = document.getElementById("wfm-feeder-gal-control-after")?.value || "loop";
|
||||
const nextIdx = (_gs.idx + 1) % total;
|
||||
const isLast = _gs.idx === total - 1;
|
||||
|
||||
if (control === "fixed") {
|
||||
// idx を変えない
|
||||
} else if (control === "increment" && isLast) {
|
||||
_s.running = false;
|
||||
showToast(t("feederComplete", count), "success");
|
||||
break;
|
||||
} else {
|
||||
_gs.idx = nextIdx;
|
||||
if (indexEl) indexEl.value = _gs.idx;
|
||||
_highlightGalCard(_gs.images[_gs.idx]);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (_s.running) showToast(t("feederRunError", err.message), "error");
|
||||
} finally {
|
||||
_s.running = false;
|
||||
_setGalRunUI(false);
|
||||
if (progressText) progressText.textContent = `Done (${count} generated)`;
|
||||
}
|
||||
}
|
||||
|
||||
async function _stopGalRun() {
|
||||
_s.running = false;
|
||||
try { await comfyUI.interrupt(); } catch {}
|
||||
_setGalRunUI(false);
|
||||
showToast(t("feederStopped"), "info");
|
||||
}
|
||||
|
||||
// ── Folder Tree (loop mode) ───────────────────────────────────────
|
||||
|
||||
async function _loadTree() {
|
||||
const container = document.getElementById("wfm-feeder-tree");
|
||||
@@ -276,7 +450,7 @@ function _highlightTreeRow(path) {
|
||||
});
|
||||
}
|
||||
|
||||
// ── Image Grid ────────────────────────────────────────────────────
|
||||
// ── Image Grid (loop mode) ────────────────────────────────────────
|
||||
|
||||
async function _loadImages(dir) {
|
||||
const grid = document.getElementById("wfm-feeder-grid");
|
||||
@@ -367,8 +541,6 @@ function _deselectAll() {
|
||||
_updateStatus();
|
||||
}
|
||||
|
||||
// ── Status Bar ───────────────────────────────────────────────────
|
||||
|
||||
function _updateStatus() {
|
||||
const el = document.getElementById("wfm-feeder-status");
|
||||
if (!el) return;
|
||||
@@ -376,6 +548,104 @@ function _updateStatus() {
|
||||
el.textContent = `📂 ${_s.dir || "(root)"} | ${inCurrent} / ${_s.images.length} selected`;
|
||||
}
|
||||
|
||||
// ── Gallery Mode: Group & Image Grid ─────────────────────────────
|
||||
|
||||
async function _loadGalGroups() {
|
||||
try {
|
||||
const res = await fetch("/wfm/gallery/groups");
|
||||
if (!res.ok) throw new Error(res.status);
|
||||
const data = await res.json();
|
||||
_gs.groups = data.groups || [];
|
||||
_renderGalGroupSelect();
|
||||
} catch (err) {
|
||||
console.warn("[Feeder] loadGalGroups failed:", err);
|
||||
}
|
||||
}
|
||||
|
||||
function _renderGalGroupSelect() {
|
||||
const sel = document.getElementById("wfm-feeder-gal-group");
|
||||
if (!sel) return;
|
||||
sel.innerHTML = _gs.groups
|
||||
.map(g => `<option value="${g.name}"${g.name === _gs.group ? " selected" : ""}>${g.name}</option>`)
|
||||
.join("");
|
||||
if (!_gs.groups.find(g => g.name === _gs.group) && _gs.groups.length > 0) {
|
||||
_gs.group = _gs.groups[0].name;
|
||||
}
|
||||
}
|
||||
|
||||
function _setGalGroupSelect(group) {
|
||||
const sel = document.getElementById("wfm-feeder-gal-group");
|
||||
if (sel) sel.value = group;
|
||||
}
|
||||
|
||||
async function _loadGalImages(group) {
|
||||
const grid = document.getElementById("wfm-feeder-gal-grid");
|
||||
const statusEl = document.getElementById("wfm-feeder-gal-status");
|
||||
if (!grid) return;
|
||||
grid.innerHTML = `<div class="wfm-feeder-grid-msg">Loading...</div>`;
|
||||
try {
|
||||
const res = await fetch(`/wfm/gallery/groups/${encodeURIComponent(group)}/images`);
|
||||
if (!res.ok) throw new Error(res.status);
|
||||
const data = await res.json();
|
||||
_gs.images = data.images || [];
|
||||
_gs.idx = 0;
|
||||
const idxEl = document.getElementById("wfm-feeder-gal-index");
|
||||
if (idxEl) idxEl.value = 0;
|
||||
_renderGalGrid();
|
||||
if (statusEl) statusEl.textContent = `${_gs.images.length} image(s) in "${group}"`;
|
||||
} catch (err) {
|
||||
_gs.images = [];
|
||||
grid.innerHTML = `<div class="wfm-feeder-grid-msg" style="color:var(--wfm-danger)">Load failed: ${err.message}</div>`;
|
||||
if (statusEl) statusEl.textContent = "";
|
||||
}
|
||||
}
|
||||
|
||||
function _renderGalGrid() {
|
||||
const grid = document.getElementById("wfm-feeder-gal-grid");
|
||||
if (!grid) return;
|
||||
if (_gs.images.length === 0) {
|
||||
grid.innerHTML = `<div class="wfm-feeder-grid-msg">No images in this group</div>`;
|
||||
return;
|
||||
}
|
||||
grid.innerHTML = "";
|
||||
_gs.images.forEach((absPath, i) => grid.appendChild(_makeGalCard(absPath, i)));
|
||||
}
|
||||
|
||||
function _makeGalCard(absPath, idx) {
|
||||
const fname = absPath.replace(/\\/g, "/").split("/").pop();
|
||||
const card = document.createElement("div");
|
||||
card.className = "wfm-feeder-card" + (idx === _gs.idx ? " selected" : "");
|
||||
card.dataset.path = absPath;
|
||||
card.dataset.idx = idx;
|
||||
|
||||
const img = document.createElement("img");
|
||||
img.className = "wfm-feeder-card-img";
|
||||
img.loading = "lazy";
|
||||
img.src = `/wfm/gallery/image/serve?path=${encodeURIComponent(absPath)}`;
|
||||
img.onerror = () => { img.style.display = "none"; card.style.minHeight = "110px"; };
|
||||
|
||||
const name = document.createElement("div");
|
||||
name.className = "wfm-feeder-card-name";
|
||||
name.textContent = fname;
|
||||
name.title = fname;
|
||||
|
||||
card.append(img, name);
|
||||
card.addEventListener("click", () => {
|
||||
_gs.idx = idx;
|
||||
const idxEl = document.getElementById("wfm-feeder-gal-index");
|
||||
if (idxEl) idxEl.value = idx;
|
||||
_highlightGalCard(absPath);
|
||||
_showGalPreview(absPath, fname);
|
||||
});
|
||||
return card;
|
||||
}
|
||||
|
||||
function _highlightGalCard(absPath) {
|
||||
document.querySelectorAll("#wfm-feeder-gal-grid .wfm-feeder-card").forEach(c => {
|
||||
c.classList.toggle("selected", c.dataset.path === absPath);
|
||||
});
|
||||
}
|
||||
|
||||
// ── Preview Panel ────────────────────────────────────────────────
|
||||
|
||||
async function _showPreview(relPath, fname) {
|
||||
@@ -400,7 +670,20 @@ async function _showPreview(relPath, fname) {
|
||||
} catch { if (infoEl) infoEl.textContent = ""; }
|
||||
}
|
||||
|
||||
// ── Presets ──────────────────────────────────────────────────────
|
||||
async function _showGalPreview(absPath, fname) {
|
||||
const imgEl = document.getElementById("wfm-feeder-preview-img");
|
||||
const nameEl = document.getElementById("wfm-feeder-preview-name");
|
||||
const infoEl = document.getElementById("wfm-feeder-preview-info");
|
||||
|
||||
if (imgEl) {
|
||||
imgEl.src = `/wfm/gallery/image/serve?path=${encodeURIComponent(absPath)}`;
|
||||
imgEl.style.display = "block";
|
||||
}
|
||||
if (nameEl) nameEl.textContent = fname;
|
||||
if (infoEl) infoEl.textContent = "";
|
||||
}
|
||||
|
||||
// ── Presets (loop mode) ───────────────────────────────────────────
|
||||
|
||||
async function _loadPresets() {
|
||||
try {
|
||||
@@ -471,6 +754,34 @@ async function _deletePreset() {
|
||||
} catch (err) { showToast(t("deleteFailed"), "error"); }
|
||||
}
|
||||
|
||||
// ── Mode Switch ───────────────────────────────────────────────────
|
||||
|
||||
function _setMode(mode) {
|
||||
_s.mode = mode;
|
||||
localStorage.setItem("wfm_feeder_mode", mode);
|
||||
|
||||
const loopBtn = document.getElementById("wfm-feeder-mode-loop");
|
||||
const galBtn = document.getElementById("wfm-feeder-mode-gallery");
|
||||
const loopSec = document.getElementById("wfm-feeder-loop-section");
|
||||
const galSec = document.getElementById("wfm-feeder-gal-section");
|
||||
const loopLib = document.getElementById("wfm-feeder-loop-library");
|
||||
const galLib = document.getElementById("wfm-feeder-gal-library");
|
||||
|
||||
const isGallery = mode === "gallery";
|
||||
|
||||
if (loopBtn) loopBtn.classList.toggle("wfm-btn-primary", !isGallery);
|
||||
if (galBtn) galBtn.classList.toggle("wfm-btn-primary", isGallery);
|
||||
if (loopSec) loopSec.style.display = isGallery ? "none" : "";
|
||||
if (galSec) galSec.style.display = isGallery ? "" : "none";
|
||||
if (loopLib) loopLib.style.display = isGallery ? "none" : "";
|
||||
if (galLib) galLib.style.display = isGallery ? "" : "none";
|
||||
|
||||
if (isGallery) {
|
||||
_loadGalGroups().then(() => _loadGalImages(_gs.group));
|
||||
_refreshGalNodeList();
|
||||
}
|
||||
}
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────
|
||||
|
||||
function _setVal(id, val) {
|
||||
@@ -485,6 +796,11 @@ function _setCheck(id, val) {
|
||||
// ── Init ─────────────────────────────────────────────────────────
|
||||
|
||||
export async function initFeederTab() {
|
||||
// Mode toggle
|
||||
document.getElementById("wfm-feeder-mode-loop")?.addEventListener("click", () => _setMode("loop"));
|
||||
document.getElementById("wfm-feeder-mode-gallery")?.addEventListener("click", () => _setMode("gallery"));
|
||||
|
||||
// ── Image Loop mode events ──
|
||||
document.getElementById("wfm-feeder-node-sel")?.addEventListener("change", e => {
|
||||
_loadFromNode(e.target.value);
|
||||
});
|
||||
@@ -511,6 +827,33 @@ export async function initFeederTab() {
|
||||
document.getElementById("wfm-feeder-run-btn")?.addEventListener("click", _startRun);
|
||||
document.getElementById("wfm-feeder-stop-btn")?.addEventListener("click", _stopRun);
|
||||
|
||||
await Promise.all([_loadTree(), _loadPresets()]);
|
||||
_selectDir("");
|
||||
// ── Gallery mode events ──
|
||||
document.getElementById("wfm-feeder-gal-node-sel")?.addEventListener("change", e => {
|
||||
_loadFromGalNode(e.target.value);
|
||||
});
|
||||
|
||||
document.getElementById("wfm-feeder-gal-apply-btn")?.addEventListener("click", _applyGalToWorkflow);
|
||||
|
||||
document.getElementById("wfm-feeder-gal-group")?.addEventListener("change", e => {
|
||||
_gs.group = e.target.value;
|
||||
_gs.idx = 0;
|
||||
_loadGalImages(_gs.group);
|
||||
});
|
||||
|
||||
document.getElementById("wfm-feeder-gal-index")?.addEventListener("change", e => {
|
||||
_gs.idx = Math.max(0, parseInt(e.target.value) || 0);
|
||||
if (_gs.images[_gs.idx]) _highlightGalCard(_gs.images[_gs.idx]);
|
||||
});
|
||||
|
||||
document.getElementById("wfm-feeder-gal-run-btn")?.addEventListener("click", _startGalRun);
|
||||
document.getElementById("wfm-feeder-gal-stop-btn")?.addEventListener("click", _stopGalRun);
|
||||
|
||||
// 初期化
|
||||
await ensureFeederGroup();
|
||||
_setMode(_s.mode);
|
||||
|
||||
if (_s.mode === "loop") {
|
||||
await Promise.all([_loadTree(), _loadPresets()]);
|
||||
_selectDir("");
|
||||
}
|
||||
}
|
||||
|
||||
+405
-61
@@ -8,6 +8,7 @@ import { t } from "./i18n.js";
|
||||
import { loadFileIntoMetadataTab } from "./metadata-tab.js";
|
||||
import { loadWorkflowIntoEditor } from "./generate-tab.js";
|
||||
import { escapeHtml } from "./util.js";
|
||||
import { comfyWorkflow } from "./comfyui-workflow.js";
|
||||
|
||||
// ── 定数 ─────────────────────────────────────────────────────
|
||||
|
||||
@@ -17,20 +18,34 @@ const API = {
|
||||
imageMeta: (path) => `/wfm/gallery/image/meta?path=${encodeURIComponent(path)}`,
|
||||
imageWorkflow: (path) => `/wfm/gallery/image/workflow?path=${encodeURIComponent(path)}`,
|
||||
serveImage: (path) => `/wfm/gallery/image/serve?path=${encodeURIComponent(path)}`,
|
||||
thumb: (path, w = 256) => `/wfm/gallery/image/thumb?path=${encodeURIComponent(path)}&w=${w}`,
|
||||
bulkFavorite: "/wfm/gallery/bulk/favorite",
|
||||
bulkGroup: "/wfm/gallery/bulk/group",
|
||||
saveImageMeta: `/wfm/gallery/image/meta`,
|
||||
toggleFavorite: `/wfm/gallery/image/favorite`,
|
||||
groups: `/wfm/gallery/groups`,
|
||||
groupCreate: `/wfm/gallery/groups`,
|
||||
groupEnsure: `/wfm/gallery/groups/ensure`,
|
||||
groupRename: (name) => `/wfm/gallery/groups/${encodeURIComponent(name)}`,
|
||||
groupDelete: (name) => `/wfm/gallery/groups/${encodeURIComponent(name)}`,
|
||||
groupAdd: (name) => `/wfm/gallery/groups/${encodeURIComponent(name)}/add`,
|
||||
groupRemove: (name) => `/wfm/gallery/groups/${encodeURIComponent(name)}/remove`,
|
||||
groupClear: (name) => `/wfm/gallery/groups/${encodeURIComponent(name)}/clear`,
|
||||
groupImages: (name) => `/wfm/gallery/groups/${encodeURIComponent(name)}/images`,
|
||||
folderCreate: `/wfm/gallery/folder`,
|
||||
folderDelete: `/wfm/gallery/folder`,
|
||||
imagesDelete: `/wfm/gallery/images/delete`,
|
||||
imagesMove: `/wfm/gallery/images/move`,
|
||||
imagesExportZip: `/wfm/gallery/images/export-zip`,
|
||||
};
|
||||
|
||||
export const FEEDER_GROUP = "__Feeder__";
|
||||
|
||||
// ── ページング ────────────────────────────────────────────────
|
||||
const PAGE_SIZE = 50;
|
||||
let _renderedCount = 0;
|
||||
let _scrollObserver = null;
|
||||
|
||||
// ── 状態 ─────────────────────────────────────────────────────
|
||||
|
||||
const state = {
|
||||
@@ -47,6 +62,7 @@ const state = {
|
||||
groups: [],
|
||||
embeddedWorkflow: null, // 選択画像のworkflow JSON
|
||||
selectedImages: new Set(), // 複数選択中のパス Set
|
||||
lastSelectionIndex: -1, // Shift選択のアンカーインデックス
|
||||
folderTree: null, // フォルダツリー全体(移動先選択に使用)
|
||||
};
|
||||
|
||||
@@ -80,6 +96,49 @@ async function openImageInMetadataTab(img) {
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadImage(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 url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = img.filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
showToast(t("downloadStarted"), "success");
|
||||
} catch (e) {
|
||||
showToast(t("errorWithMsg", e.message), "error");
|
||||
}
|
||||
}
|
||||
|
||||
async function exportSelectedImagesToZip(paths) {
|
||||
if (paths.length === 0) return;
|
||||
try {
|
||||
const res = await fetch(API.imagesExportZip, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ paths }),
|
||||
});
|
||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||
const blob = await res.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = `gallery_export_${Date.now()}.zip`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
showToast(t("exportCompleted"), "success");
|
||||
} catch (e) {
|
||||
showToast(t("errorWithMsg", e.message), "error");
|
||||
}
|
||||
}
|
||||
|
||||
// ── フォルダツリー ────────────────────────────────────────────
|
||||
|
||||
function _getExpandedPaths() {
|
||||
@@ -131,7 +190,7 @@ async function loadFolderTree() {
|
||||
try {
|
||||
const data = await apiFetch(API.folders(state.outputRoot));
|
||||
if (data.error) {
|
||||
tree.innerHTML = `<p class="wfm-placeholder">${data.error}</p>`;
|
||||
tree.innerHTML = `<p class="wfm-placeholder">${escapeHtml(data.error)}</p>`;
|
||||
return;
|
||||
}
|
||||
state.folderTree = data;
|
||||
@@ -147,7 +206,7 @@ async function loadFolderTree() {
|
||||
_restoreTreeState(expandedPaths, state.currentFolder);
|
||||
}
|
||||
} catch (e) {
|
||||
tree.innerHTML = `<p class="wfm-placeholder">Error: ${e.message}</p>`;
|
||||
tree.innerHTML = `<p class="wfm-placeholder">Error: ${escapeHtml(e.message)}</p>`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,6 +249,7 @@ function renderTreeNode(node, container, depth, isRoot) {
|
||||
item.classList.add("selected");
|
||||
state.currentFolder = absPath;
|
||||
state.selectedImages.clear();
|
||||
state.lastSelectionIndex = -1;
|
||||
updateBulkBar();
|
||||
loadImages();
|
||||
// Delete Folder ボタン: rootは削除不可
|
||||
@@ -251,11 +311,12 @@ async function loadImages() {
|
||||
try {
|
||||
const images = (await apiFetch(API.images(params))).images || [];
|
||||
state.images = images;
|
||||
state.lastSelectionIndex = -1;
|
||||
document.getElementById("wfm-gallery-count").textContent = `${state.images.length} images`;
|
||||
renderImages();
|
||||
updateTagFilter(state.images);
|
||||
} catch (e) {
|
||||
grid.innerHTML = `<p class="wfm-placeholder">Error: ${e.message}</p>`;
|
||||
grid.innerHTML = `<p class="wfm-placeholder">Error: ${escapeHtml(e.message)}</p>`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +324,9 @@ function renderImages() {
|
||||
const grid = document.getElementById("wfm-gallery-grid");
|
||||
grid.className = `wfm-gallery-grid wfm-gallery-view-${state.viewMode}`;
|
||||
|
||||
_disconnectScrollObserver();
|
||||
_renderedCount = 0;
|
||||
|
||||
if (state.images.length === 0) {
|
||||
grid.innerHTML = `<p class="wfm-placeholder">No images found.</p>`;
|
||||
return;
|
||||
@@ -271,19 +335,58 @@ function renderImages() {
|
||||
grid.innerHTML = "";
|
||||
|
||||
if (state.viewMode === "thumb") {
|
||||
state.images.forEach(img => {
|
||||
const card = createThumbCard(img);
|
||||
grid.appendChild(card);
|
||||
});
|
||||
_appendNextPage(grid);
|
||||
if (_renderedCount < state.images.length) {
|
||||
_attachScrollSentinel(grid);
|
||||
}
|
||||
} else {
|
||||
grid.appendChild(createTable(state.images));
|
||||
}
|
||||
}
|
||||
|
||||
function _appendNextPage(grid) {
|
||||
const end = Math.min(_renderedCount + PAGE_SIZE, state.images.length);
|
||||
const fragment = document.createDocumentFragment();
|
||||
for (let i = _renderedCount; i < end; i++) {
|
||||
fragment.appendChild(createThumbCard(state.images[i]));
|
||||
}
|
||||
grid.appendChild(fragment);
|
||||
_renderedCount = end;
|
||||
}
|
||||
|
||||
function _disconnectScrollObserver() {
|
||||
if (_scrollObserver) {
|
||||
_scrollObserver.disconnect();
|
||||
_scrollObserver = null;
|
||||
}
|
||||
document.getElementById("wfm-gallery-scroll-sentinel")?.remove();
|
||||
}
|
||||
|
||||
function _attachScrollSentinel(grid) {
|
||||
const sentinel = document.createElement("div");
|
||||
sentinel.id = "wfm-gallery-scroll-sentinel";
|
||||
sentinel.style.cssText = "height:1px;width:100%;grid-column:1/-1";
|
||||
grid.appendChild(sentinel);
|
||||
|
||||
_scrollObserver = new IntersectionObserver((entries) => {
|
||||
if (!entries[0].isIntersecting) return;
|
||||
_appendNextPage(grid);
|
||||
if (_renderedCount >= state.images.length) {
|
||||
_disconnectScrollObserver();
|
||||
} else {
|
||||
// sentinel を末尾に移動
|
||||
grid.appendChild(sentinel);
|
||||
}
|
||||
}, { rootMargin: "300px" });
|
||||
|
||||
_scrollObserver.observe(sentinel);
|
||||
}
|
||||
|
||||
function createThumbCard(img) {
|
||||
const card = document.createElement("div");
|
||||
card.className = "wfm-gallery-thumb-card";
|
||||
card.title = img.filename;
|
||||
card.dataset.path = img.path;
|
||||
if (state.selectedImages.has(img.path)) {
|
||||
card.classList.add("multi-selected");
|
||||
}
|
||||
@@ -295,7 +398,7 @@ function createThumbCard(img) {
|
||||
const imgEl = document.createElement("img");
|
||||
imgEl.className = "wfm-gallery-thumb-img";
|
||||
imgEl.loading = "lazy";
|
||||
imgEl.src = API.serveImage(img.path);
|
||||
imgEl.src = API.thumb(img.path);
|
||||
imgEl.alt = img.filename;
|
||||
imgEl.onerror = () => {
|
||||
imgEl.style.display = "none";
|
||||
@@ -317,14 +420,36 @@ function createThumbCard(img) {
|
||||
});
|
||||
card.appendChild(favBtn);
|
||||
|
||||
// クリック: 詳細表示 / Ctrl+クリック: 複数選択 / Alt+クリック: Metadataタブで開く
|
||||
// Feederグループトグルボタン(カード左上)
|
||||
const inFeeder = (img.groups || []).includes(FEEDER_GROUP);
|
||||
const feederBtn = document.createElement("button");
|
||||
feederBtn.className = `wfm-gallery-thumb-feeder-btn${inFeeder ? " active" : ""}`;
|
||||
feederBtn.title = inFeeder ? "Remove from Feeder" : "Add to Feeder";
|
||||
feederBtn.textContent = "F";
|
||||
feederBtn.addEventListener("click", async (e) => {
|
||||
e.stopPropagation();
|
||||
await toggleFeederGroupInPlace(img, feederBtn);
|
||||
});
|
||||
card.appendChild(feederBtn);
|
||||
|
||||
// クリック: 詳細表示 / Ctrl+クリック: 複数選択 / Shift+クリック: 範囲選択 / Alt+クリック: Metadataタブで開く
|
||||
card.addEventListener("click", (e) => {
|
||||
if (e.altKey) {
|
||||
e.preventDefault();
|
||||
openImageInMetadataTab(img);
|
||||
return;
|
||||
}
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
const idx = state.images.findIndex(i => i.path === img.path);
|
||||
if (e.shiftKey && state.lastSelectionIndex !== -1) {
|
||||
// 範囲選択: アンカーから現在位置まで一括追加
|
||||
const from = Math.min(state.lastSelectionIndex, idx);
|
||||
const to = Math.max(state.lastSelectionIndex, idx);
|
||||
for (let i = from; i <= to; i++) {
|
||||
state.selectedImages.add(state.images[i].path);
|
||||
}
|
||||
_applySelectionToDOM();
|
||||
updateBulkBar();
|
||||
} else if (e.ctrlKey || e.metaKey) {
|
||||
// 複数選択トグル
|
||||
if (state.selectedImages.has(img.path)) {
|
||||
state.selectedImages.delete(img.path);
|
||||
@@ -333,10 +458,12 @@ function createThumbCard(img) {
|
||||
state.selectedImages.add(img.path);
|
||||
card.classList.add("multi-selected");
|
||||
}
|
||||
state.lastSelectionIndex = idx;
|
||||
updateBulkBar();
|
||||
} else {
|
||||
// 通常選択: 詳細表示
|
||||
state.selectedImage = img;
|
||||
state.lastSelectionIndex = idx;
|
||||
document.querySelectorAll(".wfm-gallery-thumb-card.selected").forEach(el => el.classList.remove("selected"));
|
||||
card.classList.add("selected");
|
||||
loadImageDetail(img);
|
||||
@@ -370,6 +497,7 @@ function createTable(images) {
|
||||
const tbody = document.createElement("tbody");
|
||||
images.forEach(img => {
|
||||
const tr = document.createElement("tr");
|
||||
tr.dataset.path = img.path;
|
||||
if (state.selectedImages.has(img.path)) {
|
||||
tr.classList.add("multi-selected");
|
||||
}
|
||||
@@ -391,7 +519,7 @@ function createTable(images) {
|
||||
tdFav.appendChild(favBtn);
|
||||
|
||||
const tdThumb = document.createElement("td");
|
||||
tdThumb.innerHTML = `<img src="${API.serveImage(img.path)}" class="wfm-gallery-table-thumb" loading="lazy" alt="">`;
|
||||
tdThumb.innerHTML = `<img src="${API.thumb(img.path, 128)}" class="wfm-gallery-table-thumb" loading="lazy" alt="">`;
|
||||
|
||||
const tdName = document.createElement("td");
|
||||
tdName.className = "wfm-gallery-table-name";
|
||||
@@ -405,7 +533,7 @@ function createTable(images) {
|
||||
tdDate.textContent = formatDate(img.mtime);
|
||||
|
||||
const tdTags = document.createElement("td");
|
||||
tdTags.innerHTML = (img.tags || []).map(tag => `<span class="wfm-gallery-tag-badge">${tag}</span>`).join("");
|
||||
tdTags.innerHTML = (img.tags || []).map(tag => `<span class="wfm-gallery-tag-badge">${escapeHtml(tag)}</span>`).join("");
|
||||
|
||||
tr.appendChild(tdFav);
|
||||
tr.appendChild(tdThumb);
|
||||
@@ -414,14 +542,23 @@ function createTable(images) {
|
||||
tr.appendChild(tdDate);
|
||||
tr.appendChild(tdTags);
|
||||
|
||||
// クリック: 詳細表示 / Ctrl+クリック: 複数選択 / Alt+クリック: Metadataタブで開く
|
||||
// クリック: 詳細表示 / Ctrl+クリック: 複数選択 / Shift+クリック: 範囲選択 / Alt+クリック: Metadataタブで開く
|
||||
tr.addEventListener("click", (e) => {
|
||||
if (e.altKey) {
|
||||
e.preventDefault();
|
||||
openImageInMetadataTab(img);
|
||||
return;
|
||||
}
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
const idx = state.images.findIndex(i => i.path === img.path);
|
||||
if (e.shiftKey && state.lastSelectionIndex !== -1) {
|
||||
const from = Math.min(state.lastSelectionIndex, idx);
|
||||
const to = Math.max(state.lastSelectionIndex, idx);
|
||||
for (let i = from; i <= to; i++) {
|
||||
state.selectedImages.add(state.images[i].path);
|
||||
}
|
||||
_applySelectionToDOM();
|
||||
updateBulkBar();
|
||||
} else if (e.ctrlKey || e.metaKey) {
|
||||
if (state.selectedImages.has(img.path)) {
|
||||
state.selectedImages.delete(img.path);
|
||||
tr.classList.remove("multi-selected");
|
||||
@@ -429,9 +566,11 @@ function createTable(images) {
|
||||
state.selectedImages.add(img.path);
|
||||
tr.classList.add("multi-selected");
|
||||
}
|
||||
state.lastSelectionIndex = idx;
|
||||
updateBulkBar();
|
||||
} else {
|
||||
state.selectedImage = img;
|
||||
state.lastSelectionIndex = idx;
|
||||
tbody.querySelectorAll("tr.selected").forEach(el => el.classList.remove("selected"));
|
||||
tr.classList.add("selected");
|
||||
loadImageDetail(img);
|
||||
@@ -446,6 +585,17 @@ function createTable(images) {
|
||||
return table;
|
||||
}
|
||||
|
||||
// ── 複数選択ユーティリティ ────────────────────────────────────
|
||||
|
||||
/** state.selectedImages に基づき、描画済みの要素の multi-selected クラスを同期する */
|
||||
function _applySelectionToDOM() {
|
||||
const grid = document.getElementById("wfm-gallery-grid");
|
||||
if (!grid) return;
|
||||
grid.querySelectorAll("[data-path]").forEach(el => {
|
||||
el.classList.toggle("multi-selected", state.selectedImages.has(el.dataset.path));
|
||||
});
|
||||
}
|
||||
|
||||
// ── 複数選択バー ──────────────────────────────────────────────
|
||||
|
||||
function updateBulkBar() {
|
||||
@@ -459,6 +609,13 @@ function updateBulkBar() {
|
||||
} else {
|
||||
bar.style.display = "none";
|
||||
}
|
||||
// Compare ボタンは 2〜4 枚選択時のみ表示
|
||||
const compareBtn = document.getElementById("wfm-gallery-bulk-compare");
|
||||
if (compareBtn) {
|
||||
const show = count >= 2 && count <= 4;
|
||||
compareBtn.style.display = show ? "" : "none";
|
||||
compareBtn.textContent = t("galleryBulkCompare");
|
||||
}
|
||||
}
|
||||
|
||||
// ── お気に入りトグル(インプレース更新) ─────────────────────────
|
||||
@@ -485,6 +642,39 @@ async function toggleFavoriteInPlace(img, btn) {
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleFeederGroupInPlace(img, btn) {
|
||||
const inFeeder = (img.groups || []).includes(FEEDER_GROUP);
|
||||
try {
|
||||
if (inFeeder) {
|
||||
await fetch(API.groupRemove(FEEDER_GROUP), {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ path: img.path }),
|
||||
});
|
||||
img.groups = (img.groups || []).filter(g => g !== FEEDER_GROUP);
|
||||
showToast(t("removedFromFeeder"), "success");
|
||||
} else {
|
||||
await fetch(API.groupAdd(FEEDER_GROUP), {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ path: img.path }),
|
||||
});
|
||||
img.groups = [...(img.groups || []), FEEDER_GROUP];
|
||||
showToast(t("addedToFeeder"), "success");
|
||||
}
|
||||
const cached = state.images.find(i => i.path === img.path);
|
||||
if (cached) cached.groups = img.groups;
|
||||
const nowInFeeder = img.groups.includes(FEEDER_GROUP);
|
||||
btn.classList.toggle("active", nowInFeeder);
|
||||
btn.title = nowInFeeder ? "Remove from Feeder" : "Add to Feeder";
|
||||
if (state.selectedImage && state.selectedImage.path === img.path) {
|
||||
state.selectedImage.groups = img.groups;
|
||||
}
|
||||
} catch (e) {
|
||||
showToast(t("errorWithMsg", e.message), "error");
|
||||
}
|
||||
}
|
||||
|
||||
// ── タグフィルター更新 ────────────────────────────────────────
|
||||
|
||||
function updateTagFilter(images) {
|
||||
@@ -504,6 +694,13 @@ function updateTagFilter(images) {
|
||||
|
||||
// ── 詳細パネル ────────────────────────────────────────────────
|
||||
|
||||
function _updateCopyCanvasBtn() {
|
||||
const btn = document.getElementById("wfm-gallery-copy-workflow-btn");
|
||||
if (!btn) return;
|
||||
btn.disabled = !state.embeddedWorkflow;
|
||||
btn.title = "";
|
||||
}
|
||||
|
||||
async function loadImageDetail(img) {
|
||||
// ファイル操作ボタンを有効化
|
||||
const moveBtn = document.getElementById("wfm-gallery-img-move-btn");
|
||||
@@ -513,8 +710,16 @@ async function loadImageDetail(img) {
|
||||
|
||||
// プレビュー
|
||||
const preview = document.getElementById("wfm-gallery-detail-preview");
|
||||
preview.innerHTML = `<img src="${API.serveImage(img.path)}" class="wfm-gallery-detail-img" alt="${img.filename}" title="Double-click to enlarge">`;
|
||||
preview.innerHTML = `
|
||||
<div class="wfm-gallery-preview-wrapper">
|
||||
<img src="${API.serveImage(img.path)}" class="wfm-gallery-detail-img" alt="${escapeHtml(img.filename)}" title="Double-click to enlarge">
|
||||
<div class="wfm-gallery-preview-overlay">
|
||||
<button class="wfm-gallery-download-btn" title="Download image">⬇</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
preview.querySelector("img").addEventListener("dblclick", () => openLightbox(img));
|
||||
preview.querySelector(".wfm-gallery-download-btn").addEventListener("click", () => downloadImage(img));
|
||||
|
||||
// ファイル名
|
||||
document.getElementById("wfm-gallery-detail-filename").textContent = img.filename;
|
||||
@@ -538,8 +743,10 @@ async function loadImageDetail(img) {
|
||||
]);
|
||||
state.embeddedWorkflow = wfRes.has_workflow ? wfRes.workflow : null;
|
||||
renderWorkflowJson(state.embeddedWorkflow);
|
||||
_updateCopyCanvasBtn();
|
||||
} catch (e) {
|
||||
renderWorkflowJson(null);
|
||||
_updateCopyCanvasBtn();
|
||||
}
|
||||
|
||||
// グループタブ更新
|
||||
@@ -552,7 +759,7 @@ function renderTagsDisplay(tags) {
|
||||
tags.forEach(tag => {
|
||||
const span = document.createElement("span");
|
||||
span.className = "wfm-gallery-tag-badge wfm-gallery-tag-removable";
|
||||
span.innerHTML = `${tag} <button class="wfm-gallery-tag-remove" data-tag="${tag}" title="Remove">×</button>`;
|
||||
span.innerHTML = `${escapeHtml(tag)} <button class="wfm-gallery-tag-remove" data-tag="${escapeHtml(tag)}" title="Remove">×</button>`;
|
||||
span.querySelector("button").addEventListener("click", () => removeTag(tag));
|
||||
container.appendChild(span);
|
||||
});
|
||||
@@ -627,6 +834,34 @@ async function loadGroups() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Feederグループ(__Feeder__)が存在しない場合に作成する */
|
||||
export async function ensureFeederGroup() {
|
||||
try {
|
||||
await fetch(API.groupEnsure, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ name: FEEDER_GROUP }),
|
||||
});
|
||||
await loadGroups();
|
||||
} catch (e) {
|
||||
console.warn("[Gallery] ensureFeederGroup error:", e);
|
||||
}
|
||||
}
|
||||
|
||||
/** Feederグループ内の全画像を除外する(FC ボタン) */
|
||||
async function clearFeederGroup() {
|
||||
try {
|
||||
await fetch(API.groupClear(FEEDER_GROUP), { method: "POST" });
|
||||
showToast(t("feederGroupCleared"), "success");
|
||||
// グループフィルタが __Feeder__ ならリロード
|
||||
if (state.groupFilter === FEEDER_GROUP) {
|
||||
await loadImages();
|
||||
}
|
||||
} catch (e) {
|
||||
showToast(t("errorWithMsg", e.message), "error");
|
||||
}
|
||||
}
|
||||
|
||||
/** ツールバーのグループフィルタと一括バーのセレクトを更新 */
|
||||
function _updateGroupSelects() {
|
||||
// ツールバー: グループフィルタ
|
||||
@@ -705,12 +940,15 @@ function renderDetailGroup(img) {
|
||||
<select id="wfm-gallery-grp-manage-sel" class="wfm-select" style="flex:1;font-size:12px;padding:3px 6px;">
|
||||
${allGroups.length === 0
|
||||
? `<option value="">${t("modelsNoGroupAvailable")}</option>`
|
||||
: allGroups.map(g => `<option value="${escapeHtml(g)}">${escapeHtml(g)}</option>`).join("")}
|
||||
: allGroups.map(g => {
|
||||
const label = g === FEEDER_GROUP ? `🔒 ${escapeHtml(g)}` : escapeHtml(g);
|
||||
return `<option value="${escapeHtml(g)}">${label}</option>`;
|
||||
}).join("")}
|
||||
</select>
|
||||
<button class="wfm-btn wfm-btn-sm" id="wfm-gallery-grp-rename-btn"
|
||||
${allGroups.length === 0 ? "disabled" : ""} title="${t("modelsRename")}">✎</button>
|
||||
${allGroups.length === 0 || allGroups[0] === FEEDER_GROUP ? "disabled" : ""} title="${t("modelsRename")}">✎</button>
|
||||
<button class="wfm-btn wfm-btn-sm wfm-btn-danger" id="wfm-gallery-grp-delete-btn"
|
||||
${allGroups.length === 0 ? "disabled" : ""} title="${t("modelsDelete")}">×</button>
|
||||
${allGroups.length === 0 || allGroups[0] === FEEDER_GROUP ? "disabled" : ""} title="${t("modelsDelete")}">×</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -790,6 +1028,15 @@ function renderDetailGroup(img) {
|
||||
}
|
||||
});
|
||||
|
||||
// 管理セレクト変更時: __Feeder__ は rename/delete を無効化
|
||||
el.querySelector("#wfm-gallery-grp-manage-sel")?.addEventListener("change", (e) => {
|
||||
const isReserved = e.target.value === FEEDER_GROUP;
|
||||
const renameBtn = el.querySelector("#wfm-gallery-grp-rename-btn");
|
||||
const deleteBtn = el.querySelector("#wfm-gallery-grp-delete-btn");
|
||||
if (renameBtn) renameBtn.disabled = isReserved;
|
||||
if (deleteBtn) deleteBtn.disabled = isReserved;
|
||||
});
|
||||
|
||||
// グループ名変更
|
||||
el.querySelector("#wfm-gallery-grp-rename-btn")?.addEventListener("click", async () => {
|
||||
const sel = el.querySelector("#wfm-gallery-grp-manage-sel");
|
||||
@@ -1032,46 +1279,76 @@ function openMoveModal(paths) {
|
||||
async function bulkAddToGroup(groupName) {
|
||||
if (!groupName || state.selectedImages.size === 0) return;
|
||||
const paths = [...state.selectedImages];
|
||||
let success = 0;
|
||||
for (const path of paths) {
|
||||
try {
|
||||
await fetch(API.groupAdd(groupName), {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ path }),
|
||||
try {
|
||||
const res = await fetch(API.bulkGroup, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ paths, group: groupName, action: "add" }),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.ok > 0) {
|
||||
paths.forEach(path => {
|
||||
const img = state.images.find(im => im.path === path);
|
||||
if (img) {
|
||||
if (!img.groups) img.groups = [];
|
||||
if (!img.groups.includes(groupName)) img.groups.push(groupName);
|
||||
}
|
||||
});
|
||||
// キャッシュ更新
|
||||
const img = state.images.find(i => i.path === path);
|
||||
if (img) {
|
||||
if (!img.groups) img.groups = [];
|
||||
if (!img.groups.includes(groupName)) img.groups.push(groupName);
|
||||
}
|
||||
success++;
|
||||
} catch (e) { /* continue */ }
|
||||
}
|
||||
showToast(t("addedNImagesToGroup", data.ok, groupName), "success");
|
||||
} catch (e) {
|
||||
showToast(t("errorWithMsg", e.message), "error");
|
||||
}
|
||||
}
|
||||
|
||||
async function bulkRemoveFromGroup(groupName) {
|
||||
if (!groupName || state.selectedImages.size === 0) return;
|
||||
const paths = [...state.selectedImages];
|
||||
try {
|
||||
const res = await fetch(API.bulkGroup, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ paths, group: groupName, action: "remove" }),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.ok > 0) {
|
||||
paths.forEach(path => {
|
||||
const img = state.images.find(im => im.path === path);
|
||||
if (img && img.groups) {
|
||||
img.groups = img.groups.filter(g => g !== groupName);
|
||||
}
|
||||
});
|
||||
}
|
||||
showToast(t("removedNImagesFromGroup", data.ok, groupName), "success");
|
||||
} catch (e) {
|
||||
showToast(t("errorWithMsg", e.message), "error");
|
||||
}
|
||||
showToast(t("addedNImagesToGroup", success, groupName), "success");
|
||||
}
|
||||
|
||||
async function bulkSetFavorite(favoriteValue) {
|
||||
if (state.selectedImages.size === 0) return;
|
||||
const paths = [...state.selectedImages];
|
||||
let success = 0;
|
||||
for (const path of paths) {
|
||||
try {
|
||||
const img = state.images.find(i => i.path === path);
|
||||
if (!img || img.favorite === favoriteValue) continue;
|
||||
await fetch(API.toggleFavorite, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ path }),
|
||||
const paths = [...state.selectedImages].filter(path => {
|
||||
const img = state.images.find(i => i.path === path);
|
||||
return img && img.favorite !== favoriteValue;
|
||||
});
|
||||
if (paths.length === 0) return;
|
||||
try {
|
||||
const res = await fetch(API.bulkFavorite, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ paths, value: favoriteValue }),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.ok > 0) {
|
||||
paths.forEach(path => {
|
||||
const img = state.images.find(im => im.path === path);
|
||||
if (img) img.favorite = favoriteValue;
|
||||
});
|
||||
img.favorite = favoriteValue;
|
||||
success++;
|
||||
} catch (e) { /* continue */ }
|
||||
}
|
||||
if (success > 0) {
|
||||
showToast(favoriteValue ? t("favoritedNImages", success) : t("unfavoritedNImages", success), "success");
|
||||
renderImages(); // お気に入り状態が変わったのでビュー更新
|
||||
showToast(favoriteValue ? t("favoritedNImages", data.ok) : t("unfavoritedNImages", data.ok), "success");
|
||||
renderImages();
|
||||
}
|
||||
} catch (e) {
|
||||
showToast(t("errorWithMsg", e.message), "error");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1082,8 +1359,8 @@ function openLightbox(img) {
|
||||
overlay.className = "wfm-gallery-lightbox";
|
||||
overlay.innerHTML = `
|
||||
<div class="wfm-gallery-lightbox-inner">
|
||||
<img src="${API.serveImage(img.path)}" class="wfm-gallery-lightbox-img" alt="${img.filename}">
|
||||
<div class="wfm-gallery-lightbox-footer">${img.filename}</div>
|
||||
<img src="${API.serveImage(img.path)}" class="wfm-gallery-lightbox-img" alt="${escapeHtml(img.filename)}">
|
||||
<div class="wfm-gallery-lightbox-footer">${escapeHtml(img.filename)}</div>
|
||||
<button class="wfm-gallery-lightbox-close">×</button>
|
||||
</div>
|
||||
`;
|
||||
@@ -1095,6 +1372,36 @@ function openLightbox(img) {
|
||||
document.body.appendChild(overlay);
|
||||
}
|
||||
|
||||
// ── 画像比較ライトボックス ─────────────────────────────────────
|
||||
|
||||
function openCompare(paths) {
|
||||
const imgs = paths.map(p => state.images.find(im => im.path === p)).filter(Boolean);
|
||||
if (imgs.length < 2) return;
|
||||
|
||||
const overlay = document.createElement("div");
|
||||
overlay.className = "wfm-gallery-lightbox wfm-lightbox-compare";
|
||||
|
||||
const itemsHtml = imgs.map(img => `
|
||||
<div class="wfm-lightbox-compare-item">
|
||||
<img src="${API.serveImage(img.path)}" class="wfm-lightbox-compare-img" alt="${escapeHtml(img.filename)}" loading="lazy">
|
||||
<div class="wfm-lightbox-compare-label">${escapeHtml(img.filename)}</div>
|
||||
</div>
|
||||
`).join("");
|
||||
|
||||
overlay.innerHTML = `
|
||||
<div class="wfm-lightbox-compare-inner">
|
||||
<div class="wfm-lightbox-compare-grid" style="--compare-cols:${imgs.length}">${itemsHtml}</div>
|
||||
</div>
|
||||
<button class="wfm-gallery-lightbox-close wfm-lightbox-compare-close">×</button>
|
||||
`;
|
||||
overlay.addEventListener("click", (e) => {
|
||||
if (e.target === overlay || e.target.classList.contains("wfm-gallery-lightbox-close")) {
|
||||
overlay.remove();
|
||||
}
|
||||
});
|
||||
document.body.appendChild(overlay);
|
||||
}
|
||||
|
||||
// ── outputパス取得 ────────────────────────────────────────────
|
||||
|
||||
async function detectOutputPath() {
|
||||
@@ -1184,6 +1491,9 @@ function bindEvents() {
|
||||
loadImages();
|
||||
});
|
||||
|
||||
// FC ボタン: Feeder グループをクリア
|
||||
document.getElementById("wfm-gallery-fc-btn")?.addEventListener("click", clearFeederGroup);
|
||||
|
||||
// ビュー切替
|
||||
document.querySelectorAll("[data-gallery-view]").forEach(btn => {
|
||||
btn.addEventListener("click", () => {
|
||||
@@ -1218,23 +1528,38 @@ function bindEvents() {
|
||||
});
|
||||
|
||||
// ワークフローコピー&キャンバスへ送る
|
||||
document.getElementById("wfm-gallery-copy-workflow-btn")?.addEventListener("click", () => {
|
||||
document.getElementById("wfm-gallery-copy-workflow-btn")?.addEventListener("click", async () => {
|
||||
if (!state.embeddedWorkflow) {
|
||||
showToast(t("galleryNoEmbeddedWorkflow"), "error");
|
||||
return;
|
||||
}
|
||||
const jsonStr = JSON.stringify(state.embeddedWorkflow, null, 2);
|
||||
navigator.clipboard.writeText(jsonStr)
|
||||
.then(() => {
|
||||
localStorage.setItem("wfm_pending_workflow", jsonStr);
|
||||
try {
|
||||
// window.opener経由でComfyUIキャンバスに直接ロード(推奨)
|
||||
if (window.opener && typeof window.opener.wfmReceiveWorkflow === "function") {
|
||||
window.opener.wfmReceiveWorkflow(state.embeddedWorkflow);
|
||||
await navigator.clipboard.writeText(JSON.stringify(state.embeddedWorkflow, null, 2)).catch(() => {});
|
||||
showToast(t("workflowSentToCanvas"), "success");
|
||||
})
|
||||
.catch(() => showToast(t("copyFailed"), "error"));
|
||||
return;
|
||||
}
|
||||
// フォールバック: localStorage + タイトルドラッグ(UI形式のみ)
|
||||
const fmt = comfyWorkflow.detectFormat(state.embeddedWorkflow);
|
||||
if (fmt === "api") {
|
||||
showToast(t("apiFormatCanvasNoOpener"), "error");
|
||||
return;
|
||||
}
|
||||
const jsonStr = JSON.stringify(state.embeddedWorkflow, null, 2);
|
||||
await navigator.clipboard.writeText(jsonStr).catch(() => {});
|
||||
localStorage.setItem("wfm_pending_workflow", jsonStr);
|
||||
showToast(t("workflowSentToCanvas"), "success");
|
||||
} catch (err) {
|
||||
showToast(t("errorWithMsg", err.message), "error");
|
||||
}
|
||||
});
|
||||
|
||||
// 一括操作バー
|
||||
document.getElementById("wfm-gallery-bulk-deselect")?.addEventListener("click", () => {
|
||||
state.selectedImages.clear();
|
||||
state.lastSelectionIndex = -1;
|
||||
updateBulkBar();
|
||||
// 選択状態をビューから除去
|
||||
document.querySelectorAll(".multi-selected").forEach(el => el.classList.remove("multi-selected"));
|
||||
@@ -1255,6 +1580,15 @@ function bindEvents() {
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById("wfm-gallery-bulk-group-remove")?.addEventListener("click", () => {
|
||||
const sel = document.getElementById("wfm-gallery-bulk-group-select");
|
||||
if (sel && sel.value) {
|
||||
bulkRemoveFromGroup(sel.value);
|
||||
} else {
|
||||
showToast(t("selectGroupFirst"), "error");
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById("wfm-gallery-bulk-fav")?.addEventListener("click", () => {
|
||||
bulkSetFavorite(true);
|
||||
});
|
||||
@@ -1263,11 +1597,21 @@ function bindEvents() {
|
||||
bulkSetFavorite(false);
|
||||
});
|
||||
|
||||
document.getElementById("wfm-gallery-bulk-compare")?.addEventListener("click", () => {
|
||||
if (state.selectedImages.size < 2) return;
|
||||
openCompare([...state.selectedImages]);
|
||||
});
|
||||
|
||||
document.getElementById("wfm-gallery-bulk-move")?.addEventListener("click", () => {
|
||||
if (state.selectedImages.size === 0) return;
|
||||
openMoveModal([...state.selectedImages]);
|
||||
});
|
||||
|
||||
document.getElementById("wfm-gallery-bulk-export")?.addEventListener("click", () => {
|
||||
if (state.selectedImages.size === 0) return;
|
||||
exportSelectedImagesToZip([...state.selectedImages]);
|
||||
});
|
||||
|
||||
document.getElementById("wfm-gallery-bulk-delete")?.addEventListener("click", () => {
|
||||
if (state.selectedImages.size === 0) return;
|
||||
const count = state.selectedImages.size;
|
||||
|
||||
+123
-51
@@ -55,6 +55,8 @@ const LANGUAGES = {
|
||||
apiFormat: "API Format",
|
||||
appFormat: "App Format",
|
||||
appFormatNotSupported: "App format workflows cannot be loaded in GenerateUI. Please use 'Open in ComfyUI' instead.",
|
||||
apiFormatCanvasUnsupported: "API format: cannot send to canvas (drag the .json file from Explorer instead)",
|
||||
apiFormatCanvasNoOpener: "API format: open Workflow Studio from the ComfyUI toolbar to enable Send to Canvas",
|
||||
noSelection: "No selection",
|
||||
groupsLabel: "Groups",
|
||||
groupsNone: "none",
|
||||
@@ -176,6 +178,11 @@ const LANGUAGES = {
|
||||
selectGroupFirst: "Select a group first",
|
||||
selectPresetFirst: "Select a preset first",
|
||||
feederNoNode: "No ImageFeeder node selected",
|
||||
feederGalNoNode: "No WFS_GalleryFeeder node selected",
|
||||
feederGalEmptyGroup: "No images in the selected group",
|
||||
feederGroupCleared: "Feeder group cleared",
|
||||
addedToFeeder: "Added to Feeder",
|
||||
removedFromFeeder: "Removed from Feeder",
|
||||
appliedToWorkflow: "Applied to workflow",
|
||||
notConnectedToComfyUI: "Not connected to ComfyUI",
|
||||
wsConnectionFailed: "WebSocket connection failed",
|
||||
@@ -192,6 +199,7 @@ const LANGUAGES = {
|
||||
deletedNImages: (n) => `Deleted ${n} image(s)`,
|
||||
movedNImages: (n) => `Moved ${n} image(s)`,
|
||||
addedNImagesToGroup: (n, g) => `Added ${n} image(s) to "${g}"`,
|
||||
removedNImagesFromGroup: (n, g) => `Removed ${n} image(s) from "${g}"`,
|
||||
favoritedNImages: (n) => `Favorited ${n} image(s)`,
|
||||
unfavoritedNImages: (n) => `Unfavorited ${n} image(s)`,
|
||||
unknownWorkflowFormat: "Unknown workflow format",
|
||||
@@ -454,7 +462,7 @@ const LANGUAGES = {
|
||||
galleryFolders: "Folders",
|
||||
gallerySelectFolder: "Select a folder to browse images.",
|
||||
galleryNoImages: "No images found.",
|
||||
gallerySearchPlaceholder: "Search images...",
|
||||
gallerySearchPlaceholder: "Search by name, tag, prompt...",
|
||||
galleryOutputDir: "Gallery Output Folder",
|
||||
galleryOutputDirLabel: "Output Folder Path",
|
||||
galleryOutputDirHint: "Set the ComfyUI output folder to browse in the Gallery tab. Leave blank to use ComfyUI's default output directory.",
|
||||
@@ -463,12 +471,17 @@ const LANGUAGES = {
|
||||
galleryBulkSelected: "selected",
|
||||
galleryBulkDeselectAll: "Deselect All",
|
||||
galleryBulkSelectAll: "Select All",
|
||||
galleryBulkAddToGroup: "Add to Group...",
|
||||
galleryBulkAdd: "Add",
|
||||
galleryBulkAddToGroup: "Select Group",
|
||||
galleryBulkAdd: "Add to Group",
|
||||
galleryBulkGroupRemove: "Remove from Group",
|
||||
galleryBulkFavAll: "★ Favorite All",
|
||||
galleryBulkUnfavAll: "☆ Unfavorite All",
|
||||
galleryBulkCompare: "Compare",
|
||||
galleryBulkMoveTo: "Move To...",
|
||||
galleryBulkDelete: "Delete",
|
||||
galleryBulkExport: "Export",
|
||||
galleryBulkDelete: "Delete File",
|
||||
downloadStarted: "Download started",
|
||||
exportCompleted: "Export completed. ZIP file is downloading.",
|
||||
|
||||
tabAi: "AI TOOL",
|
||||
tabTagger: "Tagger",
|
||||
@@ -601,7 +614,9 @@ const LANGUAGES = {
|
||||
helpGen14: "Batch tab — Right pane (Batch Queue): 6 columns — Checkpoint, Lora, Prompt, Workflow, Sampler, Scheduler; each column has an enable checkbox (radio behavior: only one at a time); count shown per column",
|
||||
helpGen15: "Sampler/Scheduler batch: select samplers or schedulers in the left pane, enable the column in Batch Queue, then Generate to iterate through each value on the KSampler node; lists are fetched from ComfyUI (connection required)",
|
||||
helpFeederTitle: "GenerateUI Tab — Feeder subtab",
|
||||
helpFeederDesc: "Requires the comfyui-image-feeder custom node. Controls ImageFeeder nodes and runs continuous generation loops over an image library stored in user/default/image-loop-data/.",
|
||||
helpFeederDesc: "Two modes switchable via the [Image Loop] / [Gallery] toggle at the top of the left pane.",
|
||||
helpFeederImgloopTitle: "Image Loop mode",
|
||||
helpFeederImgloopDesc: "Requires the comfyui-image-feeder custom node. Controls ImageFeeder nodes and runs continuous generation loops over an image library stored in user/default/image-loop-data/.",
|
||||
helpFeeder1: "Left pane — Node settings: select the target ImageFeeder node from the dropdown; edit all node parameters (Directory, Sort Mode, Index, Start/End Index, Batch Size, Seed, Use Selection); click Apply to write changes to the loaded workflow",
|
||||
helpFeeder2: "Left pane — Presets: save the current directory + selection as a named preset; load or delete saved presets",
|
||||
helpFeeder3: "Left pane — Run: After gen mode determines index behavior after each generation — Loop (wrap back to 0 and continue indefinitely), Increment (advance index and stop when all images are exhausted), Fixed (always use the same index); click Run to start the loop, Stop to interrupt",
|
||||
@@ -611,7 +626,16 @@ const LANGUAGES = {
|
||||
helpFeeder7: "Status bar: shows the current folder path and how many images are selected out of the total in the folder",
|
||||
helpFeeder8: "Seed during Run: uses the right-pane seed setting (Random / Fixed / Increment / Decrement) — the ImageFeeder's own Seed field controls random sort order only",
|
||||
helpFeeder9: "Index sync: after each generation the node returns the next index via WebSocket; the Index field updates automatically so the display stays in sync",
|
||||
helpPrompt1: "AI assistant (Ollama): model selection, chat for prompt consultation, image attachment (vision models)",
|
||||
helpFeederGalTitle: "Gallery mode",
|
||||
helpFeederGalDesc: "Uses the built-in WFS_GalleryFeeder node (no external plugin required). Feeds images from a Gallery group into a continuous generation loop.",
|
||||
helpFeederGal1: "Left pane — Node: select a WFS_GalleryFeeder node from the dropdown and click Apply to link it to the workflow; select the source group (defaults to __Feeder__), Sort Mode, Index (current image position), and Seed",
|
||||
helpFeederGal2: "Left pane — Run controls: After gen — Loop (wrap to start and repeat), Increment (advance and stop at last image), Fixed (always use the same index); click Run to start the loop, Stop to interrupt after the current generation",
|
||||
helpFeederGal3: "Center pane — Group image grid: shows all images in the selected group; click a thumbnail to select it and jump to that index; the selected image is highlighted",
|
||||
helpFeederGal4: "Right pane — Preview: displays the currently selected input image; updates when a thumbnail is clicked",
|
||||
helpFeederGal5: "__Feeder__ group: reserved group pre-created automatically; cannot be renamed or deleted; add images to it from the Gallery tab using the F overlay button on each thumbnail",
|
||||
helpFeederGal6: "WFS_GalleryFeeder canvas controls: the node also has Run / Stop / After Gen widgets added directly on the ComfyUI canvas — these work the same as the WFM UI controls and allow running the gallery feeder loop without opening WFM",
|
||||
helpSearchPlaceholder: "Search help...",
|
||||
helpPrompt1: "AI assistant (Ollama / LM Studio): model selection, chat for prompt consultation, image attachment (vision models); backend and URL configured in Settings tab",
|
||||
helpPrompt2: "Apply AI responses to GenerateUI prompts",
|
||||
helpPrompt3: "Translation: JA\u2194EN, ZH\u2194EN",
|
||||
helpPrompt4: "Preset management: create, edit, positive/negative prompt clipboard copy (PP/NP)",
|
||||
@@ -624,7 +648,7 @@ const LANGUAGES = {
|
||||
helpSettings2: "Theme selection (13 presets) with customization: color overrides, background patterns (stripes, polka dot, checkerboard, SVG tiling), and font selection (16 Google Fonts including Japanese display fonts)",
|
||||
helpSettings3: "Workflow data folder path",
|
||||
helpSettings4: "ComfyUI connection URL and test",
|
||||
helpSettings5: "Ollama URL, default model, and connection test",
|
||||
helpSettings5: "AI Assistant (Prompt Tab): backend (Ollama / LM Studio), API URL, default model, and connection test",
|
||||
helpSettings6: "Default workflow setting",
|
||||
helpSettings7: "Eagle integration URL and auto-save toggle",
|
||||
helpSettings8: "Data Management: export all plugin data (settings, metadata, prompts, etc.) to a JSON file, or import to restore. After importing, restart ComfyUI.",
|
||||
@@ -655,11 +679,11 @@ const LANGUAGES = {
|
||||
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)",
|
||||
helpGallery3: "Thumbnail and Table view modes; double-click any image to open fullscreen lightbox",
|
||||
helpGallery4: "Toolbar filters: favorites (★), text search, tag filter, group filter, sort by date/name",
|
||||
helpGallery4: "Toolbar filters: favorites (★), text search (filename / tag / prompt), tag filter, group filter, sort by date/name",
|
||||
helpGallery5: "Folder tree: click to load images, expand with ▶; '+ New' creates a subfolder inside the selected folder, 'Del' deletes it with all contents",
|
||||
helpGallery6: "Multi-select with Ctrl+click — bulk operations: Add to Group, Favorite All, Unfavorite All, Move To..., Delete",
|
||||
helpGallery7: "Detail panel — Info tab: filename, size, date, tags (add/remove), memo; 'Move To...' moves the image to another folder, 'Delete' removes it permanently",
|
||||
helpGallery8: "Detail panel — JSON tab: displays workflow JSON from PNG embedded data (prompt / workflow keys) or from metadata saved by the Generate UI tab; 'Copy & Send Canvas' button copies to clipboard and stores the workflow for title-drag to canvas",
|
||||
helpGallery6: "Multi-select: Ctrl+click to toggle individual images; Shift+click to range-select from the last clicked item — bulk bar: select group → 'Add to Group' / 'Remove from Group'; 'Favorite All' / 'Unfavorite All'; 'Compare' (2–4 images); 'Move To...'; 'Delete File'",
|
||||
helpGallery7: "Detail panel — Info tab: filename, size, date, tags (add/remove), memo; 'Move To...' moves the image to another folder, 'Delete File' removes it permanently",
|
||||
helpGallery8: "Detail panel — JSON tab: displays workflow JSON from PNG embedded data (prompt / workflow keys) or from metadata saved by the Generate UI tab; 'Copy & Send Canvas' button copies to clipboard and sends the workflow directly to the ComfyUI canvas (requires Workflow Studio to be opened from the ComfyUI toolbar; UI-format only falls back to title drag if opened from a bookmark)",
|
||||
helpGallery9: "Detail panel — Groups tab: create, assign, remove, rename, and delete groups per image",
|
||||
helpGallery10: "Workflow auto-save: images generated in the Generate UI tab automatically have their workflow saved to gallery metadata and shown in the JSON tab",
|
||||
helpGallery11: "Supports PNG (tEXt/iTXt), JPEG, WebP, GIF; workflow extraction reads ComfyUI prompt and workflow keys embedded in PNG metadata",
|
||||
@@ -696,7 +720,7 @@ const LANGUAGES = {
|
||||
helpSidepanel14: "Information tab — drag items to canvas: model sub-tab places the loader node (Checkpoint → CheckpointLoaderSimple, VAE → VAELoader, Diffusion Model → UNETLoader, Text Encoder → CLIPLoader); double-click also places at canvas center",
|
||||
helpSidepanel15: "Information tab — LoRA sub-tab: detects LoRAs from LoraLoader, LoraLoaderModelOnly, and Lora Loader (LoraManager) nodes (API format supported); drag individual LoRA to place LoraLoader; \"Multiple LORA\" section places all LoRAs in a single Lora Loader (LoraManager) node with LoRA syntax pre-filled; Prompts sub-tab: drag a prompt to place CLIPTextEncode node with text pre-filled; click prompt to view full text and copy",
|
||||
helpSidepanel16: "A tab (AI Tools): Translation, Chat, TOOLS, and Settings sub-tabs powered by Ollama or LM Studio; Chat supports multi-turn conversations; TOOLS includes VLM image analysis and wildcard generation; settings shared with the SPA AI TOOL tab via localStorage",
|
||||
helpSidepanel17: "Title drag (Send to Canvas): after clicking 'Send to Canvas' (Workflow tab) or 'Copy & Send Canvas' (Gallery tab), the 'Workflow Studio Library' title turns blue with a green ● — drag it onto the canvas to load the workflow; title resets automatically after loading",
|
||||
helpSidepanel17: "Send to Canvas: clicking 'Send to Canvas' (Workflow tab) or 'Copy & Send Canvas' (Gallery tab) sends the workflow directly to the ComfyUI canvas — both UI and API formats are supported; if Workflow Studio was not opened from the ComfyUI toolbar (window.opener unavailable), UI-format workflows fall back to title drag (title turns blue with a green ●)",
|
||||
helpAiTitle: "AI Tab (A)",
|
||||
helpAi1: "4-pane layout — Translation | Chat | TOOLS | Settings — all panes are always visible simultaneously",
|
||||
helpAi2: "Translation pane: translate between Japanese, English, Chinese, or Free language; ⇄ swap button swaps both language selectors and text content; selections are saved automatically",
|
||||
@@ -711,7 +735,7 @@ const LANGUAGES = {
|
||||
helpShortcuts4: "Double-click: Open detail modal",
|
||||
helpTroubleTitle: "Troubleshooting",
|
||||
helpTrouble1: "Cannot connect to ComfyUI: Check if ComfyUI can generate images, verify URL in Settings, try refreshing or restarting",
|
||||
helpTrouble2: "Cannot connect to Ollama: Use connection test button, check if Ollama is running and models are downloaded",
|
||||
helpTrouble2: "Cannot connect to AI assistant: Use the connection test button in Settings tab; for Ollama check it is running and models are downloaded; for LM Studio check the server is running and a model is loaded",
|
||||
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",
|
||||
@@ -742,13 +766,13 @@ const LANGUAGES = {
|
||||
comfyuiUrlHint: "When running as ComfyUI plugin, leave empty to use same origin. Only set if ComfyUI is on a different server.",
|
||||
connectedCheck: "Connected \u2713",
|
||||
failedConnect: "Failed to connect \u2717",
|
||||
ollamaSettings: "Ollama Settings (Prompt Tab)",
|
||||
ollamaUrl: "Ollama API URL",
|
||||
ollamaSettings: "AI Assistant Settings (Prompt Tab)",
|
||||
ollamaUrl: "API URL",
|
||||
ollamaDefaultModel: "Default Model",
|
||||
selectModel: "Select model...",
|
||||
noModelsFound: "No models found",
|
||||
failedLoadModels: "Failed to load models",
|
||||
saveOllama: "Save Ollama Settings",
|
||||
saveOllama: "Save AI Assistant Settings",
|
||||
testConnection: "Test Connection",
|
||||
ollamaConnected: "Connected \u2713",
|
||||
ollamaFailed: "Failed",
|
||||
@@ -770,7 +794,7 @@ const LANGUAGES = {
|
||||
importError: "Import failed",
|
||||
saveSettings: "Save Settings",
|
||||
settingsSaved: "Settings saved",
|
||||
ollamaSaved: "Ollama settings saved",
|
||||
ollamaSaved: "AI Assistant settings saved",
|
||||
// -- Theme --
|
||||
themeLabel: "Theme",
|
||||
themeDefault: "Deep Ocean Dark (Default)",
|
||||
@@ -909,6 +933,8 @@ const LANGUAGES = {
|
||||
apiFormat: "API形式",
|
||||
appFormat: "App形式",
|
||||
appFormatNotSupported: "App形式のワークフローは生成UIに読み込めません。「ComfyUIで開く」をご利用ください。",
|
||||
apiFormatCanvasUnsupported: "API形式: キャンバスへの送信に非対応(エクスプローラーから.jsonをドラッグしてください)",
|
||||
apiFormatCanvasNoOpener: "API形式: Send to CanvasはComfyUIのツールバーからWorkflow Studioを開いた場合のみ使用できます",
|
||||
noSelection: "未選択",
|
||||
groupsLabel: "グループ",
|
||||
groupsNone: "なし",
|
||||
@@ -1030,6 +1056,11 @@ const LANGUAGES = {
|
||||
selectGroupFirst: "先にグループを選択してください",
|
||||
selectPresetFirst: "先にプリセットを選択してください",
|
||||
feederNoNode: "ImageFeederノードが選択されていません",
|
||||
feederGalNoNode: "WFS_GalleryFeederノードが選択されていません",
|
||||
feederGalEmptyGroup: "選択グループに画像がありません",
|
||||
feederGroupCleared: "Feederグループをクリアしました",
|
||||
addedToFeeder: "Feederに追加しました",
|
||||
removedFromFeeder: "Feederから除外しました",
|
||||
appliedToWorkflow: "ワークフローに適用しました",
|
||||
notConnectedToComfyUI: "ComfyUIに接続されていません",
|
||||
wsConnectionFailed: "WebSocket接続に失敗しました",
|
||||
@@ -1046,6 +1077,7 @@ const LANGUAGES = {
|
||||
deletedNImages: (n) => `${n}件の画像を削除しました`,
|
||||
movedNImages: (n) => `${n}件の画像を移動しました`,
|
||||
addedNImagesToGroup: (n, g) => `${n}件の画像を「${g}」に追加しました`,
|
||||
removedNImagesFromGroup: (n, g) => `${n}件の画像を「${g}」から削除しました`,
|
||||
favoritedNImages: (n) => `${n}件をお気に入りに追加しました`,
|
||||
unfavoritedNImages: (n) => `${n}件をお気に入りから外しました`,
|
||||
unknownWorkflowFormat: "不明なワークフロー形式です",
|
||||
@@ -1308,7 +1340,7 @@ const LANGUAGES = {
|
||||
galleryFolders: "フォルダ",
|
||||
gallerySelectFolder: "フォルダを選択して画像を表示します。",
|
||||
galleryNoImages: "画像が見つかりません。",
|
||||
gallerySearchPlaceholder: "画像を検索...",
|
||||
gallerySearchPlaceholder: "名前・タグ・プロンプトで検索...",
|
||||
galleryOutputDir: "ギャラリー Outputフォルダ",
|
||||
galleryOutputDirLabel: "Outputフォルダのパス",
|
||||
galleryOutputDirHint: "ギャラリータブで参照するComfyUIのoutputフォルダを設定します。空欄の場合はComfyUIのデフォルトoutputディレクトリを使用します。",
|
||||
@@ -1317,12 +1349,17 @@ const LANGUAGES = {
|
||||
galleryBulkSelected: "件選択中",
|
||||
galleryBulkDeselectAll: "選択解除",
|
||||
galleryBulkSelectAll: "全選択",
|
||||
galleryBulkAddToGroup: "グループに追加...",
|
||||
galleryBulkAdd: "追加",
|
||||
galleryBulkAddToGroup: "グループ選択",
|
||||
galleryBulkAdd: "グループに追加",
|
||||
galleryBulkGroupRemove: "グループから削除",
|
||||
galleryBulkFavAll: "★ お気に入り追加(全件)",
|
||||
galleryBulkUnfavAll: "☆ お気に入り解除(全件)",
|
||||
galleryBulkCompare: "比較",
|
||||
galleryBulkMoveTo: "移動先...",
|
||||
galleryBulkDelete: "削除",
|
||||
galleryBulkExport: "エクスポート",
|
||||
galleryBulkDelete: "ファイル削除",
|
||||
downloadStarted: "ダウンロード開始",
|
||||
exportCompleted: "エクスポート完了。ZIPファイルをダウンロード中です。",
|
||||
|
||||
tabAi: "AI TOOL",
|
||||
tabTagger: "Tagger",
|
||||
@@ -1455,7 +1492,9 @@ const LANGUAGES = {
|
||||
helpGen14: "Batchタブ — 右ペイン(バッチキュー):6列構成 — Checkpoint / Lora / Prompt / Workflow / Sampler / Scheduler;各列にチェックボックスがあり1種類のみ有効化可能(ラジオ動作);各列に件数を表示",
|
||||
helpGen15: "Sampler/Schedulerバッチ:左ペインでサンプラーまたはスケジューラーを選択し、バッチキューの対応列を有効化してGenerateを実行;選択した値を順番にKSamplerノードに適用して生成;リストはComfyUIから取得(要接続)",
|
||||
helpFeederTitle: "GenerateUI Tab — Feeder サブタブ",
|
||||
helpFeederDesc: "comfyui-image-feeder カスタムノードが必要です。ImageFeeder ノードを操作し、user/default/image-loop-data/ に保存された画像ライブラリを使って連続生成ループを実行します。",
|
||||
helpFeederDesc: "左ペイン上部の [Image Loop] / [Gallery] トグルで2つのモードを切り替えられます。",
|
||||
helpFeederImgloopTitle: "Image Loop モード",
|
||||
helpFeederImgloopDesc: "comfyui-image-feeder カスタムノードが必要です。ImageFeeder ノードを操作し、user/default/image-loop-data/ に保存された画像ライブラリを使って連続生成ループを実行します。",
|
||||
helpFeeder1: "左ペイン — ノード設定:ドロップダウンで対象 ImageFeeder ノードを選択;Directory・Sort Mode・Index・Start/End Index・Batch Size・Seed・Use Selection の各パラメータを編集;Apply で読み込み済みワークフローに反映",
|
||||
helpFeeder2: "左ペイン — プリセット:現在のフォルダ+選択ファイルを名前付きプリセットとして保存;保存済みプリセットの読み込み・削除",
|
||||
helpFeeder3: "左ペイン — Run:After gen モードで各生成後の index 動作を設定 — Loop(index を 0 に折り返して無限継続)、Increment(index を進め全画像消化で自動停止)、Fixed(常に同じ index を使用);Run ボタンでループ開始、Stop で中断",
|
||||
@@ -1465,7 +1504,16 @@ const LANGUAGES = {
|
||||
helpFeeder7: "ステータスバー:現在のフォルダパスと、そのフォルダ内の総枚数に対する選択枚数を表示",
|
||||
helpFeeder8: "Run 時のシード:右ペインのシード設定(ランダム / 固定 / 増加 / 減少)を使用 — ImageFeeder 自身の Seed フィールドはランダムソートの並び順のみに影響",
|
||||
helpFeeder9: "Index 同期:生成完了後にノードが次の index を WebSocket で返送;Index フィールドが自動更新されて表示と実行状態が一致",
|
||||
helpPrompt1: "AIアシスタント(Ollama):モデル選択、チャットでプロンプト相談、画像添付(ビジョンモデル対応)",
|
||||
helpFeederGalTitle: "Gallery モード",
|
||||
helpFeederGalDesc: "組み込みの WFS_GalleryFeeder ノードを使用します(外部プラグイン不要)。ギャラリーグループの画像を連続生成ループに供給します。",
|
||||
helpFeederGal1: "左ペイン — ノード:ドロップダウンから WFS_GalleryFeeder ノードを選択して Apply をクリックし、ワークフローに紐付け;ソースグループ(デフォルト: __Feeder__)・Sort Mode・Index(現在の画像位置)・Seed を設定",
|
||||
helpFeederGal2: "左ペイン — Run コントロール:After gen — Loop(先頭に戻って繰り返し)、Increment(進めて最後の画像で停止)、Fixed(常に同じ index を使用);Run でループ開始、Stop で現在の生成完了後に中断",
|
||||
helpFeederGal3: "中央ペイン — グループ画像グリッド:選択グループの全画像を表示;サムネイルをクリックすると選択状態になり、その index にジャンプ;選択中の画像はハイライト表示",
|
||||
helpFeederGal4: "右ペイン — プレビュー:現在選択中の入力画像を表示;サムネイルをクリックすると更新",
|
||||
helpFeederGal5: "__Feeder__ グループ:自動で作成される予約グループ;名前変更・削除不可;ギャラリータブの各サムネイル上の F ボタンでこのグループに画像を追加",
|
||||
helpFeederGal6: "WFS_GalleryFeeder キャンバスコントロール:このノードには ComfyUI キャンバス上に直接 Run / Stop / After Gen ウィジェットが追加されており、WFM を開かずにギャラリーフィーダーループを実行できます",
|
||||
helpSearchPlaceholder: "ヘルプを検索...",
|
||||
helpPrompt1: "AIアシスタント(Ollama / LM Studio):モデル選択、チャットでプロンプト相談、画像添付(ビジョンモデル対応);バックエンドとURLは設定タブで設定",
|
||||
helpPrompt2: "AIの応答をGenerateUIのプロンプトに適用",
|
||||
helpPrompt3: "翻訳機能:日⇔英、中⇔英",
|
||||
helpPrompt4: "プリセット管理:作成・編集、ポジティブ/ネガティブプロンプトのクリップボードコピー(PP/NP)",
|
||||
@@ -1478,7 +1526,7 @@ const LANGUAGES = {
|
||||
helpSettings2: "テーマ選択(13種プリセット)+カスタマイズ:カラー調整、背景パターン(ストライプ、ポルカドット、チェック、SVGタイリング)、フォント選択(日本語デザインフォント含む16種のGoogle Fonts)",
|
||||
helpSettings3: "ワークフローデータフォルダのパス変更・リセット",
|
||||
helpSettings4: "ComfyUI接続URL設定と接続テスト",
|
||||
helpSettings5: "Ollama URL、デフォルトモデル、接続テスト",
|
||||
helpSettings5: "AI Assistant(プロンプトタブ):バックエンド(Ollama / LM Studio)・API URL・デフォルトモデル・接続テスト",
|
||||
helpSettings6: "デフォルトワークフローの設定・解除",
|
||||
helpSettings7: "Eagle連携URL、自動保存の有効/無効",
|
||||
helpSettings8: "データ管理:設定・メタデータ・プロンプトなど全データをJSONにエクスポート、またはインポートして復元。インポート後はComfyUIを再起動してください。",
|
||||
@@ -1509,11 +1557,11 @@ const LANGUAGES = {
|
||||
helpGallery1: "ComfyUIの出力フォルダ内画像を閲覧 — Settings > Gallery Output Folder でフォルダパスを設定可能",
|
||||
helpGallery2: "3カラムレイアウト: フォルダツリー (左) | 画像グリッド (中央) | 詳細パネル (右)",
|
||||
helpGallery3: "サムネイル・テーブル表示モード切替;ダブルクリックで全画面ライトボックス表示",
|
||||
helpGallery4: "ツールバーフィルタ:お気に入り(★)、テキスト検索、タグフィルタ、グループフィルタ、日付・名前ソート",
|
||||
helpGallery4: "ツールバーフィルタ:お気に入り(★)、テキスト検索(ファイル名・タグ・プロンプト)、タグフィルタ、グループフィルタ、日付・名前ソート",
|
||||
helpGallery5: "フォルダツリー:クリックで画像を読み込み;▶で展開;「+ New」で選択フォルダ内にサブフォルダを作成;「Del」でそのフォルダとすべての内容を削除",
|
||||
helpGallery6: "Ctrl+クリックで複数選択 — 一括操作:グループへ追加、一括お気に入り、一括お気に入り解除、移動(Move To...)、削除",
|
||||
helpGallery7: "詳細パネル — Infoタブ:ファイル名、サイズ、日付、タグ(追加/削除)、メモ;「Move To...」で他フォルダへ移動;「Delete」で完全削除",
|
||||
helpGallery8: "詳細パネル — JSONタブ:PNGの埋め込みデータ(prompt / workflow キー)またはGenerateUIタブで保存したメタデータからワークフローJSONを表示;「Copy & Send Canvas」ボタンでクリップボードへのコピーとキャンバスへのタイトルドラッグ用保存を同時に行う",
|
||||
helpGallery6: "複数選択:Ctrl+クリックで個別トグル;Shift+クリックで最後にクリックした位置から範囲選択 — 一括操作バー:グループを選択して「グループに追加」/「グループから削除」;「お気に入り追加(全件)」/「お気に入り解除(全件)」;「比較」(2〜4枚選択時);「移動先...」;「ファイル削除」",
|
||||
helpGallery7: "詳細パネル — Infoタブ:ファイル名、サイズ、日付、タグ(追加/削除)、メモ;「Move To...」で他フォルダへ移動;「ファイル削除」で完全削除",
|
||||
helpGallery8: "詳細パネル — JSONタブ:PNGの埋め込みデータ(prompt / workflow キー)またはGenerateUIタブで保存したメタデータからワークフローJSONを表示;「Copy & Send Canvas」ボタンでクリップボードにコピーしてComfyUIキャンバスへ直接送信(UI形式・API形式どちらも対応);ComfyUIツールバーから開いていない場合はUI形式のみタイトルドラッグのフォールバック",
|
||||
helpGallery9: "詳細パネル — Groupsタブ:画像ごとのグループ作成、割り当て、解除、名前変更、削除",
|
||||
helpGallery10: "ワークフロー自動保存:GenerateUIタブで生成した画像はワークフローが自動でギャラリーメタデータに保存され、JSONタブで確認可能",
|
||||
helpGallery11: "PNG (tEXt/iTXt)、JPEG、WebP、GIF対応;PNG形式はComfyUIの埋め込みJSON(prompt / workflow キー)を読み込んでワークフロー抽出が可能",
|
||||
@@ -1550,7 +1598,7 @@ const LANGUAGES = {
|
||||
helpSidepanel14: "Information タブ — キャンバスへドラッグ:model サブタブのアイテムをドラッグすると対応ローダーノードを配置(Checkpoint → CheckpointLoaderSimple、VAE → VAELoader、Diffusion Model → UNETLoader、Text Encoder → CLIPLoader);ダブルクリックでもキャンバス中央に配置可能",
|
||||
helpSidepanel15: "Information タブ — lora サブタブ:LoraLoader・LoraLoaderModelOnly・Lora Loader (LoraManager) ノード(APIフォーマット含む)から LoRA を検出;個別 LoRA をドラッグで LoraLoader を配置;「Multiple LORA」セクションで全 LoRA を Lora Loader (LoraManager) ノードに一括配置(LoRA構文自動入力);Prompts サブタブ:プロンプトをドラッグするとテキスト入力済みの CLIPTextEncode ノードを配置;クリックで全文表示・コピー可能",
|
||||
helpSidepanel16: "A タブ(AI ツール):翻訳・Chat・TOOLS・設定のサブタブ;Chat は LLM とのマルチターン会話;TOOLS は VLM 画像解析とワイルドカード生成に対応;設定は SPA の AI タブと localStorage で共有される",
|
||||
helpSidepanel17: "タイトルドラッグ(Send to Canvas):WorkflowタブのSend to CanvasまたはGalleryタブのCopy & Send Canvasクリック後、タイトルが青くハイライトし緑の●が表示される — タイトルをキャンバスへドラッグするとワークフローが読み込まれ、タイトルは自動リセットされる",
|
||||
helpSidepanel17: "Send to Canvas:WorkflowタブのSend to CanvasまたはGalleryタブのCopy & Send Canvasをクリックするとワークフローをキャンバスへ直接送信(UI形式・API形式どちらも対応);ComfyUIのツールバーから開いていない場合はUI形式のみタイトルドラッグのフォールバック(タイトルが青くなり緑の●が表示される — ドラッグで読み込み)",
|
||||
helpAiTitle: "AI タブ(A)",
|
||||
helpAi1: "4ペインレイアウト — Translation | Chat | TOOLS | Settings — 全ペインが常時表示される",
|
||||
helpAi2: "翻訳ペイン:Ollama または LM Studio を使って日本語・英語・中国語・カスタム言語(Free)間でテキストを翻訳;⇄ ボタンで言語とテキストを同時入替;選択は自動保存",
|
||||
@@ -1565,7 +1613,7 @@ const LANGUAGES = {
|
||||
helpShortcuts4: "ダブルクリック:詳細モーダルを開く",
|
||||
helpTroubleTitle: "トラブルシューティング",
|
||||
helpTrouble1: "ComfyUIに接続できない:ComfyUIで画像生成できるか確認、設定タブでURL確認、ブラウザ更新・再起動",
|
||||
helpTrouble2: "Ollamaに接続できない:接続テストボタンで確認、Ollamaの起動・モデルのダウンロードを確認",
|
||||
helpTrouble2: "AIアシスタントに接続できない:設定タブの接続テストボタンで確認;Ollamaの場合は起動とモデルのダウンロードを確認;LM Studioの場合はサーバー起動とモデルのロードを確認",
|
||||
helpTrouble3: "ワークフローが表示されない:更新ボタン押下、ComfyUIで読み込めるか確認、ブラウザ・ComfyUI再起動",
|
||||
helpTrouble4: "画像生成が失敗する:指定モデルの存在確認、ComfyUI接続確認、再起動",
|
||||
helpTrouble5: "LoRAスタック実行時に「No such file or directory」エラー:comfyui-lora-managerが該当LoRAを認識していない可能性があります(既知の問題)。別のLoRAを試すか、Lora Manager自体のUIで該当ファイルが表示されるか確認してください",
|
||||
@@ -1596,13 +1644,13 @@ const LANGUAGES = {
|
||||
comfyuiUrlHint: "ComfyUIプラグインとして動作する場合は空欄(同一オリジン推奨)。別サーバーの場合のみ設定してください。",
|
||||
connectedCheck: "接続成功 \u2713",
|
||||
failedConnect: "接続失敗 \u2717",
|
||||
ollamaSettings: "Ollama 設定(プロンプトタブ)",
|
||||
ollamaUrl: "Ollama API URL",
|
||||
ollamaSettings: "AI Assistant設定(プロンプトタブ)",
|
||||
ollamaUrl: "API URL",
|
||||
ollamaDefaultModel: "デフォルトモデル",
|
||||
selectModel: "モデルを選択...",
|
||||
noModelsFound: "モデルが見つかりません",
|
||||
failedLoadModels: "モデル一覧の取得に失敗",
|
||||
saveOllama: "Ollama設定を保存",
|
||||
saveOllama: "AI Assistant設定を保存",
|
||||
testConnection: "接続テスト",
|
||||
ollamaConnected: "接続成功 \u2713",
|
||||
ollamaFailed: "失敗",
|
||||
@@ -1624,7 +1672,7 @@ const LANGUAGES = {
|
||||
importError: "インポート失敗",
|
||||
saveSettings: "設定を保存",
|
||||
settingsSaved: "設定を保存しました",
|
||||
ollamaSaved: "Ollama設定を保存しました",
|
||||
ollamaSaved: "AI Assistant設定を保存しました",
|
||||
// -- Theme --
|
||||
themeLabel: "テーマ",
|
||||
themeDefault: "Deep Ocean Dark (デフォルト)",
|
||||
@@ -1763,6 +1811,8 @@ const LANGUAGES = {
|
||||
apiFormat: "API格式",
|
||||
appFormat: "App格式",
|
||||
appFormatNotSupported: "App格式的工作流无法在生成UI中加载。请使用「在ComfyUI中打开」。",
|
||||
apiFormatCanvasUnsupported: "API格式:不支持发送到画布(请直接从资源管理器拖拽.json文件)",
|
||||
apiFormatCanvasNoOpener: "API格式:仅在从ComfyUI工具栏打开Workflow Studio时才能使用发送到画布功能",
|
||||
noSelection: "未选择",
|
||||
groupsLabel: "分组",
|
||||
groupsNone: "无",
|
||||
@@ -1884,6 +1934,11 @@ const LANGUAGES = {
|
||||
selectGroupFirst: "请先选择分组",
|
||||
selectPresetFirst: "请先选择预设",
|
||||
feederNoNode: "未选择ImageFeeder节点",
|
||||
feederGalNoNode: "未选择WFS_GalleryFeeder节点",
|
||||
feederGalEmptyGroup: "所选组中没有图片",
|
||||
feederGroupCleared: "已清空Feeder组",
|
||||
addedToFeeder: "已添加到Feeder",
|
||||
removedFromFeeder: "已从Feeder移除",
|
||||
appliedToWorkflow: "已应用到工作流",
|
||||
notConnectedToComfyUI: "未连接到ComfyUI",
|
||||
wsConnectionFailed: "WebSocket连接失败",
|
||||
@@ -1900,6 +1955,7 @@ const LANGUAGES = {
|
||||
deletedNImages: (n) => `已删除${n}张图像`,
|
||||
movedNImages: (n) => `已移动${n}张图像`,
|
||||
addedNImagesToGroup: (n, g) => `已将${n}张图像添加到「${g}」`,
|
||||
removedNImagesFromGroup: (n, g) => `已从「${g}」中移除${n}张图像`,
|
||||
favoritedNImages: (n) => `已收藏${n}张图像`,
|
||||
unfavoritedNImages: (n) => `已取消收藏${n}张图像`,
|
||||
unknownWorkflowFormat: "未知的工作流格式",
|
||||
@@ -2162,7 +2218,7 @@ const LANGUAGES = {
|
||||
galleryFolders: "文件夹",
|
||||
gallerySelectFolder: "选择文件夹以浏览图片。",
|
||||
galleryNoImages: "未找到图片。",
|
||||
gallerySearchPlaceholder: "搜索图片...",
|
||||
gallerySearchPlaceholder: "按名称、标签、提示词搜索...",
|
||||
galleryOutputDir: "图库输出文件夹",
|
||||
galleryOutputDirLabel: "输出文件夹路径",
|
||||
galleryOutputDirHint: "设置图库标签页浏览的ComfyUI输出文件夹。留空则使用ComfyUI默认输出目录。",
|
||||
@@ -2171,12 +2227,17 @@ const LANGUAGES = {
|
||||
galleryBulkSelected: "项已选择",
|
||||
galleryBulkDeselectAll: "取消全选",
|
||||
galleryBulkSelectAll: "全选",
|
||||
galleryBulkAddToGroup: "添加到分组...",
|
||||
galleryBulkAdd: "添加",
|
||||
galleryBulkAddToGroup: "选择分组",
|
||||
galleryBulkAdd: "添加到分组",
|
||||
galleryBulkGroupRemove: "从分组中删除",
|
||||
galleryBulkFavAll: "★ 全部收藏",
|
||||
galleryBulkUnfavAll: "☆ 全部取消收藏",
|
||||
galleryBulkCompare: "对比",
|
||||
galleryBulkMoveTo: "移动到...",
|
||||
galleryBulkDelete: "删除",
|
||||
galleryBulkExport: "导出",
|
||||
galleryBulkDelete: "删除文件",
|
||||
downloadStarted: "下载开始",
|
||||
exportCompleted: "导出完成。正在下载 ZIP 文件。",
|
||||
|
||||
tabAi: "AI TOOL",
|
||||
tabTagger: "Tagger",
|
||||
@@ -2309,7 +2370,9 @@ const LANGUAGES = {
|
||||
helpGen14: "Batch标签 — 右窗格(批量队列):6列 — Checkpoint / Lora / Prompt / Workflow / Sampler / Scheduler;每列有启用复选框(单选行为,每次仅一种);每列显示数量",
|
||||
helpGen15: "Sampler/Scheduler批次:在左窗格选择采样器或调度器,启用批次队列对应列后点击Generate;依次将每个值应用到KSampler节点逐一生成;列表从ComfyUI获取(需已连接)",
|
||||
helpFeederTitle: "GenerateUI Tab — Feeder 子标签",
|
||||
helpFeederDesc: "需要 comfyui-image-feeder 自定义节点。用于操控 ImageFeeder 节点,并对存储在 user/default/image-loop-data/ 中的图片库执行连续生成循环。",
|
||||
helpFeederDesc: "通过左侧面板顶部的 [图片循环] / [图库] 切换按钮可在两种模式间切换。",
|
||||
helpFeederImgloopTitle: "图片循环模式",
|
||||
helpFeederImgloopDesc: "需要 comfyui-image-feeder 自定义节点。用于操控 ImageFeeder 节点,并对存储在 user/default/image-loop-data/ 中的图片库执行连续生成循环。",
|
||||
helpFeeder1: "左侧面板 — 节点设置:从下拉框选择目标 ImageFeeder 节点;编辑所有节点参数(Directory、Sort Mode、Index、Start/End Index、Batch Size、Seed、Use Selection);点击 Apply 将更改写入当前工作流",
|
||||
helpFeeder2: "左侧面板 — 预设:将当前目录+选择文件保存为命名预设;加载或删除已保存的预设",
|
||||
helpFeeder3: "左侧面板 — Run:After gen 模式决定每次生成后的 index 行为 — Loop(回到0并无限循环)、Increment(递增 index,全部图片用完后自动停止)、Fixed(始终使用相同 index);点击 Run 开始循环,Stop 中断",
|
||||
@@ -2319,7 +2382,16 @@ const LANGUAGES = {
|
||||
helpFeeder7: "状态栏:显示当前文件夹路径,以及该文件夹内已选中图片数占总数的比例",
|
||||
helpFeeder8: "Run 时的种子:使用右侧面板的种子设置(随机/固定/递增/递减)— ImageFeeder 自身的 Seed 字段仅影响随机排序的顺序",
|
||||
helpFeeder9: "Index 同步:每次生成完成后节点通过 WebSocket 返回下一个 index;Index 字段自动更新,保持显示与执行状态一致",
|
||||
helpPrompt1: "AI助手(Ollama):模型选择、聊天咨询提示词、图片附件(视觉模型)",
|
||||
helpFeederGalTitle: "图库模式",
|
||||
helpFeederGalDesc: "使用内置的 WFS_GalleryFeeder 节点(无需外部插件)。将图库分组中的图片供给连续生成循环。",
|
||||
helpFeederGal1: "左侧面板 — 节点:从下拉框选择 WFS_GalleryFeeder 节点并点击 Apply 与工作流关联;选择来源分组(默认 __Feeder__)、Sort Mode、Index(当前图片位置)和 Seed",
|
||||
helpFeederGal2: "左侧面板 — Run 控制:After gen — Loop(回到开头并重复)、Increment(递进并在最后一张图停止)、Fixed(始终使用相同 index);点击 Run 开始循环,Stop 在当前生成完成后中断",
|
||||
helpFeederGal3: "中央面板 — 分组图片网格:显示所选分组中的所有图片;点击缩略图即可选中并跳转到该 index;当前选中图片高亮显示",
|
||||
helpFeederGal4: "右侧面板 — 预览:显示当前选中的输入图片;点击缩略图时更新",
|
||||
helpFeederGal5: "__Feeder__ 分组:自动预先创建的保留分组;不可重命名或删除;在图库标签页中点击每个缩略图上的 F 按钮可将图片添加到此分组",
|
||||
helpFeederGal6: "WFS_GalleryFeeder 画布控件:该节点在 ComfyUI 画布上直接添加了 Run / Stop / After Gen 组件——与 WFM 界面中的控件功能相同,无需打开 WFM 即可运行图库供给循环",
|
||||
helpSearchPlaceholder: "搜索帮助...",
|
||||
helpPrompt1: "AI助手(Ollama / LM Studio):模型选择、聊天咨询提示词、图片附件(视觉模型);后端和URL在设置标签页配置",
|
||||
helpPrompt2: "将AI回复应用到生成UI的提示词",
|
||||
helpPrompt3: "翻译功能:日\u2194英、中\u2194英",
|
||||
helpPrompt4: "预设管理:创建、编辑、正面/负面提示词剪贴板复制(PP/NP)",
|
||||
@@ -2332,7 +2404,7 @@ const LANGUAGES = {
|
||||
helpSettings2: "主题选择(13种预设)+ 自定义:颜色调整、背景图案(条纹、波点、棋盘格、SVG平铺)、字体选择(含日文显示字体在内的16种Google Fonts)",
|
||||
helpSettings3: "工作流数据文件夹路径更改/重置",
|
||||
helpSettings4: "ComfyUI连接URL设置和测试",
|
||||
helpSettings5: "Ollama URL、默认模型、连接测试",
|
||||
helpSettings5: "AI助手(提示词标签页):后端(Ollama / LM Studio)、API URL、默认模型、连接测试",
|
||||
helpSettings6: "默认工作流设置/取消",
|
||||
helpSettings7: "Eagle集成URL、自动保存开关",
|
||||
helpSettings8: "数据管理:将所有插件数据(设置、元数据、提示词等)导出为JSON文件,或导入以恢复。导入后请重启ComfyUI。",
|
||||
@@ -2363,11 +2435,11 @@ const LANGUAGES = {
|
||||
helpGallery1: "浏览 ComfyUI 输出文件夹中的图像 — 可以在 设置 > 图库输出文件夹 中设置文件夹路径",
|
||||
helpGallery2: "三列布局:文件夹树(左) | 图像网格(中) | 详情面板(右)",
|
||||
helpGallery3: "缩略图和表格视图模式;双击任何图像可在全屏灯箱中打开",
|
||||
helpGallery4: "工具栏过滤器:收藏 (★)、文本搜索、标签过滤、分组过滤、按日期/名称排序",
|
||||
helpGallery4: "工具栏过滤器:收藏 (★)、文本搜索(文件名・标签・提示词)、标签过滤、分组过滤、按日期/名称排序",
|
||||
helpGallery5: "文件夹树:点击加载图像,▶展开;'+ New'在选定文件夹内创建子文件夹;'Del'删除该文件夹及其所有内容",
|
||||
helpGallery6: "使用Ctrl+点击多选 — 批量操作:添加到分组、全部收藏、取消全部收藏、移动到...、删除",
|
||||
helpGallery7: "详情面板 — 信息(Info)标签:文件名、大小、日期、标签(添加/移除)、备注;'移动到...'将图像移至另一文件夹;'删除'永久删除",
|
||||
helpGallery8: "详情面板 — JSON标签:显示来自PNG嵌入数据(prompt / workflow键)或Generate UI标签保存的工作流JSON;「Copy & Send Canvas」按钮将工作流复制到剪贴板并存储以供标题拖拽到画布",
|
||||
helpGallery6: "多选:Ctrl+点击切换单张图像;Shift+点击从上次点击位置进行范围选择 — 批量操作栏:选择分组 → 「添加到分组」/「从分组中删除」;全部收藏/取消收藏;「对比」(2–4张);移动到...;删除文件",
|
||||
helpGallery7: "详情面板 — 信息(Info)标签:文件名、大小、日期、标签(添加/移除)、备注;'移动到...'将图像移至另一文件夹;'删除文件'永久删除",
|
||||
helpGallery8: "详情面板 — JSON标签:显示来自PNG嵌入数据(prompt / workflow键)或Generate UI标签保存的工作流JSON;「Copy & Send Canvas」按钮将工作流复制到剪贴板并直接发送到ComfyUI画布(UI和API格式均支持);若Workflow Studio不是从ComfyUI工具栏打开,UI格式将回退到标题拖拽",
|
||||
helpGallery9: "详情面板 — 分组(Groups)标签:对每个图像进行组的创建、分配、移除、重命名和删除",
|
||||
helpGallery10: "工作流自动保存:在Generate UI标签生成的图像,其工作流会自动保存到图库元数据,并在JSON标签中显示",
|
||||
helpGallery11: "支持PNG(tEXt/iTXt)、JPEG、WebP、GIF;PNG格式读取ComfyUI嵌入的JSON(prompt / workflow键)提取工作流",
|
||||
@@ -2404,7 +2476,7 @@ const LANGUAGES = {
|
||||
helpSidepanel14: "Information 标签 — 拖拽到画布:model 子标签拖拽可放置对应加载节点(Checkpoint → CheckpointLoaderSimple、VAE → VAELoader、Diffusion Model → UNETLoader、Text Encoder → CLIPLoader);双击也可放置到画布中央",
|
||||
helpSidepanel15: "Information 标签 — lora 子标签:可检测 LoraLoader、LoraLoaderModelOnly 及 Lora Loader (LoraManager) 节点(含API格式)的 LoRA;拖拽单个 LoRA 放置 LoraLoader;「Multiple LORA」区域可将全部 LoRA 一次性放入 Lora Loader (LoraManager) 节点并自动填入LoRA语法;Prompts 子标签:拖拽提示词放置预填文本的 CLIPTextEncode 节点;点击可查看全文并复制",
|
||||
helpSidepanel16: "A 标签(AI 工具):翻译、Chat、TOOLS 和设置子标签;Chat 支持与 LLM 的多轮对话;TOOLS 包含 VLM 图像分析和通配符生成;设置通过 localStorage 与 SPA 的 AI 标签共享",
|
||||
helpSidepanel17: "标题拖拽(Send to Canvas):在Workflow标签点击'Send to Canvas'或在Gallery标签点击'Copy & Send Canvas'后,面板标题变蓝并显示绿色●——将标题拖拽到画布即可加载工作流;加载后标题自动重置",
|
||||
helpSidepanel17: "Send to Canvas:在Workflow标签点击'Send to Canvas'或Gallery标签点击'Copy & Send Canvas',工作流直接发送到ComfyUI画布(支持UI和API所有格式);若Workflow Studio不是从ComfyUI工具栏打开,UI格式工作流将回退到标题拖拽(标题变蓝并显示绿色●——拖拽到画布加载)",
|
||||
helpAiTitle: "AI 标签页(A)",
|
||||
helpAi1: "4 面板布局 — Translation | Chat | TOOLS | Settings — 所有面板始终可见",
|
||||
helpAi2: "翻译面板:使用 Ollama 或 LM Studio 在日语、英语、中文或自定义语言(Free)之间翻译;⇄ 按钮同时互换语言和文本内容;选择自动保存",
|
||||
@@ -2419,7 +2491,7 @@ const LANGUAGES = {
|
||||
helpShortcuts4: "双击:打开详情弹窗",
|
||||
helpTroubleTitle: "故障排除",
|
||||
helpTrouble1: "无法连接ComfyUI:确认ComfyUI能否生成图片、在设置中验证URL、尝试刷新或重启",
|
||||
helpTrouble2: "无法连接Ollama:使用连接测试按钮、确认Ollama运行中且已下载模型",
|
||||
helpTrouble2: "无法连接AI助手:使用设置标签页的连接测试按钮;Ollama需确认已启动且模型已下载;LM Studio需确认服务器已启动且模型已加载",
|
||||
helpTrouble3: "工作流不显示:点击刷新按钮、确认能在ComfyUI中加载、尝试重启浏览器/ComfyUI",
|
||||
helpTrouble4: "图片生成失败:确认指定模型存在、验证ComfyUI连接、尝试重启",
|
||||
helpTrouble5: "LoRA Stack出现「No such file or directory」错误:该LoRA可能未被comfyui-lora-manager识别(已知问题)。请尝试其他LoRA,或检查该文件是否显示在Lora Manager自身的界面中",
|
||||
@@ -2450,13 +2522,13 @@ const LANGUAGES = {
|
||||
comfyuiUrlHint: "作为ComfyUI插件运行时留空(推荐同源)。仅在不同服务器时设置。",
|
||||
connectedCheck: "已连接 \u2713",
|
||||
failedConnect: "连接失败 \u2717",
|
||||
ollamaSettings: "Ollama 设置(提示词标签页)",
|
||||
ollamaUrl: "Ollama API URL",
|
||||
ollamaSettings: "AI助手设置(提示词标签页)",
|
||||
ollamaUrl: "API URL",
|
||||
ollamaDefaultModel: "默认模型",
|
||||
selectModel: "选择模型...",
|
||||
noModelsFound: "未找到模型",
|
||||
failedLoadModels: "获取模型列表失败",
|
||||
saveOllama: "保存Ollama设置",
|
||||
saveOllama: "保存AI助手设置",
|
||||
testConnection: "测试连接",
|
||||
ollamaConnected: "已连接 \u2713",
|
||||
ollamaFailed: "失败",
|
||||
@@ -2478,7 +2550,7 @@ const LANGUAGES = {
|
||||
importError: "导入失败",
|
||||
saveSettings: "保存设置",
|
||||
settingsSaved: "设置已保存",
|
||||
ollamaSaved: "Ollama设置已保存",
|
||||
ollamaSaved: "AI助手设置已保存",
|
||||
// -- Theme --
|
||||
themeLabel: "主题",
|
||||
themeDefault: "Deep Ocean Dark (默认)",
|
||||
|
||||
@@ -556,6 +556,10 @@ async function bulkMoveModels(destSubdir) {
|
||||
const ds = state.disabledModels[state.activeModelType];
|
||||
if (ds && ds.has(from)) { ds.delete(from); ds.add(to); }
|
||||
state.selectedModels.delete(from);
|
||||
for (const members of Object.values(state.modelGroups)) {
|
||||
const gi = members.indexOf(from);
|
||||
if (gi !== -1) members[gi] = to;
|
||||
}
|
||||
});
|
||||
if (state.selectedModel && data.moved.some((m) => m.from === state.selectedModel)) {
|
||||
state.selectedModel = null;
|
||||
|
||||
+101
-49
@@ -378,26 +378,70 @@ function renderPmGroups(container) {
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Ollama API helpers
|
||||
// AI Assistant helpers (Ollama / LM Studio)
|
||||
// ============================================
|
||||
|
||||
async function ollamaModels() {
|
||||
const res = await fetch("/api/wfm/ollama/models");
|
||||
return await res.json();
|
||||
const PROMPT_AI_KEY = "wfm_prompt_ai_settings";
|
||||
|
||||
function loadPromptAiSettings() {
|
||||
try { return JSON.parse(localStorage.getItem(PROMPT_AI_KEY) || "{}"); } catch { return {}; }
|
||||
}
|
||||
|
||||
async function ollamaTest() {
|
||||
const res = await fetch("/api/wfm/ollama/test", { method: "POST" });
|
||||
return await res.json();
|
||||
// バックエンド変更検知用: モデル一覧を取得した時点のバックエンド名を記録
|
||||
let _promptAiBackendForModels = null;
|
||||
|
||||
function getPromptAiConfig() {
|
||||
const s = loadPromptAiSettings();
|
||||
const backend = s.backend || "ollama";
|
||||
const url = (s.backendUrl || (backend === "ollama" ? "http://localhost:11434" : "http://localhost:1234")).replace(/\/$/, "");
|
||||
return { backend, url };
|
||||
}
|
||||
|
||||
async function ollamaChat(model, messages) {
|
||||
const res = await fetch("/api/wfm/ollama/chat", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ model, messages }),
|
||||
});
|
||||
return await res.json();
|
||||
async function fetchAiModels() {
|
||||
const { backend, url } = getPromptAiConfig();
|
||||
if (backend === "ollama") {
|
||||
const res = await fetch(`${url}/api/tags`);
|
||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||
return (await res.json()).models?.map(m => m.name) || [];
|
||||
} else {
|
||||
const res = await fetch(`${url}/v1/models`);
|
||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||
return ((await res.json()).data || []).map(m => m.id);
|
||||
}
|
||||
}
|
||||
|
||||
async function chatWithAi(model, messages) {
|
||||
const { backend, url } = getPromptAiConfig();
|
||||
if (backend === "ollama") {
|
||||
const res = await fetch(`${url}/api/chat`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ model, messages, stream: false }),
|
||||
});
|
||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||
return (await res.json()).message?.content || "";
|
||||
} else {
|
||||
// LM Studio: convert Ollama-style messages (with .images) to OpenAI content arrays
|
||||
const openAiMessages = messages.map(msg => {
|
||||
if (msg.images?.length) {
|
||||
return {
|
||||
role: msg.role,
|
||||
content: [
|
||||
{ type: "text", text: msg.content },
|
||||
...msg.images.map(b64 => ({ type: "image_url", image_url: { url: `data:image/jpeg;base64,${b64}` } })),
|
||||
],
|
||||
};
|
||||
}
|
||||
return { role: msg.role, content: msg.content };
|
||||
});
|
||||
const res = await fetch(`${url}/v1/chat/completions`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ model, messages: openAiMessages, stream: false }),
|
||||
});
|
||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||
return (await res.json()).choices?.[0]?.message?.content || "";
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================
|
||||
@@ -462,7 +506,7 @@ function clearChat() {
|
||||
if (chat) {
|
||||
chat.innerHTML = `
|
||||
<div class="wfm-ollama-welcome">
|
||||
<p>AI Assistant (Ollama)</p>
|
||||
<p>AI Assistant</p>
|
||||
<p>${t("assistantWelcome")}</p>
|
||||
</div>
|
||||
`;
|
||||
@@ -526,6 +570,24 @@ async function sendMessage() {
|
||||
const message = input.value.trim();
|
||||
if (!message) return;
|
||||
|
||||
// バックエンドが変更されていたらモデル一覧を自動更新
|
||||
const { backend } = getPromptAiConfig();
|
||||
if (backend !== _promptAiBackendForModels) {
|
||||
const status = document.getElementById("wfm-ollama-status");
|
||||
if (status) { status.textContent = `Switching to ${backend}...`; status.className = "wfm-ollama-status"; }
|
||||
try {
|
||||
const models = await fetchAiModels();
|
||||
const savedModel = loadPromptAiSettings().model || "";
|
||||
modelSelect.innerHTML = models.length
|
||||
? models.map(name => `<option value="${name}" ${name === savedModel ? "selected" : ""}>${name}</option>`).join("")
|
||||
: `<option value="">${t("noModelsFound")}</option>`;
|
||||
_promptAiBackendForModels = backend;
|
||||
if (status) { status.textContent = `${models.length} models [${backend}]`; status.className = "wfm-ollama-status connected"; }
|
||||
} catch {
|
||||
if (status) { status.textContent = t("failedConnect"); status.className = "wfm-ollama-status error"; }
|
||||
}
|
||||
}
|
||||
|
||||
const model = modelSelect.value;
|
||||
if (!model) {
|
||||
showToast(t("selectModelFirst"), "error");
|
||||
@@ -545,16 +607,11 @@ async function sendMessage() {
|
||||
if (sendBtn) sendBtn.disabled = true;
|
||||
|
||||
try {
|
||||
const data = await ollamaChat(model, ollamaState.chatHistory);
|
||||
if (data.status === "success" && data.message) {
|
||||
const reply = data.message.content;
|
||||
addChatMessage("assistant", reply);
|
||||
ollamaState.chatHistory.push({ role: "assistant", content: reply });
|
||||
ollamaState.attachedImage = null;
|
||||
updateAttachmentDisplay();
|
||||
} else {
|
||||
showToast(t("error") + ": " + (data.error || data.message || "No response"), "error");
|
||||
}
|
||||
const reply = await chatWithAi(model, ollamaState.chatHistory);
|
||||
addChatMessage("assistant", reply);
|
||||
ollamaState.chatHistory.push({ role: "assistant", content: reply });
|
||||
ollamaState.attachedImage = null;
|
||||
updateAttachmentDisplay();
|
||||
} catch (err) {
|
||||
showToast(t("error") + ": " + err.message, "error");
|
||||
} finally {
|
||||
@@ -597,12 +654,8 @@ async function sendTranslate(direction) {
|
||||
};
|
||||
const prompt = prompts[direction];
|
||||
|
||||
const data = await ollamaChat(model, [{ role: "user", content: prompt }]);
|
||||
if (data.status === "success" && data.message) {
|
||||
addChatMessage("assistant", data.message.content);
|
||||
} else {
|
||||
showToast(t("error") + ": No response", "error");
|
||||
}
|
||||
const reply = await chatWithAi(model, [{ role: "user", content: prompt }]);
|
||||
addChatMessage("assistant", reply);
|
||||
} catch (err) {
|
||||
showToast(t("error") + ": " + err.message, "error");
|
||||
} finally {
|
||||
@@ -858,20 +911,23 @@ function wcUpdateFilePicker() {
|
||||
// ============================================
|
||||
|
||||
export function initPromptTab() {
|
||||
// Ollama model refresh
|
||||
// AI model refresh
|
||||
async function refreshModels() {
|
||||
const select = document.getElementById("wfm-ollama-model");
|
||||
const status = document.getElementById("wfm-ollama-status");
|
||||
const { backend } = getPromptAiConfig();
|
||||
try {
|
||||
const data = await ollamaModels();
|
||||
if (data.status === "success" && data.models) {
|
||||
select.innerHTML = data.models
|
||||
.map((m) => `<option value="${m.name}">${m.name}</option>`)
|
||||
.join("");
|
||||
if (status) {
|
||||
status.textContent = `${data.models.length} models`;
|
||||
status.className = "wfm-ollama-status connected";
|
||||
}
|
||||
const models = await fetchAiModels();
|
||||
const savedModel = loadPromptAiSettings().model || "";
|
||||
if (select) {
|
||||
select.innerHTML = models.length
|
||||
? models.map(name => `<option value="${name}" ${name === savedModel ? "selected" : ""}>${name}</option>`).join("")
|
||||
: `<option value="">${t("noModelsFound")}</option>`;
|
||||
}
|
||||
_promptAiBackendForModels = backend;
|
||||
if (status) {
|
||||
status.textContent = `${models.length} models [${backend}]`;
|
||||
status.className = "wfm-ollama-status connected";
|
||||
}
|
||||
} catch {
|
||||
if (status) {
|
||||
@@ -891,15 +947,11 @@ export function initPromptTab() {
|
||||
const status = document.getElementById("wfm-ollama-status");
|
||||
if (status) { status.textContent = "Testing..."; status.className = "wfm-ollama-status"; }
|
||||
try {
|
||||
const data = await ollamaTest();
|
||||
if (data.connected) {
|
||||
if (status) { status.textContent = t("connected"); status.className = "wfm-ollama-status connected"; }
|
||||
await refreshModels();
|
||||
} else {
|
||||
if (status) { status.textContent = t("failedConnect"); status.className = "wfm-ollama-status error"; }
|
||||
}
|
||||
await fetchAiModels();
|
||||
if (status) { status.textContent = t("connectedCheck"); status.className = "wfm-ollama-status connected"; }
|
||||
await refreshModels();
|
||||
} catch {
|
||||
if (status) { status.textContent = t("error"); status.className = "wfm-ollama-status error"; }
|
||||
if (status) { status.textContent = t("failedConnect"); status.className = "wfm-ollama-status error"; }
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+88
-42
@@ -637,28 +637,38 @@ export async function initSettingsTab() {
|
||||
<div id="wfm-settings-url-status" style="font-size:12px;margin-top:4px;"></div>
|
||||
</details>
|
||||
|
||||
<!-- Ollama Settings -->
|
||||
<!-- AI Assistant Settings (Prompt Tab) -->
|
||||
<details class="wfm-settings-section">
|
||||
<summary class="wfm-settings-summary">${t("ollamaSettings")}</summary>
|
||||
<div class="wfm-form-group">
|
||||
<label>${t("aiSettingsBackend")}</label>
|
||||
<div class="wfm-ai-backend-row">
|
||||
<label class="wfm-ai-radio-label">
|
||||
<input type="radio" name="wfm-prompt-ai-backend" value="ollama"> Ollama
|
||||
</label>
|
||||
<label class="wfm-ai-radio-label">
|
||||
<input type="radio" name="wfm-prompt-ai-backend" value="lmstudio"> LM Studio
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wfm-form-group">
|
||||
<label>${t("ollamaUrl")}</label>
|
||||
<input type="text" class="wfm-input" id="wfm-settings-ollama-url"
|
||||
value="${serverSettings.ollama_url || "http://localhost:11434"}"
|
||||
<input type="text" class="wfm-input" id="wfm-settings-prompt-ai-url"
|
||||
placeholder="http://localhost:11434">
|
||||
</div>
|
||||
<div class="wfm-form-group">
|
||||
<label>${t("ollamaDefaultModel")}</label>
|
||||
<div style="display:flex;gap:8px;">
|
||||
<select class="wfm-select" id="wfm-settings-ollama-model" style="flex:1;">
|
||||
<select class="wfm-select" id="wfm-settings-prompt-ai-model" style="flex:1;">
|
||||
<option value="">${t("selectModel")}</option>
|
||||
</select>
|
||||
<button class="wfm-btn wfm-btn-sm" id="wfm-settings-ollama-refresh">${t("refresh")}</button>
|
||||
<button class="wfm-btn wfm-btn-sm" id="wfm-settings-prompt-ai-refresh">${t("refresh")}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:flex;gap:8px;margin-top:8px;">
|
||||
<button class="wfm-btn wfm-btn-primary wfm-btn-sm" id="wfm-settings-ollama-save">${t("saveOllama")}</button>
|
||||
<button class="wfm-btn wfm-btn-sm" id="wfm-settings-ollama-test">${t("testConnection")}</button>
|
||||
<span id="wfm-settings-ollama-status" style="font-size:12px;line-height:28px;"></span>
|
||||
<button class="wfm-btn wfm-btn-primary wfm-btn-sm" id="wfm-settings-prompt-ai-save">${t("saveOllama")}</button>
|
||||
<button class="wfm-btn wfm-btn-sm" id="wfm-settings-prompt-ai-test">${t("testConnection")}</button>
|
||||
<span id="wfm-settings-prompt-ai-status" style="font-size:12px;line-height:28px;"></span>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
@@ -1054,54 +1064,90 @@ export async function initSettingsTab() {
|
||||
}
|
||||
});
|
||||
|
||||
// --- Ollama model list loader ---
|
||||
async function loadOllamaModels() {
|
||||
const select = document.getElementById("wfm-settings-ollama-model");
|
||||
// --- AI Assistant (Prompt Tab) settings ---
|
||||
const PROMPT_AI_KEY = "wfm_prompt_ai_settings";
|
||||
const loadPromptAiCfg = () => {
|
||||
try { return JSON.parse(localStorage.getItem(PROMPT_AI_KEY) || "{}"); } catch { return {}; }
|
||||
};
|
||||
const savePromptAiCfg = (patch) => {
|
||||
const data = { ...loadPromptAiCfg(), ...patch };
|
||||
localStorage.setItem(PROMPT_AI_KEY, JSON.stringify(data));
|
||||
};
|
||||
|
||||
// Restore saved values into UI
|
||||
const promptAiSaved = loadPromptAiCfg();
|
||||
const promptAiBackendSaved = promptAiSaved.backend || "ollama";
|
||||
document.querySelectorAll('input[name="wfm-prompt-ai-backend"]').forEach(r => {
|
||||
r.checked = r.value === promptAiBackendSaved;
|
||||
});
|
||||
const promptAiUrlEl = document.getElementById("wfm-settings-prompt-ai-url");
|
||||
if (promptAiUrlEl) {
|
||||
promptAiUrlEl.value = promptAiSaved.backendUrl || "";
|
||||
promptAiUrlEl.placeholder = promptAiBackendSaved === "ollama" ? "http://localhost:11434" : "http://localhost:1234";
|
||||
}
|
||||
|
||||
// Backend change → update URL placeholder
|
||||
document.querySelectorAll('input[name="wfm-prompt-ai-backend"]').forEach(r => {
|
||||
r.addEventListener("change", () => {
|
||||
const backend = document.querySelector('input[name="wfm-prompt-ai-backend"]:checked')?.value || "ollama";
|
||||
if (promptAiUrlEl) promptAiUrlEl.placeholder = backend === "ollama" ? "http://localhost:11434" : "http://localhost:1234";
|
||||
});
|
||||
});
|
||||
|
||||
// Load models directly from the selected backend
|
||||
async function loadPromptAiModels() {
|
||||
const select = document.getElementById("wfm-settings-prompt-ai-model");
|
||||
if (!select) return;
|
||||
const backend = document.querySelector('input[name="wfm-prompt-ai-backend"]:checked')?.value || "ollama";
|
||||
const url = (promptAiUrlEl?.value.trim() || (backend === "ollama" ? "http://localhost:11434" : "http://localhost:1234")).replace(/\/$/, "");
|
||||
try {
|
||||
const res = await fetch("/api/wfm/ollama/models");
|
||||
const data = await res.json();
|
||||
const models = data.models || [];
|
||||
const savedModel = serverSettings.ollama_model || "llava";
|
||||
let models = [];
|
||||
if (backend === "ollama") {
|
||||
const res = await fetch(`${url}/api/tags`);
|
||||
models = (await res.json()).models?.map(m => m.name) || [];
|
||||
} else {
|
||||
const res = await fetch(`${url}/v1/models`);
|
||||
models = ((await res.json()).data || []).map(m => m.id);
|
||||
}
|
||||
const saved = loadPromptAiCfg().model || "";
|
||||
select.innerHTML = models.length
|
||||
? models.map((m) => `<option value="${m.name}" ${m.name === savedModel ? "selected" : ""}>${m.name}</option>`).join("")
|
||||
? models.map(name => `<option value="${name}" ${name === saved ? "selected" : ""}>${name}</option>`).join("")
|
||||
: `<option value="">${t("noModelsFound")}</option>`;
|
||||
} catch {
|
||||
select.innerHTML = `<option value="">${t("failedLoadModels")}</option>`;
|
||||
}
|
||||
}
|
||||
await loadOllamaModels();
|
||||
await loadPromptAiModels();
|
||||
|
||||
// Refresh Ollama models
|
||||
document.getElementById("wfm-settings-ollama-refresh")?.addEventListener("click", loadOllamaModels);
|
||||
document.getElementById("wfm-settings-prompt-ai-refresh")?.addEventListener("click", loadPromptAiModels);
|
||||
|
||||
// Test Ollama connection
|
||||
document.getElementById("wfm-settings-ollama-test")?.addEventListener("click", async () => {
|
||||
const statusEl = document.getElementById("wfm-settings-ollama-status");
|
||||
statusEl.textContent = "Testing...";
|
||||
statusEl.style.color = "var(--wfm-text-secondary)";
|
||||
document.getElementById("wfm-settings-prompt-ai-test")?.addEventListener("click", async () => {
|
||||
const statusEl = document.getElementById("wfm-settings-prompt-ai-status");
|
||||
const backend = document.querySelector('input[name="wfm-prompt-ai-backend"]:checked')?.value || "ollama";
|
||||
const url = (promptAiUrlEl?.value.trim() || (backend === "ollama" ? "http://localhost:11434" : "http://localhost:1234")).replace(/\/$/, "");
|
||||
if (statusEl) { statusEl.textContent = t("aiStatusConnecting"); statusEl.style.color = "var(--wfm-text-secondary)"; }
|
||||
try {
|
||||
const res = await fetch("/api/wfm/ollama/test", { method: "POST" });
|
||||
const data = await res.json();
|
||||
statusEl.textContent = data.connected ? t("ollamaConnected") : `${t("ollamaFailed")}: ${data.message}`;
|
||||
statusEl.style.color = data.connected ? "var(--wfm-success)" : "var(--wfm-danger)";
|
||||
let count = 0;
|
||||
if (backend === "ollama") {
|
||||
const res = await fetch(`${url}/api/tags`);
|
||||
count = ((await res.json()).models || []).length;
|
||||
} else {
|
||||
const res = await fetch(`${url}/v1/models`);
|
||||
count = ((await res.json()).data || []).length;
|
||||
}
|
||||
if (statusEl) { statusEl.textContent = `${t("ollamaConnected")} (${count} models)`; statusEl.style.color = "var(--wfm-success)"; }
|
||||
await loadPromptAiModels();
|
||||
} catch (err) {
|
||||
statusEl.textContent = `${t("error")}: ${err.message}`;
|
||||
statusEl.style.color = "var(--wfm-danger)";
|
||||
if (statusEl) { statusEl.textContent = `${t("ollamaFailed")}: ${err.message}`; statusEl.style.color = "var(--wfm-danger)"; }
|
||||
}
|
||||
});
|
||||
|
||||
// Save Ollama settings (to server)
|
||||
document.getElementById("wfm-settings-ollama-save")?.addEventListener("click", async () => {
|
||||
const ollamaUrl = document.getElementById("wfm-settings-ollama-url")?.value.trim() || "http://localhost:11434";
|
||||
const ollamaModel = document.getElementById("wfm-settings-ollama-model")?.value || "";
|
||||
try {
|
||||
await saveServerSettings({ ollama_url: ollamaUrl, ollama_model: ollamaModel });
|
||||
serverSettings.ollama_url = ollamaUrl;
|
||||
serverSettings.ollama_model = ollamaModel;
|
||||
showToast(t("ollamaSaved"), "success");
|
||||
} catch (err) {
|
||||
showToast(`${t("saveError")}: ${err.message}`, "error");
|
||||
}
|
||||
document.getElementById("wfm-settings-prompt-ai-save")?.addEventListener("click", () => {
|
||||
const backend = document.querySelector('input[name="wfm-prompt-ai-backend"]:checked')?.value || "ollama";
|
||||
const url = promptAiUrlEl?.value.trim() || "";
|
||||
const model = document.getElementById("wfm-settings-prompt-ai-model")?.value || "";
|
||||
savePromptAiCfg({ backend, backendUrl: url, model });
|
||||
showToast(t("ollamaSaved"), "success");
|
||||
});
|
||||
|
||||
// CivitAI host select
|
||||
|
||||
+3
-2
@@ -2,13 +2,14 @@
|
||||
* Shared utilities
|
||||
*/
|
||||
|
||||
// HTMLエスケープ(属性値で使うため " も必ずエスケープする)
|
||||
// HTMLエスケープ(属性値・テキストコンテンツ両方で安全に使える)
|
||||
export function escapeHtml(s) {
|
||||
return String(s)
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """);
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
// localStorage からJSONを安全に読む(不正JSON・未設定時はfallback)
|
||||
|
||||
@@ -48,6 +48,18 @@ function saveBadgePalette(palette) {
|
||||
|
||||
function sendToCanvas(workflowData) {
|
||||
try {
|
||||
// window.opener経由でComfyUIキャンバスに直接ロード(推奨)
|
||||
if (window.opener && typeof window.opener.wfmReceiveWorkflow === "function") {
|
||||
window.opener.wfmReceiveWorkflow(workflowData);
|
||||
showToast(t("workflowSentToCanvas"), "success");
|
||||
return;
|
||||
}
|
||||
// フォールバック: localStorage + タイトルドラッグ(UI形式のみ)
|
||||
const fmt = comfyWorkflow.detectFormat(workflowData);
|
||||
if (fmt === "api") {
|
||||
showToast(t("apiFormatCanvasNoOpener"), "error");
|
||||
return;
|
||||
}
|
||||
localStorage.setItem("wfm_pending_workflow", JSON.stringify(workflowData));
|
||||
showToast(t("workflowSentToCanvas"), "success");
|
||||
} catch (err) {
|
||||
|
||||
+94
-7
@@ -453,6 +453,14 @@
|
||||
<div class="wfm-feeder-layout">
|
||||
<!-- Left: Node selector + params + presets -->
|
||||
<div class="wfm-feeder-settings">
|
||||
<!-- Mode toggle -->
|
||||
<div style="display:flex;gap:4px;margin-bottom:10px;">
|
||||
<button id="wfm-feeder-mode-loop" class="wfm-btn wfm-btn-sm wfm-btn-primary" data-mode="loop">Image Loop</button>
|
||||
<button id="wfm-feeder-mode-gallery" class="wfm-btn wfm-btn-sm" data-mode="gallery">Gallery</button>
|
||||
</div>
|
||||
|
||||
<!-- Image Loop mode section -->
|
||||
<div id="wfm-feeder-loop-section">
|
||||
<div class="wfm-feeder-pane-header">ImageFeeder Node</div>
|
||||
<div style="display:flex;gap:6px;align-items:center;margin-bottom:8px;">
|
||||
<select id="wfm-feeder-node-sel" class="wfm-select" style="flex:1;min-width:0;"></select>
|
||||
@@ -519,10 +527,56 @@
|
||||
<button id="wfm-feeder-run-btn" class="wfm-btn wfm-btn-primary" style="flex:1;">▶ Run</button>
|
||||
<button id="wfm-feeder-stop-btn" class="wfm-btn wfm-btn-danger" style="flex:1;" disabled>■ Stop</button>
|
||||
</div>
|
||||
</div><!-- /wfm-feeder-loop-section -->
|
||||
|
||||
<!-- Gallery mode section -->
|
||||
<div id="wfm-feeder-gal-section" style="display:none;">
|
||||
<div class="wfm-feeder-pane-header">Gallery Feeder Node</div>
|
||||
<div style="display:flex;gap:6px;align-items:center;margin-bottom:8px;">
|
||||
<select id="wfm-feeder-gal-node-sel" class="wfm-select" style="flex:1;min-width:0;"></select>
|
||||
<button id="wfm-feeder-gal-apply-btn" class="wfm-btn wfm-btn-primary" style="white-space:nowrap;">Apply</button>
|
||||
</div>
|
||||
<div class="wfm-feeder-field-row">
|
||||
<label class="wfm-feeder-label">Group</label>
|
||||
<select id="wfm-feeder-gal-group" class="wfm-select wfm-feeder-input"></select>
|
||||
</div>
|
||||
<div class="wfm-feeder-field-row">
|
||||
<label class="wfm-feeder-label">Sort Mode</label>
|
||||
<select id="wfm-feeder-gal-sort" class="wfm-select wfm-feeder-input">
|
||||
<option value="filename_asc">Filename A-Z</option>
|
||||
<option value="filename_desc">Filename Z-A</option>
|
||||
<option value="random">Random</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="wfm-feeder-field-row">
|
||||
<label class="wfm-feeder-label">Index</label>
|
||||
<input type="number" id="wfm-feeder-gal-index" class="wfm-input wfm-feeder-input" value="0" min="0">
|
||||
</div>
|
||||
<div class="wfm-feeder-field-row">
|
||||
<label class="wfm-feeder-label">Seed</label>
|
||||
<input type="number" id="wfm-feeder-gal-seed" class="wfm-input wfm-feeder-input" value="0">
|
||||
</div>
|
||||
<div class="wfm-feeder-pane-header" style="margin-top:12px;">Run</div>
|
||||
<div class="wfm-feeder-field-row">
|
||||
<label class="wfm-feeder-label">After gen</label>
|
||||
<select id="wfm-feeder-gal-control-after" class="wfm-select wfm-feeder-input">
|
||||
<option value="loop">Loop</option>
|
||||
<option value="increment">Increment</option>
|
||||
<option value="fixed">Fixed</option>
|
||||
</select>
|
||||
</div>
|
||||
<div style="display:flex;gap:8px;margin-top:4px;">
|
||||
<button id="wfm-feeder-gal-run-btn" class="wfm-btn wfm-btn-primary" style="flex:1;">▶ Run</button>
|
||||
<button id="wfm-feeder-gal-stop-btn" class="wfm-btn wfm-btn-danger" style="flex:1;" disabled>■ Stop</button>
|
||||
</div>
|
||||
<div id="wfm-feeder-gal-status" style="font-size:11px;color:var(--wfm-text-secondary);margin-top:6px;"></div>
|
||||
</div><!-- /wfm-feeder-gal-section -->
|
||||
</div>
|
||||
|
||||
<!-- Center: Image Library -->
|
||||
<div class="wfm-feeder-library">
|
||||
<!-- Image Loop library -->
|
||||
<div id="wfm-feeder-loop-library">
|
||||
<!-- Status bar -->
|
||||
<div id="wfm-feeder-status" class="wfm-feeder-status-bar">Select a folder</div>
|
||||
|
||||
@@ -552,6 +606,17 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /wfm-feeder-loop-library -->
|
||||
|
||||
<!-- Gallery mode library -->
|
||||
<div id="wfm-feeder-gal-library" style="display:none;height:100%;">
|
||||
<div class="wfm-feeder-pane-header" style="display:flex;align-items:center;justify-content:space-between;">
|
||||
<span>Group Images</span>
|
||||
</div>
|
||||
<div id="wfm-feeder-gal-grid" class="wfm-feeder-grid" style="flex:1;overflow-y:auto;">
|
||||
<div class="wfm-feeder-grid-msg">Select a group</div>
|
||||
</div>
|
||||
</div><!-- /wfm-feeder-gal-library -->
|
||||
</div>
|
||||
|
||||
<!-- Right: Preview -->
|
||||
@@ -671,7 +736,7 @@
|
||||
<div id="wfm-ollama-attachments" class="wfm-ollama-attachments"></div>
|
||||
<div id="wfm-ollama-chat" class="wfm-ollama-chat">
|
||||
<div class="wfm-ollama-welcome">
|
||||
<p>AI Assistant (Ollama)</p>
|
||||
<p>AI Assistant</p>
|
||||
<p>Attach images, generate prompts, translate, or ask for improvements.</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -909,6 +974,9 @@
|
||||
<div class="wfm-help-layout">
|
||||
<!-- Left Sidebar -->
|
||||
<nav class="wfm-help-sidebar">
|
||||
<div class="wfm-help-search-wrap">
|
||||
<input id="wfm-help-search" class="wfm-help-search" type="text" placeholder="Search help...">
|
||||
</div>
|
||||
<div class="wfm-help-nav">
|
||||
<button class="wfm-help-nav-item active" data-help-page="about">About</button>
|
||||
<button class="wfm-help-nav-item" data-help-page="workflow">Workflow Tab</button>
|
||||
@@ -985,7 +1053,10 @@
|
||||
<div class="wfm-help-page" id="wfm-help-page-feeder">
|
||||
<div class="wfm-help-card">
|
||||
<h3 id="wfm-help-feeder-title">GenerateUI Tab — Feeder subtab</h3>
|
||||
<p id="wfm-help-feeder-desc">Requires the comfyui-image-feeder custom node. Controls ImageFeeder nodes and runs continuous generation loops over an image library stored in user/default/image-loop-data/.</p>
|
||||
<p id="wfm-help-feeder-desc">Two modes switchable via the [Image Loop] / [Gallery] toggle at the top of the left pane.</p>
|
||||
|
||||
<h4 id="wfm-help-feeder-imgloop-title" style="margin:10px 0 4px;color:var(--wfm-accent)">Image Loop mode</h4>
|
||||
<p id="wfm-help-feeder-imgloop-desc">Requires the comfyui-image-feeder custom node. Controls ImageFeeder nodes and runs continuous generation loops over an image library stored in user/default/image-loop-data/.</p>
|
||||
<ul>
|
||||
<li id="wfm-help-feeder-1">Left pane — Node settings: select the target ImageFeeder node from the dropdown; edit all node parameters (Directory, Sort Mode, Index, Start/End Index, Batch Size, Seed, Use Selection); click Apply to write changes to the loaded workflow</li>
|
||||
<li id="wfm-help-feeder-2">Left pane — Presets: save the current directory + selection as a named preset; load or delete saved presets</li>
|
||||
@@ -997,6 +1068,17 @@
|
||||
<li id="wfm-help-feeder-8">Seed during Run: uses the right-pane seed setting (Random / Fixed / Increment / Decrement) — the ImageFeeder's own Seed field controls random sort order only</li>
|
||||
<li id="wfm-help-feeder-9">Index sync: after each generation the node returns the next index via WebSocket; the Index field updates automatically so the display stays in sync</li>
|
||||
</ul>
|
||||
|
||||
<h4 id="wfm-help-feeder-gal-title" style="margin:14px 0 4px;color:var(--wfm-accent)">Gallery mode</h4>
|
||||
<p id="wfm-help-feeder-gal-desc">Uses the built-in WFS_GalleryFeeder node (no external plugin required). Feeds images from a Gallery group into a continuous generation loop.</p>
|
||||
<ul>
|
||||
<li id="wfm-help-feeder-gal-1">Left pane — Node: select a WFS_GalleryFeeder node from the dropdown and click Apply to link it to the workflow; select the source group (defaults to <b>__Feeder__</b>), Sort Mode, Index (current image position), and Seed</li>
|
||||
<li id="wfm-help-feeder-gal-2">Left pane — Run controls: <b>After gen</b> — Loop (wrap to start and repeat), Increment (advance and stop at last image), Fixed (always use the same index); click <b>Run</b> to start the loop, <b>Stop</b> to interrupt after the current generation</li>
|
||||
<li id="wfm-help-feeder-gal-3">Center pane — Group image grid: shows all images in the selected group; click a thumbnail to select it and jump to that index; the selected image is highlighted</li>
|
||||
<li id="wfm-help-feeder-gal-4">Right pane — Preview: displays the currently selected input image; updates when a thumbnail is clicked</li>
|
||||
<li id="wfm-help-feeder-gal-5"><b>__Feeder__ group</b>: reserved group pre-created automatically; cannot be renamed or deleted; add images to it from the Gallery tab using the <b>F</b> overlay button on each thumbnail</li>
|
||||
<li id="wfm-help-feeder-gal-6"><b>WFS_GalleryFeeder canvas controls</b>: the node also has Run / Stop / After Gen widgets added directly on the ComfyUI canvas — these work the same as the WFM UI controls and allow running the gallery feeder loop without opening WFM</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1073,12 +1155,13 @@
|
||||
<li id="wfm-help-gallery-1">Browse images in the ComfyUI output folder — set the folder path in Settings > Gallery Output Folder</li>
|
||||
<li id="wfm-help-gallery-2">3-column layout: folder tree (left) | image grid (center) | detail panel (right)</li>
|
||||
<li id="wfm-help-gallery-3">Thumbnail and Table view modes; double-click any image to open fullscreen lightbox</li>
|
||||
<li id="wfm-help-gallery-4">Toolbar filters: favorites (★), text search, tag filter, group filter, sort by date/name</li>
|
||||
<li id="wfm-help-gallery-4">Toolbar filters: favorites (★), text search (filename / tag / prompt), tag filter, group filter, sort by date/name</li>
|
||||
<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-6">Multi-select with Ctrl+click — bulk bar: select group → 'Add to Group' / 'Remove from Group'; 'Favorite All' / 'Unfavorite All'; 'Compare' (2–4 images); 'Move To...'; '<b>Export</b>' (downloads all selected images as a ZIP file); 'Delete File'</li>
|
||||
<li id="wfm-help-gallery-7">Detail panel — Info tab: filename, size, date, tags (add/remove), memo; <b>download icon</b> (on image hover) to download the single image; "Move To..." moves the image to another folder, "Delete File" removes it permanently</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; 'Copy & Send Canvas' button copies to clipboard and stores the workflow for title-drag to canvas</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-9">Detail panel — Groups tab: create, assign, remove, rename, and delete groups per image; the <b>__Feeder__</b> group is reserved (shown with 🔒) and cannot be renamed or deleted — rename and delete buttons are disabled when it is selected</li>
|
||||
<li id="wfm-help-gallery-15"><b>F button</b> (cyan overlay, top-left of each thumbnail): toggle the image in/out of the <b>__Feeder__</b> group with a single click; active state stays visible (cyan) when the image is already in the group; use this to quickly queue images for the Feeder tab Gallery mode</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>
|
||||
@@ -1232,6 +1315,7 @@
|
||||
<select id="wfm-gallery-group-filter" class="wfm-select wfm-toolbar-select">
|
||||
<option value="">All Groups</option>
|
||||
</select>
|
||||
<button id="wfm-gallery-fc-btn" class="wfm-btn wfm-btn-sm" title="Clear Feeder Group (__Feeder__)">FC</button>
|
||||
<select id="wfm-gallery-sort" class="wfm-select wfm-toolbar-select">
|
||||
<option value="date_desc">Date (Newest)</option>
|
||||
<option value="date_asc">Date (Oldest)</option>
|
||||
@@ -1254,9 +1338,12 @@
|
||||
<option value=""></option>
|
||||
</select>
|
||||
<button id="wfm-gallery-bulk-group-add" class="wfm-btn wfm-btn-sm wfm-btn-primary"></button>
|
||||
<button id="wfm-gallery-bulk-group-remove" class="wfm-btn wfm-btn-sm"></button>
|
||||
<button id="wfm-gallery-bulk-fav" class="wfm-btn wfm-btn-sm"></button>
|
||||
<button id="wfm-gallery-bulk-unfav" class="wfm-btn wfm-btn-sm"></button>
|
||||
<button id="wfm-gallery-bulk-compare" class="wfm-btn wfm-btn-sm" style="display:none;"></button>
|
||||
<button id="wfm-gallery-bulk-move" class="wfm-btn wfm-btn-sm"></button>
|
||||
<button id="wfm-gallery-bulk-export" class="wfm-btn wfm-btn-sm"></button>
|
||||
<button id="wfm-gallery-bulk-delete" class="wfm-btn wfm-btn-sm wfm-btn-danger"></button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1290,7 +1377,7 @@
|
||||
<span id="wfm-gallery-detail-filename" class="wfm-gallery-detail-filename"></span>
|
||||
</div>
|
||||
<!-- サムネイルプレビュー -->
|
||||
<div id="wfm-gallery-detail-preview" class="wfm-gallery-detail-preview">
|
||||
<div id="wfm-gallery-detail-preview" class="wfm-gallery-detail-preview wfm-gallery-preview-container">
|
||||
<span class="wfm-placeholder">No selection</span>
|
||||
</div>
|
||||
<!-- タブナビ -->
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
/**
|
||||
* WFS_GalleryFeeder – ComfyUI canvas extension
|
||||
* Adds "After Gen", Run, and Stop controls directly on the node widget area.
|
||||
*/
|
||||
import { app } from "../../scripts/app.js";
|
||||
|
||||
const FEEDER_GROUP = "__Feeder__";
|
||||
|
||||
// Per-node runtime state (keyed by node.id)
|
||||
const _ns = new Map();
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────
|
||||
|
||||
async function fetchGroupImages(groupName) {
|
||||
try {
|
||||
const res = await fetch(`/wfm/gallery/groups/${encodeURIComponent(groupName)}/images`);
|
||||
if (!res.ok) return [];
|
||||
return (await res.json()).images || [];
|
||||
} catch { return []; }
|
||||
}
|
||||
|
||||
function getOrCreate(nodeId) {
|
||||
if (!_ns.has(nodeId)) {
|
||||
_ns.set(nodeId, { running: false, stopFlag: false, idx: 0, images: [] });
|
||||
}
|
||||
return _ns.get(nodeId);
|
||||
}
|
||||
|
||||
function getInputWidget(node, name) {
|
||||
return node.widgets?.find(w => w.name === name);
|
||||
}
|
||||
|
||||
function setWidgetValue(node, name, value) {
|
||||
const w = getInputWidget(node, name);
|
||||
if (!w) return;
|
||||
w.value = value;
|
||||
if (w.callback) w.callback(value);
|
||||
app.canvas?.setDirty(true, true);
|
||||
}
|
||||
|
||||
/** Resolves when the current prompt finishes (executing=null, interrupted), rejects on error. */
|
||||
function waitForExecution() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const cleanup = () => {
|
||||
app.api.removeEventListener("executing", onExecuting);
|
||||
app.api.removeEventListener("execution_error", onError);
|
||||
app.api.removeEventListener("execution_interrupted", onInterrupted);
|
||||
};
|
||||
const onExecuting = ({ detail }) => { if (detail === null) { cleanup(); resolve(); } };
|
||||
const onError = ({ detail }) => { cleanup(); reject(new Error(detail?.exception_message || "Execution error")); };
|
||||
const onInterrupted = () => { cleanup(); resolve(); }; // treat interrupt as "done"
|
||||
|
||||
app.api.addEventListener("executing", onExecuting);
|
||||
app.api.addEventListener("execution_error", onError);
|
||||
app.api.addEventListener("execution_interrupted", onInterrupted);
|
||||
});
|
||||
}
|
||||
|
||||
function updateRunBtn(node) {
|
||||
const st = getOrCreate(node.id);
|
||||
if (node._wfsRunWidget) node._wfsRunWidget.name = st.running ? "⏳ Running..." : "▶ Run";
|
||||
app.canvas?.setDirty(true, true);
|
||||
}
|
||||
|
||||
function wfsToast(msg, severity = "warn") {
|
||||
try {
|
||||
const tm = app.extensionManager?.toast;
|
||||
if (tm?.add) { tm.add({ severity, summary: "Gallery Feeder", detail: msg, life: 4000 }); return; }
|
||||
} catch {}
|
||||
console[severity === "error" ? "error" : "warn"]("[WFS_GalleryFeeder]", msg);
|
||||
}
|
||||
|
||||
// ── Run / Stop ────────────────────────────────────────────────────────
|
||||
|
||||
async function startLoop(node) {
|
||||
const st = getOrCreate(node.id);
|
||||
if (st.running) return;
|
||||
|
||||
// Re-fetch images for the current group each Run
|
||||
const groupName = getInputWidget(node, "group_name")?.value || FEEDER_GROUP;
|
||||
const images = await fetchGroupImages(groupName);
|
||||
if (images.length === 0) {
|
||||
wfsToast(`No images in group "${groupName}"`, "warn");
|
||||
return;
|
||||
}
|
||||
|
||||
st.running = true;
|
||||
st.stopFlag = false;
|
||||
st.images = images;
|
||||
st.idx = Math.max(0, Math.min(
|
||||
parseInt(getInputWidget(node, "index")?.value) || 0,
|
||||
images.length - 1
|
||||
));
|
||||
|
||||
updateRunBtn(node);
|
||||
|
||||
// Queue first generation with current index
|
||||
setWidgetValue(node, "index", st.idx);
|
||||
app.queuePrompt(0, 1);
|
||||
|
||||
while (st.running && !st.stopFlag) {
|
||||
try {
|
||||
await waitForExecution();
|
||||
} catch (err) {
|
||||
if (st.running) wfsToast(err.message, "error");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!st.running || st.stopFlag) break;
|
||||
|
||||
const afterGen = node._wfsAfterGenWidget?.value || "loop";
|
||||
const total = st.images.length;
|
||||
|
||||
// Increment mode: stop after the last image
|
||||
if (afterGen === "increment" && st.idx >= total - 1) break;
|
||||
|
||||
if (afterGen !== "fixed") {
|
||||
st.idx = (st.idx + 1) % total;
|
||||
setWidgetValue(node, "index", st.idx);
|
||||
}
|
||||
|
||||
app.queuePrompt(0, 1);
|
||||
}
|
||||
|
||||
st.running = false;
|
||||
updateRunBtn(node);
|
||||
}
|
||||
|
||||
function stopLoop(node) {
|
||||
const st = getOrCreate(node.id);
|
||||
if (!st.running) return;
|
||||
st.stopFlag = true;
|
||||
st.running = false;
|
||||
try { app.api.interrupt(); } catch {}
|
||||
updateRunBtn(node);
|
||||
}
|
||||
|
||||
// ── Extension registration ────────────────────────────────────────────
|
||||
|
||||
app.registerExtension({
|
||||
name: "WorkflowStudio.GalleryFeeder",
|
||||
|
||||
async beforeRegisterNodeDef(nodeType, nodeData) {
|
||||
if (nodeData.name !== "WFS_GalleryFeeder") return;
|
||||
|
||||
const origCreated = nodeType.prototype.onNodeCreated;
|
||||
nodeType.prototype.onNodeCreated = function () {
|
||||
origCreated?.call(this);
|
||||
const node = this;
|
||||
|
||||
// ── After Gen selector ────────────────────────────────────
|
||||
// serialize:false → not included in widgets_values / prompt inputs
|
||||
const afterGenW = node.addWidget("combo", "wfs_after_gen", "loop", () => {}, {
|
||||
values: ["loop", "increment", "fixed"],
|
||||
serialize: false,
|
||||
});
|
||||
node._wfsAfterGenWidget = afterGenW;
|
||||
|
||||
// ── Run button ────────────────────────────────────────────
|
||||
const runW = node.addWidget("button", "▶ Run", null, () => startLoop(node));
|
||||
runW.serialize = false;
|
||||
node._wfsRunWidget = runW;
|
||||
|
||||
// ── Stop button ───────────────────────────────────────────
|
||||
const stopW = node.addWidget("button", "■ Stop", null, () => stopLoop(node));
|
||||
stopW.serialize = false;
|
||||
node._wfsStopWidget = stopW;
|
||||
};
|
||||
|
||||
// Clean up when node is removed from graph
|
||||
const origRemoved = nodeType.prototype.onRemoved;
|
||||
nodeType.prototype.onRemoved = function () {
|
||||
stopLoop(this);
|
||||
_ns.delete(this.id);
|
||||
origRemoved?.call(this);
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -241,6 +241,52 @@ const fetchWorkflowRaw = async (filename) => {
|
||||
} catch { return null; }
|
||||
};
|
||||
|
||||
// Returns true if the JSON is in ComfyUI API format (dict of nodeId→{class_type, inputs})
|
||||
// rather than the UI format (has nodes[] and links[] arrays).
|
||||
const isApiWorkflowFormat = (data) => {
|
||||
if (!data || typeof data !== "object" || Array.isArray(data)) return false;
|
||||
if (Array.isArray(data.nodes)) return false;
|
||||
const keys = Object.keys(data);
|
||||
return keys.length > 0 && keys.every((k) => data[k]?.class_type);
|
||||
};
|
||||
|
||||
// Minimal API→UI conversion so app.loadGraphData() can handle API-format workflows.
|
||||
// Nodes are arranged in a grid; link types use "*" since object_info is not queried here.
|
||||
const convertApiToUiWorkflow = (api) => {
|
||||
const nodes = [];
|
||||
const links = [];
|
||||
let linkId = 1;
|
||||
const sortedIds = Object.keys(api).sort((a, b) => Number(a) - Number(b));
|
||||
sortedIds.forEach((id, idx) => {
|
||||
const node = api[id];
|
||||
const col = idx % 5;
|
||||
const row = Math.floor(idx / 5);
|
||||
const uiNode = {
|
||||
id: Number(id),
|
||||
type: node.class_type,
|
||||
title: node._meta?.title || node.class_type,
|
||||
pos: [col * 300 + 50, row * 250 + 50],
|
||||
size: [250, 200],
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
widgets_values: [],
|
||||
mode: 0,
|
||||
};
|
||||
for (const [key, val] of Object.entries(node.inputs || {})) {
|
||||
if (Array.isArray(val) && val.length === 2 && typeof val[0] === "string" && typeof val[1] === "number") {
|
||||
uiNode.inputs.push({ name: key, type: "*", link: linkId });
|
||||
links.push([linkId, Number(val[0]), val[1], Number(id), uiNode.inputs.length - 1, "*"]);
|
||||
linkId++;
|
||||
} else {
|
||||
uiNode.widgets_values.push(val);
|
||||
}
|
||||
}
|
||||
nodes.push(uiNode);
|
||||
});
|
||||
const maxNodeId = Math.max(0, ...sortedIds.map(Number));
|
||||
return { nodes, links, groups: [], config: {}, extra: {}, version: 0.4, last_node_id: maxNodeId, last_link_id: linkId };
|
||||
};
|
||||
|
||||
const loadWfData = async () => {
|
||||
const workflows = await fetchWorkflows();
|
||||
state.wfList = workflows.filter(w => w.filename !== ".index.json");
|
||||
@@ -513,6 +559,30 @@ const placeLoraMgrNode = (loras, pos) => {
|
||||
// Workflow canvas loading
|
||||
// ============================================
|
||||
|
||||
/**
|
||||
* Load workflow JSON onto the ComfyUI canvas.
|
||||
* Delegates to app.handleFile() so ComfyUI's native path handles both UI and API
|
||||
* formats (identical to dragging a file from Explorer). Falls back to
|
||||
* convertApiToUiWorkflow() + loadGraphData() if handleFile is unavailable.
|
||||
*/
|
||||
const loadDataOnCanvas = async (data) => {
|
||||
if (typeof app?.handleFile === "function") {
|
||||
const blob = new Blob([JSON.stringify(data)], { type: "application/json" });
|
||||
const file = new File([blob], "workflow.json", { type: "application/json" });
|
||||
await app.handleFile(file);
|
||||
} else {
|
||||
if (isApiWorkflowFormat(data)) data = convertApiToUiWorkflow(data);
|
||||
await app.loadGraphData(data);
|
||||
}
|
||||
};
|
||||
|
||||
// ============================================
|
||||
// Cross-window receiver for SPA Send-to-Canvas
|
||||
// ============================================
|
||||
window.wfmReceiveWorkflow = async (data) => {
|
||||
await loadDataOnCanvas(data);
|
||||
};
|
||||
|
||||
const loadWorkflowOnCanvas = async (filename) => {
|
||||
const displayName = filename.replace(/\.json$/i, "");
|
||||
showToast(`Loading "${displayName}"...`, "info");
|
||||
@@ -522,7 +592,7 @@ const loadWorkflowOnCanvas = async (filename) => {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await app.loadGraphData(data);
|
||||
await loadDataOnCanvas(data);
|
||||
showToast(`Loaded: ${displayName}`, "success");
|
||||
} catch (err) {
|
||||
showToast("Failed to load: " + err.message, "error");
|
||||
@@ -600,22 +670,24 @@ const installCanvasDropHandler = () => {
|
||||
const pendingRaw = e.dataTransfer.getData("application/x-wfm-pending");
|
||||
if (pendingRaw) {
|
||||
e.preventDefault();
|
||||
try {
|
||||
const wfData = JSON.parse(pendingRaw);
|
||||
app.loadGraphData(wfData);
|
||||
localStorage.removeItem("wfm_pending_workflow");
|
||||
if (panelEl) {
|
||||
const titleEl = panelEl.querySelector(".wfm-nlp-title");
|
||||
if (titleEl) {
|
||||
titleEl.draggable = false;
|
||||
titleEl.classList.remove("wfm-nlp-title-pending");
|
||||
titleEl.title = "Workflow Studio Library";
|
||||
(async () => {
|
||||
try {
|
||||
const wfData = JSON.parse(pendingRaw);
|
||||
await loadDataOnCanvas(wfData);
|
||||
localStorage.removeItem("wfm_pending_workflow");
|
||||
if (panelEl) {
|
||||
const titleEl = panelEl.querySelector(".wfm-nlp-title");
|
||||
if (titleEl) {
|
||||
titleEl.draggable = false;
|
||||
titleEl.classList.remove("wfm-nlp-title-pending");
|
||||
titleEl.title = "Workflow Studio Library";
|
||||
}
|
||||
}
|
||||
showToast("Workflow loaded on canvas", "success");
|
||||
} catch (err) {
|
||||
showToast("Failed to load workflow: " + err.message, "error");
|
||||
}
|
||||
showToast("Workflow loaded on canvas", "success");
|
||||
} catch (err) {
|
||||
showToast("Failed to load workflow: " + err.message, "error");
|
||||
}
|
||||
})();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user