Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion agents/conductors/intake/_intake.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']}"})
Expand All @@ -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,
Expand Down
40 changes: 40 additions & 0 deletions tests/test_intake_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading