(
session: &AgentSession,
store: &Arc<dyn SessionStore>,
data: SessionData,
)
| 201 | } |
| 202 | |
| 203 | pub(super) fn restore_persisted_session_state( |
| 204 | session: &AgentSession, |
| 205 | store: &Arc<dyn SessionStore>, |
| 206 | data: SessionData, |
| 207 | ) -> Result<()> { |
| 208 | let session_id = data.id.clone(); |
| 209 | *write_or_recover(&session.history) = data.messages; |
| 210 | |
| 211 | if let Some(artifacts) = load_artifacts(store, &session_id)? { |
| 212 | let target_store = session.tool_executor.artifact_store(); |
| 213 | for artifact in artifacts.artifacts() { |
| 214 | target_store.put(artifact); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | if let Some(events) = load_trace_events(store, &session_id)? { |
| 219 | session.trace_sink.replace_events(events); |
| 220 | } |
| 221 | |
| 222 | if let Some(records) = load_run_records(store, &session_id)? { |
| 223 | if let Ok(handle) = tokio::runtime::Handle::try_current() { |
| 224 | tokio::task::block_in_place(|| { |
| 225 | handle.block_on(session.run_store.replace_records(records)) |
| 226 | }); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | if let Some(reports) = load_verification_reports(store, &session_id)? { |
| 231 | *write_or_recover(&session.verification_reports) = reports; |
| 232 | } |
| 233 | |
| 234 | if let Some(tasks) = load_subagent_tasks(store, &session_id)? { |
| 235 | if let Ok(handle) = tokio::runtime::Handle::try_current() { |
| 236 | tokio::task::block_in_place(|| { |
| 237 | handle.block_on(session.subagent_tasks.replace_snapshots(tasks)) |
| 238 | }); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | Ok(()) |
| 243 | } |
| 244 | |
| 245 | struct SessionDataSnapshotInput<'a> { |
| 246 | session_id: &'a str, |
no test coverage detected