From f050ee2a9bf2be1458a0ae00931108496219a0e0 Mon Sep 17 00:00:00 2001 From: Simon Klee Date: Wed, 18 Nov 2026 14:20:42 +0100 Subject: [PATCH] test(cli-rs): freeze the plugin monitor while limit rows compare frames The plugin limit rows compare a frame with its twin, drawn moments apart, while the plugin monitor timed the built-ins on the real clock. On preview 44303912167's Windows runner the debug build of opencode.prompt.footer averaged 1.1 ms a frame between the two draws, so a "Plugin is slow" toast covered the twin and the row failed, though the limits behaved alike on both. The module's harnesses now give the monitor a clock that does not move, as the carrier and diffs rows do; the two rows that measure host time put the real clock back. A monitor clock stepped 2 ms a read reproduces the failure on Linux. --- .../cli-rs/crates/tui/tests/all/plugin_limits.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/cli-rs/crates/tui/tests/all/plugin_limits.rs b/packages/cli-rs/crates/tui/tests/all/plugin_limits.rs index 2ab3cea339b..cd86938866d 100644 --- a/packages/cli-rs/crates/tui/tests/all/plugin_limits.rs +++ b/packages/cli-rs/crates/tui/tests/all/plugin_limits.rs @@ -124,10 +124,19 @@ fn open(carrier: Carrier) -> Harness { ..support::deps(Arc::new(support::empty())) }; let harness = support::mount(100, 30, deps); + still(&harness); settle(&harness); harness } +/// Stops the plugin monitor's clock: a frame and its twin are compared, and a slow runner's real time could find a +/// built-in slow between them, whose toast covers one of the two (preview 44303912167, Windows). A row that measures +/// host time puts the real clock back. +fn still(harness: &Harness) { + let now = std::time::Instant::now(); + harness.tui.plugins.monitor().set_clock(move || now); +} + fn settle(harness: &Harness) { harness.app.advance(Duration::from_millis(1)); harness.app.render(); @@ -815,6 +824,7 @@ fn panels_and_overlays_are_held_to_the_limits() { ..support::deps(Arc::new(support::Fake::new(|seen| support::base(seen, support::DIRECTORY)))) }; let harness = support::mount(100, 30, deps); + still(&harness); settle(&harness); for command in ["limits.panel", "limits.overlay"] { let (frame, held) = { @@ -1408,6 +1418,8 @@ fn a_long_line_costs_its_rows() { fn trees_of_abi_1_are_held_to_the_limits() { for carrier in CARRIERS { let harness = open(carrier); + // Host time is measured: the real clock. + harness.tui.plugins.monitor().set_clock(std::time::Instant::now); let host_time = harness.tui.plugins.monitor().host_time(OLD); harness.tui.navigate(Route::Plugin { id: OLD.to_owned(), name: "old".to_owned() }); settle(&harness); @@ -1518,6 +1530,8 @@ fn what_a_mount_holds_goes_and_its_host_work_is_timed() { for carrier in CARRIERS { let harness = open(carrier); let _limits = limits::set(Limits { plugin_content: 1 << 20, all_content: 1 << 20, ..small() }); + // Host time is measured: the real clock. + harness.tui.plugins.monitor().set_clock(std::time::Instant::now); let monitor = harness.tui.plugins.monitor().clone(); let decoded = |harness: &Harness| { let done = harness.app.wait_until(Duration::from_secs(10), || opencode_plugin::image::jobs(ID) == 0);