-
Notifications
You must be signed in to change notification settings - Fork 378
Contextmenu legacy compat #5992
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
Draft
Myestery
wants to merge
2
commits into
main
Choose a base branch
from
contextmenu-legacy-compat
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+816
−3
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)
🎨 Storybook Build Status✅ Build completed successfully! ⏰ Completed at: 10/09/2025, 01:30:25 AM UTC 🔗 Links🎉 Your Storybook is ready for review! |
🎭 Playwright Test Results❌ Some tests failed ⏰ Completed at: 10/09/2025, 01:41:57 AM UTC 📈 Summary
📊 Test Reports by Browser
🎉 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
ComfyExtension
interface (getCanvasMenuItems
andgetNodeMenuItems
) so extensions can contribute context menu items for canvas and node right-click menus. (src/types/comfy.ts
, src/types/comfy.tsR112-R125)app.collectCanvasMenuItems
andapp.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
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)src/services/extensionService.ts
, src/services/extensionService.tsL125-R144)Integration and Testing
src/composables/useContextMenuTranslation.ts
, src/composables/useContextMenuTranslation.tsR2-R45)tests-ui/tests/extensions/contextMenuExtension.test.ts
, tests-ui/tests/extensions/contextMenuExtension.test.tsR1-R303)tests-ui/tests/extensions/contextMenuExtensionName.test.ts
, tests-ui/tests/extensions/contextMenuExtensionName.test.tsR1-R65)┆Issue is synchronized with this Notion page by Unito