# NeonMirror — Android Device Mirroring for Gallia Viewer

Mirror a USB-connected Android device in Gallia Viewer with touch/keyboard interaction, logcat streaming, macro recording, and display settings control.

## What the user asked

$ARGUMENTS

## Step 1: Display NeonMirror in Gallia Viewer

```
mcp__adom-viewer__gv_display({ url: 'https://<neon-mirror-url>.adom.cloud/', title: 'NeonMirror' })
```

Replace `<container-slug>` with the actual neon-mirror service container slug.

## Step 2: Guide the User

- **Start Mirror** — Click "Start Mirror" to begin screen mirroring
- **Touch/Click** — Click on the mirrored screen to tap, drag to swipe
- **Keyboard** — Focus the mirror canvas and type to send keystrokes
- **Logcat** — Switch to the Logcat tab, enter a package name, and click Start
- **Macros** — Switch to the Macros tab, name a macro, and click Record. Perform touch actions, then click Stop.
- **Display Settings** — Change DPI, resolution, or toggle screen on/off from the Settings tab
- **Console** — View raw adb/scrcpy output in the Console tab

## Features

- Real-time MJPEG screen mirroring via scrcpy
- Touch and keyboard input forwarding
- Auto-reconnect on device disconnect with retry loop
- USB device detection (polls adb devices every 3 seconds)
- Logcat viewer with package name and log level filtering
- DPI and resolution override controls
- Screen on/off and stay-awake-while-plugged toggle
- Touch macro recording and replay
- Raw console output from adb, scrcpy, and ffmpeg

## Service Health Check

```
GET https://<neon-mirror-url>.adom.cloud/health
```

Returns: `{ ok, service, state, device, mirroring, uptime }`

## WebSocket API

Connect to `wss://<service-url>/ws` for real-time communication.

### Commands (client to server)

| Type | Fields | Description |
|------|--------|-------------|
| `start_mirror` | `maxFps?`, `bitRate?`, `maxSize?` | Start mirroring |
| `stop_mirror` | — | Stop mirroring |
| `touch` | `action`, `x`, `y`, `width`, `height` | Touch event |
| `key` | `keyCode` | Android keyevent |
| `text` | `text` | Type text |
| `start_logcat` | `packageName?`, `level?` | Start logcat |
| `stop_logcat` | — | Stop logcat |
| `set_density` | `dpi` | Change DPI |
| `set_size` | `width`, `height` | Change resolution |
| `reset_display` | — | Reset display settings |
| `screen_on` / `screen_off` | — | Wake/sleep screen |
| `stay_awake` | `enabled` | Toggle stay on while plugged |
| `macro_start` | `name` | Start recording macro |
| `macro_stop` | — | Stop recording |
| `macro_play` | `name` | Replay macro |
| `macro_list` | — | List saved macros |
| `macro_delete` | `name` | Delete macro |

## Troubleshooting

- **No device detected**: Ensure USB debugging is enabled on the Android device and the device is connected via USB to the service container
- **Mirror won't start**: Check that adb, scrcpy, and ffmpeg are installed (`install-deps.sh`)
- **Black screen**: The device may need to be unlocked first. Use "Screen On" in Settings
- **High latency**: Reduce bitrate or max size in Settings tab