Repository navigation
Description
Summary
Five terminal::view::tests pass in isolation but fail whenever the module (or the full warp lib suite) runs, because other tests in view_tests.rs flip the process-global FeatureFlag state via FeatureFlag::AgentView.set_enabled(true) and never reset it. The five failing tests do no flag setup and implicitly rely on AgentView defaulting to false; once an earlier test leaves the global true, they take the wrong code branches and their assertions fail. These currently report as failures on every contributor's full-suite PR gate.
Affected tests
All in app/src/terminal/view_tests.rs:
terminal::view::tests::test_insertterminal::view::tests::test_insert_into_inputterminal::view::tests::test_viewport_iter_most_recent_at_bottomterminal::view::tests::test_reinput_blocksterminal::view::tests::test_scroll_position_doesnt_change_when_block_finished
Reproduction
Full suite (fails; the 5 appear among 12-14 failures depending on run):
cargo test -p warp --lib
The 5 tests pass when run together with no flag-setting test in the set:
cargo test -p warp --lib -- --exact \
terminal::view::tests::test_insert \
terminal::view::tests::test_insert_into_input \
terminal::view::tests::test_viewport_iter_most_recent_at_bottom \
terminal::view::tests::test_reinput_blocks \
terminal::view::tests::test_scroll_position_doesnt_change_when_block_finished
# => test result: ok. 5 passed
Minimal deterministic reproduction — run a flag-setting test first, single-threaded, and the clean tests fail every time:
cargo test -p warp --lib -- --test-threads=1 --exact \
terminal::view::tests::agent_view_lifecycle_updates_input_mode \
terminal::view::tests::test_insert \
terminal::view::tests::test_viewport_iter_most_recent_at_bottom \
terminal::view::tests::test_scroll_position_doesnt_change_when_block_finished
# => test_insert FAILED, test_viewport_iter_most_recent_at_bottom FAILED,
# test_scroll_position_doesnt_change_when_block_finished FAILED
--test-threads=1 does not help: this is process-global state carried forward across sequential tests, not a data race.
Observed assertion failures in the full run:
test_insert(view_tests.rs:2698):left: "One", right: "None"— a block selection that should have been cleared is retained.test_insert_into_input(view_tests.rs:2824):Expected no selections in the blocklist but got Some(...).test_viewport_iter_most_recent_at_bottom(view_tests.rs:3220):item 3— a trailing zero-height viewport entry is missing.test_reinput_blocks(view_tests.rs:4072):left: "pwd", right: "sudo pwd".test_scroll_position_doesnt_change_when_block_finished(view_tests.rs:5310):ScrollTop(...)vsFollowsBottomOfMostRecentBlock.
Root cause
Feature-flag enabled-state is stored in a process-global array:
// crates/warp_features/src/lib.rs:918
static FLAG_STATES: [AtomicBool; cardinality::<FeatureFlag>()] =
[const { AtomicBool::new(false) }; { cardinality::<FeatureFlag>() }];set_enabled writes into it globally with no teardown, and its own guard documents that this is the wrong thing to do in a test:
// crates/warp_features/src/lib.rs:1038
pub fn set_enabled(self, enabled: bool) {
if cfg!(test) && cfg!(not(feature = "integration_tests")) {
panic!(
"Tried to globally enable {self:?} in a test. Use FeatureFlag::{self:?}.override_enabled instead"
);
}
FLAG_STATES[self as usize].store(enabled, Ordering::Relaxed);
}view_tests.rs contains 22 set_enabled(true) calls (e.g. AgentView at lines 148, 737, 1476, 1535, 5141, 5322, 5383, 5443, 5506, 5562, 5608, 5690, 5817, 5865, 5923, 7439, 7485, 7565, 7877, 7944; CloudMode at 1477, 1536). None of them reset the flag afterward. Because these tests run under the integration_tests feature, the guard's panic is bypassed and the global write silently persists for the rest of the process.
The five failing tests read the flag and branch on it. With AgentView leaked true:
app/src/terminal/view.rs:19985and:20028guardclear_selected_blocks()with&& !FeatureFlag::AgentView.is_enabled(). Leaked-on means the block selection is not cleared when typing in shell mode, sotest_insertsees"One"selection instead of"None", andtest_insert_into_inputsees a leftoverSome(...)selection.app/src/terminal/block_list_viewport.rs:2040:if !FeatureFlag::AgentView.is_enabled() || block_height.as_f64() > 0. { return next; }. Leaked-on skips the trailing zero-height entry, sotest_viewport_iter_most_recent_at_bottompanics on the missingitem 3andtest_scroll_position_doesnt_change_when_block_finishedcomputes a different content height / most-recent-block and resolves the scroll position differently.test_reinput_blocksgoes throughreinput_commands→with_non_hidden_selected_blocks(view.rs:20954), whose filter uses the AgentView-dependenttranscript_scope; the same non-clearing-and-scope divergence drops thesudovariant so the input box retains"pwd".
That the same file already defensively uses AgentView.override_enabled(false) in places (view_tests.rs:439, 798) is direct evidence the leak is known.
Fix direction
Replace the 22 global set_enabled(true) calls in view_tests.rs with the RAII thread-local override the module already uses in a couple of spots:
let _guard = FeatureFlag::AgentView.override_enabled(true); // reverts on dropoverride_enabled (crates/warp_features/src/lib.rs:1067) writes a thread-local FLAG_OVERRIDES and returns an OverrideGuard (lib.rs:1192) that clears the override on drop, so no global write leaks across tests. This restores isolation without a per-test reset dance and matches the pattern the guard's own panic message prescribes.
Related
Related: #13853 (warp_editor render::tests Once-poisoning — same class, different crate) and the sibling flake tickets filed alongside this one: #13973, #13974, #13975
Activity
warp-for-oss commentedon Jul 19, 2026
@fbartho
Here's what I found while triaging this issue:
This looks actionable from the provided reproduction and current code: the failing tests are consistent with global feature-flag state leaking between tests. No reporter follow-up appears necessary for initial triage.
Maintainer details
I concluded that full-suite terminal::view test failures appear to be caused by process-global AgentView feature-flag state leaking between tests..
Triage summary
This is an actionable test-isolation bug in the terminal view area. The report separates the observed failures from the proposed root cause, and code inspection supports the proposed cause.
Evidence
crates/warp_features/src/lib.rsstores feature flag enabled state in the process-globalFLAG_STATESarray andFeatureFlag::set_enabledwrites to it globally. The same file providesFeatureFlag::override_enabled, a scoped test override that is cleared when its guard is dropped.app/src/terminal/view_tests.rsstill contains manyFeatureFlag::AgentView.set_enabled(true)calls, including early tests such asagent_view_lifecycle_updates_input_mode, and also has existing scopedAgentView.override_enabled(...)usage elsewhere.test_insert,test_insert_into_input,test_viewport_iter_most_recent_at_bottom,test_reinput_blocks, andtest_scroll_position_doesnt_change_when_block_finished) do not set up AgentView themselves and assert behavior that changes when AgentView is left enabled.app/src/terminal/view.rsguards selection clearing with!FeatureFlag::AgentView.is_enabled(), andapp/src/terminal/block_list_viewport.rsskips returning zero-height items when AgentView is enabled. Those branches line up with the reported assertion failures.Likely fix direction
Replace the global
set_enabled(true)calls in these tests with scopedFeatureFlag::AgentView.override_enabled(true)guards, or otherwise ensure the global flag state is restored after each test. The scoped override is the safer fit because the feature-flag crate documents it as the intended test API.Duplicate check
I enumerated all open repository issues and also checked recently closed issues. Related sibling full-suite flake reports (#13973, #13974, #13975) cover different global-state or lifecycle failures, so this issue should not be marked as a duplicate.
This is my automated analysis and may be incorrect. A maintainer will verify the details.
Powered by Oz
vorporeal commentedon Jul 20, 2026
hey @fbartho - we tend to use
cargo nextestto run tests, which isolates tests into separate processes, which is why we haven't noticed this (and it doesn't affect our CI or./script/presubmit).i notice you've opened a bunch of issues about this. is using
cargo nextestan acceptable solution (instead of trying to patch all of these), or are you intending to open PRs with fixes?fbartho commentedon Jul 20, 2026
Hey @vorporeal — I’ve largely been opening tickets that I’m willing to fix! (I’ve been using Claude as I work on other features, and I have an allergy to flaky tests. Claude loves to say “pre-existing issue” with no evidence, so any failing tests I look at super suspiciously)
That said, what’s the policy of this project? In the case of feature flags, it’s unclear if this is likely to cause a correctness issue. I’m fine closing this ticket if you don’t judge it likely & I’ll just change my procedures.
fbartho commentedon Jul 21, 2026
I proactively attempted an implementation based on the ticket as it's currently written: #14039.
If the ticket changes, I'm happy to update the PR to match a maintainer's guidance, just let me know!
fbartho commentedon Jul 28, 2026
Just nudging @oss-maintainers that this is still a real flake, and that I have a proposed fix here: #14039