Leadaxe:LxBox 解析 Xray 配置应复用 registry,不能在 UI 另建解析器

Leadaxe 认为 LxBox 应通过 source-kind registry 和 decode() 处理 Xray 文档,并在保存前运行核心校验;当前 UI 解析会把任意非 sing-box JSON 当成 Xray、丢掉 sibling outbounds,且可能静默保存坏节点。该修复缺少测试与本地化,问题应先按 issue 报告。

作者原文

Closing. This is a bad fix, and please don't open PRs like this — open an issue instead. I've filed the bug here: #209.

The bug is real. The fix isn't.

Why this is the wrong solution

  1. It ignores the registry. The source-kind registry already knows the Xray dialect: xray_outbound, xray_config, the outbound array, all with mapper: "xray". Instead of using decode() and the registry, you copy-pasted the whole sing-box save path and hardcoded your own heuristics into the screen (protocol, a freedom/blackhole list that already misses dns and loopback). That's a second parser living in the UI.
  2. It skips the core check. The sing-box branch runs checkConfig before saving (§455). Yours doesn't, and you even added a UI note legitimizing it ("The core doesn't validate it on save"). A broken node now saves silently.
  3. "Not sing-box" ≠ "Xray". !sourceIsSingbox sends any non-sing-box JSON down the Xray path.
  4. It destroys data. From an Xray document only the first outbound is kept. Nodes that depend on sibling outbounds (dialerProxy, fragment) break after save.
  5. Sloppy code. The out['outbounds'] branch in _bodyTextXRay is unreachable (it receives the outbound, not the document) and indexes dynamic unchecked. The array form doesn't check the first element isn't freedom/blackhole. Re-tagging a bare object writes unindented JSON, everything else is indented. Comments are copied from the sing-box code and describe the wrong thing (type, §435/§575). Not run through dart format.
  6. New UI string without localization, no spec, no tests, wrong branch (main instead of develop).

Report bugs as issues with steps to reproduce and a sample config. We'll fix them in a way that fits the architecture.