Skip to content

Conversation

@jtydhr88
Copy link
Collaborator

@jtydhr88 jtydhr88 commented Nov 28, 2025

Summary

  • Add interactive crop box widget for ImageCrop node

Limitations

  • Vue nodes only: This widget is only available in Vue node rendering mode, not supported in legacy LiteGraph
    canvas mode
  • Limited input support: Currently only supports nodes that have outputs stored in nodeOutputStore.nodeOutputs (e.g., Load Image node). Nodes that don't populate nodeOutputStore (e.g., nodes with only preview images or external image sources) are not yet supported

Screenshots

2025-11-27.20-07-32.mp4

┆Issue is synchronized with this Notion page by Unito

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Nov 28, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 28, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Adds a Vue image-crop feature: a Vue SFC component, a composable managing crop state and handlers, litegraph widget types/renderer, extension registration wiring, widget registry entry, and English localization strings.

Changes

Cohort / File(s) Summary
Vue component & composable
src/components/imagecrop/WidgetImageCrop.vue, src/composables/useImageCrop.ts
New interactive image crop component and composable. Provides loading/placeholder/crop UI, drag-to-move, multi-handle resize, reactive crop state, image load/error handling, ResizeObserver support, and a global cropWidgetChangeHandlers registry.
Litegraph widget types & renderer
src/lib/litegraph/src/types/widgets.ts, src/lib/litegraph/src/widgets/ImageCropWidget.ts, src/lib/litegraph/src/widgets/widgetMap.ts
Adds IImageCropWidget type, implements ImageCropWidget canvas preview class, and wires imagecrop into widget mapping.
Extension & core integration
src/extensions/core/imageCrop.ts, src/extensions/core/index.ts
Registers imageCrop extension, attaches imagecrop widget to ImageCrop nodes, registers node-specific change callbacks in cropWidgetChangeHandlers, and enforces minimum node size (≥300×400).
Widget registry
src/renderer/extensions/vueNodes/widgets/registry/widgetRegistry.ts
Registers async WidgetImageCrop component in registry with aliases IMAGE_CROP/imageCrop and marks it non-essential.
Localization
src/locales/en/main.json
Adds imageCrop localization keys: loading, noInputImage, and cropPreviewAlt.

Sequence Diagram(s)

sequenceDiagram
    participant ExtSvc as Extension Service
    participant ImgCropExt as imageCrop Extension
    participant NodeGraph as Node Graph
    participant WidgetReg as Widget Registry
    participant VueComp as WidgetImageCrop
    participant Composable as useImageCrop
    participant Handlers as cropWidgetChangeHandlers

    ExtSvc->>ImgCropExt: initialize
    ImgCropExt->>NodeGraph: on ImageCrop node created (ensure size ≥300×400)
    ImgCropExt->>Handlers: register change callback for nodeId
    ImgCropExt->>WidgetReg: add imagecrop widget (Vue-only)

    WidgetReg->>VueComp: mount (props: nodeId)
    VueComp->>Composable: useImageCrop(nodeId)
    Composable->>NodeGraph: read node outputs / image URL
    Composable->>VueComp: provide refs, styles, handlers

    VueComp->>VueComp: render loading / placeholder / crop UI

    par User moves crop box
        VueComp->>Composable: drag handlers update crop state
        Composable->>Handlers: emit x,y updates for nodeId
        Handlers->>NodeGraph: persist parameters
    and User resizes crop
        VueComp->>Composable: resize handlers update crop state
        Composable->>Handlers: emit width,height updates for nodeId
        Handlers->>NodeGraph: persist parameters
    end

    VueComp->>VueComp: update cropBoxStyle & cropImageStyle (reactive)
Loading
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch imageCrop-crop-box

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Nov 28, 2025

🎭 Playwright Test Results

⚠️ Tests passed with flaky tests

⏰ Completed at: 11/29/2025, 01:35:11 AM UTC

📈 Summary

  • Total Tests: 493
  • Passed: 479 ✅
  • Failed: 0
  • Flaky: 5 ⚠️
  • Skipped: 9 ⏭️

📊 Test Reports by Browser

  • chromium: View Report • ✅ 470 / ❌ 0 / ⚠️ 5 / ⏭️ 9
  • chromium-2x: View Report • ✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0
  • chromium-0.5x: View Report • ✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0
  • mobile-chrome: View Report • ✅ 6 / ❌ 0 / ⚠️ 0 / ⏭️ 0

🎉 Click on the links above to view detailed test results for each browser configuration.

@github-actions
Copy link

github-actions bot commented Nov 28, 2025

🎨 Storybook Build Status

Build completed successfully!

⏰ Completed at: 11/29/2025, 01:26:02 AM UTC

🔗 Links


🎉 Your Storybook is ready for review!

@github-actions
Copy link

github-actions bot commented Nov 28, 2025

Bundle Size Report

Summary

  • Raw size: 17 MB baseline 17 MB — 🔴 +22.1 kB
  • Gzip: 3.37 MB baseline 3.37 MB — 🔴 +4.94 kB
  • Brotli: 2.59 MB baseline 2.58 MB — 🔴 +4.29 kB
  • Bundles: 99 current • 97 baseline • 38 added / 36 removed

Category Glance
Utilities & Hooks 🔴 +14.3 kB (17.2 kB) · Other 🔴 +5.48 kB (3.85 MB) · App Entry Points 🔴 +2.31 kB (3.18 MB) · Vendor & Third-Party ⚪ 0 B (8.56 MB) · Graph Workspace ⚪ 0 B (949 kB) · Panels & Settings ⚪ 0 B (298 kB) · + 3 more

Per-category breakdown
App Entry Points — 3.18 MB (baseline 3.18 MB) • 🔴 +2.31 kB

Main entry bundles and manifests

File Before After Δ Raw Δ Gzip Δ Brotli
assets/index-DURGBdEP.js (new) 2.95 MB 🔴 +2.95 MB 🔴 +616 kB 🔴 +468 kB
assets/index-BaIAwWq_.js (removed) 2.95 MB 🟢 -2.95 MB 🟢 -615 kB 🟢 -467 kB
assets/index-B1-Lvx_6.js (new) 227 kB 🔴 +227 kB 🔴 +48.8 kB 🔴 +40.1 kB
assets/index-CwfkVyor.js (removed) 227 kB 🟢 -227 kB 🟢 -48.6 kB 🟢 -40 kB
assets/index-DgSbNt60.js (new) 345 B 🔴 +345 B 🔴 +245 B 🔴 +201 B
assets/index-i47K8MSK.js (removed) 345 B 🟢 -345 B 🟢 -247 B 🟢 -202 B

Status: 3 added / 3 removed

Graph Workspace — 949 kB (baseline 949 kB) • ⚪ 0 B

Graph editor runtime, canvas, workflow orchestration

File Before After Δ Raw Δ Gzip Δ Brotli
assets/GraphView-S1JZi48B.js (removed) 949 kB 🟢 -949 kB 🟢 -184 kB 🟢 -141 kB
assets/GraphView-VqdXdQLb.js (new) 949 kB 🔴 +949 kB 🔴 +184 kB 🔴 +141 kB

Status: 1 added / 1 removed

Views & Navigation — 6.54 kB (baseline 6.54 kB) • ⚪ 0 B

Top-level views, pages, and routed surfaces

File Before After Δ Raw Δ Gzip Δ Brotli
assets/UserSelectView-B0E0nQXr.js (removed) 6.54 kB 🟢 -6.54 kB 🟢 -2.14 kB 🟢 -1.9 kB
assets/UserSelectView-BArCPBjN.js (new) 6.54 kB 🔴 +6.54 kB 🔴 +2.14 kB 🔴 +1.9 kB

Status: 1 added / 1 removed

Panels & Settings — 298 kB (baseline 298 kB) • ⚪ 0 B

Configuration panels, inspectors, and settings screens

File Before After Δ Raw Δ Gzip Δ Brotli
assets/CreditsPanel-FOG1Bfds.js (removed) 21.4 kB 🟢 -21.4 kB 🟢 -5.15 kB 🟢 -4.5 kB
assets/CreditsPanel-sh8Qwdht.js (new) 21.4 kB 🔴 +21.4 kB 🔴 +5.15 kB 🔴 +4.5 kB
assets/KeybindingPanel-ChJAkqX7.js (removed) 13.6 kB 🟢 -13.6 kB 🟢 -3.42 kB 🟢 -3.01 kB
assets/KeybindingPanel-DT-LhmDq.js (new) 13.6 kB 🔴 +13.6 kB 🔴 +3.42 kB 🔴 +3.01 kB
assets/ExtensionPanel-CJ6MAKHf.js (removed) 10.8 kB 🟢 -10.8 kB 🟢 -2.57 kB 🟢 -2.25 kB
assets/ExtensionPanel-DTvm3L_D.js (new) 10.8 kB 🔴 +10.8 kB 🔴 +2.57 kB 🔴 +2.26 kB
assets/AboutPanel-B1Ni69XM.js (new) 9.16 kB 🔴 +9.16 kB 🔴 +2.47 kB 🔴 +2.21 kB
assets/AboutPanel-CZ6vni3M.js (removed) 9.16 kB 🟢 -9.16 kB 🟢 -2.46 kB 🟢 -2.21 kB
assets/ServerConfigPanel-7YdA7IjW.js (removed) 6.56 kB 🟢 -6.56 kB 🟢 -1.83 kB 🟢 -1.62 kB
assets/ServerConfigPanel-DyK0n1eU.js (new) 6.56 kB 🔴 +6.56 kB 🔴 +1.83 kB 🔴 +1.63 kB
assets/UserPanel-ByIMnEz0.js (removed) 6.23 kB 🟢 -6.23 kB 🟢 -1.72 kB 🟢 -1.52 kB
assets/UserPanel-DYzG1InD.js (new) 6.23 kB 🔴 +6.23 kB 🔴 +1.72 kB 🔴 +1.51 kB
assets/settings-BhbWhsRg.js 101 B 101 B ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-BXTtSH4O.js 33.3 kB 33.3 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-C9Pzn-NG.js 25.2 kB 25.2 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-CCy2fA_h.js 27.3 kB 27.3 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-CQpqEFfl.js 26.6 kB 26.6 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-DHcnxypw.js 21.7 kB 21.7 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-DhFTK9fY.js 25.1 kB 25.1 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-DlT4t_ui.js 25.9 kB 25.9 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-DRgSrIdD.js 24.2 kB 24.2 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-tjkeqiZq.js 21.1 kB 21.1 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B

Status: 6 added / 6 removed

UI Components — 139 kB (baseline 139 kB) • ⚪ 0 B

Reusable component library chunks

File Before After Δ Raw Δ Gzip Δ Brotli
assets/Load3D.vue_vue_type_script_setup_true_lang-bDp_236E.js (new) 53.9 kB 🔴 +53.9 kB 🔴 +8.52 kB 🔴 +7.31 kB
assets/Load3D.vue_vue_type_script_setup_true_lang-DSWOEFJB.js (removed) 53.9 kB 🟢 -53.9 kB 🟢 -8.52 kB 🟢 -7.31 kB
assets/WidgetSelect.vue_vue_type_script_setup_true_lang-B4d9Ac9X.js (new) 47 kB 🔴 +47 kB 🔴 +10.1 kB 🔴 +8.79 kB
assets/WidgetSelect.vue_vue_type_script_setup_true_lang-DUwIwQBq.js (removed) 47 kB 🟢 -47 kB 🟢 -10.1 kB 🟢 -8.78 kB
assets/WidgetInputNumber.vue_vue_type_script_setup_true_lang-akAeHUog.js (removed) 12.8 kB 🟢 -12.8 kB 🟢 -3.35 kB 🟢 -2.96 kB
assets/WidgetInputNumber.vue_vue_type_script_setup_true_lang-j1gtaurS.js (new) 12.8 kB 🔴 +12.8 kB 🔴 +3.35 kB 🔴 +2.96 kB
assets/ComfyQueueButton-CIzFa9z8.js (removed) 8.44 kB 🟢 -8.44 kB 🟢 -2.48 kB 🟢 -2.21 kB
assets/ComfyQueueButton-DCNcHCeZ.js (new) 8.44 kB 🔴 +8.44 kB 🔴 +2.47 kB 🔴 +2.21 kB
assets/MediaTitle.vue_vue_type_script_setup_true_lang-aNoD0T5y.js (new) 897 B 🔴 +897 B 🔴 +503 B 🔴 +442 B
assets/MediaTitle.vue_vue_type_script_setup_true_lang-CtAMGEIT.js (removed) 897 B 🟢 -897 B 🟢 -504 B 🟢 -429 B
assets/LazyImage.vue_vue_type_script_setup_true_lang-Pm3jgX4e.js 10.8 kB 10.8 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/UserAvatar.vue_vue_type_script_setup_true_lang-Bs-EIQeq.js 1.34 kB 1.34 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/WidgetButton-CsMa_P26.js 2.04 kB 2.04 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/WidgetLayoutField.vue_vue_type_script_setup_true_lang-Cf8dNyi2.js 2 kB 2 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B

Status: 5 added / 5 removed

Data & Services — 12.5 kB (baseline 12.5 kB) • ⚪ 0 B

Stores, services, APIs, and repositories

File Before After Δ Raw Δ Gzip Δ Brotli
assets/keybindingService-BpPKB_gE.js (new) 7.51 kB 🔴 +7.51 kB 🔴 +1.83 kB 🔴 +1.58 kB
assets/keybindingService-CchRYcle.js (removed) 7.51 kB 🟢 -7.51 kB 🟢 -1.83 kB 🟢 -1.58 kB
assets/audioService-BiMPzf0O.js (removed) 2.2 kB 🟢 -2.2 kB 🟢 -959 B 🟢 -823 B
assets/audioService-DN21dJ9I.js (new) 2.2 kB 🔴 +2.2 kB 🔴 +961 B 🔴 +830 B
assets/serverConfigStore-B5NW8oSr.js 2.83 kB 2.83 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B

Status: 2 added / 2 removed

Utilities & Hooks — 17.2 kB (baseline 2.94 kB) • 🔴 +14.3 kB

Helpers, composables, and utility bundles

File Before After Δ Raw Δ Gzip Δ Brotli
assets/useImageCrop-DVdXqbyG.js (new) 14.3 kB 🔴 +14.3 kB 🔴 +2.92 kB 🔴 +2.54 kB
assets/audioUtils-Bw6F1MDV.js (removed) 1.41 kB 🟢 -1.41 kB 🟢 -652 B 🟢 -550 B
assets/audioUtils-DbDI-9XN.js (new) 1.41 kB 🔴 +1.41 kB 🔴 +652 B 🔴 +582 B
assets/mathUtil-CTARWQ-l.js 1.07 kB 1.07 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeFilterUtil-CXKCRJ-m.js 460 B 460 B ⚪ 0 B ⚪ 0 B ⚪ 0 B

Status: 2 added / 1 removed

Vendor & Third-Party — 8.56 MB (baseline 8.56 MB) • ⚪ 0 B

External libraries and shared vendor chunks

File Before After Δ Raw Δ Gzip Δ Brotli
assets/vendor-chart-uhYFfslB.js 452 kB 452 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/vendor-other-DisjWJFj.js 3.98 MB 3.98 MB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/vendor-primevue-LncEKxae.js 1.96 MB 1.96 MB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/vendor-three-aR6ntw5X.js 1.37 MB 1.37 MB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/vendor-tiptap-C4yk8cCR.js 232 kB 232 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/vendor-vue-tw3tq7KH.js 160 kB 160 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/vendor-xterm-BZLod3g9.js 407 kB 407 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
Other — 3.85 MB (baseline 3.84 MB) • 🔴 +5.48 kB

Bundles that do not match a named category

