Compare commits

...
1 Commits
Author SHA1 Message Date
ketle-manandClaude Sonnet 4.6 ef0fccbd36 feat: CivitAI panel — Type/Hash display, image new-tab, URL fix, 3-state UI (v0.3.20)
- Add Type badge, Base Model row, Hash row (BLAKE3/SHA256) to CivitAI side panel
- Extract fileHashes (BLAKE3, SHA256, AutoV2 etc.) in _extract_info
- Sample images wrapped in <a target="_blank"> to open full-size in new tab
- Fix broken model page URL caused by batch POST API omitting model.id;
  fall back to top-level modelId field in _extract_info; also reconstruct
  URL client-side from modelId+versionId for existing cached data
- Add 3-state CivitAI tab UI: unchecked / checked-not-found / found
- CivitAI tab click now calls renderSideCivitai to always show latest state

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 20:35:45 +09:00
6 changed files with 172 additions and 13 deletions
+52
View File
@@ -1,5 +1,57 @@
# DEVLOG - ComfyUI-Workflow-Studio
## 2026-05-31: v0.3.20 — CivitAI 詳細パネル強化(Type / Hash 表示・URL 修正・画像別タブ)
### 概要
Models タブのサイドパネル CivitAI タブを強化。Type・Base Model・Hash(BLAKE3/SHA256)の詳細行を追加し、
サンプル画像をクリックで別タブ表示できるようにした。バッチ POST API の `model.id` 欠落による
モデルページ URL の壊れを修正。CivitAI タブの 3 状態 UI と再描画タイミングも改善。
### 変更内容
#### `py/services/civitai_service.py`
**`_extract_info()` — `fileHashes` フィールドを追加**
- プライマリファイルの `hashes` オブジェクト(BLAKE3 / SHA256 / AutoV2 等)を `fileHashes` として保存
- 新規取得・更新後はサイドパネルで各ハッシュ値を表示できる
**`_extract_info()` — `modelId` フォールバックを追加**
- バッチ POST API(`POST /model-versions/by-hash`)はレスポンスの `model` オブジェクト内に `id` を含まない場合がある
- `model.get("id") or data.get("modelId")` でトップレベルの `modelId` をフォールバックとして使用
- これにより `modelUrl` が `https://civitai.com/models?modelVersionId=XXXX`(モデル一覧ページ)になる問題を修正
#### `static/js/models-tab.js`
**`renderCivitaiInfo()` — 詳細行を追加**
| 追加要素 | 内容 |
|---|---|
| Type | `info.type` を大文字バッジで表示("CHECKPOINT"、"LORA" 等)|
| Base Model | `info.baseModel` をラベル付き行で表示(旧サブタイトルから分離)|
| Hash | BLAKE3 優先・SHA256 フォールバック。先頭 16 文字を表示、クリックでフルハッシュをクリップボードコピー |
- ローカルメタデータの `sha256`(既存キャッシュでも利用可能)を SHA256 として自動補完
- 既存キャッシュで `modelUrl` が壊れている場合も `info.modelId` + `info.versionId` から URL を再構築(更新不要)
- サンプル画像を `<a target="_blank">` でラップ → クリックで原寸画像を別タブに表示
- モデル名サブタイトル行から `baseModel` を除去(Detail 行に移動)
**`renderSideCivitai()` — 3 状態 UI に変更**
- `sha256` なし → 「CivitAIから取得」ボタン(未確認)
- `sha256` あり・キャッシュなし → 「確認済みですが、CivitAIに見つかりませんでした。」+「再確認する」ボタン
- キャッシュあり → CivitAI 情報を表示
**CivitAI タブ切り替え時の再描画**
- サイドパネルのタブ切り替えハンドラで CivitAI タブをクリックした際に `renderSideCivitai` を呼び出すよう追加
- バッチ取得後に状態が更新されていても、タブをクリックすれば必ず最新内容が表示される
#### `static/js/i18n.js`
新規文字列を追加(EN / JA / ZH):
`civitaiType` / `civitaiBaseModel` / `civitaiHashLabel` / `civitaiCopyHash` / `civitaiHashCopied` / `civitaiOpenImage`
---
## 2026-05-31: v0.3.19 — CivitAI 連携強化(バッチ高速化・リトライ・APIキー・フィールド拡充)
### 概要
+11 -2
View File
@@ -5,7 +5,7 @@ A comprehensive workflow management and generation UI plugin for [ComfyUI](https
Browse, organize, and execute workflows directly from a dedicated studio interface — without switching between windows or manually editing JSON.
![Workflow Studio](https://img.shields.io/badge/ComfyUI-Custom_Node-blue)
![Version](https://img.shields.io/badge/version-0.3.19-green)
![Version](https://img.shields.io/badge/version-0.3.20-green)
## Screenshots
@@ -144,7 +144,8 @@ Requires the **[comfyui-image-feeder](https://github.com/ketle-man/comfyui-image
- **Search & Filter** — full-text search, filter by tags, groups, and favorites
- **User-defined badges** — assign free-label badges to models; badge colors shared with the Workflow tab palette
- **Side panel tabs** — Info (file path display with click-to-copy, tags, memo), Groups management, CivitAI integration
- **CivitAI integration** — fetch model metadata by SHA256 hash; displays base model, trained words, tags, NSFW level, download/like stats, AIR identifier, and model page link; preview image is automatically downloaded and saved if none exists
- **CivitAI integration** — fetch model metadata by SHA256 hash; side panel shows **Type** (badge), **Base Model**, **Hash** (BLAKE3/SHA256, click to copy), trained words, tags, and model page link; sample images are clickable and open full-size in a new tab; preview image is automatically downloaded and saved if none exists
- **CivitAI panel states** — three distinct states: not yet checked (fetch button), checked but not found on CivitAI (re-check button with notice), and found (full info display); clicking the CivitAI tab always refreshes to the latest state
- **Batch CivitAI fetch** — one-click batch fetch using `POST /model-versions/by-hash` (up to 100 models per request) with SSE progress streaming; previews are auto-saved for models without one
- **Detail modal** — preview image, CivitAI info, thumbnail change via file upload
- **GenUI Model button** — apply the selected model directly to the corresponding node in GenerateUI's current workflow (Checkpoint, LoRA, VAE, ControlNet, UNET, TextEncoder)
@@ -276,6 +277,14 @@ Click the **camera icon** (next to the W button) in ComfyUI's top bar to capture
## Changelog
### v0.3.20
- **CivitAI panel — Type / Base Model / Hash display** — side panel CivitAI tab now shows a Type badge (e.g. CHECKPOINT, LORA), Base Model row, and Hash row (BLAKE3 preferred, SHA256 fallback from CivitAI API or local metadata); click the hash to copy the full value to clipboard
- **CivitAI panel — images open in new tab** — sample images in the CivitAI tab are now wrapped in links; clicking an image opens the full-size version in a new browser tab
- **CivitAI panel — 3-state UI** — the panel now distinguishes between "not yet checked" (blue fetch button), "checked but not found on CivitAI" (re-check button with a notice), and "found" (full info); no more ambiguity after running batch fetch
- **CivitAI tab click refresh** — clicking the CivitAI tab in the side panel now re-renders its content, ensuring the latest fetch state is always shown without needing to reselect the model
- **Bug fix: model page URL broken after batch fetch** — the batch `POST /model-versions/by-hash` endpoint can omit `model.id` inside the version object; `_extract_info` now falls back to the top-level `modelId` field so the model page link is always correct; existing cached entries with a broken URL are also fixed client-side from `modelId` + `versionId`
- **CivitAI cache — `fileHashes` field added** — `_extract_info` now stores the primary file's full hash map (BLAKE3, SHA256, AutoV2, etc.) so the Hash row is populated for newly fetched or refreshed models
### v0.3.19
- **CivitAI batch fetch — major speedup** — switched from one-by-one `GET` requests (0.5 s delay each) to `POST /model-versions/by-hash` batch endpoint; up to 100 hashes per request, reducing 100-model fetch from ~50 s to a few seconds
- **Retry with exponential backoff** — `fetch_by_hash` and the new batch POST both retry on HTTP 429 / 500 / 502 / 503 / 504 with 1 s → 2 s → 4 s delays (max 3 attempts), as recommended in the CivitAI API docs
+13 -4
View File
@@ -281,6 +281,7 @@ class CivitaiService:
# プライマリファイルのメタ情報(精度・フォーマット)
file_meta = {}
file_hashes = {}
if primary_file:
pm = primary_file.get("metadata", {})
file_meta = {
@@ -288,12 +289,19 @@ class CivitaiService:
"size": pm.get("size"),
"format": pm.get("format"),
}
# BLAKE3, SHA256, AutoV2 等のハッシュ
file_hashes = primary_file.get("hashes", {})
stats = data.get("stats", {})
# バッチ POST API は model オブジェクト内に id を含まない場合がある
# トップレベルの modelId をフォールバックとして使用する
model_id = model.get("id") or data.get("modelId")
version_id = data.get("id", "")
return {
"versionId": data.get("id"),
"modelId": model.get("id"),
"versionId": version_id,
"modelId": model_id,
"modelName": model.get("name", ""),
"versionName": data.get("name", ""),
"type": model.get("type", ""),
@@ -310,10 +318,11 @@ class CivitaiService:
"baseModel": data.get("baseModel", ""),
"fileSize": primary_file.get("sizeKB", 0) if primary_file else 0,
"fileMeta": file_meta,
"fileHashes": file_hashes,
"downloadUrl": data.get("downloadUrl", ""),
"modelUrl": (
f"https://civitai.com/models/{model.get('id', '')}"
f"?modelVersionId={data.get('id', '')}"
f"https://civitai.com/models/{model_id}?modelVersionId={version_id}"
if model_id else f"https://civitai.com/models?modelVersionId={version_id}"
),
"stats": {
"downloadCount": stats.get("downloadCount", 0),
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui-workflow-studio"
description = "A comprehensive workflow management and generation UI plugin for ComfyUI. Browse, organize, and execute workflows from a dedicated studio interface."
version = "0.3.19"
version = "0.3.20"
license = "MIT"
requires-python = ">= 3.10"
dependencies = ["jinja2"]
+24
View File
@@ -310,7 +310,15 @@ const LANGUAGES = {
civitaiHashing: "Calculating hash... (may take a while for large files)",
civitaiFound: "CivitAI info loaded",
civitaiNotFound: "Model not found on CivitAI",
civitaiNotFoundDesc: "This model was checked but not found on CivitAI.",
civitaiRefetchBtn: "Re-check CivitAI",
civitaiError: "Error fetching from CivitAI",
civitaiType: "Type",
civitaiBaseModel: "Base Model",
civitaiHashLabel: "Hash",
civitaiCopyHash: "Click to copy hash",
civitaiHashCopied: "Hash copied",
civitaiOpenImage: "Open image in new tab",
civitaiTriggerWords: "Trigger Words",
civitaiCopyWord: "Click to copy",
civitaiWordCopied: "Trigger word copied",
@@ -952,7 +960,15 @@ const LANGUAGES = {
civitaiHashing: "ハッシュ計算中...(大きいファイルは時間がかかります)",
civitaiFound: "CivitAI情報を取得しました",
civitaiNotFound: "CivitAIにモデルが見つかりません",
civitaiNotFoundDesc: "確認済みですが、このモデルはCivitAIに見つかりませんでした。",
civitaiRefetchBtn: "再確認する",
civitaiError: "CivitAIからの取得エラー",
civitaiType: "タイプ",
civitaiBaseModel: "ベースモデル",
civitaiHashLabel: "ハッシュ",
civitaiCopyHash: "クリックでハッシュをコピー",
civitaiHashCopied: "ハッシュをコピーしました",
civitaiOpenImage: "画像を別タブで開く",
civitaiTriggerWords: "トリガーワード",
civitaiCopyWord: "クリックでコピー",
civitaiWordCopied: "トリガーワードをコピーしました",
@@ -1590,7 +1606,15 @@ const LANGUAGES = {
civitaiHashing: "计算哈希中...(大文件可能需要较长时间)",
civitaiFound: "已加载CivitAI信息",
civitaiNotFound: "在CivitAI上未找到该模型",
civitaiNotFoundDesc: "已检查,但在CivitAI上未找到此模型。",
civitaiRefetchBtn: "重新检查",
civitaiError: "从CivitAI获取时出错",
civitaiType: "类型",
civitaiBaseModel: "基础模型",
civitaiHashLabel: "哈希",
civitaiCopyHash: "点击复制哈希",
civitaiHashCopied: "哈希已复制",
civitaiOpenImage: "在新标签页中打开图片",
civitaiTriggerWords: "触发词",
civitaiCopyWord: "点击复制",
civitaiWordCopied: "触发词已复制",
+71 -6
View File
@@ -1496,6 +1496,21 @@ function renderSideCivitai(modelName) {
if (cached) {
renderCivitaiInfo(el, cached, modelName);
} else if (sha256) {
// SHA256 is known but model was not found on CivitAI
el.innerHTML = `
<div style="padding:0 4px;text-align:center;">
<p style="color:var(--wfm-text-secondary);font-size:13px;margin-bottom:12px;">
${t("civitaiNotFoundDesc")}
</p>
<button class="wfm-btn wfm-btn-sm" id="wfm-civitai-fetch-btn">
${t("civitaiRefetchBtn")}
</button>
<div id="wfm-civitai-status" style="margin-top:8px;font-size:12px;color:var(--wfm-text-secondary);"></div>
</div>`;
document.getElementById("wfm-civitai-fetch-btn")?.addEventListener("click", () => {
fetchCivitaiForModel(modelName, el);
});
} else {
el.innerHTML = `
<div style="padding:0 4px;text-align:center;">
@@ -1569,8 +1584,9 @@ async function fetchCivitaiForModel(modelName, el) {
}
function renderCivitaiInfo(el, info, modelName) {
const imagesHtml = (info.images || []).map((url) =>
`<img src="${escapeHtml(url)}" style="width:100%;border-radius:4px;margin-bottom:6px;" loading="lazy" />`
// Images — wrapped in <a> to open full image in new tab
const imagesHtml = (info.images || []).slice(0, 3).map((url) =>
`<a href="${escapeHtml(url)}" target="_blank" rel="noopener" title="${t("civitaiOpenImage")}"><img src="${escapeHtml(url)}" style="width:100%;border-radius:4px;margin-bottom:6px;cursor:pointer;display:block;" loading="lazy" /></a>`
).join("");
const tagsHtml = (info.tags || []).map((tag) =>
@@ -1581,20 +1597,60 @@ function renderCivitaiInfo(el, info, modelName) {
`<code style="font-size:11px;background:var(--wfm-bg-secondary);padding:1px 4px;border-radius:3px;cursor:pointer;" class="wfm-trained-word" title="${t("civitaiCopyWord")}">${escapeHtml(w)}</code>`
).join(" ");
// キャッシュに modelId なし / 旧形式の壊れた modelUrl を持つデータに対応
const modelUrl = (info.modelId && info.versionId)
? `https://civitai.com/models/${info.modelId}?modelVersionId=${info.versionId}`
: (info.modelUrl || "#");
// Hash: BLAKE3 優先、なければ SHA256(fileHashes または ローカルメタデータから取得)
const fileHashes = info.fileHashes || {};
const blake3 = fileHashes.BLAKE3 || fileHashes.Blake3 || "";
const sha256 = fileHashes.SHA256 || (state.modelMetadata[modelName] || {}).sha256 || "";
const hashType = blake3 ? "BLAKE3" : (sha256 ? "SHA256" : "");
const hashFull = blake3 || sha256;
// Detail rows
const ROW = "display:flex;align-items:center;font-size:12px;margin-bottom:5px;";
const LABEL = "color:var(--wfm-text-secondary);min-width:80px;flex-shrink:0;";
const typeRow = info.type ? `
<div style="${ROW}">
<span style="${LABEL}">${t("civitaiType")}</span>
<span style="font-size:10px;font-weight:700;background:var(--wfm-bg-tertiary,rgba(255,255,255,0.1));padding:2px 7px;border-radius:3px;letter-spacing:0.6px;">${escapeHtml(info.type.toUpperCase())}</span>
</div>` : "";
const baseModelRow = info.baseModel ? `
<div style="${ROW}">
<span style="${LABEL}">${t("civitaiBaseModel")}</span>
<span>${escapeHtml(info.baseModel)}</span>
</div>` : "";
const hashRow = hashFull ? `
<div style="${ROW}">
<span style="${LABEL}">${t("civitaiHashLabel")}</span>
<code class="wfm-hash-value" data-hash="${escapeHtml(hashFull)}"
style="background:var(--wfm-bg-secondary);padding:2px 6px;border-radius:3px;cursor:pointer;font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:calc(100% - 84px);"
title="${t("civitaiCopyHash")}">${escapeHtml(hashType)}: ${escapeHtml(hashFull.substring(0, 16).toUpperCase())}…</code>
</div>` : "";
const detailSection = (typeRow || baseModelRow || hashRow)
? `<div style="margin-bottom:10px;">${typeRow}${baseModelRow}${hashRow}</div>` : "";
el.innerHTML = `
<div style="padding:0 4px;">
<div style="margin-bottom:10px;">
<div style="font-weight:700;font-size:14px;margin-bottom:2px;">
<a href="${escapeHtml(info.modelUrl)}" target="_blank" style="color:var(--wfm-primary);text-decoration:none;">${escapeHtml(info.modelName)}</a>
<a href="${escapeHtml(modelUrl)}" target="_blank" style="color:var(--wfm-primary);text-decoration:none;">${escapeHtml(info.modelName)}</a>
</div>
<div style="font-size:12px;color:var(--wfm-text-secondary);">
${escapeHtml(info.versionName)} · ${escapeHtml(info.baseModel)} · by ${escapeHtml(info.creator)}
${escapeHtml(info.versionName)}${info.creator ? ` · by ${escapeHtml(info.creator)}` : ""}
</div>
</div>
${detailSection}
${imagesHtml ? `<div style="margin-bottom:10px;">${imagesHtml}</div>` : ""}
${tagsHtml ? `<div style="margin-bottom:8px;">${tagsHtml}</div>` : ""}
${trainedWordsHtml ? `<div style="margin-bottom:10px;"><div style="font-weight:600;font-size:12px;margin-bottom:4px;">${t("civitaiTriggerWords")}</div>${trainedWordsHtml}</div>` : ""}
${info.description ? `<div style="font-size:12px;color:var(--wfm-text-secondary);line-height:1.5;max-height:200px;overflow-y:auto;">${info.description}</div>` : ""}
${info.description ? `<div style="font-size:12px;color:var(--wfm-text-secondary);line-height:1.5;max-height:120px;overflow-y:auto;">${info.description}</div>` : ""}
<div style="margin-top:10px;">
<button class="wfm-btn wfm-btn-sm" id="wfm-civitai-refresh-btn">${t("civitaiRefresh")}</button>
</div>
@@ -1609,9 +1665,17 @@ function renderCivitaiInfo(el, info, modelName) {
});
});
// Copy hash on click
el.querySelectorAll(".wfm-hash-value").forEach((hashEl) => {
hashEl.addEventListener("click", () => {
navigator.clipboard.writeText(hashEl.dataset.hash).then(() => {
showToast(t("civitaiHashCopied"), "success");
});
});
});
// Refresh button
document.getElementById("wfm-civitai-refresh-btn")?.addEventListener("click", () => {
// Clear cache for this model and re-fetch
const meta = state.modelMetadata[modelName] || {};
if (meta.sha256) delete state.civitaiCache[meta.sha256];
delete meta.sha256;
@@ -1933,6 +1997,7 @@ export function initModelsTab() {
const map = { info: "wfm-models-side-info", group: "wfm-models-side-group", civitai: "wfm-models-side-civitai" };
const target = document.getElementById(map[tabId]);
if (target) target.style.display = "block";
if (tabId === "civitai" && state.selectedModel) renderSideCivitai(state.selectedModel);
});
});