summaryrefslogtreecommitdiff
path: root/makima/src/daemon/tui/event.rs
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-20 00:23:49 +0000
committersoryu <soryu@soryu.co>2026-01-20 00:23:49 +0000
commit5d8e3f80254f20eb6672701fad5f116a3b05dbc3 (patch)
tree02cc73bd49a416112c9dd7f21c480c156068827c /makima/src/daemon/tui/event.rs
parent9aac84bb20c4ca73f113fe74b9a293e4d20cdc93 (diff)
downloadsoryu-5d8e3f80254f20eb6672701fad5f116a3b05dbc3.tar.gz
soryu-5d8e3f80254f20eb6672701fad5f116a3b05dbc3.zip
Fix: auth for CLI and CLI SIGTERM
Diffstat (limited to 'makima/src/daemon/tui/event.rs')
-rw-r--r--makima/src/daemon/tui/event.rs96
1 files changed, 87 insertions, 9 deletions
diff --git a/makima/src/daemon/tui/event.rs b/makima/src/daemon/tui/event.rs
index 12a6890..0e3874b 100644
--- a/makima/src/daemon/tui/event.rs
+++ b/makima/src/daemon/tui/event.rs
@@ -3,7 +3,7 @@
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyModifiers};
use std::time::Duration;
-use super::app::{Action, App, InputMode};
+use super::app::{Action, App, InputMode, ViewType};
/// Poll for events with timeout
pub fn poll_event(timeout: Duration) -> std::io::Result<Option<Event>> {
@@ -16,10 +16,16 @@ pub fn poll_event(timeout: Duration) -> std::io::Result<Option<Event>> {
/// Handle a key event and return the resulting action
pub fn handle_key_event(app: &App, key: KeyEvent) -> Action {
+ // Special handling for TaskOutput view
+ if app.view_type == ViewType::TaskOutput && app.input_mode == InputMode::Normal {
+ return handle_output_mode(key);
+ }
+
match app.input_mode {
InputMode::Normal => handle_normal_mode(key),
InputMode::Search => handle_search_mode(key),
InputMode::Confirm => handle_confirm_mode(key),
+ InputMode::EditName | InputMode::EditDescription => handle_edit_mode(key),
}
}
@@ -38,23 +44,29 @@ fn handle_normal_mode(key: KeyEvent) -> Action {
KeyCode::Up | KeyCode::Char('k') => Action::Up,
KeyCode::Down | KeyCode::Char('j') => Action::Down,
- // Actions
- KeyCode::Enter => Action::Select,
+ // Drill-down into selected item (Enter or l for vim-style)
+ KeyCode::Enter | KeyCode::Char('l') => Action::DrillDown,
+
+ // Go back (Backspace, h for vim-style, or Esc)
+ KeyCode::Backspace | KeyCode::Char('h') => Action::GoBack,
+
+ // Other actions
KeyCode::Char('e') => Action::Edit,
KeyCode::Char('d') => Action::Delete,
KeyCode::Char('c') => Action::Navigate, // cd to worktree
+ // Preview toggle (space to show details in preview pane)
+ KeyCode::Char(' ') => Action::Select,
+
// Search
KeyCode::Char('/') => Action::EnterSearch,
- // Preview toggle (space to toggle preview visibility)
- KeyCode::Char(' ') => Action::Select,
-
// Refresh
KeyCode::Char('r') => Action::Refresh,
- // Quit
- KeyCode::Char('q') | KeyCode::Esc => Action::Quit,
+ // Quit (only q, Esc now goes back)
+ KeyCode::Char('q') => Action::Quit,
+ KeyCode::Esc => Action::GoBack,
_ => Action::None,
}
@@ -108,11 +120,77 @@ fn handle_confirm_mode(key: KeyEvent) -> Action {
}
}
+/// Handle key events in task output view mode
+fn handle_output_mode(key: KeyEvent) -> Action {
+ // Check for Ctrl+C first
+ if key.modifiers.contains(KeyModifiers::CONTROL) {
+ if let KeyCode::Char('c') = key.code {
+ return Action::Quit;
+ }
+ }
+
+ match key.code {
+ // Scroll
+ KeyCode::Up | KeyCode::Char('k') => Action::ScrollUp,
+ KeyCode::Down | KeyCode::Char('j') => Action::ScrollDown,
+ KeyCode::PageUp => Action::ScrollUp,
+ KeyCode::PageDown => Action::ScrollDown,
+
+ // Scroll to bottom
+ KeyCode::Char('G') | KeyCode::End => Action::ScrollToBottom,
+
+ // Go back (Backspace, h for vim-style, q, or Esc)
+ KeyCode::Backspace | KeyCode::Char('h') | KeyCode::Esc => Action::GoBack,
+ KeyCode::Char('q') => Action::GoBack,
+
+ // Refresh (re-connect WebSocket)
+ KeyCode::Char('r') => Action::Refresh,
+
+ // Navigate to worktree
+ KeyCode::Char('c') => Action::Navigate,
+
+ _ => Action::None,
+ }
+}
+
+/// Handle key events in edit mode
+fn handle_edit_mode(key: KeyEvent) -> Action {
+ // Check for Ctrl+C first
+ if key.modifiers.contains(KeyModifiers::CONTROL) {
+ if let KeyCode::Char('c') = key.code {
+ return Action::Quit;
+ }
+ }
+
+ match key.code {
+ // Save
+ KeyCode::Enter => Action::EditSave,
+
+ // Cancel
+ KeyCode::Esc => Action::EditCancel,
+
+ // Switch fields
+ KeyCode::Tab => Action::EditNextField,
+
+ // Text input
+ KeyCode::Char(c) => Action::EditChar(c),
+ KeyCode::Backspace => Action::EditBackspace,
+
+ _ => Action::None,
+ }
+}
+
/// Get help text for current mode
pub fn get_help_text(mode: InputMode) -> &'static str {
match mode {
- InputMode::Normal => "j/k: navigate | Enter: details | e: edit | d: delete | c: cd | /: search | q: quit",
+ InputMode::Normal => "j/k: nav | Enter: open | Esc/h: back | e: edit | d: del | c: cd | /: search | q: quit",
InputMode::Search => "Type to search | Enter/Esc: exit search | Up/Down: navigate",
InputMode::Confirm => "y: confirm | n/Esc: cancel",
+ InputMode::EditName | InputMode::EditDescription => "Type to edit | Tab: switch field | Enter: save | Esc: cancel",
}
}
+
+/// Get help text for output view
+pub fn get_output_help_text() -> &'static str {
+ "j/k: scroll | G: bottom | c: cd | q/Esc: back | r: refresh"
+}