File Before After Δ Raw Δ Gzip Δ Brotli
assets/WidgetRecordAudio-_BGPiv3A.js (removed) 20.4 kB 🟢 -20.4 kB 🟢 -5.24 kB 🟢 -4.64 kB
assets/WidgetRecordAudio-qzXGY4fJ.js (new) 20.4 kB 🔴 +20.4 kB 🔴 +5.24 kB 🔴 +4.63 kB
assets/AudioPreviewPlayer-Cizq1Ec8.js (new) 13.5 kB 🔴 +13.5 kB 🔴 +3.4 kB 🔴 +3.04 kB
assets/AudioPreviewPlayer-DF7QB_MQ.js (removed) 13.5 kB 🟢 -13.5 kB 🟢 -3.4 kB 🟢 -3.04 kB
assets/WidgetImageCrop-BVUm2Oke.js (new) 5.48 kB 🔴 +5.48 kB 🔴 +1.69 kB 🔴 +1.47 kB
assets/WidgetGalleria-B5B0gAMS.js (new) 4.1 kB 🔴 +4.1 kB 🔴 +1.45 kB 🔴 +1.3 kB
assets/WidgetGalleria-wxuh6lR8.js (removed) 4.1 kB 🟢 -4.1 kB 🟢 -1.45 kB 🟢 -1.3 kB
assets/WidgetColorPicker-CJpdHTbO.js (removed) 3.41 kB 🟢 -3.41 kB 🟢 -1.38 kB 🟢 -1.23 kB
assets/WidgetColorPicker-D94eSAjW.js (new) 3.41 kB 🔴 +3.41 kB 🔴 +1.38 kB 🔴 +1.23 kB
assets/WidgetMarkdown-B9ZywYDG.js (new) 3.1 kB 🔴 +3.1 kB 🔴 +1.29 kB 🔴 +1.13 kB
assets/WidgetMarkdown-D4PNapCQ.js (removed) 3.1 kB 🟢 -3.1 kB 🟢 -1.29 kB 🟢 -1.13 kB
assets/WidgetAudioUI-B70tnQae.js (new) 2.82 kB 🔴 +2.82 kB 🔴 +1.12 kB 🔴 +1.01 kB
assets/WidgetAudioUI-BpmJnqFZ.js (removed) 2.82 kB 🟢 -2.82 kB 🟢 -1.12 kB 🟢 -1.02 kB
assets/WidgetTextarea-B5eFUX-c.js (new) 2.48 kB 🔴 +2.48 kB 🔴 +1.01 kB 🔴 +886 B
assets/WidgetTextarea-BmuXSLjd.js (removed) 2.48 kB 🟢 -2.48 kB 🟢 -1.01 kB 🟢 -900 B
assets/WidgetInputText-Dd1116ep.js (removed) 1.99 kB 🟢 -1.99 kB 🟢 -918 B 🟢 -845 B
assets/WidgetInputText-GpqHJNw8.js (new) 1.99 kB 🔴 +1.99 kB 🔴 +918 B 🔴 +852 B
assets/MediaImageBottom-C719nP9x.js (new) 1.57 kB 🔴 +1.57 kB 🔴 +743 B 🔴 +643 B
assets/MediaImageBottom-Dze5Q59G.js (removed) 1.57 kB 🟢 -1.57 kB 🟢 -741 B 🟢 -642 B
assets/MediaAudioBottom-CZds6mgd.js (new) 1.52 kB 🔴 +1.52 kB 🔴 +742 B 🔴 +655 B
assets/MediaAudioBottom-DK6LbcyF.js (removed) 1.52 kB 🟢 -1.52 kB 🟢 -743 B 🟢 -654 B
assets/MediaVideoBottom-ejRps_8h.js (new) 1.52 kB 🔴 +1.52 kB 🔴 +739 B 🔴 +652 B
assets/MediaVideoBottom-psm2uv7r.js (removed) 1.52 kB 🟢 -1.52 kB 🟢 -738 B 🟢 -652 B
assets/Media3DBottom-BiceuOMY.js (new) 1.5 kB 🔴 +1.5 kB 🔴 +732 B 🔴 +646 B
assets/Media3DBottom-BwqtZQoo.js (removed) 1.5 kB 🟢 -1.5 kB 🟢 -732 B 🟢 -649 B
assets/Media3DTop-BOTQ2WB3.js (new) 1.49 kB 🔴 +1.49 kB 🔴 +767 B 🔴 +652 B
assets/Media3DTop-D2IaaD1x.js (removed) 1.49 kB 🟢 -1.49 kB 🟢 -765 B 🟢 -649 B
assets/WidgetSelect-C7zIioLp.js (removed) 655 B 🟢 -655 B 🟢 -343 B 🟢 -306 B
assets/WidgetSelect-si4t_c4t.js (new) 655 B 🔴 +655 B 🔴 +343 B 🔴 +286 B
assets/WidgetInputNumber-Bb7f_q9_.js (new) 595 B 🔴 +595 B 🔴 +328 B 🔴 +275 B
assets/WidgetInputNumber-lBYQz7IE.js (removed) 595 B 🟢 -595 B 🟢 -330 B 🟢 -276 B
assets/Load3D-CDK7qIaS.js (removed) 424 B 🟢 -424 B 🟢 -269 B 🟢 -224 B
assets/Load3D-D2oreFvl.js (new) 424 B 🔴 +424 B 🔴 +267 B 🔴 +223 B
assets/WidgetLegacy-B9V2d40_.js (removed) 364 B 🟢 -364 B 🟢 -236 B 🟢 -195 B
assets/WidgetLegacy-DjN6xPKr.js (new) 364 B 🔴 +364 B 🔴 +237 B 🔴 +193 B
assets/commands-_s-RvhJR.js 13.6 kB 13.6 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-BuUILW6P.js 13 kB 13 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-BV4R6fLx.js 14.9 kB 14.9 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-BWp4HdfU.js 101 B 101 B ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-CLwPdnT6.js 14.2 kB 14.2 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-CWMchBmd.js 15.9 kB 15.9 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-DazTQhtc.js 12.9 kB 12.9 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-DmWrOe93.js 13.7 kB 13.7 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-DwiH7Kr6.js 13.8 kB 13.8 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-mS3LCNPn.js 14.5 kB 14.5 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-5lOBdqcC.js 84.5 kB 84.5 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-BOCuaVpE.js 73.4 kB 73.4 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-ClrEFGUz.js 72.4 kB 72.4 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-Cw9RZWRY.js 89 B 89 B ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-CyNU0iQX.js 99.3 kB 99.3 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-D7gwLxft.js 114 kB 114 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-DC8o4BCt.js 86.8 kB 86.8 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-DKiesCV4.js 94.3 kB 94.3 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-Hq2q-OtB.js 83.6 kB 83.6 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-USAlAlnj.js 82 kB 82 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/MediaAudioTop-Bqc4HR5L.js 1.46 kB 1.46 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/MediaImageTop-DbyT2UjV.js 1.75 kB 1.75 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/MediaVideoTop-6PQqfKb3.js 2.76 kB 2.76 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-_Px5dSNW.js 306 kB 306 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-7z21KPoS.js 285 kB 285 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-Bw_Jitw_.js 101 B 101 B ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-BWKZzBPK.js 346 kB 346 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-CGbgH4Yl.js 320 kB 320 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-CjjjdWkV.js 313 kB 313 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-CVrNtxvj.js 288 kB 288 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-DLRSA0IK.js 309 kB 309 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-DQV2gnwA.js 372 kB 372 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-ofqLG5vz.js 310 kB 310 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/WidgetChart-C9sMH5oS.js 2.48 kB 2.48 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/WidgetImageCompare-D4gTOuOo.js 2.21 kB 2.21 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/widgetPropFilter-BIbGSUAt.js 1.28 kB 1.28 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/WidgetToggleSwitch-CBRsIck7.js 1.58 kB 1.58 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B

Status: 18 added / 17 removed

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
src/lib/litegraph/src/widgets/ImageCropWidget.ts (1)

15-42: Consider using canvas save/restore for context state.

The current approach of manually saving and restoring context properties works, but the canvas API provides ctx.save() and ctx.restore() methods for this purpose, which is more idiomatic:

 drawWidget(ctx: CanvasRenderingContext2D, options: DrawWidgetOptions): void {
   const { width } = options
   const { y, height } = this

-  const { fillStyle, strokeStyle, textAlign, textBaseline, font } = ctx
+  ctx.save()

   ctx.fillStyle = this.background_color
   ctx.fillRect(15, y, width - 30, height)

   ctx.strokeStyle = this.outline_color
   ctx.strokeRect(15, y, width - 30, height)

   ctx.fillStyle = this.text_color
   ctx.font = '11px monospace'
   ctx.textAlign = 'center'
   ctx.textBaseline = 'middle'

   const text = 'ImageCrop: Vue-only'
   ctx.fillText(text, width / 2, y + height / 2)

-  Object.assign(ctx, {
-    fillStyle,
-    strokeStyle,
-    textAlign,
-    textBaseline,
-    font
-  })
+  ctx.restore()
 }

However, the current implementation is acceptable and follows patterns seen elsewhere in the codebase.

src/composables/useImageCrop.ts (4)

73-98: Tighten widget helper typing to prevent name typos

getWidgetValue / setWidgetValue currently accept name: string, but all callers use the fixed set 'x' | 'y' | 'width' | 'height'. Making that union explicit will give you compile‑time protection against typos and keep the helpers aligned with CropWidgetChangeHandler.

You can refactor like this:

-type CropWidgetChangeHandler = (
-  name: 'x' | 'y' | 'width' | 'height',
-  value: number
-) => void
+type CropWidgetField = 'x' | 'y' | 'width' | 'height'
+
+type CropWidgetChangeHandler = (name: CropWidgetField, value: number) => void

-  const getWidgetValue = (name: string): number => {
+  const getWidgetValue = (name: CropWidgetField): number => {
@@
-  const setWidgetValue = (name: string, value: number) => {
+  const setWidgetValue = (name: CropWidgetField, value: number) => {

Call sites to setWidgetValue/getWidgetValue already match this union.

Also applies to: 345-347, 420-427


38-40: isLoading is never set to true — spinner state won’t work

isLoading is only set to false in handleImageLoad / handleImageError, but it’s never set to true when a new image URL is assigned. Any consumer using this ref to show a loading spinner won’t see a “loading” state.

You can flip it on when the URL changes:

  const updateImageUrl = () => {
-    imageUrl.value = getInputImageUrl()
+    const newUrl = getInputImageUrl()
+    imageUrl.value = newUrl
+    isLoading.value = !!newUrl
  }

This keeps the load/error handlers correct (they already reset it to false).

Also applies to: 133-135, 299-307


309-314: Defensively handle pointer capture to avoid runtime errors on non‑HTMLElement targets

capturePointer / releasePointer cast e.target as HTMLElement and call the pointer APIs directly. In normal usage these will be bound to elements, but it only takes one mis‑bound handler or synthetic event to trigger a runtime error (setPointerCapture undefined).

A small guard keeps this safe without changing behavior:

-  const capturePointer = (e: PointerEvent) =>
-    (e.target as HTMLElement).setPointerCapture(e.pointerId)
-
-  const releasePointer = (e: PointerEvent) =>
-    (e.target as HTMLElement).releasePointerCapture(e.pointerId)
+  const capturePointer = (e: PointerEvent) => {
+    const target = e.target
+    if (target instanceof HTMLElement && target.setPointerCapture) {
+      target.setPointerCapture(e.pointerId)
+    }
+  }
+
+  const releasePointer = (e: PointerEvent) => {
+    const target = e.target
+    if (target instanceof HTMLElement && target.releasePointerCapture) {
+      target.releasePointerCapture(e.pointerId)
+    }
+  }

Same semantics in the happy path, safer in edge cases.

Also applies to: 315-325, 356-370, 430-436


438-456: Initialize nodeId check and guard ResizeObserver for non‑browser/test environments

Two small robustness points in initialize:

  1. The if (nodeId) check treats 0/'' as “no node”. If NodeId ever includes 0, this would skip getNodeById. Since you already use nodeId == null elsewhere, it’s safer to be consistent:
-  const initialize = () => {
-    if (nodeId) {
-      node.value = app.rootGraph?.getNodeById(nodeId) || null
-    }
+  const initialize = () => {
+    if (nodeId != null) {
+      node.value = app.rootGraph?.getNodeById(nodeId) || null
+    }
  1. Directly constructing ResizeObserver can throw in non‑browser or older test environments. A light guard avoids that without affecting normal usage:
-    resizeObserver = new ResizeObserver(() => {
-      if (imageEl.value && imageUrl.value) {
-        updateDisplayedDimensions()
-      }
-    })
-
-    if (containerEl.value) {
-      resizeObserver.observe(containerEl.value)
-    }
+    if (typeof ResizeObserver !== 'undefined') {
+      resizeObserver = new ResizeObserver(() => {
+        if (imageEl.value && imageUrl.value) {
+          updateDisplayedDimensions()
+        }
+      })
+
+      if (containerEl.value) {
+        resizeObserver.observe(containerEl.value)
+      }
+    }

Both are small tweaks but improve resilience.

@christian-byrne christian-byrne added the claude-review Add to trigger a PR code review from Claude Code label Nov 28, 2025
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comprehensive PR Review

This review is generated by Claude. It may not always be accurate, as with human reviewers. If you believe that any of the comments are invalid or incorrect, please state why for each. For others, please implement the changes in one way or another.

Review Summary

PR: Crop box for ImageCrop Node (#7014)
Impact: 692 additions, 1 deletions across 9 files

Issue Distribution

  • Critical: 0
  • High: 1
  • Medium: 5
  • Low: 1

Category Breakdown

  • Architecture: 1 issues
  • Security: 1 issues
  • Performance: 3 issues
  • Code Quality: 2 issues

Key Findings

Architecture & Design

The implementation introduces a new interactive crop box widget that follows Vue 3 Composition API patterns well. However, it uses a global Map for state management instead of the established Pinia store pattern, which could impact maintainability and debugging capabilities.

Security Considerations

Found a potential XSS vulnerability where imageUrl is directly interpolated into CSS background-image properties without sanitization. This could allow injection of malicious CSS/JavaScript through image URLs.

Performance Impact

Several performance concerns were identified:

  • No debouncing of frequent widget updates during drag/resize operations
  • Expensive computations in computed properties that run on every reactive change
  • Manual implementations instead of leveraging VueUse composables

Integration Points

The widget integrates well with the existing Vue node system and LiteGraph architecture. The extension registration follows established patterns and the widget type definitions are properly integrated.

Positive Observations

  • Clean Vue 3 Composition API usage with proper reactivity
  • Comprehensive TypeScript typing throughout the implementation
  • Good separation of concerns between the composable and Vue component
  • Proper internationalization support
  • Thoughtful UI/UX design with proper visual feedback and cursor states
  • Robust mathematical calculations for image scaling and crop positioning
  • Good error handling for image load failures and edge cases

References

Next Steps

  1. Address the high-priority security issue with URL sanitization before merge
  2. Consider implementing performance optimizations for better user experience
  3. Evaluate architectural decisions for long-term maintainability
  4. Add accessibility features for better inclusive design
  5. Consider adding unit tests for the crop calculation logic

This is a comprehensive automated review. For architectural decisions requiring human judgment, please request additional manual review.

@github-actions github-actions bot removed the claude-review Add to trigger a PR code review from Claude Code label Nov 28, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/composables/useImageCrop.ts (2)

78-95: Add runtime validation for widget values to improve type safety.

The type assertion as number on line 83 and unvalidated assignments on lines 92-93 bypass TypeScript's type checking. If a widget's value is not a number or its callback expects a different signature, this could cause runtime errors.

Consider adding runtime validation:

 const getWidgetValue = (name: string): number => {
   if (!node.value) return 0
 
   const widget = node.value.widgets?.find((w) => w.name === name)
+  const value = widget?.value
+  return typeof value === 'number' ? value : 0
-  return (widget?.value as number) ?? 0
 }
 
 const setWidgetValue = (name: string, value: number) => {
   if (!node.value) return
 
   const widget = node.value.widgets?.find((w) => w.name === name)
 
   if (widget) {
+    if (typeof value !== 'number' || !isFinite(value)) return
     widget.value = value
     widget.callback?.(value)
   }
 }

321-453: Consider using VueUse's usePointer composable for pointer event handling.

The manual pointer capture/release and event handling could be simplified using VueUse's usePointer composable, which provides reactive pointer position and state. This would reduce boilerplate and align with the project's preference for VueUse utilities.

Example pattern:

import { usePointer } from '@vueuse/core'

const { x, y, pressure, pointerType } = usePointer()

// Use reactive x, y in watchers or computed instead of manual event handlers

However, the current implementation is functional and correct, so this is a nice-to-have improvement rather than a priority.

Based on learnings: The project prefers VueUse composables for performance-enhancing utilities.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c467708 and 38173d8.

📒 Files selected for processing (1)
  • src/composables/useImageCrop.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (15)
**/*.{vue,ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{vue,ts,tsx}: Leverage VueUse functions for performance-enhancing utilities
Use vue-i18n in Composition API for any string literals and place new translation entries in src/locales/en/main.json

Files:

  • src/composables/useImageCrop.ts
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursorrules)

Use es-toolkit for utility functions

Files:

  • src/composables/useImageCrop.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

Use TypeScript for type safety

**/*.{ts,tsx}: Never use any type - use proper TypeScript types
Never use as any type assertions - fix the underlying type issue

Files:

  • src/composables/useImageCrop.ts
**/*.{ts,tsx,js,vue}

📄 CodeRabbit inference engine (.cursorrules)

Implement proper error handling in components and services

**/*.{ts,tsx,js,vue}: Use 2-space indentation, single quotes, no semicolons, and maintain 80-character line width as configured in .prettierrc
Organize imports by sorting and grouping by plugin, and run pnpm format before committing

Files:

  • src/composables/useImageCrop.ts
src/**/*.{vue,ts}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/**/*.{vue,ts}: Leverage VueUse functions for performance-enhancing styles
Implement proper error handling
Use vue-i18n in composition API for any string literals. Place new translation entries in src/locales/en/main.json

Files:

  • src/composables/useImageCrop.ts
src/**/*.ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/**/*.ts: Use es-toolkit for utility functions
Use TypeScript for type safety

Files:

  • src/composables/useImageCrop.ts
**/*.{ts,tsx,js,jsx,vue}

📄 CodeRabbit inference engine (CLAUDE.md)

Use camelCase for variable and setting names in TypeScript/Vue files

Files:

  • src/composables/useImageCrop.ts
**/*.{ts,tsx,vue}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,vue}: Use const settingStore = useSettingStore() and settingStore.get('Comfy.SomeSetting') to retrieve settings in TypeScript/Vue files
Use await settingStore.set('Comfy.SomeSetting', newValue) to update settings in TypeScript/Vue files
Check server capabilities using api.serverSupportsFeature('feature_name') before using enhanced features
Use api.getServerFeature('config_name', defaultValue) to retrieve server feature configuration

Enforce ESLint rules for Vue + TypeScript including: no floating promises, no unused imports, and i18n raw text restrictions in templates

Files:

  • src/composables/useImageCrop.ts
**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.ts: Define dynamic setting defaults using runtime context with functions in settings configuration
Use defaultsByInstallVersion property for gradual feature rollout based on version in settings configuration

Files:

  • src/composables/useImageCrop.ts
src/**/{services,composables}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (src/CLAUDE.md)

src/**/{services,composables}/**/*.{ts,tsx}: Use api.apiURL() for backend endpoints instead of constructing URLs directly
Use api.fileURL() for static file access instead of constructing URLs directly

Files:

  • src/composables/useImageCrop.ts
src/**/*.{ts,tsx,vue}

📄 CodeRabbit inference engine (src/CLAUDE.md)

src/**/*.{ts,tsx,vue}: Sanitize HTML with DOMPurify to prevent XSS attacks
Avoid using @ts-expect-error; use proper TypeScript types instead
Use es-toolkit for utility functions instead of other utility libraries
Implement proper TypeScript types throughout the codebase

Files:

  • src/composables/useImageCrop.ts
src/**/{composables,components}/**/*.{ts,tsx,vue}

📄 CodeRabbit inference engine (src/CLAUDE.md)

Clean up subscriptions in state management to prevent memory leaks

Files:

  • src/composables/useImageCrop.ts
src/**/*.{vue,ts,tsx}

📄 CodeRabbit inference engine (src/CLAUDE.md)

Follow Vue 3 composition API style guide

Files:

  • src/composables/useImageCrop.ts
src/**/{components,composables}/**/*.{ts,tsx,vue}

📄 CodeRabbit inference engine (src/CLAUDE.md)

Use vue-i18n for ALL user-facing strings by adding them to src/locales/en/main.json

Files:

  • src/composables/useImageCrop.ts
**/composables/use*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Name composables in the format useXyz.ts

Files:

  • src/composables/useImageCrop.ts
🧠 Learnings (12)
📓 Common learnings
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-24T19:46:52.279Z
Learning: Applies to **/*.{vue,ts,tsx} : Use vue-i18n in Composition API for any string literals and place new translation entries in src/locales/en/main.json
📚 Learning: 2025-11-24T19:47:34.324Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: src/CLAUDE.md:0-0
Timestamp: 2025-11-24T19:47:34.324Z
Learning: Applies to src/**/*.{ts,tsx,vue} : Sanitize HTML with DOMPurify to prevent XSS attacks

Applied to files:

  • src/composables/useImageCrop.ts
📚 Learning: 2025-11-24T19:47:45.616Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: src/components/CLAUDE.md:0-0
Timestamp: 2025-11-24T19:47:45.616Z
Learning: Applies to src/components/**/*.{vue,ts,js} : Use existing VueUse composables (such as useElementHover) instead of manually managing event listeners

Applied to files:

  • src/composables/useImageCrop.ts
📚 Learning: 2025-11-24T19:47:45.616Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: src/components/CLAUDE.md:0-0
Timestamp: 2025-11-24T19:47:45.616Z
Learning: Applies to src/components/**/*.{vue,ts,js} : Use useIntersectionObserver for visibility detection instead of custom scroll handlers

Applied to files:

  • src/composables/useImageCrop.ts
📚 Learning: 2025-11-24T19:46:52.279Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-24T19:46:52.279Z
Learning: Applies to **/*.{vue,ts,tsx} : Leverage VueUse functions for performance-enhancing utilities

Applied to files:

  • src/composables/useImageCrop.ts
📚 Learning: 2025-11-24T19:47:02.860Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T19:47:02.860Z
Learning: Applies to src/**/*.{vue,ts} : Leverage VueUse functions for performance-enhancing styles

Applied to files:

  • src/composables/useImageCrop.ts
📚 Learning: 2025-11-24T19:46:52.279Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-24T19:46:52.279Z
Learning: Applies to **/*.vue : Utilize ref and reactive for reactive state in Vue 3

Applied to files:

  • src/composables/useImageCrop.ts
📚 Learning: 2025-11-24T19:47:45.616Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: src/components/CLAUDE.md:0-0
Timestamp: 2025-11-24T19:47:45.616Z
Learning: Applies to src/components/**/*.vue : Use ref/reactive for state management in Vue 3 Composition API

Applied to files:

  • src/composables/useImageCrop.ts
📚 Learning: 2025-11-24T19:47:02.860Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T19:47:02.860Z
Learning: Applies to src/**/*.vue : Use the Vue 3 Composition API instead of the Options API when writing Vue components (exception: when overriding or extending PrimeVue components for compatibility)

Applied to files:

  • src/composables/useImageCrop.ts
📚 Learning: 2025-11-24T19:47:02.860Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T19:47:02.860Z
Learning: Applies to src/**/*.vue : Utilize ref and reactive for reactive state

Applied to files:

  • src/composables/useImageCrop.ts
📚 Learning: 2025-11-24T19:47:45.616Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: src/components/CLAUDE.md:0-0
Timestamp: 2025-11-24T19:47:45.616Z
Learning: Applies to src/components/**/*.vue : Implement computed() for derived state in Vue 3 Composition API

Applied to files:

  • src/composables/useImageCrop.ts
📚 Learning: 2025-11-24T19:46:52.279Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-24T19:46:52.279Z
Learning: Applies to **/*.vue : Do not use deprecated PrimeVue components (Dropdown, OverlayPanel, Calendar, InputSwitch, Sidebar, Chips, TabMenu, Steps, InlineMessage). Use replacements: Select, Popover, DatePicker, ToggleSwitch, Drawer, AutoComplete, Tabs, Stepper, Message respectively

Applied to files:

  • src/composables/useImageCrop.ts
🧬 Code graph analysis (1)
src/composables/useImageCrop.ts (1)
src/scripts/app.ts (1)
  • app (1708-1708)
🪛 ESLint
src/composables/useImageCrop.ts

[error] 1-1: Resolve error: EACCES: permission denied, open '/EwBTEioqGB'
at Object.writeFileSync (node:fs:2409:20)
at l (file:///home/jailuser/git/node_modules/.pnpm/[email protected]/node_modules/get-tsconfig/dist/index.mjs:7:13670)
at createFilesMatcher (file:///home/jailuser/git/node_modules/.pnpm/[email protected]/node_modules/get-tsconfig/dist/index.mjs:7:14422)
at resolve (file:///home/jailuser/git/node_modules/.pnpm/[email protected][email protected]_@typescript-eslin_da4796079dab5a32abf73f9910d12370/node_modules/eslint-import-resolver-typescript/lib/index.js:70:65)
at Object.resolve (file:///home/jailuser/git/node_modules/.pnpm/[email protected][email protected]_@typescript-eslin_da4796079dab5a32abf73f9910d12370/node_modules/eslint-import-resolver-typescript/lib/index.js:147:20)
at file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/resolve.js:170:69
at setRuleContext (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint-import-context/lib/index.js:23:20)
at fullResolve (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/resolve.js:170:30)
at relative (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/resolve.js:215:12)
at resolve (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/resolve.js:220:16)
at ExportMap.get (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/export-map.js:88:22)
at processBodyStatement (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/rules/namespace.js:9:31)
at Program (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/rules/namespace.js:100:21)
at ruleErrorHandler (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:1173:33)
at /home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/source-code-visitor.js:76:46
at Array.forEach ()
at SourceCodeVisitor.callSync (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/source-code-visitor.js:76:30)
at /home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/source-code-traverser.js:291:18
at Array.forEach ()
at SourceCodeTraverser.traverseSync (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/source-code-traverser.js:290:10)
at runRules (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:1214:12)
at #flatVerifyWithoutProcessors (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:2101:4)
at Linter._verifyWithFlatConfigArrayAndWithoutProcessors (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:2189:43)
at Linter._verifyWithFlatConfigArray (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:2292:15)
at Linter.verify (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:1677:10)
at Linter.verifyAndFix (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:2557:20)
at verifyText (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/eslint/eslint-helpers.js:1179:45)
at readAndVerifyFile (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/eslint/eslint-helpers.js:1320:10)

(import-x/namespace)


[error] 1-1: Resolve error: EACCES: permission denied, open '/RJnaDzrHZO'
at Object.writeFileSync (node:fs:2409:20)
at l (file:///home/jailuser/git/node_modules/.pnpm/[email protected]/node_modules/get-tsconfig/dist/index.mjs:7:13670)
at createFilesMatcher (file:///home/jailuser/git/node_modules/.pnpm/[email protected]/node_modules/get-tsconfig/dist/index.mjs:7:14422)
at resolve (file:///home/jailuser/git/node_modules/.pnpm/[email protected][email protected]_@typescript-eslin_da4796079dab5a32abf73f9910d12370/node_modules/eslint-import-resolver-typescript/lib/index.js:70:65)
at Object.resolve (file:///home/jailuser/git/node_modules/.pnpm/[email protected][email protected]_@typescript-eslin_da4796079dab5a32abf73f9910d12370/node_modules/eslint-import-resolver-typescript/lib/index.js:147:20)
at file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/resolve.js:170:69
at setRuleContext (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint-import-context/lib/index.js:23:20)
at fullResolve (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/resolve.js:170:30)
at relative (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/resolve.js:215:12)
at resolve (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/resolve.js:220:16)
at checkSourceValue (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/rules/no-unresolved.js:31:34)
at checkSourceValue (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/module-visitor.js:14:9)
at checkSource (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/module-visitor.js:17:9)
at ruleErrorHandler (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:1173:33)
at /home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/source-code-visitor.js:76:46
at Array.forEach ()
at SourceCodeVisitor.callSync (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/source-code-visitor.js:76:30)
at /home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/source-code-traverser.js:291:18
at Array.forEach ()
at SourceCodeTraverser.traverseSync (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/source-code-traverser.js:290:10)
at runRules (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:1214:12)
at #flatVerifyWithoutProcessors (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:2101:4)
at Linter._verifyWithFlatConfigArrayAndWithoutProcessors (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:2189:43)
at Linter._verifyWithFlatConfigArray (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:2292:15)
at Linter.verify (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:1677:10)
at Linter.verifyAndFix (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:2557:20)
at verifyText (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/eslint/eslint-helpers.js:1179:45)
at readAndVerifyFile (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/eslint/eslint-helpers.js:1320:10)

(import-x/no-unresolved)


[error] 1-1: Resolve error: EACCES: permission denied, open '/lYoUuhKhJu'
at Object.writeFileSync (node:fs:2409:20)
at l (file:///home/jailuser/git/node_modules/.pnpm/[email protected]/node_modules/get-tsconfig/dist/index.mjs:7:13670)
at createFilesMatcher (file:///home/jailuser/git/node_modules/.pnpm/[email protected]/node_modules/get-tsconfig/dist/index.mjs:7:14422)
at resolve (file:///home/jailuser/git/node_modules/.pnpm/[email protected][email protected]_@typescript-eslin_da4796079dab5a32abf73f9910d12370/node_modules/eslint-import-resolver-typescript/lib/index.js:70:65)
at Object.resolve (file:///home/jailuser/git/node_modules/.pnpm/[email protected][email protected]_@typescript-eslin_da4796079dab5a32abf73f9910d12370/node_modules/eslint-import-resolver-typescript/lib/index.js:147:20)
at file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/resolve.js:170:69
at setRuleContext (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint-import-context/lib/index.js:23:20)
at fullResolve (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/resolve.js:170:30)
at relative (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/resolve.js:215:12)
at resolve (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/resolve.js:220:16)
at importType (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/import-type.js:126:63)
at checkImportForRelativePackage (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/rules/no-relative-packages.js:15:38)
at file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/rules/no-relative-packages.js:59:40
at checkSourceValue (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/module-visitor.js:14:9)
at checkSource (file:///home/jailuser/git/node_modules/.pnpm/eslint-plugin-import-x@4.16.1_@typescript-eslint[email protected]_eslint@[email protected]__d4b6b79e6f12f59d34d55ebbf27dc73f/node_modules/eslint-plugin-import-x/lib/utils/module-visitor.js:17:9)
at ruleErrorHandler (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:1173:33)
at /home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/source-code-visitor.js:76:46
at Array.forEach ()
at SourceCodeVisitor.callSync (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/source-code-visitor.js:76:30)
at /home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/source-code-traverser.js:291:18
at Array.forEach ()
at SourceCodeTraverser.traverseSync (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/source-code-traverser.js:290:10)
at runRules (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:1214:12)
at #flatVerifyWithoutProcessors (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:2101:4)
at Linter._verifyWithFlatConfigArrayAndWithoutProcessors (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:2189:43)
at Linter._verifyWithFlatConfigArray (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:2292:15)
at Linter.verify (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:1677:10)
at Linter.verifyAndFix (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/linter/linter.js:2557:20)
at verifyText (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/eslint/eslint-helpers.js:1179:45)
at readAndVerifyFile (/home/jailuser/git/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/eslint/eslint-helpers.js:1320:10)

(import-x/no-relative-packages)


[error] 1-1: Unable to resolve path to module '@vueuse/core'.

(import-x/no-unresolved)


[error] 2-2: Unable to resolve path to module 'vue'.

(import-x/no-unresolved)


[error] 5-5: Unable to resolve path to module '@/scripts/app'.

(import-x/no-unresolved)


[error] 6-6: Unable to resolve path to module '@/stores/imagePreviewStore'.

(import-x/no-unresolved)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: lint-and-format
  • GitHub Check: test
  • GitHub Check: collect
  • GitHub Check: setup
🔇 Additional comments (1)
src/composables/useImageCrop.ts (1)

327-453: Drag and resize implementation is already performant.

The drag and resize handlers correctly optimize widget updates by:

  • Updating local reactive state (cropX, cropY, cropWidth, cropHeight) during pointer move events
  • Only calling setWidgetValue once at the end of the drag/resize operation

This approach provides smooth visual feedback without triggering excessive widget callbacks, which is the optimal pattern for interactive operations.

Note: A past review comment suggested adding debouncing/throttling, but that optimization is unnecessary here since widget updates already occur only at operation completion.

Comment on lines +142 to +174
const updateDisplayedDimensions = () => {
if (!imageEl.value || !containerEl.value) return

const img = imageEl.value
const container = containerEl.value

naturalWidth.value = img.naturalWidth
naturalHeight.value = img.naturalHeight

const containerWidth = container.clientWidth
const containerHeight = container.clientHeight

const imageAspect = naturalWidth.value / naturalHeight.value
const containerAspect = containerWidth / containerHeight

if (imageAspect > containerAspect) {
displayedWidth.value = containerWidth
displayedHeight.value = containerWidth / imageAspect
imageOffsetX.value = 0
imageOffsetY.value = (containerHeight - displayedHeight.value) / 2
} else {
displayedHeight.value = containerHeight
displayedWidth.value = containerHeight * imageAspect
imageOffsetX.value = (containerWidth - displayedWidth.value) / 2
imageOffsetY.value = 0
}

if (naturalWidth.value <= 0 || displayedWidth.value <= 0) {
scaleFactor.value = 1
} else {
scaleFactor.value = displayedWidth.value / naturalWidth.value
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Guard against zero naturalHeight to prevent Infinity in aspect ratio calculation.

Line 154 divides by naturalHeight.value without checking if it's zero. While rare, corrupt or incompletely loaded images could cause this, resulting in imageAspect = Infinity and broken layout calculations.

Add a guard at the start of the function:

 const updateDisplayedDimensions = () => {
   if (!imageEl.value || !containerEl.value) return
 
   const img = imageEl.value
   const container = containerEl.value
 
   naturalWidth.value = img.naturalWidth
   naturalHeight.value = img.naturalHeight
+
+  if (naturalWidth.value <= 0 || naturalHeight.value <= 0) {
+    scaleFactor.value = 1
+    return
+  }
 
   const containerWidth = container.clientWidth
   const containerHeight = container.clientHeight
 
   const imageAspect = naturalWidth.value / naturalHeight.value
🤖 Prompt for AI Agents
In src/composables/useImageCrop.ts around lines 142 to 174, the code computes
imageAspect by dividing naturalWidth.value by naturalHeight.value without
guarding against naturalHeight being zero; add a guard at the top of
updateDisplayedDimensions to detect if naturalHeight.value is null/undefined/0
(or img.naturalHeight is falsy) and in that case set sensible defaults (e.g.,
displayedWidth=containerWidth, displayedHeight=containerHeight, imageOffsetX=0,
imageOffsetY=0, scaleFactor=1) or early-return after setting those defaults so
no division by zero occurs; also ensure later scaleFactor computation similarly
checks naturalWidth and displayedWidth before dividing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants