From 010e4b83eb1ac94ca22ccc2286eb77bc1e6beb72 Mon Sep 17 00:00:00 2001 From: Alex Blank Date: Wed, 10 Jun 2026 18:53:49 +0200 Subject: [PATCH] feat: render ASCII progress bar in Pi extension updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add renderProgressBar() helper in pi-extension.ts - Pi init/reinit now show [████░░░░░░] 3/20 → filename.ts - Replaces plain text percentage with visual bar - All 52 tests passing --- pi-extension.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pi-extension.ts b/pi-extension.ts index c94673a..61019fa 100644 --- a/pi-extension.ts +++ b/pi-extension.ts @@ -55,6 +55,14 @@ function isDirty(content: string): boolean { return content.includes("## dirty") && !content.includes("## dirty\n-"); } +function renderProgressBar(completed: number, total: number, currentFile?: string, width = 20): string { + const pct = total > 0 ? completed / total : 0; + const filled = Math.round(width * pct); + const bar = "█".repeat(filled) + "░".repeat(width - filled); + const file = currentFile ? ` → ${currentFile}` : ""; + return `[${bar}] ${completed}/${total}${file}`; +} + export default function (pi: ExtensionAPI) { pi.registerTool({ name: "project_map_init", @@ -83,10 +91,10 @@ export default function (pi: ExtensionAPI) { llmClient: client, cacheDir: ctx.cwd, onProgress: (info) => { - const pct = info.total > 0 ? Math.round((info.completed / info.total) * 100) : 0; + const bar = renderProgressBar(info.completed, info.total, info.currentFile); _onUpdate?.({ - content: [{ type: "text", text: `${info.message} (${pct}%)` }], - details: { progress: pct, file: info.currentFile, dir: info.dir }, + content: [{ type: "text", text: bar }], + details: { progress: info.total > 0 ? Math.round((info.completed / info.total) * 100) : 0, file: info.currentFile, dir: info.dir }, }); }, }); @@ -215,10 +223,10 @@ export default function (pi: ExtensionAPI) { llmClient: client, cacheDir: ctx.cwd, onProgress: (info) => { - const pct = info.total > 0 ? Math.round((info.completed / info.total) * 100) : 0; + const bar = renderProgressBar(info.completed, info.total, info.currentFile); _onUpdate?.({ - content: [{ type: "text", text: `${info.message} (${pct}%)` }], - details: { progress: pct, file: info.currentFile, dir: info.dir }, + content: [{ type: "text", text: bar }], + details: { progress: info.total > 0 ? Math.round((info.completed / info.total) * 100) : 0, file: info.currentFile, dir: info.dir }, }); }, });