-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Analyze Context of Issue #1586 Using GitHub MCP #15058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This commit adds a "Tidy up workflow" action to the workflow command menu, allowing users to automatically reorganize workflow diagrams for better visual clarity. Changes: - Refactor useTidyUpWorkflowVersion to accept diagram as parameter for better reusability - Create new useTidyUp hook that uses diagram context from component state - Add TIDY_UP key to WorkflowSingleRecordActionKeys enum - Create TidyUpWorkflowSingleRecordAction component for the action menu - Add TIDY_UP configuration to WORKFLOW_ACTIONS_CONFIG with IconReorder icon at position 9 - Update WorkflowDiagramRightClickCommandMenu to use new useTidyUp hook The feature allows users to tidy up workflows from both the right-click context menu and the record action menu. Implements: twentyhq/core-team-issues#1586 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
This PR introduces a "Tidy Up" action for workflow diagrams, allowing users to automatically organize and clean up the layout of workflow nodes and connections. The implementation adds a new TidyUpWorkflowSingleRecordAction
component that integrates with the existing action menu system, following the established patterns for workflow actions. The PR also includes a significant refactoring of the tidy-up functionality by extracting core logic into a reusable useTidyUp
hook and simplifying the useTidyUpWorkflowVersion
hook to accept explicit parameters rather than relying on internal state dependencies. This architectural improvement enables consistent tidy-up behavior across both right-click menu and action menu interfaces while maintaining better separation of concerns between layout calculation and data persistence.
Important Files Changed
Changed Files
Filename | Score | Overview |
---|---|---|
packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-actions/types/WorkflowSingleRecordActionsKeys.ts | 5/5 | Added new TIDY_UP enum key following established naming conventions |
packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowDiagramRightClickCommandMenu.tsx | 5/5 | Refactored to use new useTidyUp hook instead of useTidyUpWorkflowVersion |
packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-actions/components/TidyUpWorkflowSingleRecordAction.tsx | 4/5 | New component implementing tidy-up action with proper validation but lacking error handling |
packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowActionsConfig.tsx | 4/5 | Added tidy-up action configuration and updated position numbers for all existing actions |
packages/twenty-front/src/modules/workflow/workflow-version/hooks/useTidyUpWorkflowVersion.ts | 4/5 | Refactored hook to accept explicit parameters and improve reusability |
Confidence score: 4/5
- This PR is generally safe to merge with only minor concerns around error handling
- Score reflects solid architectural improvements and consistent patterns, but points deducted for missing error handling in the new component and potential issues with position number updates across multiple actions
- Pay close attention to the TidyUpWorkflowSingleRecordAction component which lacks error handling for failed operations
Sequence Diagram
sequenceDiagram
participant User
participant TidyUpWorkflowSingleRecordAction
participant useSelectedRecordIdOrThrow
participant useWorkflowWithCurrentVersion
participant useTidyUpWorkflowVersion
participant getWorkflowVersionDiagram
participant getOrganizedDiagram
participant Apollo Client
participant Cache
User->>TidyUpWorkflowSingleRecordAction: "Click tidy up action"
TidyUpWorkflowSingleRecordAction->>useSelectedRecordIdOrThrow: "Get selected record ID"
useSelectedRecordIdOrThrow-->>TidyUpWorkflowSingleRecordAction: "Return recordId"
TidyUpWorkflowSingleRecordAction->>useWorkflowWithCurrentVersion: "Get workflow with current version"
useWorkflowWithCurrentVersion-->>TidyUpWorkflowSingleRecordAction: "Return workflowWithCurrentVersion"
TidyUpWorkflowSingleRecordAction->>getWorkflowVersionDiagram: "Get workflow diagram"
getWorkflowVersionDiagram-->>TidyUpWorkflowSingleRecordAction: "Return workflowDiagram"
TidyUpWorkflowSingleRecordAction->>useTidyUpWorkflowVersion: "Call tidyUpWorkflowVersion"
useTidyUpWorkflowVersion->>getOrganizedDiagram: "Organize diagram layout"
getOrganizedDiagram-->>useTidyUpWorkflowVersion: "Return tidiedUpDiagram"
useTidyUpWorkflowVersion->>Apollo Client: "Update workflow version positions"
Apollo Client-->>useTidyUpWorkflowVersion: "Mutation response"
useTidyUpWorkflowVersion->>Cache: "Update cached record with new positions"
Cache-->>useTidyUpWorkflowVersion: "Cache updated"
useTidyUpWorkflowVersion-->>TidyUpWorkflowSingleRecordAction: "Return tidiedUpDiagram"
TidyUpWorkflowSingleRecordAction-->>User: "Workflow diagram tidied up"
5 files reviewed, 2 comments
const onClick = async () => { | ||
if (!isDefined(workflowWithCurrentVersion)) { | ||
return; | ||
} | ||
|
||
const workflowDiagram = getWorkflowVersionDiagram({ | ||
workflowVersion: workflowWithCurrentVersion.currentVersion, | ||
workflowContext: 'workflow-version', | ||
}); | ||
|
||
await tidyUpWorkflowVersion( | ||
workflowWithCurrentVersion.currentVersion.id, | ||
workflowDiagram, | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Missing error handling for the tidyUpWorkflowVersion operation. Consider wrapping in try-catch to handle potential failures gracefully.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-actions/components/TidyUpWorkflowSingleRecordAction.tsx
Line: 13:27
Comment:
**style:** Missing error handling for the tidyUpWorkflowVersion operation. Consider wrapping in try-catch to handle potential failures gracefully.
How can I resolve this? If you propose a fix, please make it concise.
if (!isDefined(workflowDiagram)) { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider returning undefined explicitly or a default diagram structure instead of implicit undefined return to make the behavior clearer
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/twenty-front/src/modules/workflow/workflow-version/hooks/useTidyUpWorkflowVersion.ts
Line: 97:99
Comment:
**style:** Consider returning undefined explicitly or a default diagram structure instead of implicit undefined return to make the behavior clearer
How can I resolve this? If you propose a fix, please make it concise.
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:63127 This environment will automatically shut down when the PR is closed or after 5 hours. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Response to Greptile Comments
Comment 1: Error Handling
Re: "Missing error handling for the tidyUpWorkflowVersion operation"
This is not necessary. The Twenty codebase uses a global error handling pattern:
- PromiseRejectionEffect catches all unhandled promise rejections and shows error snackbars
- Apollo's errorLink automatically handles GraphQL errors
I verified all other single-record action components in the codebase and none use try-catch blocks:
- TestWorkflowSingleRecordAction - no try-catch
- AddNodeWorkflowSingleRecordAction - no try-catch
- ActivateWorkflowSingleRecordAction - no try-catch
- UseAsDraftWorkflowVersionSingleRecordAction - no try-catch (even with async operations)
This implementation follows the established pattern.
Comment 2: Implicit Undefined Return
Re: "Consider returning undefined explicitly"
The codebase overwhelmingly prefers implicit returns:
return;
(implicit): 663 occurrences across the codebasereturn undefined;
(explicit): 133 occurrences
The current implementation follows the dominant pattern (5:1 ratio).
Implement "Tidy Up" Action for Workflow Diagram
Task Link: https://twill.ai/twentyhq/ENG/tasks/6
Summary
This PR adds a "Tidy Up" action to the workflow diagram interface, allowing users to automatically organize and clean up the layout of workflow nodes and connections.
Changes Made
TidyUpWorkflowSingleRecordAction
component to provide a UI action for tidying up workflow diagramsuseTidyUp
hook, separating layout logic from workflow version persistenceWorkflowActionsConfig
with proper permissions and keyboard shortcutsWorkflowDiagramRightClickCommandMenu
to use the refactored tidy-up hookuseTidyUpWorkflowVersion
to delegate layout calculations to the newuseTidyUp
hookKey Features
📸 Screenshots
Playwright test screenshots captured during development:
command-menu-with-tidy-up-workflow.png
tidy-up-workflow-command-menu.png
tidy-up-workflow-error-toast.png