Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix: sync activeWorkflow with canvas changes for AI refinement#390

Merged
breaking-brake merged 1 commit intomainbreaking-brake/cc-wf-studio:mainfrom
fix/388-sync-activeWorkflow-with-canvasbreaking-brake/cc-wf-studio:fix/388-sync-activeWorkflow-with-canvasCopy head branch name to clipboard
Jan 6, 2026
Merged

fix: sync activeWorkflow with canvas changes for AI refinement#390
breaking-brake merged 1 commit intomainbreaking-brake/cc-wf-studio:mainfrom
fix/388-sync-activeWorkflow-with-canvasbreaking-brake/cc-wf-studio:fix/388-sync-activeWorkflow-with-canvasCopy head branch name to clipboard

Conversation

@breaking-brake
Copy link
Copy Markdown
Owner

Problem

When the AI Refinement panel is open and users modify the canvas (add/remove/edit nodes), the AI receives stale workflow information from when the panel was opened.

Current Behavior

  1. User opens AI Refinement panel
  2. User modifies canvas (e.g., adds a node)
  3. User asks AI to refine workflow
  4. ❌ AI sees the old workflow state, not the current canvas

Expected Behavior

  1. User opens AI Refinement panel
  2. User modifies canvas (e.g., adds a node)
  3. User asks AI to refine workflow
  4. ✅ AI sees the current canvas state

Root Cause

nodes/edges and activeWorkflow are two independent state sources. Canvas modifications update nodes/edges, but activeWorkflow remains stale. The AI refinement feature reads from activeWorkflow, not directly from nodes/edges.

Solution

Add a useEffect in App.tsx that synchronizes activeWorkflow whenever nodes or edges change. This follows the same pattern as #384 (conversation history sync).

Key Implementation Details

  • Uses useRef to track previous nodes/edges references to prevent unnecessary updates
  • Uses updateActiveWorkflowMetadata instead of setActiveWorkflow to avoid infinite loops (the latter also updates nodes/edges, which would trigger the effect again)
  • Preserves the original workflow ID during serialization

Changes

File: src/webview/src/App.tsx

  • Added serializeWorkflow import
  • Added nodes, edges, workflowName, workflowDescription, subAgentFlows to store destructuring
  • Added useEffect hook to sync canvas changes to activeWorkflow
// Issue #388: Sync activeWorkflow when canvas (nodes/edges) changes
const prevNodesRef = useRef(nodes);
const prevEdgesRef = useRef(edges);
useEffect(() => {
  if (nodes === prevNodesRef.current && edges === prevEdgesRef.current) {
    return;
  }
  prevNodesRef.current = nodes;
  prevEdgesRef.current = edges;

  if (activeWorkflow && nodes.length > 0) {
    const workflow = serializeWorkflow(
      nodes, edges, workflowName || 'Untitled',
      workflowDescription, activeWorkflow.conversationHistory, subAgentFlows
    );
    workflow.id = activeWorkflow.id;
    updateActiveWorkflowMetadata(workflow);
  }
}, [nodes, edges, workflowName, workflowDescription, subAgentFlows, activeWorkflow, updateActiveWorkflowMetadata]);

Impact

  • UX: AI refinement now always sees the current canvas state
  • Breaking changes: None
  • Performance: Minimal - uses reference comparison to skip unnecessary serialization

Testing

  • Manual E2E testing completed
    • Open refinement panel → modify canvas → ask AI → AI sees current state ✅
    • No infinite loops ✅
  • Code quality checks passed (npm run format && npm run lint && npm run check)
  • Build passed (npm run build)

Related

🤖 Generated with Claude Code

- Added useEffect to update activeWorkflow when nodes/edges change
- Ensures AI refinement always sees current canvas state
- Uses updateActiveWorkflowMetadata to avoid infinite loop

Fixes #388
@breaking-brake breaking-brake merged commit 08947d7 into main Jan 6, 2026
3 checks passed
@breaking-brake breaking-brake deleted the fix/388-sync-activeWorkflow-with-canvas branch January 6, 2026 07:33
@breaking-brake breaking-brake mentioned this pull request Jan 6, 2026
braking-brake-semantic-release Bot pushed a commit that referenced this pull request Jan 6, 2026
## [3.12.7](v3.12.6...v3.12.7) (2026-01-06)

### Bug Fixes

* sync activeWorkflow with canvas changes for AI refinement ([#390](#390)) ([08947d7](08947d7)), closes [#388](#388)
* sync conversation history to workflow-store on every change ([#387](#387)) ([d1cf8a4](d1cf8a4)), closes [#384](#384)
@braking-brake-semantic-release
Copy link
Copy Markdown

🎉 This PR is included in version 3.12.7 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI Refinement: Canvas changes while panel is open are not reflected in AI context

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.