feat: add .opencode to gitignore and refactor lora routes

- Add .opencode directory to gitignore for agent-related files
- Refactor lora_routes.py with consistent string formatting and improved route registration
- Add DualRangeSlider Vue component for enhanced UI controls
This commit is contained in:
Will Miao
2026-01-13 13:59:36 +08:00
parent 688baef2f0
commit 1ebd2c93a0
10 changed files with 2793 additions and 662 deletions

3
.gitignore vendored
View File

@@ -12,6 +12,9 @@ coverage/
.coverage .coverage
model_cache/ model_cache/
# agent
.opencode/
# Vue widgets development cache (but keep build output) # Vue widgets development cache (but keep build output)
vue-widgets/node_modules/ vue-widgets/node_modules/
vue-widgets/.vite/ vue-widgets/.vite/

View File

@@ -12,14 +12,15 @@ from ..utils.utils import get_lora_info
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class LoraRoutes(BaseModelRoutes): class LoraRoutes(BaseModelRoutes):
"""LoRA-specific route controller""" """LoRA-specific route controller"""
def __init__(self): def __init__(self):
"""Initialize LoRA routes with LoRA service""" """Initialize LoRA routes with LoRA service"""
super().__init__() super().__init__()
self.template_name = "loras.html" self.template_name = "loras.html"
async def initialize_services(self): async def initialize_services(self):
"""Initialize services from ServiceRegistry""" """Initialize services from ServiceRegistry"""
lora_scanner = await ServiceRegistry.get_lora_scanner() lora_scanner = await ServiceRegistry.get_lora_scanner()
@@ -29,231 +30,225 @@ class LoraRoutes(BaseModelRoutes):
# Attach service dependencies # Attach service dependencies
self.attach_service(self.service) self.attach_service(self.service)
def setup_routes(self, app: web.Application): def setup_routes(self, app: web.Application):
"""Setup LoRA routes""" """Setup LoRA routes"""
# Schedule service initialization on app startup # Schedule service initialization on app startup
app.on_startup.append(lambda _: self.initialize_services()) app.on_startup.append(lambda _: self.initialize_services())
# Setup common routes with 'loras' prefix (includes page route) # Setup common routes with 'loras' prefix (includes page route)
super().setup_routes(app, 'loras') super().setup_routes(app, "loras")
def setup_specific_routes(self, registrar: ModelRouteRegistrar, prefix: str): def setup_specific_routes(self, registrar: ModelRouteRegistrar, prefix: str):
"""Setup LoRA-specific routes""" """Setup LoRA-specific routes"""
# LoRA-specific query routes # LoRA-specific query routes
registrar.add_prefixed_route('GET', '/api/lm/{prefix}/letter-counts', prefix, self.get_letter_counts) registrar.add_prefixed_route(
registrar.add_prefixed_route('GET', '/api/lm/{prefix}/get-trigger-words', prefix, self.get_lora_trigger_words) "GET", "/api/lm/{prefix}/letter-counts", prefix, self.get_letter_counts
registrar.add_prefixed_route('GET', '/api/lm/{prefix}/usage-tips-by-path', prefix, self.get_lora_usage_tips_by_path) )
registrar.add_prefixed_route(
"GET",
"/api/lm/{prefix}/get-trigger-words",
prefix,
self.get_lora_trigger_words,
)
registrar.add_prefixed_route(
"GET",
"/api/lm/{prefix}/usage-tips-by-path",
prefix,
self.get_lora_usage_tips_by_path,
)
# Randomizer routes # Randomizer routes
registrar.add_prefixed_route('POST', '/api/lm/{prefix}/random-sample', prefix, self.get_random_loras) registrar.add_prefixed_route(
"POST", "/api/lm/{prefix}/random-sample", prefix, self.get_random_loras
)
# ComfyUI integration # ComfyUI integration
registrar.add_prefixed_route('POST', '/api/lm/{prefix}/get_trigger_words', prefix, self.get_trigger_words) registrar.add_prefixed_route(
"POST", "/api/lm/{prefix}/get_trigger_words", prefix, self.get_trigger_words
)
def _parse_specific_params(self, request: web.Request) -> Dict: def _parse_specific_params(self, request: web.Request) -> Dict:
"""Parse LoRA-specific parameters""" """Parse LoRA-specific parameters"""
params = {} params = {}
# LoRA-specific parameters # LoRA-specific parameters
if 'first_letter' in request.query: if "first_letter" in request.query:
params['first_letter'] = request.query.get('first_letter') params["first_letter"] = request.query.get("first_letter")
# Handle fuzzy search parameter name variation # Handle fuzzy search parameter name variation
if request.query.get('fuzzy') == 'true': if request.query.get("fuzzy") == "true":
params['fuzzy_search'] = True params["fuzzy_search"] = True
# Handle additional filter parameters for LoRAs # Handle additional filter parameters for LoRAs
if 'lora_hash' in request.query: if "lora_hash" in request.query:
if not params.get('hash_filters'): if not params.get("hash_filters"):
params['hash_filters'] = {} params["hash_filters"] = {}
params['hash_filters']['single_hash'] = request.query['lora_hash'].lower() params["hash_filters"]["single_hash"] = request.query["lora_hash"].lower()
elif 'lora_hashes' in request.query: elif "lora_hashes" in request.query:
if not params.get('hash_filters'): if not params.get("hash_filters"):
params['hash_filters'] = {} params["hash_filters"] = {}
params['hash_filters']['multiple_hashes'] = [h.lower() for h in request.query['lora_hashes'].split(',')] params["hash_filters"]["multiple_hashes"] = [
h.lower() for h in request.query["lora_hashes"].split(",")
]
return params return params
def _validate_civitai_model_type(self, model_type: str) -> bool: def _validate_civitai_model_type(self, model_type: str) -> bool:
"""Validate CivitAI model type for LoRA""" """Validate CivitAI model type for LoRA"""
from ..utils.constants import VALID_LORA_TYPES from ..utils.constants import VALID_LORA_TYPES
return model_type.lower() in VALID_LORA_TYPES return model_type.lower() in VALID_LORA_TYPES
def _get_expected_model_types(self) -> str: def _get_expected_model_types(self) -> str:
"""Get expected model types string for error messages""" """Get expected model types string for error messages"""
return "LORA, LoCon, or DORA" return "LORA, LoCon, or DORA"
# LoRA-specific route handlers # LoRA-specific route handlers
async def get_letter_counts(self, request: web.Request) -> web.Response: async def get_letter_counts(self, request: web.Request) -> web.Response:
"""Get count of LoRAs for each letter of the alphabet""" """Get count of LoRAs for each letter of the alphabet"""
try: try:
letter_counts = await self.service.get_letter_counts() letter_counts = await self.service.get_letter_counts()
return web.json_response({ return web.json_response({"success": True, "letter_counts": letter_counts})
'success': True,
'letter_counts': letter_counts
})
except Exception as e: except Exception as e:
logger.error(f"Error getting letter counts: {e}") logger.error(f"Error getting letter counts: {e}")
return web.json_response({ return web.json_response({"success": False, "error": str(e)}, status=500)
'success': False,
'error': str(e)
}, status=500)
async def get_lora_notes(self, request: web.Request) -> web.Response: async def get_lora_notes(self, request: web.Request) -> web.Response:
"""Get notes for a specific LoRA file""" """Get notes for a specific LoRA file"""
try: try:
lora_name = request.query.get('name') lora_name = request.query.get("name")
if not lora_name: if not lora_name:
return web.Response(text='Lora file name is required', status=400) return web.Response(text="Lora file name is required", status=400)
notes = await self.service.get_lora_notes(lora_name) notes = await self.service.get_lora_notes(lora_name)
if notes is not None: if notes is not None:
return web.json_response({ return web.json_response({"success": True, "notes": notes})
'success': True,
'notes': notes
})
else: else:
return web.json_response({ return web.json_response(
'success': False, {"success": False, "error": "LoRA not found in cache"}, status=404
'error': 'LoRA not found in cache' )
}, status=404)
except Exception as e: except Exception as e:
logger.error(f"Error getting lora notes: {e}", exc_info=True) logger.error(f"Error getting lora notes: {e}", exc_info=True)
return web.json_response({ return web.json_response({"success": False, "error": str(e)}, status=500)
'success': False,
'error': str(e)
}, status=500)
async def get_lora_trigger_words(self, request: web.Request) -> web.Response: async def get_lora_trigger_words(self, request: web.Request) -> web.Response:
"""Get trigger words for a specific LoRA file""" """Get trigger words for a specific LoRA file"""
try: try:
lora_name = request.query.get('name') lora_name = request.query.get("name")
if not lora_name: if not lora_name:
return web.Response(text='Lora file name is required', status=400) return web.Response(text="Lora file name is required", status=400)
trigger_words = await self.service.get_lora_trigger_words(lora_name) trigger_words = await self.service.get_lora_trigger_words(lora_name)
return web.json_response({ return web.json_response({"success": True, "trigger_words": trigger_words})
'success': True,
'trigger_words': trigger_words
})
except Exception as e: except Exception as e:
logger.error(f"Error getting lora trigger words: {e}", exc_info=True) logger.error(f"Error getting lora trigger words: {e}", exc_info=True)
return web.json_response({ return web.json_response({"success": False, "error": str(e)}, status=500)
'success': False,
'error': str(e)
}, status=500)
async def get_lora_usage_tips_by_path(self, request: web.Request) -> web.Response: async def get_lora_usage_tips_by_path(self, request: web.Request) -> web.Response:
"""Get usage tips for a LoRA by its relative path""" """Get usage tips for a LoRA by its relative path"""
try: try:
relative_path = request.query.get('relative_path') relative_path = request.query.get("relative_path")
if not relative_path: if not relative_path:
return web.Response(text='Relative path is required', status=400) return web.Response(text="Relative path is required", status=400)
usage_tips = await self.service.get_lora_usage_tips_by_relative_path(relative_path) usage_tips = await self.service.get_lora_usage_tips_by_relative_path(
return web.json_response({ relative_path
'success': True, )
'usage_tips': usage_tips or '' return web.json_response({"success": True, "usage_tips": usage_tips or ""})
})
except Exception as e: except Exception as e:
logger.error(f"Error getting lora usage tips by path: {e}", exc_info=True) logger.error(f"Error getting lora usage tips by path: {e}", exc_info=True)
return web.json_response({ return web.json_response({"success": False, "error": str(e)}, status=500)
'success': False,
'error': str(e)
}, status=500)
async def get_lora_preview_url(self, request: web.Request) -> web.Response: async def get_lora_preview_url(self, request: web.Request) -> web.Response:
"""Get the static preview URL for a LoRA file""" """Get the static preview URL for a LoRA file"""
try: try:
lora_name = request.query.get('name') lora_name = request.query.get("name")
if not lora_name: if not lora_name:
return web.Response(text='Lora file name is required', status=400) return web.Response(text="Lora file name is required", status=400)
preview_url = await self.service.get_lora_preview_url(lora_name) preview_url = await self.service.get_lora_preview_url(lora_name)
if preview_url: if preview_url:
return web.json_response({ return web.json_response({"success": True, "preview_url": preview_url})
'success': True,
'preview_url': preview_url
})
else: else:
return web.json_response({ return web.json_response(
'success': False, {
'error': 'No preview URL found for the specified lora' "success": False,
}, status=404) "error": "No preview URL found for the specified lora",
},
status=404,
)
except Exception as e: except Exception as e:
logger.error(f"Error getting lora preview URL: {e}", exc_info=True) logger.error(f"Error getting lora preview URL: {e}", exc_info=True)
return web.json_response({ return web.json_response({"success": False, "error": str(e)}, status=500)
'success': False,
'error': str(e)
}, status=500)
async def get_lora_civitai_url(self, request: web.Request) -> web.Response: async def get_lora_civitai_url(self, request: web.Request) -> web.Response:
"""Get the Civitai URL for a LoRA file""" """Get the Civitai URL for a LoRA file"""
try: try:
lora_name = request.query.get('name') lora_name = request.query.get("name")
if not lora_name: if not lora_name:
return web.Response(text='Lora file name is required', status=400) return web.Response(text="Lora file name is required", status=400)
result = await self.service.get_lora_civitai_url(lora_name) result = await self.service.get_lora_civitai_url(lora_name)
if result['civitai_url']: if result["civitai_url"]:
return web.json_response({ return web.json_response({"success": True, **result})
'success': True,
**result
})
else: else:
return web.json_response({ return web.json_response(
'success': False, {
'error': 'No Civitai data found for the specified lora' "success": False,
}, status=404) "error": "No Civitai data found for the specified lora",
},
status=404,
)
except Exception as e: except Exception as e:
logger.error(f"Error getting lora Civitai URL: {e}", exc_info=True) logger.error(f"Error getting lora Civitai URL: {e}", exc_info=True)
return web.json_response({ return web.json_response({"success": False, "error": str(e)}, status=500)
'success': False,
'error': str(e)
}, status=500)
async def get_random_loras(self, request: web.Request) -> web.Response: async def get_random_loras(self, request: web.Request) -> web.Response:
"""Get random LoRAs based on filters and strength ranges""" """Get random LoRAs based on filters and strength ranges"""
try: try:
json_data = await request.json() json_data = await request.json()
# Parse parameters # Parse parameters
count = json_data.get('count', 5) count = json_data.get("count", 5)
count_min = json_data.get('count_min') count_min = json_data.get("count_min")
count_max = json_data.get('count_max') count_max = json_data.get("count_max")
model_strength_min = float(json_data.get('model_strength_min', 0.0)) model_strength_min = float(json_data.get("model_strength_min", 0.0))
model_strength_max = float(json_data.get('model_strength_max', 1.0)) model_strength_max = float(json_data.get("model_strength_max", 1.0))
use_same_clip_strength = json_data.get('use_same_clip_strength', True) use_same_clip_strength = json_data.get("use_same_clip_strength", True)
clip_strength_min = float(json_data.get('clip_strength_min', 0.0)) clip_strength_min = float(json_data.get("clip_strength_min", 0.0))
clip_strength_max = float(json_data.get('clip_strength_max', 1.0)) clip_strength_max = float(json_data.get("clip_strength_max", 1.0))
locked_loras = json_data.get('locked_loras', []) locked_loras = json_data.get("locked_loras", [])
pool_config = json_data.get('pool_config') pool_config = json_data.get("pool_config")
# Determine target count # Determine target count
if count_min is not None and count_max is not None: if count_min is not None and count_max is not None:
import random import random
target_count = random.randint(count_min, count_max) target_count = random.randint(count_min, count_max)
else: else:
target_count = count target_count = count
# Validate parameters # Validate parameters
if target_count < 1 or target_count > 100: if target_count < 1 or target_count > 100:
return web.json_response({ return web.json_response(
'success': False, {"success": False, "error": "Count must be between 1 and 100"},
'error': 'Count must be between 1 and 100' status=400,
}, status=400) )
if model_strength_min < 0 or model_strength_max > 10: if model_strength_min < -10 or model_strength_max > 10:
return web.json_response({ return web.json_response(
'success': False, {
'error': 'Model strength must be between 0 and 10' "success": False,
}, status=400) "error": "Model strength must be between -10 and 10",
},
status=400,
)
# Get random LoRAs from service # Get random LoRAs from service
result_loras = await self.service.get_random_loras( result_loras = await self.service.get_random_loras(
@@ -264,27 +259,19 @@ class LoraRoutes(BaseModelRoutes):
clip_strength_min=clip_strength_min, clip_strength_min=clip_strength_min,
clip_strength_max=clip_strength_max, clip_strength_max=clip_strength_max,
locked_loras=locked_loras, locked_loras=locked_loras,
pool_config=pool_config pool_config=pool_config,
) )
return web.json_response({ return web.json_response(
'success': True, {"success": True, "loras": result_loras, "count": len(result_loras)}
'loras': result_loras, )
'count': len(result_loras)
})
except ValueError as e: except ValueError as e:
logger.error(f"Invalid parameter for random LoRAs: {e}") logger.error(f"Invalid parameter for random LoRAs: {e}")
return web.json_response({ return web.json_response({"success": False, "error": str(e)}, status=400)
'success': False,
'error': str(e)
}, status=400)
except Exception as e: except Exception as e:
logger.error(f"Error getting random LoRAs: {e}", exc_info=True) logger.error(f"Error getting random LoRAs: {e}", exc_info=True)
return web.json_response({ return web.json_response({"success": False, "error": str(e)}, status=500)
'success': False,
'error': str(e)
}, status=500)
async def get_trigger_words(self, request: web.Request) -> web.Response: async def get_trigger_words(self, request: web.Request) -> web.Response:
"""Get trigger words for specified LoRA models""" """Get trigger words for specified LoRA models"""
@@ -292,15 +279,17 @@ class LoraRoutes(BaseModelRoutes):
json_data = await request.json() json_data = await request.json()
lora_names = json_data.get("lora_names", []) lora_names = json_data.get("lora_names", [])
node_ids = json_data.get("node_ids", []) node_ids = json_data.get("node_ids", [])
all_trigger_words = [] all_trigger_words = []
for lora_name in lora_names: for lora_name in lora_names:
_, trigger_words = get_lora_info(lora_name) _, trigger_words = get_lora_info(lora_name)
all_trigger_words.extend(trigger_words) all_trigger_words.extend(trigger_words)
# Format the trigger words # Format the trigger words
trigger_words_text = ",, ".join(all_trigger_words) if all_trigger_words else "" trigger_words_text = (
",, ".join(all_trigger_words) if all_trigger_words else ""
)
# Send update to all connected trigger word toggle nodes # Send update to all connected trigger word toggle nodes
for entry in node_ids: for entry in node_ids:
node_identifier = entry node_identifier = entry
@@ -314,21 +303,15 @@ class LoraRoutes(BaseModelRoutes):
except (TypeError, ValueError): except (TypeError, ValueError):
parsed_node_id = node_identifier parsed_node_id = node_identifier
payload = { payload = {"id": parsed_node_id, "message": trigger_words_text}
"id": parsed_node_id,
"message": trigger_words_text
}
if graph_identifier is not None: if graph_identifier is not None:
payload["graph_id"] = str(graph_identifier) payload["graph_id"] = str(graph_identifier)
PromptServer.instance.send_sync("trigger_word_update", payload) PromptServer.instance.send_sync("trigger_word_update", payload)
return web.json_response({"success": True}) return web.json_response({"success": True})
except Exception as e: except Exception as e:
logger.error(f"Error getting trigger words: {e}") logger.error(f"Error getting trigger words: {e}")
return web.json_response({ return web.json_response({"success": False, "error": str(e)}, status=500)
"success": False,
"error": str(e)
}, status=500)

