Skip to content

fix: resolve MaiBot WebUI endpoint from [http] section (Core 1.3.15+) - #18

Open
NethielChou wants to merge 3 commits into
Mai-with-u:mainfrom
NethielChou:fix/maibot-webui-http-port
Open

NethielChou wants to merge 3 commits into
Mai-with-u:mainfrom
NethielChou:fix/maibot-webui-http-port

Conversation

@NethielChou

Copy link
Copy Markdown

问题

MaiBot Core 1.3.15+ 把 WebUI 的监听地址/端口从 [webui] 段迁移到了 [http] 段([webui] 仅剩 enabled/mode 等字段),但启动器 readMaiBotWebUiEndpointSync() 仍只读 document.webui,读不到就回退 MAIBOT_WEBUI_FALLBACK_PORT = 8001。

后果:

  • 启动器 WebUI 入口、conflictPorts、readyPorts 固定使用 8001,与实例真实端口(如 8003/8008)不一致,内置 WebUI 打不开;
  • 单机多实例时 8001 只能属于一个实例,其余实例的入口必然错误;若升级后多个实例都停留在默认 8001,第二个实例启动还会被启动器的端口预检拦下(报 8001 被占用)。

Fixes #17

改动

  • src/main/services/init-manager.ts(1 行逻辑 + 注释):
// MaiBot Core 1.3.15+ moved host/port from [webui] to [http]; keep [webui] for older cores.
const config = document.http ?? document.webui;
  • scripts/tests/runtime-config-isolation.test.ts:新增一条测试,覆盖
    • [http] 段存在时优先使用其 port;
    • 只有 [webui] 段时回退到旧字段(兼容旧核心)。

兼容性

  • 新核心(1.3.15+):读取 [http].port;[http].host 是数组,asString() 会回退到 fallback host(127.0.0.1),不影响外部访问配置;
  • 旧核心:没有 [http] 段 → document.http 为 undefined → 回退 [webui],行为与现状一致;
  • 两者都缺失/损坏:仍走原有 fallback(8001)与 fallbackReason 逻辑。

测试

本地环境没有 bun,未能执行 bun test / bun run typecheck,因此新增的测试与类型检查交给 CI 验证。改动仅为单行读取顺序 + 新增测试,不涉及其他逻辑。

@NethielChou

Copy link
Copy Markdown
Author

补充两条最新信息:

  • issue [Bug] 启动器 WebUI 入口读不到核心 1.3.15+ 的 [http] port,多实例下固定打开 8001 #17 里新增了 OneKey 0.7.4 + Core 1.3.19(单实例、[http] port=18001) 的独立复现:启动器面板显示 "MAIBOT WEBUI 暂不可访问",浏览器访问 18001 正常;
  • 该复现同时更正了 issue 正文里一处说法:ConfigBase.from_dict 会静默 pop 掉 [webui] 里多余的 host/port(不触发 extra="forbid"),所以"垫片"写法可行,但不影响本 PR 的读取顺序修复;
  • 另外确认 [http] 段由 8.15.62 的一次性迁移引入,旧核心没有该段,本 PR 的 document.http ?? document.webui 回退对旧核心安全。

当前 CI 为 action_required(首次贡献需维护者批准运行),麻烦有空批准并 review。谢谢!

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.

[Bug] 启动器 WebUI 入口读不到核心 1.3.15+ 的 [http] port,多实例下固定打开 8001

1 participant