Repository navigation
TUI lib tests: flicker-history and picker-catalog state leak across parallel tests #1960
Description
A narrow slice of #596: two process-global state areas make specific jcode-tui lib tests flaky under default parallel execution, even when the shared env lock is used correctly. #596 tracks the suite-wide serialization workaround; this issue only covers these two areas so they can be fixed independently.
Steps to reproduce
cargo test -p jcode-tui --lib -- --test-threads=1passes.- Plain
cargo test -p jcode-tui --lib(default parallelism) a few times: a small set of tests fails each run, a different set each time, and every failing test passes alone.
Expected
Serial and parallel runs give the same results.
Actual
Two leak areas observed in parallel runs:
- Flicker-frame history: process-global, and not reset by the render-state clearing helpers. Deep-idle redraw tests (
test_redraw_interval_uses_low_frequency_during_remote_startup_phase,test_cold_cache_warning_keeps_redrawing_at_deep_idle,test_active_swarm_spinner_keeps_redrawing_at_deep_idle) read notices a concurrent sibling recorded, so redraws stay alive and the asserts break. - Model picker: a shell-exported named provider profile (
JCODE_NAMED_PROVIDER_PROFILEand friends) flips openai-compatible routes onto the profile route before the copilot fallback under test (test_model_picker_copilot_selection_prefixes_model), and Enter in the picker persists the usage store under whateverJCODE_HOMEis current, landing the write in a concurrently running locked test's tempdir (test_subagent_model_large_catalog_uses_cached_searchable_picker).
Proposed fix
The scoping pattern #596 documents as the approach that worked for jcode-base:
frame_flickertests take the existingviewport_snapshot_test_lock, pin the tier, and clear the flicker-frame history before the assertions read it.- Picker tests run inside
with_temp_jcode_home, extended to clear the named-profile and openrouter env vars for the test duration (restored after, even on panic), so the Enter-persisted usage store gets a private home.
Verified against the current master tip: the four affected files' 156 tests pass under default parallel threads, except the two pre-existing master drift failures tracked in #1907. The test_size_budget.json baseline bumps cover exactly the added lines.
Happy to open a PR if you want.
Activity
1jehuang commentedon Oct 24, 2026
Thanks for the careful narrowing, this matches the scoping pattern from #596. A PR with the
viewport_snapshot_test_lock+ flicker-history reset and thewith_temp_jcode_homeenv scoping would be welcome; please keep thetest_size_budget.jsonbumps limited to the added lines as you described.Jcode agent (automated triage), on behalf of @1jehuang