# v0.5.0

## New: Persistent status bar with PTY proxy

ai-jail can now display a persistent status line on the bottom row of your terminal while the sandboxed command runs. The bar shows the project path, the running command, the ai-jail version, and a green `↑` indicator when a newer release is available on GitHub.

```
 /path/to/project | claude --model opus          ai-jail 0.5.0 ↑
```

The status bar uses a PTY proxy: ai-jail allocates a pseudo-terminal for the child process and owns the real terminal, reserving the last row via ANSI scroll regions. This keeps the bar visible even when the child resets the screen (vim, less, TUI apps). Output injection is deferred to safe stream boundaries — never mid-escape-sequence or mid-UTF-8 character.

### Enable it

```bash
ai-jail -s claude          # dark theme (white on black)
ai-jail -s=light claude    # light theme (dark gray on bright white)
ai-jail --no-status-bar claude  # disable
```

The preference is stored in `$HOME/.ai-jail` (user-level, not per-project) and persists across sessions.

### New CLI flags

| Flag | Description |
|------|-------------|
| `-s`, `--status-bar` | Enable status bar (dark theme) |
| `--status-bar=light` | Enable status bar (light theme) |
| `--no-status-bar` | Disable status bar |

### New config fields

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `no_status_bar` | bool | not set (disabled) | `false` enables the status bar |
| `status_bar_style` | string | `"dark"` | `"dark"` or `"light"` theme |

These fields live in `$HOME/.ai-jail` (global user config), not in the per-project `.ai-jail`.

### Background update check

When the status bar is active, a background thread queries the GitHub releases API (via `curl`, 5s timeout). If a newer version exists, a green `↑` appears next to the version string. The check is fire-and-forget — network errors are silently ignored.

### PTY proxy details

- Child gets a PTY slave; ai-jail owns the real terminal in raw mode.
- SIGWINCH is forwarded to the child's foreground process group via `TIOCGPGRP`.
- Alt-screen enter/leave (`?1049h/l`, `?47h/l`, `?1047h/l`), RIS (`\x1bc`), and bare DECSTBM reset (`\x1b[r`) are detected incrementally across chunk boundaries and trigger a status bar redraw + cursor clamp.
- DCS, APC, PM, SOS string sequences are tracked to avoid injecting redraws mid-sequence.
- UTF-8 continuation bytes are tracked to avoid injecting between multi-byte characters.
- Raw mode is restored via RAII guard, even on panic.

## Improvements

- **Softer status bar colors** — Dark theme uses `\e[37;40m` (white on black) instead of bold bright white. Light theme uses `\e[90;107m` (dark gray on bright white) instead of bold black. Space fill instead of box-drawing characters.
- **Smart PWD truncation** — Long paths are shown as `…/last-segment` instead of hard-truncating from the right.
- **Global user config** — `$HOME/.ai-jail` now stores user-level preferences (status bar). Project-level `.ai-jail` is unchanged and does not include status bar fields.
- **SIGWINCH forwarding via TIOCGPGRP** — More accurate than forwarding to the child PID directly; reaches the actual foreground process group inside the PTY.

## Fixes

- **Fix resolv.conf mount ordering on WSL** — The resolv.conf bind mount is now placed after the `/run` tmpfs, fixing DNS resolution on WSL systems where `/etc/resolv.conf` points into `/run/systemd/resolve/`.
- **Fix Landlock /dev access in lockdown mode** — `/dev` is now read-write (was read-only), fixing writes to `/dev/null` and `/dev/tty` inside the sandbox.
- **Skip missing Landlock extra maps** — Non-existent `--rw-map` and `--map` paths are warned and skipped instead of causing Landlock errors.
- **Add XDG_RUNTIME_DIR to Landlock allowlist** — When display passthrough is enabled, the XDG runtime directory is now included in Landlock's read-write list for Wayland socket access.
- **Tighten macOS lockdown read policy** — In lockdown mode, `sandbox-exec` profiles now use an explicit read allow-list instead of global `(allow file-read*)`.
- **Teardown status bar on PTY error** — If the PTY proxy fails, the scroll region is properly reset before returning the error.

## Backward compatibility

- Old `.ai-jail` configs without `no_status_bar` or `status_bar_style` parse without error. Status bar defaults to disabled, matching prior behavior.
- All existing CLI flags and config fields are unchanged.
