Phase 10 - Refactoring: Input actor creation#186
Draft
lorenzoberts wants to merge 3 commits into
Draft
Conversation
This commit introduces the public interface of the Input actor without any implementation. It adds InputError, InputMessage (SubscribeApp, UpdateContext, Shutdown), and InputHandle (cloneable mpsc wrapper with subscribe_app, update_context, and shutdown async methods). This commit is part of the architecture's refactoring phase 10. Signed-off-by: lorenzoberts <lorenzobs@usp.br>
…ping This commit introduces InputActor, the mediator between the Terminal actor and the App. The actor spawns a dedicated pump subtask that polls the terminal via terminal_handle.poll_event(50ms) in a loop, buffering raw TerminalEvent values into an internal channel. The main actor loop selects between control messages (SubscribeApp, UpdateContext, Shutdown) and buffered terminal events, mapping each event through InputMapper with the current InputContext before delivering it to the single registered subscriber. A dedicated subtask is used for polling rather than selecting directly on the poll_event future, so that an in-flight poll is never abandoned mid-read when a control message arrives. Abandoning it would silently discard an event already consumed from the OS queue by the TerminalActor. This commit is part of the architecture's refactoring phase 10. Signed-off-by: lorenzoberts <lorenzobs@usp.br>
This commit wires the InputActor into the application runtime, completing the Terminal → Input → App data flow introduced in phase 10. InputActor is spawned in main with the TerminalHandle and the initial InputContext, and an mpsc channel is created for the App to receive already-mapped InputEvent values. The run_app entry point is updated to accept the InputHandle and the App-side receiver instead of performing event reads directly. The pull loop that called terminal_handle.read_event() and ran InputMapper inline is replaced by app_input_rx.recv().await, which blocks until the InputActor delivers a translated event. After handling each event, run_app sends an updated InputContext back to the actor so the next terminal event is mapped with current application state. The loading spinner, all per-screen dispatch functions, and the wait_for_key_press interactive path are unchanged. This commit completes the architecture's refactoring phase 10. Signed-off-by: lorenzoberts <lorenzobs@usp.br>
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.
No description provided.