diff --git a/py/routes/api_routes.py b/py/routes/api_routes.py index 9ffa7d58..479ea5ed 100644 --- a/py/routes/api_routes.py +++ b/py/routes/api_routes.py @@ -609,6 +609,11 @@ class ApiRoutes: # Update cache await self.scanner.update_single_lora_cache(file_path, file_path, metadata) + # If model_name was updated, resort the cache + if 'model_name' in metadata_updates: + cache = await self.scanner.get_cached_data() + await cache.resort(name_only=True) + return web.json_response({'success': True}) except Exception as e: diff --git a/py/services/lora_scanner.py b/py/services/lora_scanner.py index 45e259fa..857a4369 100644 --- a/py/services/lora_scanner.py +++ b/py/services/lora_scanner.py @@ -430,25 +430,41 @@ class LoraScanner: # Remove old path from hash index if exists self._hash_index.remove_by_path(original_path) + # Remove the old entry from raw_data cache.raw_data = [ item for item in cache.raw_data if item['file_path'] != original_path ] if metadata: - metadata['folder'] = self._calculate_folder(new_path) + # If this is an update to an existing path (not a move), ensure folder is preserved + if original_path == new_path: + # Find the folder from existing entries or calculate it + existing_folder = next((item['folder'] for item in cache.raw_data + if item['file_path'] == original_path), None) + if existing_folder: + metadata['folder'] = existing_folder + else: + metadata['folder'] = self._calculate_folder(new_path) + else: + # For moved files, recalculate the folder + metadata['folder'] = self._calculate_folder(new_path) + + # Add the updated metadata to raw_data cache.raw_data.append(metadata) # Update hash index with new path if 'sha256' in metadata: self._hash_index.add_entry(metadata['sha256'], new_path) - all_folders = set(cache.folders) - all_folders.add(metadata['folder']) + # Update folders list + all_folders = set(item['folder'] for item in cache.raw_data) cache.folders = sorted(list(all_folders), key=lambda x: x.lower()) # Resort cache await cache.resort() + + return True async def _update_metadata_paths(self, metadata_path: str, lora_path: str) -> Dict: """Update file paths in metadata file""" diff --git a/static/css/components/lora-modal.css b/static/css/components/lora-modal.css index 05c8304b..0e2f16a9 100644 --- a/static/css/components/lora-modal.css +++ b/static/css/components/lora-modal.css @@ -425,4 +425,58 @@ font-family: monospace; font-size: 0.9em; opacity: 0.9; +} + +/* Model name field styles - complete replacement */ +.model-name-field { + display: flex; + align-items: center; + gap: var(--space-2); + width: calc(100% - 40px); /* Reduce width to avoid overlap with close button */ + position: relative; /* Add position relative for absolute positioning of save button */ +} + +.model-name-field h2 { + margin: 0; + padding: var(--space-1); + border-radius: var(--border-radius-xs); + transition: background-color 0.2s; + flex: 1; + font-size: 1.5em !important; /* Increased and forced size */ + font-weight: 600; /* Make it bolder */ + min-height: 1.5em; + box-sizing: border-box; + border: 1px solid transparent; + line-height: 1.2; + color: var(--text-color); /* Ensure correct color */ +} + +.model-name-field h2:hover { + background: oklch(var(--lora-accent) / 0.1); + cursor: text; +} + +.model-name-field h2:focus { + outline: none; + background: var(--bg-color); + border: 1px solid var(--lora-accent); +} + +.model-name-field .save-btn { + position: absolute; + right: 10px; /* Position closer to the end of the field */ + top: 50%; + transform: translateY(-50%); + opacity: 0; + transition: opacity 0.2s; +} + +.model-name-field:hover .save-btn, +.model-name-field h2:focus ~ .save-btn { + opacity: 1; +} + +/* Ensure close button is accessible */ +.modal-content .close { + z-index: 10; /* Ensure close button is above other elements */ } \ No newline at end of file diff --git a/static/js/components/LoraModal.js b/static/js/components/LoraModal.js index 5e8d31c6..6e9653d1 100644 --- a/static/js/components/LoraModal.js +++ b/static/js/components/LoraModal.js @@ -9,7 +9,12 @@ export function showLoraModal(lora) {