Keep active projects’ parked tasks out of the Someday list

This commit is contained in:
marcus
2026-11-25 00:06:58 -08:00
parent d7c55a3c19
commit adcf79fdcc
2 changed files with 49 additions and 1 deletions

View File

@@ -124,3 +124,37 @@ describe("area lens", () => {
expect(spawned.area).toBe("work");
});
});
describe("someday tasks that belong to a project", () => {
const somedayIds = () => store.tasksByStatus(store.getState(), "someday").map((t) => t.id);
test("stay off the Someday list while their project is live", () => {
const proj = store.createProject({ name: "Move to USA" });
const loose = store.createTask({ title: "learn the cello", status: "someday" });
const step = store.createTask({ title: "ship the boxes", status: "someday", project_id: proj.id });
expect(somedayIds()).toContain(loose.id);
expect(somedayIds()).not.toContain(step.id);
// still counted on the project, so it is reachable from the Projects list
expect(store.openTaskCount(store.getState(), proj.id)).toBe(1);
});
test("come back to Someday when the project is dropped or completed", () => {
const proj = store.createProject({ name: "Old idea" });
const step = store.createTask({ title: "parked step", status: "someday", project_id: proj.id });
expect(somedayIds()).not.toContain(step.id);
store.updateProject(proj.id, { status: "completed" });
expect(somedayIds()).toContain(step.id);
store.updateProject(proj.id, { status: "active" });
store.dropProject(proj.id);
expect(somedayIds()).toContain(step.id);
});
test("other lists are unaffected by project membership", () => {
const proj = store.createProject({ name: "Things to Buy" });
const next = store.createTask({ title: "buy towel", status: "next", project_id: proj.id });
expect(store.tasksByStatus(store.getState(), "next").map((t) => t.id)).toContain(next.id);
});
});

View File

@@ -369,8 +369,22 @@ function byManualOrder(a: Task, b: Task): number {
return a.sort_order - b.sort_order || byPriorityDue(a, b);
}
/**
* A someday task that belongs to a project lives on that project's page, not in
* the Someday list — otherwise a project's parked steps drown the real
* someday/maybe ideas. Tasks whose project is gone, dropped or completed stay
* in Someday so they can never become invisible.
*/
function shownOnProjectPage(s: State, t: Task): boolean {
if (!t.project_id) return false;
const p = s.projects.find((x) => x.id === t.project_id);
return !!p && p.status !== "dropped" && p.status !== "completed";
}
export function tasksByStatus(s: State, status: Task["status"]): Task[] {
return inArea(s, s.tasks).filter((t) => t.status === status).sort(byManualOrder);
return inArea(s, s.tasks)
.filter((t) => t.status === status && !(status === "someday" && shownOnProjectPage(s, t)))
.sort(byManualOrder);
}
/**