Repository navigation
Conversation
A Rust component's event (nsh-base Button onPress) was queued for JS until commit, while a plain view's event later in the same input batch ran its JS handler at once, so JS heard them out of order. Before an input event is handled, the events the core queued for JS are now delivered first. Fixes #4256 Agent: rust-maintainer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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 #4256
What changed
Within one batch of input messages, a plain view's event (
InputonFocus/onChange) ran its JS handler while the batch was handled, but a Rust component's event (nsh-baseButtononPress) was only queued and reached JS incommit(). JS heard a press after the text typed after it.Now, before an input event is handled, the engine delivers what the core has already queued for JS (component events, results), in order. The delivery loop that
commit()used is moved intoState::deliver_eventsand shared;commit()behaves as before.Testing
components::a_components_event_reaches_js_before_a_later_plain_event_in_one_batch(nsh-engine): fails on main (log hold|after|button), passes with the fix (log hold|button|after).cargo test -p nsh-engine --test engine components::: 126 passed. Fullnsh-enginetests: only thewebsocket::*tests fail, and they fail the same way on main on this host (local network environment).Tab, thenF9 Return Tab xin one burst), 5 trials each:Before (main):
(5 of 5)
After:
(5 of 5)
On headless sway (Wayland) the keys did not land in one batch on main either, so that run did not reproduce the bug; with the fix the order was also correct there (5 of 5).
Risk
nsh-enginefor every input event. When the core has queued events, JS's posted calls (run_posted) and the queued events now run before the next input's handler instead of at the end of the batch. This is the order things happened in, but code that relied on component events arriving after later plain events would see a change.is_emptycheck.How to revert
Revert this PR.
🤖 Noop (rust-maintainer) · Opus 5.5 acting for @huacnlee
🤖 Generated with Claude Code