Skip to content

Phase 10 - Refactoring: Input actor creation#186

Draft
lorenzoberts wants to merge 3 commits into
lorenzo/actor-refactor-phase-9from
lorenzo/actor-refactor-phase-10
Draft

Phase 10 - Refactoring: Input actor creation#186
lorenzoberts wants to merge 3 commits into
lorenzo/actor-refactor-phase-9from
lorenzo/actor-refactor-phase-10

Conversation

@lorenzoberts

Copy link
Copy Markdown
Collaborator

No description provided.

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>
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.

1 participant