From 55530b5a6fdca2f94b92ae805cca67d904881fb9 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 16 Nov 2026 18:30:16 +0000 Subject: [PATCH] fix: dashboard Recent lists a planned task once, not as row + draft recent_events promises one row per task, but a planned.md row and the draft its `prompt:` names were both listed. Keep the later-dated of the pair (a tie keeps the planned row); an undated planned row hides nothing. Closes #652 Co-Authored-By: Claude Opus 5.5 --- agents/conductors/intake/_intake.py | 17 +++++++++++- tests/test_intake_dashboard.py | 40 +++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/agents/conductors/intake/_intake.py b/agents/conductors/intake/_intake.py index 066b8312..75d96ce5 100755 --- a/agents/conductors/intake/_intake.py +++ b/agents/conductors/intake/_intake.py @@ -1521,8 +1521,20 @@ def recent_events(c: dict, limit: int = RECENT_MAX) -> list: # almost none of what has been happening. Epic members stay out, as they do # in every pick list on the page: they are worked in order through their # epic, and a Recent row hands out a standalone the start-dev skill. + # A planned row and the draft its `prompt:` names are ONE task, so only + # the later-dated of the pair is listed (a tie keeps the planned row: the + # more specific event, with its own copy payload). An undated planned row + # is not listed, so it hides nothing. + planned_dates = {} + for e in c.get("planned") or []: + prompt = (e.get("prompt") or "").split() + if prompt and e.get("date"): + planned_dates[prompt[0]] = max(e["date"], planned_dates.get(prompt[0], "")) + record_dates = {r["path"]: r["date"] for r in c.get("records") or [] + if r.get("date") and not r.get("epic")} for r in c.get("records") or []: - if r.get("date") and not r.get("epic"): + if (r.get("date") and not r.get("epic") + and r["date"] > planned_dates.get(r["path"], "")): events.append({"date": r["date"], "event": "filed", "title": r["title"], "path": r["path"], "payload": f"Use the start-dev skill. {r['path']}"}) @@ -1535,6 +1547,9 @@ def recent_events(c: dict, limit: int = RECENT_MAX) -> list: "payload": _review_payload(r)}) for key, verb in (("planned", "start"),): for e in c.get(key) or []: + prompt = (e.get("prompt") or "").split() + if prompt and record_dates.get(prompt[0], "") > (e.get("date") or ""): + continue if e.get("date"): events.append({"date": e["date"], "event": e.get("event") or key, diff --git a/tests/test_intake_dashboard.py b/tests/test_intake_dashboard.py index 0f5c711c..91671f5f 100644 --- a/tests/test_intake_dashboard.py +++ b/tests/test_intake_dashboard.py @@ -683,6 +683,46 @@ def test_recent_names_the_event_each_date_records(tmp_path): } +def _planned_with_draft(root, planned_date, filed_date): + """A Mind whose planned row names a dated draft as its `prompt:`.""" + draft = _prompt("Gearbox survey").replace( + "Status: formalised\n", f"Status: formalised\nFiled: {filed_date}\n") + planned = "# Planned\n\n## gearbox-survey\n" + if planned_date: + planned += f"- filed: {planned_date}\n" + planned += "- prompt: draft/feature/widgets/gearbox_survey.md\n" + return _mind(root, drafts={"feature/widgets/gearbox_survey.md": draft}, + registries={"planned.md": planned}) + + +def test_planned_row_and_its_draft_are_one_recent_row(tmp_path): + """`recent_events` promises one row per task. A planned row and the draft + its `prompt:` names are one task; listing both spent three of the fifty + feed rows on duplicates (PyAutoBrain#652).""" + rows = _intake.census(_planned_with_draft(tmp_path, "2026-08-12", + "2026-08-05"))["recent"] + assert [(r["date"], r["path"]) for r in rows] == [ + ("2026-08-12", "planned.md#gearbox-survey")] + + +def test_planned_draft_pair_keeps_the_later_date(tmp_path): + """A draft dated after its planned row is the newer event, so it is the + one row shown; a tie keeps the planned row.""" + rows = _intake.census(_planned_with_draft(tmp_path / "later", "2026-08-05", + "2026-08-12"))["recent"] + assert [(r["date"], r["path"]) for r in rows] == [ + ("2026-08-12", "draft/feature/widgets/gearbox_survey.md")] + rows = _intake.census(_planned_with_draft(tmp_path / "tie", "2026-08-12", + "2026-08-12"))["recent"] + assert [r["path"] for r in rows] == ["planned.md#gearbox-survey"] + + +def test_undated_planned_row_does_not_hide_its_draft(tmp_path): + """An undated planned row is not in the feed, so its draft must stay.""" + rows = _intake.census(_planned_with_draft(tmp_path, "", "2026-08-05"))["recent"] + assert [r["path"] for r in rows] == ["draft/feature/widgets/gearbox_survey.md"] + + def test_recent_is_newest_first(tmp_path): rows = _intake.census(_recent_mind(tmp_path))["recent"] assert [r["date"] for r in rows] == sorted(