Commit Graph
289 Commits
Author SHA1 Message Date
Dariusz L c1ec26644d refactor: share mask result application 2026-08-13 08:20:35 +02:00
Dariusz L 5b90135533 refactor: share IndexedDB transaction execution 2026-08-13 08:16:48 +02:00
Dariusz L 38886f346d refactor: share image upload request construction 2026-08-13 08:12:08 +02:00
Dariusz L d68ee89f35 refactor: share preview blob loading 2026-08-13 08:09:04 +02:00
Dariusz L 459df09a70 refactor: unify canvas blob upload preparation 2026-08-13 08:06:43 +02:00
Dariusz L 7083ab59d4 refactor: reuse shared variants and database requests 2026-08-13 07:42:37 +02:00
Dariusz L 1dd3fe42c0 refactor: share batch and mask editor helpers 2026-08-13 07:39:03 +02:00
Dariusz L 64240a678e refactor: centralize Blob image loading 2026-08-13 07:33:29 +02:00
Dariusz L b509482eb1 refactor: share canvas output rendering primitives 2026-08-13 07:24:29 +02:00
Dariusz L ec313f1ce6 refactor: unify image cache contract 2026-08-13 07:18:12 +02:00
Dariusz L c461da1481 refactor: share distance-field mask rasterization 2026-08-13 05:43:15 +02:00
Dariusz L f60b7c0d8d refactor: centralize mask pixel primitives 2026-08-13 05:33:47 +02:00
Dariusz L 42c4de43e4 refactor: reuse canonical layer point transforms 2026-08-13 05:28:16 +02:00
Dariusz L 58ae68b8e1 refactor: centralize canvas blob variant dispatch 2026-08-13 05:24:43 +02:00
Dariusz L 76222a805b refactor: centralize strict canvas context creation 2026-08-13 04:44:59 +02:00
Dariusz L 082e8b74f1 refactor: share matting model status checks 2026-08-13 04:41:24 +02:00
Dariusz L 18445387e4 refactor: share CanvasIO tensor image conversion 2026-08-13 04:37:15 +02:00
Dariusz L b7785b6bc3 refactor: share mask result conversion 2026-08-13 04:32:30 +02:00
Dariusz L 4bed57afcd refactor: share mask pixel processing pipeline 2026-08-13 04:29:47 +02:00
Dariusz L 66faa3135a refactor: centralize image loading and serialization 2026-08-13 04:26:51 +02:00
Dariusz L 5f660629ec refactor: centralize layer geometry calculations 2026-08-13 04:18:43 +02:00
Dariusz L 2ab249efde refactor: share mask distance transform 2026-08-13 03:42:49 +02:00
Dariusz L 73d8e696cb refactor: share tensor to rgba conversion 2026-08-13 03:39:03 +02:00
Dariusz L 0217684ae8 refactor: share indexeddb infrastructure 2026-08-13 03:36:47 +02:00
Dariusz L 834476c259 refactor: unify canvas export actions 2026-08-13 03:29:52 +02:00
Dariusz L 391923d77d refactor: split canvas_node into python modules and enhance matting UI 2026-08-13 03:10:25 +02:00
Dariusz L 6284ed2b98 Fix layer-aligned generated masks 2026-08-13 02:34:37 +02:00
Dariusz L 6febc525bc fix: use native ComfyUI BiRefNet matting 2026-08-13 01:56:03 +02:00
Dariusz L dc1bde6231 refactor: use canonical logging imports 2026-08-13 01:16:42 +02:00
Dariusz L 2cec014d4c feat: migrate Model Resolver logging system 2026-08-13 00:57:52 +02:00
Dariusz L f8137a57a7 refactor: add CONFIG and context menu support to notification toast system
- Add centralized CONFIG object with PROJECT_NAME, PROJECT_ICON, CSS_PREFIX,
  LOGGER_NAME, and SHARED_CONTAINER_ID to prevent hardcoded values
- Refactor showNotification to accept both legacy (backgroundColor, duration, type)
  and new (options object) signatures for backward compatibility
- Replace hardcoded CSS IDs and keyframe names with CONFIG-prefixed variants
- Change notification container layout from row-reverse to column for proper stacking
- Add context menu binding support via contextMenuModel and contextMenuTooltip options
- Extract SVG icons into dedicated iconSVGs record/object
- Fix wrapper functions (showSuccessNotification, showErrorNotification etc.) to
  pass type as first argument instead of undefined
- Increase container z-index to 100005 to appear above modal overlays
- Remove unused lf-progress and lf-progress-rewind keyframes
2026-06-30 01:39:23 +02:00
Dariusz L e82c837af3 Add 'lf-' prefix to all LayerForge CSS classes (js)
Refactors all custom CSS class names to include an 'lf-' prefix
(e.g. .painter-button -> .lf-painter-button, .clipboard-switch -> .lf-clipboard-switch).

This isolates LayerForge styles within the ComfyUI DOM and prevents
CSS namespace collisions with other custom nodes or host page styles.
Changes span src/ TypeScript source files and src/css/ stylesheets.
2026-06-30 00:50:15 +02:00
Dariusz L d0b7261671 Refactor notification progress to use requestAnimationFrame and fix db imports
- Replace CSS animation-based notification progress bar with requestAnimationFrame-driven animation
- Centralize getCanvasState/setCanvasState imports at top-level in CanvasView (remove dynamic import())
- Clean up animation frame lifecycle tracking to prevent orphaned rAF callbacks
- Set local debug log level in python/config.py for development diagnostics
2026-06-30 00:27:52 +02:00
Dariusz L 88c2249ded Rebuild JS artifacts (no functional changes)
Changes are auto-generated by TypeScript build (formatting/newlines only). No logic changes.
2026-05-01 20:46:28 +02:00
VladiCz 65f3dcc5d5 replace hardcoded ws protocol with wss protocol based on SSL 2026-04-25 10:41:28 +02:00
Dariusz L 5cf10e5e5c Add Undo/Redo shortcuts to templates
Insert an "Undo & Redo" section into standard_shortcuts.html in both js/templates and src/templates. Documents Ctrl+Z for undo and Ctrl+Y or Ctrl+Shift+Z for redo so the UI shortcut list includes undo/redo actions.
2026-04-13 17:25:50 +02:00
diodiogod 1edde25d75 Fix ComfyUI shortcut leaks in LayerForge
Technical details:
- skip LayerForge canvas and panel shortcuts when focus is inside editable controls
- patch ComfyUI ChangeTracker undoRedo so Ctrl/Cmd+Z does not leak to graph history while LayerForge owns the shortcut context
- stop clipboard copy/cut/paste events from editable LayerForge UI from bubbling into ComfyUI node clipboard handlers
- route widget-root Ctrl/Cmd+Z, Ctrl/Cmd+Y, and Ctrl/Cmd+Shift+Z through LayerForge canvas undo and redo when the widget is active
2026-03-18 00:34:16 -03:00
diodiogod b8fbcee67a Fix focus/modifier issues and improve multi-layer selection UX 2026-02-03 02:00:24 -03:00
diodiogod d44d944f2d Fix: Restore drag-and-drop in layers panel 2026-02-02 23:15:08 -03:00
diodiogod ab5d71597a Fix: Allow paste event to bubble for system clipboard access 2026-02-02 20:56:56 -03:00
diodiogod ce4d332987 Fix Ctrl+V to paste from system clipboard when internal clipboard is empty 2026-02-02 18:22:54 -03:00
diodiogod 9b04729561 Enable cross-workflow node duplication with layers
Store canvas state in IndexedDB clipboard on copy, allowing nodes to be
duplicated with their layers preserved across different workflows.

When copying a node, the canvas state is stored in a special
'__clipboard__' entry that persists across workflow switches. On paste,
if the source node doesn't exist (indicating cross-workflow paste), the
system falls back to loading from the clipboard entry.
2026-01-19 18:24:42 -03:00
diodiogod 27ad139cd5 Add layer copy/paste and node duplication with layers
Implements two new features:
- Layer copy/paste within canvas using Ctrl+C/V
- Node duplication that preserves all layers

