# pi-tui-pro

UI enhancements for the [Pi coding agent](https://github.com/earendil-works/pi-mono) TUI.

## Install

```bash
pi install npm:pi-tui-pro
```

## Features

1. **User message background** — user messages get a slightly brighter, easy-on-the-eyes background so they stand out from the transcript.
2. **Thinking level pinned to the footer** — the current thinking level (`off` / `low` / `medium` / `high` / `xhigh` / `max`) is always shown next to the model name at the bottom-right, color-coded by level.
3. **Clock never truncated** — the current time is pinned to the very end of the status line and is never ellipsized, no matter how much token/context stats pile up.
4. **Cache hit stats** — the footer shows cache reads (`R`), cache writes (`W`) and the cache hit rate (`CH%`) alongside input/output tokens.
5. **Click to fold/unfold individual blocks** — click a collapsed thinking block (`💭 Thinking... · 点击展开`) to expand just that block, click inside an expanded thinking block to collapse it, and click anywhere on a tool output to toggle it — independent of the global expand/collapse toggle.

## Usage

- Restart `pi` after installing. The new footer appears immediately; fold markers appear on new and existing thinking blocks after the session loads.
- The global "expand/collapse all" shortcut still works and resets per-block overrides.
- Clicking is disabled while a message is streaming (to avoid racing with live updates).

## Notes

- Deep links into pi's internal components are runtime-patched from the live component tree, so the extension adapts to the actual runtime classes instead of relying on `instanceof`.
- If a future pi update breaks click-to-fold, open an issue with your pi version.

## Development

```bash
# run smoke tests (requires the extension to be loadable via jiti)
node test.mjs

# debug logging (writes to ~/.pi/agent/pi-tui-pro-debug.log)
PI_TUI_PRO_DEBUG=1 pi
```

## License

MIT
