Skip to content
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

refactor(ui): ui updates and code refactor #1098

Merged
merged 6 commits into from
Mar 21, 2025
Merged

Conversation

KaWaite
Copy link
Member

@KaWaite KaWaite commented Mar 21, 2025

Overview

What I've done

What I haven't done

How I tested

Screenshot

Which point I want you to review particularly

Memo

Summary by CodeRabbit

  • Style

    • Updated visual interactions by preventing accidental text selection and refining the appearance of graphical elements, including animations and color accents for better clarity.
    • Enhanced tabbed interface layout by repositioning the submit button and adjusting tab properties for improved visual feedback.
  • Refactor

    • Enhanced undo/redo functionality by supporting additional contextual information.
    • Improved asynchronous data handling and state management for smoother loading and more reliable UI responses.
    • Streamlined component logic by removing deprecated status tracking for a cleaner, more consistent experience.

Copy link
Contributor

coderabbitai bot commented Mar 21, 2025

Walkthrough

This pull request updates various UI and Yjs modules. It extends the signature of the undoTrackerActionWrapper function to accept an optional string parameter across multiple files to allow additional origin context. Several components now wrap their refetch calls in asynchronous IIFEs to ensure proper handling of async operations. Additionally, modifications include a CSS update to prevent text selection in the BottomBar, adjustments to node styling and status handling in React Flow components, and enhancements to workspace state management and recursive shared type tracking in the Yjs setup.

Changes

File(s) Change Summary
ui/src/features/Editor/components/BottomBar/index.tsx Added select-none class to a div to prevent text selection.
ui/src/features/Editor/hooks.ts, ui/src/features/Editor/index.tsx, ui/src/features/SharedCanvas/hooks.ts, ui/src/features/SharedCanvas/index.tsx, ui/src/lib/yjs/useYEdge.ts, ui/src/lib/yjs/useYHistory.ts, ui/src/lib/yjs/useYLayout.ts, ui/src/lib/yjs/useYNode.ts, ui/src/lib/yjs/useYWorkflow.ts, ui/src/lib/yjs/useYjsSetup.ts, ui/src/lib/yjs/useYjsStore.ts Updated undoTrackerActionWrapper signatures to accept an optional second parameter (originPrepend?: string); in useYjsSetup.ts, added a new recursive function to track shared types.
ui/src/features/WorkspaceDeployments/hooks.ts, ui/src/features/WorkspaceJobs/components/JobRunDialog.tsx, ui/src/features/WorkspaceJobs/hooks.ts, ui/src/features/WorkspaceTriggers/components/TriggerAddDialog.tsx, ui/src/features/WorkspaceTriggers/hooks.ts, ui/src/hooks/useProjectPagination.ts, ui/src/lib/reactFlow/edgeTypes/DefaultEdge/hooks.ts Wrapped calls to refetch in asynchronous immediately invoked function expressions (IIFEs) within useEffect hooks to properly await asynchronous operations.
ui/src/lib/reactFlow/edgeTypes/DefaultEdge/index.tsx Modified SVG edge styling with updated stroke colors, dash arrays, animation durations, and simplified rendering for the "failed" status.
ui/src/lib/reactFlow/nodeTypes/GeneralNode/hooks.ts, ui/src/lib/reactFlow/nodeTypes/GeneralNode/index.tsx, ui/src/lib/reactFlow/nodeTypes/GeneralNode/useNodeStatus.ts, ui/src/lib/reactFlow/nodeTypes/ReaderNode.tsx, ui/src/lib/reactFlow/nodeTypes/TransformerNode.tsx, ui/src/lib/reactFlow/nodeTypes/WriterNode.tsx Removed node status handling (status and metaProps) from GeneralNode and deleted the unused useNodeStatus hook; updated class names in Reader, Transformer, and Writer nodes by removing the /60 opacity suffix.
ui/src/features/PageWrapper/WorkspaceId.tsx Renamed a placeholder variable to currentWorkspace and modified the conditional rendering logic to better manage loading and not found states.

Sequence Diagram(s)

sequenceDiagram
  participant C as Component
  participant E as useEffect
  participant A as Async IIFE
  participant R as Refetch

  C->>E: Trigger effect
  E->>A: Invoke async IIFE
  A->>R: Await refetch call
  R-->>A: Return data
  A-->>E: Complete async execution
  E-->>C: Update component state
Loading
sequenceDiagram
  participant U as useYjsSetup
  participant R as recursivelyTrackSharedType
  participant Y as Y.Map
  participant O as Observer

  U->>R: Call recursivelyTrackSharedType(yWorkflows)
  R->>Y: Check instance of Y.Map
  Y-->>R: Provide map values
  R->>O: Attach observer for "add"/"update"
  O-->>R: On change, invoke recursivelyTrackSharedType(new Y.Map)
Loading

Possibly related PRs

  • feat(ui): Right Panel Action Parameters #564: The changes in the main PR, which involve modifying the undoTrackerActionWrapper type signature, are related to the retrieved PR as both involve updates to the same function signature in different components, enhancing the flexibility of the undoTrackerActionWrapper.
  • feat(ui): Added Versioning GQL Requests #962: The changes in the main PR, which involve modifications to the undoTrackerActionWrapper parameter in various components, are related to the changes in the retrieved PR that also update the undoTrackerActionWrapper parameter to include an optional originPrepend string, indicating a direct connection at the code level.
  • fix(ui): close for successful submission and no params message #713: The changes in the main PR, which involve modifications to the ParamEditor component's layout and structure, are related to the changes in the retrieved PR, which also modifies the ParamEditor component by removing certain elements and simplifying the display logic. Both PRs focus on enhancing the user interface of the ParamEditor.

Poem

