# DroidTUI ๐ค
[](https://crates.io/crates/droidtui)
[](LICENSE)
[](https://github.com/sorinirimies/droidtui/actions/workflows/release.yml)
[](https://github.com/sorinirimies/droidtui/actions/workflows/ci.yml)
A beautiful Terminal User Interface (TUI) for Android development โ ADB commands, live logcat viewer, device dashboard, and more. Built with Rust, Ratatui, and the pure-Rust `adb_client` crate (no Android SDK required).
## Features โจ
### ๐บ Live Logcat Viewer
Full-screen, real-time logcat streaming with professional-grade tooling:
- **Live streaming** via `adb_client`'s native API โ no `adb` binary needed
- **Regex search** (`r` toggle) โ powerful pattern matching (`Error|Exception`, `OkHttp.*failed`)
- **Find filter** (`f`) โ case-insensitive substring search with match highlighting
- **Exclude filter** (`e`) โ negative matching to hide noisy tags/messages
- **Tag & PID filters** (`t`, `p`) โ dedicated filter fields
- **Log level filter** (`l`) โ cycle minimum level V โ D โ I โ W โ E โ F
- **Per-tag color hashing** โ each tag gets a stable, visually distinct color
- **Stack trace folding** (`F`) โ detect and fold/unfold Java/Kotlin stack traces
- **Line detail popup** (`Enter`) โ inspect any line with full message, JSON formatting
- **Bookmarks** (`m`, `[`, `]`) โ mark lines and jump between them
- **Copy to clipboard** (`y`) โ copy selected line via `pbcopy`/`xclip`
- **Soft wrap** (`w`) โ wrap long messages across multiple rows with aligned indentation
- **Compact mode** (`x`) โ hide timestamp/PID columns for more message space
- **Horizontal scroll** (`โ`/`โ`) โ scroll long messages when wrap is off
- **Auto-scroll** โ sticks to bottom; manual scroll disables; `G`/`End` re-enables
- **Pause / Resume** (`Space`) โ freeze the view without losing the stream
- **Live stats** โ lines/sec rate and per-level counters in the status bar
- **Save logs** (`s`) โ save to file with path input dialog
- **Save Asโฆ** (`S`) โ browse with integrated file explorer, `Shift+S` to save in current folder
- **JSON export** โ Tab in save dialog cycles TXT/JSON format (JSONL for Nushell/jq)
- **Bounded channel** โ `sync_channel(10k)` with backpressure prevents OOM during bursts
- **JSON detection** โ auto-detects and pretty-prints JSON in log messages with syntax coloring
### ๐ฑ ADB Command Dashboard
- **Device panel** โ live device selector with model, Android version, battery, RAM, CPU stats
- **40+ typed commands** โ packages, system, network, root toolkit, bootloader & flash
- **Fastboot support** โ OEM unlock/lock, wipe data, device info
- **Type-safe execution** โ compile-time guarantees via `adb_client` crate
### ๐จ Theme System
- **12 named presets** โ Default, Dracula, Nord, Gruvbox Dark, Catppuccin Mocha, Tokyo Night, Solarized Dark, Moonfly, Oxocarbon, Forest, Neon, Mono
- **Global selector** (`Shift+T`) โ works from any screen
- **11 colour fields** โ brand, accent, success, dim, fg, sel_bg, warn, error, surface, border, key_hint
### ๐ฅ๏ธ CLI Query Mode
Stream logcat as JSON lines to stdout โ designed for piping into Nushell, jq, or grep:
```bash
droidtui --query # Stream live logcat as JSONL
droidtui --query --last 500 # Dump last 500 lines
droidtui --query --level E # Only errors
droidtui --query --tag MyApp # Filter by tag
droidtui --query --grep "timeout" # Filter by message
### ๐ Nushell Recipe Scripts
Pre-built analysis scripts in `scripts/logcat/`:
| `top_tags.nu` | Rank tags by frequency (top 20) |
| `error_summary.nu` | Group Error/Fatal by tag with sample messages |
| `timeline.nu` | Log volume + error count per second |
| `find_crashes.nu` | Detect Fatal entries, ANRs, exceptions |
| `filter_json.nu` | Extract and pretty-print JSON payloads from messages |
```bash
droidtui --query --last 5000 > logcat.jsonl
nu scripts/logcat/top_tags.nu logcat.jsonl
```
## Installation ๐ง
### From crates.io
```bash
cargo install droidtui
```
### From source
```bash
git clone https://github.com/sorinirimies/droidtui.git
cd droidtui
cargo install --path .
```
### Prerequisites
- **ADB server** running (`adb start-server`) โ the `adb` binary is only needed to start the server; all commands use the pure-Rust `adb_client` crate
- A connected Android device with USB debugging enabled
## Usage ๐ฎ
```bash
droidtui # Launch the TUI
droidtui --query # CLI mode โ stream logcat as JSON
droidtui --help # Show all options
```
### Key Bindings โ Main Menu
| `โ`/`โ` or `j`/`k` | Navigate menu |
| `Tab` / `Shift+Tab` | Jump between sections |
| `Enter` | Execute selected command |
| `L` | Open Live Logcat |
| `T` | Open Theme Selector |
| `d` | Cycle connected device |
| `r` | Refresh device info |
| `q` / `Esc` | Quit |
### Key Bindings โ Logcat Viewer
#### Navigation
| `โ`/`โ` or `j`/`k` | Scroll up/down |
| `PgUp` / `PgDn` | Scroll 20 lines |
| `g` / `G` or `Home`/`End` | Jump to top / bottom |
| `โ` / `โ` | Horizontal scroll (when wrap off) |
| `0` | Reset horizontal scroll |
#### Filters
| `f` | Find (search filter) |
| `e` | Exclude filter (negative match) |
| `t` | Tag filter |
| `p` | PID filter |
| `l` | Cycle log level (VโDโIโWโEโF) |
| `r` | Toggle regex mode |
#### Actions
| `Enter` | Line detail popup (with JSON formatting) |
| `y` | Copy line to clipboard |
| `m` | Toggle bookmark |
| `[` / `]` | Jump to prev/next bookmark |
| `F` | Fold/unfold stack trace |
| `w` | Toggle soft wrap |
| `x` | Toggle compact mode |
| `Space` | Pause / resume |
| `c` | Clear all entries |
| `s` | Save logs |
| `S` | Save Asโฆ (file browser) |
| `q` / `Esc` | Close logcat |
#### Save Dialog
| `Enter` | Save to typed path |
| `S` | Save Asโฆ (open file browser) |
| `Tab` | Cycle format: TXT all โ TXT filtered โ JSON all โ JSON filtered |
| `Esc` | Cancel |
#### File Browser (Save Asโฆ)
| `โ`/`โ` | Navigate |
| `Enter` / `l` | Open directory / select file |
| `h` / `โ` / `Backspace` | Go to parent |
| `Shift+S` | Save Here (into current directory) |
| `/` | Incremental search |
| `n` | Create new folder |
| `.` | Toggle hidden files |
| `s` | Cycle sort mode |
| `Esc` | Back to path input |
## Architecture ๐๏ธ
DroidTUI follows an **Elm-like architecture** with clear separation of concerns:
```
โโโ Model โโโโโโโโโโโโโโโโโโโโโโโ
โ app state, menu, logcat, โ
โ device status, theme โ
โโโ Message โโโโโโโโโโโโโโโโโโโโโค
โ all possible state changes โ
โโโ Update โโโโโโโโโโโโโโโโโโโโโโค
โ message โ state transitions โ
โโโ View โโโโโโโโโโโโโโโโโโโโโโโโค
โ model โ terminal rendering โ
โโโ Event โโโโโโโโโโโโโโโโโโโโโโโค
โ keyboard, tick โ messages โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
### Project Structure
```
droidtui/
โโโ src/
โ โโโ main.rs # Entry point + CLI query mode
โ โโโ app.rs # Event loop, key โ message mapping
โ โโโ model.rs # All application state
โ โโโ view.rs # UI rendering (ratatui)
โ โโโ update.rs # State transitions
โ โโโ message.rs # Message enum
โ โโโ event.rs # Async event handling
โ โโโ menu.rs # Command menu widget
โ โโโ adb.rs # ADB client abstraction
โ โโโ fastboot.rs # Fastboot command support
โ โโโ logcat.rs # Logcat viewer (streaming, parsing, filters, stats)
โ โโโ theme.rs # Theme system (12 presets, selector)
โ โโโ effects.rs # Visual effects (TachyonFX)
โ โโโ lib.rs # Library exports
โโโ scripts/
โ โโโ logcat/ # Nushell recipe scripts
โ โโโ bump_version.nu
โ โโโ release_prepare.nu
โโโ tests/
โ โโโ adb_integration_tests.rs
โโโ examples/
โโโ Cargo.toml
```
## Dependencies ๐ฆ
| `ratatui` | Terminal UI framework |
| `crossterm` | Cross-platform terminal I/O |
| `adb_client` | Pure-Rust ADB protocol client |
| `tokio` | Async runtime |
| `tachyonfx` | Visual effects & animations |
| `regex` | Regex search in logcat |
| `serde` + `serde_json` | JSON serialization for logcat export |
| `tui-file-explorer` | File browser widget (save dialog) |
| `color-eyre` | Error handling |
## Development ๐ ๏ธ
```bash
cargo test # Run all 209 tests
cargo clippy --all-targets --all-features -- -D warnings # Lint
cargo fmt --check # Format check
just release patch # Bump, test, tag, push
```
### Adding New ADB Commands
1. Add a variant to `AdbCommand` in `src/adb.rs`
2. Implement the handler in `AdbManager::execute`
3. Add a menu entry in `src/menu.rs` via `build_entries()`
4. Tests in `tests/adb_integration_tests.rs`
## Contributing ๐ค
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing`)
3. Run `cargo fmt && cargo clippy --all-targets --all-features -- -D warnings && cargo test`
4. Commit and push
5. Open a Pull Request
## License ๐
MIT โ Copyright (c) Sorin Albu-Irimies
## Acknowledgments ๐
- [Ratatui](https://ratatui.rs) โ TUI framework
- [adb_client](https://github.com/nicoulaj/adb_client) โ Pure-Rust ADB client
- [TachyonFX](https://github.com/junkdog/tachyonfx) โ Visual effects
- [tui-file-explorer](https://github.com/sorinirimies/tui-file-explorer) โ File browser widget
---
**Made with โค๏ธ and โ for Android developers** ยท *Powered by Rust ๐ฆ*