Compare commits
36 Commits
4fe9a9c958
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c5d2fc4e0 | |||
| e6d260eb1a | |||
| 8dafee9f6d | |||
| b405427a6b | |||
| c771fa3451 | |||
| 4b40d0f50c | |||
| 97c755316b | |||
| d1e32e5fc4 | |||
| c252d0b4e3 | |||
| bc61033826 | |||
| 4b19ad0a1d | |||
| b3d7c3868d | |||
| 5d2f3bbf4f | |||
| 3b700b099b | |||
| 91241b787c | |||
| e9056457cd | |||
| 5c90a59d7e | |||
| 111b37dc8d | |||
| f857485bc8 | |||
| 410c80afc8 | |||
| 2277e6e427 | |||
| 3065dd7e71 | |||
| 783da171e7 | |||
| 783f07e57a | |||
| c7ca3ae277 | |||
| f376fd5622 | |||
| fec843f804 | |||
| 2619d2c7e2 | |||
| 03dcb1c13a | |||
| 9ffdf6287d | |||
| 735d905833 | |||
| 932295ed27 | |||
| a5da8b26f4 | |||
| 5bc2838b21 | |||
| a7a4794adb | |||
| d33ce4da38 |
+75
-3
@@ -9,10 +9,11 @@ from pathlib import Path
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from fastapi import HTTPException, Query
|
from fastapi import HTTPException, Query
|
||||||
|
from fastapi.responses import FileResponse
|
||||||
from nicegui import app
|
from nicegui import app
|
||||||
|
|
||||||
from db import ProjectDB
|
from db import ProjectDB
|
||||||
from utils import load_json, KEY_BATCH_DATA, KEY_SEQUENCE_NUMBER
|
from utils import load_json, load_config, resolve_path_case_insensitive, KEY_BATCH_DATA, KEY_SEQUENCE_NUMBER
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -26,10 +27,13 @@ def register_api_routes(db: ProjectDB) -> None:
|
|||||||
_db = db
|
_db = db
|
||||||
|
|
||||||
app.add_api_route("/api/projects", _list_projects, methods=["GET"])
|
app.add_api_route("/api/projects", _list_projects, methods=["GET"])
|
||||||
|
app.add_api_route("/api/active-project", _get_active_project, methods=["GET"])
|
||||||
|
app.add_api_route("/api/projects/{name}", _get_project, methods=["GET"])
|
||||||
app.add_api_route("/api/projects/{name}/files", _list_files, methods=["GET"])
|
app.add_api_route("/api/projects/{name}/files", _list_files, methods=["GET"])
|
||||||
app.add_api_route("/api/projects/{name}/files/{file_name}/sequences", _list_sequences, methods=["GET"])
|
app.add_api_route("/api/projects/{name}/files/{file_name}/sequences", _list_sequences, methods=["GET"])
|
||||||
app.add_api_route("/api/projects/{name}/files/{file_name}/data", _get_data, methods=["GET"])
|
app.add_api_route("/api/projects/{name}/files/{file_name}/data", _get_data, methods=["GET"])
|
||||||
app.add_api_route("/api/projects/{name}/files/{file_name}/keys", _get_keys, methods=["GET"])
|
app.add_api_route("/api/projects/{name}/files/{file_name}/keys", _get_keys, methods=["GET"])
|
||||||
|
app.add_api_route("/api/image-preview", _serve_image, methods=["GET"])
|
||||||
|
|
||||||
|
|
||||||
def _get_db() -> ProjectDB:
|
def _get_db() -> ProjectDB:
|
||||||
@@ -44,6 +48,30 @@ def _list_projects() -> dict[str, Any]:
|
|||||||
return {"projects": [p["name"] for p in projects]}
|
return {"projects": [p["name"] for p in projects]}
|
||||||
|
|
||||||
|
|
||||||
|
def _get_active_project() -> dict[str, Any]:
|
||||||
|
config = load_config()
|
||||||
|
return {"project": config.get("current_project", "")}
|
||||||
|
|
||||||
|
|
||||||
|
def _get_project(name: str) -> dict[str, Any]:
|
||||||
|
db = _get_db()
|
||||||
|
proj = db.get_project(name)
|
||||||
|
if not proj:
|
||||||
|
raise HTTPException(status_code=404, detail=f"Project '{name}' not found")
|
||||||
|
folder_path = proj["folder_path"]
|
||||||
|
resolved = resolve_path_case_insensitive(folder_path)
|
||||||
|
if resolved:
|
||||||
|
folder_path = str(resolved)
|
||||||
|
# Apply configured path replacements (e.g. Docker mount casing differences)
|
||||||
|
config = load_config()
|
||||||
|
for rep in config.get("path_replacements", []):
|
||||||
|
src, dst = rep.get("from", ""), rep.get("to", "")
|
||||||
|
if src:
|
||||||
|
folder_path = folder_path.replace(src, dst)
|
||||||
|
return {"name": proj["name"], "folder_path": folder_path,
|
||||||
|
"description": proj.get("description", "")}
|
||||||
|
|
||||||
|
|
||||||
def _list_files(name: str) -> dict[str, Any]:
|
def _list_files(name: str) -> dict[str, Any]:
|
||||||
db = _get_db()
|
db = _get_db()
|
||||||
files = db.list_project_files(name)
|
files = db.list_project_files(name)
|
||||||
@@ -75,9 +103,28 @@ def _get_data(name: str, file_name: str, seq: int = Query(default=1)) -> dict[st
|
|||||||
match = next((s for s in sequences if int(s.get(KEY_SEQUENCE_NUMBER, 0)) == seq), None)
|
match = next((s for s in sequences if int(s.get(KEY_SEQUENCE_NUMBER, 0)) == seq), None)
|
||||||
if match is None:
|
if match is None:
|
||||||
raise HTTPException(status_code=404, detail=f"Sequence {seq} not found")
|
raise HTTPException(status_code=404, detail=f"Sequence {seq} not found")
|
||||||
|
result = dict(match)
|
||||||
|
# Inject strength defaults if not yet saved to JSON
|
||||||
|
for key, default in (
|
||||||
|
("start frame high strength", 1.0),
|
||||||
|
("start frame low strength", 1.0),
|
||||||
|
("middle frame high strength", 1.0),
|
||||||
|
("middle frame low strength", 1.0),
|
||||||
|
("end frame high strength", 1.0),
|
||||||
|
("end frame low strength", 1.0),
|
||||||
|
):
|
||||||
|
result.setdefault(key, default)
|
||||||
|
# Computed stem names from frame paths
|
||||||
|
for out_key, src_key in (
|
||||||
|
("start_name", "start frame path"),
|
||||||
|
("middle_name", "middle frame path"),
|
||||||
|
("end_name", "end frame path"),
|
||||||
|
):
|
||||||
|
path_val = result.get(src_key, "")
|
||||||
|
result[out_key] = Path(path_val).stem if path_val else ""
|
||||||
logger.info("API _get_data %s/%s seq=%d (%d keys): %.3fs",
|
logger.info("API _get_data %s/%s seq=%d (%d keys): %.3fs",
|
||||||
name, file_name, seq, len(match), time.perf_counter() - t0)
|
name, file_name, seq, len(result), time.perf_counter() - t0)
|
||||||
return match
|
return result
|
||||||
|
|
||||||
|
|
||||||
def _get_keys(name: str, file_name: str, seq: int = Query(default=1)) -> dict[str, Any]:
|
def _get_keys(name: str, file_name: str, seq: int = Query(default=1)) -> dict[str, Any]:
|
||||||
@@ -98,7 +145,32 @@ def _get_keys(name: str, file_name: str, seq: int = Query(default=1)) -> dict[st
|
|||||||
types.append("FLOAT")
|
types.append("FLOAT")
|
||||||
else:
|
else:
|
||||||
types.append("STRING")
|
types.append("STRING")
|
||||||
|
# Injected defaults — always present even if not yet saved to JSON
|
||||||
|
for key in (
|
||||||
|
"start frame high strength", "start frame low strength",
|
||||||
|
"middle frame high strength", "middle frame low strength",
|
||||||
|
"end frame high strength", "end frame low strength",
|
||||||
|
):
|
||||||
|
if key not in match:
|
||||||
|
keys.append(key)
|
||||||
|
types.append("FLOAT")
|
||||||
|
# Computed keys derived from frame paths
|
||||||
|
for out_key, src_key in (
|
||||||
|
("start_name", "start frame path"),
|
||||||
|
("middle_name", "middle frame path"),
|
||||||
|
("end_name", "end frame path"),
|
||||||
|
):
|
||||||
|
if src_key in match:
|
||||||
|
keys.append(out_key)
|
||||||
|
types.append("STRING")
|
||||||
total = len(sequences)
|
total = len(sequences)
|
||||||
logger.info("API _get_keys %s/%s seq=%d (%d keys): %.3fs",
|
logger.info("API _get_keys %s/%s seq=%d (%d keys): %.3fs",
|
||||||
name, file_name, seq, len(keys), time.perf_counter() - t0)
|
name, file_name, seq, len(keys), time.perf_counter() - t0)
|
||||||
return {"keys": keys, "types": types, "total_sequences": total}
|
return {"keys": keys, "types": types, "total_sequences": total}
|
||||||
|
|
||||||
|
|
||||||
|
def _serve_image(path: str = Query(...)) -> FileResponse:
|
||||||
|
p = Path(path)
|
||||||
|
if not p.exists() or not p.is_file():
|
||||||
|
raise HTTPException(status_code=404, detail="Image not found")
|
||||||
|
return FileResponse(str(p))
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from utils import load_json, KEY_BATCH_DATA, KEY_HISTORY_TREE
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_DB_PATH = Path.home() / ".comfyui_json_manager" / "projects.db"
|
DEFAULT_DB_PATH = Path(__file__).parent / "projects.db"
|
||||||
|
|
||||||
SCHEMA_SQL = """
|
SCHEMA_SQL = """
|
||||||
CREATE TABLE IF NOT EXISTS projects (
|
CREATE TABLE IF NOT EXISTS projects (
|
||||||
|
|||||||
+31
-12
@@ -67,6 +67,13 @@ def _fetch_json(url: str) -> dict:
|
|||||||
return {"error": "parse_error", "message": str(e)}
|
return {"error": "parse_error", "message": str(e)}
|
||||||
|
|
||||||
|
|
||||||
|
def _fetch_project(manager_url: str, project: str) -> dict:
|
||||||
|
"""Fetch project details (including folder_path) from the NiceGUI REST API."""
|
||||||
|
p = urllib.parse.quote(project, safe='')
|
||||||
|
url = f"{manager_url.rstrip('/')}/api/projects/{p}"
|
||||||
|
return _fetch_json(url)
|
||||||
|
|
||||||
|
|
||||||
def _fetch_data(manager_url: str, project: str, file: str, seq: int) -> dict:
|
def _fetch_data(manager_url: str, project: str, file: str, seq: int) -> dict:
|
||||||
"""Fetch sequence data from the NiceGUI REST API."""
|
"""Fetch sequence data from the NiceGUI REST API."""
|
||||||
p = urllib.parse.quote(project, safe='')
|
p = urllib.parse.quote(project, safe='')
|
||||||
@@ -221,14 +228,24 @@ class ProjectSource:
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_TYPES = ("INT", "STRING",)
|
RETURN_TYPES = ("INT", "STRING", "STRING")
|
||||||
RETURN_NAMES = ("sequence_number", "file_name",)
|
RETURN_NAMES = ("sequence_number", "file_name", "project_path")
|
||||||
FUNCTION = "hold_config"
|
FUNCTION = "hold_config"
|
||||||
CATEGORY = "JSON Manager/project"
|
CATEGORY = "JSON Manager/project"
|
||||||
OUTPUT_NODE = True
|
OUTPUT_NODE = True
|
||||||
|
|
||||||
def hold_config(self, manager_url, project_name, file_name, sequence_number, label):
|
def hold_config(self, manager_url, project_name, file_name, sequence_number, label):
|
||||||
return (sequence_number, file_name,)
|
name = project_name.strip()
|
||||||
|
if not name:
|
||||||
|
active = _fetch_json(f"{manager_url.rstrip('/')}/api/active-project")
|
||||||
|
name = active.get("project", "") if "error" not in active else ""
|
||||||
|
folder_path = ""
|
||||||
|
if name:
|
||||||
|
proj = _fetch_project(manager_url, name)
|
||||||
|
folder_path = proj.get("folder_path", "") if "error" not in proj else ""
|
||||||
|
if folder_path and not folder_path.endswith("/"):
|
||||||
|
folder_path += "/"
|
||||||
|
return (sequence_number, file_name, folder_path)
|
||||||
|
|
||||||
|
|
||||||
class ProjectKey:
|
class ProjectKey:
|
||||||
@@ -282,13 +299,15 @@ class ProjectKey:
|
|||||||
val = data.get(key_name, "")
|
val = data.get(key_name, "")
|
||||||
|
|
||||||
if key_type == "INT":
|
if key_type == "INT":
|
||||||
return (to_int(val),)
|
result = to_int(val)
|
||||||
|
return {"ui": {"value": [str(result)]}, "result": (result,)}
|
||||||
elif key_type == "FLOAT":
|
elif key_type == "FLOAT":
|
||||||
return (to_float(val),)
|
result = to_float(val)
|
||||||
|
return {"ui": {"value": [f"{result:.4g}"]}, "result": (result,)}
|
||||||
elif isinstance(val, bool):
|
elif isinstance(val, bool):
|
||||||
return (str(val).lower(),)
|
return {"ui": {"value": [str(val).lower()]}, "result": (str(val).lower(),)}
|
||||||
elif isinstance(val, (int, float)):
|
elif isinstance(val, (int, float)):
|
||||||
return (val,)
|
return {"ui": {"value": [str(val)]}, "result": (val,)}
|
||||||
else:
|
else:
|
||||||
return (str(val),)
|
return (str(val),)
|
||||||
|
|
||||||
@@ -376,11 +395,11 @@ class BinaryIndexDecoder:
|
|||||||
OUTPUT_NODE = False
|
OUTPUT_NODE = False
|
||||||
|
|
||||||
def decode(self, index: int):
|
def decode(self, index: int):
|
||||||
return (
|
f0 = bool((index >> 0) & 1)
|
||||||
bool((index >> 0) & 1),
|
f1 = bool((index >> 1) & 1)
|
||||||
bool((index >> 1) & 1),
|
f2 = bool((index >> 2) & 1)
|
||||||
bool((index >> 2) & 1),
|
return {"ui": {"values": [str(f0).lower(), str(f1).lower(), str(f2).lower()]},
|
||||||
)
|
"result": (f0, f1, f2)}
|
||||||
|
|
||||||
|
|
||||||
# --- Mappings ---
|
# --- Mappings ---
|
||||||
|
|||||||
+103
-67
@@ -6,6 +6,7 @@ import math
|
|||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from urllib.parse import quote
|
||||||
|
|
||||||
from nicegui import ui
|
from nicegui import ui
|
||||||
|
|
||||||
@@ -313,10 +314,13 @@ def render_batch_processor(state: AppState):
|
|||||||
'lora 3 high', 'lora 3 high strength', 'lora 3 low', 'lora 3 low strength']
|
'lora 3 high', 'lora 3 high strength', 'lora 3 low', 'lora 3 low strength']
|
||||||
standard_keys = {
|
standard_keys = {
|
||||||
'name', 'mode', 'general_prompt', 'general_negative', 'current_prompt', 'negative', 'prompt',
|
'name', 'mode', 'general_prompt', 'general_negative', 'current_prompt', 'negative', 'prompt',
|
||||||
'seed', 'cfg', 'camera', 'flf', KEY_SEQUENCE_NUMBER,
|
'seed', 'camera', KEY_SEQUENCE_NUMBER,
|
||||||
'frame_to_skip', 'end_frame', 'transition', 'vace_length',
|
'frame_to_skip', 'logic index', 'transition', 'vace_length',
|
||||||
'input_a_frames', 'input_b_frames', 'reference switch', 'vace schedule',
|
'input_a_frames', 'input_b_frames', 'reference switch', 'vace schedule',
|
||||||
'reference path', 'video file path', 'reference image path', 'flf image path',
|
'start frame path', 'start frame high strength', 'start frame low strength',
|
||||||
|
'middle frame path', 'middle frame high strength', 'middle frame low strength',
|
||||||
|
'end frame path', 'end frame high strength', 'end frame low strength',
|
||||||
|
'video file path',
|
||||||
}
|
}
|
||||||
standard_keys.update(lora_keys)
|
standard_keys.update(lora_keys)
|
||||||
|
|
||||||
@@ -542,6 +546,7 @@ def _render_sequence_card(i, seq, batch_list, data, file_path, state,
|
|||||||
ui.separator()
|
ui.separator()
|
||||||
|
|
||||||
# --- Prompts + Settings (2-column) ---
|
# --- Prompts + Settings (2-column) ---
|
||||||
|
frame_switches = [] # populated below, used for bidirectional sync with logic index
|
||||||
with ui.splitter(value=66).classes('w-full') as splitter:
|
with ui.splitter(value=66).classes('w-full') as splitter:
|
||||||
with splitter.before:
|
with splitter.before:
|
||||||
dict_textarea('General Prompt', seq, 'general_prompt').classes(
|
dict_textarea('General Prompt', seq, 'general_prompt').classes(
|
||||||
@@ -553,48 +558,42 @@ def _render_sequence_card(i, seq, batch_list, data, file_path, state,
|
|||||||
dict_textarea('Specific Negative', seq, 'negative').classes(
|
dict_textarea('Specific Negative', seq, 'negative').classes(
|
||||||
'w-full q-mt-sm').props('outlined rows=2')
|
'w-full q-mt-sm').props('outlined rows=2')
|
||||||
|
|
||||||
# --- Resolutions (8 fixed slots) ---
|
# --- Frame paths (start / middle / end) ---
|
||||||
ui.label('Resolutions').classes('text-caption text-weight-bold q-mt-md')
|
logic_val = int(seq.get('logic index', 0))
|
||||||
resolutions = seq.setdefault('resolutions', [])
|
for bit, img_label, img_key, hi_key, lo_key in [
|
||||||
while len(resolutions) < 8:
|
(0, 'Start Frame', 'start frame path', 'start frame high strength', 'start frame low strength'),
|
||||||
resolutions.append([512, 512, 0])
|
(1, 'Middle Frame', 'middle frame path', 'middle frame high strength', 'middle frame low strength'),
|
||||||
# Migrate old [w, h] entries to [w, h, seed] (persisted on next real save)
|
(2, 'End Frame', 'end frame path', 'end frame high strength', 'end frame low strength'),
|
||||||
for r_i in range(len(resolutions)):
|
]:
|
||||||
if len(resolutions[r_i]) < 3:
|
ui.label(img_label).classes('text-caption text-weight-bold q-mt-sm')
|
||||||
resolutions[r_i] = list(resolutions[r_i]) + [0]
|
is_on = bool((logic_val >> bit) & 1)
|
||||||
for idx in range(8):
|
with ui.row().classes('w-full items-center no-wrap q-mt-xs'):
|
||||||
entry = resolutions[idx]
|
inp = dict_input(ui.input, 'Path', seq, img_key).classes(
|
||||||
with ui.row().classes('items-center w-full q-mt-xs no-wrap'):
|
'col').props('outlined dense input-style="text-align: right"')
|
||||||
ui.label(str(idx)).classes('text-caption').style('min-width:16px')
|
thumb = None
|
||||||
w_inp = ui.number(value=int(entry[0]), min=1, step=1, label='W').style(
|
img_path = Path(seq.get(img_key, '')) if seq.get(img_key) else None
|
||||||
'width:70px').props('outlined dense hide-bottom-space')
|
if (img_path and img_path.exists() and
|
||||||
h_inp = ui.number(value=int(entry[1]), min=1, step=1, label='H').style(
|
img_path.suffix.lower() in IMAGE_EXTENSIONS):
|
||||||
'width:70px').props('outlined dense hide-bottom-space')
|
img_url = f'/api/image-preview?path={quote(str(img_path))}'
|
||||||
seed_inp = ui.number(value=int(entry[2]), min=0, step=1, label='Seed').style(
|
with ui.dialog() as img_dlg, ui.card().style('max-width:90vw; padding:0'):
|
||||||
'flex:1; min-width:60px').props('outlined dense hide-bottom-space')
|
ui.html(f'<img src="{img_url}" '
|
||||||
|
f'style="max-width:80vw;max-height:80vh;display:block">')
|
||||||
async def _sync_entry(r=idx, wi=w_inp, hi=h_inp, si=seed_inp):
|
thumb = ui.html(
|
||||||
seq['resolutions'][r] = [
|
f'<img src="{img_url}" '
|
||||||
int(wi.value) if wi.value else 512,
|
f'style="width:36px;height:36px;object-fit:cover;'
|
||||||
int(hi.value) if hi.value else 512,
|
f'border-radius:4px;cursor:pointer;flex-shrink:0;'
|
||||||
int(si.value) if si.value else 0,
|
f'opacity:{"1.0" if is_on else "0.25"}">'
|
||||||
]
|
).on('click', img_dlg.open)
|
||||||
await commit()
|
sw = ui.switch(value=is_on)
|
||||||
|
frame_switches.append(sw)
|
||||||
async def _randomize(si=seed_inp, r=idx):
|
if thumb is not None:
|
||||||
si.value = random.randint(0, 2**32 - 1)
|
sw.on('update:model-value',
|
||||||
seq['resolutions'][r][2] = int(si.value)
|
lambda e, t=thumb, s=sw: t.style(f'opacity: {"1.0" if s.value else "0.25"}'))
|
||||||
await commit()
|
with ui.row().classes('w-full no-wrap q-mt-xs q-gutter-xs'):
|
||||||
|
dict_number('High', seq, hi_key, default=1.0,
|
||||||
ui.button(icon='casino', on_click=_randomize).props(
|
step=0.05, format='%.2f').classes('col').props('outlined dense')
|
||||||
'flat dense round').classes('q-ml-xs')
|
dict_number('Low', seq, lo_key, default=1.0,
|
||||||
|
step=0.05, format='%.2f').classes('col').props('outlined dense')
|
||||||
w_inp.on('blur', lambda _, s=_sync_entry: s())
|
|
||||||
w_inp.on('update:model-value', lambda _, s=_sync_entry: s())
|
|
||||||
h_inp.on('blur', lambda _, s=_sync_entry: s())
|
|
||||||
h_inp.on('update:model-value', lambda _, s=_sync_entry: s())
|
|
||||||
seed_inp.on('blur', lambda _, s=_sync_entry: s())
|
|
||||||
seed_inp.on('update:model-value', lambda _, s=_sync_entry: s())
|
|
||||||
|
|
||||||
with splitter.after:
|
with splitter.after:
|
||||||
# Mode
|
# Mode
|
||||||
@@ -619,31 +618,68 @@ def _render_sequence_card(i, seq, batch_list, data, file_path, state,
|
|||||||
|
|
||||||
ui.button(icon='casino', on_click=randomize_seed).props('flat')
|
ui.button(icon='casino', on_click=randomize_seed).props('flat')
|
||||||
|
|
||||||
# CFG
|
|
||||||
dict_number('CFG', seq, 'cfg', default=DEFAULTS['cfg'],
|
|
||||||
step=0.5, format='%.1f').props('outlined').classes('w-full')
|
|
||||||
|
|
||||||
dict_input(ui.input, 'Camera', seq, 'camera').props('outlined').classes('w-full')
|
dict_input(ui.input, 'Camera', seq, 'camera').props('outlined').classes('w-full')
|
||||||
dict_input(ui.input, 'FLF', seq, 'flf').props('outlined').classes('w-full')
|
seq.setdefault('logic index', 0)
|
||||||
dict_number('End Frame', seq, 'end_frame').props('outlined').classes('w-full')
|
li_input = dict_number('Logic Index', seq, 'logic index').props('outlined readonly').classes('w-full')
|
||||||
|
with li_input:
|
||||||
|
ui.tooltip(
|
||||||
|
'Binary flags — bit 0: start frame | bit 1: middle frame | bit 2: end frame\n'
|
||||||
|
'0: none 1: start 2: middle 3: start+middle\n'
|
||||||
|
'4: end 5: start+end 6: middle+end 7: all'
|
||||||
|
)
|
||||||
dict_input(ui.input, 'Video File Path', seq, 'video file path').props(
|
dict_input(ui.input, 'Video File Path', seq, 'video file path').props(
|
||||||
'outlined input-style="direction: rtl"').classes('w-full')
|
'outlined input-style="text-align: right"').classes('w-full')
|
||||||
|
|
||||||
# Image paths with preview
|
# Switches → logic index (sole writer)
|
||||||
for img_label, img_key in [
|
def _sync_switches_to_logic(li=li_input, switches=frame_switches, s=seq):
|
||||||
('Reference Image Path', 'reference image path'),
|
v = sum(int(sw.value) << b for b, sw in enumerate(switches))
|
||||||
('Reference Path', 'reference path'),
|
s['logic index'] = v
|
||||||
('FLF Image Path', 'flf image path'),
|
li.set_value(v)
|
||||||
]:
|
|
||||||
with ui.row().classes('w-full items-center'):
|
for frame_sw in frame_switches:
|
||||||
inp = dict_input(ui.input, img_label, seq, img_key).classes(
|
frame_sw.on('update:model-value', lambda _, s=_sync_switches_to_logic: s())
|
||||||
'col').props('outlined input-style="direction: rtl"')
|
|
||||||
img_path = Path(seq.get(img_key, '')) if seq.get(img_key) else None
|
# --- Resolutions (8 fixed slots) ---
|
||||||
if (img_path and img_path.exists() and
|
resolutions = seq.setdefault('resolutions', [])
|
||||||
img_path.suffix.lower() in IMAGE_EXTENSIONS):
|
while len(resolutions) < 8:
|
||||||
with ui.dialog() as dlg, ui.card():
|
resolutions.append([512, 512, 0])
|
||||||
ui.image(str(img_path)).classes('w-full')
|
for r_i in range(len(resolutions)):
|
||||||
ui.button(icon='visibility', on_click=dlg.open).props('flat dense')
|
if len(resolutions[r_i]) < 3:
|
||||||
|
resolutions[r_i] = list(resolutions[r_i]) + [0]
|
||||||
|
with ui.expansion('Resolutions', icon='aspect_ratio').classes('w-full'):
|
||||||
|
for idx in range(8):
|
||||||
|
entry = resolutions[idx]
|
||||||
|
with ui.row().classes('items-center w-full q-mt-xs no-wrap'):
|
||||||
|
ui.label(str(idx)).classes('text-caption').style('min-width:16px')
|
||||||
|
w_inp = ui.number(value=int(entry[0]), min=1, step=1, label='W').style(
|
||||||
|
'width:70px').props('outlined dense hide-bottom-space')
|
||||||
|
h_inp = ui.number(value=int(entry[1]), min=1, step=1, label='H').style(
|
||||||
|
'width:70px').props('outlined dense hide-bottom-space')
|
||||||
|
seed_inp = ui.number(value=int(entry[2]), min=0, step=1, label='Seed').style(
|
||||||
|
'flex:1; min-width:60px').props('outlined dense hide-bottom-space')
|
||||||
|
|
||||||
|
async def _sync_entry(r=idx, wi=w_inp, hi=h_inp, si=seed_inp):
|
||||||
|
seq['resolutions'][r] = [
|
||||||
|
int(wi.value) if wi.value else 512,
|
||||||
|
int(hi.value) if hi.value else 512,
|
||||||
|
int(si.value) if si.value else 0,
|
||||||
|
]
|
||||||
|
await commit()
|
||||||
|
|
||||||
|
async def _randomize(si=seed_inp, r=idx):
|
||||||
|
si.value = random.randint(0, 2**32 - 1)
|
||||||
|
seq['resolutions'][r][2] = int(si.value)
|
||||||
|
await commit()
|
||||||
|
|
||||||
|
ui.button(icon='casino', on_click=_randomize).props(
|
||||||
|
'flat dense round').classes('q-ml-xs')
|
||||||
|
|
||||||
|
w_inp.on('blur', lambda _, s=_sync_entry: s())
|
||||||
|
w_inp.on('update:model-value', lambda _, s=_sync_entry: s())
|
||||||
|
h_inp.on('blur', lambda _, s=_sync_entry: s())
|
||||||
|
h_inp.on('update:model-value', lambda _, s=_sync_entry: s())
|
||||||
|
seed_inp.on('blur', lambda _, s=_sync_entry: s())
|
||||||
|
seed_inp.on('update:model-value', lambda _, s=_sync_entry: s())
|
||||||
|
|
||||||
# --- VACE Settings (full width) ---
|
# --- VACE Settings (full width) ---
|
||||||
with ui.expansion('VACE Settings', icon='settings').classes('w-full'):
|
with ui.expansion('VACE Settings', icon='settings').classes('w-full'):
|
||||||
|
|||||||
+46
-2
@@ -59,6 +59,48 @@ def render_projects_tab(state: AppState):
|
|||||||
|
|
||||||
ui.button('Create Project', icon='add', on_click=create_project).classes('w-full')
|
ui.button('Create Project', icon='add', on_click=create_project).classes('w-full')
|
||||||
|
|
||||||
|
# --- Path replacements (for ComfyUI Docker path differences) ---
|
||||||
|
with ui.card().classes('w-full q-pa-md q-mb-md'):
|
||||||
|
ui.label('ComfyUI Path Replacements').classes('section-header')
|
||||||
|
ui.label('Applied to project_path output — use to fix Docker mount casing differences.'
|
||||||
|
).classes('text-caption q-mb-sm')
|
||||||
|
|
||||||
|
replacements: list[dict] = state.config.get('path_replacements', [])
|
||||||
|
|
||||||
|
@ui.refreshable
|
||||||
|
def render_replacements():
|
||||||
|
for idx, rep in enumerate(replacements):
|
||||||
|
with ui.row().classes('w-full items-center no-wrap q-gutter-xs'):
|
||||||
|
ui.input('From', value=rep.get('from', '')).classes('col').props(
|
||||||
|
'outlined dense').on('update:model-value',
|
||||||
|
lambda e, i=idx: _update_replacement(i, 'from', e.args))
|
||||||
|
ui.label('→').classes('text-caption')
|
||||||
|
ui.input('To', value=rep.get('to', '')).classes('col').props(
|
||||||
|
'outlined dense').on('update:model-value',
|
||||||
|
lambda e, i=idx: _update_replacement(i, 'to', e.args))
|
||||||
|
ui.button(icon='delete', on_click=lambda i=idx: _remove_replacement(i)
|
||||||
|
).props('flat dense color=negative')
|
||||||
|
|
||||||
|
def _update_replacement(idx, field, value):
|
||||||
|
replacements[idx][field] = value
|
||||||
|
state.config['path_replacements'] = replacements
|
||||||
|
save_config(state.current_dir, state.config.get('favorites', []), state.config)
|
||||||
|
|
||||||
|
def _remove_replacement(idx):
|
||||||
|
replacements.pop(idx)
|
||||||
|
state.config['path_replacements'] = replacements
|
||||||
|
save_config(state.current_dir, state.config.get('favorites', []), state.config)
|
||||||
|
render_replacements.refresh()
|
||||||
|
|
||||||
|
def _add_replacement():
|
||||||
|
replacements.append({'from': '', 'to': ''})
|
||||||
|
state.config['path_replacements'] = replacements
|
||||||
|
save_config(state.current_dir, state.config.get('favorites', []), state.config)
|
||||||
|
render_replacements.refresh()
|
||||||
|
|
||||||
|
render_replacements()
|
||||||
|
ui.button('Add Replacement', icon='add', on_click=_add_replacement).props('flat dense')
|
||||||
|
|
||||||
# --- Active project indicator ---
|
# --- Active project indicator ---
|
||||||
# Fetch once with file counts and reuse in render_project_list
|
# Fetch once with file counts and reuse in render_project_list
|
||||||
_cached_projects = state.db.list_projects_with_file_counts()
|
_cached_projects = state.db.list_projects_with_file_counts()
|
||||||
@@ -216,8 +258,10 @@ def render_projects_tab(state: AppState):
|
|||||||
|
|
||||||
|
|
||||||
async def _import_folder(state: AppState, project_id: int, project_name: str, refresh_fn):
|
async def _import_folder(state: AppState, project_id: int, project_name: str, refresh_fn):
|
||||||
"""Bulk import all .json files from current directory into a project."""
|
"""Bulk import all .json files from the project's folder_path into a project."""
|
||||||
json_files = sorted(state.current_dir.glob('*.json'))
|
proj = state.db.get_project(project_name)
|
||||||
|
scan_dir = Path(proj['folder_path']) if proj else state.current_dir
|
||||||
|
json_files = sorted(scan_dir.glob('*.json'))
|
||||||
json_files = [f for f in json_files if f.name not in (
|
json_files = [f for f in json_files if f.name not in (
|
||||||
'.editor_config.json', '.editor_snippets.json')]
|
'.editor_config.json', '.editor_snippets.json')]
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -577,7 +577,6 @@ def _render_preview_fields(item_data: dict):
|
|||||||
|
|
||||||
with ui.row().classes('w-full q-gutter-md'):
|
with ui.row().classes('w-full q-gutter-md'):
|
||||||
ui.input('Camera', value=str(item_data.get('camera', 'static'))).props('readonly outlined')
|
ui.input('Camera', value=str(item_data.get('camera', 'static'))).props('readonly outlined')
|
||||||
ui.input('FLF', value=str(item_data.get('flf', '0.0'))).props('readonly outlined')
|
|
||||||
ui.input('Seed', value=str(item_data.get('seed', '-1'))).props('readonly outlined')
|
ui.input('Seed', value=str(item_data.get('seed', '-1'))).props('readonly outlined')
|
||||||
|
|
||||||
with ui.expansion('LoRA Configuration'):
|
with ui.expansion('LoRA Configuration'):
|
||||||
@@ -617,8 +616,9 @@ def _render_preview_fields(item_data: dict):
|
|||||||
|
|
||||||
known_keys = {
|
known_keys = {
|
||||||
'sequence_number', 'general_prompt', 'general_negative', 'current_prompt', 'prompt',
|
'sequence_number', 'general_prompt', 'general_negative', 'current_prompt', 'prompt',
|
||||||
'negative', 'camera', 'flf', 'seed', 'resolutions',
|
'negative', 'camera', 'seed', 'resolutions',
|
||||||
'frame_to_skip', 'vace schedule', 'video file path',
|
'frame_to_skip', 'vace schedule', 'video file path', 'middle frame path', 'end frame path', 'start frame path',
|
||||||
|
'logic index',
|
||||||
}
|
}
|
||||||
# also skip lora keys
|
# also skip lora keys
|
||||||
custom_keys = [
|
custom_keys = [
|
||||||
|
|||||||
@@ -28,16 +28,14 @@ DEFAULTS = {
|
|||||||
"current_prompt": "",
|
"current_prompt": "",
|
||||||
"negative": "",
|
"negative": "",
|
||||||
"seed": -1,
|
"seed": -1,
|
||||||
"cfg": 1.5,
|
|
||||||
|
|
||||||
# --- Settings ---
|
# --- Settings ---
|
||||||
"mode": 0,
|
"mode": 0,
|
||||||
"camera": "static",
|
"camera": "static",
|
||||||
"flf": 0.0,
|
|
||||||
|
|
||||||
# --- I2V / VACE Specifics ---
|
# --- I2V / VACE Specifics ---
|
||||||
"frame_to_skip": 81,
|
"frame_to_skip": 81,
|
||||||
"end_frame": 0,
|
"logic index": 0,
|
||||||
"transition": "1-2",
|
"transition": "1-2",
|
||||||
"vace_length": 49,
|
"vace_length": 49,
|
||||||
"vace schedule": 1,
|
"vace schedule": 1,
|
||||||
@@ -45,9 +43,15 @@ DEFAULTS = {
|
|||||||
"input_b_frames": 16,
|
"input_b_frames": 16,
|
||||||
"reference switch": 1,
|
"reference switch": 1,
|
||||||
"video file path": "",
|
"video file path": "",
|
||||||
"reference image path": "",
|
"start frame path": "",
|
||||||
"reference path": "",
|
"start frame high strength": 1.0,
|
||||||
"flf image path": "",
|
"start frame low strength": 1.0,
|
||||||
|
"middle frame path": "",
|
||||||
|
"middle frame high strength": 1.0,
|
||||||
|
"middle frame low strength": 1.0,
|
||||||
|
"end frame path": "",
|
||||||
|
"end frame high strength": 1.0,
|
||||||
|
"end frame low strength": 1.0,
|
||||||
|
|
||||||
# --- LoRAs (name as STRING, strength as FLOAT) ---
|
# --- LoRAs (name as STRING, strength as FLOAT) ---
|
||||||
"lora 1 high": "",
|
"lora 1 high": "",
|
||||||
@@ -150,6 +154,37 @@ def save_snippets(snippets):
|
|||||||
json.dump(snippets, f, indent=4)
|
json.dump(snippets, f, indent=4)
|
||||||
os.replace(tmp, SNIPPETS_FILE)
|
os.replace(tmp, SNIPPETS_FILE)
|
||||||
|
|
||||||
|
_REMOVED_KEYS = {"cfg", "flf", "end_frame"}
|
||||||
|
|
||||||
|
def _migrate_remove_keys(data: dict) -> None:
|
||||||
|
"""Drop keys that have been removed from the schema."""
|
||||||
|
for item in data.get(KEY_BATCH_DATA, []):
|
||||||
|
if not isinstance(item, dict):
|
||||||
|
continue
|
||||||
|
for k in _REMOVED_KEYS:
|
||||||
|
item.pop(k, None)
|
||||||
|
|
||||||
|
|
||||||
|
def _migrate_key_renames(data: dict) -> None:
|
||||||
|
"""Rename legacy keys to their current names."""
|
||||||
|
for item in data.get(KEY_BATCH_DATA, []):
|
||||||
|
if not isinstance(item, dict):
|
||||||
|
continue
|
||||||
|
if 'reference path' in item and 'middle frame path' not in item:
|
||||||
|
item['middle frame path'] = item.pop('reference path')
|
||||||
|
if 'flf image path' in item and 'end frame path' not in item:
|
||||||
|
item['end frame path'] = item.pop('flf image path')
|
||||||
|
if 'reference image path' in item and 'start frame path' not in item:
|
||||||
|
item['start frame path'] = item.pop('reference image path')
|
||||||
|
# Split old single strength into high+low
|
||||||
|
for prefix in ('start frame', 'middle frame', 'end frame'):
|
||||||
|
old_key = f'{prefix} strength'
|
||||||
|
if old_key in item:
|
||||||
|
val = item.pop(old_key)
|
||||||
|
item.setdefault(f'{prefix} high strength', val)
|
||||||
|
item.setdefault(f'{prefix} low strength', val)
|
||||||
|
|
||||||
|
|
||||||
def _migrate_lora_keys(data: dict) -> None:
|
def _migrate_lora_keys(data: dict) -> None:
|
||||||
"""Split combined lora 'name:strength' into separate name and strength keys.
|
"""Split combined lora 'name:strength' into separate name and strength keys.
|
||||||
|
|
||||||
@@ -208,6 +243,8 @@ def load_json(path: str | Path) -> tuple[dict[str, Any], float]:
|
|||||||
with open(path, 'r') as f:
|
with open(path, 'r') as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
t1 = time.time()
|
t1 = time.time()
|
||||||
|
_migrate_remove_keys(data)
|
||||||
|
_migrate_key_renames(data)
|
||||||
_migrate_lora_keys(data)
|
_migrate_lora_keys(data)
|
||||||
t2 = time.time()
|
t2 = time.time()
|
||||||
mtime = path.stat().st_mtime
|
mtime = path.stat().st_mtime
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { app } from "../../scripts/app.js";
|
||||||
|
|
||||||
|
app.registerExtension({
|
||||||
|
name: "json.manager.binary_index_decoder",
|
||||||
|
|
||||||
|
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||||
|
if (nodeData.name !== "BinaryIndexDecoder") return;
|
||||||
|
|
||||||
|
nodeType.prototype.onExecuted = function (output) {
|
||||||
|
if (!output?.values) return;
|
||||||
|
for (let i = 0; i < Math.min(output.values.length, this.outputs.length); i++) {
|
||||||
|
const val = output.values[i];
|
||||||
|
this.outputs[i].label = `${val} ${this.outputs[i].name}`;
|
||||||
|
this.outputs[i].color_on = (val === "true") ? "#4caf50" : "#888888";
|
||||||
|
this.outputs[i].color_off = (val === "true") ? "#4caf50" : "#888888";
|
||||||
|
}
|
||||||
|
app.graph?.setDirtyCanvas(true, true);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -201,6 +201,60 @@ app.registerExtension({
|
|||||||
app.graph?.setDirtyCanvas(true, true);
|
app.graph?.setDirtyCanvas(true, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// --- Show live value on output slot after execution (INT/FLOAT/BOOL only) ---
|
||||||
|
nodeType.prototype.onExecuted = function (output) {
|
||||||
|
if (!this.outputs.length) return;
|
||||||
|
const val = output?.value?.[0];
|
||||||
|
if (val === undefined) return;
|
||||||
|
const keyWidget = this.widgets?.find(w => w.name === "key_name");
|
||||||
|
const name = keyWidget?.value || this.outputs[0].name;
|
||||||
|
this.outputs[0].label = `${val} ${name}`;
|
||||||
|
const slotType = this.outputs[0].type;
|
||||||
|
const TYPE_COLORS = { "INT": "#3d7eb5", "FLOAT": "#68a468", "BOOLEAN": null };
|
||||||
|
let color;
|
||||||
|
if (slotType === "BOOLEAN") {
|
||||||
|
color = (val === "true") ? "#4caf50" : "#888888";
|
||||||
|
} else {
|
||||||
|
color = TYPE_COLORS[slotType]
|
||||||
|
?? LGraphCanvas?.link_type_colors?.[slotType]
|
||||||
|
?? app.canvas?.default_connection_color_byType?.[slotType];
|
||||||
|
}
|
||||||
|
if (color) {
|
||||||
|
this.outputs[0].color_on = color;
|
||||||
|
this.outputs[0].color_off = color;
|
||||||
|
}
|
||||||
|
app.graph?.setDirtyCanvas(true, true);
|
||||||
|
};
|
||||||
|
|
||||||
|
// --- Highlight all ProjectKey nodes sharing the same key_name on select ---
|
||||||
|
nodeType.prototype.onSelected = function () {
|
||||||
|
const keyWidget = this.widgets?.find(w => w.name === "key_name");
|
||||||
|
const myKey = keyWidget?.value;
|
||||||
|
if (!myKey || !this.graph) return;
|
||||||
|
for (const node of this.graph._nodes) {
|
||||||
|
if (node === this || node.type !== "ProjectKey") continue;
|
||||||
|
const kw = node.widgets?.find(w => w.name === "key_name");
|
||||||
|
if (kw?.value !== myKey) continue;
|
||||||
|
node._savedColor = node.color;
|
||||||
|
node._savedBgColor = node.bgcolor;
|
||||||
|
node.color = "#c8a000";
|
||||||
|
node.bgcolor = "#4a3800";
|
||||||
|
}
|
||||||
|
app.graph?.setDirtyCanvas(true, true);
|
||||||
|
};
|
||||||
|
|
||||||
|
nodeType.prototype.onDeselected = function () {
|
||||||
|
if (!this.graph) return;
|
||||||
|
for (const node of this.graph._nodes) {
|
||||||
|
if (node.type !== "ProjectKey" || !("_savedColor" in node)) continue;
|
||||||
|
node.color = node._savedColor;
|
||||||
|
node.bgcolor = node._savedBgColor;
|
||||||
|
delete node._savedColor;
|
||||||
|
delete node._savedBgColor;
|
||||||
|
}
|
||||||
|
app.graph?.setDirtyCanvas(true, true);
|
||||||
|
};
|
||||||
|
|
||||||
// --- Sync config on click (lazy, no key refresh to avoid race) ---
|
// --- Sync config on click (lazy, no key refresh to avoid race) ---
|
||||||
const origOnMouseDown = nodeType.prototype.onMouseDown;
|
const origOnMouseDown = nodeType.prototype.onMouseDown;
|
||||||
nodeType.prototype.onMouseDown = function (e, localPos, graphCanvas) {
|
nodeType.prototype.onMouseDown = function (e, localPos, graphCanvas) {
|
||||||
|
|||||||
+69
-27
@@ -28,6 +28,35 @@ app.registerExtension({
|
|||||||
return combo;
|
return combo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch active project from Manager and update project_name + title
|
||||||
|
async function refreshActiveProject(node) {
|
||||||
|
const urlW = node.widgets?.find(w => w.name === "manager_url");
|
||||||
|
if (!urlW?.value) return;
|
||||||
|
try {
|
||||||
|
const resp = await fetch(`${urlW.value}/api/active-project`);
|
||||||
|
if (!resp.ok) return;
|
||||||
|
const data = await resp.json();
|
||||||
|
const project = data.project || "";
|
||||||
|
const projW = node.widgets?.find(w => w.name === "project_name");
|
||||||
|
if (projW && projW.value !== project) {
|
||||||
|
projW.value = project;
|
||||||
|
await refreshFiles(node);
|
||||||
|
}
|
||||||
|
_updateTitle(node);
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("[ProjectSource] Failed to fetch active project:", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _updateTitle(node) {
|
||||||
|
const labelW = node.widgets?.find(w => w.name === "label");
|
||||||
|
const projW = node.widgets?.find(w => w.name === "project_name");
|
||||||
|
const label = labelW?.value || "";
|
||||||
|
const project = projW?.value || "?";
|
||||||
|
node.title = label ? `Source: ${label} [${project}]` : `Project Source [${project}]`;
|
||||||
|
app.graph?.setDirtyCanvas(true, true);
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch file list from API and update file_name combo
|
// Fetch file list from API and update file_name combo
|
||||||
async function refreshFiles(node) {
|
async function refreshFiles(node) {
|
||||||
const urlW = node.widgets?.find(w => w.name === "manager_url");
|
const urlW = node.widgets?.find(w => w.name === "manager_url");
|
||||||
@@ -84,22 +113,28 @@ app.registerExtension({
|
|||||||
|
|
||||||
const node = this;
|
const node = this;
|
||||||
|
|
||||||
|
// Hide project_name — it is auto-filled from the Manager's active project
|
||||||
|
const projW = this.widgets?.find(w => w.name === "project_name");
|
||||||
|
if (projW) {
|
||||||
|
if (projW.origType === undefined) projW.origType = projW.type;
|
||||||
|
projW.type = "hidden";
|
||||||
|
projW.hidden = true;
|
||||||
|
projW.computeSize = () => [0, -4];
|
||||||
|
}
|
||||||
|
|
||||||
// Replace file_name STRING with a combo
|
// Replace file_name STRING with a combo
|
||||||
replaceWithCombo(this, "file_name", [], function (value) {
|
replaceWithCombo(this, "file_name", [], function (value) {
|
||||||
notifyRelays(node);
|
notifyRelays(node);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Hook manager_url and project_name to refresh file list + notify relays
|
// Hook manager_url to refresh active project + files + notify relays
|
||||||
for (const name of ["manager_url", "project_name"]) {
|
const urlW = this.widgets?.find(w => w.name === "manager_url");
|
||||||
const w = this.widgets?.find(w => w.name === name);
|
if (urlW) {
|
||||||
if (w) {
|
const origCb = urlW.callback;
|
||||||
const origCb = w.callback;
|
urlW.callback = function (...args) {
|
||||||
w.callback = function (...args) {
|
origCb?.apply(this, args);
|
||||||
origCb?.apply(this, args);
|
refreshActiveProject(node).then(() => notifyRelays(node));
|
||||||
refreshFiles(node);
|
};
|
||||||
notifyRelays(node);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hook sequence_number to notify relays
|
// Hook sequence_number to notify relays
|
||||||
@@ -118,22 +153,27 @@ app.registerExtension({
|
|||||||
const origCallback = labelWidget.callback;
|
const origCallback = labelWidget.callback;
|
||||||
labelWidget.callback = function (...args) {
|
labelWidget.callback = function (...args) {
|
||||||
origCallback?.apply(this, args);
|
origCallback?.apply(this, args);
|
||||||
node.title = labelWidget.value
|
_updateTitle(node);
|
||||||
? `Source: ${labelWidget.value}`
|
|
||||||
: "Project Source";
|
|
||||||
app.graph?.setDirtyCanvas(true, true);
|
|
||||||
};
|
};
|
||||||
// Set initial title
|
|
||||||
if (labelWidget.value) {
|
|
||||||
this.title = `Source: ${labelWidget.value}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auto-fetch active project on creation
|
||||||
|
queueMicrotask(() => refreshActiveProject(node));
|
||||||
};
|
};
|
||||||
|
|
||||||
const origOnConfigure = nodeType.prototype.onConfigure;
|
const origOnConfigure = nodeType.prototype.onConfigure;
|
||||||
nodeType.prototype.onConfigure = function (info) {
|
nodeType.prototype.onConfigure = function (info) {
|
||||||
origOnConfigure?.apply(this, arguments);
|
origOnConfigure?.apply(this, arguments);
|
||||||
|
|
||||||
|
// Hide project_name (may have been serialized as visible)
|
||||||
|
const projW = this.widgets?.find(w => w.name === "project_name");
|
||||||
|
if (projW) {
|
||||||
|
if (projW.origType === undefined) projW.origType = projW.type;
|
||||||
|
projW.type = "hidden";
|
||||||
|
projW.hidden = true;
|
||||||
|
projW.computeSize = () => [0, -4];
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure file_name is a combo (may be STRING from serialization)
|
// Ensure file_name is a combo (may be STRING from serialization)
|
||||||
const fileW = this.widgets?.find(w => w.name === "file_name");
|
const fileW = this.widgets?.find(w => w.name === "file_name");
|
||||||
if (fileW && fileW.type !== "combo") {
|
if (fileW && fileW.type !== "combo") {
|
||||||
@@ -143,16 +183,18 @@ app.registerExtension({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const labelWidget = this.widgets?.find(w => w.name === "label");
|
_updateTitle(this);
|
||||||
if (labelWidget?.value) {
|
|
||||||
this.title = `Source: ${labelWidget.value}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deferred: refresh file list once graph is ready
|
// Deferred: fetch active project (and files) once graph is ready
|
||||||
const node = this;
|
const node = this;
|
||||||
queueMicrotask(() => {
|
queueMicrotask(() => refreshActiveProject(node));
|
||||||
refreshFiles(node);
|
};
|
||||||
});
|
|
||||||
|
// Re-check active project on click (picks up changes made in the Manager)
|
||||||
|
const origOnMouseDown = nodeType.prototype.onMouseDown;
|
||||||
|
nodeType.prototype.onMouseDown = function (e, localPos, graphCanvas) {
|
||||||
|
origOnMouseDown?.apply(this, arguments);
|
||||||
|
refreshActiveProject(this);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user