Skip to content

Conversation

@emir-karabeg
Copy link
Collaborator

Summary

  • Copilot: workflow pan on copilot change

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

Solo.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 29, 2026 0:20am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 29, 2026

Greptile Overview

Greptile Summary

This PR fixes workflow viewport panning when copilot makes changes. The key improvements:

  • Track seen blocks: Changed from tracking diff ready state transitions to tracking which blocks have been seen, ensuring panning only occurs for newly changed blocks in multi-turn conversations
  • Use absolute positions: Correctly converts node positions to absolute coordinates before panning, fixing issues where blocks inside subflows (which have relative positions) would cause incorrect viewport calculations
  • Simplified logic: Removed the two-phase approach (tracking ready state + checking nodes) in favor of a cleaner pattern that queues new blocks and pans once they have valid dimensions

The implementation correctly handles:

  • Multi-turn copilot conversations (only pans to new blocks)
  • Nested blocks in subflows (uses getNodeAbsolutePosition)
  • Diff cleared/rejected (resets tracking state)
  • Nodes not yet rendered (waits for valid dimensions)

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-contained, logically sound, and fix a specific bug. The implementation correctly handles edge cases (subflows, multi-turn conversations, dimension checks) and follows established patterns in the codebase.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx Fixed viewport panning for copilot changes by tracking seen blocks and using absolute positions

Sequence Diagram

sequenceDiagram
    participant Copilot
    participant UseEffect1 as Queue Effect
    participant SeenRef as seenDiffBlocksRef
    participant PendingRef as pendingZoomBlockIdsRef
    participant UseEffect2 as Pan Effect
    participant Utils as getNodeAbsolutePosition
    participant Viewport as fitViewToBounds

    Copilot->>UseEffect1: diffAnalysis updates (new_blocks: [block1])
    UseEffect1->>SeenRef: Check if block1 seen
    SeenRef-->>UseEffect1: Not seen
    UseEffect1->>SeenRef: Add block1
    UseEffect1->>PendingRef: Set {block1}
    
    UseEffect2->>PendingRef: Check pending blocks
    PendingRef-->>UseEffect2: {block1}
    UseEffect2->>UseEffect2: Verify block1 has dimensions
    UseEffect2->>Utils: getNodeAbsolutePosition(block1)
    Utils-->>UseEffect2: Absolute position
    UseEffect2->>Viewport: Pan to block1 (absolute coords)
    UseEffect2->>PendingRef: Clear pending
    
    Note over Copilot: User accepts, copilot makes more changes
    
    Copilot->>UseEffect1: diffAnalysis updates (new_blocks: [block2])
    UseEffect1->>SeenRef: Check if block2 seen
    SeenRef-->>UseEffect1: Not seen
    UseEffect1->>SeenRef: Add block2
    UseEffect1->>PendingRef: Set {block2}
    
    UseEffect2->>PendingRef: Check pending blocks
    PendingRef-->>UseEffect2: {block2}
    UseEffect2->>UseEffect2: Verify block2 has dimensions
    UseEffect2->>Utils: getNodeAbsolutePosition(block2)
    Utils-->>UseEffect2: Absolute position
    UseEffect2->>Viewport: Pan to block2 (absolute coords)
    UseEffect2->>PendingRef: Clear pending
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@emir-karabeg
Copy link
Collaborator Author

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@emir-karabeg emir-karabeg merged commit 1bc476f into staging Jan 29, 2026
11 checks passed
@emir-karabeg emir-karabeg deleted the fix/copilot-pan branch January 29, 2026 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants