diff --git a/crates/db/.sqlx/query-2a57b702e52b3cc9bdbc361267985958b11d4493b01a9ab8daedf5d951422897.json b/crates/db/.sqlx/query-2a57b702e52b3cc9bdbc361267985958b11d4493b01a9ab8daedf5d951422897.json new file mode 100644 index 00000000..51bf5df4 --- /dev/null +++ b/crates/db/.sqlx/query-2a57b702e52b3cc9bdbc361267985958b11d4493b01a9ab8daedf5d951422897.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE workspaces SET updated_at = datetime('now', 'subsec') WHERE id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 1 + }, + "nullable": [] + }, + "hash": "2a57b702e52b3cc9bdbc361267985958b11d4493b01a9ab8daedf5d951422897" +} diff --git a/crates/db/src/models/workspace.rs b/crates/db/src/models/workspace.rs index 57357e7c..0d19d3ef 100644 --- a/crates/db/src/models/workspace.rs +++ b/crates/db/src/models/workspace.rs @@ -223,6 +223,18 @@ impl Workspace { Ok(()) } + /// Update the workspace's updated_at timestamp to prevent cleanup. + /// Call this when the workspace is accessed (e.g., opened in editor). + pub async fn touch(pool: &SqlitePool, workspace_id: Uuid) -> Result<(), sqlx::Error> { + sqlx::query!( + "UPDATE workspaces SET updated_at = datetime('now', 'subsec') WHERE id = ?", + workspace_id + ) + .execute(pool) + .await?; + Ok(()) + } + pub async fn find_by_id(pool: &SqlitePool, id: Uuid) -> Result, sqlx::Error> { sqlx::query_as!( Workspace, diff --git a/crates/local-deployment/src/container.rs b/crates/local-deployment/src/container.rs index 41fc4874..aadb1b02 100644 --- a/crates/local-deployment/src/container.rs +++ b/crates/local-deployment/src/container.rs @@ -968,6 +968,7 @@ impl ContainerService for LocalContainerService { &self, workspace: &Workspace, ) -> Result { + Workspace::touch(&self.db.pool, workspace.id).await?; let repositories = WorkspaceRepo::find_repos_for_workspace(&self.db.pool, workspace.id).await?; diff --git a/crates/server/src/routes/task_attempts.rs b/crates/server/src/routes/task_attempts.rs index 55ec2bd3..92433abd 100644 --- a/crates/server/src/routes/task_attempts.rs +++ b/crates/server/src/routes/task_attempts.rs @@ -245,6 +245,8 @@ pub async fn stream_task_attempt_diff_ws( Extension(workspace): Extension, State(deployment): State, ) -> impl IntoResponse { + let _ = Workspace::touch(&deployment.db().pool, workspace.id).await; + let stats_only = params.stats_only; ws.on_upgrade(move |socket| async move { if let Err(e) = handle_task_attempt_diff_ws(socket, deployment, workspace, stats_only).await @@ -520,6 +522,9 @@ pub async fn open_task_attempt_in_editor( .container() .ensure_container_exists(&workspace) .await?; + + Workspace::touch(&deployment.db().pool, workspace.id).await?; + let workspace_path = Path::new(&container_ref); // For single-repo projects, open from the repo directory