Android: replies never stream in over a companion (LAN/Tailscale) pairing, only after restarting the app

未关闭
#57 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
android, typescript
领域
mobile, networking

调研方向

Start with apps/companion/src/proxy.ts and src/mobile/transport/transport.ts, then trace how installTransport opens the event stream and how companion requests check Origin. The issue reports a local native Android streaming plugin as a working fix and notes that the WebSocket viewer needs a similar path or origin handling. Done when companion replies stream to Android without restarting and the live computer view works.

由索引模型根据 Issue 内容生成。

描述

bug
What happened

Paired with the Mac over the companion (both the Wi-Fi and the Tailscale pairing). Sending a message works and the desktop shows it, but the bot's reply never appears on the phone. It only shows after the app is killed and reopened. The live computer view (the display icon) stays blank for what looks like the same reason.

Cause: the companion rejects any request that carries an Origin header before it looks at the token (apps/companion/src/proxy.ts, "A native app sends no Origin"; handle.upgrade does the same for WebSockets). Ordinary requests go through CapacitorHttp (native, no Origin) and work. But installTransport (src/mobile/transport/transport.ts) opens the event stream with the WebView's own fetch (CapacitorWebFetch), and the WebView always sends Origin: https://localhost. So the stream gets 403 {"error":"forbidden: cross-origin request"}. Reproduced with curl:

curl -H "Origin: https://localhost" http://<mac>:8810/api/events   -> 403 forbidden: cross-origin request
curl http://<mac>:8810/api/events                                  -> 401 (reaches the token check)

CapacitorHttp can't carry the stream, because it buffers the whole body. What fixed it locally: a small native Android plugin that does the streaming GET with HttpURLConnection and passes chunks to JS as events, plus a fetch-shaped shim that installTransport uses as streamFetch for http: (companion) origins. Replies now stream in live. Happy to open a PR with it if that approach is welcome. The WebSocket viewer would need a similar native path, or the companion would need to accept the app's own origins (https://localhost, capacitor://localhost) with a valid token.

Setup: desktop 0.2.17 on macOS; phone app built from main at 7791c1f (apps/mobile, Android debug build, Samsung Galaxy S26), paired over the companion (port 8810).

Steps to reproduce
  1. Build apps/mobile for Android (allowing cleartext, see the readiness notes) and pair with a Mac over Wi-Fi or Tailscale.
  2. Send a bot a message from the phone.
  3. The reply appears on the desktop but not on the phone until the app is restarted.
Version

0.2.17 (desktop, macOS); phone app from main @ 7791c1f

Platform

Android

Engine

No response

Logs or screenshots

主要语言
TypeScript
星标
277
派生
27
平均合并
2 小时 47 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DuskBotAI/duskbot 的其他 Issue

查看 DuskBotAI/duskbot 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。