View File

@@ -37,155 +37,167 @@ async def test_get_random_loras_success(routes):
"""Test successful random LoRA generation""" """Test successful random LoRA generation"""
routes.service.random_loras = [ routes.service.random_loras = [
{ {
'name': 'test_lora_1', "name": "test_lora_1",
'strength': 0.8, "strength": 0.8,
'clipStrength': 0.8, "clipStrength": 0.8,
'active': True, "active": True,
'expanded': False, "expanded": False,
'locked': False "locked": False,
}, },
{ {
'name': 'test_lora_2', "name": "test_lora_2",
'strength': 0.6, "strength": 0.6,
'clipStrength': 0.6, "clipStrength": 0.6,
'active': True, "active": True,
'expanded': False, "expanded": False,
'locked': False "locked": False,
} },
] ]
request = DummyRequest(json_data={ request = DummyRequest(
'count': 5, json_data={
'model_strength_min': 0.5, "count": 5,
'model_strength_max': 1.0, "model_strength_min": 0.5,
'use_same_clip_strength': True, "model_strength_max": 1.0,
'locked_loras': [] "use_same_clip_strength": True,
}) "locked_loras": [],
}
)
response = await routes.get_random_loras(request) response = await routes.get_random_loras(request)
payload = json.loads(response.text) payload = json.loads(response.text)
assert response.status == 200 assert response.status == 200
assert payload['success'] is True assert payload["success"] is True
assert 'loras' in payload assert "loras" in payload
assert payload['count'] == 2 assert payload["count"] == 2
async def test_get_random_loras_with_range(routes): async def test_get_random_loras_with_range(routes):
"""Test random LoRAs with count range""" """Test random LoRAs with count range"""
routes.service.random_loras = [ routes.service.random_loras = [
{ {
'name': 'test_lora_1', "name": "test_lora_1",
'strength': 0.8, "strength": 0.8,
'clipStrength': 0.8, "clipStrength": 0.8,
'active': True, "active": True,
'expanded': False, "expanded": False,
'locked': False "locked": False,
} }
] ]
request = DummyRequest(json_data={ request = DummyRequest(
'count_min': 3, json_data={
'count_max': 7, "count_min": 3,
'model_strength_min': 0.0, "count_max": 7,
'model_strength_max': 1.0, "model_strength_min": 0.0,
'use_same_clip_strength': True "model_strength_max": 1.0,
}) "use_same_clip_strength": True,
}
)
response = await routes.get_random_loras(request) response = await routes.get_random_loras(request)
payload = json.loads(response.text) payload = json.loads(response.text)
assert response.status == 200 assert response.status == 200
assert payload['success'] is True assert payload["success"] is True
async def test_get_random_loras_invalid_count(routes): async def test_get_random_loras_invalid_count(routes):
"""Test invalid count parameter""" """Test invalid count parameter"""
request = DummyRequest(json_data={ request = DummyRequest(
'count': 150, # Over limit json_data={
'model_strength_min': 0.0, "count": 150, # Over limit
'model_strength_max': 1.0 "model_strength_min": 0.0,
}) "model_strength_max": 1.0,
}
)
response = await routes.get_random_loras(request) response = await routes.get_random_loras(request)
payload = json.loads(response.text) payload = json.loads(response.text)
assert response.status == 400 assert response.status == 400
assert payload['success'] is False assert payload["success"] is False
assert 'Count must be between 1 and 100' in payload['error'] assert "Count must be between 1 and 100" in payload["error"]
async def test_get_random_loras_invalid_strength(routes): async def test_get_random_loras_invalid_strength(routes):
"""Test invalid strength range""" """Test invalid strength range"""
request = DummyRequest(json_data={ request = DummyRequest(
'count': 5, json_data={
'model_strength_min': -0.5, # Invalid "count": 5,
'model_strength_max': 1.0 "model_strength_min": -11, # Invalid (below -10)
}) "model_strength_max": 1.0,
}
)
response = await routes.get_random_loras(request) response = await routes.get_random_loras(request)
payload = json.loads(response.text) payload = json.loads(response.text)
assert response.status == 400 assert response.status == 400
assert payload['success'] is False assert payload["success"] is False
assert "Model strength must be between -10 and 10" in payload["error"]
async def test_get_random_loras_with_locked(routes): async def test_get_random_loras_with_locked(routes):
"""Test random LoRAs with locked items""" """Test random LoRAs with locked items"""
routes.service.random_loras = [ routes.service.random_loras = [
{ {
'name': 'new_lora', "name": "new_lora",
'strength': 0.7, "strength": 0.7,
'clipStrength': 0.7, "clipStrength": 0.7,
'active': True, "active": True,
'expanded': False, "expanded": False,
'locked': False "locked": False,
}, },
{ {
'name': 'locked_lora', "name": "locked_lora",
'strength': 0.9, "strength": 0.9,
'clipStrength': 0.9, "clipStrength": 0.9,
'active': True, "active": True,
'expanded': False, "expanded": False,
'locked': True "locked": True,
} },
] ]
request = DummyRequest(json_data={ request = DummyRequest(
'count': 5, json_data={
'model_strength_min': 0.5, "count": 5,
'model_strength_max': 1.0, "model_strength_min": 0.5,
'use_same_clip_strength': True, "model_strength_max": 1.0,
'locked_loras': [ "use_same_clip_strength": True,
{ "locked_loras": [
'name': 'locked_lora', {
'strength': 0.9, "name": "locked_lora",
'clipStrength': 0.9, "strength": 0.9,
'active': True, "clipStrength": 0.9,
'expanded': False, "active": True,
'locked': True "expanded": False,
} "locked": True,
] }
}) ],
}
)
response = await routes.get_random_loras(request) response = await routes.get_random_loras(request)
payload = json.loads(response.text) payload = json.loads(response.text)
assert response.status == 200 assert response.status == 200
assert payload['success'] is True assert payload["success"] is True
async def test_get_random_loras_error(routes, monkeypatch): async def test_get_random_loras_error(routes, monkeypatch):
"""Test error handling""" """Test error handling"""
async def failing(*_args, **_kwargs): async def failing(*_args, **_kwargs):
raise RuntimeError("Service error") raise RuntimeError("Service error")
routes.service.get_random_loras = failing routes.service.get_random_loras = failing
request = DummyRequest(json_data={'count': 5}) request = DummyRequest(json_data={"count": 5})
response = await routes.get_random_loras(request) response = await routes.get_random_loras(request)
payload = json.loads(response.text) payload = json.loads(response.text)
assert response.status == 500 assert response.status == 500
assert payload['success'] is False assert payload["success"] is False
assert 'error' in payload assert "error" in payload

