Repository navigation
Fix start-up races behind the command palette snapshot flakes - #1191
Merged
Merged
Conversation
The Limit checkbox could start checked when no limit was configured: the limit Input's initial Changed reached its handler after the app had set the box, so queries were cut to 500 rows. The Input is now built without posting that message and the box starts in the configured state. The Show Files and Show S3 prompts selected their whole location whenever the input's focus landed after its value was filled in, so a reopened prompt sometimes opened with the path selected. The location input no longer selects on focus. The palette tests now wait for the state their snapshots and assertions read: the theme picker listing only "nord", the location prompt mounted, and the Files tab shown and active. Refs #1190 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M8ADtp77YK31uWbip8tFWd
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.
Refs #1190. This doesn't close it: one of the issue's failure modes is still unexplained. See Still open below.
What are the key elements of this solution?
Two app races, plus test waits that didn't cover the state their snapshots read.
run_query_bar.py,app.py). This is a user-facing bug that shipped. Building the limitInputposts aChangedmessage, andhandle_new_limit_valuechecks the box for any valid value. If that message arrived afterHarlequin.on_mount→apply_configured_limit(), the box ended up checked and queries were cut to the default 500 rows.Inputis now built underself.prevent(Input.Changed), and theCheckboxstarts withvalue=query_limit is not None.apply_configured_limit()is gone.Changed;test_run_query_barcovers both.catalog_source_screen.py). Textual delivers the auto-focusFocusevent as a later message, andInput.select_on_focusdefaults to True. Whenever the value was filled in before that event was handled, all of it ended up selected. That happened both in the app, whereon_mountfills in the current location on reopen, and in the test.select_on_focus = False, matching the history screen's filter input. That also restores what the trailing separator inon_mountis for: the cursor sits after the path, so autocomplete offers what is inside it.test_command_palette.py):submit_locationwaits for the prompt'sis_mounted, sinceon_mountis what createslocation_input.test_show_files_commandwaits for the Files tab to be shown and active as well as listing the directory, instead of asserting the tab state straight after a wait on the listing.Why did you design your solution this way? Did you assess any alternatives? Are there tradeoffs?
wait_for_idle, which approximates Windows, whereprocess_timeticks at about 15.6 ms.hide-tabsassertion intest_show_files_command: 12 failures in 200 fuzzed runs before, 0 after.PathInputin textual-textarea doesn't forwardInputkeywords such asselect_on_focus. Setting Textual's public attribute after construction works today, so an upstream change isn't needed for this fix.Still open
[True, False]on macOS 3.14 and Windows 3.12) isn't root-caused.CommandList-height frame turned up once in about 400 fuzzed runs and couldn't be reproduced since.AUTO_FOCUSandDataCatalog.focus_on_widget_in_active_pane. If the tree handles that focus before the editor mounts,HarlequinTree.on_focussetscursor_line = 0, and the first catalog row stays highlighted.AUTO_FOCUS = ""breakstest_history_screen. It belongs in its own PR.Does this PR require a change to Harlequin's docs?
Did you add or update tests for this change?
test_command_palette.pynow cover the state each snapshot and assertion reads. The existing limit tests (test_a_configured_limit_is_in_force_from_the_first_query,test_no_configured_limit_leaves_the_box_unchecked,test_run_query_bar) still pass. The races are timing-dependent, so they have no deterministic regression test.Please complete the following checklist:
CHANGELOG.md, under the[Unreleased]section heading. That entry references the issue closed by this PR.Generated by Claude Code