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
26 changes: 16 additions & 10 deletions heart/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2250,7 +2250,7 @@ def _html_score(board: Board) -> str:


def _html_actions(board: Board) -> str:
plans = [("Fix Heart systematically", board.fix_plan or build_fix_plan(board))]
plans = []
if board.stale_plan:
plans.append(("Refresh all missing evidence", board.stale_plan))
rows = []
Expand Down Expand Up @@ -2351,22 +2351,33 @@ def _render_html(board: Board) -> str:
navigation = [
{"href": "#observed-checks", "label": "Observed checks"},
{"href": "#score-heading", "label": "Readiness and score"},
{"href": "#resusitate-heading", "label": "Resusitate"},
]
if board.stale_plan:
navigation.append({"href": "#resusitate-heading", "label": "Refresh evidence"})
navigation.extend(
{"href": f"#reasons-{severity}", "label": label,
"count": sum(b["severity"] == severity for b in board.blockers)}
for severity, label in (("red", "Release blockers"), ("yellow", "Warnings"), ("stale", "Evidence gaps"))
if any(b["severity"] == severity for b in board.blockers)
)
hero = t_.hero(BOARD_KEY, "Dashboard", _LEDE, navigation=navigation)
hero = t_.hero(BOARD_KEY, "Dashboard", navigation=navigation)
# The way back from the Pages board to the repository front door; owner
# from the declared config surface (REPO_OWNERS), so the segment drops
# out on a tenant whose config does not list this repo.
repo_name = PAGES_URL.rstrip("/").rsplit("/", 1)[-1]
gh_owner = REPO_OWNERS.get(repo_name)
github_link = (f' · <a href="https://github.com/{gh_owner}/{repo_name}'
'/blob/main/README.md">GitHub Page</a>' if gh_owner else "")
work_links = ([{"label": "Open Heart repository", "href":
f"https://github.com/{gh_owner}/{repo_name}"}] if gh_owner else [])
actions = _html_actions(board)
if board.stale_plan:
actions = ('<section aria-labelledby="resusitate-heading">'
'<h2 id="resusitate-heading">Refresh evidence</h2>' + actions + '</section>')
panel = t_.orchestration_panel(
"heart", "Fix Heart systematically", "",
(board.fix_plan or build_fix_plan(board))["prompt"],
work_links=work_links, copy_label="Fix Heart systematically")
return f"""<!doctype html>
<html lang="en"><head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
Expand All @@ -2375,8 +2386,8 @@ def _render_html(board: Board) -> str:
</head>
<body>
{hero}
{panel}
<h2 id="observed-checks">Observed checks</h2>
<p>Expand a check to see its entries. Colours describe observations; the release verdict below determines readiness.</p>
<div class="board">{''.join(rows)}</div>
<section aria-labelledby="score-heading">
<h2 id="score-heading">Score</h2>
Expand All @@ -2393,14 +2404,9 @@ def _render_html(board: Board) -> str:
<p class="reason-counts">{len(board.red_reasons)} release blockers ·
{len(board.yellow_reasons)} warnings · {len(board.stale_reasons)} evidence gaps</p>
</section>
<section aria-labelledby="resusitate-heading">
<h2 id="resusitate-heading">Resusitate</h2>
{_html_actions(board)}
</section>
{actions}
{reasons_html}
{_boards_nav_html()}
<footer>Copy a prompt into your coding chat, or a command into your terminal.
Copying does not run a check or change any files.</footer>
<script>{t_.JS}</script><script>{_COPY_JS}</script>
</body></html>
"""
Expand Down
20 changes: 13 additions & 7 deletions tests/test_dashboard_disclosures.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ def test_timing_cards_are_inside_category_and_checks_precede_score_actions_gaps(
assert list(timing.find(cls='timing-card'))
assert all('timing-card' not in n.attrs.get('class', '')
for c in checks for n in next(c.find('summary')).find())
assert (html.index('<div class="board">') < html.index('Release readiness score:') <
html.index('Fix Heart systematically') < html.index('Evidence gaps ('))
assert (html.index('Fix Heart systematically') < html.index('<div class="board">') <
html.index('Release readiness score:') < html.index('Evidence gaps ('))
assert '[these guys are giving me life]' not in html


Expand All @@ -132,7 +132,7 @@ def test_score_and_resusitate_sections_keep_breakdown_and_readiness():
('validation_absent', 15)]]
root = Page(dashboard._render_html(board)).root
headings = [h.text() for h in root.find('h2')]
assert headings == ['Observed checks', 'Score', 'Resusitate', 'Evidence gaps (3)']
assert headings == ['Fix Heart systematically', 'Observed checks', 'Score', 'Evidence gaps (3)']
score = next(s for s in root.find('section')
if s.attrs.get('aria-labelledby') == 'score-heading')
assert '65/100' in score.text() and 'Release readiness: STALE' in score.text()
Expand All @@ -151,10 +151,16 @@ def test_repair_rows_copy_exact_prompts_without_toggling_prompt_disclosures():
stale_details=[{'key': 'install_unknown'}] if stale else [])
board = dashboard.build_board(make_snapshot(), verdict, now=FRESH_NOW)
root = Page(dashboard._render_html(board)).root
section = next(s for s in root.find('section')
if s.attrs.get('aria-labelledby') == 'resusitate-heading')
section = (next(s for s in root.find('section')
if s.attrs.get('aria-labelledby') == 'resusitate-heading')
if stale else root)
rows = list(section.find(cls='repair-row'))
plans = [board.fix_plan] + ([board.stale_plan] if stale else [])
plans = [board.stale_plan] if stale else []
panel = next(root.find(cls="orchestration-panel"))
preview = list(panel.find("textarea"))[-1]
assert preview.text().startswith(board.fix_plan["prompt"])
assert "Work on GitHub:" in preview.text()
assert len(list(panel.find("button"))) == 1
assert len(rows) == len(plans)
for row, plan in zip(rows, plans):
details = next(row.find('details'))
Expand All @@ -166,4 +172,4 @@ def test_repair_rows_copy_exact_prompts_without_toggling_prompt_disclosures():
assert button.attrs['data-cmd'] == plan['prompt']
assert next(details.find('pre')).text() == plan['prompt']
assert button.text() == '' and list(button.find('svg'))
assert next(section.find('p')).attrs['aria-live'] == 'polite'
assert any(p.attrs.get('aria-live') == 'polite' for p in section.find('p'))
Loading