Skip to content

Conversation

@weareoutman
Copy link
Member

@weareoutman weareoutman commented Oct 14, 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

  • 新功能

    • 新增实验性“应用预览”模式:通过 URL 开关启用,支持预览、更新、重载及前进/后退导航。
    • Plop 增加 VSCode 测试配置生成选项,自动更新 .vscode 设置与启动项。
  • 重构

    • 启动流程拆分为预览/非预览路径,集中化错误处理以提升稳定性。
  • 变更

    • 公共 API 表面新增未记录的 getBrickPackages 接口。
  • Chores

    • 添加工具依赖 jsonc-parser。

@coderabbitai
Copy link

coderabbitai bot commented Oct 14, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

本次变更:在 runtime API 报告与内部导出中引入并暴露未文档化的 getBrickPackages;在 brick-container 启动中新增基于 _experimental_app_preview_ 的 App 预览流、AppPreviewer 与集中错误处理;在 packages/yo 添加 jsonc-parser 并扩展 Plop 以生成 VSCode 测试配置。

Changes

Cohort / File(s) Change Summary
API 报告更新
etc/runtime.api.md
getBrickPackages 加入 __secret_internals 内部导出列表;新增未文档化的公共签名 function getBrickPackages(): BrickPackage[];
Brick 容器启动与预览
packages/brick-container/src/bootstrap.ts
新增基于 URL 标记 _experimental_app_preview_ 的 App 预览流;新增 AppPreviewer 类与 PreviewWindow 接口;引入 doCreateRuntime() 用于按需挂载钩子;抽取并使用 handleError() 统一错误处理;在预览模式下通过 window._preview_only_appPreviewer 暴露实例并短路 bootstrap 返回。
内部导出调整
packages/runtime/src/internal/secret_internals.ts
重新导出 getBrickPackages(转发导出,未修改实现)。
YO 包:Plop 与 VSCode 测试设置
packages/yo/package.json, packages/yo/src/plopfile.js
package.json 中添加 jsonc-parser 依赖;在 plopfile.js 中新增 vscode-testing 生成器选项与处理器 initVscodeTesting,实现对 .vscode/settings.json.vscode/launch.json 的读取、解析(使用 jsonc-parser)、合并与写入,并新增 getWorkspaceFolders 辅助函数。

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning PR 描述只包含未填充的模板内容,未勾选依赖检查和提交信息检查选项,也未在简单描述和 Todo 区域提供任何实际说明,缺乏必要的信息。 请根据仓库模板填写依赖检查和提交信息检查的结果,勾选对应选项并补充简单描述与 Todo 内容,以完善 MR 描述。
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed 标题准确简洁地概括了本次主要改动——支持应用预览功能,并且与代码改动高度契合。
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch steve/v3-app-preview

