Repository navigation
fix(desktop,installer): compile LoopX.app with tauri/custom-protocol and clear stale managed runtime selection - #10272
Conversation
…and clear stale managed runtime selection Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
PR #10272 精确头评审(9d0a296bd99e)
问题背景与交付边界
本 PR 针对 #10254 合入后在 macOS 真机双击 /Applications/LoopX.app 暴露的两处真实启动故障做了最小闭环修复:其一是 scripts/desktop_app_install.py 调用 cargo build --release 时漏传 --features tauri/custom-protocol,导致 Tauri v2 保持 cfg(dev) 分支并尝试加载不存在的 http://127.0.0.1:5173,呈现白屏(NSURLErrorDomain -1004);其二是 install-local.sh 升级到新 release 后,若 ~/Library/Application Support/io.loopx.control-plane/runtime-selection.json 仍记住旧版受管 release,桌面壳会在启动阶段停留在对齐旧 CLI 与新版 Core 的引导界面。
关键实现与边界核查
- 嵌入式前端资源编译门禁(
scripts/desktop_app_install.py):build_release_binary()显式传入--features tauri/custom-protocol,使 Tauri v2 按cfg(not(dev))编译并将../static嵌入tauri://localhost/;同时在.loopx-desktop-app-build.json中记录"custom_protocol": true并在can_reuse_installed_app()中强校验,确保此前安装的旧版#10254白屏包不会被指纹复用,升级时自动触发安全重编。 - 过期受管运行时偏好清理:新增
clear_stale_managed_runtime_selection(),仅在 macOS 且已传入release_id、且runtime-selection.json明确指向~/.local/share/loopx/releases/<older_id>/...下的不同 release 时才清理该文件;同 release 绑定及受管目录外的自定义开发路径均严格原样保留,无越权写操作。 - 测试与真机验证:
tests/test_desktop_app_install.py新增 3 项针对tauri/custom-protocol参数传递、旧回执拒绝复用及runtime-selection.json三态边界(旧受管版清理 / 同版本保留 / 自定义路径保留)的回归单测,全部7 passed;ruff、semantic-vocabulary-drift-smoke.py、check_rfc_bilingual.py、loopx check全绿,且本机实装/Applications/LoopX.app后已验证 0 条:5173报错并建立 6 条至 Workbench:8796→ Core:8767的活跃连接。
对主干的风险
本改动仅作用于本地 macOS 安装器脚本 scripts/desktop_app_install.py 及其配套单测,不修改控制面协议、Core 运行时状态机或非 macOS 安装路径。clear_stale_managed_runtime_selection() 通过 Path.resolve().relative_to(releases_root) 严格限定删除作用域,不会误删受管发布目录外的自定义 LOOPX_BIN 偏好,亦不影响已有 Goal/会话数据;在 install-local.sh 与临时目录单测中仍沿用既有隔离条件,可随时单提交回滚,对主干回归风险极低。
Verdict
Approved for merge (author-owned COMMENTED exact-head review). No blocking findings on 9d0a296bd99efdf23be36ca6e690e8eecca176f7.
loopx-agent
left a comment
There was a problem hiding this comment.
Review Conclusion (Author-Owned Commented Fallback): Approve
动机
本 PR 修复 #10254 合入后在 macOS 真机启动本地安装版 /Applications/LoopX.app 时遇到的两处真实阻断:第一,scripts/desktop_app_install.py 调用 cargo build --release 时漏传 --features tauri/custom-protocol,导致 Tauri v2 保持 cfg(dev) 模式并在打开窗口后尝试访问不存在的 http://127.0.0.1:5173(NSURLErrorDomain -1004),表现为完全白屏;第二,当本机通过 install-local.sh 升级到新 release 后,若 ~/Library/Application Support/io.loopx.control-plane/runtime-selection.json 仍固定指向旧受管 release,桌面壳会在引导阶段停留在对齐旧 CLI 与新版 Core 的状态,无法顺利跳转至 Workbench。
改动思路
采用最小、可逆且高内聚的修复路径:编译期显式启用 tauri/custom-protocol 让 Tauri v2 将 ../static 嵌入 tauri://localhost/,同时把 "custom_protocol": true 写入构建回执 .loopx-desktop-app-build.json 并在指纹复用门禁中强制校验,从而让所有受旧版 #10254 影响的本机在下次安装时自动重建而非复用旧白屏包;对 runtime-selection.json 仅在 macOS 且已提供 release_id、且路径严格落在 ~/.local/share/loopx/releases/<other_release>/ 下时执行清理,完整保留同版本绑定与自定义开发路径。
具体改动
- scripts/desktop_app_install.py:在
build_release_binary()中为cargo build --release增加--features tauri/custom-protocol;在stage_app_bundle()写入"custom_protocol": true并在can_reuse_installed_app()强校验;新增clear_stale_managed_runtime_selection()并在install_desktop_app()安装与复用分支统一调用。 - tests/test_desktop_app_install.py:补充 3 组回归单测,覆盖
--features tauri/custom-protocol透传、缺失custom_protocol的旧回执拒绝复用,以及clear_stale_managed_runtime_selection()对旧受管 release 清理、同 release 保留和受管目录外自定义路径保留的完整边界。
对主干的风险
本改动严格收敛在本地 macOS 桌面应用安装脚本 scripts/desktop_app_install.py 与对应单测内,不触及 Core 控制面协议、状态机、非 macOS 路径或现有 Goal/会话数据。clear_stale_managed_runtime_selection() 通过 Path.resolve().relative_to(releases_root) 做路径隔离,不会误删受管发布目录外的自定义 LOOPX_BIN 偏好;旧版白屏安装仅因回执缺失 custom_protocol 触发一次增量重编,可单提交安全回滚,对主干回归风险极低。
我的整体评价
本次修复直击白屏(:5173 devUrl)与升级后卡启动页(过期 runtime-selection.json)两处真机根因,边界克制、回执失效机制设计严谨,单测(7 passed)、ruff、semantic-vocabulary-drift-smoke、check_rfc_bilingual、loopx check 与 macOS 真机安装启动(零 :5173 错误、6 条至 :8796 Workbench → :8767 Core 的活跃连接)均已实测通过。
English Verdict: Approve (author-owned COMMENTED fallback on exact head 9d0a296bd99efdf23be36ca6e690e8eecca176f7; no blocking findings).
loopx-agent
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机
本 PR 修复 #10254 合入后在 macOS 真机启动本地安装版 /Applications/LoopX.app 时遇到的两处真实阻断:第一,scripts/desktop_app_install.py 调用 cargo build --release 时漏传 --features tauri/custom-protocol,导致 Tauri v2 保持 cfg(dev) 模式并在打开窗口后尝试访问不存在的 http://127.0.0.1:5173(NSURLErrorDomain -1004),表现为完全白屏;第二,当本机通过 install-local.sh 升级到新 release 后,若 ~/Library/Application Support/io.loopx.control-plane/runtime-selection.json 仍固定指向旧受管 release,桌面壳会在引导阶段停留在对齐旧 CLI 与新版 Core 的状态,无法顺利跳转至 Workbench。
改动思路
采用最小、可逆且高内聚的修复路径:编译期显式启用 tauri/custom-protocol 让 Tauri v2 将 ../static 嵌入 tauri://localhost/,同时把 "custom_protocol": true 写入构建回执 .loopx-desktop-app-build.json 并在指纹复用门禁中强制校验,从而让所有受旧版 #10254 影响的本机在下次安装时自动重建而非复用旧白屏包;对 runtime-selection.json 仅在 macOS 且已提供 release_id、且路径严格落在 ~/.local/share/loopx/releases/<other_release>/ 下时执行清理,完整保留同版本绑定与自定义开发路径。
具体改动
- scripts/desktop_app_install.py:在
build_release_binary()中为cargo build --release增加--features tauri/custom-protocol;在stage_app_bundle()写入"custom_protocol": true并在can_reuse_installed_app()强校验;新增clear_stale_managed_runtime_selection()并在install_desktop_app()安装与复用分支统一调用。 - tests/test_desktop_app_install.py:补充 3 组回归单测,覆盖
--features tauri/custom-protocol透传、缺失custom_protocol的旧回执拒绝复用,以及clear_stale_managed_runtime_selection()对旧受管 release 清理、同 release 保留和受管目录外自定义路径保留的完整边界。
对主干的风险
本改动严格收敛在本地 macOS 桌面应用安装脚本 scripts/desktop_app_install.py 与对应单测内,不触及 Core 控制面协议、状态机、非 macOS 路径或现有 Goal/会话数据。clear_stale_managed_runtime_selection() 通过 Path.resolve().relative_to(releases_root) 做路径隔离,不会误删受管发布目录外的自定义 LOOPX_BIN 偏好;旧版白屏安装仅因回执缺失 custom_protocol 触发一次增量重编,可单提交安全回滚,对主干回归风险极低。
我的整体评价
本次修复直击白屏(:5173 devUrl)与升级后卡启动页(过期 runtime-selection.json)两处真机根因,边界克制、回执失效机制设计严谨,单测(7 passed)、ruff、semantic-vocabulary-drift-smoke、check_rfc_bilingual、loopx check 与 macOS 真机安装启动(零 :5173 错误、6 条至 :8796 Workbench → :8767 Core 的活跃连接)均已实测通过。
English Verdict: Approve (exact head 9d0a296bd99efdf23be36ca6e690e8eecca176f7; no blocking findings).
Summary
Fixes two real-machine launch failures observed when opening the locally installed macOS
LoopX.appafter #10254:Connection refusedto127.0.0.1:5173):scripts/desktop_app_install.pypreviously invokedcargo build --releasewithout--features tauri/custom-protocol. In Tauri v2, omittingtauri/custom-protocolleavescfg(dev)enabled, causing the release binary to navigate todevUrl(http://127.0.0.1:5173) instead of loading the embedded../staticboot launcher viatauri://localhost/.--features tauri/custom-protocolinbuild_release_binary()."custom_protocol": truein.loopx-desktop-app-build.jsonand require it incan_reuse_installed_app()so pre-fix#10254installs automatically rebuild instead of reusing the broken dev-mode binary.runtime-selection.jsonstalling boot alignment: Wheninstall-local.shupgrades~/.local/share/loopx/releases/<release_id>and restarts Core (:8767), a previously remembered~/Library/Application Support/io.loopx.control-plane/runtime-selection.jsonpointing to an older managed release under~/.local/share/loopx/releases/causesLoopX.appto hold on the boot screen trying to align the older CLI against the upgraded Core.clear_stale_managed_runtime_selection()to drop only stale preferences pointing inside~/.local/share/loopx/releases/to a different release id, while strictly preserving same-release pins and custom developer executables outside the managed releases root.Verification
uv run --extra test python -m pytest tests/test_desktop_app_install.py -q→7 passeduv run --extra test ruff check scripts/desktop_app_install.py tests/test_desktop_app_install.py→All checks passed!uv run --extra test python examples/semantic-vocabulary-drift-smoke.py→okuv run --extra test python scripts/check_rfc_bilingual.py --base origin/main --head HEAD→ passeduv run --extra test loopx --registry /Users/huangruiteng/Developer/loopx/.loopx/registry.json --runtime-root /Users/huangruiteng/.loopx check --scan-path .→ok: True, errors=0/Applications/LoopX.app: rebuilt with--features tauri/custom-protocol, confirmed receipt carries"custom_protocol": true, launched/Applications/LoopX.app, and verified zero:5173errors + 6 activeESTABLISHEDWebKit connections directly to Workbench (127.0.0.1:8796) → Core (127.0.0.1:8767).