From bbf7b4801cab4ae59613244ccb869bbf27b920a7 Mon Sep 17 00:00:00 2001 From: Comfy Org PR Bot Date: Tue, 12 Aug 2025 02:45:53 +0800 Subject: [PATCH] [backport 1.25] [feat] Make hotkey for exiting subgraphs configurable in user keybindings (#4914) Co-authored-by: Christian Byrne Co-authored-by: github-actions --- browser_tests/tests/subgraph.spec.ts | 99 +++++++++ .../breadcrumb/SubgraphBreadcrumb.vue | 13 -- src/composables/useCoreCommands.ts | 16 ++ src/constants/coreKeybindings.ts | 6 + src/locales/en/commands.json | 3 + src/locales/en/main.json | 1 + src/locales/es/commands.json | 3 + src/locales/es/main.json | 1 + src/locales/fr/commands.json | 3 + src/locales/fr/main.json | 1 + src/locales/ja/commands.json | 3 + src/locales/ja/main.json | 1 + src/locales/ko/commands.json | 3 + src/locales/ko/main.json | 1 + src/locales/ru/commands.json | 3 + src/locales/ru/main.json | 1 + src/locales/zh-TW/commands.json | 3 + src/locales/zh-TW/main.json | 1 + src/locales/zh/commands.json | 3 + src/locales/zh/main.json | 1 + src/services/keybindingService.ts | 15 ++ .../services/keybindingService.escape.test.ts | 202 ++++++++++++++++++ 22 files changed, 370 insertions(+), 13 deletions(-) create mode 100644 tests-ui/tests/services/keybindingService.escape.test.ts diff --git a/browser_tests/tests/subgraph.spec.ts b/browser_tests/tests/subgraph.spec.ts index 1c9c8d97b..fb9543e66 100644 --- a/browser_tests/tests/subgraph.spec.ts +++ b/browser_tests/tests/subgraph.spec.ts @@ -528,4 +528,103 @@ test.describe('Subgraph Operations', () => { expect(finalCount).toBe(parentCount) }) }) + + test.describe('Navigation Hotkeys', () => { + test.beforeEach(async ({ comfyPage }) => { + await comfyPage.setSetting('Comfy.UseNewMenu', 'Top') + }) + + test('Navigation hotkey can be customized', async ({ comfyPage }) => { + await comfyPage.loadWorkflow('basic-subgraph') + await comfyPage.nextFrame() + + // Change the Exit Subgraph keybinding from Escape to Alt+Q + await comfyPage.setSetting('Comfy.Keybinding.NewBindings', [ + { + commandId: 'Comfy.Graph.ExitSubgraph', + combo: { + key: 'q', + ctrl: false, + alt: true, + shift: false + } + } + ]) + + await comfyPage.setSetting('Comfy.Keybinding.UnsetBindings', [ + { + commandId: 'Comfy.Graph.ExitSubgraph', + combo: { + key: 'Escape', + ctrl: false, + alt: false, + shift: false + } + } + ]) + + // Reload the page + await comfyPage.page.reload() + await comfyPage.page.waitForTimeout(1024) + + // Navigate into subgraph + const subgraphNode = await comfyPage.getNodeRefById('2') + await subgraphNode.navigateIntoSubgraph() + await comfyPage.page.waitForSelector(SELECTORS.breadcrumb) + + // Verify we're in a subgraph + expect(await isInSubgraph(comfyPage)).toBe(true) + + // Test that Escape no longer exits subgraph + await comfyPage.page.keyboard.press('Escape') + await comfyPage.nextFrame() + if (!(await isInSubgraph(comfyPage))) { + throw new Error('Not in subgraph') + } + + // Test that Alt+Q now exits subgraph + await comfyPage.page.keyboard.press('Alt+q') + await comfyPage.nextFrame() + expect(await isInSubgraph(comfyPage)).toBe(false) + }) + + test('Escape prioritizes closing dialogs over exiting subgraph', async ({ + comfyPage + }) => { + await comfyPage.loadWorkflow('basic-subgraph') + await comfyPage.nextFrame() + + const subgraphNode = await comfyPage.getNodeRefById('2') + await subgraphNode.navigateIntoSubgraph() + await comfyPage.page.waitForSelector(SELECTORS.breadcrumb) + + // Verify we're in a subgraph + if (!(await isInSubgraph(comfyPage))) { + throw new Error('Not in subgraph') + } + + // Open settings dialog using hotkey + await comfyPage.page.keyboard.press('Control+,') + await comfyPage.page.waitForSelector('.settings-container', { + state: 'visible' + }) + + // Press Escape - should close dialog, not exit subgraph + await comfyPage.page.keyboard.press('Escape') + await comfyPage.nextFrame() + + // Dialog should be closed + await expect( + comfyPage.page.locator('.settings-container') + ).not.toBeVisible() + + // Should still be in subgraph + expect(await isInSubgraph(comfyPage)).toBe(true) + + // Press Escape again - now should exit subgraph + await comfyPage.page.keyboard.press('Escape') + await comfyPage.nextFrame() + expect(await isInSubgraph(comfyPage)).toBe(false) + }) + }) }) diff --git a/src/components/breadcrumb/SubgraphBreadcrumb.vue b/src/components/breadcrumb/SubgraphBreadcrumb.vue index 83bec7ffd..cd34babab 100644 --- a/src/components/breadcrumb/SubgraphBreadcrumb.vue +++ b/src/components/breadcrumb/SubgraphBreadcrumb.vue @@ -32,7 +32,6 @@