📜 Recent 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 0aff1b2 and 0c9ae17.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (2)
  • packages/yo/package.json (1 hunks)
  • packages/yo/src/plopfile.js (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/yo/package.json
  • packages/yo/src/plopfile.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@weareoutman weareoutman requested a review from Copilot October 14, 2025 03:51
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 PR introduces support for app preview functionality by adding conditional runtime creation and an AppPreviewer class that enables live preview capabilities. The feature is activated through the _experimental_app_preview_ URL parameter.

  • Added conditional runtime creation based on preview mode
  • Implemented AppPreviewer class with setup, update, and navigation methods
  • Exported getBrickPackages function to support preview functionality

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/runtime/src/internal/secret_internals.ts Exports getBrickPackages function for external access
packages/brick-container/src/bootstrap.ts Implements app preview functionality with conditional bootstrap logic
etc/runtime.api.md Updates API documentation to include getBrickPackages export

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

history.replaceState(null, "", url);
const runtime = doCreateRuntime();
await loadCheckLogin();
await runtime.bootstrap(data as any);
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

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

Avoid using 'as any' type assertion. Consider properly typing the data parameter or using a more specific type assertion.

Suggested change
await runtime.bootstrap(data as any);
await runtime.bootstrap(data);

Copilot uses AI. Check for mistakes.
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

📜 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 85a05ea and 0858f23.

📒 Files selected for processing (3)
  • etc/runtime.api.md (2 hunks)
  • packages/brick-container/src/bootstrap.ts (4 hunks)
  • packages/runtime/src/internal/secret_internals.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build (20.x)
  • GitHub Check: Analyze (javascript-typescript)

Comment on lines +124 to +141
function doCreateRuntime() {
return createRuntime({
hooks: {
auth,
checkPermissions,
flowApi,
checkInstalledApps,
menu,
images: { imagesFactory, widgetImagesFactory },
messageDispatcher,
...(isAppPreview
? null
: {
fulfilStoryboard,
pageView: analytics.pageView,
}),
},
});
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

修复 ...null 展开导致的运行时异常

_experimental_app_preview_ 参数存在时,isAppPreviewtrue,表达式 ...(isAppPreview ? null : { … }) 会在对象字面量内尝试展开 null,从而抛出 TypeError: Cannot convert undefined or null to object,预览模式在创建 runtime 之前即崩溃。请将条件分支改为展开空对象,或在展开前先行判空。

-      ...(isAppPreview
-        ? null
-        : {
-            fulfilStoryboard,
-            pageView: analytics.pageView,
-          }),
+      ...(isAppPreview
+        ? {}
+        : {
+            fulfilStoryboard,
+            pageView: analytics.pageView,
+          }),
🤖 Prompt for AI Agents
In packages/brick-container/src/bootstrap.ts around lines 124 to 141, the object
spread uses ...(isAppPreview ? null : { … }) which throws when isAppPreview is
true because null cannot be spread; replace the conditional to spread an empty
object instead (e.g. ...(isAppPreview ? {} : { fulfilStoryboard, pageView:
analytics.pageView })) or restructure to conditionally add the properties only
when isAppPreview is false, ensuring no null/undefined is ever passed to the
object spread.

@cypress
Copy link

cypress bot commented Oct 14, 2025

next-core    Run #11746

Run Properties:  status check passed Passed #11746  •  git commit d2a4d2284e ℹ️: Merge 0c9ae178dc038a8dc009110e3683cecf536096b5 into 85a05ea25da9ed3b2ba4d64ffc61...
Project next-core
Branch Review steve/v3-app-preview
Run status status check passed Passed #11746
Run duration 00m 26s
Commit git commit d2a4d2284e ℹ️: Merge 0c9ae178dc038a8dc009110e3683cecf536096b5 into 85a05ea25da9ed3b2ba4d64ffc61...
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 ↗︎

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

🧹 Nitpick comments (3)
packages/yo/src/plopfile.js (3)

421-421: 移除注释掉的代码。

第 421 行的注释代码应该删除,保持代码整洁。

应用此差异删除注释代码:

   let settings = {};
   if (existsSync(settingsJson)) {
-    // settings = JSON.parse(await readFile(settingsJson, "utf-8"));
     const errors = [];

432-443: 考虑更谨慎地合并设置,避免覆盖用户自定义配置。

当前使用 Object.assign 会直接替换 jest.runModejest.jestCommandLine 等属性。如果用户已经自定义了这些设置,它们将会被覆盖丢失。

建议更智能地合并配置,例如:

  • 只在属性不存在时才添加
  • 或者提供选项让用户决定是否覆盖

参考实现:

-  Object.assign(settings, {
-    "jest.runMode": "on-demand",
-    "jest.jestCommandLine": "npx test-next",
-    "jest.useJest30": true,
-    "jest.nodeEnv": {
-      NODE_ENV: "test",
-    },
-    "jest.virtualFolders": folders.map((folder) => ({
-      name: folder,
-      rootPath: folder,
-    })),
-  });
+  // Merge settings, only set if not already defined by user
+  settings["jest.runMode"] ??= "on-demand";
+  settings["jest.jestCommandLine"] ??= "npx test-next";
+  settings["jest.useJest30"] ??= true;
+  settings["jest.nodeEnv"] ??= { NODE_ENV: "test" };
+  // Always update virtualFolders to reflect current workspace structure
+  settings["jest.virtualFolders"] = folders.map((folder) => ({
+    name: folder,
+    rootPath: folder,
+  }));

444-444: 考虑为文件写入操作添加错误处理。

writeFile 操作可能因权限问题或磁盘空间不足而失败。虽然当前函数的调用者可能会处理错误,但在此处添加 try-catch 可以提供更友好的错误消息。

参考实现:

try {
  await writeFile(settingsJson, JSON.stringify(settings, null, 2) + "\n");
} catch (error) {
  return `Failed to write .vscode/settings.json: ${error.message}`;
}
📜 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 34186b9 and 0aff1b2.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (2)
  • packages/yo/package.json (1 hunks)
  • packages/yo/src/plopfile.js (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build (20.x)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (5)
packages/yo/package.json (1)

24-24: LGTM!

依赖添加正确,版本 3.3.1 是当前最新稳定版本,使用 ^ 范围符合最佳实践。

根据学习资料

packages/yo/src/plopfile.js (4)

3-5: LGTM!

导入声明正确,添加了新功能所需的文件操作和 JSONC 解析功能。


127-130: LGTM!

新增的 VSCode 测试设置选项遵循现有模式,实现正确。


395-397: LGTM!

处理逻辑正确,与其他类型的处理保持一致。


407-488: 删除关于 rootDir 变量扩展的误导性评论
代码中使用的模板字符串会在运行时计算 ${rootDir}/${folder} 并写入实际路径,无需额外处理。

Likely an incorrect or invalid review comment.

@weareoutman weareoutman merged commit d656aeb into v3 Oct 14, 2025
8 checks passed
@weareoutman weareoutman deleted the steve/v3-app-preview branch October 14, 2025 06:29
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