perf(render): memo 稳定化 + Context useMemo + 列表项 memo,消除全量重渲染 - #42
Merged
Conversation
PR2 — 运行时渲染
ToastContext/ChannelContext:
- value 加 useMemo(参照 GlobalTaskContext 已有模式),避免每次 Provider render 新建 value
导致所有 useToast/useChannels 消费者重渲染
Papers.tsx(消除勾选/toast 时 20 卡全量重渲染):
- PaperListItem/PaperGridItem props 改稳定 callback:onSelect/onFavorite/onReject/onNavigate
接 id/path 由子组件内部用 paper.id 调用,消除每 render 内联箭头新引用击穿 memo
Agent.tsx(长会话每键不再重渲染 N ChatBlock):
- onOpenArtifact 提为 useCallback handleOpenArtifact(setCanvas 是稳定 useState setter)
- EmptyState onSelect={(p)=>handleSend(p)} 改直接传 handleSend(已是 useCallback)
Collect.tsx:
- SearchResultCard 加 memo + props 稳定化:onToggle 改 handleResultToggle useCallback 接 index,
onNavigate 直接传 navigate,消除内联箭头击穿 memo
Statistics.tsx:
- TopicCard 加 memo(props 仅 stat,浅比较有效)
Pipelines.tsx:
- 抽 RunRow memo 组件,navigate 稳定引用传入,消除筛选切换时全量行重渲染
(table 虚拟化作为后续,当前规模行 memo 已消除主要开销)
🔍 OpenCode PR Review Required这是一个受保护的分支,merge 前需要进行 code review。 请运行以下命令进行 OpenCode review: 或者在 PR 页面评论 This is an automated reminder from PR Review Gate. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR2 — 运行时渲染(中风险)
ToastContext/ChannelContext
Papers.tsx(消除勾选/toast 时 20 卡全量重渲染)
Agent.tsx(长会话每键不再重渲染 N ChatBlock)
Collect.tsx
Statistics.tsx
Pipelines.tsx
验证