From ad4a8da2c2b2d159ea5f861ed9c7eb187d032244 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Fri, 4 Sep 2026 12:33:41 -0400 Subject: [PATCH] feat(board): the footer reads the canonical board family, not a tuple in here MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `BOARD_FAMILY` was written before the Cortex had a board, so this page's footer linked five siblings in an ad-hoc order and silently missed the sixth. Membership and order are not this file's to decide: they live once, in the Brain's `config/policy.yaml` `board: boards:`, and the shared theme now offers `board_links` as the one read of it. The tuple stays as the fallback for an older PyAutoBrain checkout whose theme predates the helper, and stays deliberately the OLD list — a fallback that guessed at the current one would drift exactly the way this one did. tests/test_dashboard.py pins the canonical chip order, that the page never links itself, and that the fallback still renders a footer. Refs #199 Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01GnXNPigN6qWxLZy2cqhDBX --- heart/dashboard.py | 23 ++++++++++++++++----- tests/test_dashboard.py | 46 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/heart/dashboard.py b/heart/dashboard.py index ceda7397..7bc8f71d 100644 --- a/heart/dashboard.py +++ b/heart/dashboard.py @@ -193,8 +193,17 @@ def theme(): "— check PyAutoBrain out beside this repo or set PYAUTO_BRAIN") # The one-tap board family — the cross-board footer nav every board carries, -# each board skipping its own entry. The base comes from PAGES_URL so the -# owner is named exactly once in this file. +# each board skipping its own entry. +# +# Membership and order are NOT decided here: they live once, in the Brain's +# `config/policy.yaml` `board: boards:`, and `_theme.board_links` is the read. +# This file used to keep its own tuple, written before the Cortex had a board +# — so this footer was short a chip and out of the family's order, and nothing +# noticed. The tuple below survives only as the fallback for an older +# PyAutoBrain checkout whose theme predates the helper; it is deliberately the +# old list, because a fallback that guessed at the current one would drift the +# same way. The base comes from PAGES_URL so the owner is named exactly once +# in this file. BOARD_FAMILY = (("mind", "PyAutoMind"), ("brain", "PyAutoBrain"), ("hands", "PyAutoHands"), ("memory", "PyAutoMemory"), ("organism", "PyAutoScientist")) @@ -202,10 +211,14 @@ def theme(): def _boards_nav_html() -> str: """The cross-board footer — one chip per sibling, each in its own organ's - colour (the theme owns the chip palette; this board owns the URLs).""" + colour (the theme owns the chip palette AND the family's membership; this + board owns only which page it is).""" + t_ = theme() base = PAGES_URL.rsplit("/", 2)[0] - links = {key: f"{base}/{repo}/" for key, repo in BOARD_FAMILY} - return theme().boards_footer(links, BOARD_KEY) + links = getattr(t_, "board_links", None) + links = (links(base, BOARD_KEY) if links else + {key: f"{base}/{repo}/" for key, repo in BOARD_FAMILY}) + return t_.boards_footer(links, BOARD_KEY) # v2: sections gained links/action/observed_ago; the board gained structured # `blockers` ({text, severity, repo, repo_url, run_url, prompt}). Additive. diff --git a/tests/test_dashboard.py b/tests/test_dashboard.py index 4a3cdec5..aadbf8b5 100644 --- a/tests/test_dashboard.py +++ b/tests/test_dashboard.py @@ -849,6 +849,52 @@ def test_html_wears_the_shared_family_theme(): assert "#58a6ff" not in out # the old hard-coded GitHub blue +# The canonical board family, in the order `PyAutoBrain/config/policy.yaml` +# declares it. This board is `heart`, so its own chip never appears. +FAMILY_WITHOUT_HEART = ["brain", "mind", "cortex", "memory", "hands", "organism"] + + +def test_the_family_footer_carries_the_cortex_in_the_canonical_order(): + """The footer's membership is the Brain's config, not a tuple in here. + + It used to be a tuple in here — written before the Cortex had a board — + so this page linked five siblings in an ad-hoc order and silently missed + the sixth. Reading `_theme.board_links` means adding a board to + `config/policy.yaml` lights it in every footer at once. + """ + out = dashboard.render(_failing_snapshot(), make_verdict("red", 45), + fmt="html", now=FRESH_NOW) + footer = re.search(r'', out, re.S).group(0) + assert re.findall(r'data-organ="(\w+)"', footer) == FAMILY_WITHOUT_HEART + assert "PyAutoCortex" in footer + + +def test_the_footer_never_links_the_page_it_is_on(): + out = dashboard.render(_failing_snapshot(), make_verdict("red", 45), + fmt="html", now=FRESH_NOW) + footer = re.search(r'', out, re.S).group(0) + assert f'data-organ="{dashboard.BOARD_KEY}"' not in footer + + +def test_the_footer_falls_back_when_the_brain_checkout_predates_the_helper(): + """An older PyAutoBrain beside this repo has no `board_links`. The page + must still render its footer — from the legacy tuple — rather than crash + the whole board over a nav strip.""" + class _Older: + def __init__(self, real): + self.boards_footer = real.boards_footer + + real = dashboard.theme() + nav = dashboard._boards_nav_html.__globals__["theme"] + dashboard._boards_nav_html.__globals__["theme"] = lambda: _Older(real) + try: + footer = dashboard._boards_nav_html() + finally: + dashboard._boards_nav_html.__globals__["theme"] = nav + assert re.findall(r'data-organ="(\w+)"', footer) == [ + k for k, _ in dashboard.BOARD_FAMILY] + + def test_a_long_out_link_label_cannot_push_the_page_sideways(): """The out-links carry DATA in their labels (` run`), and this org's longest repo name is 36 characters. Under `white-space:nowrap` that was a