From a4994371c0b0fbea9d2802acc22d9cc3977a0de0 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Sun, 4 Oct 2026 13:30:41 -0700 Subject: Slides for 2026 REBASE --- graph/README.md | 2 +- graph/test_browser.py | 3 +++ graph/web/viewer.js | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'graph') diff --git a/graph/README.md b/graph/README.md index d52ecfeb..8577f509 100644 --- a/graph/README.md +++ b/graph/README.md @@ -28,7 +28,7 @@ python -m http.server 8000 --bind 127.0.0.1 --directory graph/web Then launch Java with `-Dsimple.graph.url=http://127.0.0.1:8000/index.html`. The compiler WebSocket still uses port 12345; run one viewer session at a time. -The initial program compiles on connection. For another program, click **Compile** +The viewer starts idle. Enter a program and click **Compile** or press **Ctrl+Enter** (**Cmd+Enter** on macOS). Use the arrows to step through frames (Left/Right arrow keys perform the same steps, including animation stages), the first/last buttons to jump to either end, or enter a frame number diff --git a/graph/test_browser.py b/graph/test_browser.py index aa1015e1..b95e4555 100644 --- a/graph/test_browser.py +++ b/graph/test_browser.py @@ -55,6 +55,9 @@ def check(chapter, browser_name): return raise AssertionError("Peephole did not reach a stable frame") page.goto(url) + page.wait_for_function('connection === "Connected" && rendererReady') + assert page.evaluate('!compiling && !done && frames.length === 0') + page.locator("#compile").click() page.wait_for_function("done && current === 0 && !rendering", timeout=15000) assert page.locator("#graph svg g.node").count() > 0 assert page.locator("#doPrev").is_disabled() diff --git a/graph/web/viewer.js b/graph/web/viewer.js index 6309deae..4412817e 100644 --- a/graph/web/viewer.js +++ b/graph/web/viewer.js @@ -71,7 +71,7 @@ function updateUI() { status.textContent = failure || (connection !== "Connected" ? connection : !rendererReady ? "Connected; initializing graph renderer..." : busy ? busy : compiling ? "Compiling... " + frames.length + " frames received" : - done ? frames.length + " frames ready" : "Connected"); + done ? frames.length + " frames ready" : "Ready. Enter a program and click Compile."); const at = wanted >= 0 ? wanted : current; if (document.activeElement !== frameNo) frameNo.value = String(at + 1); frameNo.max = scrub.max = String(Math.max(1, frames.length)); @@ -365,7 +365,7 @@ try { socket.onmessage = event => { const message = event.data; if (message === "!") { - get_program(); + updateUI(); } else if (message === "#") { done = true; compiling = false; -- cgit v1.2.3