From 1c0b538b081d64203f781faa1afcc14398b8c8ea Mon Sep 17 00:00:00 2001 From: Etienne Filhol Date: Tue, 24 Nov 2026 10:07:25 +0100 Subject: [PATCH 1/2] fix(runs): switch from launch logs to live without reloading --- app/nullius/execution.py | 8 +-- app/nullius/progress.py | 6 +- app/static/runs/live-board.css | 4 +- app/static/runs/live-board.js | 37 +++++++++-- app/static/traces/conversation.css | 14 +--- app/templates/runs/_execution.html | 13 ++-- app/templates/runs/_live_board.html | 27 ++++++++ app/templates/runs/job.html | 60 +++++------------- app/templates/runs/preparing.html | 14 +++- app/templates/traces/_head.html | 30 --------- app/templates/traces/attempts.html | 4 +- app/templates/traces/trial.html | 11 +--- app/tests/test_execution.py | 3 +- app/tests/test_progress.py | 15 +++++ app/ui_tests/evidence/run-logs/task-after.png | Bin 0 -> 192827 bytes .../evidence/run-logs/task-before.png | Bin 0 -> 30085 bytes app/ui_tests/test_attempt_routes.py | 5 +- app/ui_tests/test_live_board.py | 24 ++++++- app/ui_tests/test_run_routes.py | 16 ++--- app/ui_tests/test_trial_head.py | 33 +++++----- app/web/runs.py | 23 +++---- 21 files changed, 186 insertions(+), 161 deletions(-) create mode 100644 app/templates/runs/_live_board.html delete mode 100644 app/templates/traces/_head.html create mode 100644 app/ui_tests/evidence/run-logs/task-after.png create mode 100644 app/ui_tests/evidence/run-logs/task-before.png diff --git a/app/nullius/execution.py b/app/nullius/execution.py index aa4d58d3..a38aca32 100644 --- a/app/nullius/execution.py +++ b/app/nullius/execution.py @@ -633,13 +633,13 @@ def summary(self) -> dict: def stages(self) -> dict: """The stages said so far, folded for the page (``progress.fold``). - Once the run has failed or been stopped, a stage still running was - cut short by it, and nothing is waiting any more.""" + Once the run has ended, no stage is running or waiting any more. + Counts remain exactly what the progress events reported.""" with self._lock: events = list(self.events) got = progress.fold(events) - if self.state in ("failed", "stopped"): - got["stages"] = [dict(r, state="failed") if r["state"] == "running" else r for r in got["stages"] if r["state"] != "waiting"] + if self.state in ("done", "failed", "stopped"): + got["stages"] = [dict(r, state="done" if self.state == "done" else "failed") if r["state"] == "running" else r for r in got["stages"] if r["state"] != "waiting"] got["current"] = None return got diff --git a/app/nullius/progress.py b/app/nullius/progress.py index bdfcb477..1208bb1f 100644 --- a/app/nullius/progress.py +++ b/app/nullius/progress.py @@ -271,6 +271,10 @@ def fold(events: Iterable[dict]) -> dict: stages[key]["key"] = key stages.setdefault(key, {"key": key, "stage": st, "label": label(ev), "state": "waiting"}) row = stages[key] + if state == "start": + # A later part or retry starts this stage afresh. + for field in ("seconds", "bytes", "total", "detail"): + row.pop(field, None) row["label"] = label(ev) if ev.get("detail") is not None: row["detail"] = ev["detail"] @@ -295,7 +299,7 @@ def fold(events: Iterable[dict]) -> dict: last = seen[-1] if seen else -1 rows = [r for i, r in enumerate(rows) if r["state"] != "waiting" or i > last] if ended: # a run that ended has nothing running, nor anything still to come - rows = [dict(r, state="failed") if r["state"] == "running" and ended == "refused" else r + rows = [dict(r, state="failed" if ended == "refused" else "done") if r["state"] == "running" else r for r in rows if r["state"] != "waiting"] current = next((r for r in rows if r["state"] == "running"), None) return {"stages": rows, "units": units, "current": current["key"] if current else None, "ended": ended, "detail": detail} diff --git a/app/static/runs/live-board.css b/app/static/runs/live-board.css index 0f870e07..b8da7721 100644 --- a/app/static/runs/live-board.css +++ b/app/static/runs/live-board.css @@ -1,4 +1,4 @@ -/* The job page's two views, and the Live board. +/* The job page's views, and the Live board. Scoped to .lb; the phase and outcome hues are the app's own. */ /* ---- the two views ---- */ @@ -183,3 +183,5 @@ .lb-open-row:hover { text-decoration: underline; } /* the board counts the trials itself: the run strip's own task bar would say it twice */ body:has(#live-board) #execution-units { display: none; } + +.view-tabs [role="tab"]:disabled { color: var(--text-faint); cursor: default; } diff --git a/app/static/runs/live-board.js b/app/static/runs/live-board.js index f6a997bf..b7a9d787 100644 --- a/app/static/runs/live-board.js +++ b/app/static/runs/live-board.js @@ -307,8 +307,20 @@ let snap = null, timer = null, misses = 0; // opened while the run was going: the Results rendered with the page are older than its end const startedLive = board.dataset.state !== 'finished'; + let waiting = board.dataset.state === 'unknown'; function paint() { - if (!snap) return; + if (!snap || stateOf(snap) === 'unknown') return; + if (waiting) { + waiting = false; + doc.getElementById('preparing')?.remove(); + const liveTab = doc.getElementById('tab-live'); + if (liveTab) liveTab.disabled = false; + const resultsTab = doc.getElementById('tab-results'); + if (resultsTab) resultsTab.disabled = false; + const dot = doc.getElementById('live-dot'); + if (dot) dot.classList.toggle('on', stateOf(snap) !== 'finished'); + doc.dispatchEvent(new Event('live-ready')); + } const out = render(snap, opts); board.dataset.state = out.state; $('[data-lb-state]').textContent = out.stateLabel; @@ -338,8 +350,18 @@ async function tick() { try { const r = await nulliusFetch(endpoint, {headers: {'Accept': 'application/json'}, cache: 'no-store'}); - if (!r.ok) throw new Error('HTTP ' + r.status); - misses = 0; snap = await r.json(); + if (!r.ok) { + if (waiting && doc.getElementById('execution')?.dataset.live === 'no') { clearInterval(timer); timer = null; } + throw new Error('HTTP ' + r.status); + } + const next = await r.json(); + if (waiting && (next.state === 'unknown' || !next.counts)) { + if (next.state === 'finished' || doc.getElementById('execution')?.dataset.live === 'no') { + clearInterval(timer); timer = null; + } + return; + } + misses = 0; snap = next; } catch (e) { misses += 1; } paint(); } @@ -360,7 +382,7 @@ paint(); if (!snap || stateOf(snap) !== 'finished') { timer = setInterval(tick, 1000); tick(); } } - // The two views of the job page: switched in place, kept in the address as ?view=. + // The views of the job page: switched in place, kept in the address as ?view=. function mountTabs(doc) { const tabs = Array.from(doc.querySelectorAll('[data-view-tab]')); if (!tabs.length) return; @@ -376,11 +398,14 @@ if (view === 'results' && badge && badge.dataset.stale) { location.assign(u); return; } history.replaceState(null, '', u); } - tabs.forEach((t, i) => { + doc.addEventListener('live-ready', () => { + if (!new URL(location.href).searchParams.has('view')) show('live'); + }); + tabs.forEach(t => { t.addEventListener('click', () => show(t.dataset.viewTab)); t.addEventListener('keydown', e => { const d = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : 0; - if (d) { e.preventDefault(); const n = tabs[(i + d + tabs.length) % tabs.length]; n.focus(); show(n.dataset.viewTab); } + if (d) { e.preventDefault(); const enabled = tabs.filter(t => !t.disabled); const i = enabled.indexOf(t); const n = enabled[(i + d + enabled.length) % enabled.length]; n.focus(); show(n.dataset.viewTab); } }); }); } diff --git a/app/static/traces/conversation.css b/app/static/traces/conversation.css index 69ae22b7..b141cf38 100644 --- a/app/static/traces/conversation.css +++ b/app/static/traces/conversation.css @@ -45,18 +45,10 @@ @media(max-width:850px){.reader-selected{padding:18px}.reader-layout{grid-template-columns:minmax(175px,30%) minmax(0,1fr)}.reader-step-nav{align-items:flex-start;flex-direction:column;gap:12px}} @media(max-width:600px){.reader-layout{grid-template-columns:minmax(0,1fr);min-height:0}.reader-index{border-right:0;border-bottom:1px solid var(--border)}.reader-rows{max-height:230px;overflow:auto}.reader-row{padding:10px 12px}.reader-row-preview{-webkit-line-clamp:1}.reader-selected{padding:16px}.reader-content pre{max-height:360px;padding:12px}.reader-search{gap:6px}.reader-toolbar{gap:10px}.reader-jump{width:100%}.reader-jump input{flex:1;min-width:0}.reader-content-nav{gap:6px;font-size:10px}.trial-tabs{gap:22px}.reader-filters{width:100%;justify-content:space-between}.reader-filters button{padding:7px 8px}} -/* the trial's head: what ran, then how it went, one row that wraps */ +/* The trial's own metrics, in a row that wraps. */ .trial-head{display:flex;flex-wrap:wrap;gap:10px;margin:14px 0 6px;align-items:stretch} -.th-card{display:flex;align-items:center;gap:12px;border:1px solid var(--border);border-radius:var(--radius);background:var(--surface);padding:9px 14px;min-width:0} -.th-card .k,.th-strip .k{display:block;color:var(--text-dim);font-size:.75rem} -.th-card .v{display:block;font-weight:500} -.th-sep{width:1px;align-self:stretch;background:var(--border)} -.th-mark{width:32px;height:32px;border-radius:8px;background:var(--accent-soft);color:var(--accent);display:grid;place-items:center;font:500 15px/1 var(--mono);flex:none;padding:6px} -.th-mark:has(.agent-logo){padding:4px;background:color-mix(in srgb,var(--text) 8%,transparent);color:var(--text)} -.th-model{display:block;font-size:.8rem;color:var(--text-dim);overflow-wrap:anywhere} -/* The cells keep their own width: the strip sits beside the cards while all of them fit on one - line, moves under the cards when they do not, and wraps its cells when the page itself is narrower. - The 1px gaps over the border colour are the rules between cells, on every row. */ +.th-strip .k{display:block;color:var(--text-dim);font-size:.75rem} +/* The 1px gaps over the border colour separate the cells on every row. */ .th-strip{display:flex;flex-wrap:wrap;flex:1 0 auto;max-width:100%;gap:1px;background:var(--border);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden} .th-strip>div{flex:1 0 auto;padding:9px 14px;background:var(--surface);white-space:nowrap} .th-strip .n{display:block;font-size:1.1rem;font-weight:500;font-variant-numeric:tabular-nums} diff --git a/app/templates/runs/_execution.html b/app/templates/runs/_execution.html index 558b8058..d026880f 100644 --- a/app/templates/runs/_execution.html +++ b/app/templates/runs/_execution.html @@ -31,12 +31,12 @@ {%- if st.state == 'cached' %}cached{% elif st.get('seconds') is not none and st.state in ('done', 'failed') %}{{ st.seconds|secs }}{% endif %} {%- if st.state in ('running', 'failed') and st.detail and st.detail != sp.detail %}{{ st.detail }}{% endif %}{% endfor %} -
{% if sp.units %}{% set u = sp.units %}{{ u.done }} / {{ u.n if u.n is not none else '?' }} {{ u.noun }}{% for k in ('passed', 'failed', 'scored', 'errors') if u[k] %} · {{ u[k] }} {{ 'error' + ('' if u[k] == 1 else 's') if k == 'errors' else k }}{% endfor %}{% if u.running %} · {{ u.running }} running{% endif %}{% endif %}
+
{% if sp.units %}{% set u = sp.units %}{{ u.done }} / {{ u.n if u.n is not none else '?' }} {{ u.noun }}{% for k in ('passed', 'failed', 'scored', 'errors') if u[k] %} · {{ u[k] }} {{ 'error' + ('' if u[k] == 1 else 's') if k == 'errors' else k }}{% endfor %}{% if u.running %} · {{ u.running }} running{% endif %}{% endif %}
{% if sp.ended == 'refused' %}Refused before its first unit: {{ sp.detail }}{% endif %}
{# a part downloading: its file, how much of it, as a bar #} -
Launch log
+
Launch log
+{% endmacro %} diff --git a/app/templates/runs/job.html b/app/templates/runs/job.html index 92ce1898..3a8f674d 100644 --- a/app/templates/runs/job.html +++ b/app/templates/runs/job.html @@ -1,3 +1,4 @@ +{% from 'runs/_live_board.html' import live_panel %} {% from 'runs/_execution.html' import execution_strip %} {% from 'traces/_attempts.html' import attempt_count %} {% extends "base.html" %} @@ -32,14 +33,14 @@ title="{{ job.harbor_command }}">Copy command{% endif %}{% endset %} {{ page_head(job.job_id, sub=meta, actions=actions) }} -{% if execution %}{{ execution_strip(execution, csrf, own=own if execution.plan.steps()|length > 1 else none, deletable=deletable) }}{% endif %} +{% set board_ready = live_board and live_board.initial and live_board.initial.state != 'unknown' %} {% if job.is_preparing and not live_board and not ended %} {# Launched, not started: Harbor has written the configuration and nothing else. There is no result record and no feed to fold yet, so this page - waits for the feed and reloads itself when it appears. #} + waits for the feed and opens Live when it appears. #}
Preparing — this run was launched and {{ job.runner or 'Harbor' }} has written its configuration; no trial has started yet. - The live board appears here as soon as the first event lands. This page refreshes itself. + The live board appears here as soon as the first event lands.
{% elif (job.is_running or job.is_preparing) and ended %} {# Harbor's record says trials are running; the runner that started it says @@ -68,39 +69,20 @@
The live feed could not be read — {{ live_board.error }}. The sections below come from the trial results and are unaffected.
{% endif %} {% if view %} -{# Two views of one page. Live: the job's events.jsonl folded every second while it runs, and kept once it ended as the - record of how it ran. Results: the page rendered from the job's files when this page loaded. ?view= picks; without - it, Live while the feed says the job is going. At job.end Live stops asking and says Results is ready; no reload. #}
- - + + + {% if execution %}{% endif %}
+{% if execution %} +
+{{ execution_strip(execution, csrf, own=own if execution.plan.steps()|length > 1 else none, deletable=deletable) }} +
+{% endif %}
-
-
- {{ live_board.initial.state|capitalize }} - - -
-
-
- -
    - -
    -
    -
    -
    All trials
    -
    -
    - -
    - -
    - +{% if board_ready or execution or job.is_preparing %} +{{ live_panel(job.job_id, live_board, '' if job.runner and not job.standard and not job.trials else url_for('job', job_id=job.job_id), job.runner_items[0] if job.runner_items else '') }} +{% endif %}
    {% if job.is_running and not ended %} @@ -110,18 +92,6 @@
    {% endif %} {% endif %} -{% if job.is_preparing and not live_board and not ended %} - -{% endif %} - {#- Board counts are whole-run and never change under a filter; the trial rows are rendered here, and job.js only filters, sorts and links them. Every lane and tally count is nullius.judge.lanes, which is reconcile's. -#} diff --git a/app/templates/runs/preparing.html b/app/templates/runs/preparing.html index fb4e35db..18aa21e1 100644 --- a/app/templates/runs/preparing.html +++ b/app/templates/runs/preparing.html @@ -1,3 +1,4 @@ +{% from 'runs/_live_board.html' import live_panel %} {% from 'runs/_execution.html' import execution_strip %} {% extends "base.html" %} {% from '_page.html' import page_head %} @@ -6,8 +7,15 @@ {% block head %}{% endblock %} {% block body %} {{ page_head(job_id) }} - {% if ex.plan.runner == 'harbor' %}

    Started from the builder. This page becomes the live board as soon as Harbor writes the job.

    - {% elif ex.plan.runner == 'standard' %}

    Started from the builder with Nullius. This page becomes the live board as soon as the install is done and the run starts.

    - {% else %}

    Started from the builder with the {{ ex.plan.runner }} runner. This page becomes the live board as soon as this arm's questions are chosen, after the install.

    {% endif %} +
    + + + +
    +
    {{ execution_strip(ex, csrf, waiting=true, own=own, deletable=deletable) }} +
    + + {% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/templates/traces/_head.html b/app/templates/traces/_head.html deleted file mode 100644 index e28ed44f..00000000 --- a/app/templates/traces/_head.html +++ /dev/null @@ -1,30 +0,0 @@ -{% from 'runs/_runtime.html' import what_ran %} -{# What ran, said the same on a trial's page and on its task's All attempts: where the task is from - and what ran it, then the agent, its mark (`mark`: base.html's agent_mark) and the model that - answered. An imported trial says its importer. - A block with nothing to say is not drawn. #} -{% macro ran_cards(job, trial, imported_from, mark) -%} - {# The trial records a bare model name ("gpt-5.6-luna"); the job keeps the - provider-qualified one ("openai/gpt-5.6-luna"). Prefer the fuller id. #} - {% set model = job.model_name if job.model_name and job.model_name.endswith(trial.model_name or '~') - else (trial.model_name or job.model_name) %} - {% set agent = trial.agent_info_name or job.agent_label %} - {% if imported_from %} -
    Imported from{{ imported_from }}
    - {% else %} -
    - {% if trial.source %}
    Benchmark{{ trial.source|dsname }}
    - {% endif %} -
    Runner{% if job.runner %}{{ what_ran(job) }}{% else %}Harbor{% endif %}
    -
    - {% endif %} - {% if agent or model %} -
    - {% if agent %}{% endif %} -
    - {% if agent %}{{ agent }}{% if trial.agent_version %} {{ trial.agent_version }}{% endif %}{% endif %} - {% if model %}{{ model }}{% endif %} -
    -
    - {% endif %} -{%- endmacro %} diff --git a/app/templates/traces/attempts.html b/app/templates/traces/attempts.html index caadbefc..943dfdb1 100644 --- a/app/templates/traces/attempts.html +++ b/app/templates/traces/attempts.html @@ -1,16 +1,14 @@ {% extends "base.html" %} {% from '_page.html' import page_head %} {% from 'traces/_attempts.html' import attempt_tabs, attempt_count %} -{% from 'traces/_head.html' import ran_cards %} {% block title %}{{ trial.task_base }}, all attempts — Nullius{% endblock %} {% block crumb %}/ {{ job.job_id }} / {{ trial.task_base }}{% endblock %} {% block body %} {% set workspace = request.args.get('workspace') %} -{# the head of an attempt's page (traces/trial.html): the name, what ran, then the tabs, so a tab +{# the head of an attempt's page (traces/trial.html): the name and the tabs, so a tab changes what is under it and nothing above #} {{ page_head(trial.task_base, mono=true) }} -
    {{ ran_cards(job, trial, imported_from, agent_mark) }}
    {{ attempt_count(attempts) }} {{ attempt_tabs(job, attempts, none, workspace) }} diff --git a/app/templates/traces/trial.html b/app/templates/traces/trial.html index 892653b0..6344bd81 100644 --- a/app/templates/traces/trial.html +++ b/app/templates/traces/trial.html @@ -23,7 +23,6 @@ {% from 'traces/_judgement.html' import judgement_panel %} {% from 'traces/_attempts.html' import attempt_tabs, attempt_count, try_tabs %} -{% from 'traces/_head.html' import ran_cards %} {% from '_page.html' import page_head %} {% block body %} @@ -38,7 +37,7 @@ {{ page_head(trial.task_base, sub=sub, mono=true) }} {# an earlier try of an attempt: evidence only, never judged #} {% set replaced = trial.trial_name != attempt.trial_name %} -{# What ran (traces/_head.html, the same on All attempts), then how it went: the dataset's own +{# How this trial went: the dataset's own checks, the reward or the score, the agent's time and its steps. A value the trial does not have has no cell, and a block with no cell is not drawn. #} {% set vocab = trial.vocab %} @@ -52,7 +51,6 @@ {%- if traj and not traj.error %}
    Steps{{ traj.n_steps }}
    {% endif -%} {% endset %} {% if attempts or tries %} -
    {{ ran_cards(job, trial, imported_from, agent_mark) }}
    {% if attempts %}
    {{ attempt_count(attempts) }} @@ -61,11 +59,8 @@ {% endif %} {% if tries %}{{ try_tabs(job, tries, trial, request.args.get('workspace')) }}{% endif %} {% if cells|trim %}
    {{ cells }}
    {% endif %} -{% else %} -
    - {{ ran_cards(job, trial, imported_from, agent_mark) }} - {% if cells|trim %}
    {{ cells }}
    {% endif %} -
    +{% elif cells|trim %} +
    {{ cells }}
    {% endif %}