From 2beb335b7884f6888823ddfe9ddb22db3052fefb Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Mon, 5 Oct 2026 08:41:50 +0000 Subject: [PATCH 1/5] refactor: remove parallel agent node selection state Amp-Thread-ID: https://ampcode.com/threads/T-01a10aac-36b3-7537-bf2d-fa1ddfcee328 --- ...TION-0040-composer-owns-node-references.md | 56 ++++ docs/adr/README.md | 1 + .../LiteGraphCanvasSplitterOverlay.test.ts | 6 +- .../LiteGraphCanvasSplitterOverlay.vue | 12 +- src/components/TopMenuSection.test.ts | 12 +- src/components/TopMenuSection.vue | 8 +- src/components/builder/VueNodeSwitchPopup.vue | 8 +- src/components/graph/DomWidgets.test.ts | 3 +- src/components/graph/DomWidgets.vue | 4 +- src/components/graph/GraphCanvas.vue | 20 +- .../graph/NodeSelectionModeBanner.test.ts | 27 +- .../graph/NodeSelectionModeBanner.vue | 18 +- .../helpcenter/HelpCenterPopups.test.ts | 42 +++ .../helpcenter/HelpCenterPopups.vue | 3 + src/components/sidebar/SideToolbar.vue | 4 +- src/components/toast/GlobalToast.test.ts | 32 +-- src/components/toast/GlobalToast.vue | 8 +- src/extensions/core/agentPanel.test.ts | 264 ++++++------------ src/extensions/core/agentPanel.ts | 64 ++--- .../composables/useLitegraphSettings.test.ts | 8 +- .../composables/useLitegraphSettings.ts | 4 +- .../ReleaseNotificationToast.test.ts | 14 - .../components/ReleaseNotificationToast.vue | 9 +- .../canvas/canvasStore.nodePicking.test.ts | 90 ++++++ src/renderer/core/canvas/canvasStore.ts | 30 +- .../interaction/canvasInteractionMode.test.ts | 4 +- .../interaction/canvasInteractionMode.ts | 6 +- src/stores/agentNodeSelectionStore.test.ts | 255 ----------------- src/stores/agentNodeSelectionStore.ts | 189 ------------- .../extensions/agent/AgentPanelRoot.test.ts | 88 ++---- .../extensions/agent/AgentPanelRoot.vue | 110 ++------ .../composables/agent/useCanvasSelection.ts | 5 +- 32 files changed, 462 insertions(+), 942 deletions(-) create mode 100644 docs/adr/AGENT-SELECTION-0040-composer-owns-node-references.md create mode 100644 src/components/helpcenter/HelpCenterPopups.test.ts create mode 100644 src/renderer/core/canvas/canvasStore.nodePicking.test.ts delete mode 100644 src/stores/agentNodeSelectionStore.test.ts delete mode 100644 src/stores/agentNodeSelectionStore.ts diff --git a/docs/adr/AGENT-SELECTION-0040-composer-owns-node-references.md b/docs/adr/AGENT-SELECTION-0040-composer-owns-node-references.md new file mode 100644 index 00000000000..827897647cb --- /dev/null +++ b/docs/adr/AGENT-SELECTION-0040-composer-owns-node-references.md @@ -0,0 +1,56 @@ +# ADR-AGENT-SELECTION-0040: Composer Owns Node References + +Date: 2026-10-05 + +## Status + +Proposed + +## Context + +Canvas selection and prompt references have different lifetimes. A reference +can outlive picking, panel closure, or a graph reload. Keeping another copy +in `agentNodeSelectionStore`, keyed by workflow path, required a restore +handshake with canvas selection and broke when a workflow was renamed. + +## Decision + +Use `agentComposerStore` as the only owner of draft node references. Scope +them by the workflow's session-stable `instanceId`, not its mutable path. +After a graph load, revalidate matching references against the root graph, +including subgraph locators, without restoring canvas selection. + +Keep transient picking state in `canvasStore`. The existing injected +interaction-mode reader continues to enforce select-only behavior. Stop +tracking before deselecting so exiting does not erase prompt references. +The banner owns Escape; presentation derives visibility without changing +minimap or sidebar preferences. + +This replaces the store ownership specified in +[ADR-CANVAS-INTERACTION-0035](CANVAS-INTERACTION-0035-agent-node-picking-policy.md), +not its input guards. Canvas selection remains owned as specified in +[ADR-CANVAS-SELECTION-0028](CANVAS-SELECTION-0028-single-selection-store.md). + +## Alternatives considered + +- Repair path-key migration in the old store. This fixes rename but keeps + two writable copies of draft references and the restore handshake. +- Use canvas selection as the draft. This loses references when selection + is cleared or the visible graph changes. +- Keep a separate picker store. After removing persistence and preference + restoration, its remaining state belongs to the existing canvas owner. + +## Consequences + +### Positive + +- Rename and graph reload no longer require a parallel reference cache. +- Closing the panel does not prevent reference revalidation. +- Picking does not write user preferences that later need restoration. + +### Negative + +- Graph-load integration still needs to know which workflow owns the draft. +- The minimap remains hidden throughout picking, even if its preference is + toggled; the current preference takes effect when picking ends. +- `instanceId` is a session identity, not a cross-reload persistence key. diff --git a/docs/adr/README.md b/docs/adr/README.md index a39c07929ea..64f74e27647 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -14,6 +14,7 @@ An Architecture Decision Record captures an important architectural decision mad | [AGENT-CONTEXT-0028](AGENT-CONTEXT-0028-separate-workflow-references-from-editor-tabs.md) | Separate Workflow References from Editor Tabs | Proposed | 2026-09-07 | | [AGENT-HISTORY-0038](AGENT-HISTORY-0038-wait-for-chat-and-workflow-readiness.md) | Wait for Chat and Workflow Readiness | Proposed | 2026-09-25 | | [AGENT-OBSERVABILITY-0034](AGENT-OBSERVABILITY-0034-frontend-journey-effect-contract.md) | Frontend Journey Effect Contract | Proposed | 2026-09-17 | +| [AGENT-SELECTION-0040](AGENT-SELECTION-0040-composer-owns-node-references.md) | Composer Owns Node References | Proposed | 2026-10-05 | | [AGENT-SESSION-0028](AGENT-SESSION-0028-compose-turn-origin-and-account-generation.md) | Compose Turn Origin and Account Generation | Proposed | 2026-09-05 | | [AGENT-TARGET-0037](AGENT-TARGET-0037-commit-workflow-target-on-send-or-node-reference.md) | Commit Workflow Target on Explicit User Intent | Proposed | 2026-09-24 | | [ASSETS-DRAG-DROP-0035](ASSETS-DRAG-DROP-0035-asset-card-drag-uses-file-url.md) | Asset Card Drag-and-Drop Uses the File URL, Never the Preview URL | Proposed | 2026-09-19 | diff --git a/src/components/LiteGraphCanvasSplitterOverlay.test.ts b/src/components/LiteGraphCanvasSplitterOverlay.test.ts index 6b0fa762dc0..d916f3cb9e7 100644 --- a/src/components/LiteGraphCanvasSplitterOverlay.test.ts +++ b/src/components/LiteGraphCanvasSplitterOverlay.test.ts @@ -8,7 +8,7 @@ import { createI18n } from 'vue-i18n' import LiteGraphCanvasSplitterOverlay from '@/components/LiteGraphCanvasSplitterOverlay.vue' import { useSettingStore } from '@/platform/settings/settingStore' -import { useAgentNodeSelectionStore } from '@/stores/agentNodeSelectionStore' +import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' import { useAgentPanelStore } from '@/workbench/extensions/agent/stores/agent/agentPanelStore' import { useBottomPanelStore } from '@/stores/workspace/bottomPanelStore' import { useSidebarTabStore } from '@/stores/workspace/sidebarTabStore' @@ -101,7 +101,7 @@ describe('LiteGraphCanvasSplitterOverlay', () => { expect(screen.getByTestId('right-panel')).toBeInTheDocument() expect(screen.getByTestId('bottom-panel')).toBeInTheDocument() - useAgentNodeSelectionStore().enter() + useCanvasStore().isPickingNodes = true await nextTick() expect(screen.getByTestId('workflow-tabs')).toBeInTheDocument() @@ -112,7 +112,7 @@ describe('LiteGraphCanvasSplitterOverlay', () => { expect(screen.getByTestId('graph')).toBeInTheDocument() expect(screen.getByTestId('agent-panel')).toBeInTheDocument() - useAgentNodeSelectionStore().exit() + useCanvasStore().stopNodePicking() await nextTick() expect(screen.getByTestId('topmenu')).toBeInTheDocument() diff --git a/src/components/LiteGraphCanvasSplitterOverlay.vue b/src/components/LiteGraphCanvasSplitterOverlay.vue index 65a8bd961b2..d37c2bd0f71 100644 --- a/src/components/LiteGraphCanvasSplitterOverlay.vue +++ b/src/components/LiteGraphCanvasSplitterOverlay.vue @@ -173,7 +173,7 @@ import { SIDE_TOOLBAR_WIDTH } from '@/constants/splitterConstants' import { useSettingStore } from '@/platform/settings/settingStore' -import { useAgentNodeSelectionStore } from '@/stores/agentNodeSelectionStore' +import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' import { useBottomPanelStore } from '@/stores/workspace/bottomPanelStore' import { useRightSidePanelStore } from '@/stores/workspace/rightSidePanelStore' import { useSidebarTabStore } from '@/stores/workspace/sidebarTabStore' @@ -196,9 +196,8 @@ const unifiedWidth = computed(() => ) const { focusMode } = storeToRefs(workspaceStore) -const { isActive: agentNodeSelectionActive } = storeToRefs( - useAgentNodeSelectionStore() -) +const { isPickingNodes: agentNodeSelectionActive } = + storeToRefs(useCanvasStore()) const { isSelectMode, isBuilderMode } = useAppMode() const { activeSidebarTabId, activeSidebarTab } = storeToRefs(sidebarTabStore) @@ -233,7 +232,10 @@ const graphMeetsAgentPanel = computed( ) const sidebarPanelVisible = computed( - () => activeSidebarTab.value !== null && !isBuilderMode.value + () => + activeSidebarTab.value !== null && + !isBuilderMode.value && + !agentNodeSelectionActive.value ) /** diff --git a/src/components/TopMenuSection.test.ts b/src/components/TopMenuSection.test.ts index e1eff2d33a4..52c4792a422 100644 --- a/src/components/TopMenuSection.test.ts +++ b/src/components/TopMenuSection.test.ts @@ -29,7 +29,7 @@ import type { } from '@/platform/remote/comfyui/jobs/jobTypes' import { useSettingStore } from '@/platform/settings/settingStore' import { useReleaseStore } from '@/platform/updates/common/releaseStore' -import { useAgentNodeSelectionStore } from '@/stores/agentNodeSelectionStore' +import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' import { useCommandStore } from '@/stores/commandStore' import { useExecutionStore } from '@/stores/executionStore' import { TaskItemImpl, useQueueStore } from '@/stores/queueStore' @@ -252,7 +252,7 @@ describe('TopMenuSection', () => { it('keeps action bars mounted while hiding the error overlay in node selection mode', () => { const pinia = getActivePinia()! - useAgentNodeSelectionStore(pinia).isActionBarsHidden = true + useCanvasStore(pinia).isPickingNodes = true createWrapper({ pinia, @@ -401,7 +401,7 @@ describe('TopMenuSection', () => { it('does not render inline progress summary while action bars are hidden', async () => { const pinia = getActivePinia()! configureSettings(pinia, true) - useAgentNodeSelectionStore(pinia).isActionBarsHidden = true + useCanvasStore(pinia).isPickingNodes = true const { container } = createWrapper({ pinia }) @@ -475,8 +475,7 @@ describe('TopMenuSection', () => { async ({ isActionBarsHidden, rendered }) => { const pinia = getActivePinia()! configureSettings(pinia, false) - useAgentNodeSelectionStore(pinia).isActionBarsHidden = - isActionBarsHidden + useCanvasStore(pinia).isPickingNodes = isActionBarsHidden const { container } = createWrapper({ pinia }) await nextTick() @@ -495,8 +494,7 @@ describe('TopMenuSection', () => { async ({ isActionBarsHidden, hidden }) => { const pinia = getActivePinia()! configureSettings(pinia, false) - useAgentNodeSelectionStore(pinia).isActionBarsHidden = - isActionBarsHidden + useCanvasStore(pinia).isPickingNodes = isActionBarsHidden const { container } = createWrapper({ pinia }) await nextTick() diff --git a/src/components/TopMenuSection.vue b/src/components/TopMenuSection.vue index 197c025df34..1dff21f9b10 100644 --- a/src/components/TopMenuSection.vue +++ b/src/components/TopMenuSection.vue @@ -188,7 +188,7 @@ import { useSettingStore } from '@/platform/settings/settingStore' import { useTelemetry } from '@/platform/telemetry' import { app } from '@/scripts/app' import { useExecutionErrorStore } from '@/stores/executionErrorStore' -import { useAgentNodeSelectionStore } from '@/stores/agentNodeSelectionStore' +import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' import { useActionBarButtonStore } from '@/stores/actionBarButtonStore' import { useQueueUIStore } from '@/stores/queueStore' import { useRightSidePanelStore } from '@/stores/workspace/rightSidePanelStore' @@ -208,10 +208,8 @@ import { cn } from '@comfyorg/tailwind-utils' const settingStore = useSettingStore() const workspaceStore = useWorkspaceStore() const rightSidePanelStore = useRightSidePanelStore() -const agentNodeSelectionStore = useAgentNodeSelectionStore() -const isActionBarsHidden = computed( - () => agentNodeSelectionStore.isActionBarsHidden -) +const canvasStore = useCanvasStore() +const isActionBarsHidden = computed(() => canvasStore.isPickingNodes) const managerState = useManagerState() const managerSurveyDialog = useManagerSurveyDialog() const { flags } = useFeatureFlags() diff --git a/src/components/builder/VueNodeSwitchPopup.vue b/src/components/builder/VueNodeSwitchPopup.vue index 3c51d6521c0..6b4619fc2fc 100644 --- a/src/components/builder/VueNodeSwitchPopup.vue +++ b/src/components/builder/VueNodeSwitchPopup.vue @@ -1,8 +1,6 @@