I hopped through lines of code today,
Adjusting functions in a boppy way.
Async calls now await with grace,
And status checks have left no trace.
With every change my heart beats fast –
A happy rabbit coding at last! 🐰

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Mar 21, 2025

Deploy Preview for reearth-flow ready!

Name Link
🔨 Latest commit 61db3fc
🔍 Latest deploy log https://app.netlify.com/sites/reearth-flow/deploys/67dd0bb42e65e40008e09cb7
😎 Deploy Preview https://deploy-preview-1098--reearth-flow.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (8)
ui/src/features/WorkspaceDeployments/hooks.ts (1)

39-43: Improved async handling for refetch

Wrapping the refetch() call in an async IIFE allows proper awaiting of the Promise, which is a good practice for handling asynchronous operations. This ensures that the refetch operation completes properly before any subsequent code would execute.

Consider adding error handling for a more robust implementation:

useEffect(() => {
  (async () => {
    try {
      await refetch();
+   } catch (error) {
+     // Log or handle error appropriately
+     console.error("Failed to refetch deployments:", error);
    }
  })();
}, [currentPage, currentOrder, refetch]);
ui/src/lib/yjs/useYLayout.ts (1)

24-46: Consider utilizing the new originPrepend parameter

The function call to undoTrackerActionWrapper doesn't utilize the newly added originPrepend parameter. Consider adding a descriptive origin string to provide better context for layout changes in the undo history.

-      undoTrackerActionWrapper(() => {
+      undoTrackerActionWrapper(() => {
         rawWorkflows.forEach((rawWorkflow) => {
           const yNodes = yWorkflows?.get(rawWorkflow.id)?.get("nodes") as
             | YNodesMap
             | undefined;
           if (!yNodes) return;

           const nodes = rawWorkflow.nodes as Node[];
           const edges = rawWorkflow.edges as Edge[];
           const layoutedElements = autoLayout(
             algorithm,
             direction,
             nodes,
             edges,
             // spacing,
           );

           layoutedElements.nodes?.forEach((n) => {
             const yNode = yNodeConstructor(n);
             yNodes.set(n.id, yNode);
           });
         });
-      });
+      }, "layout-change");
ui/src/lib/yjs/useYNode.ts (1)

31-43: Consider using the new originPrepend parameter

The function signature has been updated to include the originPrepend parameter, but it's not being utilized in the actual function calls. Consider adding an appropriate origin string to provide context for these undo actions.

For example:

