pi-tui-polish
Rounded input box corners, a prompt gutter, a highlighted tool name, and path / TPS / model / context labels in the border or the footer of pi
Package details
Install pi-tui-polish from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-tui-polish- Package
pi-tui-polish- Version
0.6.0- Published
- Nov 20, 2026
- Downloads
- 672/mo · 250/wk
- Author
- heibaige123
- License
- MIT
- Types
- extension
- Size
- 475.6 KB
- Dependencies
- 0 dependencies · 2 peers
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-tui-polish
Four small, theme-following touches to pi's terminal UI:
- Rounded input box — the border rules end in
╭ ╮ ╰ ╯instead of four bare─, a blank row inside each end keeps the text off the rules, and the chrome can move into them: the path in the top rule, the TPS meter, the model and the context gauge in the bottom one. - A gutter for the prompt — the text keeps 2 columns of air from the border on each side, so it never runs into the frame and every wrapped line starts on the same column.
- A highlighted tool name — the name on a tool call line is painted with the theme's
highlight color (
accent) instead of the plain text color. - A configurable footer — whatever the border does not take: pi's stats line, the
⚡ tok/smeter, the context gauge, with a blank row above the block.
Screenshots
Every picture is a whole pi screen drawn by this extension — a user turn, a tool call, the
reply, the input box and the footer — at 120 columns, with pi's resolved dark and light
palette. npm run screenshots regenerates them.
Dark, everything in the rules — editor: { tps, model, context, path }. Nothing is left
for the footer, so its row disappears and the transcript gets the two rows back:

Light, the same screen — every color, the border included, comes from the theme:

Mixed — only the model in the bottom rule. The footer keeps the path, the stats, the meter and the gauge, and the path shortens itself to stay on one line:

Footer only — layout: "inline" puts everything on one row; layout: "pi" keeps pi's
stack of path, stats and statuses:


Narrow terminals — the top rule shortens the path to its last segments; the bottom rule gives up the speed first, then the gauge, then the model, then draws the plain rule:

The tool name — pi paints it bold in the plain text color; this extension paints it bold
in the theme's accent and leaves the rest of the line alone:

