From de01894348ff1ca329d4abd496b93197658ab3d2 Mon Sep 17 00:00:00 2001 From: wassname Date: Thu, 2 Jul 2026 06:29:16 +0800 Subject: [PATCH] widget: show only live goals, crop finished to a one-line summary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Completed goals were listed in file order, so done goals pushed the active/open work down the widget. Now show active+open in full and collapse done/cancelled into a single muted '✔ N done ✗ M cancelled' line. Full history stays in goals.md and the ## Log. Co-Authored-By: Claudypoo <288921227+claudypoo@users.noreply.github.com> --- src/index.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index ff8d1a2..974c580 100644 --- a/src/index.ts +++ b/src/index.ts @@ -133,13 +133,21 @@ export default function piGoalsExtension(pi: ExtensionAPI): void { // plus a footer path -- one line carries both. Title trails the path when set. const header = ctx.ui.theme.fg("muted", doc.title ? `${PLAN_REL}: ${doc.title}` : PLAN_REL); const lines = [header]; - for (const g of doc.goals) { - // Show every goal with its status glyph (✔ done, ▸ active, ◻ open, ✗ cancelled) so finished - // goals read as checked off rather than vanishing. Plans are small, so this stays readable. + // Show the live work (active + open) in full, in file order; finished goals (done/cancelled) get + // cropped to one muted summary line so completed goals don't push the current work off screen as + // they pile up across sessions. Full history still lives in goals.md / the ## Log. + const live = doc.goals.filter((g) => g.status === "active" || g.status === "open"); + for (const g of live) { const total = g.subtasks.length; const done = g.subtasks.filter((s) => s.status === "done").length; lines.push(`${mark[g.status]} ${g.subject}${total ? ` (${done}/${total} tasks)` : ""}`); } + const doneN = doc.goals.filter((g) => g.status === "done").length; + const cancN = doc.goals.filter((g) => g.status === "cancelled").length; + if (doneN || cancN) { + const parts = [doneN ? `✔ ${doneN} done` : "", cancN ? `✗ ${cancN} cancelled` : ""].filter(Boolean); + lines.push(ctx.ui.theme.fg("muted", parts.join(" "))); + } return lines; }