Skip to content

feat: 切换编辑器预览同步到 V1 运行时#926

Open
A-kirami wants to merge 2 commits intoOpenWebGAL:devfrom
A-kirami:feat/editor-preview-sync-v1-runtime
Open

feat: 切换编辑器预览同步到 V1 运行时#926
A-kirami wants to merge 2 commits intoOpenWebGAL:devfrom
A-kirami:feat/editor-preview-sync-v1-runtime

Conversation

@A-kirami
Copy link
Copy Markdown
Contributor

@A-kirami A-kirami commented Apr 7, 2026

Summary

  • 新增编辑器预览同步 V1 的协议类型与 envelope 定义,作为引擎侧的统一 contract
  • 新增 preview sync runtime、transport、embedded bootstrap 和 scene command 执行链路
  • 将初始化流程改为在 Enable_Editor_Sync 开启且初始场景就绪后再启动预览同步
  • 将 ready/snapshot 状态改为由 runtime 发布,并在重连后重新注册与恢复同步
  • 删除旧的 DebugCommandwebSocketFunc 和旧场景同步主路径
  • 补充协议、runtime、transport、bootstrap 和初始化门控相关测试

Impact

  • 编辑器侧需要按 webgal-editor-preview-sync.v1 subprotocol 和新的 request/event/response envelope 对接
  • 预览状态同步改为事件驱动,不再依赖固定轮询推送
  • 内嵌预览会尝试通过 bootstrap 获取 embeddedLaunchId,超时后退回未绑定注册
  • JMP 绑定改为复用新的场景快进实现

Test Plan

  • yarn build
  • 打开 Enable_Editor_Sync=true 的工程,确认引擎启动后会在初始场景完成加载后建立预览同步连接
  • 确认 register 成功后能收到 preview.ready.updated 和首个 stage.snapshot.updated
  • 验证 preview.command.sync-scenepreview.command.run-snippetpreview.command.set-effect 等命令可被接收并返回成功响应
  • 断开并恢复连接后,确认 runtime 会重新注册且不会产生重复活跃连接

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the editor synchronization logic by introducing a new WebSocket-based preview sync runtime and a structured protocol, replacing the legacy implementation. Key additions include a robust transport layer with reconnection support, an embedded bootstrap mechanism for iframe integration, and a refined scene synchronization command that supports backlog recovery. The initialization process was updated to conditionally start the sync runtime based on configuration. Review feedback identifies performance bottlenecks caused by frequent state serialization and a logic error in the scene comparison logic within the synchronization command.

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