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
Binary file modified docs/assets/screenshot-connect-dark.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/screenshot-connect.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/screenshot-findings-dark.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/screenshot-findings.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/screenshot-loop-dark.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/screenshot-loop.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/screenshot-overview-dark.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/screenshot-overview.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/screenshot-rounds-dark.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/screenshot-rounds.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/screenshot-waiting-dark.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/screenshot-waiting.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/loopcaptain/board/static/mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
258 changes: 205 additions & 53 deletions src/loopcaptain/board/static/style.css

Large diffs are not rendered by default.

17 changes: 5 additions & 12 deletions src/loopcaptain/board/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!doctype html>
<html lang="en">
<html lang="en" data-board="monitoring">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light dark">
{% set t = totals() %}
{% set t = totals() %}{% from "totals.html" import totals_line with context %}
<title>{% if t and t.waiting %}({{ t.waiting }}) {% endif %}Loopcaptain{% set part %}{% block title %}{% endblock %}{% endset %}{% if part|trim %} · {{ part|trim }}{% endif %}</title>
<link rel="icon" type="image/svg+xml" href="{{ url_for('static', path='mark.svg') }}">
<link rel="preload" href="{{ url_for('static', path='fonts/inter-latin-wght-normal.woff2') }}" as="font" type="font/woff2" crossorigin>
Expand All @@ -13,16 +13,9 @@
</head>
<body{% block body_attrs %}{% endblock %}>
<header class="top">
<a class="brand" href="{{ url_for('overview') }}" aria-label="Loopcaptain, all loops"><img src="{{ url_for('static', path='mark.svg') }}" alt="" width="28" height="28"><span>L<span class="oo">oo</span>pcaptain</span></a>
{% if t and t.loops %}{% set home = url_for('overview') %}
<nav class="kpis" aria-label="Totals">
<a href="{{ home }}" class="kpi"><b>{{ t.loops }}</b><span title="in {{ t.projects }} project{{ 's' if t.projects != 1 }}">loop{{ 's' if t.loops != 1 }}</span></a>
<a href="{{ home }}?tab=waiting" class="kpi{{ ' hot' if t.waiting }}"{% if page == 'overview' and tab == 'waiting' %} aria-current="page"{% endif %}><b>{{ t.waiting }}</b><span>waiting for you</span></a>
<a href="{{ home }}?show=running" class="kpi{{ ' live' if t.running }}"><b>{{ t.running }}</b><span>running</span></a>
<a href="{{ home }}?show=look" class="kpi{{ ' alarm' if t.troubled }}" title="stalled, failed or capped, or going round without progress"><b>{{ t.troubled }}</b><span>need{{ 's' if t.troubled == 1 }} a look</span></a>
<span class="kpi" title="the reported cost of all rounds"><b>{{ t.usd|usd or '$0' }}</b><span>spent</span></span>
</nav>
{% else %}<span class="where">{% block where %}{% endblock %}</span>{% endif %}
<a class="brand" href="{{ url_for('overview') }}" aria-label="Loopcaptain, all loops"><img src="{{ url_for('static', path='mark.svg') }}" alt="" width="32" height="32"><span class="words"><span class="board">the agent loops on this machine</span><span>L<span class="oo">oo</span>pcaptain</span></span></a>
<span class="where">{% block where %}{% endblock %}</span>
{{ totals_line() }}
<nav class="strip" aria-label="Pages">
<a href="{{ url_for('overview') }}"{% if page == 'overview' and tab != 'waiting' %} aria-current="page"{% elif page == 'loop' %} aria-current="true"{% endif %}>Loops</a>
<a href="{{ url_for('connect') }}"{% if page == 'connect' %} aria-current="page"{% endif %}>Connect a loop</a>
Expand Down
5 changes: 4 additions & 1 deletion src/loopcaptain/board/templates/connect.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
{% set page = 'connect' %}
{% block title %}Connect a loop{% endblock %}
{% block main %}
<h1>Connect a loop</h1>
<div class="head">
<p class="eyebrow">Connect · Three ways</p>
<h1 class="title">How a <span class="em">loop</span> shows up on this board</h1>
<p class="lede">Pick the way that fits. Each takes a few minutes, and you do not need to read anything else on this page.</p>
</div>

