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

Đang mở
#57 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
android, typescript
Lĩnh vực
mobile, networking

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
TypeScript
Star
277
Fork
27
Merge trung bình
2 giờ 47 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của DuskBotAI/duskbot

Tất cả issue của DuskBotAI/duskbot

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.