Skip to content

fix(templates-page): loading issue due to loading extensive workflow block in preview for all listings - #2166

Merged
icecrasher321 merged 2 commits into
stagingfrom
fix/templates-loading
Dec 3, 2025
Merged

fix(templates-page): loading issue due to loading extensive workflow block in preview for all listings#2166
icecrasher321 merged 2 commits into
stagingfrom
fix/templates-loading

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

Workflow preview in templates page renders full workflow block causing it to be slow when there are a lot of templates. This PR makes lightweight preview components.

Type of Change

  • Bug fix

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

vercelBot commented Dec 3, 2025

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentPreviewCommentsUpdated (UTC)
docsSkippedSkippedDec 3, 2025 3:42am

@greptile-apps

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR optimizes template page performance by implementing lightweight preview components for workflow blocks.

  • Created WorkflowPreviewBlock and WorkflowPreviewSubflow components that render minimal UI without heavy hooks, store subscriptions, or interactive features
  • Added lightweight prop to WorkflowPreview component that switches between full interactive components and lightweight preview components
  • Updated both template card components to pass lightweight={true} to WorkflowPreview
  • The lightweight components render static previews with block headers, dummy subblock skeletons, and handles while avoiding expensive operations like store subscriptions and data fetching

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The changes are well-architected, focused on performance optimization, and maintain backward compatibility. The new lightweight components follow established patterns from the codebase, use proper memoization, and have clear separation between preview and full modes. No breaking changes or risky logic introduced.
  • No files require special attention

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/app/workspace/[workspaceId]/w/components/workflow-preview/workflow-preview-block.tsx5/5New lightweight block component that renders minimal preview without hooks or store subscriptions
apps/sim/app/workspace/[workspaceId]/w/components/workflow-preview/workflow-preview-subflow.tsx5/5New lightweight subflow component for loop/parallel previews without interactive features
apps/sim/app/workspace/[workspaceId]/w/components/workflow-preview/workflow-preview.tsx5/5Added lightweight mode with separate node types that use minimal preview components for better performance

Sequence Diagram

sequenceDiagram
participant TC as TemplateCard
participant WP as WorkflowPreview
participant LWT as lightweightNodeTypes
participant WPB as WorkflowPreviewBlock
participant WPS as WorkflowPreviewSubflow
participant BR as Block Registry
participant RF as ReactFlow
Note over TC,WP: Template Page Rendering
TC->>WP: render with lightweight={true}
Note over WP: Select node types based on mode
WP->>WP: nodeTypes = lightweight ? lightweightNodeTypes : fullNodeTypes
Note over WP: Build nodes array
loop For each block in workflow
WP->>WP: Check if lightweight mode
alt Lightweight Mode
alt Block is loop/parallel
WP->>WPS: Create minimal subflow node data
WPS-->>WP: {name, width, height, kind}
else Regular block
WP->>WPB: Create minimal block node data
WPB-->>WP: {type, name, isTrigger, horizontalHandles, enabled}
end
else Full Mode
WP->>WP: Create detailed node with subBlockValues
end
end
Note over WP,RF: Render with ReactFlow
WP->>RF: Pass nodes, edges, nodeTypes
alt Lightweight Mode
RF->>WPB: Render WorkflowPreviewBlock
WPB->>BR: getBlock(type) - config only
BR-->>WPB: blockConfig
WPB->>WPB: Filter visible subblocks from config
WPB->>RF: Render static skeleton UI
else Full Mode
RF->>RF: Render full WorkflowBlock with hooks
end
RF-->>TC: Rendered preview
Loading

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

5 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@icecrasher321
icecrasher321 merged commit 9670d96 into stagingDec 3, 2025
9 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/templates-loading branch December 4, 2025 05:14
Sign up for freeto 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.

1 participant

@icecrasher321