Discard archived session checkpoints

This commit is contained in:
Georg Bauer
2026-07-28 19:20:10 +02:00
parent 74c5948955
commit eaa2fcfe42
5 changed files with 154 additions and 20 deletions

View File

@@ -613,7 +613,13 @@ impl App {
}
}
};
let Some(service) = &self.generation_service else {
let archived_session = self
.projects
.iter()
.flat_map(|project| &project.sessions)
.find(|session| session.id == session_id)
.is_some_and(|session| session.state() == SessionState::Archived);
let Some(service) = self.generation_service.clone() else {
self.error = Some("The model runtime is unavailable.".into());
return;
};
@@ -633,6 +639,13 @@ impl App {
return;
}
};
if archived_session {
self.reload_projects();
self.context_notice = Some(
"Rebuilding context: the session was archived and its checkpoint was discarded."
.into(),
);
}
let user_id = saved[saved.len() - 2].id;
self.active_turn
.get_or_insert_with(TurnSummary::new)
@@ -1643,6 +1656,12 @@ impl App {
} else {
None
};
let archived_session = self
.projects
.iter()
.flat_map(|project| &project.sessions)
.find(|session| session.id == session_id)
.is_some_and(|session| session.state() == SessionState::Archived);
let tail_start = message_ids.get(compacted.tail_start).copied();
let messages = self
.database
@@ -1659,7 +1678,9 @@ impl App {
.map_err(|error| format!("Could not save compacted conversation: {error}"))?;
self.conversation
.extend(messages.into_iter().map(ChatMessage::from));
if let Some(session) = self
if archived_session {
self.reload_projects();
} else if let Some(session) = self
.projects
.iter_mut()
.flat_map(|project| &mut project.sessions)