- undoTrackerActionWrapper(() => {
+ undoTrackerActionWrapper(() => {
  const yNodes = currentYWorkflow?.get("nodes") as YNodesMap | undefined;
  if (!yNodes) return;

  newNodes.forEach((newNode) => {
    // ...
  });
}, "node/add");

Similarly for other undoTrackerActionWrapper calls in this file.

Also applies to: 57-148, 161-197

ui/src/lib/yjs/useYHistory.ts (3)

4-5: Consider removing or documenting the commented-out code.
Leaving the historyClientPrepend comment in place without explanation may cause confusion. If you plan to revive this feature later, a clarifying comment would help; otherwise, removing the unused code entirely could keep things clean.


29-41: Avoid potential infinite recursion in undo logic.
If undoManager?.undo() keeps failing, the recursive call can repeat indefinitely. Consider limiting retries or adding a mechanism to detect persistent errors to prevent infinite loops.


48-60: Mirror undo retry strategy in redo logic carefully.
The same recursion applies here, risking repeated failures if the error is persistent. Implement a retry limit or error-handling strategy that prevents infinite retry loops.

ui/src/lib/yjs/useYjsSetup.ts (2)

87-95: Check for yDocState nullability before transaction.
Although unlikely, if yDocState were null at runtime, attempting a transaction could throw an error. Safeguarding or early-returning may help avoid edge-case issues.


112-143: Consider tracking other Yjs data types.
Your recursive method currently handles Y.Map objects. If you ever store data in Y.Array or Y.Text, you might extend this to ensure full coverage.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between abf9ab0 and 6655a49.

📒 Files selected for processing (27)
  • ui/src/features/Editor/components/BottomBar/index.tsx (1 hunks)
  • ui/src/features/Editor/hooks.ts (1 hunks)
  • ui/src/features/Editor/index.tsx (1 hunks)
  • ui/src/features/PageWrapper/WorkspaceId.tsx (2 hunks)
  • ui/src/features/SharedCanvas/hooks.ts (1 hunks)
  • ui/src/features/SharedCanvas/index.tsx (1 hunks)
  • ui/src/features/WorkspaceDeployments/hooks.ts (1 hunks)
  • ui/src/features/WorkspaceJobs/components/JobRunDialog.tsx (1 hunks)
  • ui/src/features/WorkspaceJobs/hooks.ts (1 hunks)
  • ui/src/features/WorkspaceTriggers/components/TriggerAddDialog.tsx (1 hunks)
  • ui/src/features/WorkspaceTriggers/hooks.ts (1 hunks)
  • ui/src/hooks/useProjectPagination.ts (1 hunks)
  • ui/src/lib/reactFlow/edgeTypes/DefaultEdge/hooks.ts (1 hunks)
  • ui/src/lib/reactFlow/edgeTypes/DefaultEdge/index.tsx (4 hunks)
  • ui/src/lib/reactFlow/nodeTypes/GeneralNode/hooks.ts (3 hunks)
  • ui/src/lib/reactFlow/nodeTypes/GeneralNode/index.tsx (3 hunks)
  • ui/src/lib/reactFlow/nodeTypes/GeneralNode/useNodeStatus.ts (0 hunks)
  • ui/src/lib/reactFlow/nodeTypes/ReaderNode.tsx (1 hunks)
  • ui/src/lib/reactFlow/nodeTypes/TransformerNode.tsx (1 hunks)
  • ui/src/lib/reactFlow/nodeTypes/WriterNode.tsx (1 hunks)
  • ui/src/lib/yjs/useYEdge.ts (1 hunks)
  • ui/src/lib/yjs/useYHistory.ts (2 hunks)
  • ui/src/lib/yjs/useYLayout.ts (1 hunks)
  • ui/src/lib/yjs/useYNode.ts (1 hunks)
  • ui/src/lib/yjs/useYWorkflow.ts (1 hunks)
  • ui/src/lib/yjs/useYjsSetup.ts (3 hunks)
  • ui/src/lib/yjs/useYjsStore.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • ui/src/lib/reactFlow/nodeTypes/GeneralNode/useNodeStatus.ts
🧰 Additional context used
🧬 Code Definitions (2)
ui/src/lib/reactFlow/nodeTypes/GeneralNode/index.tsx (1)
ui/src/lib/reactFlow/nodeTypes/GeneralNode/hooks.ts (1) (1)
  • data (10-53)
ui/src/lib/yjs/useYjsSetup.ts (5)
ui/src/features/Editor/hooks.ts (1) (1)
  • yWorkflows (29-317)
ui/src/lib/yjs/useYWorkflow.ts (1) (1)
  • yWorkflows (23-361)
ui/src/features/SharedCanvas/hooks.ts (1) (1)
  • yWorkflows (17-135)
ui/src/lib/yjs/useYLayout.ts (1) (1)
  • yWorkflows (10-54)
ui/src/lib/yjs/useYHistory.ts (1) (1)
  • undoManager (6-70)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Collect information
🔇 Additional comments (36)
ui/src/lib/reactFlow/nodeTypes/WriterNode.tsx (1)

6-6: Styling consistency improvement

The /60 opacity modifier has been removed from the class name, which simplifies the styling and suggests the opacity is now managed in the base class definition itself. This appears to be part of a consistent styling update across node components.

ui/src/lib/reactFlow/nodeTypes/TransformerNode.tsx (1)

6-6: Consistent styling update across node components

Removing the /60 opacity modifier aligns with the same styling changes made in other node components. This creates a more consistent approach to node styling throughout the application.

ui/src/lib/reactFlow/nodeTypes/ReaderNode.tsx (1)

6-6: Completed styling consistency across all node types

This change completes the pattern of removing opacity modifiers across all node type components (Reader, Writer, and Transformer). The styling approach is now more consistent and likely easier to maintain.

ui/src/features/WorkspaceJobs/hooks.ts (1)

27-29: Improved asynchronous operation handling

Great improvement! Wrapping the refetch() call in an async IIFE ensures the Promise is properly awaited, which helps prevent potential race conditions and provides better error handling capability.

ui/src/features/Editor/components/BottomBar/index.tsx (1)

41-41: Enhanced UI interaction with select-none

Good addition of the select-none class to prevent users from accidentally selecting text in the status bar, providing a more polished user experience.

ui/src/features/WorkspaceTriggers/components/TriggerAddDialog.tsx (1)

60-62: Improved asynchronous operation handling

Good improvement! Wrapping the refetch() call in an async IIFE ensures the Promise is properly awaited, consistent with similar changes in other components.

ui/src/features/WorkspaceTriggers/hooks.ts (1)

43-45: Improved asynchronous operation handling

Good improvement! This change maintains consistency with other files by properly awaiting the asynchronous refetch() operation, which is a best practice for handling Promises.

ui/src/lib/reactFlow/edgeTypes/DefaultEdge/hooks.ts (1)

62-64: Improved async handling for refetch operations

The code now properly awaits the asynchronous refetch operation by wrapping it in an async IIFE. This change prevents potential race conditions or state inconsistencies that could occur when dealing with asynchronous operations.

ui/src/features/WorkspaceJobs/components/JobRunDialog.tsx (1)

43-45: Proper async handling for refetch operation

The code now correctly awaits the asynchronous refetch operation by wrapping it in an async IIFE. This pattern ensures that promises are properly resolved and handled before the effect concludes.

ui/src/hooks/useProjectPagination.ts (1)

40-42: Improved async handling for refetch operation

Wrapping the refetch call in an async IIFE ensures that the promise is properly awaited. This is a good practice when dealing with asynchronous operations in useEffect hooks, as it provides better control over the execution flow.

ui/src/lib/yjs/useYLayout.ts (1)

17-20: Enhanced undo tracking with additional context parameter

The type signature for undoTrackerActionWrapper has been updated to accept an optional originPrepend parameter, allowing for additional context when tracking undo actions. This change is consistent with similar modifications across multiple Yjs files in the codebase.

ui/src/lib/reactFlow/nodeTypes/GeneralNode/hooks.ts (2)

6-6: Removed dependency on getPropsFrom utility

The commented import indicates the removal of a dependency on the getPropsFrom utility. Make sure this change is intentional and consistent with the other changes in this file.


38-38: Removal of node status logic

The code now removes the metaProps derivation and its inclusion in the returned object. This simplifies the component by eliminating dependencies on node status and related properties.

Also applies to: 48-48

ui/src/features/SharedCanvas/index.tsx (1)

18-21: Enhanced undo tracking with contextual information

The undoTrackerActionWrapper signature now includes an optional originPrepend parameter, allowing for more contextual information when tracking undo actions. This change aligns with similar updates across multiple files in the application.

ui/src/features/Editor/hooks.ts (1)

36-39: Enhanced undo tracking with contextual information

The undoTrackerActionWrapper signature now includes an optional originPrepend parameter, allowing for more contextual information when tracking undo actions. This change is consistent with updates in other files and improves action tracking flexibility.

ui/src/lib/yjs/useYNode.ts (1)

23-26: Enhanced undo tracking with contextual information

The undoTrackerActionWrapper signature now includes an optional originPrepend parameter, allowing for more contextual information when tracking undo actions. This change is consistent with similar updates across multiple files in the application.

ui/src/lib/reactFlow/nodeTypes/GeneralNode/index.tsx (4)

58-58: Removed unused metaProps.

The metaProps variable has been commented out in both this file and in the hooks.ts file, indicating a deliberate simplification of the component's props.


70-70: Simplified component styling logic.

The conditional styling now only depends on the selected state, removing the previous dependency on node status. This simplification makes the component more maintainable and focused.


82-82: Simplified border styling.

Similar to the previous change, the conditional styling now only depends on the selected state, making the component more consistent.


86-88: Removed status indicator visualization.

The status indicator div has been commented out, which aligns with the removal of metaProps from the component props. This is consistent with the overall refactoring to simplify the component.

ui/src/features/Editor/index.tsx (1)

20-23:

✅ Verification successful

Enhanced undo tracking with origin context.

The undoTrackerActionWrapper signature has been updated to accept an optional originPrepend parameter, allowing for more contextual information when tracking undo actions.


🏁 Script executed:

#!/bin/bash
# Check for usage of the new parameter across the codebase
rg -A 2 -B 2 "undoTrackerActionWrapper\s*\(\s*.*,\s*['\"].*['\"]" --type ts --type tsx

Length of output: 120


🏁 Script executed:

#!/bin/bash
# Re-run the command to search for invocations of `undoTrackerActionWrapper` with a string argument for originPrepend
# across both .ts and .tsx files by specifying file glob patterns.
rg -A 2 -B 2 "undoTrackerActionWrapper\s*\(\s*.*,\s*['\"].*['\"]" -g "*.ts" -g "*.tsx"

Length of output: 92


Approval of Enhanced Undo Tracking API Update

The updated signature for undoTrackerActionWrapper in ui/src/features/Editor/index.tsx (lines 20–23) now includes the optional originPrepend parameter, providing additional context when tracking undo actions. Our verification using grep indicates that there are currently no instances where a string literal is passed to this parameter—which is acceptable if its usage is intended for future integration or handled dynamically.

  • The API update is clear and correctly documented.
  • No unexpected usage patterns were detected that would conflict with the new parameter.
ui/src/features/SharedCanvas/hooks.ts (1)

24-27: Enhanced undo tracking with origin context.

The undoTrackerActionWrapper signature has been consistently updated across the codebase to accept an optional originPrepend parameter, enabling better tracking and contextualization of undo actions.

ui/src/lib/yjs/useYjsStore.ts (2)

25-28: Enhanced undo tracking with origin context.

The function signature has been updated to accept an optional originPrepend parameter, maintaining consistency with the same change applied across the codebase.


64-64: Updated useYHistory implementation.

The call to useYHistory has been modified to pass the undoTrackerActionWrapper directly, which is a necessary change to support the enhanced undo tracking functionality.

ui/src/lib/yjs/useYEdge.ts (1)

16-19:

❓ Verification inconclusive

Type signature updated to improve undo tracking capabilities

The updated signature adds an optional originPrepend parameter, enabling more contextual information when tracking undo actions. This aligns with similar changes across other files in the codebase.


🏁 Script executed:

#!/bin/bash
# Check for other instances of the updated signature to verify consistency

# Find all files with the updated undoTrackerActionWrapper pattern
echo "Files with updated undoTrackerActionWrapper signature:"
rg -l "undoTrackerActionWrapper.*\(.*callback.*\).*=>.*void" --type ts

# Check if this pattern is consistently applied
echo "\nChecking for inconsistent implementations:"
rg "undoTrackerActionWrapper.*\(.*callback: \(\) => void\).*=>.*void" --type ts

Length of output: 372


Updated undoTrackerActionWrapper Signature Verification

The updated type signature now includes an optional originPrepend parameter, which should provide more contextual information for undo operations. Our initial automated search did not return additional occurrences or inconsistencies across the codebase, so we couldn’t definitively confirm consistency with similar changes elsewhere. Please verify manually that any other usages or references across the codebase align with this new signature.

ui/src/lib/reactFlow/edgeTypes/DefaultEdge/index.tsx (5)

49-49: Adding bold styling improves visibility for failed state

The addition of weight="bold" enhances the visibility of the error icon in failed edges.


70-70: Color change improves completed edge visibility

Changing from bright green (#00ff00) to a more subdued green (#00a340) provides better contrast and reduces visual strain.


81-81: Animation adjustments enhance in-progress visualization

The reduced dash array size (10,10) and increased animation duration (3s) create a more subtle and professional animation effect for the in-progress state.

Also applies to: 87-87


92-92: Circle animation enhancements improve visual feedback

The adjusted opacity, radius, and duration create a more balanced and visually appealing animation that better indicates the in-progress state.

Also applies to: 94-94, 100-106


114-114: Simplified failed edge presentation

Removing the markerEnd attribute and changing to a more subdued red (#fc4444) creates a cleaner visual indication of failure state.

ui/src/features/PageWrapper/WorkspaceId.tsx (2)

15-15: Improved variable naming enhances code readability

Renaming the unused variable _ to currentWorkspace better reflects its purpose and improves code comprehension.


29-32: Enhanced loading logic improves user experience

The updated conditional rendering now shows the loading screen not only when isLoading is true but also when currentWorkspace is not available, providing better handling of intermediate states.

ui/src/lib/yjs/useYWorkflow.ts (1)

30-33:

✅ Verification successful

Type signature updated to improve undo tracking consistency

The updated signature adds an optional originPrepend parameter, aligning with similar changes across the codebase and enabling more contextual information when tracking undo actions.


🏁 Script executed:

#!/bin/bash
# Check if any instances of undoTrackerActionWrapper are using the new parameter

# Look for actual usage of the new originPrepend parameter
echo "Checking for usage of the new originPrepend parameter:"
rg "undoTrackerActionWrapper\s*\(\s*.+\s*,\s*['\"].*['\"]\s*\)" --type ts

# Check current file for potential usage points
echo "\nPotential places in this file where originPrepend could be used:"
rg "undoTrackerActionWrapper\s*\(\s*\(\)\s*=>" ui/src/lib/yjs/useYWorkflow.ts

Length of output: 623


Updated undoTrackerActionWrapper Signature Approved

The type signature has been updated to include an optional originPrepend parameter, in line with similar changes across the codebase. Our verification shows that current invocations—such as those in ui/src/lib/yjs/useYWorkflow.ts—still use the shorthand call (passing only the callback), which is acceptable since the parameter is optional. Please ensure that when more contextual information is needed for undo tracking, the originPrepend argument is used accordingly.

File: ui/src/lib/yjs/useYWorkflow.ts
Observation: There are no call sites currently supplying a second argument, but this remains backward compatible and prepares for future enhancements.

ui/src/lib/yjs/useYHistory.ts (1)

10-15: Validate necessity of undoTrackerActionWrapper interface.
Although the parameter is typed here, its usage is entirely commented out. Confirm whether you need this parameter across the codebase or remove it if unused.

ui/src/lib/yjs/useYjsSetup.ts (2)

1-1: No issues noted.
The updated import statement looks fine.


107-107: Good cleanup approach.
Resetting the undo manager on unmount prevents stale references or memory leaks.

Comment on lines +6 to +9
export default ({
undoManager,
// undoTrackerActionWrapper,
}: {
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove or restore the undoTrackerActionWrapper parameter.
It’s currently commented out yet partially defined. If you no longer plan to wrap undo/redo calls, consider removing it to reduce clutter; otherwise, uncomment and implement its usage for consistent undo tracking.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
ui/src/lib/reactFlow/nodeTypes/GeneralNode/hooks.ts (1)

6-6: Code cleanup: commented out unused node status functionality.

The commented-out lines relate to node status handling that's been removed as part of the refactoring. This change is consistent with the broader effort to simplify node property handling.

Rather than keeping commented code, consider removing these lines completely for a cleaner codebase:

-// import { getPropsFrom } from "../utils";
-  // const metaProps = getPropsFrom(status);
-    // metaProps,

Also applies to: 38-38, 48-48

ui/src/lib/yjs/useYjsSetup.ts (2)

114-139: Well-implemented recursive tracking of shared types

The recursivelyTrackSharedType function is well-structured with proper guards against infinite recursion. It effectively handles nested Y.Map instances and sets up appropriate observers for change tracking.

Consider moving this function inside a useEffect or useCallback hook to prevent it from being recreated on every render.

-function recursivelyTrackSharedType(sharedType?: Y.Map<any>): void {
+const recursivelyTrackSharedType = useCallback((sharedType?: Y.Map<any>): void => {
   if (!sharedType) return;
   if (observedMapsRef.current.has(sharedType)) return;
   observedMapsRef.current.add(sharedType);

   undoManager?.addToScope([sharedType]);

   if (sharedType instanceof Y.Map) {
     sharedType.forEach((value: any) => {
       if (value instanceof Y.Map) {
         recursivelyTrackSharedType(value);
       }
     });

     sharedType.observe((event: Y.YMapEvent<any>) => {
       event.changes.keys.forEach((change: any, key: string) => {
         if (change.action === "add" || change.action === "update") {
           const newValue: any = sharedType.get(key);
           if (newValue instanceof Y.Map) {
             recursivelyTrackSharedType(newValue);
           }
         }
       });
     });
   }
-}
+}, [undoManager]);

142-142: Consider moving recursive tracking call to an effect hook

The call to recursivelyTrackSharedType is placed at the component level, which means it's executed on every render. Consider moving this call to a useEffect hook that runs when dependencies like yWorkflows or undoManager change.

+useEffect(() => {
+  if (yWorkflows && undoManager) {
+    // Start the recursive tracking
+    recursivelyTrackSharedType(yWorkflows);
+  }
+}, [yWorkflows, undoManager, recursivelyTrackSharedType]);

-// Start the recursive tracking
-recursivelyTrackSharedType(yWorkflows);
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between abf9ab0 and 6655a49.

📒 Files selected for processing (27)
  • ui/src/features/Editor/components/BottomBar/index.tsx (1 hunks)
  • ui/src/features/Editor/hooks.ts (1 hunks)
  • ui/src/features/Editor/index.tsx (1 hunks)
  • ui/src/features/PageWrapper/WorkspaceId.tsx (2 hunks)
  • ui/src/features/SharedCanvas/hooks.ts (1 hunks)
  • ui/src/features/SharedCanvas/index.tsx (1 hunks)
  • ui/src/features/WorkspaceDeployments/hooks.ts (1 hunks)
  • ui/src/features/WorkspaceJobs/components/JobRunDialog.tsx (1 hunks)
  • ui/src/features/WorkspaceJobs/hooks.ts (1 hunks)
  • ui/src/features/WorkspaceTriggers/components/TriggerAddDialog.tsx (1 hunks)
  • ui/src/features/WorkspaceTriggers/hooks.ts (1 hunks)
  • ui/src/hooks/useProjectPagination.ts (1 hunks)
  • ui/src/lib/reactFlow/edgeTypes/DefaultEdge/hooks.ts (1 hunks)
  • ui/src/lib/reactFlow/edgeTypes/DefaultEdge/index.tsx (4 hunks)
  • ui/src/lib/reactFlow/nodeTypes/GeneralNode/hooks.ts (3 hunks)
  • ui/src/lib/reactFlow/nodeTypes/GeneralNode/index.tsx (3 hunks)
  • ui/src/lib/reactFlow/nodeTypes/GeneralNode/useNodeStatus.ts (0 hunks)
  • ui/src/lib/reactFlow/nodeTypes/ReaderNode.tsx (1 hunks)
  • ui/src/lib/reactFlow/nodeTypes/TransformerNode.tsx (1 hunks)
  • ui/src/lib/reactFlow/nodeTypes/WriterNode.tsx (1 hunks)
  • ui/src/lib/yjs/useYEdge.ts (1 hunks)
  • ui/src/lib/yjs/useYHistory.ts (2 hunks)
  • ui/src/lib/yjs/useYLayout.ts (1 hunks)
  • ui/src/lib/yjs/useYNode.ts (1 hunks)
  • ui/src/lib/yjs/useYWorkflow.ts (1 hunks)
  • ui/src/lib/yjs/useYjsSetup.ts (3 hunks)
  • ui/src/lib/yjs/useYjsStore.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • ui/src/lib/reactFlow/nodeTypes/GeneralNode/useNodeStatus.ts
🧰 Additional context used
🧬 Code Definitions (1)
ui/src/lib/reactFlow/nodeTypes/GeneralNode/index.tsx (1)
ui/src/lib/reactFlow/nodeTypes/GeneralNode/hooks.ts (1) (1)
  • data (10-53)
🔇 Additional comments (37)
ui/src/lib/reactFlow/nodeTypes/WriterNode.tsx (1)

6-6: UI consistency improvement by removing opacity modifier.

The change removes the /60 opacity modifier from the background class, making the writer node background fully opaque. This aligns with similar changes in other node types, creating a more consistent visual appearance.

ui/src/lib/reactFlow/nodeTypes/ReaderNode.tsx (1)

6-6: UI consistency improvement by removing opacity modifier.

The change removes the /60 opacity modifier from the background class, making the reader node background fully opaque. This aligns with similar changes in other node types, creating a more consistent visual appearance.

ui/src/lib/reactFlow/nodeTypes/TransformerNode.tsx (1)

6-6: UI consistency improvement by removing opacity modifier.

The change removes the /60 opacity modifier from the background class, making the transformer node background fully opaque. This aligns with similar changes in other node types, creating a more consistent visual appearance.

ui/src/features/Editor/components/BottomBar/index.tsx (1)

41-41: Enhanced UX by preventing text selection in status bar.

Adding the select-none class prevents users from accidentally selecting text in the status area, which improves the user experience by avoiding unintended text selection when interacting with the UI.

ui/src/features/WorkspaceDeployments/hooks.ts (1)

39-43: Improved async operation handling in useEffect.

Wrapping the refetch call in an async IIFE allows proper awaiting of the Promise, which is a better practice for handling asynchronous operations. This change is part of a consistent pattern across the codebase to standardize async handling.

ui/src/features/WorkspaceTriggers/components/TriggerAddDialog.tsx (1)

59-62: Improved async handling for refetch operation

The change properly wraps the refetch call in an async IIFE, allowing you to await the asynchronous operation. This is a good practice that ensures:

  1. The promise from refetch is properly awaited and handled
  2. Any component state updates dependent on this operation will happen more predictably
  3. Potential race conditions are reduced when fetching data
ui/src/hooks/useProjectPagination.ts (1)

39-42: Improved async handling for refetch operation

Converting the direct refetch() call to an awaited async operation ensures proper promise handling. This is a good standardization that aligns with best practices for handling asynchronous data fetching within React hooks.

ui/src/features/WorkspaceJobs/components/JobRunDialog.tsx (1)

42-45: Improved async handling for refetch operation

The implementation of an async IIFE to await the refetch operation is a proper way to handle promise-based operations in a React useEffect hook. This ensures that any asynchronous data fetching completes properly before the effect concludes.

ui/src/lib/yjs/useYEdge.ts (1)

16-19:

❓ Verification inconclusive

Enhanced parameter support for undoTrackerActionWrapper

Adding the optional originPrepend parameter to the undoTrackerActionWrapper function signature is a good improvement that allows for more contextual information when tracking undo actions. This enhances the flexibility of the function without breaking existing usage.

To ensure consistent implementation, verify that this parameter is properly used in the implementation of undoTrackerActionWrapper:


🏁 Script executed:

#!/bin/bash
# Find the implementation of undoTrackerActionWrapper to verify proper usage of the new parameter
rg -A 10 "function.*undoTrackerActionWrapper" --type ts

Length of output: 57


Action required: Verify proper usage of the new parameter

The automated search did not reveal an implementation snippet that clearly shows the use of the optional originPrepend parameter. Please manually verify that the implementation of undoTrackerActionWrapper properly leverages the originPrepend parameter for enhanced context in undo actions. In particular, check that:

  • The implementation of undoTrackerActionWrapper (likely located in or used by the file ui/src/lib/yjs/useYEdge.ts or its related modules) correctly accepts and uses originPrepend.
  • Any logic related to undo tracking benefits from the additional parameter without breaking existing functionality.
ui/src/features/WorkspaceTriggers/hooks.ts (1)

42-46: Improved async handling of refetch operation.

Wrapping the refetch call in an async IIFE is a good practice as it ensures proper handling of the asynchronous operation. This change prevents potential race conditions and allows for better error handling if needed in the future.

ui/src/features/WorkspaceJobs/hooks.ts (1)

26-30: Improved async handling of refetch operation.

Converting the refetch call to use an async IIFE ensures that the Promise is properly awaited. This is a good pattern that's being consistently applied across different components in the codebase.

ui/src/lib/yjs/useYNode.ts (1)

23-26: Function signature extended to support additional context.

The undoTrackerActionWrapper signature now supports an optional originPrepend parameter, which can provide additional context when tracking undo actions.

While the type signature has been updated, the function is still only called with a single argument throughout this file (at lines 31, 57, and 161). Ensure that this is intentional and that other components using this parameter are updated accordingly.

ui/src/lib/yjs/useYLayout.ts (1)

17-20: Function signature extended to support additional context.

The undoTrackerActionWrapper signature now includes an optional originPrepend parameter, allowing for more contextual information when tracking undo operations.

Similar to other files, the function is still only called with a single argument in this file (at line 24). Ensure that this signature change is part of a coordinated update across the codebase.

ui/src/lib/reactFlow/edgeTypes/DefaultEdge/hooks.ts (1)

57-66: Improved async handling in effect hook.

The change properly wraps the refetch call in an async IIFE, ensuring that the asynchronous operation is correctly awaited. This is a good practice when dealing with async operations in effect hooks.

ui/src/features/Editor/index.tsx (1)

17-24: Enhanced function signature to support origin context.

The undoTrackerActionWrapper signature has been extended to accept an optional originPrepend string parameter. This enhancement allows for additional context when tracking undo actions, which can be useful for debugging or more granular undo history tracking.

ui/src/features/Editor/hooks.ts (1)

29-40: Consistent function signature update for undoTrackerActionWrapper.

This change aligns with the interface update in Editor/index.tsx, allowing the optional originPrepend parameter to be passed through to underlying components. This ensures consistent API usage throughout the component hierarchy.

ui/src/lib/yjs/useYjsStore.ts (2)

12-29: Aligned undoTrackerActionWrapper signature with other files.

Updated the parameter signature to match the changes in related files. This maintains consistency across the codebase and allows for the addition of context information during undo operations.


64-64: Updated parameter passing pattern for useYHistory.

Now passing both undoManager and undoTrackerActionWrapper as named properties in a single options object. This improves code maintainability by using a consistent pattern across similar hook calls.

ui/src/features/SharedCanvas/hooks.ts (1)

24-27: Function signature updated to support contextual undo tracking.

The addition of an optional originPrepend parameter to the undoTrackerActionWrapper function allows for more context when tracking undo actions. This is part of a consistent change across multiple files in the codebase.

ui/src/lib/yjs/useYWorkflow.ts (1)

30-33: Function signature updated to support contextual undo tracking.

The addition of an optional originPrepend parameter to the undoTrackerActionWrapper function aligns with the changes made across other files, providing a consistent interface for undo tracking functionality throughout the application.

ui/src/features/SharedCanvas/index.tsx (1)

18-21: Props type updated to match the enhanced undo tracking functionality.

The update to the undoTrackerActionWrapper property in the Props type ensures type safety and consistency with the implementation changes made across the codebase.

ui/src/lib/reactFlow/nodeTypes/GeneralNode/index.tsx (3)

58-58: Consistent cleanup of unused code.

The commented-out metaProps variable matches the commented-out status in the hooks.ts file. This maintains consistency with the hook implementation.


70-70: Simplified node styling logic.

The node styling has been simplified by removing status-dependent conditional classes. The component now relies solely on the selected state and node type colors, which makes the UI more consistent and maintainable.

Also applies to: 82-82


86-88: Removal of status indicator from node UI.

The status indicator div has been commented out, which aligns with the removal of status-dependent styling throughout the component. This creates a cleaner, more streamlined node representation.

ui/src/lib/reactFlow/edgeTypes/DefaultEdge/index.tsx (5)

49-49: Enhanced visibility for failure indicator.

Adding weight="bold" to the X icon improves visibility of the failure state, making it easier for users to identify problematic edges.


70-70: More subtle success state color.

Changing the completed edge color from "#00ff00" to "#00a340" provides a more professional, less jarring green that better aligns with typical UI design patterns.


81-90: Refined animation pattern for in-progress edges.

The updated stroke dash pattern (10,10) and longer animation duration (3s) creates a smoother, more visually appealing animation for edges in progress.


92-109: Improved progress indicator animation.

The changes to the animated circles (smaller radius, added opacity classes, and longer animation duration) create a more refined and subtle animation that draws appropriate attention without being distracting.


114-114: Simplified error state rendering.

The simplified path for failed edges removes unnecessary attributes while maintaining clear visual indication of errors with the "#fc4444" stroke color.

ui/src/features/PageWrapper/WorkspaceId.tsx (2)

15-15: Improved variable naming for better code clarity.

Changed from unused placeholder _ to descriptive currentWorkspace, making the code more readable and allowing the component to properly utilize the current workspace state.


29-32: Enhanced conditional rendering logic.

The improved rendering logic now:

  1. First checks if workspace exists, showing NotFoundPage if it doesn't
  2. Shows loading state when either still loading OR currentWorkspace isn't available yet
  3. Only renders children when both conditions are satisfied

This creates a more robust rendering flow that prevents showing incomplete UI states.

ui/src/lib/yjs/useYHistory.ts (3)

29-42: Added robust error handling for undo operations.

The new try-catch block provides several benefits:

  1. Logs errors when undo operations fail
  2. Removes failed operations from the stack to prevent getting stuck
  3. Recursively attempts next operation if more are available

This prevents the undo system from breaking when encountering corrupt or problematic operations.


48-61: Added robust error handling for redo operations.

Similar to the undo implementation, this adds error handling that gracefully recovers from failed redo operations by removing them from the stack and attempting to continue with subsequent operations.


6-15:

❓ Verification inconclusive

Function signature updated for improved error handling.

The function now accepts an undoTrackerActionWrapper parameter, allowing for additional context during undo/redo operations, though it's currently commented out in the implementation.


🌐 Web query:

What is the typical usage pattern for Yjs UndoManager error handling?

💡 Result:

The Yjs UndoManager provides granular control over undo/redo operations in collaborative applications, but proper error handling and usage patterns are essential. Here are key strategies based on common implementations:

Isolating User Actions

  • Track origins by client ID to prevent undoing others' changes:
    const undoManager = new Y.UndoManager(type, {
      trackedOrigins: new Set([doc.clientID]) // [1][4][5]
    })
  • Stop accidental merge of distinct operations:
    undoManager.stopCapturing() // Forces new operation grouping [1][4]

Concurrent Modification Handling

  • Check undo validity before execution:
    if (undoManager.undoStack.length > 0) {
      undoManager.undo()
    } else {
      showDisabledUndoUI() // [2][5]
    }
  • Handle conflicted states using version vectors:
    const currentState = Y.encodeStateVector(doc)
    const revertUpdate = Y.encodeStateAsUpdate(tempDoc, currentState)
    Y.applyUpdate(doc, revertUpdate) // [8][10]

Multi-Editor Coordination

When using with multiple rich-text editors:

// Shared UndoManager for coordinated undo
const undoManager = new Y.UndoManager([yText1, yText2], {
  trackedOrigins: new Set([doc.clientID]) // [7]
})

// Editor bindings must support custom UndoManager
new CodeMirrorBinding(yText, editor, { yUndoManager: undoManager }) // [7][11]

Error Recovery Patterns

  • Snapshot restoration for version rollbacks:
    function revertToSnapshot(snapshot) {
      const tempDoc = Y.createDocFromSnapshot(snapshot)
      const undoManager = new Y.UndoManager([...tempDoc.share.values()])
      Y.applyUpdate(tempDoc, Y.encodeStateAsUpdate(doc))
      undoManager.undo() // [8][10]
      Y.applyUpdate(doc, Y.encodeStateAsUpdate(tempDoc))
    }

Event-Driven Validation

Monitor stack changes for UI sync:

undoManager.on('stack-item-popped', ({ stackItem, type }) => {
  updateUndoRedoButtons() // [1][4]
  restoreCursorPosition(stackItem.meta.get('cursor')) // [4][5]
})

Conflict Resolution

  • Atomic transactions for multi-type operations:
    Y.transact(doc, () => {
      array.delete(0)
      map.set('key', 'value')
    }, doc.clientID) // [16][20]
  • Duplicate prevention with content checks:
    new Y.UndoManager(type, {
      deleteFilter: item => !item.content.isEmpty // [7][16]
    })

Common pitfalls include not isolating user actions (leading to unexpected undo of remote changes) and improperly handling concurrent document modifications. The UndoManager should typically be configured with:

  1. Client-specific origin tracking
  2. Appropriate capture timeouts (500ms default)
  3. Type-specific delete filters
  4. Stack size limits for memory management [3][19]

For collaborative applications, each client should maintain its own UndoManager instance scoped to local changes, while global undo managers require careful coordination through transaction origins and document versioning strategies [5][7][16].

Citations:


Attention: Verify the Integration of the New undoTrackerActionWrapper Parameter

  • The updated function signature now accepts an undoTrackerActionWrapper parameter to potentially enhance error handling during undo/redo operations in line with common Yjs UndoManager patterns.
  • However, the parameter is currently commented out in the destructuring assignment even though its type is declared. Please verify whether it should be activated to wrap undo/redo actions (e.g. to check operation validity, manage undo grouping, or provide UI feedback) according to best practices.
  • If the integration is intended for a later iteration, consider adding a brief comment or TODO mentioning when or how this parameter will be utilized to maintain clarity.
ui/src/lib/yjs/useYjsSetup.ts (3)

87-95: Function signature enhancement for better traceability

The updated signature of undoTrackerActionWrapper with the optional originPrepend parameter is a good improvement. This allows for more descriptive transaction origins by prefixing the client ID with context information, making it easier to track and debug changes.


112-112: Good use of WeakSet for tracking observed maps

Using a WeakSet via useRef is an excellent choice for tracking already processed Y.Map objects. It prevents memory leaks since WeakSet doesn't prevent garbage collection of objects that are no longer referenced elsewhere.


107-107: Good cleanup practice

Setting undoManager to null during cleanup is a good practice to prevent memory leaks and ensure proper resource management.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
ui/src/features/Editor/components/ParamsPanel/components/ParamEditor/index.tsx (1)

158-195: Consider applying consistent styling to Details tab

The "details" tab doesn't have the same scrolling behavior updates (min-h-0 and overflow-scroll) that were applied to the other tabs. For consistency, consider updating this tab with the same pattern.

-        <TabsContent value="details">
-          <div className="min-h-32 overflow-scroll rounded border bg-card px-2 pt-4">
+        <TabsContent value="details" asChild>
+          <div className="min-h-0 overflow-scroll rounded border bg-card px-2 pt-4">
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6655a49 and 61db3fc.

📒 Files selected for processing (1)
  • ui/src/features/Editor/components/ParamsPanel/components/ParamEditor/index.tsx (2 hunks)
🔇 Additional comments (3)
ui/src/features/Editor/components/ParamsPanel/components/ParamEditor/index.tsx (3)

94-96: Improved tab styling with dynamic flex properties

The TabsTrigger components now have dynamic styling that gives more visual weight to the active tab using flex properties. This is a good UI improvement that provides clearer visual feedback to users about which tab is currently active.

Also applies to: 100-102, 105-107


111-130: Improved content layout with better scrolling

Good restructuring of the TabsContent for parameters:

  1. Using a fragment wrapper with the asChild prop ensures proper component composition
  2. The min-height change to min-h-0 allows content to be more compact
  3. Adding overflow-scroll ensures content remains accessible when it exceeds the container

The Submit button placement within the tab content creates a clearer action context for the user.


132-156: Consistent UI pattern across tabs

The same structural improvements applied to the "customizations" tab maintain consistency across the UI. This helps users build a mental model of how the interface works across different sections.

@KaWaite KaWaite merged commit 4d8d243 into main Mar 21, 2025
23 checks passed
@KaWaite KaWaite deleted the ui/small-ui-updates branch March 21, 2025 06:50
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