Initial release
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
||||
import type { TaskState } from "./state.ts";
|
||||
import { renderProgressHeader, renderTree } from "./ui.ts";
|
||||
|
||||
const WIDGET_ID = "pi-todo-herdr";
|
||||
|
||||
export function clearTaskWidget(ctx: ExtensionContext): void {
|
||||
ctx.ui.setWidget(WIDGET_ID, undefined);
|
||||
}
|
||||
|
||||
export function updateTaskWidget(state: TaskState, ctx: ExtensionContext, visible: boolean): void {
|
||||
const tasks = state.list();
|
||||
if (!visible || tasks.length === 0) {
|
||||
clearTaskWidget(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
const stats = state.stats();
|
||||
ctx.ui.setWidget(WIDGET_ID, (_tui, theme) => ({
|
||||
render(width: number): string[] {
|
||||
return [renderProgressHeader(stats, theme, width), ...renderTree(tasks, theme, width)];
|
||||
},
|
||||
invalidate(): void {},
|
||||
}));
|
||||
}
|
||||
Reference in New Issue
Block a user