From 73be6b82773ef00506240b25c6596f56c02c663e Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Thu, 5 Mar 2026 18:23:39 -0500 Subject: [PATCH] fix(setup): cancel all active panels on problem navigation Problem: `navigate_problem` only called `views.disable()` for the `'run'` panel; interactive and stress terminals were left alive when stepping through problems with `:CP next/prev`. In-flight `run_io_view` callbacks were also not invalidated since `is_new_contest` stays false for same-contest navigation, so the generation-counter guard in `setup_contest` never fired. Solution: call `cancel_io_view()` unconditionally in `navigate_problem` and expand the panel dispatch to cover `'interactive'` and `'stress'` alongside `'run'`, mirroring the contest-switch logic in `setup_contest`. --- lua/cp/setup.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/cp/setup.lua b/lua/cp/setup.lua index 1609e61..a954d62 100644 --- a/lua/cp/setup.lua +++ b/lua/cp/setup.lua @@ -477,9 +477,15 @@ function M.navigate_problem(direction, language) logger.log(('navigate_problem: %s -> %s'):format(current_problem_id, problems[new_index].id)) + local views = require('cp.ui.views') + views.cancel_io_view() local active_panel = state.get_active_panel() if active_panel == 'run' then - require('cp.ui.views').disable() + views.disable() + elseif active_panel == 'interactive' then + views.cancel_interactive() + elseif active_panel == 'stress' then + require('cp.stress').cancel() end local lang = nil