Commit Graph
42 Commits
Author SHA1 Message Date
Vito Sansevero 7f92c4d5b8 fix: preserve full tracebacks in server-side error logging
Use logger.exception() and exc_info=True to retain stack traces
for debugging, addressing Codex review feedback on PR #110.
2026-02-08 05:33:06 -08:00
Vito Sansevero be205f3dcc feat: add pre-commit hooks for local CI checks
- Black (auto-fix formatting on commit)
- Flake8 (block on syntax errors and undefined names)
- Bandit (security scan, non-blocking to match CI)
- Tests (run on pre-push only)
- Apply Black formatting fixes caught by the new hooks
2026-02-08 05:27:03 -08:00
Vito Sansevero ed40be066c fix: prevent stack trace exposure in SSE error responses
Log exception details server-side only; send generic error messages
to clients via SSE streams to resolve code scanning alerts.
2026-02-08 05:23:04 -08:00
Vito Sansevero 113d663fce fix: resolve 15 GitHub code scanning security alerts
- Fix XSS in showFullPrompt() across admin.js, gallery.js, metadata.html
  by replacing HTML string interpolation with DOM manipulation (createElement
  + textContent), eliminating unsafe user content injection
- Fix stack trace exposure in py/api error responses by replacing str(e)
  with generic messages and adding logger.exception() for server-side
  traceability
2026-02-07 13:04:52 -08:00
Vito Sansevero 2737a4b1ef style: apply Black formatter (line-length=88) to all Python files
Automated formatting pass across 30 files to establish consistent code
style enforced by CI. No logic changes.
2026-02-07 08:30:09 -08:00
Vito Sansevero 4548beb723 refactor: split api.py into domain modules and extract frontend JS
Phase 4 structural refactoring:
- Split monolithic py/api.py (5.3k lines) into domain mixins:
  prompts.py, images.py, admin.py, logging_routes.py, autotag_routes.py
- Extract inline JS from admin.html into web/js/admin.js
- Extract inline JS from gallery.html into web/js/gallery.js
- Add gzip compression middleware to API responses (Phase 5.4)
- Standardize API error envelope with success: false (Phase 5.3)
- Add filmstrip image enrichment to prompt list responses (Phase 5.2)
2026-02-07 07:02:25 -08:00
Vito Sansevero 4f62066c63 fix: harden nodes, validators, and utility modules
Phase 0-3 fixes from codebase audit:
- Extract shared node logic into prompt_manager_base.py (DRY)
- Add input validation guards to validators.py
- Fix logging_config.py buffer management
- Harden image_monitor.py against race conditions
- Fix prompt_tracker.py cleanup edge cases
- Fix diagnostics.py import path
- Wire config.py server instance correctly
2026-02-07 07:02:10 -08:00
Vito Sansevero a5a1169829 fix(api): handle invalid input and improve progress tracking 2026-02-06 14:32:43 -08:00
Vito Sansevero 760b2a0f48 feat(tags): add Phase 2 tag management enhancements
- Bulk tag operations: rename, delete, merge across all prompts
- Right-click context menu on tags (rename/delete/merge)
- Click prompt card → dashboard search, click thumbnail → ViewerJS
- Usage bars, prompt count badge, staggered card animations
- URL-synced tag selection (#/tags/landscape,portrait?mode=or)
- Untagged prompts filter with [untagged] entry
2026-02-03 18:40:58 -08:00
Vito Sansevero f485825bfb fix: resolve gallery crash when thumbnails exist and prevent thumbnail-as-image linking
- Fix AttributeError: 'str' has no attribute 'as_posix' on thumbnail_rel_path
  in get_output_images and find_duplicates (thumbnail_rel_path is already a
  string from f-string construction, not a Path object)
- Fix NameError: total_images undefined in generate_thumbnails (was defined as
  total_media, causing progress logging and response to fail)
- Add URL encoding for paths in scan_output_dir for filenames with spaces
- Exclude thumbnails directory from image monitor to prevent linking thumbnail
  files to prompts via fallback mechanism
- Bump version to 3.0.31
2026-02-03 14:07:23 -08:00
Vito Sansevero a7d842a51c feat(settings): add configurable gallery scan directory
Add ability to configure a custom image scan directory in Settings:
- New "Image Scan Directory" field in Settings modal
- "Currently Monitoring" display shows active directory path
- Settings API now returns/saves gallery_root_path and monitored_directories
- Image monitor checks GalleryConfig before auto-detecting
- Restart notification when gallery path changes

Closes #76
2026-02-02 15:58:54 -08:00
Vito Sansevero 344640eb26 Merge origin/main into feature/button
Resolve conflicts in py/api.py by keeping feature/button's thumbnail
path generation approach (using rel_path.with_suffix('') and string
formatting) which was tested and working correctly.
2026-02-02 15:15:53 -08:00
Vito Sansevero 3fe2ee5075 feat(api): serve static files and update thumbnail paths 2026-02-02 15:09:25 -08:00
Shaun Johnston b8a5eaf9a6 fix subdir thumbnail gen 2025-12-25 19:41:01 +10:00
Vito Sansevero da239bb7e1 feat(api): exclude protected prompts from pruning 2025-12-09 09:29:34 -08:00
Vito Sansevero 11d25afa56 feat(api): add unload autotag model endpoint 2025-12-09 06:05:04 -08:00
Vito Sansevero c11d98fa17 feat(autotag): add AutoTagService for image tagging 2025-12-07 17:25:43 -08:00
Vito Sansevero 56eed388a8 feat(api): add AutoTag endpoints and image routes 2025-12-07 17:25:06 -08:00
Vito Sansevero 22593e8514 docs: add comprehensive docstrings to all Python modules
- Add Google-style docstrings to main node files (prompt_manager.py, prompt_manager_text.py)
- Enhance database module docstrings with detailed parameter and return documentation
- Add comprehensive docstrings to all utils modules with usage examples
- Document API endpoints and configuration classes thoroughly
- Update module-level docstrings in all __init__.py files
- Ensure consistent naming (ComfyUI_PromptManager) across all documentation
- Follow Python best practices for docstring formatting
2025-08-12 06:51:36 -07:00
Vito Sansevero db5f6c3307 fix(gallery): improve thumbnail generation progress feedback and modal width
Frontend improvements:
- Fixed "Check thumbnails at startup" modal to use EventSource properly
- Shows current file being processed with directory path
- Displays file type (image/video) and action (generating/skipping)
- Real-time progress updates with ETA calculation
- Detailed status messages in scrollable log area
- Increased modal width from max-w-md to max-w-2xl for long filenames
- Path truncation for files over 60 characters
- Console logging for debugging when debug mode enabled
- Better EventSource error handling with connection state logging

Backend improvements:
- Verbose scanning progress with directory counts
- File type breakdown in start message (X images, Y videos)
- More frequent progress updates (every 5 files instead of 10)
- Include current file path, type, and action in progress events
- Send error notifications during processing (first 5 errors)
- Enhanced completion message with error count and processing rate
- Detailed logging throughout the process

The thumbnail generation now provides real-time, detailed feedback in both
the settings panel and the startup prompt modal, making it clear which files
are being processed and the overall progress.
2025-08-11 19:10:41 -07:00
Vito Sansevero a17dcba540 fix(gallery): resolve prompt display issue when navigating between images
Fixes issue where PromptManager Gallery showed identical prompts for all
images when using workflows like Flux models that generate multiple images
with the same base workflow.

**Problem:**
- Gallery relied solely on PNG metadata extraction for prompt display
- Images generated from same workflow (e.g., Flux models) contained
  identical workflow metadata but should show different prompts
- Navigation between images didn't update prompt information correctly

**Solution:**
1. **Enhanced metadata extraction:**
   - Improved parseWorkflowData() to handle more ComfyUI node types
   - Added support for PromptManagerText, UNETLoader, DualCLIPLoader
   - Better negative prompt detection patterns
   - Enhanced sampling parameter extraction

2. **New API endpoint:**
   - Added GET /prompt_manager/images/prompt/{image_path}
   - Queries database for actual prompt used during generation
   - Provides accurate prompt data linked to specific images

3. **Hybrid metadata loading:**
   - Primary: Query database for linked prompt data
   - Fallback: Extract from PNG metadata if no database record
   - Combines database prompts with PNG technical parameters

**Changes:**
- py/api.py: Added get_image_prompt() endpoint and route
- web/gallery.html: Enhanced loadImageMetadata() and parseWorkflowData()

**Result:**
- Gallery now displays correct, unique prompts for each image
- Prompt information updates properly when navigating between images
- Generation data refreshes correctly with prev/next navigation
- Maintains backward compatibility for images without database records

Resolves user-reported issue with Flux.1_Krea_Dev_workflow.json where
all images showed identical prompts in gallery view.
2025-08-11 14:18:13 -07:00
Vito Sansevero 7cc042f48c fix(gallery): resolve duplicate image display on Windows
Fix issue where every image appears twice in gallery on Windows systems
due to case-insensitive filesystem and path handling differences.

- Deduplicate files when searching with both lowercase/uppercase extensions
- Use pathlib.as_posix() to ensure forward slashes in URLs on all platforms
- Add normalized path tracking to prevent duplicate file collection

The root cause was:
1. Files were found twice (once for *.png and once for *.PNG) on Windows
2. URLs with backslashes caused path inconsistencies

Fixes gallery showing 1922 images when only 961 files exist on disk.
2025-08-04 06:48:53 -07:00
Vito Sansevero 983306366f fix(api): handle new ComfyUI workflow format with list-based inputs
Fix AttributeError when processing PNG files with newer ComfyUI workflow format
where node inputs are stored as lists instead of dictionaries.

- Add _get_node_inputs() helper to normalize both dict and list input formats
- Add _find_text_in_node() to extract text from nodes using multiple strategies
- Update _extract_positive_prompt_from_comfyui_data() to use safe accessors
- Maintain full backward compatibility with existing workflow formats

Fixes error: "'list' object has no attribute 'get'" when scanning images
from workflows using the newer ComfyUI format.
2025-08-04 06:31:35 -07:00
Vito Sansevero 6e7a958355 style(api): Change log level from info to debug 2025-06-19 16:56:14 -07:00
Vito Sansevero f6dd6d65cf feat(api): add duplicate image scan and delete endpoints 2025-06-09 09:03:26 -07:00
Vito Sansevero 0c54c4dced feat(api): Add gallery and thumbnail management endpoints 2025-06-09 08:41:42 -07:00
Vito Sansevero 2af331b375 refactor(api): improve ComfyUI output dir detection logic reported in #27 2025-06-08 13:45:43 -07:00
Vito Sansevero 3d00d1ef45 feat(api): add pruning for orphaned prompts 2025-06-03 17:55:56 -07:00
Vito Sansevero e13d4f0284 refactor(api): update html path in PromptManagerAPI 2025-06-03 17:05:53 -07:00
Vito Sansevero 798adcc0f3 style(config): update default display mode to 'newtab' 2025-06-01 12:25:29 -07:00
Vito Sansevero 9e117496e0 feat(api): add gallery interface and config settings, for metadata 2025-06-01 12:25:19 -07:00
Vito Sansevero 815b034c2d feat(api): add endpoint to add tags to prompts 2025-05-29 06:47:36 -07:00
Vito Sansevero 861dbd8a12 refactor(api): clean up and enhance category handling 2025-05-28 13:00:10 -07:00
Vito Sansevero 4f6d7234d6 feat(api): add pagination and A1111 parsing support 2025-05-28 11:01:20 -07:00
Vito Sansevero fb46931b1a feat(logging): integrate logging throughout API 2025-05-28 08:28:49 -07:00
Vito Sansevero fd51ec3a1b refactor(config): Replace print with logging in config 2025-05-28 08:28:35 -07:00
Vito Sansevero 7a42cf96ed feat(api): add scan images endpoint for metadata parsing 2025-05-27 14:57:51 -07:00
Vito Sansevero 4fca3f6d87 feat(api): add database backup and restore endpoints 2025-05-27 14:29:01 -07:00
Vito Sansevero bb7329bff7 feat(api): handle duplicate prompts with metadata update 2025-05-27 12:35:43 -07:00
Vito Sansevero 67b77d457e feat(api): add maintenance endpoint for database 2025-05-26 10:11:19 -07:00
Vito Sansevero 27ca3b0555 fix(api): fix foreign key constraint error deletion 2025-05-25 21:37:02 -07:00
Vito Sansevero 96113cbabd feat(api): Add PromptManager API and config files 2025-05-24 12:27:01 -07:00