Skip to content

Feat: Add preview as plaintext toggle for Preview As Text#7102

Merged
DrJKL merged 4 commits intomainfrom
drjkl/preview-plaintext
Dec 2, 2025
Merged

Feat: Add preview as plaintext toggle for Preview As Text#7102
DrJKL merged 4 commits intomainfrom
drjkl/preview-plaintext

Conversation

@DrJKL
Copy link
Contributor

@DrJKL DrJKL commented Dec 2, 2025

Summary

Adds a toggle to conditionally render the text as Markdown.

Also...

Fixes some type issues across our myriad Widget types. We should probably clean those up.

Example

Screen.Recording.2025-12-02.140823.mp4

This could be a good minimal testcase for dynamic widgets @AustinMroz

┆Issue is synchronized with this Notion page by Unito

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 2, 2025

📝 Walkthrough

Walkthrough

Tightens widget typings and runtime validation, changes SafeWidgetData.options to IWidgetOptions, assigns widget.options directly, excludes hidden widgets from layout/size calculations, refactors per-widget rendering and preview widgets (Markdown + plaintext toggle), and updates a test to use SafeWidgetData typing.

Changes

Cohort / File(s) Summary
Widget typing & validation
src/scripts/widgets.ts, src/composables/graph/useGraphNodeManager.ts, src/extensions/core/widgetInputs.ts
Exports ComfyWidgets as a readonly literal and adds isValidWidgetType(); imports IWidgetOptions and changes SafeWidgetData.options from Record<string, unknown> to IWidgetOptions<unknown>; when constructing widgets, replaces direct membership checks with isValidWidgetType().
Safe widget mapping
src/composables/graph/useGraphNodeManager.ts
safeWidgetMapper now assigns options directly from widget.options (no object spread) to match the new IWidgetOptions typing.
Node layout / hidden widgets
src/lib/litegraph/src/LGraphNode.ts
Filters out hidden widgets from computeSize and vertical positioning so hidden widgets no longer contribute to node height or widget y-positions.
Widget options narrowing in preview component
src/renderer/extensions/vueNodes/components/LGraphNodePreview.vue
Removes spread of full input into widget options; options now include only hidden, advanced, and values (for COMBO).
Widget rendering refactor
src/renderer/extensions/vueNodes/components/NodeWidgets.vue
Replaces per-widget wrapper div with template, adds v-if for hidden widgets and data-hidden, reintroduces InputSlot (uses socketless), computes widgetOptions (sets disabled when linked), converts update handler to function form, and adjusts props/classes passed to child widget components.
Preview widgets toggling
src/extensions/core/previewAny.ts
Replaces single preview widget with Markdown + plaintext widgets plus showAsPlaintextWidget toggle; updates execution handler to find and update all preview widgets.
Tests typing update
tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts
Test imports SafeWidgetData and changes widget declaration to Partial<SafeWidgetData> (type-only change).

Possibly related PRs

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch drjkl/preview-plaintext

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

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

🎨 Storybook Build Status

Build completed successfully!

⏰ Completed at: 12/02/2025, 10:30:26 PM UTC

🔗 Links


🎉 Your Storybook is ready for review!

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

🎭 Playwright Test Results

⚠️ Tests passed with flaky tests

⏰ Completed at: 12/02/2025, 10:39:43 PM UTC

📈 Summary

  • Total Tests: 497
  • Passed: 486 ✅
  • Failed: 0
  • Flaky: 2 ⚠️
  • Skipped: 9 ⏭️

📊 Test Reports by Browser

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

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

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

Bundle Size Report

Summary

  • Raw size: 17 MB baseline 17 MB — 🔴 +1.59 kB
  • Gzip: 3.37 MB baseline 3.37 MB — 🔴 +310 B
  • Brotli: 2.59 MB baseline 2.59 MB — 🔴 +411 B
  • Bundles: 97 current • 97 baseline • 37 added / 37 removed

Category Glance
App Entry Points 🔴 +1.63 kB (3.19 MB) · Graph Workspace 🟢 -33 B (928 kB) · Vendor & Third-Party ⚪ 0 B (8.56 MB) · Other ⚪ 0 B (3.84 MB) · Panels & Settings ⚪ 0 B (298 kB) · UI Components ⚪ 0 B (169 kB) · + 3 more

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

Main entry bundles and manifests

File Before After Δ Raw Δ Gzip Δ Brotli
assets/index-CQaFzrDz.js (new) 2.97 MB 🔴 +2.97 MB 🔴 +619 kB 🔴 +470 kB
assets/index-b_mbUp1T.js (removed) 2.97 MB 🟢 -2.97 MB 🟢 -619 kB 🟢 -470 kB
assets/index-EexU1HR6.js (new) 223 kB 🔴 +223 kB 🔴 +47.5 kB 🔴 +39.2 kB
assets/index-D3tJR-2D.js (removed) 222 kB 🟢 -222 kB 🟢 -47.3 kB 🟢 -39.1 kB
assets/index-Balt3ihN.js (removed) 345 B 🟢 -345 B 🟢 -243 B 🟢 -203 B
assets/index-R9ORtfV8.js (new) 345 B 🔴 +345 B 🔴 +245 B 🔴 +230 B

Status: 3 added / 3 removed

Graph Workspace — 928 kB (baseline 928 kB) • 🟢 -33 B

Graph editor runtime, canvas, workflow orchestration

File Before After Δ Raw Δ Gzip Δ Brotli
assets/GraphView-BhXJGGNS.js (removed) 928 kB 🟢 -928 kB 🟢 -180 kB 🟢 -138 kB
assets/GraphView-CUjLgeDA.js (new) 928 kB 🔴 +928 kB 🔴 +180 kB 🔴 +138 kB

Status: 1 added / 1 removed

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

Top-level views, pages, and routed surfaces

File Before After Δ Raw Δ Gzip Δ Brotli
assets/UserSelectView-FDp9QVap.js (removed) 6.54 kB 🟢 -6.54 kB 🟢 -2.14 kB 🟢 -1.89 kB
assets/UserSelectView-umJTFIF5.js (new) 6.54 kB 🔴 +6.54 kB 🔴 +2.14 kB 🔴 +1.89 kB

Status: 1 added / 1 removed

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

Configuration panels, inspectors, and settings screens

File Before After Δ Raw Δ Gzip Δ Brotli
assets/CreditsPanel-C9NomRuB.js (removed) 21.4 kB 🟢 -21.4 kB 🟢 -5.15 kB 🟢 -4.5 kB
assets/CreditsPanel-CYzBQoG-.js (new) 21.4 kB 🔴 +21.4 kB 🔴 +5.15 kB 🔴 +4.5 kB
assets/KeybindingPanel-BaGDa37N.js (new) 13.6 kB 🔴 +13.6 kB 🔴 +3.42 kB 🔴 +3.02 kB
assets/KeybindingPanel-CXhFGaqY.js (removed) 13.6 kB 🟢 -13.6 kB 🟢 -3.42 kB 🟢 -3.01 kB
assets/ExtensionPanel-B7TngsRP.js (new) 10.8 kB 🔴 +10.8 kB 🔴 +2.58 kB 🔴 +2.26 kB
assets/ExtensionPanel-gqI-i-89.js (removed) 10.8 kB 🟢 -10.8 kB 🟢 -2.58 kB 🟢 -2.26 kB
assets/AboutPanel-DZHl7_fO.js (removed) 9.16 kB 🟢 -9.16 kB 🟢 -2.46 kB 🟢 -2.21 kB
assets/AboutPanel-NctmQKEh.js (new) 9.16 kB 🔴 +9.16 kB 🔴 +2.46 kB 🔴 +2.21 kB
assets/ServerConfigPanel-B5c5HGeF.js (removed) 6.56 kB 🟢 -6.56 kB 🟢 -1.83 kB 🟢 -1.63 kB
assets/ServerConfigPanel-CAgHBZQo.js (new) 6.56 kB 🔴 +6.56 kB 🔴 +1.83 kB 🔴 +1.63 kB
assets/UserPanel-Bo3sWqHb.js (new) 6.23 kB 🔴 +6.23 kB 🔴 +1.72 kB 🔴 +1.51 kB
assets/UserPanel-DcZ3ftnj.js (removed) 6.23 kB 🟢 -6.23 kB 🟢 -1.72 kB 🟢 -1.51 kB
assets/settings-BhbWhsRg.js 101 B 101 B ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-BXTtSH4O.js 33.3 kB 33.3 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-C9Pzn-NG.js 25.2 kB 25.2 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-CCy2fA_h.js 27.3 kB 27.3 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-CQpqEFfl.js 26.6 kB 26.6 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-DHcnxypw.js 21.7 kB 21.7 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-DhFTK9fY.js 25.1 kB 25.1 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-DlT4t_ui.js 25.9 kB 25.9 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-DRgSrIdD.js 24.2 kB 24.2 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/settings-tjkeqiZq.js 21.1 kB 21.1 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B

Status: 6 added / 6 removed

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

Reusable component library chunks

File Before After Δ Raw Δ Gzip Δ Brotli
assets/Load3D.vue_vue_type_script_setup_true_lang-BS0JQvxC.js (removed) 53.9 kB 🟢 -53.9 kB 🟢 -8.52 kB 🟢 -7.32 kB
assets/Load3D.vue_vue_type_script_setup_true_lang-Dv4KtLri.js (new) 53.9 kB 🔴 +53.9 kB 🔴 +8.52 kB 🔴 +7.31 kB
assets/WidgetSelect.vue_vue_type_script_setup_true_lang-Dd1AMz_3.js (removed) 47.6 kB 🟢 -47.6 kB 🟢 -10.2 kB 🟢 -8.9 kB
assets/WidgetSelect.vue_vue_type_script_setup_true_lang-FrlbB8b_.js (new) 47.6 kB 🔴 +47.6 kB 🔴 +10.3 kB 🔴 +8.91 kB
assets/LazyImage.vue_vue_type_script_setup_true_lang-CIY2WcHS.js (removed) 39.4 kB 🟢 -39.4 kB 🟢 -9.08 kB 🟢 -7.96 kB
assets/LazyImage.vue_vue_type_script_setup_true_lang-CZXvcPwv.js (new) 39.4 kB 🔴 +39.4 kB 🔴 +9.08 kB 🔴 +7.97 kB
assets/WidgetInputNumber.vue_vue_type_script_setup_true_lang-ClExNYE-.js (new) 12.9 kB 🔴 +12.9 kB 🔴 +3.37 kB 🔴 +2.97 kB
assets/WidgetInputNumber.vue_vue_type_script_setup_true_lang-CRBwPnUX.js (removed) 12.9 kB 🟢 -12.9 kB 🟢 -3.36 kB 🟢 -2.97 kB
assets/ComfyQueueButton-CYzQPPxz.js (removed) 8.44 kB 🟢 -8.44 kB 🟢 -2.48 kB 🟢 -2.22 kB
assets/ComfyQueueButton-iEVYLGIn.js (new) 8.44 kB 🔴 +8.44 kB 🔴 +2.48 kB 🔴 +2.21 kB
assets/MediaTitle.vue_vue_type_script_setup_true_lang-CpOqoEW8.js (removed) 897 B 🟢 -897 B 🟢 -501 B 🟢 -436 B
assets/MediaTitle.vue_vue_type_script_setup_true_lang-D50de0jq.js (new) 897 B 🔴 +897 B 🔴 +503 B 🔴 +429 B
assets/UserAvatar.vue_vue_type_script_setup_true_lang-B4R5m1qI.js 1.34 kB 1.34 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/WidgetButton-C9RSl9Jc.js 2.04 kB 2.04 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/WidgetLayoutField.vue_vue_type_script_setup_true_lang-C-GzTNBl.js 2 kB 2 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B

Status: 6 added / 6 removed

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

Stores, services, APIs, and repositories

File Before After Δ Raw Δ Gzip Δ Brotli
assets/keybindingService-BAathVzF.js (new) 7.51 kB 🔴 +7.51 kB 🔴 +1.83 kB 🔴 +1.58 kB
assets/keybindingService-DW9ZBb3k.js (removed) 7.51 kB 🟢 -7.51 kB 🟢 -1.83 kB 🟢 -1.58 kB
assets/audioService-DIts7y41.js (removed) 2.2 kB 🟢 -2.2 kB 🟢 -959 B 🟢 -821 B
assets/audioService-SMTVa4cu.js (new) 2.2 kB 🔴 +2.2 kB 🔴 +958 B 🔴 +822 B
assets/serverConfigStore-W1zhjkBH.js 2.83 kB 2.83 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B

Status: 2 added / 2 removed

Utilities & Hooks — 2.94 kB (baseline 2.94 kB) • ⚪ 0 B

Helpers, composables, and utility bundles

File Before After Δ Raw Δ Gzip Δ Brotli
assets/audioUtils-csX-U-LE.js (new) 1.41 kB 🔴 +1.41 kB 🔴 +651 B 🔴 +544 B
assets/audioUtils-CUsT5yeW.js (removed) 1.41 kB 🟢 -1.41 kB 🟢 -650 B 🟢 -548 B
assets/mathUtil-CTARWQ-l.js 1.07 kB 1.07 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeFilterUtil-CXKCRJ-m.js 460 B 460 B ⚪ 0 B ⚪ 0 B ⚪ 0 B

Status: 1 added / 1 removed

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

External libraries and shared vendor chunks

File Before After Δ Raw Δ Gzip Δ Brotli
assets/vendor-chart-BCOr5Gfm.js 452 kB 452 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/vendor-other-DsoOPVgr.js 3.98 MB 3.98 MB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/vendor-primevue-CjsaCDb8.js 1.96 MB 1.96 MB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/vendor-three-aR6ntw5X.js 1.37 MB 1.37 MB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/vendor-tiptap-CzjUILzD.js 232 kB 232 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/vendor-vue-BEWVLQIi.js 160 kB 160 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/vendor-xterm-BZLod3g9.js 407 kB 407 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
Other — 3.84 MB (baseline 3.84 MB) • ⚪ 0 B

Bundles that do not match a named category

File Before After Δ Raw Δ Gzip Δ Brotli
assets/WidgetRecordAudio-arzsQk8c.js (removed) 20.4 kB 🟢 -20.4 kB 🟢 -5.24 kB 🟢 -4.63 kB
assets/WidgetRecordAudio-ClEe22zm.js (new) 20.4 kB 🔴 +20.4 kB 🔴 +5.24 kB 🔴 +4.63 kB
assets/AudioPreviewPlayer-BIndJxG0.js (removed) 13.5 kB 🟢 -13.5 kB 🟢 -3.4 kB 🟢 -3.04 kB
assets/AudioPreviewPlayer-d-Q19jkH.js (new) 13.5 kB 🔴 +13.5 kB 🔴 +3.4 kB 🔴 +3.04 kB
assets/WidgetGalleria-Cg10hG_E.js (new) 4.1 kB 🔴 +4.1 kB 🔴 +1.45 kB 🔴 +1.3 kB
assets/WidgetGalleria-CutNFcol.js (removed) 4.1 kB 🟢 -4.1 kB 🟢 -1.45 kB 🟢 -1.3 kB
assets/WidgetColorPicker-BUgc-eHT.js (new) 3.41 kB 🔴 +3.41 kB 🔴 +1.38 kB 🔴 +1.23 kB
assets/WidgetColorPicker-uGXzm8SH.js (removed) 3.41 kB 🟢 -3.41 kB 🟢 -1.38 kB 🟢 -1.23 kB
assets/WidgetMarkdown-D5o2L_Gz.js (removed) 3.1 kB 🟢 -3.1 kB 🟢 -1.29 kB 🟢 -1.13 kB
assets/WidgetMarkdown-DfKYR0q5.js (new) 3.1 kB 🔴 +3.1 kB 🔴 +1.29 kB 🔴 +1.13 kB
assets/WidgetAudioUI-CdqudvY3.js (removed) 2.82 kB 🟢 -2.82 kB 🟢 -1.12 kB 🟢 -1.02 kB
assets/WidgetAudioUI-CXruqcO9.js (new) 2.82 kB 🔴 +2.82 kB 🔴 +1.12 kB 🔴 +1.01 kB
assets/WidgetTextarea-C7PqP_v7.js (new) 2.48 kB 🔴 +2.48 kB 🔴 +1.01 kB 🔴 +886 B
assets/WidgetTextarea-Cjw8XhFS.js (removed) 2.48 kB 🟢 -2.48 kB 🟢 -1.01 kB 🟢 -886 B
assets/WidgetInputText--f5qsKBQ.js (new) 1.99 kB 🔴 +1.99 kB 🔴 +917 B 🔴 +851 B
assets/WidgetInputText-B8Wl6hb2.js (removed) 1.99 kB 🟢 -1.99 kB 🟢 -916 B 🟢 -850 B
assets/MediaImageBottom-uoIX2Q_a.js (removed) 1.57 kB 🟢 -1.57 kB 🟢 -743 B 🟢 -648 B
assets/MediaImageBottom-yYZDCOGm.js (new) 1.57 kB 🔴 +1.57 kB 🔴 +744 B 🔴 +645 B
assets/MediaAudioBottom-CmD4hfdf.js (new) 1.52 kB 🔴 +1.52 kB 🔴 +742 B 🔴 +657 B
assets/MediaAudioBottom-W4uKev9k.js (removed) 1.52 kB 🟢 -1.52 kB 🟢 -743 B 🟢 -655 B
assets/MediaVideoBottom-DCTOnWd_.js (removed) 1.52 kB 🟢 -1.52 kB 🟢 -739 B 🟢 -657 B
assets/MediaVideoBottom-tip7v5cY.js (new) 1.52 kB 🔴 +1.52 kB 🔴 +739 B 🔴 +655 B
assets/Media3DBottom-BpF1JYkS.js (removed) 1.5 kB 🟢 -1.5 kB 🟢 -733 B 🟢 -649 B
assets/Media3DBottom-CTEbXse1.js (new) 1.5 kB 🔴 +1.5 kB 🔴 +732 B 🔴 +649 B
assets/Media3DTop-Brcv8OUu.js (removed) 1.49 kB 🟢 -1.49 kB 🟢 -764 B 🟢 -654 B
assets/Media3DTop-DscfdsTv.js (new) 1.49 kB 🔴 +1.49 kB 🔴 +764 B 🔴 +655 B
assets/WidgetSelect-Dg0Iwccl.js (new) 655 B 🔴 +655 B 🔴 +341 B 🔴 +287 B
assets/WidgetSelect-Do48C02n.js (removed) 655 B 🟢 -655 B 🟢 -343 B 🟢 -305 B
assets/WidgetInputNumber-BO1MJl5G.js (new) 595 B 🔴 +595 B 🔴 +329 B 🔴 +275 B
assets/WidgetInputNumber-Cz2qEB5h.js (removed) 595 B 🟢 -595 B 🟢 -329 B 🟢 -277 B
assets/Load3D-DjuPLZMI.js (new) 424 B 🔴 +424 B 🔴 +265 B 🔴 +225 B
assets/Load3D-Drjbyctu.js (removed) 424 B 🟢 -424 B 🟢 -267 B 🟢 -223 B
assets/WidgetLegacy-BbQ9e-l6.js (new) 364 B 🔴 +364 B 🔴 +236 B 🔴 +193 B
assets/WidgetLegacy-DcwjPJAW.js (removed) 364 B 🟢 -364 B 🟢 -237 B 🟢 -197 B
assets/commands-_s-RvhJR.js 13.6 kB 13.6 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-BuUILW6P.js 13 kB 13 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-BV4R6fLx.js 14.9 kB 14.9 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-BWp4HdfU.js 101 B 101 B ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-CLwPdnT6.js 14.2 kB 14.2 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-CWMchBmd.js 15.9 kB 15.9 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-DazTQhtc.js 12.9 kB 12.9 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-DmWrOe93.js 13.7 kB 13.7 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-DwiH7Kr6.js 13.8 kB 13.8 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/commands-mS3LCNPn.js 14.5 kB 14.5 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-5lOBdqcC.js 84.5 kB 84.5 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-BOCuaVpE.js 73.4 kB 73.4 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-ClrEFGUz.js 72.4 kB 72.4 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-Cw9RZWRY.js 89 B 89 B ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-CyNU0iQX.js 99.3 kB 99.3 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-D7gwLxft.js 114 kB 114 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-DC8o4BCt.js 86.8 kB 86.8 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-DKiesCV4.js 94.3 kB 94.3 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-Hq2q-OtB.js 83.6 kB 83.6 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/main-USAlAlnj.js 82 kB 82 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/MediaAudioTop-B_r9Y3e-.js 1.46 kB 1.46 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/MediaImageTop-Df0PRhSp.js 1.75 kB 1.75 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/MediaVideoTop-_g8aBAAL.js 2.76 kB 2.76 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-_Px5dSNW.js 306 kB 306 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-7z21KPoS.js 285 kB 285 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-Bw_Jitw_.js 101 B 101 B ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-BWKZzBPK.js 346 kB 346 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-CGbgH4Yl.js 320 kB 320 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-CjjjdWkV.js 313 kB 313 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-CVrNtxvj.js 288 kB 288 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-DLRSA0IK.js 309 kB 309 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-DQV2gnwA.js 372 kB 372 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/nodeDefs-ofqLG5vz.js 310 kB 310 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/WidgetChart-f0b59iz3.js 2.48 kB 2.48 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/WidgetImageCompare-65U3rWW6.js 2.21 kB 2.21 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/widgetPropFilter-BIbGSUAt.js 1.28 kB 1.28 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B
assets/WidgetToggleSwitch-C53mIaDW.js 1.58 kB 1.58 kB ⚪ 0 B ⚪ 0 B ⚪ 0 B

