Skip to content

Conversation

@weareoutman
Copy link
Member

@weareoutman weareoutman commented Jun 30, 2025

依赖检查

组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。

请勾选以下两组选项其中之一:

  • 本次 MR 没有使用上游组件(例如框架、后台组件等)的较新版本提供的特性。

或者:

  • 本次 MR 使用了上游组件(例如框架、后台组件等)的较新版本提供的特性。
  • 在对应的文件中更新了该上游组件的依赖版本(或确认了当前声明的依赖版本已包含本次 MR 使用的新特性)。

提交信息检查

Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。

破坏性变更是针对于下游使用者而言,可以通过本次改动对下游使用者的影响来识别变更类型:

  • 下游使用者不做任何改动,仍可以正常工作时,那么它属于普通变更。
  • 反之,下游使用者不做改动就无法正常工作时,那么它属于破坏性变更。

例如,构件修改了一个属性名,小产品 Storyboard 中需要使用新属性名才能工作,那么它就是破坏性变更。
又例如,构件还没有任何下游使用者,那么它的任何变更都是普通变更。

破坏性变更:

  • ⚠️ 本次 MR 包含破坏性变更的提交,请继续确认以下所有选项:
  • 没有更好的兼容方案,必须做破坏性变更。
  • 使用了 feat 作为提交类型。
  • 标注了 BREAKING CHANGE: 你的变更说明
  • 同时更新了本仓库中所有下游使用者的调用。
  • 同时更新了本仓库中所有下游使用者对该子包的依赖为即将发布的 major 版本。
  • 同时为其它仓库的 Migrating 做好了准备,例如文档或批量改动的方法。
  • 手动验证过破坏性变更在 Migrate 后可以正常工作。
  • 破坏性变更所在的提交没有意外携带其它子包的改动。

新特性:

  • 本次 MR 包含新特性的提交,且该提交不带有破坏性变更,并使用了 feat 作为提交类型。
  • 给新特性添加了单元测试。
  • 手动验证过新特性可以正常工作。

问题修复:

  • 本次 MR 包含问题修复的提交,且该提交不带有新特性或破坏性变更,并使用了 fix 作为提交类型。
  • 给问题修复添加了单元测试。
  • 手动验证过问题修复得到解决。

杂项工作:

即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:

  • 本次 MR 包含杂项工作的提交,且该提交不带有问题修复、新特性或破坏性变更,并使用了 chore, docs, test 等作为提交类型。

Summary by CodeRabbit

  • 新功能

    • 新增了用于测试嵌套条件渲染(:if)交互行为的页面和自动化测试用例。
    • 新增调试页面,可通过按钮切换调试信息的显示。
  • 修复

    • 优化了条件渲染和子节点更新的内部处理,提升了嵌套和动态场景下的渲染一致性。
  • 测试

    • 更新并完善了渲染引擎的相关单元测试和端到端测试,提高了代码的稳定性和覆盖率。
  • 其他

    • 调整了部分日志等级,减少开发模式下的冗余日志输出。
    • 简化了渲染流程,移除部分内部缓存和跟踪逻辑,提升渲染性能和代码维护性。
    • 改进了节点挂载和DOM插入逻辑,确保抽象节点正确处理子元素。
    • 重命名并简化了渲染节点类型,优化了渲染树结构及相关类型定义。

@coderabbitai
Copy link

coderabbitai bot commented Jun 30, 2025

Walkthrough

本次变更重构了 runtime 渲染树的节点结构,将原有的 PLACEHOLDER 节点统一为 ABSTRACT 节点,简化了类型体系,并移除了渲染节点的跟踪与缓存机制。渲染逻辑和挂载流程同步调整以适配 ABSTRACT 节点。相关测试、类型定义和部分工具函数也进行了相应修改,并补充了 E2E 场景和 Storyboard 路由配置。

Changes

文件/路径分组 变更摘要
cypress/e2e/control-nodes.spec.js 新增 E2E 测试用例,验证嵌套 :if 控制节点的重新渲染行为。
mock-micro-apps/e2e/storyboard.yaml 新增 /nested-if/debug 路由,分别用于测试嵌套条件渲染和调试场景。
packages/brick-container/scripts/start.js WebpackDevServer 客户端日志级别增加 logging: "warn" 配置。
packages/react-runtime/src/ReactUseBrick.tsx 移除 ESLint 禁用注释,WebComponent 类型断言由 any 改为 "div"
packages/runtime/src/internal/Renderer.ts
packages/runtime/src/internal/RendererContext.ts
移除节点跟踪与缓存(hasTrackingControls、keyPath、memoize),所有控制节点统一包裹为 RenderAbstract,渲染和重新渲染流程调整,辅助函数替换与重构。
packages/runtime/src/internal/interfaces.ts
packages/runtime/src/internal/enums.ts
PLACEHOLDER 节点及相关接口统一更名为 ABSTRACT,RenderNode/RenderChildNode/RenderReturnNode 类型定义同步调整,去除 tracking/hasTrackingControls 字段。
packages/runtime/src/internal/mount.ts 挂载树遍历及元素追加逻辑调整,跳过 ABSTRACT 节点,确保元素挂载到最近的实体节点。
packages/runtime/src/internal/Renderer.spec.ts 控制节点相关测试断言更新,适配 RenderTag.ABSTRACT 节点结构,新增嵌套 :if 测试用例。
packages/runtime/src/internal/secret_internals.ts renderUseBrick 内部逻辑调整,遍历 child 链定位 BRICK 节点,适配新的节点结构。
packages/runtime/src/internal/secret_internals.spec.ts 控制节点 root 相关测试用例改为跳过(skip),并补充注释说明。
packages/runtime/src/internal/Runtime.spec.ts window.location 赋值方式调整为类型断言,规避类型限制。

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/brick-container/scripts/start.js

