Skip to content

fix(desktop,installer): compile LoopX.app with tauri/custom-protocol and clear stale managed runtime selection - #10272

Merged
loopx-agent merged 1 commit into
mainfrom
codex/fix-desktop-app-custom-protocol-20261206
Dec 6, 2026
Merged

loopx-agent merged 1 commit into
mainfrom
codex/fix-desktop-app-custom-protocol-20261206

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Summary

Fixes two real-machine launch failures observed when opening the locally installed macOS LoopX.app after #10254:

  1. Blank white window on launch (Connection refused to 127.0.0.1:5173): scripts/desktop_app_install.py previously invoked cargo build --release without --features tauri/custom-protocol. In Tauri v2, omitting tauri/custom-protocol leaves cfg(dev) enabled, causing the release binary to navigate to devUrl (http://127.0.0.1:5173) instead of loading the embedded ../static boot launcher via tauri://localhost/.
    • Pass --features tauri/custom-protocol in build_release_binary().
    • Record "custom_protocol": true in .loopx-desktop-app-build.json and require it in can_reuse_installed_app() so pre-fix #10254 installs automatically rebuild instead of reusing the broken dev-mode binary.
  2. Stale remembered runtime-selection.json stalling boot alignment: When install-local.sh upgrades ~/.local/share/loopx/releases/<release_id> and restarts Core (:8767), a previously remembered ~/Library/Application Support/io.loopx.control-plane/runtime-selection.json pointing to an older managed release under ~/.local/share/loopx/releases/ causes LoopX.app to hold on the boot screen trying to align the older CLI against the upgraded Core.
    • Add 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 passed
  • uv 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 → ok
  • uv run --extra test python scripts/check_rfc_bilingual.py --base origin/main --head HEAD → passed
  • uv run --extra test loopx --registry /Users/huangruiteng/Developer/loopx/.loopx/registry.json --runtime-root /Users/huangruiteng/.loopx check --scan-path . → ok: True, errors=0
  • Live macOS verification on /Applications/LoopX.app: rebuilt with --features tauri/custom-protocol, confirmed receipt carries "custom_protocol": true, launched /Applications/LoopX.app, and verified zero :5173 errors + 6 active ESTABLISHED WebKit connections directly to Workbench (127.0.0.1:8796) → Core (127.0.0.1:8767).

…and clear stale managed runtime selection

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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 的引导界面。

关键实现与边界核查

  1. 嵌入式前端资源编译门禁(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 白屏包不会被指纹复用,升级时自动触发安全重编。
  2. 过期受管运行时偏好清理:新增 clear_stale_managed_runtime_selection(),仅在 macOS 且已传入 release_id、且 runtime-selection.json 明确指向 ~/.local/share/loopx/releases/<older_id>/... 下的不同 release 时才清理该文件;同 release 绑定及受管目录外的自定义开发路径均严格原样保留,无越权写操作。
  3. 测试与真机验证: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 loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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 loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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).

@loopx-agent
loopx-agent merged commit 69b326c into main Dec 6, 2026
27 of 31 checks passed
@loopx-agent
loopx-agent deleted the codex/fix-desktop-app-custom-protocol-20261206 branch December 6, 2026 12:43
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