Status: 17 added / 17 removed

@DrJKL
Copy link
Contributor Author

DrJKL commented Dec 2, 2025

I know it should be Heading not Header. Don't @ me.

@DrJKL DrJKL changed the title WIP/Feat: Add preview as plaintext toggle for Preview As Text Feat: Add preview as plaintext toggle for Preview As Text Dec 2, 2025
@DrJKL DrJKL marked this pull request as ready for review December 2, 2025 22:09
@DrJKL DrJKL requested a review from a team as a code owner December 2, 2025 22:09
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 2, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/extensions/core/previewAny.ts (1)

27-32: Add i18n for user-facing strings.

The label_on: 'Markdown' and label_off: 'Plaintext' strings on lines 39-40 should use vue-i18n for localization. Per coding guidelines, user-facing strings should be added to src/locales/en/main.json.

Consider:

+ import { t } from '@/i18n'

  const showAsPlaintextWidget = ComfyWidgets['BOOLEAN'](
    this,
    'previewMode',
    [
      'BOOLEAN',
-     { label_on: 'Markdown', label_off: 'Plaintext', default: false }
+     { label_on: t('previewAny.markdown'), label_off: t('previewAny.plaintext'), default: false }
    ],
    app
  )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e887d69 and 4a8b4b8.

📒 Files selected for processing (8)
  • src/composables/graph/useGraphNodeManager.ts (3 hunks)
  • src/extensions/core/previewAny.ts (2 hunks)
  • src/extensions/core/widgetInputs.ts (2 hunks)
  • src/lib/litegraph/src/LGraphNode.ts (2 hunks)
  • src/renderer/extensions/vueNodes/components/LGraphNodePreview.vue (0 hunks)
  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue (2 hunks)
  • src/scripts/widgets.ts (2 hunks)
  • tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • src/renderer/extensions/vueNodes/components/LGraphNodePreview.vue
🧰 Additional context used
📓 Path-based instructions (22)
**/*.{vue,ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

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

Files:

  • src/scripts/widgets.ts
  • src/composables/graph/useGraphNodeManager.ts
  • tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts
  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
  • src/lib/litegraph/src/LGraphNode.ts
  • src/extensions/core/previewAny.ts
  • src/extensions/core/widgetInputs.ts
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursorrules)

Use es-toolkit for utility functions

Files:

  • src/scripts/widgets.ts
  • src/composables/graph/useGraphNodeManager.ts
  • tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts
  • src/lib/litegraph/src/LGraphNode.ts
  • src/extensions/core/previewAny.ts
  • src/extensions/core/widgetInputs.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

Use TypeScript for type safety

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

Files:

  • src/scripts/widgets.ts
  • src/composables/graph/useGraphNodeManager.ts
  • tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts
  • src/lib/litegraph/src/LGraphNode.ts
  • src/extensions/core/previewAny.ts
  • src/extensions/core/widgetInputs.ts
**/*.{ts,tsx,js,vue}

📄 CodeRabbit inference engine (.cursorrules)

Implement proper error handling in components and services

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

Files:

  • src/scripts/widgets.ts
  • src/composables/graph/useGraphNodeManager.ts
  • tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts
  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
  • src/lib/litegraph/src/LGraphNode.ts
  • src/extensions/core/previewAny.ts
  • src/extensions/core/widgetInputs.ts
src/**/*.{vue,ts}

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

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