Oops! Something went wrong! :(

ESLint: 9.29.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@next-core/eslint-config-next' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:202:49)

packages/react-runtime/src/ReactUseBrick.tsx

Oops! Something went wrong! :(

ESLint: 9.29.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@next-core/eslint-config-next' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:202:49)

packages/runtime/src/internal/Renderer.spec.ts

Oops! Something went wrong! :(

ESLint: 9.29.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@next-core/eslint-config-next' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:202:49)

  • 8 others
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Jun 30, 2025

Codecov Report

Attention: Patch coverage is 98.27586% with 2 lines in your changes missing coverage. Please review.

Project coverage is 95.23%. Comparing base (ecea0b3) to head (c2d3e93).
Report is 4 commits behind head on v3.

Files with missing lines Patch % Lines
packages/runtime/src/internal/RendererContext.ts 96.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##               v3    #4743      +/-   ##
==========================================
- Coverage   95.26%   95.23%   -0.03%     
==========================================
  Files         209      209              
  Lines        9060     9066       +6     
  Branches     1744     1738       -6     
==========================================
+ Hits         8631     8634       +3     
- Misses        319      321       +2     
- Partials      110      111       +1     
Files with missing lines Coverage Δ
packages/react-runtime/src/ReactUseBrick.tsx 100.00% <100.00%> (ø)
packages/runtime/src/internal/Renderer.ts 94.07% <100.00%> (-0.36%) ⬇️
packages/runtime/src/internal/mount.ts 94.64% <100.00%> (+0.52%) ⬆️
packages/runtime/src/internal/secret_internals.ts 94.96% <100.00%> (+0.07%) ⬆️
packages/runtime/src/internal/RendererContext.ts 97.94% <96.66%> (-0.42%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cypress
Copy link

cypress bot commented Jun 30, 2025

next-core    Run #11468

Run Properties:  status check passed Passed #11468  •  git commit 9834faf895 ℹ️: Merge c2d3e93f113007aca29a5239f64316b13e421734 into ecea0b31aa75450c6b146c96b3f6...
Project next-core
Branch Review steve/v3-control-node-bug
Run status status check passed Passed #11468
Run duration 00m 22s
Commit git commit 9834faf895 ℹ️: Merge c2d3e93f113007aca29a5239f64316b13e421734 into ecea0b31aa75450c6b146c96b3f6...
Committer Shenwei Wang
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 17
View all changes introduced in this branch ↗︎

@weareoutman weareoutman force-pushed the steve/v3-control-node-bug branch 4 times, most recently from c76b40a to 84558a4 Compare July 1, 2025 06:57
@weareoutman weareoutman requested a review from Copilot July 1, 2025 06:59
@weareoutman weareoutman marked this pull request as ready for review July 1, 2025 06:59

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

@weareoutman weareoutman force-pushed the steve/v3-control-node-bug branch 2 times, most recently from 01bf1d1 to 58b37b3 Compare July 1, 2025 07:44
coderabbitai[bot]

This comment was marked as resolved.

@weareoutman weareoutman force-pushed the steve/v3-control-node-bug branch from 58b37b3 to af760cf Compare July 1, 2025 07:52
@weareoutman weareoutman requested a review from Copilot July 1, 2025 07:55
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
packages/runtime/src/internal/RendererContext.ts (1)

803-809: getEntityReturnNode 函数存在栈安全性问题

这个递归函数在深度嵌套的抽象节点中可能导致栈溢出。

建议改为迭代实现以避免栈溢出:

-function getEntityReturnNode(node: RenderReturnNode): RenderRoot | RenderBrick {
-  let current = node;
-  while (current.tag === RenderTag.ABSTRACT) {
-    current = current.return;
-  }
-  return current;
-}
+function getEntityReturnNode(node: RenderReturnNode): RenderRoot | RenderBrick {
+  let current = node;
+  while (current.tag === RenderTag.ABSTRACT && current.return) {
+    current = current.return;
+  }
+  return current as RenderRoot | RenderBrick;
+}
🧹 Nitpick comments (2)
packages/runtime/src/internal/Renderer.ts (1)

274-276: 使用 forEach 替代传统 for 循环

代码更简洁,但在性能敏感的渲染路径中,传统 for 循环通常更快。

考虑在性能敏感的渲染代码中保持传统 for 循环:

-  rendered.forEach((item) => {
-    mergeRenderOutput(output, item);
-  });
+  for (const item of rendered) {
+    mergeRenderOutput(output, item);
+  }
packages/runtime/src/internal/RendererContext.ts (1)

680-727: findLastChildNodes 函数实现合理

该函数正确处理了抽象节点的遍历,区分普通节点和 portal 节点。逻辑复杂但看起来正确。

考虑添加更详细的注释说明复杂的遍历逻辑:

+  // 遍历给定节点及其子节点,查找最后的普通和 portal 节点
+  // level 用于跟踪抽象节点的嵌套深度,确保不会超出给定节点的范围
   let current: RenderChildNode | undefined = node;
   let level = 0;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 58b37b3 and af760cf.

📒 Files selected for processing (12)
  • mock-micro-apps/e2e/storyboard.yaml (1 hunks)
  • packages/brick-container/scripts/start.js (1 hunks)
  • packages/react-runtime/src/ReactUseBrick.tsx (1 hunks)
  • packages/runtime/src/internal/Renderer.spec.ts (5 hunks)
  • packages/runtime/src/internal/Renderer.ts (17 hunks)
  • packages/runtime/src/internal/RendererContext.ts (7 hunks)
  • packages/runtime/src/internal/Runtime.spec.ts (1 hunks)
  • packages/runtime/src/internal/enums.ts (1 hunks)
  • packages/runtime/src/internal/interfaces.ts (2 hunks)
  • packages/runtime/src/internal/mount.ts (3 hunks)
  • packages/runtime/src/internal/secret_internals.spec.ts (1 hunks)
  • packages/runtime/src/internal/secret_internals.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (10)
  • packages/brick-container/scripts/start.js
  • packages/runtime/src/internal/enums.ts
  • packages/runtime/src/internal/Runtime.spec.ts
  • packages/runtime/src/internal/secret_internals.spec.ts
  • packages/react-runtime/src/ReactUseBrick.tsx
  • packages/runtime/src/internal/mount.ts
  • packages/runtime/src/internal/secret_internals.ts
  • packages/runtime/src/internal/interfaces.ts
  • packages/runtime/src/internal/Renderer.spec.ts
  • mock-micro-apps/e2e/storyboard.yaml
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/runtime/src/internal/RendererContext.ts (1)
packages/runtime/src/internal/interfaces.ts (5)
  • RenderReturnNode (81-81)
  • RenderChildNode (80-80)
  • RenderBrick (61-64)
  • RenderNode (79-79)
  • RenderRoot (52-59)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build (20.x)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (15)
packages/runtime/src/internal/Renderer.ts (8)

51-51: 导入类型更新正确

RenderPlaceholder 更新为 RenderAbstract 与整体重构保持一致。


259-272: 移除 keyPath 参数简化了函数调用

参数简化有助于降低复杂性,与移除记忆化缓存的重构目标一致。


465-470: 控制节点包装逻辑实现正确

新的 RenderAbstract 节点包装机制正确实现了控制节点的统一处理。


619-624: reRender 调用签名更新正确

新的参数顺序 (returnNode, newNode, oldNode) 更直观,与 RendererContext 中的实现保持一致。


902-906: 增量渲染中的抽象节点创建

在增量渲染场景中正确创建了 RenderAbstract 节点,保持了架构一致性。

Also applies to: 954-960


1017-1019: 增量渲染的重新渲染调用

更新后的 reRender 调用签名在增量渲染场景中使用正确。


1125-1143: forEach 渲染逻辑保持一致

renderForEach 函数中的更新与整体架构变更保持一致,forEach 循环改为更简洁的形式。

Also applies to: 1148-1150


473-474: 请手动验证复杂嵌套场景下控制节点渲染逻辑的测试覆盖情况

自动扫描未发现针对嵌套 <if>/<for>/<switch> 场景的测试用例,建议在以下位置确认或补充测试:

  • packages/runtime/src/internal/Renderer.ts
    • Lines 473–474
    • Lines 481
    • Lines 483–495
    • Lines 496
    • Lines 499–510
    • Lines 513–518

可使用以下脚本快速定位现有测试文件并检查是否覆盖到嵌套场景:

#!/bin/bash
# 查找测试文件中涉及嵌套控制节点的测试用例
rg -l -e '<if' -e '<for' -e '<switch' --glob '*.{spec,test}.ts'
packages/runtime/src/internal/RendererContext.ts (7)

378-382: reRender 方法签名简化合理

新的签名 (returnNode, node, oldNode) 比原来的 (slotId, keyPath, node, returnNode) 更直观,移除了复杂的 keyPath 跟踪。


408-414: 前置兄弟节点查找逻辑正确

直接遍历查找 oldNode 的前置兄弟节点,逻辑简单清晰。


433-434: 使用新的 getContainedBricks 函数

替换了原有的 getBrickRange 函数,新函数逻辑更清晰。

Also applies to: 489-490


444-444: 简化兄弟节点链接

直接赋值 node.sibling = oldNode.sibling 比之前的复杂逻辑更简洁。


454-459: 抽象节点的实体返回节点解析

使用 getEntityReturnNode 跳过抽象节点找到实际的容器节点,逻辑正确。


729-769: findNextSiblingNode 函数逻辑正确

该函数正确实现了在 DOM 中查找下一个兄弟节点的逻辑,恰当处理了抽象节点的跳过。


771-801: getContainedBricks 函数实现正确

递归收集节点内包含的所有 brick,终止条件设置合理。

This comment was marked as outdated.

@weareoutman weareoutman force-pushed the steve/v3-control-node-bug branch from af760cf to c2d3e93 Compare July 1, 2025 08:21
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (2)
packages/runtime/src/internal/RendererContext.ts (2)

383-403: 新的树遍历逻辑替代记忆化缓存

使用直接树遍历替代记忆化缓存是重大架构变更。逻辑看起来正确,但在复杂的 DOM 结构中需要验证性能影响。


803-809: getEntityReturnNode 递归函数的栈安全性

这是一个递归函数,在深度嵌套的抽象节点中可能导致栈溢出。

🧹 Nitpick comments (3)
packages/runtime/src/internal/RendererContext.ts (3)

680-727: findLastChildNodes 函数复杂度较高

此函数实现了复杂的树遍历逻辑来查找最后的子节点。逻辑正确但相当复杂,需要确保边界情况处理得当。

考虑为复杂的遍历逻辑添加详细的单元测试,特别是嵌套抽象节点的场景:

// 建议添加测试用例
describe('findLastChildNodes', () => {
  it('should handle deeply nested abstract nodes', () => {
    // 测试深度嵌套的抽象节点
  });
  
  it('should correctly distinguish normal and portal nodes', () => {
    // 测试正常节点和门户节点的区分
  });
  
  it('should handle mixed node types', () => {
    // 测试混合节点类型
  });
});

729-769: findNextSiblingNode 函数逻辑复杂

此函数在查找下一个兄弟节点时需要处理抽象节点的遍历。实现正确但逻辑复杂,建议加强测试覆盖。

建议添加边界情况的单元测试,确保在各种节点结构下都能正确工作。


771-801: getContainedBricks 函数需要优化边界条件

函数在遍历包含的 brick 节点时有多个终止条件。逻辑看起来正确,但需要确保所有边界情况都被正确处理。

建议添加断言或日志来帮助调试,特别是在复杂的节点层次结构中:

function getContainedBricks(node: RenderChildNode) {
  const range = new Set<RenderBrick>();
  let current: RenderNode | undefined = node;
  let depth = 0; // 添加深度跟踪用于调试
  
  while (current) {
    // 添加深度限制防止无限循环
    if (depth > 1000) {
      console.warn('getContainedBricks: Maximum depth exceeded');
      break;
    }
    // ... 现有逻辑
  }
  return range;
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between af760cf and c2d3e93.

📒 Files selected for processing (12)
  • mock-micro-apps/e2e/storyboard.yaml (1 hunks)
  • packages/brick-container/scripts/start.js (1 hunks)
  • packages/react-runtime/src/ReactUseBrick.tsx (1 hunks)
  • packages/runtime/src/internal/Renderer.spec.ts (5 hunks)
  • packages/runtime/src/internal/Renderer.ts (17 hunks)
  • packages/runtime/src/internal/RendererContext.ts (7 hunks)
  • packages/runtime/src/internal/Runtime.spec.ts (1 hunks)
  • packages/runtime/src/internal/enums.ts (1 hunks)
  • packages/runtime/src/internal/interfaces.ts (2 hunks)
  • packages/runtime/src/internal/mount.ts (2 hunks)
  • packages/runtime/src/internal/secret_internals.spec.ts (1 hunks)
  • packages/runtime/src/internal/secret_internals.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (10)
  • packages/react-runtime/src/ReactUseBrick.tsx
  • packages/runtime/src/internal/Runtime.spec.ts
  • packages/brick-container/scripts/start.js
  • packages/runtime/src/internal/enums.ts
  • packages/runtime/src/internal/mount.ts
  • packages/runtime/src/internal/secret_internals.spec.ts
  • packages/runtime/src/internal/secret_internals.ts
  • mock-micro-apps/e2e/storyboard.yaml
  • packages/runtime/src/internal/Renderer.spec.ts
  • packages/runtime/src/internal/interfaces.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/runtime/src/internal/RendererContext.ts (1)
packages/runtime/src/internal/interfaces.ts (5)
  • RenderReturnNode (81-81)
  • RenderChildNode (80-80)
  • RenderBrick (61-64)
  • RenderNode (79-79)
  • RenderRoot (52-59)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build (20.x)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (7)
packages/runtime/src/internal/Renderer.ts (6)

51-51: 导入更新符合重构需求

RenderPlaceholder 更新为 RenderAbstract 的导入与整体重构保持一致。


259-272: 简化渲染函数参数,移除跟踪逻辑

移除 keyPath 参数和相关跟踪逻辑,简化了函数签名。更改与整体架构重构目标一致。


619-624: reRender 调用参数顺序更新

reRender 方法的参数顺序已从 (slotId, keyPath, node, returnNode) 更改为 (returnNode, node, oldNode)。更改与 RendererContext 中的新签名一致。


901-906: 路由渲染中的抽象节点创建

在增量子路由渲染中创建 RenderAbstract 控制节点是正确的。这确保了路由渲染与控制节点渲染使用相同的抽象节点模式。

Also applies to: 954-959


1125-1148: renderForEach 函数简化

移除 keyPath 参数并简化结果合并逻辑。更改与整体简化目标一致。


466-470: 确认 RenderAbstract 节点处理一致性

经验证,核心遍历和挂载逻辑在以下位置均正确跳过并处理了 RenderTag.ABSTRACT 节点,相关接口与测试覆盖也已到位,新增的 controlNode 构建逻辑符合预期,无需额外调整。

需要关注的文件:

  • packages/runtime/src/internal/RendererContext.ts:遍历时正确下钻并跳过抽象节点
  • packages/runtime/src/internal/mount.ts:跳过 RenderTag.ABSTRACT 后,将子元素挂载到 ROOT 或对应元素
  • packages/runtime/src/internal/interfaces.ts:RenderAbstract 接口已正确定义
  • packages/runtime/src/internal/Renderer.ts:controlNode 构建逻辑清晰
  • packages/runtime/src/internal/Renderer.spec.ts:测试已覆盖抽象节点场景
packages/runtime/src/internal/RendererContext.ts (1)

378-382: reRender 方法签名重大更改

方法签名从基于记忆化的参数更改为直接的节点参数。这是架构重构的核心部分,简化了接口但需要新的树遍历逻辑。

@weareoutman weareoutman requested a review from Copilot July 1, 2025 08:26
Copy link

Copilot AI left a 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 pull request fixes a bug related to control node handling and improves the rendering logic for nested and dynamic nodes in the runtime. Key changes include modifications to node type handling (e.g. replacing "PLACEHOLDER" with "ABSTRACT"), refactoring of the re-render and memoization logic in the renderer context, and adjustments in test cases and mounting behaviors to support the new control node structure.

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.

File Description
packages/runtime/src/internal/secret_internals.ts Revamped the brick node detection logic in renderUseBrick
packages/runtime/src/internal/RendererContext.ts Refactored reRender parameter order and child node traversal logic
packages/react-runtime/src/ReactUseBrick.tsx Modified type cast for tagName in the React useBrick component
Other files Various updates to enums, interfaces, tests, mounts, and scripts
Comments suppressed due to low confidence (2)

packages/runtime/src/internal/RendererContext.ts:382

  • The parameter order for reRender has been changed compared to the previous implementation; please verify all invocations throughout the codebase are updated accordingly to avoid parameter mismatches.
  ) {

packages/runtime/src/internal/secret_internals.ts:112

  • When traversing to determine the brick node, if no node with tag BRICK is found then tagName becomes null while renderRoot.child remains the original node, possibly leading to unexpected behavior. Confirm that this fallback behavior is intended and does not inadvertently bypass required node validations.
  let brickNode: RenderBrick | undefined;

@weareoutman weareoutman merged commit 4c1f6e9 into v3 Jul 1, 2025
8 checks passed
@weareoutman weareoutman deleted the steve/v3-control-node-bug branch July 1, 2025 08:28
export interface RenderPlaceholder extends BaseRenderNode {
tag: RenderTag.PLACEHOLDER;
export interface RenderAbstract extends BaseRenderNode {
tag: RenderTag.ABSTRACT;
Copy link
Member Author

@weareoutman weareoutman Jul 1, 2025

Choose a reason for hiding this comment

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

Now, we will always generate abstract nodes for control nodes and routes nodes in bricks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants