From 566217b00ac91a14d1c6c5fbf8f4dbd0b7b8ddf6 Mon Sep 17 00:00:00 2001 From: onlyyu1996 <1158673577@qq.com> Date: Mon, 18 May 2026 16:48:45 +0800 Subject: [PATCH] Clear TUI input when starting new session --- src/cortex-tui/src/app/methods.rs | 1 + src/cortex-tui/src/runner/handlers/tests.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/cortex-tui/src/app/methods.rs b/src/cortex-tui/src/app/methods.rs index 6156596ee..cf9cdcf27 100644 --- a/src/cortex-tui/src/app/methods.rs +++ b/src/cortex-tui/src/app/methods.rs @@ -87,6 +87,7 @@ impl AppState { pub fn new_session(&mut self) { self.session_id = Some(Uuid::new_v4()); self.clear_messages(); + self.input.clear(); self.set_view(AppView::Session); } diff --git a/src/cortex-tui/src/runner/handlers/tests.rs b/src/cortex-tui/src/runner/handlers/tests.rs index 045fa6ddc..ec4ada685 100644 --- a/src/cortex-tui/src/runner/handlers/tests.rs +++ b/src/cortex-tui/src/runner/handlers/tests.rs @@ -166,12 +166,14 @@ async fn test_handle_submit_empty() { async fn test_handle_new_session() { let mut state = create_test_state(); let mut stream = create_test_stream(); + state.input.set_text("hello from old session"); let result = run_action(&mut state, &mut stream, KeyAction::NewSession).await; assert!(result.is_ok()); assert!(result.unwrap()); assert!(state.session_id.is_some()); assert_eq!(state.view, AppView::Session); + assert!(state.input.text().is_empty()); } #[tokio::test]