Files:

  • src/scripts/widgets.ts
  • src/composables/graph/useGraphNodeManager.ts
  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
  • src/lib/litegraph/src/LGraphNode.ts
  • src/extensions/core/previewAny.ts
  • src/extensions/core/widgetInputs.ts
src/**/*.ts

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

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

Files:

  • src/scripts/widgets.ts
  • src/composables/graph/useGraphNodeManager.ts
  • src/lib/litegraph/src/LGraphNode.ts
  • src/extensions/core/previewAny.ts
  • src/extensions/core/widgetInputs.ts
**/*.{ts,tsx,js,jsx,vue}

📄 CodeRabbit inference engine (CLAUDE.md)

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

Files:

  • src/scripts/widgets.ts
  • src/composables/graph/useGraphNodeManager.ts
  • tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts
  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
  • src/lib/litegraph/src/LGraphNode.ts
  • src/extensions/core/previewAny.ts
  • src/extensions/core/widgetInputs.ts
**/*.{ts,tsx,vue}

📄 CodeRabbit inference engine (CLAUDE.md)

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

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

Files:

  • src/scripts/widgets.ts
  • src/composables/graph/useGraphNodeManager.ts
  • tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts
  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
  • src/lib/litegraph/src/LGraphNode.ts
  • src/extensions/core/previewAny.ts
  • src/extensions/core/widgetInputs.ts
**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

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

Files:

  • src/scripts/widgets.ts
  • src/composables/graph/useGraphNodeManager.ts
  • tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts
  • src/lib/litegraph/src/LGraphNode.ts
  • src/extensions/core/previewAny.ts
  • src/extensions/core/widgetInputs.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/scripts/widgets.ts
  • src/composables/graph/useGraphNodeManager.ts
  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
  • src/lib/litegraph/src/LGraphNode.ts
  • src/extensions/core/previewAny.ts
  • src/extensions/core/widgetInputs.ts
src/**/*.{vue,ts,tsx}

📄 CodeRabbit inference engine (src/CLAUDE.md)

Follow Vue 3 composition API style guide

Files:

  • src/scripts/widgets.ts
  • src/composables/graph/useGraphNodeManager.ts
  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
  • src/lib/litegraph/src/LGraphNode.ts
  • src/extensions/core/previewAny.ts
  • src/extensions/core/widgetInputs.ts
src/**/{services,composables}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (src/CLAUDE.md)

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

Files:

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

📄 CodeRabbit inference engine (src/CLAUDE.md)

Clean up subscriptions in state management to prevent memory leaks

Files:

  • src/composables/graph/useGraphNodeManager.ts
  • src/renderer/extensions/vueNodes/components/NodeWidgets.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/composables/graph/useGraphNodeManager.ts
  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
tests-ui/**/*.test.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (tests-ui/CLAUDE.md)

tests-ui/**/*.test.{js,ts,jsx,tsx}: Write tests for new features
Follow existing test patterns in the codebase
Use existing test utilities rather than writing custom utilities
Mock external dependencies in tests
Always prefer vitest mock functions over writing verbose manual mocks

Files:

  • tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts
**/*.{test,spec}.{ts,tsx,js}

📄 CodeRabbit inference engine (AGENTS.md)

Unit and component tests should be located in tests-ui/ or co-located with components as src/components/**/*.{test,spec}.ts; E2E tests should be in browser_tests/

Files:

  • tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts
**/composables/use*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Name composables in the format useXyz.ts

Files:

  • tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts
**/*.vue

📄 CodeRabbit inference engine (.cursorrules)

**/*.vue: Use setup() function for component logic in Vue 3 Composition API
Utilize ref and reactive for reactive state in Vue 3
Implement computed properties with computed() function
Use watch and watchEffect for side effects in Vue 3
Implement lifecycle hooks with onMounted, onUpdated, etc.
Utilize provide/inject for dependency injection in Vue 3
Use Vue 3.5 style of default prop declaration with defineProps()
Organize Vue components in <script> <style> order
Use Tailwind CSS for styling Vue components
Implement responsive design with Tailwind CSS
Do not use deprecated PrimeVue components (Dropdown, OverlayPanel, Calendar, InputSwitch, Sidebar, Chips, TabMenu, Steps, InlineMessage). Use replacements: Select, Popover, DatePicker, ToggleSwitch, Drawer, AutoComplete, Tabs, Stepper, Message respectively
Implement proper props and emits definitions in Vue components
Utilize Vue 3's Teleport component when needed
Use Suspense for async components in Vue 3
Follow Vue 3 style guide and naming conventions
Never use deprecated PrimeVue components (Dropdown, OverlayPanel, Calendar, InputSwitch, Sidebar, Chips, TabMenu, Steps, InlineMessage)

Never use :class="[]" to merge class names - always use import { cn } from '@/utils/tailwindUtil' for class merging in Vue templates

**/*.vue: Use TypeScript with Vue 3 Single File Components (.vue files)
Name Vue components in PascalCase (e.g., MenuHamburger.vue)

Files:

  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
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/renderer/extensions/vueNodes/components/NodeWidgets.vue
**/*.{vue,html}

📄 CodeRabbit inference engine (CLAUDE.md)

Never use dark: or dark-theme: Tailwind variants - instead use semantic values from style.css theme, e.g. bg-node-component-surface

Files:

  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
src/lib/litegraph/**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (src/lib/litegraph/CLAUDE.md)

src/lib/litegraph/**/*.{js,ts,jsx,tsx}: Run ESLint instead of manually figuring out whitespace fixes or other trivial style concerns using the pnpm lint:fix command
Take advantage of TypedArray subarray when appropriate
The size and pos properties of Rectangle share the same array buffer (subarray); they may be used to set the rectangle's size and position
Prefer single line if syntax over adding curly braces, when the statement has a very concise expression and concise, single line statement
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
When writing methods, prefer returning idiomatic JavaScript undefined over null

Files:

  • src/lib/litegraph/src/LGraphNode.ts
src/lib/litegraph/**/*.{ts,tsx}

📄 CodeRabbit inference engine (src/lib/litegraph/CLAUDE.md)

Type assertions are an absolute last resort. In almost all cases, they are a crutch that leads to brittle code

Files:

  • src/lib/litegraph/src/LGraphNode.ts
