feat: better session creation handling
This commit is contained in:
@@ -51,7 +51,7 @@ impl From<StoredMessage> for ChatMessage {
|
||||
|
||||
impl App {
|
||||
pub(super) fn start_generation(&mut self) {
|
||||
if self.generating || self.selected_session.is_none() {
|
||||
if self.generating || self.selected_project.is_none() {
|
||||
return;
|
||||
}
|
||||
let prompt = self.composer.trim().to_owned();
|
||||
@@ -78,9 +78,6 @@ impl App {
|
||||
}
|
||||
};
|
||||
let assistant_reasoning = effective.turn.reasoning_mode != ReasoningMode::Direct;
|
||||
let session_id = self
|
||||
.selected_session
|
||||
.expect("a selected session was checked");
|
||||
#[cfg(target_os = "macos")]
|
||||
let mut messages = self
|
||||
.conversation
|
||||
@@ -104,6 +101,22 @@ impl App {
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
// A draft session only reaches the database once there is a turn to store.
|
||||
let session_id = match self.selected_session {
|
||||
Some(session_id) => session_id,
|
||||
None => {
|
||||
let Some(project_id) = self.selected_project else {
|
||||
return;
|
||||
};
|
||||
match self.persist_session(project_id) {
|
||||
Ok(session_id) => session_id,
|
||||
Err(error) => {
|
||||
self.error = Some(format!("Could not create the session: {error}"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let Some(service) = &self.generation_service else {
|
||||
self.error = Some("The model runtime is unavailable.".into());
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user