# @matheusbbarni/pi-run-timer

[![npm](https://img.shields.io/npm/v/@matheusbbarni/pi-run-timer.svg)](https://www.npmjs.com/package/@matheusbbarni/pi-run-timer)
[![Pi package](https://img.shields.io/badge/pi-package-111.svg)](https://pi.dev)

> Live elapsed time for the current [Pi](https://pi.dev) run.

A compact timer sits above the editor:

```text
Running • 3m9s
Worked • 3m9s
```

The clock starts when you submit a prompt, keeps ticking across retries and compaction, and holds the last duration when the run finishes. The next prompt starts it over.

## Features

- Shows `Running • 3m9s` while a run is in progress
- Switches off the live widget when the run settles and leaves `Worked • 3m9s` in the transcript
- Keeps running while async pi-subagents are still working, then records the full wall time
- Also writes the same label to Pi's working message and footer status
- Stays visible with themes such as amp-themes that hide the built-in working row
- Writes a `Worked • 3m9s` line into the transcript when a run settles
- Also records the time if you quit mid-run
- No-ops the live widget in print/JSON mode; still prints the duration on stderr

## Install

```bash
pi install npm:@matheusbbarni/pi-run-timer
```

From this repo:

```bash
pi -e ./pi-run-timer
```

Or as a local package:

```bash
pi install ./pi-run-timer
```

> [!TIP]
> If Pi is already open, run `/reload`.

## How it works

This is a widget, not Pi's built-in working row. Themes that replace the streaming chrome still show the timer because it renders above the editor.

Vanilla Pi also gets the same label on the working message and in the footer, so the duration is visible even without the widget.

When a run finishes, a muted `Worked • 3m9s` line is appended to the session. That entry is not sent to the model, so you can scroll back and compare run times.

## Development

```bash
npm install
npm test
npm run typecheck
```
