Skip to content

Commit 566217b

Browse files
committed
Clear TUI input when starting new session
1 parent 7954d02 commit 566217b

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

src/cortex-tui/src/app/methods.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ impl AppState {
8787
pub fn new_session(&mut self) {
8888
self.session_id = Some(Uuid::new_v4());
8989
self.clear_messages();
90+
self.input.clear();
9091
self.set_view(AppView::Session);
9192
}
9293

src/cortex-tui/src/runner/handlers/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,14 @@ async fn test_handle_submit_empty() {
166166
async fn test_handle_new_session() {
167167
let mut state = create_test_state();
168168
let mut stream = create_test_stream();
169+
state.input.set_text("hello from old session");
169170

170171
let result = run_action(&mut state, &mut stream, KeyAction::NewSession).await;
171172
assert!(result.is_ok());
172173
assert!(result.unwrap());
173174
assert!(state.session_id.is_some());
174175
assert_eq!(state.view, AppView::Session);
176+
assert!(state.input.text().is_empty());
175177
}
176178

177179
#[tokio::test]

0 commit comments

Comments
 (0)