From 3b3df250cdb89073cfa4b1e8734a0a4ffac9815c Mon Sep 17 00:00:00 2001 From: bymyself Date: Tue, 18 Feb 2025 09:39:43 -0700 Subject: [PATCH] Add refresh button to selecton toolbox (#2612) --- browser_tests/remoteWidgets.spec.ts | 17 ++++++ browser_tests/selectionToolbox.spec.ts | 12 +++++ src/components/graph/SelectionToolbox.vue | 9 ++++ src/composables/useRefreshableSelection.ts | 61 ++++++++++++++++++++++ src/composables/widgets/useRemoteWidget.ts | 15 ++++-- src/types/litegraph-augmentation.d.ts | 5 ++ 6 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 src/composables/useRefreshableSelection.ts diff --git a/browser_tests/remoteWidgets.spec.ts b/browser_tests/remoteWidgets.spec.ts index 285570fd9..972a8ffde 100644 --- a/browser_tests/remoteWidgets.spec.ts +++ b/browser_tests/remoteWidgets.spec.ts @@ -176,6 +176,23 @@ test.describe('Remote COMBO Widget', () => { }) test.describe('Refresh Behavior', () => { + test('refresh button is visible in selection toolbar when node is selected', async ({ + comfyPage + }) => { + await comfyPage.setSetting('Comfy.Canvas.SelectionToolbox', true) + + const nodeName = 'Remote Widget Node' + await addRemoteWidgetNode(comfyPage, nodeName) + await waitForWidgetUpdate(comfyPage) + + // Select remote widget node + await comfyPage.page.keyboard.press('Control+A') + + await expect( + comfyPage.page.locator('.selection-toolbox .pi-refresh') + ).toBeVisible() + }) + test('refreshes options when TTL expires', async ({ comfyPage }) => { // Fulfill each request with a unique timestamp await comfyPage.page.route( diff --git a/browser_tests/selectionToolbox.spec.ts b/browser_tests/selectionToolbox.spec.ts index db47f9bd1..6bd1a87e3 100644 --- a/browser_tests/selectionToolbox.spec.ts +++ b/browser_tests/selectionToolbox.spec.ts @@ -57,4 +57,16 @@ test.describe('Selection Toolbox', () => { comfyPage.page.locator('.selection-overlay-container.show-border') ).not.toBeVisible() }) + + test('displays refresh button in toolbox when all nodes are selected', async ({ + comfyPage + }) => { + // Select all nodes + await comfyPage.page.focus('canvas') + await comfyPage.page.keyboard.press('Control+A') + + await expect( + comfyPage.page.locator('.selection-toolbox .pi-refresh') + ).toBeVisible() + }) }) diff --git a/src/components/graph/SelectionToolbox.vue b/src/components/graph/SelectionToolbox.vue index 9f2f3c39f..ead0fde8e 100644 --- a/src/components/graph/SelectionToolbox.vue +++ b/src/components/graph/SelectionToolbox.vue @@ -18,6 +18,13 @@ icon="pi pi-trash" @click="() => commandStore.execute('Comfy.Canvas.DeleteSelectedItems')" /> +