diff --git a/packages/cli-rs/crates/tui/src/plugins/host.rs b/packages/cli-rs/crates/tui/src/plugins/host.rs index 024bf98a0ac..a5fe0d854a8 100644 --- a/packages/cli-rs/crates/tui/src/plugins/host.rs +++ b/packages/cli-rs/crates/tui/src/plugins/host.rs @@ -157,7 +157,8 @@ type Watched = (PathBuf, Option, W); /// Watches the loader's directories: keeps the watches that still see them, and replaces one whose directory /// went away or was made again, which the old watch no longer sees. fn watch(tui: &Tui, loader: &Loader, watches: &RefCell>) { - for (dir, id) in unwatched(&mut watches.borrow_mut(), loader.watch_dirs()) { + let fresh = unwatched(&mut watches.borrow_mut(), loader.watch_dirs()); + for (dir, id) in fresh { let proxy = tui.app.proxy(); let watch = opencode_local::watch::watch( &dir, diff --git a/packages/cli-rs/crates/tui/tests/all/plugins.rs b/packages/cli-rs/crates/tui/tests/all/plugins.rs index c95734dc825..ee2aeeeabd4 100644 --- a/packages/cli-rs/crates/tui/tests/all/plugins.rs +++ b/packages/cli-rs/crates/tui/tests/all/plugins.rs @@ -168,6 +168,11 @@ fn a_panicking_command_is_caught_and_enabling_restarts_the_plugin() { let screen = h.wait_for("run-command panicked: sample command panicked"); print_excerpt("error details after a panic", &screen); h.app.press("escape"); + // A plugin that failed while active is still active, as in TS: enter disables it, then enables it afresh. + h.wait_for("disable enter"); + h.app.press("enter"); + h.app.wait_until(Duration::from_secs(5), || h.status() == opencode_plugin::Status::Inactive); + assert_eq!(h.status(), opencode_plugin::Status::Inactive); h.wait_for("enable enter"); h.app.press("enter"); h.app.wait_until(Duration::from_secs(5), || h.status() == opencode_plugin::Status::Active);