aboutsummaryrefslogtreecommitdiffstats
path: root/crates/atuin-ai/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/atuin-ai/src')
-rw-r--r--crates/atuin-ai/src/tui/components/atuin_ai.rs6
-rw-r--r--crates/atuin-ai/src/tui/components/input_box.rs24
2 files changed, 10 insertions, 20 deletions
diff --git a/crates/atuin-ai/src/tui/components/atuin_ai.rs b/crates/atuin-ai/src/tui/components/atuin_ai.rs
index 680b93ed..b2239a70 100644
--- a/crates/atuin-ai/src/tui/components/atuin_ai.rs
+++ b/crates/atuin-ai/src/tui/components/atuin_ai.rs
@@ -7,7 +7,7 @@
use std::sync::mpsc;
use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
-use eye_declare::{Component, EventResult, Hooks, impl_slot_children};
+use eye_declare::{Component, EventResult, Hooks, Tracked, impl_slot_children};
use crate::tui::events::AiTuiEvent;
use crate::tui::state::AppMode;
@@ -67,7 +67,9 @@ impl Component for AtuinAi {
0
}
- fn handle_event(&self, event: &Event, state: &mut Self::State) -> EventResult {
+ fn handle_event_capture(&self, event: &Event, state: &mut Tracked<Self::State>) -> EventResult {
+ let state = state.read();
+
let Event::Key(KeyEvent {
code,
kind: KeyEventKind::Press,
diff --git a/crates/atuin-ai/src/tui/components/input_box.rs b/crates/atuin-ai/src/tui/components/input_box.rs
index fd8132f4..3167ecc1 100644
--- a/crates/atuin-ai/src/tui/components/input_box.rs
+++ b/crates/atuin-ai/src/tui/components/input_box.rs
@@ -9,7 +9,7 @@
use std::sync::{Mutex, mpsc};
use crossterm::event::KeyModifiers;
-use eye_declare::{Component, EventResult, Hooks};
+use eye_declare::{Component, EventResult, Hooks, Tracked};
use ratatui::widgets::{Block, Borders, Padding};
use ratatui_core::{
buffer::Buffer,
@@ -153,8 +153,10 @@ impl Component for InputBox {
fn handle_event(
&self,
event: &crossterm::event::Event,
- state: &mut Self::State,
+ state: &mut Tracked<Self::State>,
) -> EventResult {
+ let state = state.read();
+
if !self.active {
return EventResult::Ignored;
}
@@ -170,13 +172,6 @@ impl Component for InputBox {
return EventResult::Ignored;
}
- // Let Ctrl+C bubble up to AtuinAi for exit handling
- if key.modifiers.contains(KeyModifiers::CONTROL)
- && key.code == crossterm::event::KeyCode::Char('c')
- {
- return EventResult::Ignored;
- }
-
let mut textarea = state.textarea.lock().unwrap();
match key.code {
@@ -192,25 +187,18 @@ impl Component for InputBox {
return EventResult::Consumed;
} else {
let text = textarea.lines().join("\n");
- textarea.clear();
-
if text.trim().is_empty() {
return EventResult::Ignored;
}
+ textarea.clear();
+
if let Some(ref tx) = state.tx {
let _ = tx.send(AiTuiEvent::SubmitInput(text));
}
return EventResult::Consumed;
}
}
- crossterm::event::KeyCode::Tab => {
- return EventResult::Ignored;
- }
- // Esc: bubble up to app
- crossterm::event::KeyCode::Esc => {
- return EventResult::Ignored;
- }
_ => {}
}