ui: store the last selected spoken text when not focused
This commit is contained in:
@@ -31,6 +31,7 @@ pub struct Ui {
|
|||||||
tts: TtsControl,
|
tts: TtsControl,
|
||||||
predictions: SessionControl,
|
predictions: SessionControl,
|
||||||
conversation: Vec<ConversationEntry>,
|
conversation: Vec<ConversationEntry>,
|
||||||
|
last_spoken_idx: Option<usize>,
|
||||||
sfx: SfxControl
|
sfx: SfxControl
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,6 +61,7 @@ impl Ui {
|
|||||||
last_tick: Instant::now(),
|
last_tick: Instant::now(),
|
||||||
conversation: vec![],
|
conversation: vec![],
|
||||||
reply_options: Default::default(),
|
reply_options: Default::default(),
|
||||||
|
last_spoken_idx: None,
|
||||||
sfx
|
sfx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,6 +214,7 @@ impl Ui {
|
|||||||
match key.code {
|
match key.code {
|
||||||
KeyCode::Tab => {
|
KeyCode::Tab => {
|
||||||
self.focus_state = FocusState::UserInput;
|
self.focus_state = FocusState::UserInput;
|
||||||
|
self.last_spoken_idx = self.conversation_state.selected();
|
||||||
self.conversation_state.select(None);
|
self.conversation_state.select(None);
|
||||||
self.reply_state.select_first();
|
self.reply_state.select_first();
|
||||||
},
|
},
|
||||||
@@ -227,6 +230,7 @@ impl Ui {
|
|||||||
self.tts.speak(text.clone()).await.unwrap();
|
self.tts.speak(text.clone()).await.unwrap();
|
||||||
self.sfx.play_ambient().await.unwrap();
|
self.sfx.play_ambient().await.unwrap();
|
||||||
self.focus_state = FocusState::UserInput;
|
self.focus_state = FocusState::UserInput;
|
||||||
|
self.last_spoken_idx = self.conversation_state.selected();
|
||||||
self.conversation_state.select(None);
|
self.conversation_state.select(None);
|
||||||
self.reply_state.select_first();
|
self.reply_state.select_first();
|
||||||
}
|
}
|
||||||
@@ -238,7 +242,7 @@ impl Ui {
|
|||||||
match key.code {
|
match key.code {
|
||||||
KeyCode::Tab => {
|
KeyCode::Tab => {
|
||||||
self.focus_state = FocusState::Conversation;
|
self.focus_state = FocusState::Conversation;
|
||||||
self.conversation_state.select_first();
|
self.conversation_state.select(self.last_spoken_idx);
|
||||||
self.reply_state.select(None);
|
self.reply_state.select(None);
|
||||||
},
|
},
|
||||||
KeyCode::Char('r') if key.modifiers.contains(KeyModifiers::CONTROL) => self.predictions.regenerate_options().await,
|
KeyCode::Char('r') if key.modifiers.contains(KeyModifiers::CONTROL) => self.predictions.regenerate_options().await,
|
||||||
|
|||||||
Reference in New Issue
Block a user