Four TUI tests read machine state (~/.codewhale, display probe) and fail deterministically on a dev box while CI stays green
Summary
Four TUI tests read machine state — ~/.codewhale and the display-refresh probe — so they fail deterministically on a dev box that has real CodeWhale state, while CI (clean HOME, no display probe) stays green. Verified on current main (7b67149b2), macOS, with a real ~/.codewhale/settings.toml (locale = zh-Hans, calm_mode = true) and a populated catalog/models-dev-catalog.json.
commands::groups::config::config::tests::settings_command_opens_typed_editor_and_preserves_text_mode
tui::views::tests::config_view_surfaces_structural_external_consent_without_io
tui::model_picker::tests::model_picker_is_usable_and_opaque_at_blocker_sizes
tui::ui::tests::underwater_motion_keeps_its_smoother_cadence_during_live_status
All four fail filtered or under the full suite; all four pass with the machine state taken out of the equation (contrast below).
Mechanisms
Three distinct paths, not one:
1. The lock_test_env() trust hole (first two tests). settings_path_candidates() sends lock-holding threads to settings_path_candidates_from_environment() on the assumption that a test holding the lock has provided explicit temporary paths. These two hold the lock (to serialize) but set no CODEWHALE_HOME/CODEWHALE_CONFIG_PATH, so Settings::load() resolves the real ~/.codewhale/settings.toml. With locale = zh-Hans the settings dump renders 「设置:」 and the assertion on "Settings:" fails. The isolation contract exists — it's just unenforced for lock holders that don't opt in.
2. resolve_state_dir has no test shield (model picker). The settings isolation lives in crates/tui/src/settings.rs only. models_dev_live::cache_path() goes through codewhale_config::resolve_state_dir("catalog"), which never heard of isolated_test_state_root(), so the picker renders against the real models-dev cache; at 80x24 the footer wraps differently and the "move" hint assertion fails.
3. The display probe (underwater cadence). probe_display_refresh() is OnceLock-cached and on macOS asks CoreGraphics for the real display Hz. This box reports 60Hz, so adaptive_animation_interval_ms(false) returns 66ms and the assertion on the 80ms UI_UNDERWATER_ANIMATION_MS floor fails. The test pins low_motion/fancy_animations but can't pin the probe.
Contrast
# fails (real machine state)
cargo test -p codewhale-tui --lib settings_command_opens_typed_editor_and_preserves_text_mode
# passes — first three tests
CODEWHALE_HOME=$(mktemp -d) cargo test -p codewhale-tui --lib <each of the first three>
# passes — underwater (0 is out of range, probe rejects it and falls back)
CODEWHALE_DISPLAY_HZ=0 cargo test -p codewhale-tui --lib underwater_motion_keeps_its_smoother_cadence_during_live_status
Possible directions
- Make the lock-holder branch of
settings_path_candidates()fall back toisolated_test_state_root()unless an override var is actually set, instead of trusting the lock alone. - Give
resolve_state_dir(or its tui-side callers) the samecfg(test)confinement settings already have. - Pin the probe in cadence tests via
CODEWHALE_DISPLAY_HZ(or a test-only setter) the way the two motion flags are already pinned.
Happy to send any of these as a PR if the direction sounds right.
Thanks @Lstarsky0 for the report.
This issue is staying open for maintainer triage. CodeWhale gets better because people bring us real edge cases from real machines, providers, regions, and workflows.
If you can add a reproduction, logs, version output, screenshots, or the provider/model involved, that makes it much easier for us to verify and harvest the fix. Maintainers may comment /lgtmi to mark recurring issue reporters as approved so this intake note is skipped next time.
Correction to mechanism 2 above, found while building the fix: I attributed model_picker_is_usable_and_opaque_at_blocker_sizes to the catalog cache, and that is wrong.
My original contrast used CODEWHALE_HOME=$(mktemp -d), which redirects settings and catalog at once, so it could not separate them. Fixing each path independently and re-running does separate them:
| fix applied | model_picker |
|---|---|
| settings predicate only | passes |
| catalog confinement only | fails |
| both | passes |
So that test fails for the same reason as the first two — the lock_test_env() trust hole feeding it the real ~/.codewhale/settings.toml — not because of resolve_state_dir. Mechanisms 1 and 3 hold as written; mechanism 2 had the right diagnosis of a real gap attached to the wrong symptom.
The resolve_state_dir gap itself is real, just not what was breaking that test. With the settings path fixed and the catalog path left alone, an unguarded test still resolves the developer's cache:
catalog cache escaped the isolated test root: /Users/rvkeo/.codewhale/catalog/models-dev-catalog.json
That is a pinned assertion now rather than an observation — no test covered that path before, which is why nothing caught it either way.
Fix is built against d48db57e6 and covers all three mechanisms, each with a test that fails when its own fix is reverted. Sending it as a PR shortly; happy to split the catalog part out if you would rather take the two symptom fixes first.