mirror of
https://github.com/wassname/pi-plan.git
synced 2026-09-25 14:00:15 +08:00
Prioritize unfinished goals in widget
This commit is contained in:
+5
-1
@@ -121,7 +121,11 @@ export default function mainSupervisor(pi: ExtensionAPI) {
|
||||
const accepted = items.filter((g) => g.status === "done" && state.signoffs[key(g.subject)]).length;
|
||||
ctx.ui.setStatus("goals", `👀 ${accepted}/${items.length} goals`);
|
||||
const mark = (status: GoalStatus) => status === "done" ? "✔" : status === "active" ? "◼" : status === "cancelled" ? "✗" : "◻";
|
||||
const lines = items.slice(0, WIDGET_GOAL_LIMIT).map((g, index) => `${mark(g.status)} G${index + 1}: ${g.subject}`);
|
||||
const priority: Record<GoalStatus, number> = { active: 0, open: 1, done: 2, cancelled: 3 };
|
||||
const visible = [...items].sort((a, b) => priority[a.status] - priority[b.status]).slice(0, WIDGET_GOAL_LIMIT);
|
||||
const lines = visible.map((g) => `${mark(g.status)} G${items.indexOf(g) + 1}: ${g.subject}`);
|
||||
const hidden = items.length - visible.length;
|
||||
if (hidden) lines.push(`… ${hidden} more goal${hidden === 1 ? "" : "s"}`);
|
||||
ctx.ui.setWidget("goals", lines);
|
||||
}
|
||||
function watchPlan(ctx: ExtensionContext) {
|
||||
|
||||
+3
-3
@@ -585,11 +585,11 @@ it("lineage-only child attaches its plan without a widget, retains task context,
|
||||
expect(completion.content[0].text).toContain("only to the active parent");
|
||||
});
|
||||
|
||||
it("shows only the first three goals in the widget", async () => {
|
||||
it("prioritizes unfinished goals and says when the widget list is truncated", async () => {
|
||||
const f = fixture(); await f.draft();
|
||||
writeFileSync(f.path, "- [ ] goal: one\n- [ ] goal: two\n- [ ] goal: three\n- [ ] goal: four\n");
|
||||
writeFileSync(f.path, "- [x] goal: completed one\n- [x] goal: completed two\n- [/] goal: active work\n- [ ] goal: open one\n- [ ] goal: open two\n");
|
||||
await f.command("ready");
|
||||
expect(f.ctx.ui.setWidget.mock.lastCall?.[1]).toEqual(["◻ G1: one", "◻ G2: two", "◻ G3: three"]);
|
||||
expect(f.ctx.ui.setWidget.mock.lastCall?.[1]).toEqual(["◼ G3: active work", "◻ G4: open one", "◻ G5: open two", "… 2 more goals"]);
|
||||
f.shutdown();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user