# pi-status-bar

A customizable status bar (footer) extension for [pi](https://github.com/earendil-works/pi), the AI coding assistant.

Replaces pi's default footer with configurable widgets arranged on up to 3 lines.

## Features

- **37+ widget types** across 7 categories: Core, Git, Tokens, Context, Session, Layout
- **3 configurable lines** with independent widget lists
- **ANSI 16-color palette** per widget
- **Git integration** — branch, ahead/behind, staged/unstaged changes, cumulative session tracking
- **Token & cost tracking** — input/output/cached tokens, session cost
- **Session clock** — elapsed time since session start
- **Custom text** widgets for static labels

## Installation

```bash
pi install git:github.com/earendil-works/pi-status-bar
```

Or load manually:

```bash
pi -e /path/to/pi-status-bar/index.ts
```

Or place in `~/.pi/agent/extensions/` for auto-loading.

## Commands

| Command | Description |
|---------|-------------|
| `/statusbar` | Open the configuration TUI |
| `/statusbar reset` | Reset to default widget layout |
| `/statusbar toggle` | Enable/disable the status bar |

## Configuration

Run `/statusbar` to open the interactive configuration menu:

1. **Modify Widgets** — Add, remove, reorder, and configure widgets on 3 lines
2. **Change Colors** — Change widget colors using the ANSI 16-color palette
3. **Enable/Disable Status Bar** — Toggle on/off from the menu

### Keybindings (Widget List)

| Key | Action |
|-----|--------|
| `d` | Delete selected widget |
| `c` | Clone selected widget |
| `a` | Add new widget below selection |
| `Space` | Toggle reorder mode (↑↓ moves widget) |
| `Enter` | Open widget action menu |
| `Escape` | Back to line selector |

## Widget Types

| Category | Widgets |
|----------|---------|
| **Core** | `model`, `cwd`, `turnCount`, `thinking`, `sessionName`, `version` |
| **Git** | `gitBranch`, `gitAheadBehind`, `gitChanges`, `gitStaged`, `gitUnstaged`, `gitUntracked`, `gitCleanStatus`, `gitConflicts`, `gitRootDir`, `gitSHA` |
| **Tokens** | `tokens`, `tokensInput`, `tokensOutput`, `tokensCached`, `tokensTotal` |
| **Context** | `contextPct`, `contextLength`, `contextWindow` |
| **Session** | `cost`, `sessionClock` |
| **Layout** | `customText`, `separator`, `spacer` |

## Persistence

- **Widget layout** — stored globally in `~/.pi/statusbar-config.json` (shared across all sessions)
- **Cumulative git counters** — stored per-project in `~/.pi/agent/sessions/--<cwd>--/cumulative-counters.json`
- **Atomic writes** — config files use `.tmp.<timestamp>` + `renameSync` to prevent corruption
- **Corruption recovery** — broken JSON is backed up to `.corrupted.<timestamp>` and defaults are restored

## Requirements

- [pi](https://github.com/earendil-works/pi) (AI coding assistant)

## License

MIT