<section class="ways" aria-label="Ways to connect a loop">
<div class="card way first">
Expand Down
6 changes: 3 additions & 3 deletions src/loopcaptain/board/templates/loop.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'verdict': '<path d="M2.5 11V1.5h7l-1.6 2.6 1.6 2.6h-7"/>',
} %}{{ (paths.get(kind) or '<circle cx="6" cy="6" r="2.6"/>')|safe }}{% endmacro %}
{% block main %}
<p class="crumb"><a href="{{ url_for('overview') }}">Loops</a> / {{ view.repo.key }} / {{ view.loop_id }}</p>
<p class="crumb eyebrow"><a href="{{ url_for('overview') }}">Loops</a> / {{ view.repo.key }} / {{ view.loop_id }}</p>
<h1>{{ view.title }}</h1>
<p class="meta"><span class="pill {{ state.status }}">{{ state.status }}</span><span>{{ 'went quiet between rounds, past the time it said it would be back' if state.status == 'stalled' and state.rounds and not state.rounds[-1].running else status_text[state.status] }}</span>{% if state.last_event %}<span>last line {{ state.last_event|ago }}</span>{% endif %}{% if branch %}<span>branch <code>{{ branch }}</code></span>{% endif %}{% if view.repo.others %}<span title="{% for other in view.repo.others %}{{ other|place }}{% if not loop.last %}, {% endif %}{% endfor %}">written from <code>{{ view.repo.path|place }}</code>, the latest of {{ view.repo.others|length + 1 }} worktrees</span>{% endif %}{% if manifest.pace %}<span>{{ manifest.pace }}</span>{% endif %}{% if state.status == 'sleeping' and state.expected %}<span>back at {{ state.expected|stamp }}</span>{% endif %}{% if state.ended %}<span>ended between rounds: {{ state.ended.stop_reason|replace('_', ' ') }}{% if state.ended.summary %}, {{ state.ended.summary }}{% endif %}</span>{% endif %}</p>
{% if note %}<p class="flash" role="status">{{ note }}</p>{% endif %}
Expand Down Expand Up @@ -325,8 +325,8 @@ <h2>What the loop evaluates<small>each cell is the latest check of that kind; a
<h2>Convergence<small>per finished round{% if state.rounds|length > chart_rounds %}, the last {{ chart_rounds }}{% endif %}; point at a round to read it, click to open it{% if charts|selectattr('target_y', 'ne', none)|list %}; dashed: the loop's target{% endif %}</small></h2>
<section class="trends">
{% for c in charts %}
<figure class="card trend {{ c.tone }}">
<figcaption><span class="eyebrow">{{ c.series.label }}</span><b>{{ c.last|figure(c.series.unit) }}</b>{% if c.met is true %}<span class="flag">on target</span>{% elif c.left %}<span class="flag">{{ c.left }}</span>{% elif c.met is false %}<span class="flag">target {{ c.series.target|figure(c.series.unit) }}</span>{% endif %}</figcaption>
<figure class="card trend {{ c.tone }}{{ ' worse' if c.direction in ('rising', 'falling') }}">
<figcaption><span class="eyebrow">{{ c.series.label }}</span><b>{{ c.last|figure(c.series.unit) }}</b>{% if c.direction and c.met is not true %}<span class="flag way">{{ c.direction }}</span>{% endif %}{% if c.met is true %}<span class="flag">on target</span>{% elif c.left %}<span class="flag">{{ c.left }}</span>{% elif c.met is false %}<span class="flag">target {{ c.series.target|figure(c.series.unit) }}</span>{% endif %}</figcaption>
{% if c.series.about or c.series.file %}<p class="about">{{ c.series.about }}{% if c.series.file %} {{ file_link(c.series.file, 'the list') }}{% endif %}</p>{% endif %}
<svg viewBox="0 0 {{ c.width }} {{ c.height }}" role="group" aria-label="{{ c.series.label }} per round">
{% if c.target_y is not none %}<line class="target" x1="0" x2="{{ c.width }}" y1="{{ c.target_y }}" y2="{{ c.target_y }}"/>{% endif %}
Expand Down
16 changes: 10 additions & 6 deletions src/loopcaptain/board/templates/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
{% set page = 'overview' %}
{% block title %}{{ 'Waiting for you' if tab == 'waiting' else '' }}{% endblock %}
{% block body_attrs %} data-pulse-url="{{ url_for('overview_pulse') }}" data-pulse="{{ pulse }}"{% if turn_at %} data-turn-at="{{ turn_at }}"{% endif %}{% endblock %}
{% macro project_head(project) %}<span class="name"{% if not project.worktree %} title="{{ project.place }}"{% endif %}>{{ project.name or project.repo.key }}</span>{% if project.worktree %}<span class="wt" title="a worktree of {{ project.name }}, at {{ project.place }}">worktree {{ project.worktree }}</span>{% endif %}{% if project.branch %}<code class="branch">{{ project.branch }}</code>{% endif %}<span class="count">{{ project.views|length }} loop{{ 's' if project.views|length != 1 }}</span>{% if project.waiting %}<a class="waits" href="{{ here }}?tab=waiting">{{ project.waiting }} wait{{ 's' if project.waiting == 1 }} for you</a>{% endif %}{% endmacro %}
{% macro loop_row(view) %}
{% macro project_head(project) %}<span class="name"{% if not project.worktree %} title="{{ project.place }}"{% endif %}>{{ project.name or project.repo.key }}</span>{% if project.worktree and project.worktree != project.branch %}<span class="wt" title="a worktree of {{ project.name }}, at {{ project.place }}">worktree {{ project.worktree }}</span>{% endif %}{% if project.branch %}<code class="branch">{{ project.branch }}</code>{% endif %}<span class="count">{{ project.views|length }} loop{{ 's' if project.views|length != 1 }}</span>{% if project.waiting %}<a class="waits" href="{{ here }}?tab=waiting">{{ project.waiting }} wait{{ 's' if project.waiting == 1 }} for you</a>{% endif %}{% endmacro %}
{% macro loop_row(view, project_branch=none) %}
<tr class="is-{{ view.state.status if view.state else 'failed' }}">
<td class="name"><a href="{{ url_for('loop_page', repo_key=view.repo.key, loop_id=view.loop_id) }}">{{ view.title }}</a><span class="id">{{ view.loop_id }}</span></td>
<td class="name"><a href="{{ url_for('loop_page', repo_key=view.repo.key, loop_id=view.loop_id) }}">{{ view.title }}</a>{% set ws = view.state.manifest.workspace if view.state else none %}{% set branch = (ws.branch if ws and ws.branch else none) or project_branch %}{% if branch %}<span class="id" title="loop {{ view.loop_id }}"><code>{{ branch }}</code></span>{% else %}<span class="id">{{ view.loop_id }}</span>{% endif %}</td>
{% if view.state %}
{% set s = view.state %}
<td><span class="pill {{ s.status }}" title="{{ status_text[s.status] }}">{{ s.status }}</span>{% if group_of(view) == 'old' %}<span class="old" title="no line for over two weeks: listed, and no longer counted as needing a look">old</span>{% endif %}{% if s.question and s.status != 'waiting' %}<span class="asks" title="it has a question for you">asks</span>{% endif %}{% set signs = no_progress(s) %}{% if signs %}<span class="stuck" title="{{ signs|join('; ') }}">no progress</span>{% endif %}</td>
Expand All @@ -27,7 +27,11 @@
</tr></thead>{% endmacro %}
{% macro cols() %}<colgroup><col class="c-loop"><col class="c-status"><col class="c-goal"><col class="c-rounds"><col class="c-n"><col class="c-n"><col class="c-n"><col class="c-last"><col class="c-go"></colgroup>{% endmacro %}
{% block main %}
<h1 class="sr">{{ 'Waiting for you' if tab == 'waiting' else 'Loops' }}</h1>
{% set t = totals() %}<div class="head">
<p class="eyebrow">Loops · {{ 'Waiting for you' if tab == 'waiting' else 'All projects' }}</p>
<h1 class="title">{% if tab == 'waiting' %}Which <span class="em">loops</span> wait for your answer{% else %}Which <span class="em">loops</span> wait for you, and how the rest are going{% endif %}</h1>
{% if t and t.loops %}<p class="points"><span>{{ t.loops }} loop{{ 's' if t.loops != 1 }} in {{ t.projects }} project{{ 's' if t.projects != 1 }}</span><span>{{ t.usd|usd or '$0' }} spent on all rounds</span><span>read fresh from each <code>.loops/</code> folder</span></p>{% endif %}
</div>
{% if note %}<p class="flash" role="status">{{ note }}</p>{% endif %}
{% if error %}<p class="flash bad" role="alert">{{ error }}</p>{% endif %}
{% if repeated %}<p class="flash warn" role="status">Two watched repositories have a loop with the same id: {% for loop_id, keys in repeated.items() %}<code>{{ loop_id }}</code> in {{ keys[:-1]|join(', ') }} and {{ keys[-1] }}{{ '; ' if not loop.last }}{% endfor %}. Check you are answering the right one.</p>{% endif %}
Expand All @@ -50,7 +54,7 @@ <h1 class="sr">{{ 'Waiting for you' if tab == 'waiting' else 'Loops' }}</h1>
{% for project in waiting_projects %}
<div class="project card flush">
<div class="summary project">{{ project_head(project) }}</div>
<table class="loops">{{ cols() }}{{ head_row(false) }}<tbody>{% for view in project.views %}{{ loop_row(view) }}{% endfor %}</tbody></table>
<table class="loops">{{ cols() }}{{ head_row(false) }}<tbody>{% for view in project.views %}{{ loop_row(view, project.branch) }}{% endfor %}</tbody></table>
{% for view in project.views %}
<section class="ask inline" aria-label="Question from {{ view.title }}">
{% set q = view.state.question %}
Expand Down Expand Up @@ -106,7 +110,7 @@ <h1 class="sr">{{ 'Waiting for you' if tab == 'waiting' else 'Loops' }}</h1>
{{ head_row(loop.first) }}
<tbody>
<tr class="project"><th scope="rowgroup" colspan="9" class="sr">Project {{ project.repo.key }} · {{ project.place }} · {{ project.views|length }} loop{{ 's' if project.views|length != 1 }}</th></tr>
{% for view in project.views %}{{ loop_row(view) }}
{% for view in project.views %}{{ loop_row(view, project.branch) }}
{% endfor %}
</tbody>
</table>
Expand Down
11 changes: 11 additions & 0 deletions src/loopcaptain/board/templates/totals.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{# The board's figures, one line of links in the middle of the header on every page. #}
{% macro totals_line() %}{% set t = totals() %} {% if t and t.loops %}{% set home = url_for('overview') %}
<nav class="kpis" aria-label="Totals">
<a href="{{ home }}" class="kpi"><b>{{ t.loops }}</b><span title="in {{ t.projects }} project{{ 's' if t.projects != 1 }}">loop{{ 's' if t.loops != 1 }}</span></a>
<a href="{{ home }}?tab=waiting" class="kpi{{ ' hot' if t.waiting }}"{% if page == 'overview' and tab == 'waiting' %} aria-current="page"{% endif %}><b>{{ t.waiting }}</b><span>waiting for you</span></a>
<a href="{{ home }}?show=running" class="kpi{{ ' live' if t.running }}"><b>{{ t.running }}</b><span>running</span></a>
<a href="{{ home }}?show=look" class="kpi{{ ' alarm' if t.troubled }}" title="stalled, failed or capped, or going round without progress"><b>{{ t.troubled }}</b><span>need{{ 's' if t.troubled == 1 }} a look</span></a>
<span class="kpi" title="the reported cost of all rounds"><b>{{ t.usd|usd or '$0' }}</b><span>spent</span></span>
</nav>
{% endif %}
{% endmacro %}
15 changes: 14 additions & 1 deletion src/loopcaptain/board/trend.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,20 @@ def tone(self) -> str:
return "short"
if self.improving is True:
return "good" if self.met is None else "short"
return "short" if self.met is False else "plain"
return "short" if self.met is False or self.direction else "plain"

@property
def direction(self) -> str:
"""In one or two words whether the measure converges, where the loop says which way is
better: "converging" when it got better, "not converging" when it stayed, else the way it
went the wrong way ("rising" for a measure that should fall). "" without a direction."""
if self.series.better is None or len(self.series.values) < 2:
return ""
if self.improving is None:
return "not converging"
if self.improving:
return "converging"
return "rising" if self.series.better == "lower" else "falling"

@property
def area(self) -> str:
Expand Down
25 changes: 25 additions & 0 deletions tests/test_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,31 @@ def test_overview_groups_the_loops_under_the_project_they_live_in(client: TestCl
assert '<span class="id">scan</span>' in page


def test_every_page_carries_the_figures_in_its_header_and_the_overview_head_does_not_repeat_them(
client: TestClient,
) -> None:
for path in ("/", "/loop/some-repo/scan", "/connect"):
header = client.get(path).text.split('<header class="top">', 1)[1].split("</header>", 1)[0]
assert '<nav class="kpis" aria-label="Totals">' in header, path

page = client.get("/").text
head = page.split('<div class="head">', 1)[1].split("</div>", 1)[0]
assert 'class="kpi' not in head and "waiting for you" not in head and "1 loop in 1 project" in head


def test_a_loop_row_shows_the_branch_it_runs_on_and_keeps_its_id_for_hover(
client: TestClient, scan: Path, helper: types.ModuleType
) -> None:
helper.register(
"side", {"title": "Side task", "steps": STEPS, "workspace": {"branch": "loop/side"}}, scan
)

page = client.get("/").text

assert '<span class="id" title="loop side"><code>loop/side</code></span>' in page
assert '<span class="id">scan</span>' in page # no branch known: the id stands in


def test_the_repository_line_names_the_folder_once_and_keeps_the_path_for_hover(
client: TestClient, scan: Path
) -> None:
Expand Down
8 changes: 8 additions & 0 deletions tests/test_look.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,11 @@ def test_the_two_os_of_the_name_are_the_marks_lenses_in_red() -> None:
f'L<tspan fill="{red}">oo</tspan>pcaptain'
in (ROOT / "docs/assets" / f"banner-{theme}.svg").read_text()
)


def test_a_step_that_finished_well_is_green_and_one_that_runs_is_blue() -> None:
sheet = STYLE.read_text(encoding="utf-8")
light, dark = sheet.split("@media (prefers-color-scheme: dark)", 1)

assert "--ok-mark: #1E8E5A;" in light and "--run-mark: #2563A8;" in light
assert "--ok-mark: #5CC98F;" in dark and "--run-mark: #7DB3EE;" in dark
12 changes: 12 additions & 0 deletions tests/test_page_reads.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,15 @@ def test_a_unit_that_only_looks_like_a_whole_does_not_break_the_page() -> None:
odd = chart(Series("score", ((1, 1.0),), "of ,", better="higher"))

assert odd.left == ""


def test_a_chart_says_in_a_word_whether_the_measure_converges() -> None:
falling = chart(Series("open_findings", ((1, 7.0), (2, 4.0), (3, 2.0)), better="lower"))
flat = chart(Series("open_findings", ((1, 3.0), (2, 3.0)), better="lower"))
rising = chart(Series("open_findings", ((1, 2.0), (2, 5.0)), better="lower"))
cost = chart(Series("cost", ((1, 2.0), (2, 1.0)), "$"))

assert (falling.direction, falling.tone) == ("converging", "good")
assert (flat.direction, flat.tone) == ("not converging", "short")
assert (rising.direction, rising.tone) == ("rising", "short")
assert (cost.direction, cost.tone) == ("", "plain")
Loading