Skip to content

fix(editor): Use direct store reference for connections in initializeWorkspace (backport to release-candidate/2.14.x) - #27559

Merged
r00gm merged 1 commit into
release-candidate/2.14.xfrom
backport-27552-to-release-candidate/2.14.x
Mar 25, 2026
Merged

r00gm merged 1 commit into
release-candidate/2.14.xfrom
backport-27552-to-release-candidate/2.14.x

Conversation

@n8n-assistant

@n8n-assistant n8n-assistant Bot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Description

Backport of #27552 to release-candidate/2.14.x.

Checklist for the author (@r00gm) to go through.

  • Review the backport changes
  • Fix possible conflicts
  • Merge to target branch

After this PR has been merged, it will be picked up in the next patch release for release track.

Original description

Summary

initializeWorkspace set nodes via the direct initializedDocumentStore reference but set connections via the computed workflowDocumentStore?.value?. After resetWorkspace() clears workflowId to '', the computed evaluates to undefined and setConnections is silently skipped — so no connections are loaded.

This broke the workflow preview (used on n8n.io) for all workflows, most visibly for AI agent nodes whose shape depends on sub-node connections (model, memory, tool). Without connections, the agent renders as a plain square instead of a wide rectangle with input slots.

The fix uses initializedDocumentStore consistently for both setNodes and setConnections, matching the direct reference already returned by initState.

Regression introduced in: #27280

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/ADO-4999

Review / Merge checklist

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Architecture diagram
sequenceDiagram
    participant UI as Editor UI
    participant Ops as useCanvasOperations
    participant WfStore as Workflows Store
    participant DocStore as Workflow Document Store

    Note over UI, DocStore: Workspace Initialization (e.g. Loading a Workflow or Preview)

    UI->>Ops: initializeWorkspace(workflowData)
    
    Ops->>WfStore: Check current workflow ID
    Note right of WfStore: If resetWorkspace() was called, ID is ""

    Ops->>DocStore: useWorkflowDocumentStore(workflowData.id)
    DocStore-->>Ops: initializedDocumentStore (Direct Reference)

    Ops->>DocStore: setNodes(workflowData.nodes)

    alt Connection Handling
        Note over Ops, DocStore: Fix: Avoid dependency on reactive 'workflowId' computed property
        Ops->>DocStore: CHANGED: setConnections(workflowData.connections)
        Note right of Ops: Now uses the 'initializedDocumentStore' reference directly
    end

    Ops->>WfStore: Update global workflow metadata (ID, name, etc.)
    
    Note over Ops, DocStore: UI components (like AI Agents) now render with correct input slots
    
    Ops-->>UI: return { workflowDocumentStore }
Loading

@r00gm
r00gm enabled auto-merge (squash) March 25, 2026 12:52
@codecov

codecov Bot commented Mar 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@r00gm
r00gm disabled auto-merge March 25, 2026 14:31
@r00gm
r00gm enabled auto-merge (squash) March 25, 2026 14:31
@r00gm
r00gm merged commit 07dc87d into release-candidate/2.14.x Mar 25, 2026
78 of 80 checks passed
@r00gm
r00gm deleted the backport-27552-to-release-candidate/2.14.x branch March 25, 2026 14:32
@n8n-assistant n8n-assistant Bot mentioned this pull request Mar 26, 2026
@n8n-assistant

n8n-assistant Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor Author

Got released with n8n@2.14.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant