From e0b5564f04aa0ae6666f29ef29c768d800fbabce Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 13:15:41 -0300 Subject: Step core animation by the shell's clock and sleep to the next wake A shell now answers Host.now, its monotonic clock in ns, and the pump advances core animation to it: one .tick per whole 16 ms frame since core time last stood still. The same animation therefore takes the same time at 60, 120 and 144 Hz, over ssh and after a slow frame (the GUI's re-armed clock ran them ~25% slow at 144 Hz; the tty's post-frame sleep drifted). nextWake() lists every core animation in one place: a frame from now while anything moves, the end of the wait while something only waits (a message lingering, the look-hover delay), null when idle. Shells sleep exactly that long, and a wait is jumped to its end in one step, so an 800 ms linger costs one frame instead of fifty. An overshoot under 1.5 ms after a step is let go: at 60 and 120 Hz every display frame takes exactly one step (a 16 ms frame against a 16.67 ms vsync would otherwise double-step every 24th). The six tick drivers are gone: tty's timer thread only times the wait, interruptibly (a newer, shorter request cuts short a sleep still timing a longer one); the GUI's AnimationClock, web's JS tick bank (pardes_tick now takes rAF's timestamp), the detached server's and the board's ticks; grid mode steps a virtual clock straight to each wake. PARDES_TEST_CLOCK, set by the snapshot harness, gives tty and the detached server the same virtual clock. Every stepped frame is drawn. The old pump never drew the last frame of a fade (a .tick asks for no frame, and the fade was over by the check), so a theme switch stopped at 9/10 of the way until the next input: theme.golden, themesel.golden and the GUI's acme-light scene move to the theme's true colours, and nothing else changes. The frozen previous grid is captured only while a panel transition is chosen, not on every idle frame. --- test/web_harness.mjs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'test/web_harness.mjs') diff --git a/test/web_harness.mjs b/test/web_harness.mjs index 90dd9a19..402e41f4 100644 --- a/test/web_harness.mjs +++ b/test/web_harness.mjs @@ -17,7 +17,7 @@ async function main() { const webDir = path.resolve(process.argv[2]); const wasmBytes = await fs.readFile(path.join(webDir, "pardes.wasm")); const module = await WebAssembly.compile(wasmBytes); - const { DomRenderer, animationTicks, browserHost } = await import(pathToFileURL(path.join(webDir, "app.mjs"))); + const { DomRenderer, browserHost } = await import(pathToFileURL(path.join(webDir, "app.mjs"))); assert.deepEqual( [...new Set(WebAssembly.Module.imports(module).map((entry) => entry.module))], ["pardes"], @@ -40,7 +40,7 @@ async function main() { for (const name of [ "memory", "pardes_init", "pardes_frame", "pardes_frame_ptr", "pardes_key", "pardes_mouse", "pardes_pointer_leave", "pardes_pointer_shape", "pardes_gui_tagline_font_percent", - "pardes_paste", "pardes_tick", "pardes_animation_tick", "pardes_animating", + "pardes_paste", "pardes_tick", "pardes_should_quit", "pardes_deinit", ]) assert.ok(wasm[name], `missing wasm export ${name}`); @@ -85,18 +85,6 @@ async function main() { "DOM did not use the build-time tagline percentage", ); - for (const hz of [60, 120, 144]) { - const clock = { last: null, lag: 0 }; - let ticks = 0; - for (let frame = 0; frame <= hz; frame += 1) { - ticks += animationTicks(clock, frame * 1000 / hz); - } - assert.equal(ticks, 60, `${hz} Hz rAF did not produce 60 core ticks per second`); - } - const stalled = { last: null, lag: 0 }; - assert.equal(animationTicks(stalled, 0), 0); - assert.equal(animationTicks(stalled, 60_000), 4, "suspended tab catch-up was not bounded"); - const firstCell = renderer.cells[0]; const second = draw(); assert.equal(renderer.cells[0], firstCell, "stable frames should reuse DOM nodes"); -- cgit v1.3 From 4c30f231a6dc57adde8ae7390cd656ddc6210c8a Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 23:16:24 -0300 Subject: The web harness Looks through the touch fixture its documented dump holds test/web_harness.mjs still expected source-list.dump.zon (a git ls-files listing of the live tree), which posxwrksryvw deleted for capturing project paths; the documented invocation embeds touch.dump.zon, so the scroll check could never match. The harness now scrolls the fixture to its first row, right-click Looks /virtual/pane/1/body and checks the reflected body opens with Tree-sitter styles. A stale test, not a product bug. Co-Authored-By: Claude Opus 5.5 --- test/web_harness.mjs | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'test/web_harness.mjs') diff --git a/test/web_harness.mjs b/test/web_harness.mjs index 402e41f4..7fd58b86 100644 --- a/test/web_harness.mjs +++ b/test/web_harness.mjs @@ -90,29 +90,34 @@ async function main() { assert.equal(renderer.cells[0], firstCell, "stable frames should reuse DOM nodes"); assert.equal(second.cells.length, 80 * 24); - // A replay follows the terminal cursor at the bottom. Deliberately - // over-scroll (the core clamps at row zero) so adding more source files does - // not silently move the hard-coded build.zig click onto some later path. + // The embedded dump is test/web-snapshots/touch.dump.zon, a fixed source + // fixture (no live project paths). Over-scroll first (the core clamps at row + // zero) so the Look below always lands on the fixture's own first rows. for (let tick = 0; tick < 128; tick += 1) wasm.pardes_mouse(3, 0, 5, 3, 0); const listingTop = draw(); - assert.match( - listingTop.cells.map((cell) => cell.text).join(""), - /git ls-files --cached --others --exclude-standard.*build\.zig/, - "working-tree source listing did not scroll to its first row", + const topLines = Array.from({ length: listingTop.rows }, (_, row) => + listingTop.cells.slice(row * listingTop.cols, (row + 1) * listingTop.cols).map((cell) => cell.text).join("")); + assert.ok( + topLines.some((text) => /^\s*1 pub fn choose/.test(text)), + "fixture source did not scroll to its first row", ); - wasm.pardes_mouse(2, 0, 5, 3, 0); - wasm.pardes_mouse(2, 1, 5, 3, 0); + const link = "/virtual/pane/1/body"; + const linkRow = topLines.findIndex((text) => text.includes(link)); + assert.ok(linkRow >= 0, "fixture has no Look target"); + const linkCol = topLines[linkRow].indexOf(link) + 5; + wasm.pardes_mouse(2, 0, linkCol, linkRow, 0); + wasm.pardes_mouse(2, 1, linkCol, linkRow, 0); const looked = draw(); - assert.match( - looked.cells.map((cell) => cell.text).join(""), - /build\.zig\s+Save Tty Del/, - "right-click LOOK did not open the embedded source", + const lookedText = looked.cells.map((cell) => cell.text).join(""); + assert.ok( + lookedText.includes(`${link} `) && lookedText.split("pub fn choose").length - 1 >= 2, + "right-click LOOK did not open the reflected source body", ); const sourceRows = Array.from({ length: looked.rows }, (_, row) => looked.cells.slice(row * looked.cols, (row + 1) * looked.cols)); const codeRows = sourceRows.filter((row) => row.map((cell) => cell.text).join("").match(/^\s*\d+\s/)); const codeColors = new Set(codeRows.flatMap((row) => row.slice(5).map((cell) => `${cell.fg}:${cell.attrs & 1}`))); - assert.ok(codeColors.size >= 3, "Tree-sitter did not apply distinct syntax styles to build.zig"); + assert.ok(codeColors.size >= 3, "Tree-sitter did not apply distinct syntax styles to the fixture"); assert.deepEqual(asked, [], "a plain replay asked the page for host IO"); wasm.pardes_resize(41, 13); -- cgit v1.3