force WAL sync after session create (#5202)

This commit is contained in:
Jack Amadeo
2025-10-16 11:00:36 -04:00
committed by GitHub
parent ceba54d60c
commit 6c25600356
4 changed files with 17 additions and 14 deletions
@@ -218,7 +218,7 @@ where
.update_provider(provider_arc as Arc<dyn goose::providers::base::Provider>)
.await?;
let mut session = CliSession::new(agent, None, false, None, None, None, None);
let mut session = CliSession::new(agent, None, false, None, None, None, None).await;
let mut error = None;
for message in &messages {
+3 -2
View File
@@ -133,7 +133,7 @@ async fn offer_extension_debugging_help(
}
// Create the debugging session
let mut debug_session = CliSession::new(debug_agent, None, false, None, None, None, None);
let mut debug_session = CliSession::new(debug_agent, None, false, None, None, None, None).await;
// Process the debugging request
println!("{}", style("Analyzing the extension failure...").yellow());
@@ -465,7 +465,8 @@ pub async fn build_session(session_config: SessionBuilderConfig) -> CliSession {
session_config.max_turns,
edit_mode,
session_config.retry_config.clone(),
);
)
.await;
// Add stdio extensions if provided
for extension_str in session_config.extensions {
+5 -9
View File
@@ -119,7 +119,7 @@ pub async fn classify_planner_response(
}
impl CliSession {
pub fn new(
pub async fn new(
agent: Agent,
session_id: Option<String>,
debug: bool,
@@ -129,14 +129,10 @@ impl CliSession {
retry_config: Option<RetryConfig>,
) -> Self {
let messages = if let Some(session_id) = &session_id {
tokio::task::block_in_place(|| {
tokio::runtime::Handle::current().block_on(async {
SessionManager::get_session(session_id, true)
.await
.map(|session| session.conversation.unwrap_or_default())
.unwrap()
})
})
SessionManager::get_session(session_id, true)
.await
.map(|session| session.conversation.unwrap_or_default())
.unwrap()
} else {
Conversation::new_unvalidated(Vec::new())
};
+8 -2
View File
@@ -645,7 +645,7 @@ impl SessionStorage {
async fn create_session(&self, working_dir: PathBuf, description: String) -> Result<Session> {
let today = chrono::Utc::now().format("%Y%m%d").to_string();
Ok(sqlx::query_as(
let session_id = sqlx::query_as(
r#"
INSERT INTO sessions (id, description, working_dir, extension_data)
VALUES (
@@ -666,7 +666,13 @@ impl SessionStorage {
.bind(&description)
.bind(working_dir.to_string_lossy().as_ref())
.fetch_one(&self.pool)
.await?)
.await?;
sqlx::query("PRAGMA wal_checkpoint")
.execute(&self.pool)
.await?;
Ok(session_id)
}
async fn get_session(&self, id: &str, include_messages: bool) -> Result<Session> {