🧠 Learnings (6)
📚 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/**/*.{test,spec}.{ts,tsx} : Use provided test helpers `createTestSubgraph` and `createTestSubgraphNode` from `./fixtures/subgraphHelpers` for consistent subgraph test setup

Applied to files:

  • src/composables/graph/useGraphNodeManager.ts
  • tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts
  • src/extensions/core/widgetInputs.ts
📚 Learning: 2025-11-24T19:48:03.270Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: tests-ui/CLAUDE.md:0-0
Timestamp: 2025-11-24T19:48:03.270Z
Learning: Applies to tests-ui/**/*.test.{js,ts,jsx,tsx} : Use existing test utilities rather than writing custom utilities

Applied to files:

  • tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts
📚 Learning: 2025-11-24T19:48:09.318Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: .cursor/rules/unit-test.mdc:0-0
Timestamp: 2025-11-24T19:48:09.318Z
Learning: Applies to test/**/*.{test,spec}.{js,ts,jsx,tsx} : Prefer the use of `test.extend` over loose variables; import `test as baseTest` from `vitest`

Applied to files:

  • tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts
📚 Learning: 2025-11-24T19:48:03.270Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: tests-ui/CLAUDE.md:0-0
Timestamp: 2025-11-24T19:48:03.270Z
Learning: Applies to tests-ui/**/*.test.{js,ts,jsx,tsx} : Write tests for new features

Applied to files:

  • tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.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 : Replace PrimeVue InputSwitch component with ToggleSwitch

Applied to files:

  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
📚 Learning: 2025-11-24T19:47:34.324Z
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: src/CLAUDE.md:0-0
Timestamp: 2025-11-24T19:47:34.324Z
Learning: Applies to src/**/*.{ts,tsx,vue} : Implement proper TypeScript types throughout the codebase

Applied to files:

  • src/extensions/core/widgetInputs.ts
🧬 Code graph analysis (4)
src/composables/graph/useGraphNodeManager.ts (1)
src/lib/litegraph/src/types/widgets.ts (1)
  • IWidgetOptions (5-36)
tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts (1)
src/composables/graph/useGraphNodeManager.ts (1)
  • SafeWidgetData (40-50)
src/extensions/core/previewAny.ts (3)
src/scripts/widgets.ts (1)
  • ComfyWidgets (288-302)
src/scripts/domWidget.ts (1)
  • DOMWidget (40-49)
src/types/index.ts (1)
  • DOMWidget (43-43)
src/extensions/core/widgetInputs.ts (1)
src/scripts/widgets.ts (1)
  • isValidWidgetType (304-308)
🔇 Additional comments (17)
src/scripts/widgets.ts (2)

288-302: LGTM - Good type refinement with as const.

Using as const provides better type inference and allows keyof typeof ComfyWidgets to be a union of literal types rather than just string, enabling stronger compile-time checks.


304-308: Type guard implementation is correct.

The isValidWidgetType function properly narrows unknown to valid widget keys. The implementation correctly handles the runtime check using property lookup.

src/lib/litegraph/src/LGraphNode.ts (2)

4030-4032: Good addition of hidden widget filtering for layout calculations.

Filtering out hidden widgets prevents them from contributing to fixedWidgetHeight, which is the correct behavior. The filtering is applied consistently in both the height computation loop and the positioning loop (line 4071).


4071-4074: Consistent use of visibleWidgets for positioning.

The same filtered set is used for both height calculation and y-position assignment, ensuring hidden widgets don't create gaps in the layout.

tests-ui/tests/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer.test.ts (2)

9-9: Good type import for test alignment.

Importing SafeWidgetData ensures the test widget object aligns with the updated interface, particularly the options field type change from Record<string, unknown> to IWidgetOptions<unknown>.


125-128: Proper typing for test widget object.

Using Partial<SafeWidgetData> correctly types the test widget with only the properties needed for this specific test case.

src/extensions/core/previewAny.ts (2)

34-49: Consider clarifying toggle semantics.

The toggle logic works correctly, but the naming is counterintuitive: default: false with label_off: 'Plaintext' means the default shows Plaintext. When the toggle is ON (value=true), Markdown is shown.

The callback correctly inverts visibility:

  • value=true → Markdown visible, Plaintext hidden
  • value=false → Markdown hidden, Plaintext visible

This matches the initial state (lines 51-63) where Markdown is hidden by default.


73-80: Filter correctly retrieves both preview widgets for updating, but violates system-wide widget naming assumption.

The code uses filter() intentionally to update both the Markdown and plaintext preview widgets that share the name 'preview'. This is necessary because one widget is shown/hidden dynamically based on the previewMode toggle. However, the broader codebase extensively uses .find() (60+ locations) which returns only the first match, assuming unique widget names per node. While this extension's internal usage is self-contained and works correctly, the pattern creates architectural inconsistency. Consider documenting this exception or using distinct widget names ('previewMarkdown', 'previewPlaintext') to align with system-wide design assumptions.

src/extensions/core/widgetInputs.ts (2)

17-21: Good centralization of widget type validation.

Importing isValidWidgetType from the widgets module instead of doing an inline type in ComfyWidgets check improves maintainability and provides consistent type narrowing across the codebase.


230-236: Type narrowing works correctly with the guard.

After isValidWidgetType(type) returns true, type is narrowed to keyof typeof ComfyWidgets, allowing safe indexing into ComfyWidgets[type]. The else branch appropriately falls back to addWidget for unknown types.

src/composables/graph/useGraphNodeManager.ts (3)

13-16: Good type refinement with IWidgetOptions.

Importing IWidgetOptions allows the SafeWidgetData.options field to have a more specific type than the generic Record<string, unknown>, providing better autocompletion and type checking for known widget option properties.


45-45: Type improvement for options field.

Changing from Record<string, unknown> to IWidgetOptions<unknown> provides more accurate typing. The <unknown> generic parameter correctly indicates that the values array type is not known at this level.


113-113: Direct assignment is correct.

Assigning widget.options directly (instead of spreading) is appropriate since IWidgetOptions is already the correct type. Spreading would have been necessary only if the source type was incompatible.

src/renderer/extensions/vueNodes/components/NodeWidgets.vue (4)

19-26: Good template restructuring for hidden widget support.

Using a <template> wrapper with v-if on the inner div correctly filters out hidden widgets from the DOM while maintaining the loop structure. The data-is-hidden attribute is useful for debugging.


30-50: InputSlot integration for widget connection dots.

Adding the InputSlot component with dot-only mode correctly renders connection points for widgets that have associated input slots. The conditional rendering based on widget.slotMetadata is appropriate.


165-174: Good refactor to function-based update handler.

Converting updateHandler from an object method to a standalone function is cleaner and avoids potential this binding issues. The logic correctly updates the widget value and conditionally calls the callback.


146-153: Correct conditional disabling for linked widgets.

When a widget's slot is linked (slotMetadata?.linked), the widget should be disabled to prevent conflicting inputs. The spread with disabled: true correctly achieves this without mutating the original options.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/extensions/core/previewAny.ts (1)

51-63: Consider initializing visibility state via the callback.

The visibility initialization (lines 51-52, 58-59) duplicates the logic in the callback (lines 44-49), violating DRY principles. If the callback logic changes, these lines must be updated separately.

Apply this diff to avoid duplication:

         showAsPlaintextWidget.widget.callback = (value) => {
           showValueWidget.hidden = !value
           showValueWidget.options.hidden = !value
           showValueWidgetPlain.hidden = value
           showValueWidgetPlain.options.hidden = value
         }
 
-        showValueWidget.hidden = true
-        showValueWidget.options.hidden = true
         showValueWidget.options.read_only = true
         showValueWidget.element.readOnly = true
         showValueWidget.element.disabled = true
         showValueWidget.serialize = false
 
-        showValueWidgetPlain.hidden = false
-        showValueWidgetPlain.options.hidden = false
         showValueWidgetPlain.options.read_only = true
         showValueWidgetPlain.element.readOnly = true
         showValueWidgetPlain.element.disabled = true
         showValueWidgetPlain.serialize = false
+
+        // Initialize visibility based on default value
+        showAsPlaintextWidget.widget.callback(showAsPlaintextWidget.widget.value)
       }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a8b4b8 and 39522fa.

📒 Files selected for processing (1)
  • src/extensions/core/previewAny.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (11)
**/*.{vue,ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

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

Files:

  • src/extensions/core/previewAny.ts
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursorrules)

Use es-toolkit for utility functions

Files:

  • src/extensions/core/previewAny.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

Use TypeScript for type safety

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

Files:

  • src/extensions/core/previewAny.ts
**/*.{ts,tsx,js,vue}

📄 CodeRabbit inference engine (.cursorrules)

Implement proper error handling in components and services

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

Files:

  • src/extensions/core/previewAny.ts
src/**/*.{vue,ts}

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

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

Files:

  • src/extensions/core/previewAny.ts
src/**/*.ts

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

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

Files:

  • src/extensions/core/previewAny.ts
**/*.{ts,tsx,js,jsx,vue}

📄 CodeRabbit inference engine (CLAUDE.md)

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

Files:

  • src/extensions/core/previewAny.ts
**/*.{ts,tsx,vue}

📄 CodeRabbit inference engine (CLAUDE.md)

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

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

Files:

  • src/extensions/core/previewAny.ts
**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

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

Files:

  • src/extensions/core/previewAny.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/extensions/core/previewAny.ts
src/**/*.{vue,ts,tsx}

📄 CodeRabbit inference engine (src/CLAUDE.md)

Follow Vue 3 composition API style guide

Files:

  • src/extensions/core/previewAny.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: playwright-tests-chromium-sharded (7, 8)
  • GitHub Check: playwright-tests-chromium-sharded (8, 8)
  • GitHub Check: playwright-tests-chromium-sharded (6, 8)
  • GitHub Check: playwright-tests-chromium-sharded (2, 8)
  • GitHub Check: playwright-tests-chromium-sharded (5, 8)
  • GitHub Check: playwright-tests-chromium-sharded (3, 8)
  • GitHub Check: playwright-tests-chromium-sharded (4, 8)
  • GitHub Check: playwright-tests-chromium-sharded (1, 8)
  • GitHub Check: playwright-tests (chromium-0.5x)
  • GitHub Check: playwright-tests (mobile-chrome)
  • GitHub Check: playwright-tests (chromium-2x)
🔇 Additional comments (3)
src/extensions/core/previewAny.ts (3)

44-49: LGTM! Toggle logic is correct.

The callback correctly manages visibility for both preview widgets. When Markdown mode is active (value = true), the Markdown widget is shown and plaintext is hidden, and vice versa. Both the hidden property and options.hidden are consistently updated.


73-78: LGTM! Correctly handles multiple preview widgets.

The updated logic properly supports both preview widgets by filtering all widgets named 'preview' and updating each one with the preview text. This ensures both the Markdown and plaintext widgets stay synchronized with the node's output.


39-39: Internationalize user-facing label strings.

The hardcoded strings 'Markdown' and 'Plaintext' violate the i18n coding guideline. User-facing strings should use vue-i18n.

As per coding guidelines, use vue-i18n for string literals and add entries to src/locales/en/main.json. Apply this diff:

-            { label_on: 'Markdown', label_off: 'Plaintext', default: false }
+            { label_on: t('previewAny.labelMarkdown'), label_off: t('previewAny.labelPlaintext'), default: false }

Then add to src/locales/en/main.json:

{
  "previewAny": {
    "labelMarkdown": "Markdown",
    "labelPlaintext": "Plaintext"
  }
}

You'll also need to import useI18n at the top and call const { t } = useI18n() within the function scope.

⛔ Skipped due to learnings
Learnt from: CR
Repo: Comfy-Org/ComfyUI_frontend PR: 0
File: src/CLAUDE.md:0-0
Timestamp: 2025-11-24T19:47:34.324Z
Learning: Applies to src/**/{components,composables}/**/*.{ts,tsx,vue} : Use vue-i18n for ALL user-facing strings by adding them to `src/locales/en/main.json`

AustinMroz
AustinMroz previously approved these changes Dec 2, 2025
Copy link
Collaborator

@AustinMroz AustinMroz left a comment

Choose a reason for hiding this comment

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

Functionality works well.

Some passing concern on the change to how hidden functions. There's a fairly lengthy tail of recommending custom node authors add a widget.computeSize to set the height to -4 when hidden. (This wouldn't quite work here due to the sizing on textAreas). However, I'm reasonably confident this change is safe. I can't think of a time you'd want a widget to be hidden, but still take up space.

@DrJKL
Copy link
Contributor Author

DrJKL commented Dec 2, 2025

Functionality works well.

