From 1c7c5e10e0a9fcab641f2da0988097acd0e418e1 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 26 Jan 2026 16:53:49 +0100 Subject: [PATCH] add redraws helper extension for TUI development --- .pi/extensions/redraws.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .pi/extensions/redraws.ts diff --git a/.pi/extensions/redraws.ts b/.pi/extensions/redraws.ts new file mode 100644 index 00000000..2db0867f --- /dev/null +++ b/.pi/extensions/redraws.ts @@ -0,0 +1,24 @@ +/** + * Redraws Extension + * + * Exposes /tui to show TUI redraw stats. + */ + +import type { ExtensionAPI } from "@mariozechner/pi-coding-agent"; +import { Text } from "@mariozechner/pi-tui"; + +export default function (pi: ExtensionAPI) { + pi.registerCommand("tui", { + description: "Show TUI stats", + handler: async (_args, ctx) => { + if (!ctx.hasUI) return; + let redraws = 0; + await ctx.ui.custom((tui, _theme, _keybindings, done) => { + redraws = tui.fullRedraws; + done(undefined); + return new Text("", 0, 0); + }); + ctx.ui.notify(`TUI full redraws: ${redraws}`, "info"); + }, + }); +}