https://github.com/foae/opencode-timings
OpenCode TUI sidebar panel showing per-session timing: total API/inference time, wall-clock, turns, average and slowest turn
https://github.com/foae/opencode-timings
opencode opencode-ai opencode-plugin opencode-plugins
Last synced: about 1 month ago
JSON representation
OpenCode TUI sidebar panel showing per-session timing: total API/inference time, wall-clock, turns, average and slowest turn
- Host: GitHub
- URL: https://github.com/foae/opencode-timings
- Owner: foae
- License: mit
- Created: 2026-06-02T09:39:22.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-06-02T11:39:36.000Z (about 1 month ago)
- Last Synced: 2026-06-02T12:23:31.410Z (about 1 month ago)
- Topics: opencode, opencode-ai, opencode-plugin, opencode-plugins
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@foae/opencode-timings
- Size: 14.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# opencode-timings
A tiny [OpenCode](https://opencode.ai) **TUI sidebar** plugin that shows
per-session timing — how much wall-clock the session has taken and how much of
that was actually spent waiting on the model.
It renders into the same right-hand sidebar as the Quota / MCP / LSP / Todo /
Files panels, reading the session's messages directly from the TUI's reactive
state. Nothing is ever injected into the message stream, so there is **zero
context-window pollution**.

```
Timing
api/wall ██████░░ 78%
api 31s · wall 40s
turns 4 · avg 8s
slowest 19s
per-turn ▄█▂▂
```
Every row names itself, so there are no unlabeled numbers or glyphs to decode.
## Metrics
| Row | Meaning |
|------------|---------|
| `api/wall` | How much of wall-clock was actual model inference, as a bar gauge and percent. |
| `api` | Total assistant inference time — the sum of `time.completed − time.created` over every completed assistant message. |
| `wall` | Span from the first to the last message timestamp. Includes the time you spend reading/typing between turns, so `api` is always a fraction of it. |
| `turns` | Number of completed assistant messages, plus the average per-turn duration. |
| `slowest` | The single slowest assistant message. |
| `per-turn` | Sparkline of each recent turn's duration. |
The panel is always shown; before the first turn its values read zero.
## Install
Add it to the `plugin` array of the **TUI** config that OpenCode loads
(`~/.config/opencode/tui.json` or `tui.jsonc`) — this is a TUI plugin, so it
belongs in `tui.json`, not `opencode.json`:
```jsonc
{
"$schema": "https://opencode.ai/tui.json",
"plugin": ["@foae/opencode-timings@latest"]
}
```
OpenCode installs the plugin and its dependencies with Bun at startup. Restart
OpenCode and open the session sidebar to see the `Timing` panel.
You can also pin a version, e.g. `@foae/opencode-timings@0.1.2`.
## Configuration
Pass options using the tuple form (`[spec, options]`) in `tui.json`:
```jsonc
{
"$schema": "https://opencode.ai/tui.json",
"plugin": [
["@foae/opencode-timings@latest", {
"mode": "fancy",
"fields": { "ratio": true, "api": true, "wall": true, "turns": true, "avg": true, "slow": true, "sparkline": true }
}]
]
}
```
| Option | Values | Default | Meaning |
|----------|--------|---------|---------|
| `mode` | `"fancy"` \| `"simple"` | `"fancy"` | `fancy` draws the gauge bar on the `api/wall` row and adds the per-turn sparkline; `simple` is the same rows without the bar or sparkline. |
| `fields` | object of booleans | all `true` | Each toggles exactly one value: `ratio` (the `api/wall` gauge + percent), `api`, `wall`, `turns`, `avg`, `slow`, `sparkline` (`sparkline` is fancy-only). Values that share a line drop out individually. |
With no options (a plain `"@foae/opencode-timings@latest"` string), it defaults to `fancy` mode with all fields shown.
## Requirements
- OpenCode `1.15.x` or newer (uses the TUI slot plugin API).
## Development
Built and run with [Bun](https://bun.sh). The package ships raw source — there is no build step; OpenCode loads `src/tui.tsx` directly.
- `src/timing.ts` — pure timing math, formatting, and config parsing (no JSX), unit-tested.
- `src/tui.tsx` — the SolidJS sidebar component and the slot registration.
```sh
bun install
bun run typecheck # tsc --noEmit
bun test # unit tests for the pure logic in src/timing.ts
```
`opentui`, `solid-js`, and the OpenCode plugin/SDK are **peer dependencies** — at runtime they come from the OpenCode host so the plugin shares its renderer; the `devDependencies` mirror them for local typecheck and tests.
## License
MIT — see [LICENSE](./LICENSE).