feat: capture before/after values for changed props/state/hooks during profiling
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 30/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- react, typescript
调研方向
阅读 issue #18 以及 devtools-bridge.ts:103-126 和 :131,以了解 changed-key profiling 和 inspectElement。比较 snapshot、targeted-watch 和 direct-fiber 这几种方案,然后确定该 feature 将接受哪种方案以及怎样的性能/准确性表现;该 issue 目前没有指定单一的实现或测试。
由索引模型根据 Issue 内容生成。
描述
Problem
Issue #18 surfaces the names of changed props/state/hooks in profiling output (e.g. props: onClick, className), but not their actual values. Knowing that className changed is useful, but knowing it changed from "btn" to "btn active" would be far more actionable for debugging.
The React DevTools profiling protocol only sends key names — values are not included by design (to keep profiling lightweight).
Possible approaches
Option A: Snapshot-based diffing (heavy, comprehensive)
During profiling, call inspectElement() after each commit for every component that changed. Store snapshots and diff consecutive ones to reconstruct before/after values.
- Pro: Uses existing infrastructure —
inspectElementalready works over the DevTools WebSocket protocol - Con:
inspectElementis async over WebSocket. Calling it for every changed component after every commit adds significant overhead and could slow profiling on busy apps - Con: "Before" values are approximated (previous snapshot), not true pre-commit values
Option B: Targeted watch mode (practical middle ground)
Let the user specify components to watch during profiling (e.g. profile-watch @c5). Only snapshot those specific components after each commit, reducing overhead.
- Pro: Practical performance trade-off — overhead scales with watched components, not total tree size
- Pro: User explicitly opts in, so the cost is expected
- Con: Requires knowing which components to watch upfront (could combine with a post-hoc "inspect the top offenders" step)
Option C: Direct fiber access (fragile, precise)
Inject custom code into the page that reads fiber.memoizedProps / fiber.pendingProps during onCommitFiberRoot to capture true before/after values at commit time.
- Pro: Would give true before/after values with no async overhead
- Con: Very fragile — fiber internals are not a public API and break across React versions
- Con: Requires forking or monkey-patching React DevTools backend code
- Con: Significant implementation complexity
Context
- Depends on #18 (surface changed key names first)
- The tool connects to React via the DevTools wire protocol over WebSocket (
devtools-bridge.ts) inspectElement()can already fetch full props/state/hooks on demand (devtools-bridge.ts:103-126)- Profiling uses
recordChangeDescriptions: truewhich only enables key name tracking (devtools-bridge.ts:131)
- 主要语言
- TypeScript
- 星标
- 243
- 派生
- 12
- 平均合并
- 11 小时 22 分钟
- 30 天内合并 PR
- 2
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
callstackincubator/agent-react-devtools 的其他 Issue
-
难度 5/5 一周以上 新手友好度 42/100
-
enhancement
难度 5/5 一周以上 新手友好度 25/100
callstackincubator/agent-react-devtools#56 · 1 条评论 ·
-
enhancement
难度 4/5 3-5 天 新手友好度 45/100
查看 callstackincubator/agent-react-devtools 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
vercel-labs/just-bash#464 ·
-
looksLikeSlug() is ASCII-only, so non-Latin entity slugs (e.g. Korean) skip exact match and collapse 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 1/5 1 小时以内 新手友好度 90/100
TanStack/tanstack.com#1293 ·