Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • added action bar for picker/hand/undo/redo/zoom workflow controls, added general setting to disabl
  • added util to fitViewToBounds that is panel/sidebar/terminal aware & updated callers
  • added new emcn hand and picker icon, updated strokewidth for some existing ones that were only used in this contetx

Type of Change

  • New feature

Testing

Tested manually

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 10, 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 12, 2026 4:18am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 10, 2026

Greptile Overview

Greptile Summary

This PR introduces a new floating action bar for workflow canvas controls, replacing the previous panel-embedded workflow controls. The action bar provides quick access to hand/cursor mode switching, undo/redo, and zoom controls.

Key Architectural Changes:

  1. Canvas Mode System: New persistent hand/cursor mode via Zustand store (useCanvasModeStore) replaces the previous Shift-key-based temporary selection mode. The mode is persisted across sessions.

  2. Action Bar Component: A new floating toolbar positioned at the bottom-left of the canvas (above terminal, to the right of sidebar) with:

    • Hand/Cursor mode toggles
    • Undo/Redo buttons
    • Zoom controls (in/out/fit)
    • Right-click context menu to hide
  3. Viewport Utilities: New useCanvasViewport hook calculates visible canvas bounds accounting for sidebar, panel, and terminal overlays. The fitViewToBounds function replaces direct fitView calls to properly center content in the visible area.

  4. Settings Integration: Added showActionBar setting with full database migration, API endpoints, and UI toggle in settings modal.

Implementation Quality:

  • Database migration correctly adds the new column with proper defaults
  • API routes and query hooks follow existing patterns with proper validation
  • Settings sync between server, React Query cache, and Zustand store works correctly
  • New icon components follow established patterns

Issues Found:

  • Dead code in workflow.tsx: isShiftPressed state and handlers are no longer used
  • Potential conflict: multiSelectionKeyCode still includes 'Shift' which may interfere with the new mode system
  • Missing error logging in action bar's context menu handler
  • Ambiguous tooltip text ("Move" should be "Select" or "Cursor")

The changes are well-structured and follow the codebase's architectural patterns. The main concern is cleanup of the old Shift-based selection logic.

Confidence Score: 4/5

  • This PR is generally safe to merge with minor cleanup recommended
  • The implementation is solid with proper database migrations, API integration, and UI components. However, there's dead code from the old selection system that should be cleaned up, and some potential edge cases around Shift key behavior with the new mode system. The core functionality is sound but code hygiene could be improved.
  • Pay special attention to apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx - contains dead code and potential interaction conflicts with the new canvas mode system

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/action-bar/action-bar.tsx 4/5 New action bar component with hand/cursor toggles, undo/redo, and zoom controls. Minor issues: incomplete error handling in context menu, ambiguous tooltip text.
apps/sim/stores/canvas-mode/store.ts 5/5 Clean new Zustand store for persisting canvas mode (hand vs cursor). Well-structured with proper devtools and persistence setup.
apps/sim/hooks/use-canvas-viewport.ts 5/5 New viewport utilities that properly account for sidebar, panel, and terminal overlays. Well-documented and correctly implements fitViewToBounds logic.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx 3/5 Updated to use new canvas mode system. Has dead code (isShiftPressed state) that should be removed. Shift key in multiSelectionKeyCode may conflict with new mode system.
packages/db/schema.ts 5/5 Added showActionBar boolean field to settings table with correct defaults. Consistent with other settings fields.

Sequence Diagram

sequenceDiagram
    participant User
    participant ActionBar
    participant CanvasModeStore
    participant ReactFlow
    participant SettingsAPI
    participant Database

    User->>ActionBar: Click Hand/Cursor button
    ActionBar->>CanvasModeStore: setMode('hand' | 'cursor')
    CanvasModeStore->>CanvasModeStore: Persist to localStorage
    CanvasModeStore->>ReactFlow: Update selectionOnDrag/panOnDrag
    ReactFlow->>User: Canvas behavior changes

    User->>ActionBar: Right-click context menu
    ActionBar->>User: Show "Hide canvas controls"
    User->>ActionBar: Click hide
    ActionBar->>SettingsAPI: PATCH showActionBar: false
    SettingsAPI->>Database: UPDATE settings
    Database->>SettingsAPI: Success
    SettingsAPI->>ActionBar: Response
    ActionBar->>ActionBar: Unmount (showActionBar = false)

    User->>ActionBar: Click Zoom to Fit
    ActionBar->>ReactFlow: Call useCanvasViewport.fitViewToBounds()
    ReactFlow->>ReactFlow: Calculate visible bounds (minus sidebar/panel/terminal)
    ReactFlow->>ReactFlow: Center content in visible area
    ReactFlow->>User: Animated zoom/pan
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.

3 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
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.

4 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

onSelectionStart={onSelectionStart}
onSelectionEnd={onSelectionEnd}
panOnDrag={isHandMode ? [0, 1] : false}
multiSelectionKeyCode={['Meta', 'Control', 'Shift']}
Copy link
Contributor

Choose a reason for hiding this comment

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

With the new hand/cursor mode system, having Shift in multiSelectionKeyCode may cause confusion. Previously, Shift was used to toggle selection mode temporarily, but now it's just one of the multi-selection modifiers.

