Conversation
|
it would be better to actual raise an issue and then link a PR with the fix to the issue. Folks who come search for similar problems will most likely search in the issues rather than past PRs. |
|
Based on the description I assume this is LLM generated. |
|
Hi @svartkanin! Sorry for the LLM jump scare 😄 Now on replication, the best way is to :
Once you get the hang of it, it's easy to replicate. 2 key things I have noticed :
The reason for the bugs I think is due to the event handler always assuming that the SelectionList is present in the DOM whenever an event fires, so it just throws the To fix that my |
|
Thanks for the explanation I was able to replicate it and confirm the fix |
|
The mypy check is failing |
This comment was marked as outdated.
This comment was marked as outdated.
|
I've kept on digging on this issue, trying to fix those To fix this issue I added a slight delay between each of the operations and also refactored the code to fire the operations only on batches of keystrokes. The delay is minimal, at 60ms (best performance I found while testing), and can be tuned later if needed. |
|
Hey was just checking this out. I'm wondering if it's not overdoing it. I.e adding debounce, and empty-clear when really the issue is just the guard. Can you try something like: diff --git a/archinstall/tui/components.py b/archinstall/tui/components.py
index 75cb82be..a7076331 100644
--- a/archinstall/tui/components.py
+++ b/archinstall/tui/components.py
@@ -332,6 +332,10 @@ class OptionListScreen(BaseScreen[ValueT]):
self.query_one(OptionList).focus()
def on_input_changed(self, event: Input.Changed) -> None:
+ # late Changed from fast typing can land after dismiss
+ if not self.is_current:
+ return
+
search_term = event.value.lower()
self._group.set_filter_pattern(search_term)
filtered_options = self._get_options()
@@ -581,6 +585,10 @@ class SelectListScreen(BaseScreen[ValueT]):
_ = self.dismiss(Result(ResultType.Selection, _item=self._selected_items))
def on_input_changed(self, event: Input.Changed) -> None:
+ # late Changed from fast typing can land after dismiss
+ if not self.is_current:
+ return
+
search_term = event.value.lower()
self._group.set_filter_pattern(search_term)
filtered_options = self._get_selections()This uses only built-in |
|
Hi @h8d13, appreciate the effort!
I still think we do need the debouncing to fix this, but I am open to suggestions. |
|
I'm guessing that you might want to try how much you can reduce the patch size for it to be "fixed". What I mean is that from the 75+ -11 LoC, how much is critical for your fix and how much is "nice-to-have". If that makes sense ? What I learned from contributing here is that the smaller the patches, the faster you'll get them reviewed and merged. Nice trick: You can add to the current url here It might need all of it, I'm just saying maybe also parts aren't needed? |
|
Hi @svartkanin. Could you take another look at the latest commits, and approve the CI checks to run on them? |
|
As pointed out by @h8d13 this patch size has now significantly increase from it's original submission. I'll have to check the full impact and all cases. I'm very much not a fan of introducing any timers with randomly chosen timeouts to fix this. This is either a logic problem in archinstall or a bug in textual, the prior one can be addressed properly in the second instance it should be reported upstream |
|
Hi @svartkanin. What my current fix does:
I’m opening a PR upstream in Textual to fix the handler directly, but having this patch in archinstall keeps our menus safe in the meantime. Let me know if everything's fine! Edit : PRs are restricted to collaborators only on texual, so idk what to do. |
Problem :
If a keystroke arrives during
SelectionListtransition or screen dismissal, an unhandledNoMatchesexception is thrown, causingarchinstallto crash:Replication :
Additional packagesmenu.backspacewhen the menu is transitioning.Reasons for the problem I figured :
NoMatchesexception ifSelectionListis not visible in DOM. (First assumption)Additional packagesI figured that the main reason for the crash could have been the_update_options(...)being called over every single keystroke, which did the entire search cycle offiltering-->sorting-->widgeton every key press by calling_group.get_focused_index(...).Which is expensive on larger lists and due to keystrokes overlapping the cycle queries the system crashed.
note : This issue was already marked in the
menu_item.pybut I think was never guarded against.Fix :
query_onecalls on key events._update_optionsby adding a slight delay (60ms, was found to be best in testing) on the event inon_input_changed. The delay is minuscule and doesn't really affect the overall UI experience.