Skip to content

plugin_install 安装的 runtime addon 与 editorBridge 内嵌实现不一致 #4

Description

@solanonaga

问题概述

我在把一个 Godot 项目的自动化流程迁移到 godot-devtool 时发现,plugin_install 安装到项目内的 runtime addon 实现,和 src/godot/editorBridge.ts 里内嵌的 runtime bridge 实现不一致。

这会导致一些 runtime routes 看起来已经支持,但实际行为不完整,甚至会出现“命令返回成功,但运行中的游戏/UI 没有真正发生对应动作”的情况。

我本地复核了安装后的 addon 文件,也检查了当前上游 main 分支。问题在 main 上仍然存在。

相关文件

  • src/addons/godot_devtool/commands/runtime_commands.gd
  • src/godot/editorBridge.ts

具体问题

  1. find_nearby_nodesruntime_commands.gd 中被声明为可用 route,但 dispatch 时固定返回 {"nodes": []}。而 editorBridge.ts 内嵌 runtime bridge 有真正的 nearby node 遍历实现。

  2. simulate_sequence 会读取 delayFrames / delay_frames,但没有 await get_tree().process_frame,所以输入序列中的帧延迟实际被忽略。editorBridge.ts 里的实现会等待对应帧数。

  3. click_button_by_text 找到文本匹配的按钮后只返回 clicked: true,但没有触发 Button.pressed,也没有发送 GUI input event。调用方会收到成功结果,但按钮逻辑没有执行。editorBridge.ts 里的实现会执行 button.emit_signal("pressed")

  4. get_game_node_properties 直接返回 node.get(name),复杂 Variant / Object 的 JSON 返回可能不稳定。editorBridge.ts 里的实现会通过 _serialize_value(...) 处理 Vector2Vector3ColorNodePathObject 等类型。

预期行为

plugin_install 安装进 Godot 项目的 runtime addon 应该和 godot-devtool 实际暴露的 runtime 能力保持一致:

  • 如果 route 标记为 supported,命令成功时应该真的执行对应行为。
  • simulate_sequence 应该尊重 delayFrames
  • click_button_by_text 应该实际触发按钮,或者明确返回 unsupported / failed。
  • find_nearby_nodes 应该执行查询,或者不要声明为已支持。
  • property 返回值应该做 JSON-safe 序列化。

实际影响

这个问题会影响依赖 runtime 自动化的项目验证流程:

  • UI 自动化可能误判为“按钮已点击”,但实际按钮逻辑没有运行。
  • 输入序列的时间间隔失效,复杂交互测试可能不可信。
  • nearby node 查询永远为空。
  • 节点属性读取在复杂类型上可能和内嵌 runtime bridge 行为不一致。

最严重的是 click_button_by_text 返回成功但没有产生实际 UI 行为,容易让上层 smoke test 或自动化检查出现假阳性。

复现方式

  1. 在 Godot 项目中通过 plugin_install 安装 godot-devtool addon。
  2. 查看安装后的 addons/godot_devtool/commands/runtime_commands.gd
  3. 对比仓库中的 src/godot/editorBridge.ts 内嵌 runtime bridge 实现。
  4. 调用 click_button_by_textsimulate_sequencefind_nearby_nodes,可以看到 addon 侧行为与内嵌 runtime bridge 不一致。

建议修复方向

可以考虑:

  1. editorBridge.ts 内嵌 runtime bridge 中较完整的实现同步到 src/addons/godot_devtool/commands/runtime_commands.gd
  2. 让 addon runtime 和 editorBridge runtime 由同一份源生成,避免两套实现继续漂移。
  3. 增加发布前检查,确保 routes() 中声明支持的 runtime command 在安装后的 addon 中有真实实现,并且和 server/editorBridge 侧能力一致。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions