The per-bucket lock was inserted without synchronization. Two first
writers could take different locks and overwrite each other's preset
file. Lock creation now happens under a guard lock.
Co-authored-by: AE <by-ae@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
test_store replaced the folder_paths mock after store.py had imported it.
Route tests then configured the replacement, and store writes went to a
MagicMock path that had been committed. Both suites now share the mock
from conftest and land files in a temp directory.
Co-authored-by: AE <by-ae@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Additive scene load nudged each region further than the one before it, so
a saved composition was sheared. Every region now moves by the same offset
and is clamped back inside the canvas.
Co-authored-by: AE <by-ae@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
The caption verifier accepts only uppercase #RRGGBB, at most 16 style
colors and 5 per element. Shorthand #RGB is expanded, other values are
dropped, and a null palette no longer crashes prompt assembly.
Co-authored-by: AE <by-ae@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Pasted captions with swapped or non-numeric bbox values produced negative
or NaN regions, so the editor could not select them. Coordinates are now
swapped and clamped to the 0-1000 range from the Ideogram 4 caption schema,
and unreadable bboxes keep the non-overlapping grid slot for that element.
Saved regions with NaN coordinates are dropped on restore.
Co-authored-by: AE <by-ae@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Preview BG Update logged save and notify failures only when BG_DEBUG was
set, so the console stayed quiet while the README told users to look there.
Warnings now print for a missing image, an empty or invalid guid, a tensor
that cannot be converted, a disk write error, and a failed editor push.
Co-authored-by: AE <by-ae@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
comfy_api.latest.io is part of ComfyUI core, not from ComfyUI-KJNodes.
Restore accurate installation instructions and update ImportError message
to indicate a recent ComfyUI version is needed.
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
When importing captions with missing/invalid bbox data, elements are now
arranged in a 4-column grid (row/column layout) instead of a diagonal
pattern that overlapped after 6 elements.
- Change fallback positioning from modulo-6 diagonal to row/column grid
- Update both Python backend and JavaScript editor
- Add comprehensive test for 12+ elements with no overlap
- Fixes visual collision when pasting captions with many unbounded regions
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
- Add clear import error message when comfy_api.latest is missing
- Update README installation instructions to require KJNodes first
- Update troubleshooting section with dependency check
- Remove misleading statement that KJNodes is not needed
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
- Add MAX_PAYLOAD_SIZE constant (10 MB) to prevent memory exhaustion
- Validate store names against path traversal and special characters in routes layer (defense in depth)
- Check Content-Length header and body size before processing
- Return HTTP 413 for oversized payloads
- Add comprehensive test coverage for validation edge cases
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
- Add Unicode character support info with examples (角色, Персонаж, Émilie)
- Document preset naming requirements clearly
- Add troubleshooting section for save failures with browser console guidance
- Add Development section with test running and linting instructions
- Improve error debugging guidance for users
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
- Add package.json with ESLint configuration for JS code quality checks
- Configure ESLint with browser environment and ES2021 features
- Add npm install and lint steps to CI workflow
- Fix unused parameter warnings in ideogram4_prompt_builder_enhanced.js and utility.js
- Update .gitignore to exclude node_modules, Python cache, and build artifacts
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
- Log errors to console when parsing elements_data or style_palette_data fails
- Show alerts and log errors when store operations (save/load scenes, characters, objects) fail
- Log clipboard access failures during import instead of silently ignoring
- Replace empty catch blocks with proper error logging for better debugging
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
- Allow Unicode letters/numbers in preset names (e.g. 角色, Персонаж, Émilie)
- Add thread-safe locking per bucket to prevent race conditions during concurrent writes
- Use mkstemp() for atomic temp file creation to avoid tmp file name collisions
- Add tests demonstrating the bugs and verifying the fixes
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
- Add store location in troubleshooting section
- Explain corrupt file backup behavior with timestamps
- Add API section with GET, PUT, and DELETE endpoint documentation
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
- Test corrupt JSON creates backup and returns empty bucket
- Test corrupt file does not affect other buckets
- Test save works after corrupt file recovery
- Test DELETE success, 404 not found, invalid bucket/name 400
- All existing tests continue to pass
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
- Add DELETE /byae/ideogram/stores/{bucket}/{name} route handler
- Return 400 for invalid bucket/name, 404 for not found, 200 on success
- Mirror error handling pattern from PUT route
- Add deleteStoreEntry() helper in ideogram4_shared.js
- Use same fetch/timeout/error-handling pattern as saveStoreEntry
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
- Add error handling for JSONDecodeError and UnicodeDecodeError in _read_json
- Move corrupt files to timestamped backup (e.g. characters.json.corrupt-1234567890)
- Treat corrupt bucket as empty, allowing other buckets to continue working
- Clean up temp files if _write_json fails
- Log warnings for corrupt file recovery and errors for backup failures
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Ensures data is written to disk before the atomic rename. The write
was already atomic (tmp + os.replace), but adding fsync prevents
preset corruption if the process is killed between json.dump and
the file system sync.
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Harden route handlers against malformed requests:
Store entry route (PUT):
- Validate name is non-empty and under 128 chars
- Verify request body is a JSON object, not array or primitive
- Return clear error messages for each validation failure
Background stat route (GET):
- Handle os.path.getmtime() failures (permissions, race conditions)
- Log file stat errors for debugging
- Return appropriate HTTP status codes
Prevents crashes from malicious or malformed API requests.
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Wrap imports in try-except blocks to provide clear error messages:
- Node imports: log helpful message if ComfyUI dependencies missing
- PromptServer import: log warning if server unavailable
- Export empty mappings instead of crashing ComfyUI startup
This allows the extension to fail gracefully when dependencies
are unavailable (e.g., during testing or accidental standalone
execution) while still providing diagnostic information.
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Add practical documentation that helps users:
Usage section:
- Where to find nodes in the menu
- How to connect the nodes
- What output to expect
Troubleshooting section:
- Nodes not appearing (installation issues)
- Route/store errors (usually harmless)
- Background image not updating (connection issues)
- Workflow compatibility (breaking changes prevention)
Reduces user friction and provides self-service solutions
for common setup problems.
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Implement CI pipeline that runs on push and pull requests:
Python checks (3.10, 3.11, 3.12):
- Lint with flake8 (syntax errors and code quality)
- Compile all Python modules
- Run unit test suite
JavaScript checks:
- Validate syntax of all JS files with Node.js
This ensures code quality and catches issues before they reach users.
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Implement 10 unit tests covering:
- Name validation (valid and invalid patterns)
- Save, load, and delete operations
- Multiple entries and overwrites
- Empty buckets and non-existent entries
- Invalid bucket names
- Persistence across reloads
Tests use unittest (stdlib) and mock folder_paths dependency,
ensuring the store logic is reliable without ComfyUI runtime.
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Prevent crashes when users provide invalid JSON or malformed bbox data:
- Catch TypeError and ValueError in addition to JSONDecodeError
- Handle non-numeric bbox coordinates gracefully with try-except
- Fall back to default positioning when bbox parsing fails
This protects users from workflow crashes due to corrupted or
hand-edited JSON input.
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Fork of KJNodes' Ideogram 4 Prompt Builder with stores, multi-select, scene save/load, live background preview, and separate width/height outputs.
Co-authored-by: Cursor <cursoragent@cursor.com>