dotfiles
bugabingas dorkfiles
owned by bugabinga
fix(pi/footer): swap footer via setFooter() on toggle for true 0-height when hidden
a49441f4e1e4649ba95c2124b166524e51bec9dc
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
Browse filesCompare with HEAD
Changed files (2)
pi/agent/extensions/footer/index.ts
Modified 10 10 * Producers use semantic
zones (
"workspace" | "llm"). Footer decides row mapping.
11 11 * Uses
setFooter() — the single footer owner. Producers are decoupled.
13 + * /footer or ctrl
+alt
+f toggles visibility by swapping between
14 + * the real footer and a zero
-height stub via
setFooter().
14 17 import type { ExtensionAPI, ExtensionContext, Theme, ThemeColor }
from "@mariozechner/pi-coding-agent";
52 +const HIDDEN_FOOTER
= {
55 + render()
: string[] {
return []; },
48 58 export default function footerExtension(pi
: ExtensionAPI) {
49 59 const segments
= new Map<
string,
Segment>();
50 60 let config
: FooterConfig = {
...DEFAULT_CONFIG };
51 61 let requestRender
: (()
=> void)
| undefined;
52 62 let renderScheduled
= false;
53 63 let hidden
= false;
64 + let currentCtx
: ExtensionContext | undefined;
91 102 function getZoneSegments(zone
: FooterZone, ctx
?: ExtensionContext)
: Segment[] {
92 103 const segs
= Array.
from(segments.
values()).
filter((s)
=> s.zone
=== zone);
93 104 if (zone
=== "workspace" && ctx) {
99 105 const name
= getSessionName(ctx);
101 107 segs.
push({ id:
"session-name", text: name, icon:
"✎", color:
"accent", zone:
"workspace", order:
0.5 });
119 125 const bar
= config.barStyle
=== "blocks" 120 126 ? renderBlocksBar(seg.bar, config.barWidth, theme, color)
121 127 : renderContinuousBar(seg.bar, config.barWidth, theme, color);
123 128 const suffix
= seg.suffix
? theme.
fg(color, seg.suffix)
: "";
124 129 parts.
push(bar
+ suffix);
125 130 }
else if (seg.suffix) {
171 176 return [line1, line2];
176 - function toggleVisibility(ctx
: ExtensionContext) {
178 - ctx.ui.
notify(hidden
? "Footer hidden" : "Footer visible",
"info");
181 + function mountFooter() {
182 + if (
!currentCtx)
return;
182 - pi.
registerCommand(
"footer", {
183 - description:
"Toggle footer visibility",
184 - handler:
async (_args, ctx)
=> toggleVisibility(ctx),
185 + requestRender
= undefined;
186 + currentCtx.ui.
setFooter(()
=> HIDDEN_FOOTER);
187 - pi.
registerShortcut(Key.
ctrlAlt(
"f"), {
188 - description:
"Toggle footer visibility",
189 - handler:
async (ctx)
=> toggleVisibility(ctx),
194 - pi.
on(
"session_start",
async (_event, ctx)
=> {
195 - if (
!ctx.hasUI)
return;
197 - ctx.ui.
setFooter((tui, theme, footerData)
=> {
190 + currentCtx.ui.
setFooter((tui, theme, footerData)
=> {
198 191 requestRender = ()
=> tui.
requestRender();
199 192 const unsubBranch
= footerData.
onBranchChange(()
=> scheduleRender());
207 200 render(width: number): string[] {
208 - if (hidden)
return [];
210 201 const contentWidth
= Math.
max(
0, width
- 2);
211 202 const padLine = (line
: string)
=> {
212 203 if (width
<= 1)
return truncateToWidth(line, width);
213 204 return ` ${truncateToWidth(line, contentWidth)} `;
216 - const workspaceLine
= renderWorkspaceLine(theme, contentWidth, ctx);
207 + const workspaceLine
= renderWorkspaceLine(theme, contentWidth, currentCtx
!);
217 208 const [llmLine1, llmLine2]
= renderLlmLines(theme, contentWidth);
243 233 setTimeout(()
=> scheduleRender(),
0);
238 + function toggleVisibility(ctx
: ExtensionContext) {
241 + ctx.ui.
notify(hidden
? "Footer hidden" : "Footer visible",
"info");
245 + pi.
registerCommand(
"footer", {
246 + description:
"Toggle footer visibility",
247 + handler:
async (_args, ctx)
=> toggleVisibility(ctx),
250 + pi.
registerShortcut(Key.
ctrlAlt(
"f"), {
251 + description:
"Toggle footer visibility",
252 + handler:
async (ctx)
=> toggleVisibility(ctx),
257 + pi.
on(
"session_start",
async (_event, ctx)
=> {
258 + if (
!ctx.hasUI)
return;
246 263 pi.
on(
"session_shutdown",
async ()
=> {
247 264 segments.
clear();
248 265 requestRender
= undefined;
266 + currentCtx
= undefined;
pi/agent/previews/neko-preview.ts
Modified264 264 function render(frame
: number)
: string {
265 265 const lines
: string[]
= [];
266 - lines.
push(
`${A.bold}${A.cyan}neko sprite preview${A.reset} ${A.dim}| Ctrl-C quits | NEKO_PREVIEW_FPS=12 bun agent/extensions/neko-preview.ts${A.reset}`);
266 + lines.
push(
`${A.bold}${A.cyan}neko sprite preview${A.reset} ${A.dim}| Ctrl-C quits | NEKO_PREVIEW_FPS=12 bun agent/previews/neko-preview.ts${A.reset}`);
268 268 lines.
push(
`${pad("activity", 12)} ${pad("idle ←", 18)} ${pad("idle →", 18)} ${pad("walk ←", 18)} ${pad("walk →", 18)}`);
269 269 lines.
push(
`${A.dim}${"─".repeat(89)}${A.reset}`);