feat: add API connection state management and update status display
This commit is contained in:
@@ -295,6 +295,7 @@ pub fn apply_action(state: &mut AppStateRest, action: Action) {
|
||||
match event {
|
||||
TurnEvent::AssistantMessage(msg) => {
|
||||
state.misc.thinking = false;
|
||||
state.misc.api_connected = true;
|
||||
let display_content = msg.content.clone().unwrap_or_default();
|
||||
if !display_content.is_empty() {
|
||||
state.push_transcript(ChatMessageDisplay::new(Role::Assistant, display_content));
|
||||
@@ -366,6 +367,7 @@ pub fn apply_action(state: &mut AppStateRest, action: Action) {
|
||||
}
|
||||
TurnEvent::StreamStart => {
|
||||
state.misc.thinking = false;
|
||||
state.misc.api_connected = true;
|
||||
state.push_transcript(ChatMessageDisplay::new(Role::Assistant, String::new()));
|
||||
}
|
||||
TurnEvent::StreamToken(delta) => {
|
||||
@@ -390,6 +392,7 @@ pub fn apply_action(state: &mut AppStateRest, action: Action) {
|
||||
}
|
||||
}
|
||||
TurnEvent::Error(msg) => {
|
||||
state.misc.api_connected = false;
|
||||
let long_toast = Toast {
|
||||
kind: ToastKind::Error,
|
||||
message: msg.clone(),
|
||||
@@ -468,6 +471,9 @@ fn spawn_turn(state: &AppStateRest) {
|
||||
.unwrap_or_default();
|
||||
}
|
||||
}
|
||||
if api_key.is_empty() {
|
||||
api_key = crate::service::provider::DEFAULT_API_KEY.to_string();
|
||||
}
|
||||
let (temperature, max_tokens) = crate::app::mode::effort::generation_params(
|
||||
state.misc.effort_level,
|
||||
state.settings.max_tokens,
|
||||
|
||||
Reference in New Issue
Block a user