Repository navigation
fix(agent): fix flaky Agent tests and a stale store check that paused the chat - #1496
Merged
Merged
Conversation
Sidebar::new asks the backend for the saved order on a real tokio thread. Test screens use the dead 127.0.0.1:9 backend, so the refusal arrived at a moment set by the OS rather than the test: - landing mid-test, its notice banner moved the layout after a test had measured it: the centered composer rose 33px (navigation_loading_keeps_the_header_and_composer_in_place), or the transcript row moved so a stored click point missed its link (transcript_context_menu_copies_link_destinations, Nov 4 and the Nov 7 nightly); - landing after the task's first poll, it woke the task from a tokio thread, which gpui's test scheduler rejects as nondeterministic (test_application_vim_escape_assistant_focus_and_plain_command_count). The order request now has its own task. The test-only constructor and the fixture reset drop it before its first poll. Production behaviour is unchanged. A new test fails every time without the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#1496's first CI run failed in a desktop maintenance test. A full-suite soak under CPU load then found three more tests that fail intermittently. Each is fixed at its cause. Store checks (a real bug, not only a test race): the Maintenance event starts a store_status check. If its Maintenance reply was handled after the host's later Open event, it paused the chat again and left the settings refresh pending, and no further event resumed it. The chat then stayed on "Updating local data". A check whose reply predates a newer StoreStateChanged is now dropped, since that event was already handled. `a_late_maintenance_status_cannot_pause_the_reopened_chat` holds the reply until after Open, and it fails every time without the fix. This was the CI failure in `reconnect_and_password_maintenance_preserve_saved_language`. Tests: - `committed_restart_retry_quit_and_close_do_not_contact_the_retired_host` cleared its request log while a startup store_status was still in flight, then counted it against quit. It now waits until every call sent before retirement has been answered. Every call checks retirement before it is sent, so later calls cannot reach the host. - Unmounted-screen tests built with `ChatScreen::new_inner`, so #1496's cancellation of the sidebar's startup order request did not reach them. Its late refusal failed `test_application_vim_moves_over_the_semantic_transcript_projection`. `new_inner_for_test` cancels it, and all nine call sites use it. - `test_sidebar_menu_selects_grouping_and_task_order` saved a Manual order to the dead backend, and the refusal could close a later menu. It now waits for that refusal right after the press. - Lock tests asserted that a just-released flock was free. A process that another test forks at that moment holds the lock until it execs. `lock_after_release` waits that out for up to 5 seconds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AnthonyRonning
force-pushed
the
fix/agent-ui-test-backend-races
branch
from
November 7, 2026 21:36
aea62d0 to
1299afc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the intermittent Agent test failures behind last night's red nightly, plus every other intermittent failure a soak under CPU load turned up. One of them was a real bug in the app.
Root cause
Sidebar::newasks the backend for the saved sidebar order on a real tokio thread. Test screens use the dead127.0.0.1:9backend, so the refusal (Local account is not ready) arrives at a moment set by the OS rather than the test. Usually it lands during the fixture's lastrun_until_parked, so tests start with its notice already on screen. On a loaded runner it lands later:navigation_loading_keeps_the_header_and_composer_in_place(macOS, Nov 7): the empty state centres its column, so a banner below the composer moved it up 33px (y453 → 420).transcript_context_menu_copies_link_destinations(macOS, Nov 4 and the Nov 7 nightly): the transcript row moved, so the click point the test stored missed its link and the menu had no Copy Link.test_application_vim_moves_over_the_semantic_transcript_projection(found in the soak, 2 of 15 loaded runs): the notice appeared after the test had cleared it.test_application_vim_escape_assistant_focus_and_plain_command_countbuilds its own window withoutallow_parking. It failed this way in this branch's pre-commit hook.reset_persisted_for_testmarked the order loaded but left the request in flight.Change
The order request gets its own task (
order_request) instead of joining the sharedbridged_tasks. The test-onlySidebar::cancel_order_request_for_testdrops it before its first poll, while it has no waker for the tokio thread to call.ChatScreen::new_without_start, the newChatScreen::new_inner_for_test(used by all nine tests that build an unmounted screen) andreset_persisted_for_testall call it. Production code still makes the same request and handles its result the same way.fixture_leaves_no_saved_order_request_to_raise_a_late_noticeis new. It fails every time without the fix (unexpected notice: Some(Raw("Local account is not ready"))).Stale store checks (app bug)
This PR's first CI run failed in
reconnect_and_password_maintenance_preserve_saved_language("Timed out waiting for maintenance settings refresh"). It reproduced locally in 1 of 5 full-suite runs under CPU load, and never alone.The Maintenance event starts a
store_statuscheck. If its Maintenance reply was handled after the host's later Open event, it paused the chat again and left the settings refresh pending, and no further event resumed it. The chat stayed on "Updating local data…". In real use the window is small, because a password change usually outlasts that round trip, but the app trusted a stale reply over a newer event.MapleAppnow counts theStoreStateChangedevents it handles. A check whose reply predates a newer one is dropped, because that event was already handled.a_late_maintenance_status_cannot_pause_the_reopened_chatholds the reply in the fixture host until after Open. It fails 10 of 10 without the fix and passes 20 of 20 with it.Other test races found in the soak
committed_restart_retry_quit_and_close_do_not_contact_the_retired_hostcleared its request log while a startupstore_statuswas still in flight, then counted it against quit. It now waits until every call sent before retirement has been answered (AgentBackend::host_calls_in_flight_for_test). Every call checks retirement before it is sent, so the app was never contacting the retired host.test_sidebar_menu_selects_grouping_and_task_ordersaved a Manual order to the dead backend, and the refusal could close a later menu. It now waits for that refusal right after the press. With an injected 2 or 6 ms backend delay it failed 9 of 12 runs before the change and 0 of 48 after.flockwas free. A process that another test forks at that moment (host spawning usespre_exec, so it forks) shares every descriptor until it execs.ipc::lock_after_releasewaits that out for up to 5 seconds and fails on a real holder. Seen once, in a suite-wide injected-delay audit.Testing
With a temporary
tokio::time::sleepinjected before backend futures (not committed):transcript_context_menu_copies_link_destinationsnavigation_loading_keeps_the_header_and_composer_in_placetest_application_vim_escape_assistant_focus_and_plain_command_counttest_application_vim_moves_over_the_semantic_transcript_projectiontest_sidebar_menu_selects_grouping_and_task_ordernew_inner_for_testchange.Not covered
agent-full-macosdoesn't run on PRs withoutci:full. Master's push run and the next nightly will confirm it there.agent-testis the first Linux run.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.