The border labels and the footer are configurable; the rest is fixed — including the blank
rows: one inside each end of the input box, one above the footer. Configuration lives in
~/.config/pi-tui-polish/config.json, and /polish edits the same values interactively —
see The border rules and Footer.
(Renamed from pi-tui-cards in 0.3.0 — the earlier version drew whole cards around tool
blocks and the input box, which is long gone.)
Install
pi install npm:pi-tui-polish # published release
pi install git:github.com/<you>/pi-tui-polish # straight from a repository
pi install ./pi-tui-polish # a local checkout
pi -e npm:pi-tui-polish # one invocation, no settings entry
Then /reload (or restart pi). pi remove npm:pi-tui-polish removes it again.
Development and release notes live in CONTRIBUTING.md.
The package ships TypeScript and pi loads it through its extension loader (jiti), so there is no build step and no bundled output.
The border rules
editor.* moves the four parts you look at all day out of the footer and into the input
box's rules — editor.path at the right end of the top rule; editor.context and
editor.tps at the left end of the bottom rule, two blanks apart; editor.model at its
right end.
An empty box is five rows: top rule, a blank row, the text, a blank row, bottom rule. The padding is a blank row inside each end rather than extra border, so the text never sits on a rule and the box grows from the inside — clicking a text row still lands on the right column, and the autocomplete list keeps its hit-testing.
Provider in brackets, the model id exactly as configured, the thinking level only for
models that reason. The path is pi's footer path with the same ~, (branch) and
• session name behind it. The TPS meter and the gauge are the same widgets the footer
uses, in their own colors; the model and the path are dim. The rule takes whatever width is
left — pi's ↑/↓ N more hints stay in it, and the working spinner stays at the left of the
top rule — so every row is exactly as wide as the terminal. A git checkout, a /rename,
a model switch or a streaming turn all show up without a reload.
A row that does not fit gives up in this order: the top rule shortens the path to its last three segments, then two, then one, then drops it; the bottom rule drops the speed first, then the gauge, then the model; the plain rounded rule is the last resort.
{
"editor": {
"tps": true,
"model": true,
"context": true,
"path": true
}
}
Same ~/.config/pi-tui-polish/config.json; all four default to false, and /polish has
a switch each. Whatever the border prints, the footer leaves out: editor.path silences
footer.path, and editor.tps / editor.context / editor.model do the same for their
footer counterparts, so nothing is drawn twice. The git branch comes from the footer's data
provider, which pi only creates while this extension draws the footer: with
footer.enabled: false the border shows the path without (branch).
Footer
pi builds the stats line from segments — ↑input, ↓output, Rcache-read,
Wcache-write, CHhit%, $cost, percent%/window — and prints each one as soon as it has
a value.
This extension draws the footer itself and prints only the segments the config keeps. Two layouts:
layout: "pi" — pi's rows, minus what you switched off: the path, then the stats with the
model right-aligned, then the status line. layout: "inline" — everything on one row with
· between the parts. The two pictures above show both, with every part switched off in
the border.
Either layout gets the blank row above it, so the footer never touches the input box; the block sits flush on the bottom edge, where an extra row would only cost screen.
When an inline row does not fit, it gives up in this order: the model, then the tail of
the path (down to …/learn-notes), then the TPS meter, then other extensions' status
texts, and only as a last resort the path itself. So a narrow terminal keeps
…/learn-notes (main) · 15.2%/1.0M rather than the model name or the speed.
~/.config/pi-tui-polish/config.json ($XDG_CONFIG_HOME wins) is read on every
session_start, including /reload:
{
"editor": { "tps": true, "model": true, "context": true, "path": true },
"footer": {
"enabled": true,
"layout": "inline",
"segments": [],
"path": false,
"sessionName": true,
"model": "off",
"tps": true,
"context": true
}
}
Every part of this footer is on the border (see above), so the row renders empty and pi
draws no footer at all — the transcript gains the two rows back. Switch any editor.* part
off and it comes back to the footer row, right where it was.
footer.context is the same number pi's footer prints as 33.9%/1.0M (auto): rounded to
whole percent, a sixteen-cell bar, used/window, green below 70%, yellow to 90%, red above.
The (auto) marker follows compaction.enabled, so with automatic compaction off the
gauge ends at 1M. ctx.getContextUsage() walks the session, so it is cached until the
session, leaf, entry count or model changes.
| Key | Default | What it does |
|---|---|---|
footer.enabled |
true |
false hands the footer back to pi |
footer.layout |
"pi" |
"pi" = path / stats / statuses on separate rows; "inline" = one row joined by · |
footer.segments |
all seven | stats to print, always in pi's order: input (↑), output (↓), cacheRead (R), cacheWrite (W), cacheHit (CH), cost ($), context (%/window) |
footer.path |
true |
the pwd (branch) part; skipped while editor.path has it |
footer.sessionName |
true |
• name after the path |
footer.model |
"full" |
"full" = (provider) id • level when several providers are available, otherwise id • level; "short" = the id after its last /; "off" = hidden; skipped while editor.model has it |
footer.tps |
false |
the ⚡ tok/s meter, fed by the stream; skipped while editor.tps has it |
footer.context |
false |
34% █████░░░░░░░░░░░ 337k/1M; skipped while editor.context has it |
A segment whose value is zero stays hidden, exactly like pi's footer, so ↑0 never shows
up. Unknown segment names are ignored, and a broken file keeps pi running with a warning
instead of failing the session.
TPS meter
footer.tps adds ⚡ 42.1 tok/s without a second extension.
- While streaming the number is an estimate from the deltas themselves: CJK characters
count as one token, the rest as
chars / n, wherenstarts at 4 and is re-measured from the provider's count after every message big enough to trust. The value slides over the last 2.5 s, so it tracks local speed — a thinking burst and a prose run read differently. - After the turn the number is exact: the provider's
usage.outputdivided by the time the model actually spent emitting, i.e. the sum of each assistant message's first-to-last delta. Tool calls, the request latency between two messages and the tail after the last token never enter the denominator.
Before a measured window (under 120 ms of streaming) it shows ⚡ --. While streaming the
value is accent, otherwise dim.
Backtested against provider counts on three real turns: the frozen number matched to
0.0% every time, the live estimate averaged +18% on the first uncalibrated message and
-6% on the next one once n had been learned.
It is a deliberate subset of pi-tps-status: no TTFT, no counting strategies, no speed
tiers, no [provider] tag. Both extensions installed means two readings, so remove
npm:pi-tps-status when you switch.
/polish is the same file as a settings list: Enter (or Space) cycles a value, every
change is applied to the running footer immediately and written back to config.json,
Escape closes the list.
Two things pi's footer draws that an extension cannot see, so this one omits them: the
→ routed-model hop of a virtual model, and the (sub) marker of a subscription-backed
provider.
What it leaves alone
| Stays exactly as pi draws it |
|---|
| tool result blocks, diffs and output previews (pi's own renderers) |
| the rest of a call line: path, line range, argument preview |
| border color — thinking level, bash mode, and the working spinner in the top rule |
| text layout and word wrap, cursor and mouse hit-testing |
| autocomplete menu, history, paste markers |
app keybindings (Esc, Ctrl+D, model switching, …) |
A theme can already restyle toolTitle, but a theme cannot round corners or pad the
prompt — that is what the editor subclass is for. The tool-name repaint is also narrower
than a theme change: only the name at the start of a call line is touched.
Requirements
- pi 1.5.x (developed and tested against 1.5.2) — it relies on
Editor.renderTopBorder,renderBottomBorder,renderandhandleMouse; the editor'spaddingXand its two row counters;pi.registerToolRenderer,ctx.ui.setFooterandgetSettingsListTheme(). - Node 20+, like pi itself.
@earendil-works/pi-coding-agentand@earendil-works/pi-tuiarepeerDependencieson purpose: pi supplies them at runtime, and a second copy would create a duplicate component/theme instance. They are repeated indevDependenciesonly so the types andnpm run typecheckresolve locally.