Skip to content

feat(android,ios,client): open a remote terminal from the phone - #147

Merged
sqlpxc merged 1 commit into
mainfrom
feat/mobile-terminal
Dec 3, 2026
Merged

sqlpxc merged 1 commit into
mainfrom
feat/mobile-terminal

Conversation

@sqlpxc

@sqlpxc sqlpxc commented Dec 3, 2026

Copy link
Copy Markdown
Owner

The Android and iOS apps can now open a remote terminal on a computer, without its screen, like the desktop console (#145).

What's in it

  • Home screen: a Terminal button next to Connect, and a terminal icon next to each computer in My devices. The filled one of the two buttons is the one tapped last, and it's what a completed control code opens (typing the 6th digit used to always start a screen session, leaving no way to pick the terminal). A card leads back to an open terminal.
  • Same terminal as the console: client/mobile-terminal/ is a shared page (classic scripts: Android's WebView can't load module scripts from file:///android_asset) with the console's xterm.js and colors, copied into the apps at build time together with xterm.js from client/node_modules (Android terminalAssets task, iOS scripts/terminal-page.sh). Page and native code talk over JSON messages.
  • Session (controller/TerminalSession.kt, Terminal/TerminalSession.swift): connect / reconnect / wait for the host like remote sessions, with terminal: true in the connect options; opening, resuming with the token, acknowledging after xterm has processed the output, restart after exit, close. The page belongs to the session, so leaving and returning keeps the content; if the system kills the page's process a new one takes over (acks everything outstanding and makes the program redraw).
  • Keyboard is native: a hidden input view (input-method composition handled like remote control), a key bar (Esc, Tab, ⇧Tab, sticky Ctrl/Alt, arrows, ^C, Home/End, PgUp/PgDn, symbols, F1–F12, paste), hardware keyboards. keys.js turns keys into bytes for the terminal's current mode.
  • The soft keyboard doesn't resize the terminal: it covers the bottom and the page shifts the cursor's line above it. Resizing on every keyboard toggle made programs like claude redraw the whole screen, and after a resumed terminal was resized ConPTY lost track of the cursor relative to xterm.
  • Gestures in the page: swipe to scroll back (arrow keys in full-screen programs, wheel events when the program wants the mouse), fling, tap for the keyboard, long-press for a "Copy text" sheet (select part or copy all), pinch for the text size (remembered).
  • Strings in both languages, docs (usage, android, ios, architecture, building), README.
  • CI: the Android and iOS jobs run npm ci --omit=dev --ignore-scripts in client/ for xterm.js.

Testing

  • Android emulator against a local relay and a Windows host (PowerShell / ConPTY): pairing, typing, sticky Ctrl + c, scrolling and fling, copy sheet, leaving and returning, relay restart → the same terminal resumed, exit → open again, close from the menu; also the R8-minified release build.
  • ./gradlew testDebugUnitTest lintDebug (new protocol tests for the terminal commands and input chunking), npm test in client/ (new mobile-terminal.test.ts for the key sequences).
  • iOS was not compiled here (no Mac available): please build it in Xcode and try it before relying on it. ProtocolTests has the matching command tests.

The Android and iOS apps can now open a remote terminal on a computer (no screen), like the desktop console: a Terminal button next to Connect and a terminal icon in My devices. The terminal is the same xterm.js as the console, in a shared page (client/mobile-terminal) shown in a WebView / WKWebView; the keyboard is native (input methods, a key bar with Esc/Tab/Ctrl/Alt/arrows, hardware keyboards). Reconnects resume the same terminal; the soft keyboard overlays the terminal instead of resizing it.
@sqlpxc
sqlpxc merged commit 05f3b5c into main Dec 3, 2026
1 check passed
@sqlpxc
sqlpxc deleted the feat/mobile-terminal branch December 3, 2026 15:42
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