Visual node-based Photoshop automation platform built on tldraw SDK, compiles Photoshop UXP scripts reactively.
π Quick Start
- Webview Bridge: tldraw requires standard DOM APIs unavailable in native UXP. Host the tldraw React app inside a
sp-webviewtag. - Message Passing: Establish two-way communication between the UXP host script and the webview using
webview.postMessageand window event listeners. - Compilation Engine: Parse the tldraw storeβs node/edge graph (
store.allRecords()) into sequential PhotoshopbatchPlaycommand arrays.
π§ Configuration
- Manifest V5: Ensure
manifest.jsonrequires"host": [{"app": "PS", "minVersion": "24.0"}]and enablesenableWebviewpermissions. - tldraw Store: Use a custom
createTLStoreto track node connections and detect cycles before dispatching payloads. - Execution Throttle: Configure a strict debounce on the graph compiler. Rapid reactive
batchPlaydispatches will lock Photoshopβs UI thread.
π¦ Dependencies
@tldraw/tldraw(Infinite canvas and state management)photoshop.action.batchPlay(Native UXP action execution)photoshop.core.executeAsModal(Mandatory for document-modifying UXP state changes)
π‘ Best Practices / Patterns
- Reactive
executeAsModal: Wrap compiled script payloads inexecuteAsModal. Map graph node states directly to specificbatchPlaydescriptors to avoid redundant history states. - Headless Store Sync: Maintain a headless tldraw store in the UXP context if possible, or strictly type the JSON graph payload across the webview IPC boundary.
- Atomic Node Operations: Design each visual node to emit a single, isolated
batchPlayJSON object. Combine these array objects at the edge connections during compilation. - Visual Debugging: Change node colors in tldraw to reflect Photoshop execution status (e.g., green for success, red for
batchPlayrejection).
π¨ Gotchas / Anti-Patterns (Warnings)
- Anti-Pattern - Direct UXP DOM Manipulation: Never attempt to mount tldraw directly to the UXP DOM. UXP lacks the SVG and Canvas API completeness required by tldraw.
- Anti-Pattern - Synchronous Compilation: Do not block the React render cycle with UXP script generation. Offload graph traversal to a web worker or non-blocking async generator.
- Warning - History State Bloat: Executing every reactive stroke as a UXP script will flood the Photoshop History panel. Use
historyStateInfowithsuspendHistoryto group reactive adjustments. - Warning - IPC Stringification: Large tldraw workspaces serialize into massive JSON strings. Strip superficial UI state before passing the graph across the UXP webview boundary to prevent memory out-of-bounds errors.