Restore archived tasks, fix dashboard scroll-reset, bind ornith, add Playwright smoke test
- **Restore 82 completed tasks** from tasks/complete/ back to tasks/ top level (all <7 days old per the cleanup policy; premature bulk archive was fixed). - **Dashboard: fix scroll-reset on auto-refresh** — renderBoard rebuilds the board via innerHTML every 2s, destroying each column-body's scrollTop. Now snapshots column-body scrollTop + board.scrollLeft + view.scrollTop before rebuild and restores after (matched by PHASE_GROUPS index). - **Dashboard UI additions** (pre-existing unstaged work): approval section cards, transition buttons, inline artifact editor (textarea for writing missing SPEC/VERDICT/etc from the detail modal). - **Bind ornith as Implement model** — config.md: Model explicit to omlx/Ornith-1.0-35B-4bit-mlx, context window 32768. Interactive autopilot already used ornith via opencode default; now explicit. - **Fix cleanup stub** — automaton-cleanup.sh had a stale --project arg pointing at a pytest temp dir (test isolation leak). Rewired to point at ~/.automaton. - **Fix plist-isolation test** — test asserted host plist doesn't exist, but a real install creates it. Now snapshots mtime before run, asserts unchanged after (only a write during the test counts as bleed). - **New Playwright smoke test** (tests/test_dashboard_ui.py) — 2 tests: board renders tasks, column scroll survives auto-refresh tick. Verified the test fails without the scroll fix (scrollTop resets to 0). Skipped via importorskip when playwright is absent (main CI stays green). - **Clarify SI loop scope in README** — new-project onboarding section documents the framework-scoped self-improvement loop and options (leave/pause/create project loop). - **CHANGELOG** documents all changes including the known model-divergence gap (mde tasks marked complete but per-role model binding was never implemented).
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
"""Playwright browser smoke test for the dashboard UI.
|
||||
|
||||
Verifies the dashboard boots, renders tasks, and preserves column scroll
|
||||
position across auto-refresh (the fix for the scroll-reset bug). Skipped
|
||||
when playwright/chromium is not installed so the main suite stays green
|
||||
in CI environments without a browser.
|
||||
|
||||
Run standalone:
|
||||
python3 -m pytest tests/test_dashboard_ui.py -v
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import socket
|
||||
import threading
|
||||
import time
|
||||
from http.server import HTTPServer
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from automaton.dashboard.ui.app import DashboardHandler, DashboardApp
|
||||
|
||||
playwright = pytest.importorskip("playwright")
|
||||
from playwright.sync_api import sync_playwright # noqa: E402
|
||||
|
||||
|
||||
def _free_port() -> int:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.bind(("127.0.0.1", 0))
|
||||
port = s.getsockname()[1]
|
||||
s.close()
|
||||
return port
|
||||
|
||||
|
||||
def _make_done_tasks(project_root: Path, count: int) -> None:
|
||||
tasks = project_root / ".automaton" / "tasks"
|
||||
tasks.mkdir(parents=True, exist_ok=True)
|
||||
for i in range(count):
|
||||
d = tasks / f"done-task-{i:02d}"
|
||||
d.mkdir(exist_ok=True)
|
||||
(d / "SPEC.md").write_text(f"# Done task {i}\n" + ("line. " * 40) + "\n")
|
||||
(d / ".state").write_text("complete\n")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def dashboard_server(tmp_path: Path):
|
||||
_make_done_tasks(tmp_path, 40)
|
||||
app = DashboardApp(start_path=tmp_path)
|
||||
assert app.initialize(), "dashboard failed to init"
|
||||
port = _free_port()
|
||||
DashboardHandler.config = app.config
|
||||
DashboardHandler.project_root = app.project_root
|
||||
DashboardHandler.scope = app.scope
|
||||
server = HTTPServer(("127.0.0.1", port), DashboardHandler)
|
||||
thread = threading.Thread(target=server.serve_forever, daemon=True)
|
||||
thread.start()
|
||||
base_url = f"http://127.0.0.1:{port}"
|
||||
try:
|
||||
yield base_url
|
||||
finally:
|
||||
server.shutdown()
|
||||
server.server_close()
|
||||
thread.join(timeout=5)
|
||||
|
||||
|
||||
def _wait_for(predicate, timeout=10.0, interval=0.2):
|
||||
deadline = time.time() + timeout
|
||||
while time.time() < deadline:
|
||||
if predicate():
|
||||
return True
|
||||
time.sleep(interval)
|
||||
return False
|
||||
|
||||
|
||||
class TestDashboardUI:
|
||||
def test_board_renders_done_tasks(self, dashboard_server):
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch()
|
||||
page = browser.new_page()
|
||||
page.goto(dashboard_server)
|
||||
# Footer refresh counter increments once auto-refresh fires.
|
||||
assert _wait_for(lambda: page.text_content("#refresh-count") not in (None, "0", ""))
|
||||
# The Done (resolution) group contains our tasks.
|
||||
cards = page.locator(".task-card")
|
||||
assert _wait_for(lambda: cards.count() >= 40, timeout=15)
|
||||
assert page.text_content("#done-tasks") == "40"
|
||||
browser.close()
|
||||
|
||||
def test_refresh_preserves_column_scroll(self, dashboard_server):
|
||||
"""The scroll-reset bug: re-render snapped a column's scrollTop to 0,
|
||||
so users couldn't scroll the Done group down to review older tasks.
|
||||
Verify the column-body scrollTop survives an auto-refresh tick."""
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch()
|
||||
# Wide viewport so columns fit and the Done column-body overflows
|
||||
# vertically (rather than the board squeezing them horizontally).
|
||||
page = browser.new_page(viewport={"width": 1400, "height": 500})
|
||||
page.goto(dashboard_server)
|
||||
assert _wait_for(lambda: page.locator(".task-card").count() >= 40, timeout=15)
|
||||
# The Done (resolution) group is the last column.
|
||||
bodies = page.locator(".column-body")
|
||||
n = bodies.count()
|
||||
done_body = bodies.nth(n - 1)
|
||||
assert done_body.evaluate("el => el.scrollHeight > el.clientHeight")
|
||||
# Scroll the column-body well past the top.
|
||||
target = 400
|
||||
done_body.evaluate("(el, y) => { el.scrollTop = y; }", target)
|
||||
assert done_body.evaluate("el => el.scrollTop") == target
|
||||
# Wait for an auto-refresh re-render (default interval 2s).
|
||||
before = int(page.text_content("#refresh-count") or "0")
|
||||
assert _wait_for(lambda: int(page.text_content("#refresh-count") or "0") > before, timeout=10)
|
||||
# Scroll must survive the re-render (the bug fix).
|
||||
assert done_body.evaluate("el => el.scrollTop") == target
|
||||
browser.close()
|
||||
Reference in New Issue
Block a user