-
Notifications
You must be signed in to change notification settings - Fork 461
Fix "Markdown" and "Text Preview" widgets mouse events #7907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughAdds canvas interaction event bindings to TextPreviewWidget and implements nuanced wheel event routing in the Markdown widget to distinguish pinch-zoom, trackpad gestures, horizontal scroll, and vertical scroll, conditionally routing events to the canvas or allowing local scrolling based on editor state and settings. Changes
Sequence Diagram(s)sequenceDiagram
participant Widget as Markdown Widget
participant Settings as SettingStore
participant Editor as Editor / textarea
participant Canvas as CanvasInteractions
Widget->>Settings: read trackpad detection setting
Widget->>Editor: get inputEl and editing/scroll state
Note over Widget,Editor: wheel event occurs on inputEl
Widget->>Widget: detect Ctrl (pinch-zoom) or trackpad gesture via deltas
alt Pinch-zoom (Ctrl) or Trackpad gesture detected
Widget->>Canvas: forward wheel event to canvas.handleWheel
else Horizontal wheel
Widget->>Canvas: forward horizontal wheel to canvas.handleWheel
else Vertical wheel & editor scrollable/editing
Widget->>Editor: allow local scrolling
else Vertical wheel & not scrollable/editing
Widget->>Canvas: forward vertical wheel to canvas.handleWheel
end
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
I'm as far from development as a butcher is from surgery :) So I couldn't think of anything better than just copying the code for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In @src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts:
- Around line 99-101: The wheel handler repeatedly calls
useSettingStore().get('LiteGraph.Pointer.TrackpadGestures'), which can be
cached; capture useSettingStore() once (e.g., const settingStore =
useSettingStore()) near addMarkdownWidget/editor initialization and then read
settingStore.get('LiteGraph.Pointer.TrackpadGestures') inside the wheel handler
(or create a reactive/computed gesturesEnabled from settingStore) so the store
lookup isn't performed on every wheel event.
- Around line 98-149: The wheel handler attached in inputEl.addEventListener is
large and should be split: extract shouldPreventPinchZoom(event: WheelEvent),
isLikelyTrackpadGesture(deltaX, deltaY) (using TRACKPAD_DETECTION_THRESHOLD),
and a shouldRouteToCanvas(event, gesturesEnabled, isEditing, canScrollYMarkdown,
canScrollYTextarea) that returns { route, allowDefault }; then replace the
inline logic with calls to these helpers and centralize
event.preventDefault()/event.stopPropagation() and the call to
app.canvas.processMouseWheel(event) based on the helpers' result so the main
handler is declarative and each helper is small and testable.
- Line 16: TRACKPAD_DETECTION_THRESHOLD is a magic number; add a clear comment
above the constant TRACKPAD_DETECTION_THRESHOLD = 50 in useMarkdownWidget.ts
explaining why 50 was chosen (e.g., summary of empirical testing, sample delta
values observed on macOS/Windows/Linux, device types, and the tradeoff between
false positives/negatives) and note the scope of testing or remaining unknowns;
optionally include a TODO to parametrize or make it configurable if platform
variance was observed and reference the constant name in the comment for
clarity.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
src/components/graph/widgets/TextPreviewWidget.vuesrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
🧰 Additional context used
📓 Path-based instructions (16)
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/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tssrc/components/graph/widgets/TextPreviewWidget.vue
src/**/*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/**/*.ts: Use es-toolkit for utility functions
Use TypeScript for type safety
Files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
src/**/{services,composables}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (src/CLAUDE.md)
src/**/{services,composables}/**/*.{ts,tsx}: Useapi.apiURL()for backend endpoints instead of constructing URLs directly
Useapi.fileURL()for static file access instead of constructing URLs directly
Files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.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/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tssrc/components/graph/widgets/TextPreviewWidget.vue
src/**/{composables,components}/**/*.{ts,tsx,vue}
📄 CodeRabbit inference engine (src/CLAUDE.md)
Clean up subscriptions in state management to prevent memory leaks
Files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tssrc/components/graph/widgets/TextPreviewWidget.vue
src/**/*.{vue,ts,tsx}
📄 CodeRabbit inference engine (src/CLAUDE.md)
Follow Vue 3 composition API style guide
Files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tssrc/components/graph/widgets/TextPreviewWidget.vue
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/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tssrc/components/graph/widgets/TextPreviewWidget.vue
**/*.{ts,tsx,vue}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,vue}: Use TypeScript exclusively; do not write new JavaScript code
Use sorted and grouped imports organized by plugin/source
Enforce ESLint rules including Vue + TypeScript rules, disallow floating promises, disallow unused imports, and restrict i18n raw text in templates
Do not useanytype oras anytype assertions; fix the underlying type issue instead
Write code that is expressive and self-documenting; avoid redundant comments and clean as you go
Keep functions short and functional; minimize nesting and follow the arrow anti-pattern
Avoid mutable state; prefer immutability and assignment at point of declaration
Use function declarations instead of function expressions when possible
Use es-toolkit for utility functions
Implement proper error handling in code
Files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tssrc/components/graph/widgets/TextPreviewWidget.vue
**/**/use[A-Z]*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Name composables using the pattern
useXyz.ts
Files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
**/*.{ts,tsx,vue,js,jsx,json,css}
📄 CodeRabbit inference engine (AGENTS.md)
Apply Prettier formatting with 2-space indentation, single quotes, no trailing semicolons, and 80-character line width
Files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tssrc/components/graph/widgets/TextPreviewWidget.vue
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Minimize the surface area (exported values) of each module and composable
Files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
src/**/*.vue
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
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)
Use setup() function for component logic
Utilize ref and reactive for reactive state
Implement computed properties with computed()
Use watch and watchEffect for side effects
Implement lifecycle hooks with onMounted, onUpdated, etc.
Utilize provide/inject for dependency injection
Use vue 3.5 style of default prop declaration
Use Tailwind CSS for styling
Implement proper props and emits definitions
Utilize Vue 3's Teleport component when needed
Use Suspense for async components
Follow Vue 3 style guide and naming conventions
Files:
src/components/graph/widgets/TextPreviewWidget.vue
src/components/**/*.vue
📄 CodeRabbit inference engine (src/components/CLAUDE.md)
src/components/**/*.vue: Use setup() function in Vue 3 Composition API
Destructure props using Vue 3.5 style in Vue components
Use ref/reactive for state management in Vue 3 Composition API
Implement computed() for derived state in Vue 3 Composition API
Use provide/inject for dependency injection in Vue components
Prefer emit/@event-name for state changes over other communication patterns
Use defineExpose only for imperative operations (such as form.validate(), modal.open())
Replace PrimeVue Dropdown component with Select
Replace PrimeVue OverlayPanel component with Popover
Replace PrimeVue Calendar component with DatePicker
Replace PrimeVue InputSwitch component with ToggleSwitch
Replace PrimeVue Sidebar component with Drawer
Replace PrimeVue Chips component with AutoComplete with multiple enabled
Replace PrimeVue TabMenu component with Tabs without panels
Replace PrimeVue Steps component with Stepper without panels
Replace PrimeVue InlineMessage component with Message
Extract complex conditionals to computed properties
Implement cleanup for async operations in Vue components
Use lifecycle hooks: onMounted, onUpdated in Vue 3 Composition API
Use Teleport/Suspense when needed for component rendering
Define proper props and emits definitions in Vue components
Files:
src/components/graph/widgets/TextPreviewWidget.vue
src/components/**/*.{vue,css}
📄 CodeRabbit inference engine (src/components/CLAUDE.md)
src/components/**/*.{vue,css}: Use Tailwind CSS only for styling (no custom CSS)
Use the correct tokens from style.css in the design system package
Files:
src/components/graph/widgets/TextPreviewWidget.vue
src/components/**/*.{vue,ts,js}
📄 CodeRabbit inference engine (src/components/CLAUDE.md)
src/components/**/*.{vue,ts,js}: Use existing VueUse composables (such as useElementHover) instead of manually managing event listeners
Use useIntersectionObserver for visibility detection instead of custom scroll handlers
Use vue-i18n for ALL UI strings
Files:
src/components/graph/widgets/TextPreviewWidget.vue
**/*.vue
📄 CodeRabbit inference engine (AGENTS.md)
**/*.vue: Use Vue 3.5+ with TypeScript in.vuefiles, exclusively using Composition API with<script setup lang="ts">syntax
Use Tailwind 4 for styling in Vue components; avoid<style>blocks
Name Vue components using PascalCase (e.g.,MenuHamburger.vue)
Use Vue 3.5 TypeScript-style default prop declaration with reactive props destructuring; do not usewithDefaultsor runtime props declaration
Prefercomputed()overrefwithwatchwhen deriving values
PreferuseModelover separately defining prop and emit for two-way binding
Usevue-i18nin composition API for string literals; place new translation entries insrc/locales/en/main.json
Usecn()utility function from@/utils/tailwindUtilfor merging Tailwind class names; do not use:class="[]"syntax
Do not use thedark:Tailwind variant; use semantic values from thestyle.csstheme instead (e.g.,bg-node-component-surface)
Do not use!importantor the!important prefix for Tailwind classes; find and correct interfering!importantclasses instead
Avoid new usage of PrimeVue components; use VueUse, shadcn/vue, or Reka UI instead
Leverage VueUse functions for performance-enhancing styles in Vue components
Implement proper props and emits definitions in Vue components
Utilize Vue 3's Teleport component when needed
Use Suspense for async components
Follow Vue 3 style guide and naming conventions
Files:
src/components/graph/widgets/TextPreviewWidget.vue
🧠 Learnings (27)
📓 Common learnings
Learnt from: simula-r
Repo: Comfy-Org/ComfyUI_frontend PR: 7252
File: src/renderer/extensions/vueNodes/components/ImagePreview.vue:151-158
Timestamp: 2025-12-11T03:55:57.926Z
Learning: In src/renderer/extensions/vueNodes/components/ImagePreview.vue and LGraphNode.vue, keyboard navigation for image galleries should respond to node-level focus (via keyEvent injection from LGraphNode), not require focus within the image preview wrapper itself. This allows users to navigate the gallery with arrow keys immediately when the node is focused/selected.
📚 Learning: 2025-12-09T03:39:54.501Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7169
File: src/platform/remote/comfyui/jobs/jobTypes.ts:1-107
Timestamp: 2025-12-09T03:39:54.501Z
Learning: In the ComfyUI_frontend project, Zod is on v3.x. Do not suggest Zod v4 standalone validators (z.uuid, z.ulid, z.cuid2, z.nanoid) until an upgrade to Zod 4 is performed. When reviewing TypeScript files (e.g., src/platform/remote/comfyui/jobs/jobTypes.ts) validate against Zod 3 capabilities and avoid introducing v4-specific features; flag any proposal to upgrade or incorporate v4-only validators and propose staying with compatible 3.x patterns.
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-12-13T11:03:11.264Z
Learnt from: christian-byrne
Repo: Comfy-Org/ComfyUI_frontend PR: 7416
File: src/stores/imagePreviewStore.ts:5-7
Timestamp: 2025-12-13T11:03:11.264Z
Learning: In the ComfyUI_frontend repository, lint rules require keeping 'import type' statements separate from non-type imports, even if importing from the same module. Do not suggest consolidating them into a single import statement. Ensure type imports remain on their own line (import type { ... } from 'module') and regular imports stay on separate lines.
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-12-17T00:40:09.635Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7537
File: src/components/ui/button/Button.stories.ts:45-55
Timestamp: 2025-12-17T00:40:09.635Z
Learning: Prefer pure function declarations over function expressions (e.g., use function foo() { ... } instead of const foo = () => { ... }) for pure functions in the repository. Function declarations are more functional-leaning, offer better hoisting clarity, and can improve readability and tooling consistency. Apply this guideline across TypeScript files in Comfy-Org/ComfyUI_frontend, including story and UI component code, except where a function expression is semantically required (e.g., callbacks, higher-order functions with closures).
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-12-30T22:22:33.836Z
Learnt from: kaili-yang
Repo: Comfy-Org/ComfyUI_frontend PR: 7805
File: src/composables/useCoreCommands.ts:439-439
Timestamp: 2025-12-30T22:22:33.836Z
Learning: When accessing reactive properties from Pinia stores in TypeScript files, avoid using .value on direct property access (e.g., useStore().isOverlayExpanded). Pinia auto-wraps refs when accessed directly, returning the primitive value. The .value accessor is only needed when destructuring store properties or when using storeToRefs().
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-12-11T12:25:15.470Z
Learnt from: christian-byrne
Repo: Comfy-Org/ComfyUI_frontend PR: 7358
File: src/components/dialog/content/signin/SignUpForm.vue:45-54
Timestamp: 2025-12-11T12:25:15.470Z
Learning: This repository uses CI automation to format code (pnpm format). Do not include manual formatting suggestions in code reviews for Comfy-Org/ComfyUI_frontend. If formatting issues are detected, rely on the CI formatter or re-run pnpm format. Focus reviews on correctness, readability, performance, accessibility, and maintainability rather than style formatting.
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tssrc/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-11T03:55:57.926Z
Learnt from: simula-r
Repo: Comfy-Org/ComfyUI_frontend PR: 7252
File: src/renderer/extensions/vueNodes/components/ImagePreview.vue:151-158
Timestamp: 2025-12-11T03:55:57.926Z
Learning: In src/renderer/extensions/vueNodes/components/ImagePreview.vue and LGraphNode.vue, keyboard navigation for image galleries should respond to node-level focus (via keyEvent injection from LGraphNode), not require focus within the image preview wrapper itself. This allows users to navigate the gallery with arrow keys immediately when the node is focused/selected.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-18T20:39:30.137Z
Learnt from: jtydhr88
Repo: Comfy-Org/ComfyUI_frontend PR: 7621
File: src/components/load3d/Load3DScene.vue:4-4
Timestamp: 2025-12-18T20:39:30.137Z
Learning: In src/components/load3d/Load3DScene.vue, the scoped `<style>` block with `!important` declarations for the canvas element is necessary because Three.js dynamically creates the canvas with inline styles, preventing direct application of Tailwind classes. This is a valid exception to the Tailwind-only styling guideline.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vue
📚 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 lifecycle hooks: onMounted, onUpdated in Vue 3 Composition API
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-04T21:43:49.363Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7137
File: src/components/rightSidePanel/parameters/TabParameters.vue:10-0
Timestamp: 2025-12-04T21:43:49.363Z
Learning: Vue 3.5+ supports reactive props destructure in <script setup>. Destructuring props directly (e.g., `const { nodes } = defineProps<{ nodes: LGraphNode[] }>()`) maintains reactivity through compiler transformation. This is the recommended modern approach and does not require using `props.x` or `toRef`/`toRefs`.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-21T06:04:12.562Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-21T06:04:12.562Z
Learning: Applies to **/*.vue : Prefer `computed()` over `ref` with `watch` when deriving values
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-21T06:04:12.562Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-21T06:04:12.562Z
Learning: Applies to **/*.vue : Leverage VueUse functions for performance-enhancing styles in Vue components
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-09T03:49:52.828Z
Learnt from: christian-byrne
Repo: Comfy-Org/ComfyUI_frontend PR: 6300
File: src/platform/updates/components/WhatsNewPopup.vue:5-13
Timestamp: 2025-12-09T03:49:52.828Z
Learning: In Vue files across the ComfyUI_frontend repo, when a button is needed, prefer the repo's common button components from src/components/button/ (IconButton.vue, TextButton.vue, IconTextButton.vue) over plain HTML <button> elements. These components wrap PrimeVue with the project’s design system styling. Use only the common button components for consistency and theming, and import them from src/components/button/ as needed.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-09T21:40:12.361Z
Learnt from: benceruleanlu
Repo: Comfy-Org/ComfyUI_frontend PR: 7297
File: src/components/actionbar/ComfyActionbar.vue:33-43
Timestamp: 2025-12-09T21:40:12.361Z
Learning: In Vue single-file components, allow inline Tailwind CSS class strings for static classes and avoid extracting them into computed properties solely for readability. Prefer keeping static class names inline for simplicity and performance. For dynamic or conditional classes, use Vue bindings (e.g., :class) to compose classes.
Applies to all Vue files in the repository (e.g., src/**/*.vue) where Tailwind utilities are used for static styling.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-16T22:26:49.463Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7537
File: src/components/ui/button/Button.vue:17-17
Timestamp: 2025-12-16T22:26:49.463Z
Learning: In Vue 3.5+ with <script setup>, when using defineProps<Props>() with partial destructuring (e.g., const { as = 'button', class: customClass = '' } = defineProps<Props>() ), props that are not destructured (e.g., variant, size) stay accessible by name in the template scope. This pattern is valid: you can destructure only a subset of props for convenience while referencing the remaining props directly in template expressions. Apply this guideline to Vue components across the codebase (all .vue files).
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-22T21:36:08.369Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7649
File: src/platform/cloud/subscription/components/PricingTable.vue:185-201
Timestamp: 2025-12-22T21:36:08.369Z
Learning: In Vue components, avoid creating single-use variants for common UI components (e.g., Button and other shared components). Aim for reusable variants that cover multiple use cases. It’s acceptable to temporarily mix variant props with inline Tailwind classes when a styling need is unique to one place, but plan and consolidate into shared, reusable variants as patterns emerge across the codebase.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2026-01-08T02:26:18.357Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7893
File: src/components/button/IconGroup.vue:5-6
Timestamp: 2026-01-08T02:26:18.357Z
Learning: In components that use the cn utility from '@/utils/tailwindUtil' with tailwind-merge, rely on the behavior that conflicting Tailwind classes are resolved by keeping the last one. For example, cn('base-classes bg-default', propClass) will have any conflicting background class from propClass override bg-default. This additive pattern is intentional and aligns with the shadcn-ui convention; ensure you document or review expectations accordingly in Vue components.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-18T02:07:38.870Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7598
File: src/components/sidebar/tabs/AssetsSidebarTab.vue:131-131
Timestamp: 2025-12-18T02:07:38.870Z
Learning: Tailwind CSS v4 safe utilities (e.g., items-center-safe, justify-*-safe, place-*-safe) are allowed in Vue components under src/ and in story files. Do not flag these specific safe variants as invalid when reviewing code in src/**/*.vue or related stories.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-18T21:15:46.862Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7603
File: src/components/queue/QueueOverlayHeader.vue:49-59
Timestamp: 2025-12-18T21:15:46.862Z
Learning: In the ComfyUI_frontend repository, for Vue components, do not add aria-label to buttons that have visible text content (e.g., buttons containing <span> text). The visible text provides the accessible name. Use aria-label only for elements without visible labels (e.g., icon-only buttons). If a button has no visible label, provide a clear aria-label or associate with an aria-labelledby describing its action.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-21T01:06:02.786Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7649
File: src/components/graph/selectionToolbox/ColorPickerButton.vue:15-18
Timestamp: 2025-12-21T01:06:02.786Z
Learning: In Comfy-Org/ComfyUI_frontend, in Vue component files, when a filled icon is required (e.g., 'pi pi-circle-fill'), you may mix PrimeIcons with Lucide icons since Lucide lacks filled variants. This mixed usage is acceptable when one icon library does not provide an equivalent filled icon. Apply consistently across Vue components in the src directory where icons are used, and document the rationale when a mixed approach is chosen.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-18T16:03:02.066Z
Learnt from: henrikvilhelmberglund
Repo: Comfy-Org/ComfyUI_frontend PR: 7617
File: src/components/actionbar/ComfyActionbar.vue:301-308
Timestamp: 2025-12-18T16:03:02.066Z
Learning: In the ComfyUI frontend queue system, useQueuePendingTaskCountStore().count indicates the number of tasks in the queue, where count = 1 means a single active/running task and count > 1 means there are pending tasks in addition to the active task. Therefore, in src/components/actionbar/ComfyActionbar.vue, enable the 'Clear Pending Tasks' button only when count > 1 to avoid clearing the currently running task. The active task should be canceled using the 'Cancel current run' button instead. This rule should be enforced via a conditional check on the queue count, with appropriate disabled/aria-disabled states for accessibility, and tests should verify behavior for count = 1 and count > 1.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
🧬 Code graph analysis (1)
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts (1)
src/scripts/app.ts (1)
app(1772-1772)
🔇 Additional comments (2)
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts (1)
46-46: No changes needed.TipTap's type definitions (version ^2.10.4) properly type
EditorView.domasHTMLElement, notElementorNode. The explicit type annotation on line 46 is correct and consistent with TipTap's documented API usage pattern.Likely an incorrect or invalid review comment.
src/components/graph/widgets/TextPreviewWidget.vue (1)
4-5: No action needed — the@pointerdownhandler does not interfere with link clicks.The
handlePointerimplementation only intercepts and prevents default behavior for:
- Middle mouse button clicks (button === 1)
- Space + left-drag panning (canvas.read_only && event.buttons === 1)
- Middle mouse panning (event.buttons === 4)
Regular left-click pointer events don't match any of these conditions, so the handler returns without calling
preventDefault()orstopPropagation(), allowing browser default link behavior to proceed normally.Likely an incorrect or invalid review comment.
| inputEl.addEventListener('wheel', (event: WheelEvent) => { | ||
| const gesturesEnabled = useSettingStore().get( | ||
| 'LiteGraph.Pointer.TrackpadGestures' | ||
| ) | ||
| const deltaX = event.deltaX | ||
| const deltaY = event.deltaY | ||
|
|
||
| const canScrollYMarkdown = editorDom.scrollHeight > editorDom.clientHeight | ||
| const canScrollYTextarea = textarea.scrollHeight > textarea.clientHeight | ||
| const isHorizontal = Math.abs(deltaX) > Math.abs(deltaY) | ||
|
|
||
| // Prevent pinch zoom from zooming the page | ||
| if (event.ctrlKey) { | ||
| event.preventDefault() | ||
| event.stopPropagation() | ||
| app.canvas.processMouseWheel(event) | ||
| return | ||
| } | ||
|
|
||
| // Detect if this is likely a trackpad gesture vs mouse wheel | ||
| // Trackpads usually have deltaX or smaller deltaY values (< TRACKPAD_DETECTION_THRESHOLD) | ||
| // Mouse wheels typically have larger discrete deltaY values (>= TRACKPAD_DETECTION_THRESHOLD) | ||
| const isLikelyTrackpad = | ||
| Math.abs(deltaX) > 0 || Math.abs(deltaY) < TRACKPAD_DETECTION_THRESHOLD | ||
|
|
||
| // Trackpad gestures: when enabled, trackpad panning goes to canvas | ||
| if (gesturesEnabled && isLikelyTrackpad) { | ||
| event.preventDefault() | ||
| event.stopPropagation() | ||
| app.canvas.processMouseWheel(event) | ||
| return | ||
| } | ||
|
|
||
| // When gestures disabled: horizontal always goes to canvas (no horizontal scroll in textarea) | ||
| if (isHorizontal) { | ||
| event.preventDefault() | ||
| event.stopPropagation() | ||
| app.canvas.processMouseWheel(event) | ||
| return | ||
| } | ||
|
|
||
| // Vertical scrolling when gestures disabled: let textarea scroll if scrollable | ||
| const isEditing = inputEl.classList.contains('editing') | ||
| if (isEditing ? canScrollYTextarea : canScrollYMarkdown) { | ||
| event.stopPropagation() | ||
| return | ||
| } | ||
|
|
||
| // If textarea can't scroll vertically, pass to canvas | ||
| event.preventDefault() | ||
| app.canvas.processMouseWheel(event) | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Consider refactoring the wheel handler for better maintainability.
The wheel event handler implements sophisticated logic that handles pinch-zoom, trackpad detection, horizontal/vertical scrolling, and canvas delegation. While the logic appears correct, the 50-line handler with multiple conditional branches could benefit from extraction into smaller, testable helper functions.
Consider extracting decision logic into focused helper functions:
♻️ Suggested refactoring approach
// Helper functions for wheel event routing decisions
function shouldPreventPinchZoom(event: WheelEvent): boolean {
return event.ctrlKey
}
function isLikelyTrackpadGesture(deltaX: number, deltaY: number): boolean {
return Math.abs(deltaX) > 0 || Math.abs(deltaY) < TRACKPAD_DETECTION_THRESHOLD
}
function shouldRouteToCanvas(
event: WheelEvent,
gesturesEnabled: boolean,
isEditing: boolean,
canScrollYMarkdown: boolean,
canScrollYTextarea: boolean
): { route: boolean; allowDefault: boolean } {
const { deltaX, deltaY } = event
const isHorizontal = Math.abs(deltaX) > Math.abs(deltaY)
const isLikelyTrackpad = isLikelyTrackpadGesture(deltaX, deltaY)
// Pinch zoom always goes to canvas
if (event.ctrlKey) {
return { route: true, allowDefault: false }
}
// Trackpad gestures when enabled
if (gesturesEnabled && isLikelyTrackpad) {
return { route: true, allowDefault: false }
}
// Horizontal scrolling
if (isHorizontal) {
return { route: true, allowDefault: false }
}
// Vertical: allow local scroll if possible
const canScroll = isEditing ? canScrollYTextarea : canScrollYMarkdown
if (canScroll) {
return { route: false, allowDefault: true }
}
// Default: route to canvas
return { route: true, allowDefault: false }
}
// Then in the event handler:
inputEl.addEventListener('wheel', (event: WheelEvent) => {
const gesturesEnabled = useSettingStore().get('LiteGraph.Pointer.TrackpadGestures')
const canScrollYMarkdown = editorDom.scrollHeight > editorDom.clientHeight
const canScrollYTextarea = textarea.scrollHeight > textarea.clientHeight
const isEditing = inputEl.classList.contains('editing')
const { route, allowDefault } = shouldRouteToCanvas(
event,
gesturesEnabled,
isEditing,
canScrollYMarkdown,
canScrollYTextarea
)
if (!allowDefault) {
event.preventDefault()
}
event.stopPropagation()
if (route) {
app.canvas.processMouseWheel(event)
}
})Benefits:
- Each helper function is testable in isolation
- The main event handler reads more declaratively
- Edge cases are easier to identify and fix
- Reduced cognitive complexity
🤖 Prompt for AI Agents
In @src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
around lines 98 - 149, The wheel handler attached in inputEl.addEventListener is
large and should be split: extract shouldPreventPinchZoom(event: WheelEvent),
isLikelyTrackpadGesture(deltaX, deltaY) (using TRACKPAD_DETECTION_THRESHOLD),
and a shouldRouteToCanvas(event, gesturesEnabled, isEditing, canScrollYMarkdown,
canScrollYTextarea) that returns { route, allowDefault }; then replace the
inline logic with calls to these helpers and centralize
event.preventDefault()/event.stopPropagation() and the call to
app.canvas.processMouseWheel(event) based on the helpers' result so the main
handler is declarative and each helper is small and testable.
| const gesturesEnabled = useSettingStore().get( | ||
| 'LiteGraph.Pointer.TrackpadGestures' | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Minor: Consider caching the gestures setting.
The useSettingStore().get('LiteGraph.Pointer.TrackpadGestures') call executes on every wheel event. While likely negligible, you could cache this value reactively if wheel events occur frequently during interactions.
⚡ Optional performance optimization
// At the top of addMarkdownWidget, after editor initialization:
const settingStore = useSettingStore()
// ... later in the wheel handler:
const gesturesEnabled = settingStore.get('LiteGraph.Pointer.TrackpadGestures')Or use a reactive computed value if this composable becomes reactive in the future.
🤖 Prompt for AI Agents
In @src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
around lines 99 - 101, The wheel handler repeatedly calls
useSettingStore().get('LiteGraph.Pointer.TrackpadGestures'), which can be
cached; capture useSettingStore() once (e.g., const settingStore =
useSettingStore()) near addMarkdownWidget/editor initialization and then read
settingStore.get('LiteGraph.Pointer.TrackpadGestures') inside the wheel handler
(or create a reactive/computed gesturesEnabled from settingStore) so the store
lookup isn't performed on every wheel event.
✅ Confirmed as addressed by @Myestery
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will go with code rabbit here, lets cache this value once cos its a bit expensive to call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Myestery Great call! Here's how to implement the caching:
function addMarkdownWidget(
node: LGraphNode,
name: string,
opts: { defaultVal: string }
) {
TiptapMarkdown.configure({
html: false,
breaks: true,
transformPastedText: true
})
const editor = new TiptapEditor({
extensions: [
TiptapStarterKit,
TiptapMarkdown,
TiptapLink,
TiptapTable,
TiptapTableCell,
TiptapTableHeader,
TiptapTableRow
],
content: opts.defaultVal,
editable: false
})
// Cache the settingStore once
const settingStore = useSettingStore()
const inputEl = editor.options.element as HTMLElement
inputEl.classList.add('comfy-markdown')
const textarea = document.createElement('textarea')
inputEl.append(textarea)
const editorDom: HTMLElement = editor.view.dom
// ... rest of the function
inputEl.addEventListener('wheel', (event: WheelEvent) => {
// Use the cached settingStore
const gesturesEnabled = settingStore.get(
'LiteGraph.Pointer.TrackpadGestures'
)
// ... rest of the wheel handler
})
}This will avoid the store lookup overhead on every wheel event, which can fire very frequently during scrolling.
🧠 Learnings used
Learnt from: simula-r
Repo: Comfy-Org/ComfyUI_frontend PR: 7252
File: src/renderer/extensions/vueNodes/components/ImagePreview.vue:151-158
Timestamp: 2025-12-11T03:55:57.926Z
Learning: In src/renderer/extensions/vueNodes/components/ImagePreview.vue and LGraphNode.vue, keyboard navigation for image galleries should respond to node-level focus (via keyEvent injection from LGraphNode), not require focus within the image preview wrapper itself. This allows users to navigate the gallery with arrow keys immediately when the node is focused/selected.
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
|
Let's cache the settings call and this will be good to go. |
88a255b to
b7c638d
Compare
|
@Myestery Since the 'wheel' event handler code is identical for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In @src/components/graph/widgets/TextPreviewWidget.vue:
- Around line 2-6: The preview div's wheel events are being unconditionally
forwarded to the canvas via canvasInteractions.handleWheel in legacy navigation
mode, which prevents vertical scrolling of long previews; to fix this either add
the opt-out attribute data-capture-wheel="true" to the TextPreviewWidget's root
div so the canvas handler will not capture wheel events for this element, or
modify the canvasInteractions.handleWheel implementation to detect and ignore
wheel events coming from elements inside TextPreviewWidget (e.g., by checking
event.target or walking up DOM for an element with a specific class or
attribute) so the div's native overflow-y-auto scrolling still works.
In @src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts:
- Around line 42-44: Register the wheel event listeners with explicit options {
passive: false } and ensure every canvas-routing branch calls
event.stopPropagation() just like the other branches to prevent double-handling;
find the addEventListener('wheel', ...) usages in useMarkdownWidget.ts
(including the occurrences around the commented locations ~101-105 and ~151-153)
and change the third parameter to { passive: false }, and in the last
canvas-routing branch add event.stopPropagation() alongside the existing
preventDefault() so all branches handle propagation consistently.
- Around line 16-17: The wheel handler currently stops propagation whenever the
area is scrollable, and the TRACKPAD_DETECTION_THRESHOLD uses raw delta values;
update the wheel handling logic (the onWheel / wheel event handler that
references isEditing, canScrollYTextarea, canScrollYMarkdown and calls
event.stopPropagation()) to first normalize event.deltaX / deltaY by
event.deltaMode (use 1 for lines, 16 for DOM_DELTA_PIXEL fallback) and then only
stop propagation when the scrollable element can actually scroll further in the
wheel direction (i.e., check current scrollTop/scrollHeight/clientHeight for
vertical boundaries and only call event.stopPropagation() if not at the top when
scrolling up or not at the bottom when scrolling down); also adjust
TRACKPAD_DETECTION_THRESHOLD to operate on normalized deltas and apply the same
fixed logic in the other occurrence around lines 101-153 so both handlers are
boundary-aware and deltaMode-normalized.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
src/components/graph/widgets/TextPreviewWidget.vuesrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
🧰 Additional context used
📓 Path-based instructions (12)
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.jsonLeverage VueUse functions for performance-enhancing utilities
Files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tssrc/components/graph/widgets/TextPreviewWidget.vue
src/**/*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/**/*.ts: Use es-toolkit for utility functions
Use TypeScript for type safety
src/**/*.ts: Minimize the surface area (exported values) of each module and composable
Use es-toolkit for utility functions
Files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
src/**/{services,composables}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (src/CLAUDE.md)
src/**/{services,composables}/**/*.{ts,tsx}: Useapi.apiURL()for backend endpoints instead of constructing URLs directly
Useapi.fileURL()for static file access instead of constructing URLs directly
Files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.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
src/**/*.{ts,tsx,vue}: Use separateimport typestatements; do not mix inlinetypeimports in the same statement
Sort and group imports by plugin; runpnpm formatbefore committing
Derive component types usingvue-component-type-helpers(ComponentProps,ComponentSlots) instead of separate type files
Code should be well-designed with clear names for everything; write code that is expressive and self-documenting
Avoid redundant comments and clean up code as you go; comments should explain why, not what
Ask if there is a simpler way to implement functionality; refactor complex code to simplify it
Minimize nesting depth (e.g.,if () { ... }orfor () { ... }); watch for arrow anti-pattern
Watch out for code smells and refactor to avoid them
Never useanytype; use proper TypeScript types
Never useas anytype assertions; fix the underlying type issue instead
Indent with 2 spaces; use single quotes; no trailing semicolons; max line width 80 (per .prettierrc)
Complex type definitions used in multiple related places should be extracted and named for reuse
Implement proper error handling
Files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tssrc/components/graph/widgets/TextPreviewWidget.vue
src/**/{composables,components}/**/*.{ts,tsx,vue}
📄 CodeRabbit inference engine (src/CLAUDE.md)
Clean up subscriptions in state management to prevent memory leaks
Files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tssrc/components/graph/widgets/TextPreviewWidget.vue
src/**/*.{vue,ts,tsx}
📄 CodeRabbit inference engine (src/CLAUDE.md)
Follow Vue 3 composition API style guide
Files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tssrc/components/graph/widgets/TextPreviewWidget.vue
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/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tssrc/components/graph/widgets/TextPreviewWidget.vue
src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.{ts,tsx}: Keep functions short and functional; use function declarations instead of function expressions when possible
Avoid mutable state; prefer immutability and assignment at point of declaration
Favor pure functions, especially testable ones
Files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
src/**/*.vue
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
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)
Use setup() function for component logic
Utilize ref and reactive for reactive state
Implement computed properties with computed()
Use watch and watchEffect for side effects
Implement lifecycle hooks with onMounted, onUpdated, etc.
Utilize provide/inject for dependency injection
Use vue 3.5 style of default prop declaration
Use Tailwind CSS for styling
Implement proper props and emits definitions
Utilize Vue 3's Teleport component when needed
Use Suspense for async components
Follow Vue 3 style guide and naming conventions
src/**/*.vue: Use Vue 3 Single File Components (SFCs) with Composition API only; never use Options API
Use<script setup lang="ts">syntax for component logic
Use Tailwind 4 utility classes for styling; avoid<style>blocks in Vue components
Do not use thedark:Tailwind variant; use semantic values fromstyle.csstheme instead (e.g.,bg-node-component-surface)
Usecn()utility from@/utils/tailwindUtilfor merging class names; never use:class="[]"syntax
Never use!importantor the!prefix for Tailwind classes; find and fix interfering classes instead
Use Tailwind fraction utilities instead of arbitrary percentages (e.g.,w-4/5instead ofw-[80%],w-1/2instead ofw-[50%])
Use Vue 3.5 TypeScript style default prop declaration with destructuring; avoidwithDefaultsand runtime props
UsedefineModelfor v-model bindings instead of separately defining props and emits
Prefer reactive props destructuring overconst props = defineProps<...>
Define slots via template usage, notdefineSlots
Use same-name shorthand for slot prop bindings (e.g.,:isExpandedinstead of:is-expanded="isExpanded")
Usereffor reactive state,computed()for computed properties, andwatch/watchEffectfor side effects
Avoid usingrefandwatcht...
Files:
src/components/graph/widgets/TextPreviewWidget.vue
src/components/**/*.vue
📄 CodeRabbit inference engine (src/components/CLAUDE.md)
src/components/**/*.vue: Use setup() function in Vue 3 Composition API
Destructure props using Vue 3.5 style in Vue components
Use ref/reactive for state management in Vue 3 Composition API
Implement computed() for derived state in Vue 3 Composition API
Use provide/inject for dependency injection in Vue components
Prefer emit/@event-name for state changes over other communication patterns
Use defineExpose only for imperative operations (such as form.validate(), modal.open())
Replace PrimeVue Dropdown component with Select
Replace PrimeVue OverlayPanel component with Popover
Replace PrimeVue Calendar component with DatePicker
Replace PrimeVue InputSwitch component with ToggleSwitch
Replace PrimeVue Sidebar component with Drawer
Replace PrimeVue Chips component with AutoComplete with multiple enabled
Replace PrimeVue TabMenu component with Tabs without panels
Replace PrimeVue Steps component with Stepper without panels
Replace PrimeVue InlineMessage component with Message
Extract complex conditionals to computed properties
Implement cleanup for async operations in Vue components
Use lifecycle hooks: onMounted, onUpdated in Vue 3 Composition API
Use Teleport/Suspense when needed for component rendering
Define proper props and emits definitions in Vue componentsName Vue components in PascalCase (e.g., MenuHamburger.vue)
Files:
src/components/graph/widgets/TextPreviewWidget.vue
src/components/**/*.{vue,css}
📄 CodeRabbit inference engine (src/components/CLAUDE.md)
src/components/**/*.{vue,css}: Use Tailwind CSS only for styling (no custom CSS)
Use the correct tokens from style.css in the design system package
Files:
src/components/graph/widgets/TextPreviewWidget.vue
src/components/**/*.{vue,ts,js}
📄 CodeRabbit inference engine (src/components/CLAUDE.md)
src/components/**/*.{vue,ts,js}: Use existing VueUse composables (such as useElementHover) instead of manually managing event listeners
Use useIntersectionObserver for visibility detection instead of custom scroll handlers
Use vue-i18n for ALL UI strings
Files:
src/components/graph/widgets/TextPreviewWidget.vue
🧠 Learnings (30)
📚 Learning: 2026-01-09T00:50:57.103Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-09T00:50:57.103Z
Learning: Applies to src/**/*.{ts,tsx,vue} : Ask if there is a simpler way to implement functionality; refactor complex code to simplify it
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2026-01-09T00:50:57.103Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-09T00:50:57.103Z
Learning: Applies to src/**/*.{ts,tsx,vue} : Watch out for code smells and refactor to avoid them
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-12-11T03:55:57.926Z
Learnt from: simula-r
Repo: Comfy-Org/ComfyUI_frontend PR: 7252
File: src/renderer/extensions/vueNodes/components/ImagePreview.vue:151-158
Timestamp: 2025-12-11T03:55:57.926Z
Learning: In src/renderer/extensions/vueNodes/components/ImagePreview.vue and LGraphNode.vue, keyboard navigation for image galleries should respond to node-level focus (via keyEvent injection from LGraphNode), not require focus within the image preview wrapper itself. This allows users to navigate the gallery with arrow keys immediately when the node is focused/selected.
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tssrc/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2026-01-09T00:50:57.103Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-09T00:50:57.103Z
Learning: Applies to src/**/*.{ts,tsx,vue} : Minimize nesting depth (e.g., `if () { ... }` or `for () { ... }`); watch for arrow anti-pattern
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-12-09T03:39:54.501Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7169
File: src/platform/remote/comfyui/jobs/jobTypes.ts:1-107
Timestamp: 2025-12-09T03:39:54.501Z
Learning: In the ComfyUI_frontend project, Zod is on v3.x. Do not suggest Zod v4 standalone validators (z.uuid, z.ulid, z.cuid2, z.nanoid) until an upgrade to Zod 4 is performed. When reviewing TypeScript files (e.g., src/platform/remote/comfyui/jobs/jobTypes.ts) validate against Zod 3 capabilities and avoid introducing v4-specific features; flag any proposal to upgrade or incorporate v4-only validators and propose staying with compatible 3.x patterns.
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-12-13T11:03:11.264Z
Learnt from: christian-byrne
Repo: Comfy-Org/ComfyUI_frontend PR: 7416
File: src/stores/imagePreviewStore.ts:5-7
Timestamp: 2025-12-13T11:03:11.264Z
Learning: In the ComfyUI_frontend repository, lint rules require keeping 'import type' statements separate from non-type imports, even if importing from the same module. Do not suggest consolidating them into a single import statement. Ensure type imports remain on their own line (import type { ... } from 'module') and regular imports stay on separate lines.
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-12-17T00:40:09.635Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7537
File: src/components/ui/button/Button.stories.ts:45-55
Timestamp: 2025-12-17T00:40:09.635Z
Learning: Prefer pure function declarations over function expressions (e.g., use function foo() { ... } instead of const foo = () => { ... }) for pure functions in the repository. Function declarations are more functional-leaning, offer better hoisting clarity, and can improve readability and tooling consistency. Apply this guideline across TypeScript files in Comfy-Org/ComfyUI_frontend, including story and UI component code, except where a function expression is semantically required (e.g., callbacks, higher-order functions with closures).
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-12-30T22:22:33.836Z
Learnt from: kaili-yang
Repo: Comfy-Org/ComfyUI_frontend PR: 7805
File: src/composables/useCoreCommands.ts:439-439
Timestamp: 2025-12-30T22:22:33.836Z
Learning: When accessing reactive properties from Pinia stores in TypeScript files, avoid using .value on direct property access (e.g., useStore().isOverlayExpanded). Pinia auto-wraps refs when accessed directly, returning the primitive value. The .value accessor is only needed when destructuring store properties or when using storeToRefs().
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-12-11T12:25:15.470Z
Learnt from: christian-byrne
Repo: Comfy-Org/ComfyUI_frontend PR: 7358
File: src/components/dialog/content/signin/SignUpForm.vue:45-54
Timestamp: 2025-12-11T12:25:15.470Z
Learning: This repository uses CI automation to format code (pnpm format). Do not include manual formatting suggestions in code reviews for Comfy-Org/ComfyUI_frontend. If formatting issues are detected, rely on the CI formatter or re-run pnpm format. Focus reviews on correctness, readability, performance, accessibility, and maintainability rather than style formatting.
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tssrc/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-18T20:39:30.137Z
Learnt from: jtydhr88
Repo: Comfy-Org/ComfyUI_frontend PR: 7621
File: src/components/load3d/Load3DScene.vue:4-4
Timestamp: 2025-12-18T20:39:30.137Z
Learning: In src/components/load3d/Load3DScene.vue, the scoped `<style>` block with `!important` declarations for the canvas element is necessary because Three.js dynamically creates the canvas with inline styles, preventing direct application of Tailwind classes. This is a valid exception to the Tailwind-only styling guideline.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2026-01-09T00:50:57.103Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-09T00:50:57.103Z
Learning: Applies to src/**/*.vue : Use `ref` for reactive state, `computed()` for computed properties, and `watch`/`watchEffect` for side effects
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2026-01-09T00:50:57.103Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-09T00:50:57.103Z
Learning: Applies to src/**/*.vue : Avoid using `ref` and `watch` together if a `computed` would work instead
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2026-01-09T00:50:57.103Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-09T00:50:57.103Z
Learning: Applies to src/**/*.{vue,ts} : Leverage VueUse functions for performance-enhancing utilities
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vue
📚 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 lifecycle hooks: onMounted, onUpdated in Vue 3 Composition API
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-04T21:43:49.363Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7137
File: src/components/rightSidePanel/parameters/TabParameters.vue:10-0
Timestamp: 2025-12-04T21:43:49.363Z
Learning: Vue 3.5+ supports reactive props destructure in <script setup>. Destructuring props directly (e.g., `const { nodes } = defineProps<{ nodes: LGraphNode[] }>()`) maintains reactivity through compiler transformation. This is the recommended modern approach and does not require using `props.x` or `toRef`/`toRefs`.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2026-01-09T00:50:57.103Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-09T00:50:57.103Z
Learning: Applies to src/**/*.vue : Be judicious with state additions: prefer props, avoid `computed` for simple values, use `computed` instead of `watch` for derived values
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-09T03:49:52.828Z
Learnt from: christian-byrne
Repo: Comfy-Org/ComfyUI_frontend PR: 6300
File: src/platform/updates/components/WhatsNewPopup.vue:5-13
Timestamp: 2025-12-09T03:49:52.828Z
Learning: In Vue files across the ComfyUI_frontend repo, when a button is needed, prefer the repo's common button components from src/components/button/ (IconButton.vue, TextButton.vue, IconTextButton.vue) over plain HTML <button> elements. These components wrap PrimeVue with the project’s design system styling. Use only the common button components for consistency and theming, and import them from src/components/button/ as needed.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-09T21:40:12.361Z
Learnt from: benceruleanlu
Repo: Comfy-Org/ComfyUI_frontend PR: 7297
File: src/components/actionbar/ComfyActionbar.vue:33-43
Timestamp: 2025-12-09T21:40:12.361Z
Learning: In Vue single-file components, allow inline Tailwind CSS class strings for static classes and avoid extracting them into computed properties solely for readability. Prefer keeping static class names inline for simplicity and performance. For dynamic or conditional classes, use Vue bindings (e.g., :class) to compose classes.
Applies to all Vue files in the repository (e.g., src/**/*.vue) where Tailwind utilities are used for static styling.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-16T22:26:49.463Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7537
File: src/components/ui/button/Button.vue:17-17
Timestamp: 2025-12-16T22:26:49.463Z
Learning: In Vue 3.5+ with <script setup>, when using defineProps<Props>() with partial destructuring (e.g., const { as = 'button', class: customClass = '' } = defineProps<Props>() ), props that are not destructured (e.g., variant, size) stay accessible by name in the template scope. This pattern is valid: you can destructure only a subset of props for convenience while referencing the remaining props directly in template expressions. Apply this guideline to Vue components across the codebase (all .vue files).
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-22T21:36:08.369Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7649
File: src/platform/cloud/subscription/components/PricingTable.vue:185-201
Timestamp: 2025-12-22T21:36:08.369Z
Learning: In Vue components, avoid creating single-use variants for common UI components (e.g., Button and other shared components). Aim for reusable variants that cover multiple use cases. It’s acceptable to temporarily mix variant props with inline Tailwind classes when a styling need is unique to one place, but plan and consolidate into shared, reusable variants as patterns emerge across the codebase.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2026-01-08T02:26:18.357Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7893
File: src/components/button/IconGroup.vue:5-6
Timestamp: 2026-01-08T02:26:18.357Z
Learning: In components that use the cn utility from '@/utils/tailwindUtil' with tailwind-merge, rely on the behavior that conflicting Tailwind classes are resolved by keeping the last one. For example, cn('base-classes bg-default', propClass) will have any conflicting background class from propClass override bg-default. This additive pattern is intentional and aligns with the shadcn-ui convention; ensure you document or review expectations accordingly in Vue components.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-18T02:07:38.870Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7598
File: src/components/sidebar/tabs/AssetsSidebarTab.vue:131-131
Timestamp: 2025-12-18T02:07:38.870Z
Learning: Tailwind CSS v4 safe utilities (e.g., items-center-safe, justify-*-safe, place-*-safe) are allowed in Vue components under src/ and in story files. Do not flag these specific safe variants as invalid when reviewing code in src/**/*.vue or related stories.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-18T21:15:46.862Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7603
File: src/components/queue/QueueOverlayHeader.vue:49-59
Timestamp: 2025-12-18T21:15:46.862Z
Learning: In the ComfyUI_frontend repository, for Vue components, do not add aria-label to buttons that have visible text content (e.g., buttons containing <span> text). The visible text provides the accessible name. Use aria-label only for elements without visible labels (e.g., icon-only buttons). If a button has no visible label, provide a clear aria-label or associate with an aria-labelledby describing its action.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-21T01:06:02.786Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7649
File: src/components/graph/selectionToolbox/ColorPickerButton.vue:15-18
Timestamp: 2025-12-21T01:06:02.786Z
Learning: In Comfy-Org/ComfyUI_frontend, in Vue component files, when a filled icon is required (e.g., 'pi pi-circle-fill'), you may mix PrimeIcons with Lucide icons since Lucide lacks filled variants. This mixed usage is acceptable when one icon library does not provide an equivalent filled icon. Apply consistently across Vue components in the src directory where icons are used, and document the rationale when a mixed approach is chosen.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-18T16:03:02.066Z
Learnt from: henrikvilhelmberglund
Repo: Comfy-Org/ComfyUI_frontend PR: 7617
File: src/components/actionbar/ComfyActionbar.vue:301-308
Timestamp: 2025-12-18T16:03:02.066Z
Learning: In the ComfyUI frontend queue system, useQueuePendingTaskCountStore().count indicates the number of tasks in the queue, where count = 1 means a single active/running task and count > 1 means there are pending tasks in addition to the active task. Therefore, in src/components/actionbar/ComfyActionbar.vue, enable the 'Clear Pending Tasks' button only when count > 1 to avoid clearing the currently running task. The active task should be canceled using the 'Cancel current run' button instead. This rule should be enforced via a conditional check on the queue count, with appropriate disabled/aria-disabled states for accessibility, and tests should verify behavior for count = 1 and count > 1.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
| <div | ||
| class="relative max-h-[200px] min-h-[28px] w-full overflow-y-auto rounded-lg px-4 py-2 text-xs" | ||
| @wheel="canvasInteractions.handleWheel" | ||
| @pointerdown="canvasInteractions.handlePointer" | ||
| > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for useCanvasInteractions implementation
fd . --type=f -e ts -e tsx | xargs grep -l "useCanvasInteractions\|export.*useCanvasInteractions" | head -20Repository: Comfy-Org/ComfyUI_frontend
Length of output: 600
🏁 Script executed:
#!/bin/bash
# Find the TextPreviewWidget component file
find . -name "TextPreviewWidget.vue" -type fRepository: Comfy-Org/ComfyUI_frontend
Length of output: 122
🏁 Script executed:
#!/bin/bash
# Explore composables directory structure
fd . --type=f -e ts -path "*/composables/*" | head -30Repository: Comfy-Org/ComfyUI_frontend
Length of output: 238
🏁 Script executed:
#!/bin/bash
# Read the useCanvasInteractions composable
cat -n src/renderer/core/canvas/useCanvasInteractions.tsRepository: Comfy-Org/ComfyUI_frontend
Length of output: 5069
🏁 Script executed:
#!/bin/bash
# Read the TextPreviewWidget component
cat -n src/components/graph/widgets/TextPreviewWidget.vueRepository: Comfy-Org/ComfyUI_frontend
Length of output: 3749
In legacy navigation mode, wheel events are unconditionally forwarded to canvas, blocking local scroll despite overflow-y-auto.
The handleWheel function forwards all wheel events to the canvas in legacy mode (line 50-52), calling preventDefault() unconditionally. Since TextPreviewWidget doesn't use the [data-capture-wheel="true"] opt-out attribute, users cannot scroll long previews in legacy mode. Text selection/copy are unaffected (pointer events allow normal selection unless space+dragging).
Consider either: (1) adding data-capture-wheel="true" to the preview div to preserve scroll in all modes, or (2) adjusting canvas wheel handling to not block preview scrolling.
🤖 Prompt for AI Agents
In @src/components/graph/widgets/TextPreviewWidget.vue around lines 2 - 6, The
preview div's wheel events are being unconditionally forwarded to the canvas via
canvasInteractions.handleWheel in legacy navigation mode, which prevents
vertical scrolling of long previews; to fix this either add the opt-out
attribute data-capture-wheel="true" to the TextPreviewWidget's root div so the
canvas handler will not capture wheel events for this element, or modify the
canvasInteractions.handleWheel implementation to detect and ignore wheel events
coming from elements inside TextPreviewWidget (e.g., by checking event.target or
walking up DOM for an element with a specific class or attribute) so the div's
native overflow-y-auto scrolling still works.
| import { useSettingStore } from '@/platform/settings/settingStore' | ||
| import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# First, locate the files mentioned
find src -name "useMarkdownWidget.ts" -o -name "useStringWidget.ts" | head -20Repository: Comfy-Org/ComfyUI_frontend
Length of output: 215
🏁 Script executed:
#!/bin/bash
# Examine the useMarkdownWidget.ts file
cat -n src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tsRepository: Comfy-Org/ComfyUI_frontend
Length of output: 6248
🏁 Script executed:
#!/bin/bash
# Examine the useStringWidget.ts file
cat -n src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.tsRepository: Comfy-Org/ComfyUI_frontend
Length of output: 5124
🏁 Script executed:
#!/bin/bash
# Search for wheel event handling and the specific setting read
rg -n "LiteGraph\.Pointer\.TrackpadGestures|TRACKPAD_DETECTION_THRESHOLD|isLikelyTrackpad" -A3 -B3 src/renderer/extensions/vueNodes/widgetsRepository: Comfy-Org/ComfyUI_frontend
Length of output: 6259
🏁 Script executed:
#!/bin/bash
# Find all wheel event listeners in the widgets directory
rg -n "addEventListener.*wheel" src/renderer/extensions/vueNodes/widgets -A5 -B2Repository: Comfy-Org/ComfyUI_frontend
Length of output: 1755
Extract shared wheel-event routing logic and cache the trackpad setting in useMarkdownWidget.
The settingStore.get('LiteGraph.Pointer.TrackpadGestures') call at lines 103–105 fires on every wheel event (a hot path), and nearly identical wheel-routing logic exists in both useMarkdownWidget.ts (101–153) and useStringWidget.ts (56–105). Cache the setting value once and subscribe to changes with settingStore.$subscribe(...) to avoid repeated reads. Extract the shared detection and routing logic into a reusable helper to prevent divergence and reduce code duplication. Remember to unsubscribe on widget cleanup.
| const TRACKPAD_DETECTION_THRESHOLD = 50 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix wheel routing at scroll boundaries (currently can still “trap” scroll) and account for deltaMode.
if (isEditing ? canScrollYTextarea : canScrollYMarkdown) { event.stopPropagation(); return } consumes all vertical wheel events whenever the area is scrollable, even when already at the top/bottom—so the canvas still won’t receive wheel in the “can’t scroll further” cases. Also, TRACKPAD_DETECTION_THRESHOLD uses raw deltaX/deltaY without considering event.deltaMode, which can make the heuristic device/browser-dependent.
Proposed fix (boundary-aware + deltaMode normalization)
const TRACKPAD_DETECTION_THRESHOLD = 50
+function canScrollInDirection(
+ el: HTMLElement,
+ deltaY: number
+): boolean {
+ // deltaY > 0 => scroll down, deltaY < 0 => scroll up
+ if (deltaY > 0) {
+ return el.scrollTop + el.clientHeight < el.scrollHeight
+ }
+ if (deltaY < 0) {
+ return el.scrollTop > 0
+ }
+ return false
+}
+
+function normalizeWheelDeltaY(event: WheelEvent): number {
+ // 0: pixels, 1: lines, 2: pages
+ if (event.deltaMode === 1) return event.deltaY * 16
+ if (event.deltaMode === 2) return event.deltaY * window.innerHeight
+ return event.deltaY
+}
+
inputEl.addEventListener('wheel', (event: WheelEvent) => {
// Use the cached settingStore
const gesturesEnabled = settingStore.get(
'LiteGraph.Pointer.TrackpadGestures'
)
const deltaX = event.deltaX
- const deltaY = event.deltaY
+ const deltaY = normalizeWheelDeltaY(event)
const canScrollYMarkdown = editorDom.scrollHeight > editorDom.clientHeight
const canScrollYTextarea = textarea.scrollHeight > textarea.clientHeight
const isHorizontal = Math.abs(deltaX) > Math.abs(deltaY)
@@
const isEditing = inputEl.classList.contains('editing')
- if (isEditing ? canScrollYTextarea : canScrollYMarkdown) {
- event.stopPropagation()
- return
- }
+ const scrollEl = (isEditing ? textarea : editorDom) as unknown as HTMLElement
+ const canScrollY = isEditing ? canScrollYTextarea : canScrollYMarkdown
+ if (canScrollY && canScrollInDirection(scrollEl, deltaY)) {
+ event.stopPropagation()
+ return
+ }
// If textarea can't scroll vertically, pass to canvas
event.preventDefault()
+ event.stopPropagation()
app.canvas.processMouseWheel(event)
})Also applies to: 101-153
🤖 Prompt for AI Agents
In @src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
around lines 16 - 17, The wheel handler currently stops propagation whenever the
area is scrollable, and the TRACKPAD_DETECTION_THRESHOLD uses raw delta values;
update the wheel handling logic (the onWheel / wheel event handler that
references isEditing, canScrollYTextarea, canScrollYMarkdown and calls
event.stopPropagation()) to first normalize event.deltaX / deltaY by
event.deltaMode (use 1 for lines, 16 for DOM_DELTA_PIXEL fallback) and then only
stop propagation when the scrollable element can actually scroll further in the
wheel direction (i.e., check current scrollTop/scrollHeight/clientHeight for
vertical boundaries and only call event.stopPropagation() if not at the top when
scrolling up or not at the bottom when scrolling down); also adjust
TRACKPAD_DETECTION_THRESHOLD to operate on normalized deltas and apply the same
fixed logic in the other occurrence around lines 101-153 so both handlers are
boundary-aware and deltaMode-normalized.
| // Cache the settingStore once | ||
| const settingStore = useSettingStore() | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make wheel listener explicitly non-passive and keep propagation handling consistent.
You call preventDefault() in multiple branches, so it’s safer to register the wheel listener with { passive: false }. Also the last branch currently doesn’t stopPropagation(), unlike the other canvas-routing branches, risking double-handling by other listeners.
Proposed fix (listener options + consistent stopPropagation)
- inputEl.addEventListener('wheel', (event: WheelEvent) => {
+ inputEl.addEventListener('wheel', (event: WheelEvent) => {
...
- event.preventDefault()
- app.canvas.processMouseWheel(event)
- })
+ event.preventDefault()
+ event.stopPropagation()
+ app.canvas.processMouseWheel(event)
+ }, { passive: false })Also applies to: 101-105, 151-153
🤖 Prompt for AI Agents
In @src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
around lines 42 - 44, Register the wheel event listeners with explicit options {
passive: false } and ensure every canvas-routing branch calls
event.stopPropagation() just like the other branches to prevent double-handling;
find the addEventListener('wheel', ...) usages in useMarkdownWidget.ts
(including the occurrences around the commented locations ~101-105 and ~151-153)
and change the third parameter to { passive: false }, and in the last
canvas-routing branch add event.stopPropagation() alongside the existing
preventDefault() so all branches handle propagation consistently.
Or we can open an issue to follow-up. |
Bundle Size ReportSummary
Category Glance Per-category breakdownApp Entry Points — 3.24 MB (baseline 3.25 MB) • 🟢 -5.48 kBMain entry bundles and manifests
Status: 3 added / 3 removed Graph Workspace — 1.05 MB (baseline 1.05 MB) • 🔴 +7 BGraph editor runtime, canvas, workflow orchestration
Status: 1 added / 1 removed Views & Navigation — 6.63 kB (baseline 6.63 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Status: 1 added / 1 removed Panels & Settings — 302 kB (baseline 337 kB) • 🟢 -35.3 kBConfiguration panels, inspectors, and settings screens
Status: 15 added / 15 removed UI Components — 198 kB (baseline 199 kB) • 🟢 -1.46 kBReusable component library chunks
Status: 9 added / 9 removed Data & Services — 12.5 kB (baseline 12.5 kB) • ⚪ 0 BStores, services, APIs, and repositories
Status: 3 added / 3 removed Utilities & Hooks — 1.41 kB (baseline 1.41 kB) • ⚪ 0 BHelpers, composables, and utility bundles
Status: 1 added / 1 removed Vendor & Third-Party — 9.19 MB (baseline 9.19 MB) • ⚪ 0 BExternal libraries and shared vendor chunks
Status: 6 added / 6 removed Other — 3.6 MB (baseline 4.73 MB) • 🟢 -1.13 MBBundles that do not match a named category
Status: 51 added / 51 removed |
Adds wheel and pointerdown event handlers to the TextPreviewWidget to delegate interaction events to the canvas interaction system. This ensures that global canvas zoom and pan functionality works correctly even when the pointer is over the widget, preventing interaction blocking.
I've got the commit ready, so I'll push it here to keep things consistent and save us the extra hassle. |
b7c638d to
428db57
Compare
There was a problem hiding this 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.ts (1)
15-22: Use the cached settingStore consistently.The
settingStoreis cached at line 16 to avoid repeated calls touseSettingStore(), but line 22 still callsuseSettingStore().get('Comfy.TextareaWidget.Spellcheck')instead of using the cached variable. This defeats the purpose of the caching optimization.🔧 Proposed fix
- inputEl.spellcheck = useSettingStore().get('Comfy.TextareaWidget.Spellcheck') + inputEl.spellcheck = settingStore.get('Comfy.TextareaWidget.Spellcheck')
🤖 Fix all issues with AI agents
In @src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts:
- Line 16: TRACKPAD_DETECTION_THRESHOLD is a magic-number heuristic used to
distinguish trackpad gestures from mouse wheel events; add a short comment above
the constant explaining the rationale (e.g., measured delta magnitude
difference, empirical value good for common hardware), note its limitations
across devices, and make it configurable by exposing it as an optional parameter
or prop in useMarkdownWidget (or read from a settings/config source) so users
can override the default if they report issues; reference the constant name
TRACKPAD_DETECTION_THRESHOLD and the composable useMarkdownWidget to locate and
update the code.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
src/components/graph/widgets/TextPreviewWidget.vuesrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.tssrc/renderer/extensions/vueNodes/widgets/composables/useStringWidget.ts
🧰 Additional context used
📓 Path-based instructions (13)
src/**/*.vue
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
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)
Use setup() function for component logic
Utilize ref and reactive for reactive state
Implement computed properties with computed()
Use watch and watchEffect for side effects
Implement lifecycle hooks with onMounted, onUpdated, etc.
Utilize provide/inject for dependency injection
Use vue 3.5 style of default prop declaration
Use Tailwind CSS for styling
Implement proper props and emits definitions
Utilize Vue 3's Teleport component when needed
Use Suspense for async components
Follow Vue 3 style guide and naming conventions
src/**/*.vue: Use Vue 3 Single File Components (SFCs) with Composition API only
Use<script setup lang="ts">for component logic in Vue SFCs
Avoid<style>blocks in Vue components - use Tailwind 4 styling instead
Use vue-i18n for all string literals in Vue components - place translation entries insrc/locales/en/main.json
Use Tailwind utility classes instead ofdark:variant - use semantic values fromstyle.csstheme (e.g.,bg-node-component-surface)
Usecn()utility from@/utils/tailwindUtilfor merging Tailwind class names instead of:class="[]"or hardcoding
Never use!importantor!Tailwind prefix - fix interfering classes instead
Use Tailwind fraction utilities instead of arbitrary percentage values (e.g.,w-4/5instead ofw-[80%])
Use TypeScript Vue 3.5 style default prop declaration with reactive props destructuring - avoidwithDefaultsor runtime props
PreferdefineModelover separately defining a prop and emit for v-model bindings
Define slots via template usage, not viadefineSlots
Use same-name shorthand for slot prop bindings (e.g.,:isExpandedinstead of:is-expanded="isExpanded")
Do not import Vue macros unnecessarily
Avoid new usage of PrimeVue components
Use Tailwind's plurals system via i18n instead of hardcoding ...
Files:
src/components/graph/widgets/TextPreviewWidget.vue
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/components/graph/widgets/TextPreviewWidget.vuesrc/renderer/extensions/vueNodes/widgets/composables/useStringWidget.tssrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.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
src/**/*.{ts,tsx,vue}: Use separateimport typestatements instead of inlinetypein mixed imports
Apply Prettier formatting with 2-space indentation, single quotes, no trailing semicolons, 80-character width
Sort and group imports by plugin, runpnpm formatbefore committing
Never useanytype - use proper TypeScript types
Never useas anytype assertions - fix the underlying type issue
Write code that is expressive and self-documenting - avoid unnecessary comments
Do not add or retain redundant comments - clean as you go
Avoid mutable state - prefer immutability and assignment at point of declaration
Watch out for Code Smells and refactor to avoid them
Files:
src/components/graph/widgets/TextPreviewWidget.vuesrc/renderer/extensions/vueNodes/widgets/composables/useStringWidget.tssrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.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/components/graph/widgets/TextPreviewWidget.vuesrc/renderer/extensions/vueNodes/widgets/composables/useStringWidget.tssrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
src/**/*.{vue,ts,tsx}
📄 CodeRabbit inference engine (src/CLAUDE.md)
Follow Vue 3 composition API style guide
Files:
src/components/graph/widgets/TextPreviewWidget.vuesrc/renderer/extensions/vueNodes/widgets/composables/useStringWidget.tssrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.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/components/graph/widgets/TextPreviewWidget.vuesrc/renderer/extensions/vueNodes/widgets/composables/useStringWidget.tssrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
src/components/**/*.vue
📄 CodeRabbit inference engine (src/components/CLAUDE.md)
src/components/**/*.vue: Use setup() function in Vue 3 Composition API
Destructure props using Vue 3.5 style in Vue components
Use ref/reactive for state management in Vue 3 Composition API
Implement computed() for derived state in Vue 3 Composition API
Use provide/inject for dependency injection in Vue components
Prefer emit/@event-name for state changes over other communication patterns
Use defineExpose only for imperative operations (such as form.validate(), modal.open())
Replace PrimeVue Dropdown component with Select
Replace PrimeVue OverlayPanel component with Popover
Replace PrimeVue Calendar component with DatePicker
Replace PrimeVue InputSwitch component with ToggleSwitch
Replace PrimeVue Sidebar component with Drawer
Replace PrimeVue Chips component with AutoComplete with multiple enabled
Replace PrimeVue TabMenu component with Tabs without panels
Replace PrimeVue Steps component with Stepper without panels
Replace PrimeVue InlineMessage component with Message
Extract complex conditionals to computed properties
Implement cleanup for async operations in Vue components
Use lifecycle hooks: onMounted, onUpdated in Vue 3 Composition API
Use Teleport/Suspense when needed for component rendering
Define proper props and emits definitions in Vue componentsName Vue components in PascalCase (e.g.,
MenuHamburger.vue)
Files:
src/components/graph/widgets/TextPreviewWidget.vue
src/components/**/*.{vue,css}
📄 CodeRabbit inference engine (src/components/CLAUDE.md)
src/components/**/*.{vue,css}: Use Tailwind CSS only for styling (no custom CSS)
Use the correct tokens from style.css in the design system package
Files:
src/components/graph/widgets/TextPreviewWidget.vue
src/components/**/*.{vue,ts,js}
📄 CodeRabbit inference engine (src/components/CLAUDE.md)
src/components/**/*.{vue,ts,js}: Use existing VueUse composables (such as useElementHover) instead of manually managing event listeners
Use useIntersectionObserver for visibility detection instead of custom scroll handlers
Use vue-i18n for ALL UI strings
Files:
src/components/graph/widgets/TextPreviewWidget.vue
src/**/*.{ts,vue}
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.{ts,vue}: Usereffor reactive state,computed()for derived values, andwatch/watchEffectfor side effects in Composition API
Avoid usingrefwithwatchif acomputedwould suffice - minimize refs and derived state
Useprovide/injectfor dependency injection only when simpler alternatives (Store or shared composable) won't work
Leverage VueUse functions for performance-enhancing composables
Use VueUse function for useI18n in composition API for string literals
Files:
src/components/graph/widgets/TextPreviewWidget.vuesrc/renderer/extensions/vueNodes/widgets/composables/useStringWidget.tssrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
src/**/*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/**/*.ts: Use es-toolkit for utility functions
Use TypeScript for type safety
src/**/*.ts: Derive component types usingvue-component-type-helpers(ComponentProps,ComponentSlots) instead of separate type files
Use es-toolkit for utility functions
Minimize the surface area (exported values) of each module and composable
Favor pure functions, especially testable ones
Files:
src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.tssrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
src/**/{services,composables}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (src/CLAUDE.md)
src/**/{services,composables}/**/*.{ts,tsx}: Useapi.apiURL()for backend endpoints instead of constructing URLs directly
Useapi.fileURL()for static file access instead of constructing URLs directly
Files:
src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.tssrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.{ts,tsx}: Keep functions short and functional
Minimize nesting (if statements, for loops, etc.)
Use function declarations instead of function expressions when possible
Files:
src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.tssrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
🧠 Learnings (30)
📚 Learning: 2025-12-11T03:55:57.926Z
Learnt from: simula-r
Repo: Comfy-Org/ComfyUI_frontend PR: 7252
File: src/renderer/extensions/vueNodes/components/ImagePreview.vue:151-158
Timestamp: 2025-12-11T03:55:57.926Z
Learning: In src/renderer/extensions/vueNodes/components/ImagePreview.vue and LGraphNode.vue, keyboard navigation for image galleries should respond to node-level focus (via keyEvent injection from LGraphNode), not require focus within the image preview wrapper itself. This allows users to navigate the gallery with arrow keys immediately when the node is focused/selected.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vuesrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-12-18T20:39:30.137Z
Learnt from: jtydhr88
Repo: Comfy-Org/ComfyUI_frontend PR: 7621
File: src/components/load3d/Load3DScene.vue:4-4
Timestamp: 2025-12-18T20:39:30.137Z
Learning: In src/components/load3d/Load3DScene.vue, the scoped `<style>` block with `!important` declarations for the canvas element is necessary because Three.js dynamically creates the canvas with inline styles, preventing direct application of Tailwind classes. This is a valid exception to the Tailwind-only styling guideline.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2026-01-10T00:24:17.662Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-10T00:24:17.662Z
Learning: Applies to src/**/*.{ts,vue} : Use `ref` for reactive state, `computed()` for derived values, and `watch`/`watchEffect` for side effects in Composition API
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2026-01-10T00:24:17.662Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-10T00:24:17.662Z
Learning: Applies to src/**/*.{ts,vue} : Leverage VueUse functions for performance-enhancing composables
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2026-01-10T00:24:17.662Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-10T00:24:17.662Z
Learning: Applies to src/**/*.{ts,vue} : Avoid using `ref` with `watch` if a `computed` would suffice - minimize refs and derived state
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vuesrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.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 lifecycle hooks: onMounted, onUpdated in Vue 3 Composition API
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-04T21:43:49.363Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7137
File: src/components/rightSidePanel/parameters/TabParameters.vue:10-0
Timestamp: 2025-12-04T21:43:49.363Z
Learning: Vue 3.5+ supports reactive props destructure in <script setup>. Destructuring props directly (e.g., `const { nodes } = defineProps<{ nodes: LGraphNode[] }>()`) maintains reactivity through compiler transformation. This is the recommended modern approach and does not require using `props.x` or `toRef`/`toRefs`.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 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/components/graph/widgets/TextPreviewWidget.vuesrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-12-09T03:49:52.828Z
Learnt from: christian-byrne
Repo: Comfy-Org/ComfyUI_frontend PR: 6300
File: src/platform/updates/components/WhatsNewPopup.vue:5-13
Timestamp: 2025-12-09T03:49:52.828Z
Learning: In Vue files across the ComfyUI_frontend repo, when a button is needed, prefer the repo's common button components from src/components/button/ (IconButton.vue, TextButton.vue, IconTextButton.vue) over plain HTML <button> elements. These components wrap PrimeVue with the project’s design system styling. Use only the common button components for consistency and theming, and import them from src/components/button/ as needed.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-09T21:40:12.361Z
Learnt from: benceruleanlu
Repo: Comfy-Org/ComfyUI_frontend PR: 7297
File: src/components/actionbar/ComfyActionbar.vue:33-43
Timestamp: 2025-12-09T21:40:12.361Z
Learning: In Vue single-file components, allow inline Tailwind CSS class strings for static classes and avoid extracting them into computed properties solely for readability. Prefer keeping static class names inline for simplicity and performance. For dynamic or conditional classes, use Vue bindings (e.g., :class) to compose classes.
Applies to all Vue files in the repository (e.g., src/**/*.vue) where Tailwind utilities are used for static styling.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-16T22:26:49.463Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7537
File: src/components/ui/button/Button.vue:17-17
Timestamp: 2025-12-16T22:26:49.463Z
Learning: In Vue 3.5+ with <script setup>, when using defineProps<Props>() with partial destructuring (e.g., const { as = 'button', class: customClass = '' } = defineProps<Props>() ), props that are not destructured (e.g., variant, size) stay accessible by name in the template scope. This pattern is valid: you can destructure only a subset of props for convenience while referencing the remaining props directly in template expressions. Apply this guideline to Vue components across the codebase (all .vue files).
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-22T21:36:08.369Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7649
File: src/platform/cloud/subscription/components/PricingTable.vue:185-201
Timestamp: 2025-12-22T21:36:08.369Z
Learning: In Vue components, avoid creating single-use variants for common UI components (e.g., Button and other shared components). Aim for reusable variants that cover multiple use cases. It’s acceptable to temporarily mix variant props with inline Tailwind classes when a styling need is unique to one place, but plan and consolidate into shared, reusable variants as patterns emerge across the codebase.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2026-01-08T02:26:18.357Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7893
File: src/components/button/IconGroup.vue:5-6
Timestamp: 2026-01-08T02:26:18.357Z
Learning: In components that use the cn utility from '@/utils/tailwindUtil' with tailwind-merge, rely on the behavior that conflicting Tailwind classes are resolved by keeping the last one. For example, cn('base-classes bg-default', propClass) will have any conflicting background class from propClass override bg-default. This additive pattern is intentional and aligns with the shadcn-ui convention; ensure you document or review expectations accordingly in Vue components.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-11T12:25:15.470Z
Learnt from: christian-byrne
Repo: Comfy-Org/ComfyUI_frontend PR: 7358
File: src/components/dialog/content/signin/SignUpForm.vue:45-54
Timestamp: 2025-12-11T12:25:15.470Z
Learning: This repository uses CI automation to format code (pnpm format). Do not include manual formatting suggestions in code reviews for Comfy-Org/ComfyUI_frontend. If formatting issues are detected, rely on the CI formatter or re-run pnpm format. Focus reviews on correctness, readability, performance, accessibility, and maintainability rather than style formatting.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vuesrc/renderer/extensions/vueNodes/widgets/composables/useStringWidget.tssrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-12-18T02:07:38.870Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7598
File: src/components/sidebar/tabs/AssetsSidebarTab.vue:131-131
Timestamp: 2025-12-18T02:07:38.870Z
Learning: Tailwind CSS v4 safe utilities (e.g., items-center-safe, justify-*-safe, place-*-safe) are allowed in Vue components under src/ and in story files. Do not flag these specific safe variants as invalid when reviewing code in src/**/*.vue or related stories.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-18T21:15:46.862Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7603
File: src/components/queue/QueueOverlayHeader.vue:49-59
Timestamp: 2025-12-18T21:15:46.862Z
Learning: In the ComfyUI_frontend repository, for Vue components, do not add aria-label to buttons that have visible text content (e.g., buttons containing <span> text). The visible text provides the accessible name. Use aria-label only for elements without visible labels (e.g., icon-only buttons). If a button has no visible label, provide a clear aria-label or associate with an aria-labelledby describing its action.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-21T01:06:02.786Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7649
File: src/components/graph/selectionToolbox/ColorPickerButton.vue:15-18
Timestamp: 2025-12-21T01:06:02.786Z
Learning: In Comfy-Org/ComfyUI_frontend, in Vue component files, when a filled icon is required (e.g., 'pi pi-circle-fill'), you may mix PrimeIcons with Lucide icons since Lucide lacks filled variants. This mixed usage is acceptable when one icon library does not provide an equivalent filled icon. Apply consistently across Vue components in the src directory where icons are used, and document the rationale when a mixed approach is chosen.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2025-12-18T16:03:02.066Z
Learnt from: henrikvilhelmberglund
Repo: Comfy-Org/ComfyUI_frontend PR: 7617
File: src/components/actionbar/ComfyActionbar.vue:301-308
Timestamp: 2025-12-18T16:03:02.066Z
Learning: In the ComfyUI frontend queue system, useQueuePendingTaskCountStore().count indicates the number of tasks in the queue, where count = 1 means a single active/running task and count > 1 means there are pending tasks in addition to the active task. Therefore, in src/components/actionbar/ComfyActionbar.vue, enable the 'Clear Pending Tasks' button only when count > 1 to avoid clearing the currently running task. The active task should be canceled using the 'Cancel current run' button instead. This rule should be enforced via a conditional check on the queue count, with appropriate disabled/aria-disabled states for accessibility, and tests should verify behavior for count = 1 and count > 1.
Applied to files:
src/components/graph/widgets/TextPreviewWidget.vue
📚 Learning: 2026-01-10T00:24:17.662Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-10T00:24:17.662Z
Learning: Applies to src/**/*.{ts,vue} : Use VueUse function for useI18n in composition API for string literals
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.ts
📚 Learning: 2025-12-09T03:39:54.501Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7169
File: src/platform/remote/comfyui/jobs/jobTypes.ts:1-107
Timestamp: 2025-12-09T03:39:54.501Z
Learning: In the ComfyUI_frontend project, Zod is on v3.x. Do not suggest Zod v4 standalone validators (z.uuid, z.ulid, z.cuid2, z.nanoid) until an upgrade to Zod 4 is performed. When reviewing TypeScript files (e.g., src/platform/remote/comfyui/jobs/jobTypes.ts) validate against Zod 3 capabilities and avoid introducing v4-specific features; flag any proposal to upgrade or incorporate v4-only validators and propose staying with compatible 3.x patterns.
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.tssrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-12-13T11:03:11.264Z
Learnt from: christian-byrne
Repo: Comfy-Org/ComfyUI_frontend PR: 7416
File: src/stores/imagePreviewStore.ts:5-7
Timestamp: 2025-12-13T11:03:11.264Z
Learning: In the ComfyUI_frontend repository, lint rules require keeping 'import type' statements separate from non-type imports, even if importing from the same module. Do not suggest consolidating them into a single import statement. Ensure type imports remain on their own line (import type { ... } from 'module') and regular imports stay on separate lines.
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.tssrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-12-17T00:40:09.635Z
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 7537
File: src/components/ui/button/Button.stories.ts:45-55
Timestamp: 2025-12-17T00:40:09.635Z
Learning: Prefer pure function declarations over function expressions (e.g., use function foo() { ... } instead of const foo = () => { ... }) for pure functions in the repository. Function declarations are more functional-leaning, offer better hoisting clarity, and can improve readability and tooling consistency. Apply this guideline across TypeScript files in Comfy-Org/ComfyUI_frontend, including story and UI component code, except where a function expression is semantically required (e.g., callbacks, higher-order functions with closures).
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.tssrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-12-30T22:22:33.836Z
Learnt from: kaili-yang
Repo: Comfy-Org/ComfyUI_frontend PR: 7805
File: src/composables/useCoreCommands.ts:439-439
Timestamp: 2025-12-30T22:22:33.836Z
Learning: When accessing reactive properties from Pinia stores in TypeScript files, avoid using .value on direct property access (e.g., useStore().isOverlayExpanded). Pinia auto-wraps refs when accessed directly, returning the primitive value. The .value accessor is only needed when destructuring store properties or when using storeToRefs().
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.tssrc/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2026-01-10T00:24:17.662Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-10T00:24:17.662Z
Learning: Applies to src/**/*.{ts,tsx,vue} : Watch out for Code Smells and refactor to avoid them
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
📚 Learning: 2025-11-24T19:47:56.371Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: src/lib/litegraph/CLAUDE.md:0-0
Timestamp: 2025-11-24T19:47:56.371Z
Learning: Applies to src/lib/litegraph/**/*.{js,ts,jsx,tsx} : Do not replace `&&=` or `||=` with `=` when there is no reason to do so. If you do find a reason to remove either `&&=` or `||=`, leave a comment explaining why the removal occurred
Applied to files:
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts
🧬 Code graph analysis (1)
src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.ts (1)
src/platform/settings/settingStore.ts (1)
useSettingStore(46-252)
🔇 Additional comments (2)
src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts (2)
101-153: Comprehensive wheel event handling implementation.The wheel event handler properly addresses the canvas interaction issues by:
- Preventing page pinch-zoom and routing ctrl+wheel to canvas
- Detecting trackpad gestures using deltaX/deltaY heuristics
- Conditionally routing events based on the trackpad gestures setting
- Handling both horizontal and vertical scroll with appropriate fallback to canvas
- Respecting the editing vs. viewing mode when determining scroll capability
The implementation is consistent with the pattern in
useStringWidget.tsand properly delegates events to the canvas when appropriate while preserving local scrolling when needed.
42-43: Good practice: caching the settings store.Caching the
settingStoreavoids repeated calls touseSettingStore()within the event handlers, which is a good optimization for frequently-fired events like wheel handlers.
| import { app } from '@/scripts/app' | ||
| import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets' | ||
|
|
||
| const TRACKPAD_DETECTION_THRESHOLD = 50 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Consider documenting the trackpad detection heuristic.
The TRACKPAD_DETECTION_THRESHOLD = 50 is a heuristic that distinguishes trackpad gestures from mouse wheel events. While this value works well in practice, it may not be perfect for all hardware configurations. Consider adding a brief comment explaining the rationale, or make it configurable if users report issues with specific trackpad/mouse combinations.
🤖 Prompt for AI Agents
In @src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts at
line 16, TRACKPAD_DETECTION_THRESHOLD is a magic-number heuristic used to
distinguish trackpad gestures from mouse wheel events; add a short comment above
the constant explaining the rationale (e.g., measured delta magnitude
difference, empirical value good for common hardware), note its limitations
across devices, and make it configurable by exposing it as an optional parameter
or prop in useMarkdownWidget (or read from a settings/config source) so users
can override the default if they report issues; reference the constant name
TRACKPAD_DETECTION_THRESHOLD and the composable useMarkdownWidget to locate and
update the code.

Summary
Fixes canvas interaction issues in "Markdown" and "Text Preview" widgets by properly delegating wheel and pointer events to the canvas interaction system, preventing interaction blocking.
Changes
useMarkdownWidget.ts: Implemented comprehensive wheel handling with trackpad detection, pinch zoom prevention, and proper vertical scroll delegationTextPreviewWidget.vue: Added wheel and pointerdown handlers usinguseCanvasInteractionscomposableScreenshots
Before:
before.mp4
After:
after.mp4
┆Issue is synchronized with this Notion page by Unito