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

improvement: auto-focus canvas on newly added nodes#392

Merged
breaking-brake merged 1 commit intomainbreaking-brake/cc-wf-studio:mainfrom
improvement/auto-focus-on-added-nodebreaking-brake/cc-wf-studio:improvement/auto-focus-on-added-nodeCopy head branch name to clipboard
Jan 6, 2026
Merged

improvement: auto-focus canvas on newly added nodes#392
breaking-brake merged 1 commit intomainbreaking-brake/cc-wf-studio:mainfrom
improvement/auto-focus-on-added-nodebreaking-brake/cc-wf-studio:improvement/auto-focus-on-added-nodeCopy head branch name to clipboard

Conversation

@breaking-brake
Copy link
Copy Markdown
Owner

Problem

When adding a node to the canvas, users cannot easily locate the newly added node, especially when:

  • The canvas is zoomed out
  • The canvas is panned to a different area
  • Multiple nodes already exist on the canvas

Current Behavior

  1. User clicks a node type in NodePalette
  2. ❌ Node is added at a calculated position, but canvas doesn't move
  3. ❌ User must manually search for the new node

Expected Behavior

  1. User clicks a node type in NodePalette
  2. ✅ Node is added and canvas automatically pans to show the new node
  3. ✅ Node is selected and property panel opens

Solution

Implement auto-focus functionality using React Flow's setCenter() method with smooth animation.

Changes

New File: src/webview/src/hooks/useAutoFocusNode.ts

  • Custom hook that watches lastAddedNodeId state
  • Uses React Flow's setCenter() with 300ms animation
  • Preserves current zoom level

File: src/webview/src/main.tsx

  • Wrap App with ReactFlowProvider to enable useReactFlow() hook

File: src/webview/src/stores/workflow-store.ts

  • Add lastAddedNodeId state tracking
  • Modify addNode() to set lastAddedNodeId, auto-select node, and open property panel
  • Add clearLastAddedNodeId() action

File: src/webview/src/components/WorkflowEditor.tsx

  • Use useAutoFocusNode hook

File: src/webview/src/components/dialogs/SubAgentFlowDialog.tsx

  • Use useAutoFocusNode hook for SubAgentFlow editing

Impact

  • Improved UX: Users can immediately see newly added nodes
  • No breaking changes
  • Works for all node addition methods (NodePalette, MCP dialog, Skill dialog)

Testing

  • Manual E2E testing completed
    • Add node from NodePalette → canvas pans to node
    • Add node in SubAgentFlow dialog → canvas pans to node
    • Zoom level preserved after pan
    • Rapid node additions → focuses on last node
  • Code quality checks passed (npm run format && npm run lint && npm run check)
  • Build succeeded (npm run build)

🤖 Generated with Claude Code

- Add ReactFlowProvider wrapper in main.tsx
- Track lastAddedNodeId in workflow-store
- Create useAutoFocusNode hook with setCenter animation
- Apply to both WorkflowEditor and SubAgentFlowDialog

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@breaking-brake breaking-brake merged commit 7c1856c into main Jan 6, 2026
3 checks passed
@breaking-brake breaking-brake deleted the improvement/auto-focus-on-added-node branch January 6, 2026 12:13
@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.8](v3.12.7...v3.12.8) (2026-01-06)

### Bug Fixes

* handle multiple JSON blocks in AI response parsing ([#393](#393)) ([29c01bf](29c01bf))

### Improvements

* add node name constraint to AI refinement prompts ([#394](#394)) ([055d254](055d254))
* auto-focus canvas on newly added nodes ([#392](#392)) ([7c1856c](7c1856c))
@braking-brake-semantic-release
Copy link
Copy Markdown

🎉 This PR is included in version 3.12.8 🎉

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.

1 participant

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