Skip to content

perf(render): memo 稳定化 + Context useMemo + 列表项 memo,消除全量重渲染 - #42

Merged
Color2333 merged 1 commit into
mainfrom
perf/pr2-render
Jul 17, 2026
Merged

perf(render): memo 稳定化 + Context useMemo + 列表项 memo,消除全量重渲染#42
Color2333 merged 1 commit into
mainfrom
perf/pr2-render

Conversation

@Color2333

Copy link
Copy Markdown
Owner

PR2 — 运行时渲染(中风险)

ToastContext/ChannelContext

  • value 加 useMemo,避免每次 Provider render 新建 value 导致所有消费者重渲染

Papers.tsx(消除勾选/toast 时 20 卡全量重渲染)

  • PaperListItem/PaperGridItem props 改稳定 callback(onSelect/onFavorite/onReject/onNavigate 接 id),消除每 render 内联箭头新引用击穿 memo

Agent.tsx(长会话每键不再重渲染 N ChatBlock)

  • onOpenArtifact 提为 useCallback handleOpenArtifact
  • EmptyState onSelect 改直接传 handleSend

Collect.tsx

  • SearchResultCard 加 memo + handleResultToggle useCallback

Statistics.tsx

  • TopicCard 加 memo

Pipelines.tsx

  • 抽 RunRow memo 组件,navigate 稳定引用(table 虚拟化作为后续)

验证

  • typecheck 通过;5 PR 合并零冲突 + build 通过

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 已消除主要开销)
@github-actions

Copy link
Copy Markdown

🔍 OpenCode PR Review Required

这是一个受保护的分支,merge 前需要进行 code review。

请运行以下命令进行 OpenCode review:

/oc review https://github.com/Color2333/PaperMind/pull/$PR_NUM

或者在 PR 页面评论 /oc 来触发 OpenCode review。


This is an automated reminder from PR Review Gate.

@Color2333
Color2333 merged commit faa066f into main Jul 17, 2026
2 checks passed
@Color2333
Color2333 deleted the perf/pr2-render branch July 17, 2026 16:07
Sign up for free to 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