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`.
This commit is contained in:
Barrett Ruth 2026-03-05 18:23:39 -05:00
parent 9cf9cd8441
commit 73be6b8277

View file

@ -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