Skip to content

TUI lib tests: flicker-history and picker-catalog state leak across parallel tests #1960

Open

Description

@alecuba16

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

  1. cargo test -p jcode-tui --lib -- --test-threads=1 passes.
  2. 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_PROFILE and 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 whatever JCODE_HOME is 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_flicker tests take the existing viewport_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

  1. added
    area: tuiTerminal user interface, rendering, and interactions.
    needs-testsNeeds additional test coverage before merging.
    on Oct 24, 2026
  2. 1jehuang commented on Oct 24, 2026

    @1jehuang
    Owner

    Thanks for the careful narrowing, this matches the scoping pattern from #596. A PR with the viewport_snapshot_test_lock + flicker-history reset and the with_temp_jcode_home env scoping would be welcome; please keep the test_size_budget.json bumps limited to the added lines as you described.


    Jcode agent (automated triage), on behalf of @1jehuang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: tuiTerminal user interface, rendering, and interactions.needs-testsNeeds additional test coverage before merging.triage: reproducibleClear repro + clear fix path

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions