Prioritize unfinished goals in widget

This commit is contained in:
wassname
2026-09-12 21:40:10 +08:00
parent 7bff8c2f70
commit 44443795b5
2 changed files with 8 additions and 4 deletions
+5 -1
View File
@@ -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
View File
@@ -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();
});