-
Notifications
You must be signed in to change notification settings - Fork 17.8k
perf(web): improve app workflow build performance. #26310
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
Summary of ChangesHello @zhyd1997, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request primarily focuses on enhancing the web application's build and runtime performance through strategic implementation of code splitting and dynamic imports. By deferring the loading of several UI components and the comprehensive Markdown rendering engine, the changes aim to reduce the initial bundle size, leading to faster page loads and a more responsive user experience. Additionally, minor refactorings were performed in the workflow history management to improve type safety and code organization. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request focuses on improving web application performance by dynamically importing heavy components, which is a great approach. The refactoring of the Markdown component and its dependencies into a separate, lazy-loaded wrapper is well-executed. I've added one suggestion to further improve performance by dynamically importing another component.
import MarkdownForm from '@/app/components/base/markdown-blocks/form' | ||
import Paragraph from '@/app/components/base/markdown-blocks/paragraph' | ||
import ScriptBlock from '@/app/components/base/markdown-blocks/script-block' | ||
import ThinkBlock from '@/app/components/base/markdown-blocks/think-block' | ||
import VideoBlock from '@/app/components/base/markdown-blocks/video-block' | ||
import { customUrlTransform } from './markdown-utils' | ||
|
||
import type { FC } from 'react' | ||
|
||
import dynamic from 'next/dynamic' | ||
|
||
const CodeBlock = dynamic(() => import('@/app/components/base/markdown-blocks/code-block'), { ssr: false }) |
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.
For further performance improvement, consider dynamically importing MarkdownForm
as well, similar to how CodeBlock
is handled. The MarkdownForm
component and its dependencies (like DatePicker
, TimePicker
, Select
) can contribute significantly to the bundle size, and forms might not be present in all markdown content. Lazy-loading it would be beneficial.
import MarkdownForm from '@/app/components/base/markdown-blocks/form' | |
import Paragraph from '@/app/components/base/markdown-blocks/paragraph' | |
import ScriptBlock from '@/app/components/base/markdown-blocks/script-block' | |
import ThinkBlock from '@/app/components/base/markdown-blocks/think-block' | |
import VideoBlock from '@/app/components/base/markdown-blocks/video-block' | |
import { customUrlTransform } from './markdown-utils' | |
import type { FC } from 'react' | |
import dynamic from 'next/dynamic' | |
const CodeBlock = dynamic(() => import('@/app/components/base/markdown-blocks/code-block'), { ssr: false }) | |
import Paragraph from '@/app/components/base/markdown-blocks/paragraph' | |
import ScriptBlock from '@/app/components/base/markdown-blocks/script-block' | |
import ThinkBlock from '@/app/components/base/markdown-blocks/think-block' | |
import VideoBlock from '@/app/components/base/markdown-blocks/video-block' | |
import { customUrlTransform } from './markdown-utils' | |
import type { FC } from 'react' | |
import dynamic from 'next/dynamic' | |
const CodeBlock = dynamic(() => import('@/app/components/base/markdown-blocks/code-block'), { ssr: false }) | |
const MarkdownForm = dynamic(() => import('@/app/components/base/markdown-blocks/form'), { ssr: false }) |
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.
Pull Request Overview
This PR improves the build performance of the web application's workflow feature by implementing dynamic imports for heavy components and refactoring type definitions to use const assertions instead of enums.
- Convert enum to const object with type assertion for better tree shaking
- Add dynamic imports for performance-heavy components like charts, markdown, and mermaid diagrams
- Refactor markdown component structure to enable code splitting
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
web/app/components/workflow/workflow-history-store.tsx | Update type reference to use new const-based type |
web/app/components/workflow/hooks/use-workflow-history.ts | Convert enum to const object and update type definitions |
web/app/components/workflow-app/index.tsx | Update import path to more specific hook location |
web/app/components/datasets/documents/create-from-pipeline/data-source/local-file/index.tsx | Add dynamic import for SimplePieChart component |
web/app/components/base/markdown/react-markdown-wrapper.tsx | Extract ReactMarkdown logic into separate component with dynamic CodeBlock import |
web/app/components/base/markdown/index.tsx | Refactor to use dynamic import for ReactMarkdown wrapper |
web/app/components/base/markdown-blocks/code-block.tsx | Add dynamic import for Flowchart component |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Important
Fixes #<issue number>
.Summary
Partially fixes #26311
Screenshots
Checklist
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint gods