Skip to content

feat(terminal): interactive PTY shells, tabs and background sessions - #20

Merged
abrahdev merged 4 commits into
mainfrom
feat/terminal
Nov 6, 2026
Merged

abrahdev merged 4 commits into
mainfrom
feat/terminal

Conversation

@abrahdev

@abrahdev abrahdev commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Summary

Implements #6: an interactive terminal for each environment, with multiple sessions, background
persistence, configurable extra keys and external windows.

  • Vendor Termux terminal-emulator and terminal-view (GPL-3.0) in mobile/lib, built with the
    project SDK and NDK. termux-shared is intentionally not vendored.
  • TerminalSession creates the PTY through the vendored JNI and runs libproot.so with
    /bin/bash -l and the same mounts as the runtime.
  • TerminalSessionManager keeps sessions per environment; a specialUse foreground service keeps
    the process alive and shows a notification.
  • Tabs create and close sessions, named Terminal N from a per-environment counter.
  • Configurable extra keys (Ctrl, Alt, Esc, Tab, arrows) stored in shared preferences.
  • TerminalActivity is resizeable and launches with NEW_TASK | MULTIPLE_TASK and an empty task
    affinity, so Android can place it in a separate window; the task description shows the session.
  • Deleting an environment stops its sessions first.
  • NOTICE and ADR 0006 document the vendored code and the design.

Test plan

  • ./gradlew ktlintCheck lintStandardDebug testStandardDebugUnitTest assembleStandardDebug passes.
  • On a Xiaomi Android 16 arm64 device: interactive bash prompt, + creates Terminal 2,
    tabs switch, extra keys send sequences, "Open in window" opens a separate task, and the session
    survives going to the home screen.
  • Pending manual checks: deleting an environment closes its sessions, notification visibility on
    Android 13+, resizing in split screen/DeX.

Notes

  • Sessions survive backgrounding but not process death; the manager and counters are in memory.
  • The foreground service uses the specialUse type and POST_NOTIFICATIONS on Android 13+.

- Vendor terminal-emulator and terminal-view, built with the project
  SDK and NDK versions.
- Add ProotCommand.interactiveArgv() for /bin/bash -l inside proot.
- Add TerminalScreen with TerminalView, IME focus and soft keyboard.
- Open the terminal from the environment card.
- Update NOTICE with the Termux GPL-3.0 attribution.
- Keep sessions in a process-wide manager and a foreground service so
  shells survive the UI going to the background.
- Add tabs with create and close actions, and name sessions Terminal N.
- Add configurable Ctrl, Alt, Esc, Tab and arrow keys.
- Add TerminalActivity with resizeable window support and a dedicated
  task for "Open in window", plus the task title with the session name.
- Declare the specialUse foreground service and notification permission.
@abrahdev
abrahdev merged commit 6a07f62 into main Nov 6, 2026
1 check passed
@abrahdev
abrahdev deleted the feat/terminal branch November 6, 2026 00:21
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