Layer Copy/Paste:
- Added Ctrl+V keyboard shortcut handler for pasting layers
- Intercept keydown events during capture phase to handle before ComfyUI
- Focus canvas when layer is clicked to ensure shortcuts work
- Prevent layers panel from stealing focus on mousedown

Node Duplication:
- Store source node ID during serialize for copy operations
- Track pending copy sources across node ID changes (-1 to real ID)
- Copy canvas state from source to destination in onAdded hook
- Use Map to persist copy metadata through node lifecycle
2026-01-19 17:57:14 -03:00
diodiogod 66cbcb641b Add retry logic for image loading validation
Increase robustness of image loading check before sending canvas data.
Now retries up to 5 times with 200ms delays (1 second total) instead
of a single 100ms wait.

This fixes the 'Failed to get confirmation from server' error that
appeared when executing workflows immediately after ComfyUI restart,
before images finished loading from IndexedDB.

Prevents workflow execution failures due to timing issues during
canvas initialization.
2026-01-17 20:30:36 -03:00
diodiogod 986e0a23a2 Fix canvas sizing bug by separating display and output dimensions
The canvas was getting corrupted to a small strip because of confusion
between two different dimension types:
- Output area dimensions (logical working area, e.g. 512x512)
- Display canvas dimensions (actual pixels shown on screen)

Root cause: Setting canvas.width/height attributes to match output area
while also using CSS width:100%/height:100% created conflicts. When
zooming or reloading, wrong dimensions would be read and saved.

Fix: Remove canvas element width/height attribute assignments. Let the
render loop control display size based on clientWidth/clientHeight.
Keep output area dimensions separate.

This prevents the canvas from being saved with corrupted tiny dimensions
and fixes the issue where canvas would only show in a small strip after
zooming or reloading workflows.
2026-01-17 15:03:00 -03:00
diodiogod 068ed9ee59 Skip sending canvas data for bypassed nodes
Fix critical issue where LayerForge was trying to send canvas data
even when the node was bypassed (mode === 4). This caused unnecessary
errors and blocked workflow execution.

Now properly checks node.mode before attempting to send data via
WebSocket, skipping bypassed nodes entirely.
2026-01-15 09:40:33 -03:00
diodiogod 4e5ef18d93 Fix canvas initialization and sizing bugs
- Add image loading validation before sending canvas data to server
  Prevents 'Failed to get confirmation' error when images haven't
  finished loading after workflow reload. Waits 100ms and checks
  if all layer images are complete before rendering output.

- Improve layer loading error handling in CanvasState
  Better logging when layers fail to load from IndexedDB.
  Allows empty canvas as valid state instead of failing.

- Add ResizeObserver for canvas container
  Fixes bug where canvas only shows in top half of node.
  Watches container size changes and triggers re-render to ensure
  canvas dimensions are correctly calculated after DOM layout.
2026-01-15 09:38:59 -03:00
diodiogod be37966b45 Add DOM connection check to prevent capturing events in subgraphs
Ensure the canvas element is actually connected to the DOM before
handling paste events. This prevents LayerForge from capturing paste
events when navigating in subgraphs where the canvas is not visible.

Adds check for canvas.isConnected and document.body.contains() to
verify the canvas is part of the active DOM tree.
2026-01-14 16:11:22 -03:00
diodiogod dd5fc5470f Fix keyboard shortcuts capturing events when node is unfocused
Prevent LayerForge from intercepting Ctrl+C, Ctrl+V, and other keyboard
shortcuts when the canvas is not focused. This was causing unwanted
popups and interfering with other nodes in ComfyUI.

Changes:
- Remove document.body focus check from handlePasteEvent
- Add focus validation to handleKeyDown before processing shortcuts
- Modifier keys (Ctrl, Shift, Alt, Meta) are still tracked globally
- All other shortcuts only trigger when canvas is focused

Fixes issue where paste events were captured globally regardless of focus.
2026-01-10 11:12:31 -03:00
Dariusz L de67252a87 Add grab icon for layer movement
Implemented grab icon feature in transform mode to move selected layers without changing selection, even when behind other layers. Added hover detection, cursor updates, and visual rendering in CanvasInteractions.ts and CanvasRenderer.ts.
2025-10-27 17:20:53 +01:00