View File

@@ -104,7 +104,7 @@ onMounted(async () => {
// Handle external value updates (e.g., loading workflow, paste) // Handle external value updates (e.g., loading workflow, paste)
props.widget.onSetValue = (v) => { props.widget.onSetValue = (v) => {
state.restoreFromConfig(v) state.restoreFromConfig(v as LoraPoolConfig | LegacyLoraPoolConfig)
state.refreshPreview() state.refreshPreview()
} }

View File

@@ -7,8 +7,8 @@
<!-- LoRA Count --> <!-- LoRA Count -->
<div class="setting-section"> <div class="setting-section">
<label class="setting-label">LoRA Count</label> <label class="setting-label">LoRA Count</label>
<div class="count-mode-selector"> <div class="count-mode-tabs">
<label class="radio-label"> <label class="count-mode-tab" :class="{ active: countMode === 'fixed' }">
<input <input
type="radio" type="radio"
name="count-mode" name="count-mode"
@@ -16,20 +16,9 @@
:checked="countMode === 'fixed'" :checked="countMode === 'fixed'"
@change="$emit('update:countMode', 'fixed')" @change="$emit('update:countMode', 'fixed')"
/> />
<span>Fixed:</span> <span class="count-mode-tab-label">Fixed</span>
<input
type="number"
class="number-input"
:value="countFixed"
:disabled="countMode !== 'fixed'"
min="1"
max="100"
@input="$emit('update:countFixed', parseInt(($event.target as HTMLInputElement).value))"
/>
</label> </label>
</div> <label class="count-mode-tab" :class="{ active: countMode === 'range' }">
<div class="count-mode-selector">
<label class="radio-label">
<input <input
type="radio" type="radio"
name="count-mode" name="count-mode"
@@ -37,101 +26,82 @@
:checked="countMode === 'range'" :checked="countMode === 'range'"
@change="$emit('update:countMode', 'range')" @change="$emit('update:countMode', 'range')"
/> />
<span>Range:</span> <span class="count-mode-tab-label">Range</span>
<input
type="number"
class="number-input"
:value="countMin"
:disabled="countMode !== 'range'"
min="1"
max="100"
@input="$emit('update:countMin', parseInt(($event.target as HTMLInputElement).value))"
/>
<span>to</span>
<input
type="number"
class="number-input"
:value="countMax"
:disabled="countMode !== 'range'"
min="1"
max="100"
@input="$emit('update:countMax', parseInt(($event.target as HTMLInputElement).value))"
/>
</label> </label>
</div> </div>
<div class="slider-container">
<SingleSlider
v-if="countMode === 'fixed'"
:min="1"
:max="10"
:value="countFixed"
:step="1"
:default-range="{ min: 1, max: 5 }"
@update:value="$emit('update:countFixed', $event)"
/>
<DualRangeSlider
v-else
:min="1"
:max="10"
:value-min="countMin"
:value-max="countMax"
:step="1"
:default-range="{ min: 1, max: 5 }"
@update:value-min="$emit('update:countMin', $event)"
@update:value-max="$emit('update:countMax', $event)"
/>
</div>
</div> </div>
<!-- Model Strength Range --> <!-- Model Strength Range -->
<div class="setting-section"> <div class="setting-section">
<label class="setting-label">Model Strength Range</label> <label class="setting-label">Model Strength Range</label>
<div class="strength-inputs"> <div class="slider-container">
<div class="strength-input-group"> <DualRangeSlider
<label>Min:</label> :min="-10"
<input :max="10"
type="number" :value-min="modelStrengthMin"
class="number-input" :value-max="modelStrengthMax"
:value="modelStrengthMin" :step="0.1"
min="0" :default-range="{ min: -2, max: 3 }"
max="10" @update:value-min="$emit('update:modelStrengthMin', $event)"
step="0.1" @update:value-max="$emit('update:modelStrengthMax', $event)"
@input="$emit('update:modelStrengthMin', parseFloat(($event.target as HTMLInputElement).value))" />
/>
</div>
<div class="strength-input-group">
<label>Max:</label>
<input
type="number"
class="number-input"
:value="modelStrengthMax"
min="0"
max="10"
step="0.1"
@input="$emit('update:modelStrengthMax', parseFloat(($event.target as HTMLInputElement).value))"
/>
</div>
</div> </div>
</div> </div>
<!-- Clip Strength Range --> <!-- Clip Strength Range -->
<div class="setting-section"> <div class="setting-section">
<label class="setting-label">Clip Strength Range</label> <div class="section-header-with-toggle">
<div class="checkbox-group"> <label class="setting-label">
<label class="checkbox-label"> Clip Strength Range - {{ useSameClipStrength ? 'Use Model Strength' : 'Custom Range' }}
<input
type="checkbox"
:checked="useSameClipStrength"
@change="$emit('update:useSameClipStrength', ($event.target as HTMLInputElement).checked)"
/>
<span>Same as model</span>
</label> </label>
<button
type="button"
class="toggle-switch"
:class="{ 'toggle-switch--active': useSameClipStrength }"
@click="$emit('update:useSameClipStrength', !useSameClipStrength)"
role="switch"
:aria-checked="useSameClipStrength"
title="Lock clip strength to model strength"
>
<span class="toggle-switch__track"></span>
<span class="toggle-switch__thumb"></span>
</button>
</div> </div>
<div class="strength-inputs" :class="{ disabled: isClipStrengthDisabled }"> <div class="slider-container">
<div class="strength-input-group"> <DualRangeSlider
<label>Min:</label> :min="-10"
<input :max="10"
type="number" :value-min="clipStrengthMin"
class="number-input" :value-max="clipStrengthMax"
:value="clipStrengthMin" :step="0.1"
:disabled="isClipStrengthDisabled" :default-range="{ min: -1, max: 2 }"
min="0" :disabled="isClipStrengthDisabled"
max="10" @update:value-min="$emit('update:clipStrengthMin', $event)"
step="0.1" @update:value-max="$emit('update:clipStrengthMax', $event)"
@input="$emit('update:clipStrengthMin', parseFloat(($event.target as HTMLInputElement).value))" />
/>
</div>
<div class="strength-input-group">
<label>Max:</label>
<input
type="number"
class="number-input"
:value="clipStrengthMax"
:disabled="isClipStrengthDisabled"
min="0"
max="10"
step="0.1"
@input="$emit('update:clipStrengthMax', parseFloat(($event.target as HTMLInputElement).value))"
/>
</div>
</div> </div>
</div> </div>
@@ -200,6 +170,8 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { ref } from 'vue'
import LastUsedPreview from './LastUsedPreview.vue' import LastUsedPreview from './LastUsedPreview.vue'
import SingleSlider from '../shared/SingleSlider.vue'
import DualRangeSlider from '../shared/DualRangeSlider.vue'
import type { LoraEntry } from '../../composables/types' import type { LoraEntry } from '../../composables/types'
defineProps<{ defineProps<{
@@ -255,123 +227,155 @@ const areLorasEqual = (a: LoraEntry[] | null, b: LoraEntry[] | null): boolean =>
.randomizer-settings { .randomizer-settings {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 16px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
color: #e4e4e7; color: #e4e4e7;
} }
.settings-header { .settings-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px; margin-bottom: 8px;
} }
.settings-title { .settings-title {
font-size: 11px; font-size: 10px;
font-weight: 600; font-weight: 600;
letter-spacing: 0.05em; letter-spacing: 0.05em;
color: #a1a1aa; color: var(--fg-color, #fff);
opacity: 0.6;
margin: 0; margin: 0;
text-transform: uppercase; text-transform: uppercase;
} }
.setting-section { .setting-section {
display: flex; margin-bottom: 16px;
flex-direction: column;
gap: 8px;
} }
.setting-label { .setting-label {
font-size: 12px; font-size: 12px;
font-weight: 500; font-weight: 500;
color: #d4d4d8; color: #d4d4d8;
display: block;
margin-bottom: 8px;
} }
.count-mode-selector, .section-header-with-toggle {
.roll-mode-selector {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; justify-content: space-between;
padding: 6px 8px; margin-bottom: 8px;
background: rgba(30, 30, 36, 0.5); }
.section-header-with-toggle .setting-label {
margin-bottom: 0;
}
/* Count Mode Tabs */
.count-mode-tabs {
display: flex;
background: rgba(26, 32, 44, 0.9);
border: 1px solid rgba(226, 232, 240, 0.2);
border-radius: 4px; border-radius: 4px;
overflow: hidden;
margin-bottom: 8px;
} }
.radio-label { .count-mode-tab {
display: flex;
align-items: center;
gap: 8px;
font-size: 13px;
color: #e4e4e7;
cursor: pointer;
flex: 1; flex: 1;
} position: relative;
padding: 8px 12px;
.radio-label input[type='radio'] { text-align: center;
cursor: pointer; cursor: pointer;
transition: all 0.2s ease;
} }
.radio-label input[type='radio']:disabled { .count-mode-tab input[type="radio"] {
cursor: not-allowed; position: absolute;
opacity: 0;
width: 0;
height: 0;
} }
.number-input { .count-mode-tab-label {
width: 60px;
padding: 4px 8px;
background: rgba(20, 20, 24, 0.6);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 3px;
color: #e4e4e7;
font-size: 13px;
}
.number-input:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.strength-inputs {
display: flex;
gap: 12px;
padding: 6px 8px;
background: rgba(30, 30, 36, 0.5);
border-radius: 4px;
}
.strength-inputs.disabled {
opacity: 0.5;
}
.strength-input-group {
display: flex;
align-items: center;
gap: 6px;
flex: 1;
}
.strength-input-group label {
font-size: 12px; font-size: 12px;
color: #d4d4d8; font-weight: 500;
color: rgba(226, 232, 240, 0.7);
transition: all 0.2s ease;
} }
.checkbox-group { .count-mode-tab:hover .count-mode-tab-label {
padding: 6px 8px; color: rgba(226, 232, 240, 0.9);
background: rgba(30, 30, 36, 0.5); }
.count-mode-tab.active .count-mode-tab-label {
color: rgba(191, 219, 254, 1);
font-weight: 600;
}
.count-mode-tab.active {
background: rgba(66, 153, 225, 0.2);
}
.count-mode-tab.active::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 2px;
background: rgba(66, 153, 225, 0.9);
}
.slider-container {
background: rgba(26, 32, 44, 0.9);
border: 1px solid rgba(226, 232, 240, 0.2);
border-radius: 4px; border-radius: 4px;
padding: 4px 8px;
} }
.checkbox-label { /* Toggle Switch (same style as LicenseSection) */
display: flex; .toggle-switch {
align-items: center; position: relative;
gap: 8px; width: 36px;
font-size: 13px; height: 20px;
color: #e4e4e7; padding: 0;
background: transparent;
border: none;
cursor: pointer; cursor: pointer;
} }
.checkbox-label input[type='checkbox'] { .toggle-switch__track {
cursor: pointer; position: absolute;
inset: 0;
background: var(--comfy-input-bg, #333);
border: 1px solid var(--border-color, #444);
border-radius: 10px;
transition: all 0.2s;
}
.toggle-switch--active .toggle-switch__track {
background: rgba(66, 153, 225, 0.3);
border-color: rgba(66, 153, 225, 0.6);
}
.toggle-switch__thumb {
position: absolute;
top: 2px;
left: 2px;
width: 14px;
height: 14px;
background: var(--fg-color, #fff);
border-radius: 50%;
transition: all 0.2s;
opacity: 0.6;
}
.toggle-switch--active .toggle-switch__thumb {
transform: translateX(16px);
background: #4299e1;
opacity: 1;
}
.toggle-switch:hover .toggle-switch__thumb {
opacity: 1;
} }
/* Roll buttons with tooltip container */ /* Roll buttons with tooltip container */

View File

@@ -0,0 +1,295 @@
<template>
<div class="dual-range-slider" :class="{ disabled }" @wheel="onWheel">
<div class="slider-track" ref="trackEl">
<!-- Background track -->
<div class="slider-track__bg"></div>
<!-- Active track (colored range between handles) -->
<div
class="slider-track__active"
:style="{ left: minPercent + '%', width: (maxPercent - minPercent) + '%' }"
></div>
<!-- Default range indicators -->
<div
v-if="defaultRange"
class="slider-track__default"
:style="{
left: defaultMinPercent + '%',
width: (defaultMaxPercent - defaultMinPercent) + '%'
}"
></div>
</div>
<!-- Handles with value labels -->
<div
class="slider-handle slider-handle--min"
:style="{ left: minPercent + '%' }"
@mousedown="startDrag('min', $event)"
@touchstart="startDrag('min', $event)"
>
<div class="slider-handle__thumb"></div>
<div class="slider-handle__value">{{ formatValue(valueMin) }}</div>
</div>
<div
class="slider-handle slider-handle--max"
:style="{ left: maxPercent + '%' }"
@mousedown="startDrag('max', $event)"
@touchstart="startDrag('max', $event)"
>
<div class="slider-handle__thumb"></div>
<div class="slider-handle__value">{{ formatValue(valueMax) }}</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, computed, onUnmounted } from 'vue'
const props = withDefaults(defineProps<{
min: number
max: number
valueMin: number
valueMax: number
step: number
defaultRange?: { min: number; max: number }
disabled?: boolean
}>(), {
disabled: false
})
const emit = defineEmits<{
'update:valueMin': [value: number]
'update:valueMax': [value: number]
}>()
const trackEl = ref<HTMLElement | null>(null)
const dragging = ref<'min' | 'max' | null>(null)
const minPercent = computed(() => {
const range = props.max - props.min
return ((props.valueMin - props.min) / range) * 100
})
const maxPercent = computed(() => {
const range = props.max - props.min
return ((props.valueMax - props.min) / range) * 100
})
const defaultMinPercent = computed(() => {
if (!props.defaultRange) return 0
const range = props.max - props.min
return ((props.defaultRange.min - props.min) / range) * 100
})
const defaultMaxPercent = computed(() => {
if (!props.defaultRange) return 100
const range = props.max - props.min
return ((props.defaultRange.max - props.min) / range) * 100
})
const formatValue = (val: number): string => {
if (Number.isInteger(val)) return val.toString()
return val.toFixed(stepToDecimals(props.step))
}
const stepToDecimals = (step: number): number => {
const str = step.toString()
const decimalIndex = str.indexOf('.')
return decimalIndex === -1 ? 0 : str.length - decimalIndex - 1
}
const snapToStep = (value: number): number => {
const steps = Math.round((value - props.min) / props.step)
return Math.max(props.min, Math.min(props.max, props.min + steps * props.step))
}
const startDrag = (handle: 'min' | 'max', event: MouseEvent | TouchEvent) => {
if (props.disabled) return
event.preventDefault()
dragging.value = handle
document.addEventListener('mousemove', onDrag)
document.addEventListener('mouseup', stopDrag)
document.addEventListener('touchmove', onDrag, { passive: false })
document.addEventListener('touchend', stopDrag)
}
const onDrag = (event: MouseEvent | TouchEvent) => {
if (!trackEl.value || !dragging.value) return
event.preventDefault()
const clientX = 'touches' in event ? event.touches[0].clientX : event.clientX
const rect = trackEl.value.getBoundingClientRect()
const percent = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width))
const rawValue = props.min + percent * (props.max - props.min)
const value = snapToStep(rawValue)
if (dragging.value === 'min') {
const maxAllowed = props.valueMax - props.step
const newValue = Math.min(value, maxAllowed)
emit('update:valueMin', newValue)
} else {
const minAllowed = props.valueMin + props.step
const newValue = Math.max(value, minAllowed)
emit('update:valueMax', newValue)
}
}
const onWheel = (event: WheelEvent) => {
if (props.disabled) return
const rect = trackEl.value?.getBoundingClientRect()
if (!rect) return
const rootRect = (event.currentTarget as HTMLElement).getBoundingClientRect()
if (event.clientX < rootRect.left || event.clientX > rootRect.right ||
event.clientY < rootRect.top || event.clientY > rootRect.bottom) return
event.preventDefault()
const delta = event.deltaY > 0 ? -1 : 1
const relativeX = event.clientX - rect.left
const rangeWidth = rect.width
const minPixel = (minPercent.value / 100) * rangeWidth
const maxPixel = (maxPercent.value / 100) * rangeWidth
if (relativeX < minPixel) {
const newValue = snapToStep(props.valueMin + delta * props.step)
const maxAllowed = props.valueMax - props.step
emit('update:valueMin', Math.min(newValue, maxAllowed))
} else if (relativeX > maxPixel) {
const newValue = snapToStep(props.valueMax + delta * props.step)
const minAllowed = props.valueMin + props.step
emit('update:valueMax', Math.max(newValue, minAllowed))
} else {
const newMin = snapToStep(props.valueMin - delta * props.step)
const newMax = snapToStep(props.valueMax + delta * props.step)
if (newMin < props.valueMin) {
emit('update:valueMin', Math.max(newMin, props.min))
emit('update:valueMax', Math.min(newMax, props.max))
} else {
if (newMin < newMax - props.step) {
emit('update:valueMin', newMin)
emit('update:valueMax', newMax)
}
}
}
}
const stopDrag = () => {
dragging.value = null
document.removeEventListener('mousemove', onDrag)
document.removeEventListener('mouseup', stopDrag)
document.removeEventListener('touchmove', onDrag)
document.removeEventListener('touchend', stopDrag)
}
onUnmounted(() => {
stopDrag()
})
</script>
<style scoped>
.dual-range-slider {
position: relative;
width: 100%;
height: 32px;
user-select: none;
}
.dual-range-slider.disabled {
opacity: 0.4;
pointer-events: none;
}
.slider-track {
position: absolute;
top: 14px;
left: 0;
right: 0;
height: 4px;
background: var(--comfy-input-bg, #333);
border-radius: 2px;
}
.slider-track__bg {
position: absolute;
inset: 0;
background: rgba(66, 153, 225, 0.15);
border-radius: 2px;
}
.slider-track__active {
position: absolute;
top: 0;
bottom: 0;
background: rgba(66, 153, 225, 0.6);
border-radius: 2px;
transition: left 0.05s linear, width 0.05s linear;
}
.slider-track__default {
position: absolute;
top: 0;
bottom: 0;
background: rgba(66, 153, 225, 0.1);
border-radius: 2px;
}
.slider-handle {
position: absolute;
top: 0;
transform: translateX(-50%);
cursor: grab;
z-index: 2;
}
.slider-handle:active {
cursor: grabbing;
}
.slider-handle__thumb {
width: 12px;
height: 12px;
background: var(--fg-color, #fff);
border-radius: 50%;
position: absolute;
top: 10px;
left: 0;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
transition: transform 0.15s ease;
}
.slider-handle:hover .slider-handle__thumb {
transform: scale(1.1);
}
.slider-handle:active .slider-handle__thumb {
transform: scale(1.15);
}
.slider-handle__value {
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
font-size: 10px;
font-family: 'SF Mono', 'Roboto Mono', monospace;
color: var(--fg-color, #fff);
opacity: 0.8;
white-space: nowrap;
pointer-events: none;
}
.slider-handle--min .slider-handle__value {
text-align: center;
}
.slider-handle--max .slider-handle__value {
text-align: center;
}
</style>

View File

@@ -0,0 +1,235 @@
<template>
<div class="single-slider" :class="{ disabled }" @wheel="onWheel">
<div class="slider-track" ref="trackEl">
<div class="slider-track__bg"></div>
<div
class="slider-track__active"
:style="{ width: percent + '%' }"
></div>
<div
v-if="defaultRange"
class="slider-track__default"
:style="{
left: defaultMinPercent + '%',
width: (defaultMaxPercent - defaultMinPercent) + '%'
}"
></div>
</div>
<div
class="slider-handle"
:style="{ left: percent + '%' }"
@mousedown="startDrag($event)"
@touchstart="startDrag($event)"
>
<div class="slider-handle__thumb"></div>
<div class="slider-handle__value">{{ formatValue(value) }}</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, computed, onUnmounted } from 'vue'
const props = withDefaults(defineProps<{
min: number
max: number
value: number
step: number
defaultRange?: { min: number; max: number }
disabled?: boolean
}>(), {
disabled: false
})
const emit = defineEmits<{
'update:value': [value: number]
}>()
const trackEl = ref<HTMLElement | null>(null)
const dragging = ref(false)
const percent = computed(() => {
const range = props.max - props.min
return ((props.value - props.min) / range) * 100
})
const defaultMinPercent = computed(() => {
if (!props.defaultRange) return 0
const range = props.max - props.min
return ((props.defaultRange.min - props.min) / range) * 100
})
const defaultMaxPercent = computed(() => {
if (!props.defaultRange) return 100
const range = props.max - props.min
return ((props.defaultRange.max - props.min) / range) * 100
})
const formatValue = (val: number): string => {
if (Number.isInteger(val)) return val.toString()
return val.toFixed(stepToDecimals(props.step))
}
const stepToDecimals = (step: number): number => {
const str = step.toString()
const decimalIndex = str.indexOf('.')
return decimalIndex === -1 ? 0 : str.length - decimalIndex - 1
}
const snapToStep = (value: number): number => {
const steps = Math.round((value - props.min) / props.step)
return Math.max(props.min, Math.min(props.max, props.min + steps * props.step))
}
const startDrag = (event: MouseEvent | TouchEvent) => {
if (props.disabled) return
event.preventDefault()
dragging.value = true
document.addEventListener('mousemove', onDrag)
document.addEventListener('mouseup', stopDrag)
document.addEventListener('touchmove', onDrag, { passive: false })
document.addEventListener('touchend', stopDrag)
onDrag(event)
}
const onDrag = (event: MouseEvent | TouchEvent) => {
if (!trackEl.value || !dragging.value) return
event.preventDefault()
const clientX = 'touches' in event ? event.touches[0].clientX : event.clientX
const rect = trackEl.value.getBoundingClientRect()
const percent = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width))
const rawValue = props.min + percent * (props.max - props.min)
const value = snapToStep(rawValue)
emit('update:value', value)
}
const onWheel = (event: WheelEvent) => {
if (props.disabled) return
const rect = trackEl.value?.getBoundingClientRect()
if (!rect) return
const rootRect = (event.currentTarget as HTMLElement).getBoundingClientRect()
if (event.clientX < rootRect.left || event.clientX > rootRect.right ||
event.clientY < rootRect.top || event.clientY > rootRect.bottom) return
event.preventDefault()
const delta = event.deltaY > 0 ? -1 : 1
const newValue = snapToStep(props.value + delta * props.step)
emit('update:value', newValue)
}
const stopDrag = () => {
dragging.value = false
document.removeEventListener('mousemove', onDrag)
document.removeEventListener('mouseup', stopDrag)
document.removeEventListener('touchmove', onDrag)
document.removeEventListener('touchend', stopDrag)
}
onUnmounted(() => {
stopDrag()
})
</script>
<style scoped>
.single-slider {
position: relative;
width: 100%;
height: 32px;
user-select: none;
}
.single-slider.disabled {
opacity: 0.4;
pointer-events: none;
}
.slider-track {
position: absolute;
top: 14px;
left: 0;
right: 0;
height: 4px;
background: var(--comfy-input-bg, #333);
border-radius: 2px;
}
.slider-track__bg {
position: absolute;
inset: 0;
background: rgba(66, 153, 225, 0.15);
border-radius: 2px;
}
.slider-track__active {
position: absolute;
top: 0;
bottom: 0;
left: 0;
background: rgba(66, 153, 225, 0.6);
border-radius: 2px;
transition: width 0.05s linear;
}
.slider-track__default {
position: absolute;
top: 0;
bottom: 0;
background: rgba(66, 153, 225, 0.1);
border-radius: 2px;
}
.slider-handle {
position: absolute;
top: 0;
transform: translateX(-50%);
cursor: grab;
z-index: 2;
}
.slider-handle:active {
cursor: grabbing;
}
.slider-handle__thumb {
width: 12px;
height: 12px;
background: var(--fg-color, #fff);
border-radius: 50%;
position: absolute;
top: 10px;
left: 0;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
transition: transform 0.15s ease;
}
.slider-handle:hover .slider-handle__thumb {
transform: scale(1.1);
}
.slider-handle:active .slider-handle__thumb {
transform: scale(1.15);
}
.slider-handle__value {
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
font-size: 10px;
font-family: 'SF Mono', 'Roboto Mono', monospace;
color: var(--fg-color, #fff);
opacity: 0.8;
white-space: nowrap;
pointer-events: none;
}
</style>

View File

@@ -7,8 +7,8 @@ import type { LoraPoolConfig, LegacyLoraPoolConfig, RandomizerConfig } from './c
const LORA_POOL_WIDGET_MIN_WIDTH = 500 const LORA_POOL_WIDGET_MIN_WIDTH = 500
const LORA_POOL_WIDGET_MIN_HEIGHT = 400 const LORA_POOL_WIDGET_MIN_HEIGHT = 400
const LORA_RANDOMIZER_WIDGET_MIN_WIDTH = 500 const LORA_RANDOMIZER_WIDGET_MIN_WIDTH = 500
const LORA_RANDOMIZER_WIDGET_MIN_HEIGHT = 462 const LORA_RANDOMIZER_WIDGET_MIN_HEIGHT = 430
const LORA_RANDOMIZER_WIDGET_MAX_HEIGHT = 462 const LORA_RANDOMIZER_WIDGET_MAX_HEIGHT = LORA_RANDOMIZER_WIDGET_MIN_HEIGHT
// @ts-ignore - ComfyUI external module // @ts-ignore - ComfyUI external module
import { app } from '../../../scripts/app.js' import { app } from '../../../scripts/app.js'
@@ -231,7 +231,7 @@ app.registerExtension({
const isRandomizerNode = node.comfyClass === 'Lora Randomizer (LoraManager)' const isRandomizerNode = node.comfyClass === 'Lora Randomizer (LoraManager)'
// For randomizer nodes, add a callback to update connected trigger words // For randomizer nodes, add a callback to update connected trigger words
const callback = isRandomizerNode ? (value: any) => { const callback = isRandomizerNode ? () => {
updateDownstreamLoaders(node) updateDownstreamLoaders(node)
} : null } : null

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long