# Claude Status Display

A round desk display that shows what [Claude Code](https://claude.com/claude-code) is doing — in any terminal on your Mac — and takes you back to it with a tap.

<p align="center"><img src="docs/states.png" alt="The four screens: spinning gear, exclamation mark on red, check mark on green, clock" width="100%"></p>

| State | Screen | When |
|---|---|---|
| **working** | <img src="docs/working.gif" width="48" align="center"> orange gear, spinning | Claude is thinking or running tools |
| **attention** | white `!` on red, pulsing backlight | Claude needs you: a permission prompt, a question, plan approval, an MCP elicitation, or the turn stopped on an API error |
| **done** | white check mark on green | Claude finished its turn; tap to dismiss (expires by itself after 30 min) |
| **idle** | dim clock with a seconds dot | no session is working |
| — | screen off | no message from the Mac for 8 s (Mac asleep, daemon stopped, cable unplugged) |

With several sessions open, the most urgent one wins: `attention > working > done > idle`.

**Tap the screen** to bring the terminal of the session on display to the front: the exact tab in Terminal.app and iTerm2, the right window in VS Code, Cursor and other apps (see [permissions](#permissions-for-tap-to-focus)).

Runs on a [Waveshare ESP32-S3-Touch-LCD-1.28](https://www.waveshare.com/esp32-s3-touch-lcd-1.28.htm): ESP32-S3, 1.28" round 240×240 GC9A01 display, CST816S capacitive touch.

## How it works

```
 Claude Code sessions             ~/.claude/status-display/        LaunchAgent              ESP32-S3
 (any terminal, any app)          sessions/<id>.json               (Python daemon)          round display
┌───────────────────────┐ hooks  ┌──────────────────────┐  poll   ┌─────────────────┐ USB  ┌──────────────┐
│ Terminal / iTerm2 /   │──────▶ │ state, timestamp,    │ ──────▶ │ aggregate, fix  │─────▶│ gear, !, ✓,  │
│ VS Code / ...         │        │ pid, tty, host app   │  0.2 s  │ up, heartbeat   │ JSON │ clock        │
└───────────────────────┘        └──────────────────────┘         └─────────────────┘◀─────└──────────────┘
           ▲                                                         │  "tap"
           └──────────── focus the session's tab / window ───────────┘
```

- **Hooks** (`mac/claude_status_hook.py`): registered globally in `~/.claude/settings.json`, so every Claude Code session reports its state, whatever terminal it runs in. Each event writes a small JSON file per session: `UserPromptSubmit`/`PreToolUse`/`PostToolUse` → working; `PermissionRequest`, `AskUserQuestion`, `ExitPlanMode`, MCP elicitations, `StopFailure` → attention; `Stop` → done; `SessionEnd` removes the file. The hook also records the `claude` PID, its tty and the app hosting it, by walking up the process tree.
- **Daemon** (`mac/claude_status_daemon.py`): a LaunchAgent that aggregates the sessions and owns the serial port. It also fixes what hooks can't see:
  - pressing **Esc** fires no hook, so the daemon detects the interruption marker at the end of the session transcript;
  - sessions whose `claude` process died without `SessionEnd` are dropped;
  - `working` with no activity for 15 minutes falls back to idle, as a safety net.
- **Firmware** (`firmware/claude_status/`): renders every shape as an anti-aliased signed distance field into a framebuffer. The gear is redrawn at ~30 fps in a 144×144 box. A touch sends `tap` back to the Mac.

## Hardware

- Waveshare ESP32-S3-Touch-LCD-1.28 (pins are hard-coded for this board)
- A USB-C data cable to the Mac

## Firmware

Install the **esp32** board package by Espressif (3.x) and these libraries (Arduino Library Manager):

| Library | Tested |
|---|---|
| [GFX Library for Arduino](https://github.com/moononournation/Arduino_GFX) | 1.6.7 |
| [ArduinoJson](https://arduinojson.org) | 7.4.3 |
| [CST816S](https://github.com/fbiego/CST816S) by fbiego | 1.3.0 |

Board settings — **USB CDC On Boot must be Disabled**: on this board the USB-C port is wired to a CH343 USB-UART on UART0, not to the ESP32-S3 native USB, so with CDC enabled `Serial` goes nowhere.

| Arduino IDE option | Value |
|---|---|
| Board | ESP32S3 Dev Module |
| USB CDC On Boot | Disabled |
| USB Mode | USB-OTG (TinyUSB) |
| Flash Size | 16MB (128Mb) |
| PSRAM | QSPI PSRAM |

With arduino-cli:

```sh
arduino-cli compile --upload -p /dev/cu.usbmodemXXXX \
  -b esp32:esp32:esp32s3:CDCOnBoot=default,USBMode=default,FlashSize=16M,PSRAM=enabled \
  firmware/claude_status
```

> **Flashing fails from macOS Sequoia?** With the CH343 chip some setups fail with `Failed to write to target RAM (result was 0107: Checksum error)` in every tool (esptool, Arduino IDE, WebSerial). It's the macOS USB serial stack, not the board. One workaround is to compile with `--export-binaries` and flash from any Linux machine, e.g. a Raspberry Pi, with `esptool.py write_flash` (offsets `0x0` bootloader, `0x8000` partitions, `0xe000` boot_app0, `0x10000` app). Talking to the board at runtime from the Mac works fine.

## Mac setup

Requirements: macOS, Claude Code, Python 3 (standard library only). The [python.org](https://www.python.org/downloads/macos/) build is preferred because it starts in ~50 ms, which matters since the hook runs on every event. `/usr/bin/python3` works too, but takes ~200 ms per start.

```sh
./mac/install.sh
```

This copies the hook and the daemon to `~/.claude/status-display/`, installs the `local.claude-status-display` LaunchAgent (starts at login), and adds the hooks to `~/.claude/settings.json`. A backup is saved as `settings.json.bak-claude-status`, and the rest of the file is left untouched. Sessions that are already open pick up the hooks after a restart, or after opening `/hooks` once.

Plug the board in: the daemon finds `/dev/cu.usbmodem*` / `/dev/cu.wchusbserial*` by itself. To force a port, add `CLAUDE_STATUS_PORT` to the `EnvironmentVariables` of the LaunchAgent plist.

Log: `~/Library/Logs/claude-status-display.log`. Re-run `install.sh` after editing the hook, the daemon or the OpenCode plugin. To remove everything:

```sh
./mac/install.sh --uninstall
```

### OpenCode

`install.sh` also copies `opencode/tui.ts` to `~/.config/opencode/plugins/claude-status-display/`, where OpenCode (v2) discovers it; an open TUI picks it up by itself or with `/reload`. It is a TUI plugin that listens to the server's events and writes the same session files as the hook, so OpenCode and Claude Code sessions share the display with no change to the daemon or the firmware:

| OpenCode event | State |
|---|---|
| `session.execution.started` | working |
| `permission.asked`, `form.created` (also from subagents) | attention |
| `permission.replied`, `form.replied`, `form.cancelled` | working, if the session is still running |
| `session.execution.failed` | attention |
| `session.execution.succeeded` | done |
| `session.execution.interrupted` | idle |
| `session.deleted` | file removed |

When the plugin loads (OpenCode start, `/reload`, plugin update) it also picks up the sessions already running, as working or, if a permission or question is pending, attention. With several TUIs open, a session belongs to the TUI showing it, else to the one started in the session's folder.

It runs in the TUI, not in the server part, because the record needs a process that lives as long as the terminal: the pid is the TUI's (closing it clears its sessions), and its tty and host app are what a tap brings to the front. Files are named `opencode-<session id>.json`. Sessions that OpenCode runs on Claude through its Claude agent provider don't fire Claude Code hooks, so they show up through this plugin.

### Permissions for tap-to-focus

- **Terminal.app / iTerm2**: the first tap triggers the macOS "Automation" prompt to let Python control the app. Allow it to jump to the exact tab. *(Implemented but not tested yet: so far tap-to-focus has been verified with VS Code.)*
- **VS Code, Cursor and other apps**: without extra permissions a tap brings the app to the front. To raise the exact window (matched by the project folder name in the window title), add the daemon's Python to *System Settings → Privacy & Security → Accessibility*. The exact path is printed in the log on the first tap, e.g. `/Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13`. Note that this grants Accessibility to that Python interpreter. VS Code offers no external API to pick which integrated terminal to show.

## Serial protocol

115200 baud, one line per message.

| Direction | Message |
|---|---|
| Mac → board | `{"s":"working","clk":"14:05:33"}`, sent on every change and at least once per second (`s`: `idle`, `working`, `attention`, `done`; `clk`: the Mac's local time) |
| Board → Mac | `tap` on touch, `claude-status ready` at boot |

## Tweaking

- Daemon (`mac/claude_status_daemon.py`): `DONE_TIMEOUT_S`, `WORKING_STALE_S`, `POLL_S`, `HEARTBEAT_S`.
- Firmware (`claude_status.ino`): colors (`C_*`), backlight levels (`BL_*`), `LINK_TIMEOUT_MS`, gear speed (`GEAR_TOOTH_PERIOD_MS`).
- `tools/render_screens.py` is a Python port of the firmware renderer: it draws the screens to `docs/` so you can iterate on the graphics without flashing.

## Troubleshooting

- **Screen stays black**: check the daemon log. The board turns the screen off when no message arrives for 8 s, and the log shows `connected to ...` and `state -> ...` lines.
- **Nothing from the board / it seems stuck in reset**: opening the port asserts DTR/RTS, which the CH343 auto-download circuit can turn into a reset. The daemon clears them right after opening, but other serial tools may not.
- **`Serial` silent**: the firmware was built with USB CDC On Boot enabled.
- **Gear keeps spinning in a closed session**: it is dropped as soon as its `claude` process exits. An interrupted turn (Esc) is detected from the transcript.

## Credits

- [agent-light](https://github.com/eternityspring/agent-light) by eternityspring: the Claude Code traffic light (hooks + serial bridge) that sparked the idea.
- [ESP32-S3 1.28 Waveshare Plane Radar](https://makerworld.com/it/models/2913572-esp32-s3-1-28-waveshare-plane-radar) on MakerWorld: a project for the same round Waveshare board that inspired turning it into a desk gadget.

## License

[MIT](LICENSE)