Some passing concern on the change to how hidden functions. There's a fairly lengthy tail of recommending custom node authors add a widget.computeSize to set the height to -4 when hidden. (This wouldn't quite work here due to the sizing on textAreas). However, I'm reasonably confident this change is safe. I can't think of a time you'd want a widget to be hidden, but still take up space.

Very worth calling out. I'll keep an eye out.

@DrJKL DrJKL enabled auto-merge (squash) December 2, 2025 22:30
@DrJKL DrJKL requested a review from AustinMroz December 2, 2025 22:30
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/renderer/extensions/vueNodes/components/NodeWidgets.vue (1)

19-63: Per-widget template structure and hidden-widget handling look solid; minor optional tweak for data attribute

The move to a <template v-for> with a single guarded wrapper per widget, plus the InputSlot column and widget component in the same grid row, looks correct and matches the grid semantics. The v-if="!widget.simplified.options?.hidden" cleanly removes hidden widgets from layout calculations, which aligns with the PR intent.

If you only need data-is-hidden for debugging or CSS hooks, you might simplify it to a plain boolean instead of a formatted string, e.g.:

-        :data-is-hidden="`hidden: ${widget.simplified.options?.hidden}`"
+        :data-is-hidden="Boolean(widget.simplified.options?.hidden)"

This keeps the attribute value predictable ("true" / "false") while preserving current behavior.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39522fa and e22fd14.

📒 Files selected for processing (1)
  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue (3 hunks)
🧰 Additional context used
📓 Path-based instructions (12)
**/*.vue

📄 CodeRabbit inference engine (.cursorrules)

**/*.vue: Use setup() function for component logic in Vue 3 Composition API
Utilize ref and reactive for reactive state in Vue 3
Implement computed properties with computed() function
Use watch and watchEffect for side effects in Vue 3
Implement lifecycle hooks with onMounted, onUpdated, etc.
Utilize provide/inject for dependency injection in Vue 3
Use Vue 3.5 style of default prop declaration with defineProps()
Organize Vue components in <script> <style> order
Use Tailwind CSS for styling Vue components
Implement responsive design with Tailwind CSS
Do not use deprecated PrimeVue components (Dropdown, OverlayPanel, Calendar, InputSwitch, Sidebar, Chips, TabMenu, Steps, InlineMessage). Use replacements: Select, Popover, DatePicker, ToggleSwitch, Drawer, AutoComplete, Tabs, Stepper, Message respectively
Implement proper props and emits definitions in Vue components
Utilize Vue 3's Teleport component when needed
Use Suspense for async components in Vue 3
Follow Vue 3 style guide and naming conventions
Never use deprecated PrimeVue components (Dropdown, OverlayPanel, Calendar, InputSwitch, Sidebar, Chips, TabMenu, Steps, InlineMessage)

Never use :class="[]" to merge class names - always use import { cn } from '@/utils/tailwindUtil' for class merging in Vue templates

**/*.vue: Use TypeScript with Vue 3 Single File Components (.vue files)
Name Vue components in PascalCase (e.g., MenuHamburger.vue)

Files:

  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
**/*.{vue,ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

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

Files:

  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
**/*.{ts,tsx,js,vue}

📄 CodeRabbit inference engine (.cursorrules)

Implement proper error handling in components and services

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

Files:

  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
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/renderer/extensions/vueNodes/components/NodeWidgets.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/renderer/extensions/vueNodes/components/NodeWidgets.vue
**/*.{ts,tsx,js,jsx,vue}

📄 CodeRabbit inference engine (CLAUDE.md)

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

Files:

  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
**/*.{vue,html}

📄 CodeRabbit inference engine (CLAUDE.md)

Never use dark: or dark-theme: Tailwind variants - instead use semantic values from style.css theme, e.g. bg-node-component-surface

Files:

  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
**/*.{ts,tsx,vue}

📄 CodeRabbit inference engine (CLAUDE.md)

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

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

Files:

  • src/renderer/extensions/vueNodes/components/NodeWidgets.vue
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/components/NodeWidgets.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/components/NodeWidgets.vue
src/**/*.{vue,ts,tsx}

📄 CodeRabbit inference engine (src/CLAUDE.md)

Follow Vue 3 composition API style guide

Files:

  • src/renderer/extensions/vueNodes/components/NodeWidgets.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/components/NodeWidgets.vue
🧠 Learnings (4)
📚 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/renderer/extensions/vueNodes/components/NodeWidgets.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 : Implement computed properties with computed()

Applied to files:

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

Applied to files:

  • src/renderer/extensions/vueNodes/components/NodeWidgets.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/renderer/extensions/vueNodes/components/NodeWidgets.vue
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: setup
  • GitHub Check: collect
  • GitHub Check: test
  • GitHub Check: lint-and-format
🔇 Additional comments (1)
src/renderer/extensions/vueNodes/components/NodeWidgets.vue (1)

139-188: Widget options/slot metadata processing and update handler look correct

The processedWidgets computed mapping looks good:

  • Using shouldRenderAsVue(widget) as a gate and resolving vueComponent via getComponent with a WidgetDOM/WidgetLegacy fallback is consistent with the existing pattern.
  • Destructuring slotMetadata and options, then deriving widgetOptions with disabled: true when slotMetadata?.linked avoids mutating the original widget.options while still enforcing read-only behavior for linked slots.
  • The simplified object construction is straightforward and no longer wrapped in reactive, which matches previous feedback and keeps reactivity anchored on the original widget and widgetOptions.
  • The updateHandler closure mutating widget.value and skipping callbacks for asset widgets preserves the prior behavior.

No changes requested here. This is a clean refinement of the widget processing pipeline.

@DrJKL DrJKL merged commit c263111 into main Dec 2, 2025
26 checks passed
@DrJKL DrJKL deleted the drjkl/preview-plaintext branch December 2, 2025 22:37
Yourz pushed a commit that referenced this pull request Dec 24, 2025
## Summary

Adds a toggle to conditionally render the text as Markdown.

## Also...

Fixes some type issues across our myriad Widget types. We should
probably clean those up.

## Example


https://github.com/user-attachments/assets/24fed943-1e79-4ea4-a962-826b06d68761



This could be a good minimal testcase for dynamic widgets @AustinMroz

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-7102-WIP-Feat-Add-preview-as-plaintext-toggle-for-Preview-As-Text-2bd6d73d3650810c8b25c84866c8875c)
by [Unito](https://www.unito.io)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants