pi-ext bugabingas pi extensions
owned by bugabinga
README Source History Refs Compare Notes Search fix(footer): show overflowing LLM segments
6ec7adc2cbaf43778861eaffaea5b90db0e46d1c
Oliver Jan Krylow <oliver@bugabinga.net > · 9 Sep 2026
SSH signature · not checked
Browse files Compare with HEAD
Changed files (3) extensions/footer/README.md Modified 27 27 Owns the Pi footer through `ctx.ui.setFooter()`.
29 - Visible footer has a stable two-line height:
29 + Visible footer has two lines normally and adds a third under LLM-segment pressure:
31 31 - line 0: `workspace` segments plus current session name on the left, with extension statuses via `ctx.ui.setStatus()` right-aligned in the remaining space.
32 - - line 1: the first `llm` flow row; overflow is not shown.
32 + - line 1: the first `llm` flow row.
33 + - line 2: the second `llm` flow row, shown only when content overflows line 1.
34 35 `footer:segment` payloads use `id`, `text`, and `zone` (`workspace` or `llm`).
35 36 Optional fields: `variants`, `icon`, `color`, `bar`, `suffix`, `group`, `separator`, and `order`.
extensions/footer/__tests__/harness.test.ts Modified 1 1 import path
from "node:path" ;
2 + import type { ExtensionAPI }
from "@earendil-works/pi-coding-agent" ;
2 3 import { visibleWidth }
from "@earendil-works/pi-tui" ;
3 4 import { afterEach, describe, expect, it }
from "vitest" ;
4 5 import { createTestSession, type TestSession }
from "../../../test/harness" ;
5 - import { __test }
from "../index.ts" ;
6 + import footerExtension, { __test }
from "../index.ts" ;
7 8 describe (
"footer pi-test-harness" , ()
=> {
8 9 let t
: TestSession | undefined ;
20 21 expect (t.session.extensionRunner.extensions[
0 ].path).
toBe (extensionPath);
24 + it (
"keeps later LLM components visible as earlier values grow" ,
async ()
=> {
25 + let emitSegment
: ((segment
: unknown )
=> void )
| undefined ;
26 + const producer = (pi
: ExtensionAPI )
=> {
27 + emitSegment = (segment)
=> pi.events.
emit (
"footer:segment" , segment);
29 + t
= await createTestSession ({
30 + extensionFactories: [footerExtension, producer],
33 + const factory
= t.events.
uiCallsFor (
"setFooter" ).
at (
- 1 )?.args[
0 ] as
35 + tui
: {
requestRender ()
: void },
36 + theme
: {
fg (style
: string , text
: string )
: string },
38 + onBranchChange (
callback : ()
=> void )
: ()
=> void ;
39 + getExtensionStatuses ()
: ReadonlyMap <
string ,
string >;
42 + render (width: number): string[];
46 + expect (factory).
toBeTypeOf (
"function" );
47 + const component
= factory ?.(
48 + {
requestRender () {} },
49 + {
fg : (_style, text)
=> text },
51 + onBranchChange : ()
=> ()
=> {},
52 + getExtensionStatuses : ()
=> new Map (),
55 + expect (component).
toBeDefined ();
57 + emitSegment ?.({ id:
"model" , text:
"sol:medium" , zone:
"llm" , order:
0 });
58 + emitSegment ?.({ id:
"tokens" , text:
"↑0" , zone:
"llm" , order:
2 });
59 + emitSegment ?.({ id:
"tps" , text:
"50.0/s" , zone:
"llm" , order:
4 });
60 + const initial
= component?.
render (
32 )
?? [];
61 + expect (initial).
toHaveLength (
2 );
62 + expect (initial.
join (
"\n" )).
toContain (
"50.0/s" );
70 + const grown
= component?.
render (
32 )
?? [];
71 + expect (grown).
toHaveLength (
3 );
72 + expect (grown.
join (
"\n" )).
toContain (
"50.0/s" );
73 + expect (grown.
every ((line)
=> visibleWidth (line)
<= 32 )).
toBe (
true );
75 + emitSegment ?.({ id:
"tokens" , text:
"↑0" , zone:
"llm" , order:
2 });
76 + const shrunk
= component?.
render (
32 )
?? [];
77 + expect (shrunk).
toHaveLength (
2 );
78 + expect (shrunk.
join (
"\n" )).
toContain (
"50.0/s" );
79 + component?.
dispose ();
23 82 it (
"right-aligns statuses beside the workspace row" , ()
=> {
24 83 expect (__test.
alignLeftAndRight (
"workspace" ,
"busy" ,
16 )).
toBe (
extensions/footer/index.ts Modified 334 335 const contentWidth
= Math .
max (
0 , width
- 2 );
335 336 const workspaceLine
= renderWorkspaceLine (theme, contentWidth, ctx);
336 - const [llmLine]
= renderLlmLines (theme, contentWidth);
337 + const [llmLine, llmOverflowLine]
= renderLlmLines (theme, contentWidth);
337 338 const statusLine
= renderStatusLine (theme, statuses);
338 339 const topLine
= alignLeftAndRight (workspaceLine, statusLine, contentWidth);
340 - return [
padLine (topLine, width),
padLine (llmLine, width)];
340 + const lines
= [
padLine (topLine, width),
padLine (llmLine, width)];
341 + if (llmOverflowLine) lines.
push (
padLine (llmOverflowLine, width));