From 2f702ad446fcd6a261a3bea0ab2807d70eca43e2 Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Tue, 21 Apr 2026 13:07:27 -0700 Subject: refactor: Replace ad-hoc dispatch with FSM + driver architecture (#3434) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the tangled dispatch handler system (`tui/dispatch.rs`, `tui/state.rs`) with a pure finite state machine + driver architecture. The FSM handles all state transitions as explicit `(State, Event) → (NewState, Effects)` mappings. The driver executes IO effects and bridges the TUI to the FSM. --- crates/atuin-ai/src/tui/components/select.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'crates/atuin-ai/src/tui/components/select.rs') diff --git a/crates/atuin-ai/src/tui/components/select.rs b/crates/atuin-ai/src/tui/components/select.rs index 5abbe655..771d7830 100644 --- a/crates/atuin-ai/src/tui/components/select.rs +++ b/crates/atuin-ai/src/tui/components/select.rs @@ -1,10 +1,9 @@ -use std::sync::mpsc; - use crossterm::event::KeyCode; use eye_declare::{Elements, EventResult, Hooks, Span, Text, View, component, element, props}; use ratatui::style::Style; use typed_builder::TypedBuilder; +use crate::commands::inline::DriverEventSender; use crate::tui::events::AiTuiEvent; type OnSelectFn = Box Option + Send + Sync + 'static>; @@ -24,7 +23,7 @@ pub(crate) struct SelectOption { #[derive(Default)] pub(crate) struct PermissionSelectorState { selected_option: usize, - tx: Option>, + tx: Option, } #[props] @@ -42,7 +41,7 @@ pub(crate) fn permission_selector( hooks.use_focusable(true); hooks.use_autofocus(); - hooks.use_context::>(|tx, _, state| { + hooks.use_context::(|tx, _, state| { state.tx = tx.cloned(); }); -- cgit v1.3.1