Skip to content

Fix flaky login provider picker focus assertion (#410)#416

Merged
alejandro-ao merged 8 commits into
huggingface:mainfrom
vizansh:fix-flaky-tui-focus
Jul 21, 2026
Merged

Fix flaky login provider picker focus assertion (#410)#416
alejandro-ao merged 8 commits into
huggingface:mainfrom
vizansh:fix-flaky-tui-focus

Conversation

@vizansh

@vizansh vizansh commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Resolves #410.

This PR implements the second approach outlined in the issue to fix the flaky focus assertion on the login provider picker screen:

Separation of Concerns: Removed the flaky assert search.has_focus check from the data filtering test (test_tui_login_api_provider_picker_filters_by_name_and_display_name), as filtering behavior doesn't rely on focus states. Changed pilot.pause() calls to pilot.wait_for_scheduled_animations() to flush asynchronous filter events reliably.

Dedicated Focus Test: Added a dedicated autofocus test (test_tui_login_provider_search_autofocus) that utilizes native event flushing to test focus state behavior independently.

The isolated tests passed completely clean locally across consecutive test runs.

cc @ShreyanshVaibhaw — since this issue primarily popped up on your environment, could you check out this branch and verify if it permanently kills the flake on your machine?

Bash

git fetch origin
git checkout fix-flaky-tui-focus
uv run pytest "tests/test_tui_app.py::test_tui_login_api_provider_picker_filters_by_name_and_display_name"
uv run pytest "tests/test_tui_app.py::test_tui_login_provider_search_autofocus"
#original test :-
uv run pytest "tests/test_tui_app.py::test_tui_login_api_provider_picker_filters_by_name_and_display_name" -q

@vizansh
vizansh requested a review from alejandro-ao as a code owner July 20, 2026 14:16

@alejandro-ao alejandro-ao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed in an isolated worktree (see prior review). Test-only change; wait_for_scheduled_animations() is a correct, stronger flush than pause() under Textual 8.2.8; no coverage loss. Re-ran the two affected tests 10x plus the full login subset — all green. Full CI parity (pytest 1053 passed, ruff, format, mypy) verified locally after merging latest main into the branch.

@alejandro-ao alejandro-ao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approving after branch sync with latest main (daab3b9). Content unchanged from prior approval; CI green, login subset re-verified locally.

@alejandro-ao alejandro-ao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approving after sync with main (8c45bff). CI green; change content identical to prior approvals.

@alejandro-ao
alejandro-ao merged commit e3b7d2d into huggingface:main Jul 21, 2026
2 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.

Flaky test: login provider picker focus assertion fails intermittently (~50% on Windows)

2 participants