Skip to content

fix(mobile,relay): remote session attach — E2EE OUT decrypt + Origins editor#271

Merged
attson merged 1 commit into
mainfrom
fix/mobile-remote-attach
Jul 26, 2026
Merged

fix(mobile,relay): remote session attach — E2EE OUT decrypt + Origins editor#271
attson merged 1 commit into
mainfrom
fix/mobile-remote-attach

Conversation

@attson

@attson attson commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • Mobile "无法进入远程会话" (black screen after tapping a remote session) had two independent causes stacked together — this PR fixes both.
  • Origin whitelist: WKWebView's WS from capacitor://localhost failed nhooyr's origin check because admin's AllowedOrigins didn't include it, and the Config tab had no editor for that field. Adds allowed_origins to /admin/api/config GET/PUT and a multi-line textarea in the admin Config tab.
  • E2EE OUT decrypt: MobileTerminal created SessionConnection without remote: true, so once QR-pairing reliably unlocks account_key the desktop uplink's sealed OUT envelopes were fed straight to xterm.write() — the random 24-byte nonce contains ESC/CSI sequences that continuously clear/reposition the terminal, producing a fully-black screen. META decrypted via its own path so header cwd/title still displayed, masking the bug.
  • Tests: TestAdminConfigRoundtripsAllowedOrigins (Go) covers the API contract + hot-apply; Config.vue test covers pre-populate + parse-on-save trim/blank-drop.

Test plan

  • Rebuild + redeploy relay container; verify /admin/health page still renders correctly.
  • Admin UI "管理 → 配置" shows the new "允许的 Origin" textarea pre-populated with server's current list.
  • Add capacitor://localhost in the editor, save; /admin/api/health mobile_origin_compatible flips to true within ~10s hot-reload TTL.
  • Mobile Simulator: kill + relaunch app, tap a remote session — terminal renders content (prompt visible, not black).
  • Regression: desktop remote session still works via the same relay (unchanged origin auto-append for wails.localhost).

… editor

Mobile "无法进入远程会话" (black terminal after tapping a remote session)
had two independent causes, both fixed here:

1. WKWebView WS to /client failed nhooyr's origin check. Mobile Origin
   `capacitor://localhost` doesn't match any pattern unless admin's
   AllowedOrigins includes it, and the admin UI had no editor for that
   field — so first-time mobile users hit `close 1006` with no obvious
   knob to turn. Adds `allowed_origins` to the /admin/api/config
   response and a multi-line editor in the Config tab.

2. SessionConnection was created without `remote: true`, so once
   QR-pairing reliably unlocks account_key (recent 51dee2e / 9004b73),
   the desktop uplink's sealed OUT envelopes got fed straight to
   xterm.write() — the random nonce bytes contain ESC/CSI sequences
   that continuously clear/reposition, producing a fully-black screen.
   META still decrypted via its own path, so the header still showed
   cwd/title — masking the bug.

Tests:
- Go: TestAdminConfigRoundtripsAllowedOrigins covers GET/PUT and
  hot-apply of the origin patterns.
- TS: Config.vue test covers pre-populate from server + parse-on-save
  (trim + drop blank lines).
@attson
attson merged commit 600a1e2 into main Jul 26, 2026
7 checks passed
@attson
attson deleted the fix/mobile-remote-attach branch July 26, 2026 15:37
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