Since the new system uses a persistent mode toggle (hand vs cursor), consider whether Shift should still be in this array. If users press Shift in hand mode, it might create unexpected behavior where they can multi-select even though they're in hand mode.

Consider removing Shift from this array or documenting the intended behavior when Shift is pressed in hand mode.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx
Line: 3326:3326

Comment:
With the new hand/cursor mode system, having Shift in multiSelectionKeyCode may cause confusion. Previously, Shift was used to toggle selection mode temporarily, but now it's just one of the multi-selection modifiers.

Since the new system uses a persistent mode toggle (hand vs cursor), consider whether Shift should still be in this array. If users press Shift in hand mode, it might create unexpected behavior where they can multi-select even though they're in hand mode.

Consider removing Shift from this array or documenting the intended behavior when Shift is pressed in hand mode.

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 55 to 61
const handleHide = async () => {
try {
await updateSetting.mutateAsync({ key: 'showActionBar', value: false })
} finally {
setContextMenu(null)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Error handling is incomplete - if updateSetting.mutateAsync fails, the error is silently swallowed. The context menu closes regardless of success or failure, leaving the user unaware that the setting wasn't actually updated.

Consider logging the error or showing a notification to inform the user when the operation fails.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/action-bar/action-bar.tsx
Line: 55:61

Comment:
Error handling is incomplete - if updateSetting.mutateAsync fails, the error is silently swallowed. The context menu closes regardless of success or failure, leaving the user unaware that the setting wasn't actually updated.

Consider logging the error or showing a notification to inform the user when the operation fails.

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Collaborator Author

@waleedlatif1 waleedlatif1 left a comment

Choose a reason for hiding this comment

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

🤖 AI Code Review

Pull Request Review: Workflow Controls Action Bar

🔍 Overview

This PR adds an action bar for workflow controls (picker/hand/undo/redo/zoom) with a general setting to disable it, plus viewport fitting utilities and icon updates.

⚠️ Critical Issues

1. Incomplete PR Title and Description

  • The title and description are truncated ("...to disabl")
  • Action Required: Complete the description to clearly state what can be disabled and why

2. Missing Test Coverage

  • The checklist shows "Tests added/updated and passing" is unchecked
  • For a feature touching 30 files, automated tests are essential
  • Recommendation: Add unit tests for the new utilities and integration tests for the action bar

📋 General Concerns

Code Quality

Positive:

  • Feature appears well-scoped (workflow controls consolidation)
  • Includes settings for user customization

Concerns:

  • 30 files changed is substantial for a single PR - consider if this could be split into smaller, reviewable chunks:
    1. Utility functions (fitViewToBounds)
    2. Icon updates
    3. Action bar implementation
    4. Settings integration

Documentation

  • No mention of documentation updates
  • Questions to address:
    • Are there user-facing docs that need updating?
    • Is the new setting documented?
    • Are the new utilities documented with JSDoc/TSDoc?

🐛 Potential Issues

Without seeing the actual code, here are common pitfalls to check:

1. Viewport/Bounds Calculations

// Ensure fitViewToBounds handles edge cases:
// - Empty/null bounds
// - Negative dimensions
// - Panel/sidebar in collapsed state
// - Multiple monitors with different DPIs
// - Zoom limits (min/max)

2. Settings Persistence

  • Verify the disable setting persists across sessions
  • Check default value is sensible (likely enabled)
  • Ensure setting changes apply immediately without requiring reload

3. Undo/Redo State Management

  • Confirm undo/redo doesn't conflict with existing keyboard shortcuts
  • Verify state consistency when action bar is disabled
  • Check for memory leaks in undo history

4. Icon Updates

  • Ensure SVG icons are optimized
  • Verify accessibility (proper ARIA labels)
  • Check icon sizing is consistent across different zoom levels

🔒 Security Considerations

  • If settings are stored, ensure they're validated on load
  • Verify no XSS vulnerabilities if icons are dynamically loaded
  • Check that zoom controls have reasonable min/max limits to prevent DoS

⚡ Performance Implications

Potential Concerns:

  1. fitViewToBounds calculations - ensure these are debounced/throttled if called frequently
  2. Panel/sidebar awareness - verify this doesn't cause layout thrashing
  3. Icon rendering - confirm SVGs are cached appropriately
  4. Undo/redo history - ensure there's a reasonable limit to prevent memory issues

Recommendations:

// Example: Debounce expensive calculations
const debouncedFitView = debounce(fitViewToBounds, 150);

// Example: Limit undo history
const MAX_UNDO_HISTORY = 50;

🎯 Specific Recommendations

1. Code Organization

  • Extract the fitViewToBounds utility into a separate, well-tested module
  • Consider using a factory pattern for the action bar to improve testability

2. Accessibility

  • Ensure all controls have keyboard shortcuts
  • Add proper ARIA labels and roles
  • Test with screen readers
  • Verify focus management

3. User Experience

  • Consider adding tooltips to action bar buttons
  • Provide visual feedback for disabled state
  • Ensure the action bar doesn't obstruct important content
  • Consider making the action bar position customizable

4. Testing Strategy

// Suggested test coverage:
// - Unit tests for fitViewToBounds with various panel states
// - Integration tests for action bar interactions
// - E2E tests for undo/redo functionality
// - Visual regression tests for icon updates
// - Accessibility tests (axe-core)


This review was automatically generated by an AI assistant.

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.

3 participants