From 4e3fa590c8362a02b33086954c54bd30ed6ff88d Mon Sep 17 00:00:00 2001 From: elpatron Date: Fri, 19 Jun 2026 22:36:15 +0200 Subject: [PATCH] Fix empty goal groups not appearing in the Goals tab. Include goal groups without items in the structured goals API so newly created groups show up immediately. Co-authored-by: Cursor --- db.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/db.py b/db.py index db3d4bc..1766315 100644 --- a/db.py +++ b/db.py @@ -499,6 +499,20 @@ def list_goals_structured(db_path: Path | str = DEFAULT_DB) -> dict[str, Any]: if goal["completed_at"]: groups_map[gid]["completed"] += 1 + empty_groups = conn.execute( + "SELECT id, name FROM goal_groups ORDER BY created_at ASC, id ASC" + ).fetchall() + for row in empty_groups: + gid = row["id"] + if gid not in groups_map: + groups_map[gid] = { + "id": gid, + "name": row["name"], + "total": 0, + "completed": 0, + "goals": [], + } + conn.close() return { "groups": list(groups_map.values()),