Skip to content

fix(remote-connect): drop offline peer controllers from event fanout - #3657

Merged
bobleer merged 2 commits into
GCWing:mainfrom
gordon-gs:fix/peer-controller-presence-cleanup
Nov 2, 2026
Merged

bobleer merged 2 commits into
GCWing:mainfrom
gordon-gs:fix/peer-controller-presence-cleanup

Conversation

@gordon-gs

@gordon-gs gordon-gs commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

问题与修复

Desktop 的 DevicePresence 分支此前只清理 host-stream 订阅,没有清理 Peer UI 事件 fanout 的离线接收端,因此持续向离线设备发送事件并产生 relay 拒绝日志。

本 PR 接上接收端清理,并补齐两项审查修正:

  • 离线不等于撤销权限。 Presence 仅删除事件接收端,不再 drain / cancel 待答权限请求;重连仍从既有 mailbox 恢复。显式 detach 和账户生命周期路径保持原行为。
  • 按实际 relay route 清理。 Official 与 LAN 分别使用自己的在线设备列表,不能用 LAN presence 清除 Official 接收端,反之亦然;同一 device id 在不同 route 上也分别处理。

没有新增命令、必填协议字段或持久化格式。

验证

  • 新增“最后一个控制端离线后仍保留权限请求”回归测试:修正前失败,修正后通过。
  • 新增 Official / LAN 双向隔离测试,包括两个 route 使用相同 device id 的情况。
  • pnpm run fmt:rs — 通过,仅格式化改动的 Rust 文件。
  • TAURI_CONFIG='{"bundle":{"resources":[],"externalBin":[]}}' cargo test --locked -p openbitfun-desktop --lib api::peer_host_invoke::tests — 16 passed。

本地全新 worktree 没有构建 extension-host 等发布资源,直接执行测试先在 Tauri 资源准备阶段失败;上述测试通过仅用于单测的 bundle 配置运行,不修改仓库配置,也不代表发布打包通过。编译有一条既有 miniapp_desktop/mod.rs unused-mut warning。

远程覆盖:本地状态/路由单测,不是 live Peer/Relay 断线重连验证;未运行真实 SSH、手机/IM 或 Detached Dispatch。新提交的 CI 必须通过后才能合入。

Generated with OpenBitFun

gordon-gs and others added 2 commits November 1, 2026 17:33
`peer_host_invoke::retain_online_controllers` exists on the desktop host
but nothing ever calls it — the CLI has the equivalent wiring through
`peer_host::update_controller_presence`, the desktop `DevicePresence`
handler only prunes the host-stream hub.

A controller that goes offline therefore stays in `controllers` forever.
Every peer event keeps fanning out to it and the relay rejects each one,
which is what fills the log with:

    peer event fanout to <device> failed: Relay event rejected

Reconnecting does not help: the stale id is still there, so the failures
continue alongside the new connection.

Retain the controller set against account presence, mirroring the CLI,
and fail closed permission requests whose last control surface vanished.
Scope subscriber removal to the relay reporting presence, including LAN. Offline presence is not permission revocation.

Co-authored-by: OpenBitFun <318544290+bitfun-ai@users.noreply.github.com>
@bobleer
bobleer merged commit 54c06fa into GCWing:main Nov 2, 2026
13 checks passed
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.

2 participants