pi-status-footer 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -7
- package/package.json +3 -8
- package/stats-footer.ts +185 -140
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# pi-status-footer
|
|
2
2
|
|
|
3
|
-
Compact status footer for the pi TUI: context usage, tokens,
|
|
3
|
+
Compact status footer for the pi TUI: context usage, tokens, live TPS, run completion time, git diff, and run timers, plus an optional third line for other extensions' status segments.
|
|
4
4
|
|
|
5
5
|
See [pi.dev docs](https://pi.dev) for how extensions work.
|
|
6
6
|
|
|
@@ -8,10 +8,12 @@ See [pi.dev docs](https://pi.dev) for how extensions work.
|
|
|
8
8
|
|
|
9
9
|
| Extension | Command / shortcut | What it does |
|
|
10
10
|
|---|---|---|
|
|
11
|
-
| `stats-footer.ts` | (no command; TUI footer widget) | Renders a footer: line 1
|
|
11
|
+
| `stats-footer.ts` | (no command; TUI footer widget) | Renders a footer: line 1 usage/completion clock/timers, line 2 folder/git/model, and a conditional line 3 carrying statuses other extensions set via `ctx.ui.setStatus()` |
|
|
12
12
|
|
|
13
13
|
It registers no slash commands, shortcuts, flags, tools, or providers. It hooks session/agent/turn/message events (`session_start`, `agent_start`, `agent_settled`, `turn_start/end`, `message_start/update/end`, `model_select`, `thinking_level_select`, `session_info_changed`, `session_shutdown`) to update the footer.
|
|
14
14
|
|
|
15
|
+
Both data lines spread their groups across the terminal width — left, middle, right — instead of hugging the left edge, so a wide terminal uses its space. Narrow terminals fall back to a compact left-aligned line.
|
|
16
|
+
|
|
15
17
|
## Install
|
|
16
18
|
|
|
17
19
|
```bash
|
|
@@ -34,14 +36,18 @@ The footer appears automatically in the next TUI session.
|
|
|
34
36
|
Just run `pi` in the TUI. Example footer:
|
|
35
37
|
|
|
36
38
|
```
|
|
37
|
-
38%/128k 63% ↑5.2k ↓8.1k
|
|
38
|
-
my-project
|
|
39
|
+
38%/128k 63% ↑5.2k ↓8.1k 42 t/s 08:23:30 4:32 1:18
|
|
40
|
+
my-project ▸ main +3 -1 openai/gpt-4o medium
|
|
39
41
|
bg 1 running · Shift↓
|
|
40
42
|
```
|
|
41
43
|
|
|
42
44
|
Icons are Nerd Font glyphs (Font Awesome / Material Design ranges), not emoji. Emoji are colour bitmaps whose rendering the terminal decides: some hosts (xterm.js/Chromium, iTerm2) paint them in full colour while others (Alacritty, kitty) draw flat monochrome silhouettes, so the same footer looked different per terminal. Nerd Font glyphs are single-cell line art everywhere. Requires a patched Nerd Font as the terminal font (for example `JetBrainsMono Nerd Font`); without one the icons show as boxes.
|
|
43
45
|
|
|
44
|
-
Line 1: context used/limit, cache hit rate, input/output tokens,
|
|
46
|
+
Line 1 is three groups: usage on the left (context used/limit, cache hit rate, input/output tokens, tokens/sec), the run completion clock in the middle, and the timers on the right (agent-run timer, current-turn timer). Tokens/sec sits with the output tokens it is derived from and is always rendered, so it shows from a session's first frame rather than appearing only once a rate exists. Line 2 is three groups too: folder (repo root, or cwd outside a repo) on the left, git branch + working-tree diff vs HEAD in the middle, provider/model + thinking level on the right.
|
|
47
|
+
|
|
48
|
+
The groups spread across the full width when the terminal is wide enough — the common case, and what stops the footer from piling everything against the left edge. When the line cannot hold the spread, the footer falls back to the compact left-aligned flow; on line 2 it then shortens the model id from the left and finally drops the git group.
|
|
49
|
+
|
|
50
|
+
The completion clock appears centred on line 1 when a run settles, keeps the local wall-clock time frozen until the next run starts, and is never shown for an aborted run. It is the same fact `pi-done-at` notifies with, but persistent instead of a transient notification — so both can be installed, or `pi-done-at` can be dropped for a quieter TUI.
|
|
45
51
|
|
|
46
52
|
Line 3 is conditional: it appears only while an extension has status text registered through `ctx.ui.setStatus()` (for example `pi-background-tasks`'s `bg 1 running · Shift↓`, or `pi-subagents` progress), and it disappears as soon as the last status clears, so the footer returns to its two-line height. Segments keep their own styling and are truncated to the terminal width like the other lines. This matters because a custom footer replaces pi's built-in footer: a footer that never reads those statuses hides other extensions' progress entirely.
|
|
47
53
|
|
|
@@ -51,7 +57,7 @@ Zero config. No env vars, no settings keys.
|
|
|
51
57
|
|
|
52
58
|
## Security note
|
|
53
59
|
|
|
54
|
-
Runs in-process with your OS permissions. It reads session entries (token usage,
|
|
60
|
+
Runs in-process with your OS permissions. It reads session entries (token usage, model, context) and runs one shell command, debounced to 1s during agent runs: `git diff --shortstat HEAD` (with `--no-optional-locks`, 3s timeout) plus a walk-up check for `.git` to find the repo root. No network access, no file writes.
|
|
55
61
|
|
|
56
62
|
## Update / remove / enable-disable
|
|
57
63
|
|
|
@@ -75,7 +81,7 @@ git clone https://github.com/kslamph/pi-status-footer.git
|
|
|
75
81
|
cd pi-status-footer
|
|
76
82
|
pi install ./ # local copy loads in place
|
|
77
83
|
pi -e ./stats-footer.ts # single run from inside the repo
|
|
78
|
-
npm test # runs test-layout, test-
|
|
84
|
+
npm test # runs test-live-tps, test-layout, test-cost, test-done-at
|
|
79
85
|
```
|
|
80
86
|
|
|
81
87
|
No build step; pi loads the TypeScript file directly. Optional typecheck: install the peer deps as devDependencies, then `npx tsc --noEmit stats-footer.ts`.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-status-footer",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Compact status footer for pi: model, thinking level, tokens,
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "Compact status footer for pi: model, thinking level, tokens, TPS, cache hit rate, context usage, live git diff, working/turn timers, run completion time, plus a conditional third line for other extensions' status segments.",
|
|
5
5
|
"author": "kslamph",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"pi-package",
|
|
@@ -15,11 +15,6 @@
|
|
|
15
15
|
"tokens",
|
|
16
16
|
"tps",
|
|
17
17
|
"tokens-per-second",
|
|
18
|
-
"cost",
|
|
19
|
-
"spend",
|
|
20
|
-
"usd",
|
|
21
|
-
"budget",
|
|
22
|
-
"pricing",
|
|
23
18
|
"cache",
|
|
24
19
|
"context",
|
|
25
20
|
"usage",
|
|
@@ -35,7 +30,7 @@
|
|
|
35
30
|
"streaming"
|
|
36
31
|
],
|
|
37
32
|
"scripts": {
|
|
38
|
-
"test": "node --experimental-strip-types test-live-tps.ts && node --experimental-strip-types test-layout.ts && node --experimental-strip-types test-cost.ts"
|
|
33
|
+
"test": "node --experimental-strip-types test-live-tps.ts && node --experimental-strip-types test-layout.ts && node --experimental-strip-types test-cost.ts && node --experimental-strip-types test-done-at.ts"
|
|
39
34
|
},
|
|
40
35
|
"license": "MIT",
|
|
41
36
|
"repository": {
|
package/stats-footer.ts
CHANGED
|
@@ -33,13 +33,14 @@ type RenderTui = { requestRender(force?: boolean): void };
|
|
|
33
33
|
export const ICONS = {
|
|
34
34
|
context: "\u{F1B2}", // fa-cube
|
|
35
35
|
cache: "\u{F1C0}", // fa-database
|
|
36
|
-
cost: "\u{F155}", // fa-usd
|
|
37
36
|
tps: "\u{F0E7}", // fa-flash (bolt)
|
|
38
37
|
runTimer: "\u{F252}", // fa-hourglass-half
|
|
39
38
|
turnTimer: "\u{F0E5}", // fa-comment-o
|
|
40
39
|
folder: "\u{F114}", // fa-folder-o
|
|
41
40
|
model: "\u{F2DB}", // fa-microchip
|
|
42
41
|
thinking: "\u{F09D1}", // md-brain
|
|
42
|
+
clock: "\u{F017}", // fa-clock-o (run completion time)
|
|
43
|
+
branch: "\u{E725}", // nf-cod-git_branch
|
|
43
44
|
} as const;
|
|
44
45
|
|
|
45
46
|
const THINKING_THEME_COLOR = {
|
|
@@ -71,41 +72,16 @@ export function formatDuration(ms: number): string {
|
|
|
71
72
|
return `${minutes}:${pad(seconds)}`;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
/** Decimals for the session sum and for the per-run delta. */
|
|
75
|
-
const COST_DECIMALS = 3;
|
|
76
|
-
const COST_DELTA_DECIMALS = 6;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Session cost in USD, fixed to 3 decimals. Fixed decimals rather than
|
|
80
|
-
* precision that follows the magnitude: the segment width then never changes
|
|
81
|
-
* as the total grows, and the value is never abbreviated away.
|
|
82
|
-
*
|
|
83
|
-
* Fixed decimals also mean no exponential fallback is ever needed. Dividing a
|
|
84
|
-
* rate by 1e6 twice is a real failure mode on this box (it happened), and
|
|
85
|
-
* `$0.000000` is a loud, obviously-broken number, whereas `$3.6e-9` could be
|
|
86
|
-
* read as a plausible price.
|
|
87
|
-
*
|
|
88
|
-
* A zero cost with tokens on the clock means the model carries no catalog
|
|
89
|
-
* pricing (aggregator/custom providers declare no rates, so pi records 0) —
|
|
90
|
-
* that is missing data, not a free session, so it reads `n/a`. Before any
|
|
91
|
-
* usage at all there is nothing to report, but the segment still renders as a
|
|
92
|
-
* `$0.000` placeholder rather than vanishing.
|
|
93
|
-
*/
|
|
94
|
-
export function formatCost(usd: number, hasTokens = true): string {
|
|
95
|
-
if (!Number.isFinite(usd) || usd < 0) return "n/a";
|
|
96
|
-
if (usd === 0) return hasTokens ? "n/a" : `$${(0).toFixed(COST_DECIMALS)}`;
|
|
97
|
-
return `$${usd.toFixed(COST_DECIMALS)}`;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
75
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
76
|
+
* Local wall-clock completion time, 24-hour with seconds (`08:23:30`), the
|
|
77
|
+
* same shape pi-done-at notifies with. The date is omitted on purpose: the
|
|
78
|
+
* footer always describes the current session, where a bare clock time is
|
|
79
|
+
* unambiguous and costs 8 columns instead of 14.
|
|
105
80
|
*/
|
|
106
|
-
export function
|
|
107
|
-
|
|
108
|
-
|
|
81
|
+
export function formatDoneAt(when: Date | number = Date.now()): string {
|
|
82
|
+
const date = typeof when === "number" ? new Date(when) : when;
|
|
83
|
+
const pad = (n: number): string => String(n).padStart(2, "0");
|
|
84
|
+
return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
109
85
|
}
|
|
110
86
|
|
|
111
87
|
/**
|
|
@@ -158,8 +134,8 @@ export function collectSessionStats(entries: readonly SessionEntry[]): {
|
|
|
158
134
|
// (`kind: "cache_warm"`) — is recorded *only* as a usage entry: no
|
|
159
135
|
// assistant message, no tool result. Pi counts these in session
|
|
160
136
|
// totals (docs/session-format.md), so skipping them would under-report
|
|
161
|
-
//
|
|
162
|
-
//
|
|
137
|
+
// tokens and the cache-hit rate against `/session`. Unknown kinds are
|
|
138
|
+
// counted like any other usage, per the same doc.
|
|
163
139
|
if (entry.type === "usage") {
|
|
164
140
|
addUsage(usage, entry.usage);
|
|
165
141
|
}
|
|
@@ -272,6 +248,63 @@ function joinSegments(segments: string[], separator: string): string {
|
|
|
272
248
|
return segments.filter(Boolean).join(separator);
|
|
273
249
|
}
|
|
274
250
|
|
|
251
|
+
export interface LineGroup {
|
|
252
|
+
/** Rendered text; "" groups are dropped before layout. */
|
|
253
|
+
text: string;
|
|
254
|
+
align: "left" | "center" | "right";
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Lay groups out across the full terminal width: left groups start at column
|
|
259
|
+
* 0, a centered group sits on the middle of the line, right groups end at the
|
|
260
|
+
* right edge. Without this a wide footer collapses into one left-hugging run
|
|
261
|
+
* of text and the right half of the terminal reads as empty space.
|
|
262
|
+
*
|
|
263
|
+
* Groups keep at least one separator of clearance, so a centered group that
|
|
264
|
+
* would collide is pushed instead of overlapping. Returns null when the
|
|
265
|
+
* groups plus their separators cannot fit at this width — callers then fall
|
|
266
|
+
* back to a compact left-aligned flow (or to their own fitting rules).
|
|
267
|
+
*/
|
|
268
|
+
export function distributeGroups(
|
|
269
|
+
groups: readonly LineGroup[],
|
|
270
|
+
width: number,
|
|
271
|
+
separator: string,
|
|
272
|
+
): string | null {
|
|
273
|
+
const budget = width - SAFETY_MARGIN;
|
|
274
|
+
const gap = Math.max(1, measureWidth(separator));
|
|
275
|
+
const items = groups
|
|
276
|
+
.filter((group) => group.text !== "")
|
|
277
|
+
.map((group) => ({ ...group, w: measureWidth(group.text) }));
|
|
278
|
+
if (items.length === 0) return "";
|
|
279
|
+
const minWidth =
|
|
280
|
+
items.reduce((sum, item) => sum + item.w, 0) + gap * (items.length - 1);
|
|
281
|
+
if (budget < minWidth) return null;
|
|
282
|
+
|
|
283
|
+
let line = "";
|
|
284
|
+
let cursor = 0;
|
|
285
|
+
for (let index = 0; index < items.length; index++) {
|
|
286
|
+
const item = items[index]!;
|
|
287
|
+
// Room the later groups need, so a centered group can never shove a
|
|
288
|
+
// right-aligned one past the edge.
|
|
289
|
+
let suffix = 0;
|
|
290
|
+
for (let rest = index + 1; rest < items.length; rest++) {
|
|
291
|
+
suffix += items[rest]!.w + gap;
|
|
292
|
+
}
|
|
293
|
+
const earliest = cursor + (index > 0 ? gap : 0);
|
|
294
|
+
const latest = budget - item.w - suffix;
|
|
295
|
+
let start =
|
|
296
|
+
item.align === "left"
|
|
297
|
+
? earliest
|
|
298
|
+
: item.align === "right"
|
|
299
|
+
? latest
|
|
300
|
+
: Math.round((budget - item.w) / 2);
|
|
301
|
+
start = Math.max(earliest, Math.min(start, latest));
|
|
302
|
+
line += " ".repeat(start - cursor) + item.text;
|
|
303
|
+
cursor = start + item.w;
|
|
304
|
+
}
|
|
305
|
+
return line;
|
|
306
|
+
}
|
|
307
|
+
|
|
275
308
|
/** Below this terminal width the footer gives up fitting and lets the line
|
|
276
309
|
* overflow (the TUI clips it); shortening arithmetic degenerates here. */
|
|
277
310
|
const MIN_FIT_WIDTH = 50;
|
|
@@ -388,6 +421,10 @@ export default function statsFooter(pi: ExtensionAPI) {
|
|
|
388
421
|
let timer: ReturnType<typeof setInterval> | null = null;
|
|
389
422
|
let runStart: number | null = null;
|
|
390
423
|
let lastRunDuration = 0;
|
|
424
|
+
// Wall-clock time of the last settled run — the "done at" segment. Null
|
|
425
|
+
// while a run is in flight, and after an aborted run, which never gets a
|
|
426
|
+
// completion time.
|
|
427
|
+
let settledAt: number | null = null;
|
|
391
428
|
// Turn timer: elapsed time since the current turn began (frozen at turn_end).
|
|
392
429
|
let turnStart: number | null = null;
|
|
393
430
|
let lastTurnDuration = 0;
|
|
@@ -415,32 +452,6 @@ export default function statsFooter(pi: ExtensionAPI) {
|
|
|
415
452
|
let gitDeleted = 0;
|
|
416
453
|
let gitFetching = false;
|
|
417
454
|
let lastGitFetch = 0;
|
|
418
|
-
// Session-manager handle, kept so agent_start can read the cumulative cost
|
|
419
|
-
// synchronously (renders are throttled, so a cached total can still be
|
|
420
|
-
// missing the previous run's final message when a new run begins).
|
|
421
|
-
let sessionManager: { getEntries(): SessionEntry[] } | null = null;
|
|
422
|
-
// Cumulative session cost at the start of the current agent run; the delta
|
|
423
|
-
// is the current cumulative minus this baseline — so the sum and the delta
|
|
424
|
-
// cover the session and the run, the same windows as the token totals and
|
|
425
|
-
// the run timer.
|
|
426
|
-
//
|
|
427
|
-
// Sampled at agent_start, NOT turn_start: in pi a "turn" is one assistant
|
|
428
|
-
// message inside the agentic tool loop (agent-session.js resets _turnIndex
|
|
429
|
-
// on agent_start and increments it on every turn_end), so a per-turn
|
|
430
|
-
// baseline was rewritten after every message. The delta appeared at
|
|
431
|
-
// message_end and was gone again by the next turn_start — never on screen
|
|
432
|
-
// for the whole time the next message was streaming.
|
|
433
|
-
let costAtRunStart = 0;
|
|
434
|
-
|
|
435
|
-
/** Cumulative session cost right now, read straight from the session. */
|
|
436
|
-
const readSessionCost = (): number => {
|
|
437
|
-
if (sessionManager === null) return 0;
|
|
438
|
-
try {
|
|
439
|
-
return collectSessionStats(sessionManager.getEntries()).usage.cost;
|
|
440
|
-
} catch {
|
|
441
|
-
return 0;
|
|
442
|
-
}
|
|
443
|
-
};
|
|
444
455
|
|
|
445
456
|
const rerender = () => tuiRef?.requestRender();
|
|
446
457
|
const stopTimer = () => {
|
|
@@ -477,6 +488,7 @@ export default function statsFooter(pi: ExtensionAPI) {
|
|
|
477
488
|
stopTimer();
|
|
478
489
|
runStart = null;
|
|
479
490
|
lastRunDuration = 0;
|
|
491
|
+
settledAt = null;
|
|
480
492
|
turnStart = null;
|
|
481
493
|
lastTurnDuration = 0;
|
|
482
494
|
genStart = null;
|
|
@@ -484,10 +496,6 @@ export default function statsFooter(pi: ExtensionAPI) {
|
|
|
484
496
|
lastTps = null;
|
|
485
497
|
deltaChars = 0;
|
|
486
498
|
sessionCwd = ctx.cwd;
|
|
487
|
-
sessionManager = ctx.sessionManager;
|
|
488
|
-
// Baseline the delta at whatever the (possibly resumed) session already
|
|
489
|
-
// spent, so a delta only ever appears once a run actually spends.
|
|
490
|
-
costAtRunStart = readSessionCost();
|
|
491
499
|
folderName = basename(ctx.cwd);
|
|
492
500
|
const repoRoot = findRepoRoot(ctx.cwd);
|
|
493
501
|
repoName = repoRoot === null ? null : basename(repoRoot);
|
|
@@ -557,74 +565,111 @@ export default function statsFooter(pi: ExtensionAPI) {
|
|
|
557
565
|
? computeTps(liveOutput, genStart, Date.now())
|
|
558
566
|
: null;
|
|
559
567
|
const tpsValue = liveTps ?? lastTps;
|
|
560
|
-
//
|
|
561
|
-
//
|
|
562
|
-
//
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
568
|
+
// Line 1 — three groups spread across the full width: the usage
|
|
569
|
+
// counters on the left (context, cache, tokens, live rate), the
|
|
570
|
+
// completion clock in the middle, the timers on the right. Wide
|
|
571
|
+
// terminals therefore use their space instead of hugging the left
|
|
572
|
+
// edge; narrow ones fall back to one compact left-aligned run,
|
|
573
|
+
// which the TUI clips rather than reordering.
|
|
574
|
+
const leftSegments = [
|
|
575
|
+
`${ICONS.context} ${theme.fg(contextColor, contextText)}`,
|
|
576
|
+
theme.fg(
|
|
577
|
+
"dim",
|
|
578
|
+
`${ICONS.cache} ${cacheRate === null ? "-" : `${cacheRate.toFixed(0)}%`}`,
|
|
579
|
+
),
|
|
580
|
+
theme.fg(
|
|
581
|
+
"dim",
|
|
582
|
+
`↑${formatTokens(usage.input)} ↓${formatTokens(usage.output)}`,
|
|
583
|
+
),
|
|
584
|
+
// The rate belongs beside the output tokens it is derived
|
|
585
|
+
// from, so the usage counters read as one block.
|
|
586
|
+
theme.fg("dim", `${ICONS.tps} ${Math.round(tpsValue ?? 0)} t/s`),
|
|
587
|
+
];
|
|
588
|
+
// Wall-clock time of the last settled run, centred on line 1: shown
|
|
589
|
+
// from agent_settled until the next run starts, and never for an
|
|
590
|
+
// aborted run — the same rule pi-done-at's notification uses. The
|
|
591
|
+
// centre slot keeps it clear of both the usage counters and the
|
|
592
|
+
// timers, and an in-flight run simply leaves the slot empty.
|
|
593
|
+
const doneAtSegment =
|
|
594
|
+
settledAt === null
|
|
595
|
+
? ""
|
|
596
|
+
: `${ICONS.clock} ${theme.fg("dim", formatDoneAt(settledAt))}`;
|
|
597
|
+
const rightSegments = [
|
|
598
|
+
`${ICONS.runTimer} ${theme.fg("accent", formatDuration(elapsed))}`,
|
|
599
|
+
`${ICONS.turnTimer} ${theme.fg("accent", formatDuration(turnElapsed))}`,
|
|
600
|
+
];
|
|
601
|
+
const statsLine =
|
|
602
|
+
distributeGroups(
|
|
603
|
+
[
|
|
604
|
+
{ text: joinSegments(leftSegments, separator), align: "left" },
|
|
605
|
+
{ text: doneAtSegment, align: "center" },
|
|
606
|
+
{ text: joinSegments(rightSegments, separator), align: "right" },
|
|
607
|
+
],
|
|
608
|
+
width,
|
|
609
|
+
separator,
|
|
610
|
+
) ??
|
|
611
|
+
joinSegments(
|
|
612
|
+
[...leftSegments, doneAtSegment, ...rightSegments],
|
|
613
|
+
separator,
|
|
614
|
+
);
|
|
615
|
+
// Line 2 — folder on the left, git (branch + diff) in the middle,
|
|
616
|
+
// model/thinking on the right. The folder always shows (repo root
|
|
617
|
+
// basename, or plain cwd basename outside a repo). When the spread
|
|
618
|
+
// layout does not fit, fitSecondLine shortens the model id from
|
|
619
|
+
// the left and, as a last resort, drops the whole git group.
|
|
598
620
|
const branch = footerData.getGitBranch();
|
|
599
|
-
const
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
621
|
+
const isRepo = repoName !== null;
|
|
622
|
+
const folderText =
|
|
623
|
+
folderName === null
|
|
624
|
+
? ""
|
|
625
|
+
: `${ICONS.folder} ${theme.fg("accent", repoName ?? folderName)}`;
|
|
626
|
+
const branchText =
|
|
627
|
+
isRepo && branch ? `▸ ${ICONS.branch} ${branch}` : "";
|
|
628
|
+
const diffText = `${theme.fg("toolDiffAdded", `+${gitAdded}`)} ${theme.fg("toolDiffRemoved", `-${gitDeleted}`)}`;
|
|
629
|
+
const provider = ctx.model?.provider ?? "";
|
|
630
|
+
const modelId = ctx.model?.id ?? "no-model";
|
|
631
|
+
const modelPrefix = `${ICONS.model} `;
|
|
632
|
+
const modelSuffix = ` ${thinkingText}`;
|
|
633
|
+
const styleModelId = (text: string) => theme.fg("accent", text);
|
|
634
|
+
const modelText = `${modelPrefix}${styleModelId(
|
|
635
|
+
`${provider ? `${provider}/` : ""}${modelId}`,
|
|
636
|
+
)}${modelSuffix}`;
|
|
637
|
+
const gitLine =
|
|
638
|
+
distributeGroups(
|
|
639
|
+
[
|
|
640
|
+
{ text: folderText, align: "left" },
|
|
641
|
+
{
|
|
642
|
+
text: isRepo
|
|
643
|
+
? joinSegments([branchText, diffText], separator)
|
|
644
|
+
: "",
|
|
645
|
+
align: "center",
|
|
646
|
+
},
|
|
647
|
+
{ text: modelText, align: "right" },
|
|
648
|
+
],
|
|
649
|
+
width,
|
|
623
650
|
separator,
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
651
|
+
) ??
|
|
652
|
+
fitSecondLine(
|
|
653
|
+
{
|
|
654
|
+
// Compact fallback keeps the old look: folder, branch and
|
|
655
|
+
// diff joined by single spaces so a narrow line stays tight.
|
|
656
|
+
gitGroup: joinSegments(
|
|
657
|
+
[
|
|
658
|
+
folderText,
|
|
659
|
+
branchText === "" ? "" : ` ${branchText}`,
|
|
660
|
+
isRepo ? ` ${diffText}` : "",
|
|
661
|
+
],
|
|
662
|
+
"",
|
|
663
|
+
),
|
|
664
|
+
modelPrefix,
|
|
665
|
+
provider,
|
|
666
|
+
modelId,
|
|
667
|
+
modelSuffix,
|
|
668
|
+
separator,
|
|
669
|
+
styleModelId,
|
|
670
|
+
},
|
|
671
|
+
width,
|
|
672
|
+
);
|
|
628
673
|
|
|
629
674
|
// Extension statuses set via ctx.ui.setStatus() are rendered by
|
|
630
675
|
// the built-in footer, which this custom footer replaces. Surface
|
|
@@ -658,11 +703,9 @@ export default function statsFooter(pi: ExtensionAPI) {
|
|
|
658
703
|
pi.on("agent_start", () => {
|
|
659
704
|
if (runStart === null) runStart = Date.now();
|
|
660
705
|
lastRunDuration = 0;
|
|
661
|
-
//
|
|
662
|
-
//
|
|
663
|
-
|
|
664
|
-
// previous run's cost into this one. Once per run, not once per turn.
|
|
665
|
-
costAtRunStart = readSessionCost();
|
|
706
|
+
// The previous run's completion clock is stale as soon as a new run
|
|
707
|
+
// starts; the segment reappears at the next agent_settled.
|
|
708
|
+
settledAt = null;
|
|
666
709
|
stopTimer();
|
|
667
710
|
timer = setInterval(() => {
|
|
668
711
|
if (sessionCwd !== null) fetchGitDiff(sessionCwd);
|
|
@@ -670,9 +713,12 @@ export default function statsFooter(pi: ExtensionAPI) {
|
|
|
670
713
|
}, 1_000);
|
|
671
714
|
rerender();
|
|
672
715
|
});
|
|
673
|
-
pi.on("agent_settled", () => {
|
|
716
|
+
pi.on("agent_settled", (event?: { aborted?: boolean }) => {
|
|
674
717
|
if (runStart !== null) lastRunDuration = Date.now() - runStart;
|
|
675
718
|
runStart = null;
|
|
719
|
+
// A cancelled run has no completion time; mirror pi-done-at, which also
|
|
720
|
+
// stays silent for aborted runs. Older hosts may omit the flag.
|
|
721
|
+
settledAt = event?.aborted ? null : Date.now();
|
|
676
722
|
genStart = null;
|
|
677
723
|
liveOutput = 0;
|
|
678
724
|
stopTimer();
|
|
@@ -694,6 +740,7 @@ export default function statsFooter(pi: ExtensionAPI) {
|
|
|
694
740
|
stopTimer();
|
|
695
741
|
tuiRef = null;
|
|
696
742
|
runStart = null;
|
|
743
|
+
settledAt = null;
|
|
697
744
|
turnStart = null;
|
|
698
745
|
lastTurnDuration = 0;
|
|
699
746
|
genStart = null;
|
|
@@ -701,8 +748,6 @@ export default function statsFooter(pi: ExtensionAPI) {
|
|
|
701
748
|
lastTps = null;
|
|
702
749
|
deltaChars = 0;
|
|
703
750
|
sessionCwd = null;
|
|
704
|
-
sessionManager = null;
|
|
705
|
-
costAtRunStart = 0;
|
|
706
751
|
folderName = null;
|
|
707
752
|
repoName = null;
|
|
708
753
|
gitAdded = 0;
|