Skip to content

Conversation

Myestery
Copy link
Collaborator

@Myestery Myestery commented Oct 9, 2025

This pull request introduces a new extension API for context menus, allowing extensions to add custom items to canvas and node right-click menus in a standardized and safe way. It also adds a compatibility layer to detect and warn about legacy monkey-patching of menu methods, including extension names in deprecation warnings for easier migration. Comprehensive unit tests are provided to ensure correct behavior and error handling.

Extension API for Context Menus

  • Added new optional methods to the ComfyExtension interface (getCanvasMenuItems and getNodeMenuItems) so extensions can contribute context menu items for canvas and node right-click menus. (src/types/comfy.ts, src/types/comfy.tsR112-R125)
  • Implemented app.collectCanvasMenuItems and app.collectNodeMenuItems methods to aggregate menu items from all loaded extensions, with robust error handling and argument passing. (src/scripts/app.ts, src/scripts/app.tsR1671-R1720)

Legacy Compatibility and Deprecation Warnings

  • Introduced legacyMenuCompat, a compatibility layer that detects legacy monkey-patching of context menu methods, issues deprecation warnings, and tracks which extension performed the patch. Warnings include the extension name when available. (src/lib/litegraph/src/contextMenuCompat.ts, src/composables/useContextMenuTranslation.tsR2-R45)
  • Integrated legacy compatibility tracking into extension setup, ensuring extension names are correctly associated with warnings. (src/services/extensionService.ts, src/services/extensionService.tsL125-R144)

Integration and Testing

┆Issue is synchronized with this Notion page by Unito

Introduces a new extension API that allows extensions to provide context menu items directly, without monkey-patching. This provides a clean, type-safe way for extensions to add menu items.

**New API methods:**
- `getCanvasMenuItems(canvas)`: Add items to canvas right-click menus
- `getNodeMenuItems(node)`: Add items to node right-click menus

**Implementation:**
- Added TypeScript interfaces in `src/types/comfy.ts`
- Added collection methods in `ComfyApp` class
- Comprehensive test coverage for the new API
…extensions

Adds a compatibility layer that detects and supports legacy extensions using the monkey-patching pattern, while warning developers about the deprecated approach.

**Features:**
- Automatic detection of monkey-patched context menu methods
- Console warnings with extension name for deprecated patterns
- Extraction and integration of legacy menu items
- Extension tracking during setup for accurate warnings

**Files:**
- `src/lib/litegraph/src/contextMenuCompat.ts`: Core compatibility logic
- `src/services/extensionService.ts`: Extension name tracking
- `src/composables/useContextMenuTranslation.ts`: Integration layer
- Comprehensive test coverage

Depends on PR #5977 (context menu extension API)
Copy link

github-actions bot commented Oct 9, 2025

🎨 Storybook Build Status

Build completed successfully!

⏰ Completed at: 10/09/2025, 01:30:25 AM UTC

🔗 Links


🎉 Your Storybook is ready for review!

Copy link

github-actions bot commented Oct 9, 2025

🎭 Playwright Test Results

Some tests failed

⏰ Completed at: 10/09/2025, 01:41:57 AM UTC

📈 Summary

  • Total Tests: 484
  • Passed: 447 ✅
  • Failed: 3 ❌
  • Flaky: 4 ⚠️
  • Skipped: 30 ⏭️

📊 Test Reports by Browser

  • chromium: View Report • ✅ 438 / ❌ 3 / ⚠️ 4 / ⏭️ 30
  • 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.

christian-byrne pushed a commit that referenced this pull request Oct 10, 2025
This pull request introduces a new extension API for context menu
customization, allowing extensions to contribute items to both canvas
and node right-click menus. It adds two collection methods to the
`ComfyApp` class to aggregate these menu items from all registered
extensions, and updates the extension interface accordingly.
Comprehensive unit tests are included to verify the correct aggregation
behavior and error handling.

**Extension API for Context Menus:**

* Added optional `getCanvasMenuItems` and `getNodeMenuItems` methods to
the `ComfyExtension` interface, enabling extensions to provide context
menu items for canvas and node right-click menus (`src/types/comfy.ts`).

* Updated type imports to support the new API, including
`IContextMenuValue`, `LGraphCanvas`, and `LGraphNode`
(`src/types/comfy.ts`, `src/scripts/app.ts`).
[[1]](diffhunk://#diff-c29886a1b0c982c6fff3545af0ca8ec269876c2cf3948f867d08c14032c04d66L1-R5)
[[2]](diffhunk://#diff-bde0dce9fe2403685d27b0e94a938c3d72824d02d01d1fd6167a0dddc6e585ddR10)

**Core Implementation:**

* Implemented `collectCanvasMenuItems` and `collectNodeMenuItems`
methods in the `ComfyApp` class to gather menu items from all
extensions, with robust error handling and logging for extension
failures (`src/scripts/app.ts`).

**Testing:**

* Added a comprehensive test suite for the new context menu extension
API, covering aggregation logic, error handling, and integration
scenarios (`tests-ui/tests/extensions/contextMenuExtension.test.ts`).

This is PR 1 of the 3 PRs in the Contextmenu standardizations.
-#5992
-#5993
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant