Skip to content

Fix a chat-mode toggle crash and the flaky TUI tests#539

Merged
tobocop2 merged 5 commits into
mainfrom
fix/catalog-search-worker-leak
Jul 16, 2026
Merged

Fix a chat-mode toggle crash and the flaky TUI tests#539
tobocop2 merged 5 commits into
mainfrom
fix/catalog-search-worker-leak

Conversation

@tobocop2

@tobocop2 tobocop2 commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Problem

The chat-mode toggle could crash the screen while mounting: its refresh queries the pills in the DOM, and when it ran before they finished attaching, the NoMatches took the screen down.

Beyond that, CI's red was flaky tests. The catalog search focus tests started a real model download every run (never stubbed), and on a loaded runner that worker starves the other TUI tests on its xdist worker, failing a different one each time. The GPU panel test keyed its fake probe on call count, so an extra timer tick drew the wrong answer.

Solution

The toggle keeps the pill references its compose creates and refreshes through them, so mount order no longer matters; a regression test pins it. The search tests stub the download enqueue, the GPU panel fake answers by phase, and the LeaveUp focus test waits for animations to settle before reading focus.

tobocop2 added 4 commits July 16, 2026 15:26
Enter in the catalog search installs the first visible match by design,
so the two focus-return tests were starting a genuine download task for
the fake test model on every run. Locally the worker dies within the
leak guard's grace; on a loaded runner it lives for minutes and starves
whichever TUI test shares the xdist worker next, which is where most of
the moving-victim CI failures came from. Stub _enqueue_download around
the submit so the selection path stays real but no worker is spawned.
The panel's interval timer can slip extra ticks in between the test's
explicit ones on a slow host. With a counter-keyed fake, one such tick
consumed the good-stats answer while its labels snapshot predated
set_devices, rendering the default GPU0 label, and the test's own tick
then drew the raising branch. Answer by the test's current phase
instead, so any number of extra ticks is idempotent.
ChatModeToggle.on_mount refreshes through query_one, and on a slow
mount the composed pills are not attached yet, so the refresh raises
NoMatches inside the message handler and takes the whole screen down
(seen as test_initial_view_switches_to_catalog failing on CI). Keep
the references compose creates and use them in _refresh; attributes
carry no mount-order dependency.

Also settle the catalog LeaveUp focus test on
wait_for_scheduled_animations: a bare pause reads focus mid-flight.
Sabotage-verified: fails against the query_one version of _refresh,
passes with the compose-held references.
@tobocop2 tobocop2 changed the title Fix the flaky TUI tests that keep CI red Fix a chat-mode toggle crash during mount, and the flaky tests that keep CI red Jul 16, 2026
@tobocop2 tobocop2 changed the title Fix a chat-mode toggle crash during mount, and the flaky tests that keep CI red Fix a chat-mode toggle crash and the flaky TUI tests Jul 16, 2026
The suite runs under a 100 percent coverage gate and the None guard's
return was the one statement nothing executed: every mounted toggle has
its pills by the time anything refreshes it. Exercise the pre-compose
state directly.
@tobocop2
tobocop2 merged commit 32cbaa1 into main Jul 16, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant