diff --git a/crates/worker-runtime/src/worker_backend.rs b/crates/worker-runtime/src/worker_backend.rs index 4949a899..1fcf9c06 100644 --- a/crates/worker-runtime/src/worker_backend.rs +++ b/crates/worker-runtime/src/worker_backend.rs @@ -1703,11 +1703,7 @@ mod tests { runtime_base: &std::path::Path, working_directory_id: &str, ) -> PathBuf { - runtime_base - .join("working-directories") - .join(working_directory_id) - .join("root") - .join("repo-main") + runtime_base.join(working_directory_id).join("checkout") } #[test] @@ -2008,7 +2004,7 @@ mod tests { let error = runtime.create_worker(request).unwrap_err(); assert!(format!("{error:?}").contains("spawn failed")); - let working_directories_root = runtime_base.path().join("working-directories"); + let working_directories_root = runtime_base.path(); let remaining_entries = fs::read_dir(working_directories_root) .map(|entries| entries.count()) .unwrap_or(0); diff --git a/crates/worker-runtime/src/working_directory.rs b/crates/worker-runtime/src/working_directory.rs index ebbec7fc..10bcd593 100644 --- a/crates/worker-runtime/src/working_directory.rs +++ b/crates/worker-runtime/src/working_directory.rs @@ -10,7 +10,7 @@ use std::process::Command; use std::sync::atomic::{AtomicU64, Ordering}; use std::time::{SystemTime, UNIX_EPOCH}; -const WORKING_DIRECTORIES_DIR: &str = "working-directories"; +const CHECKOUT_DIR: &str = "checkout"; const MATERIALIZATION_RECORD: &str = "materialization.json"; static NEXT_WORKING_DIRECTORY_SEQUENCE: AtomicU64 = AtomicU64::new(0); @@ -200,9 +200,7 @@ impl LocalGitWorktreeMaterializer { } fn working_directory_root(&self, working_directory_id: &str) -> PathBuf { - self.runtime_root - .join(WORKING_DIRECTORIES_DIR) - .join(working_directory_id) + self.runtime_root.join(working_directory_id) } fn corrupted_status(&self, working_directory_id: &str) -> WorkingDirectoryStatus { @@ -346,9 +344,7 @@ impl LocalGitWorktreeMaterializer { .filter(|value| !value.is_empty()); let working_directory_root = self.working_directory_root(&working_directory_id); - let worktree_root = working_directory_root - .join("root") - .join(sanitize_path_component(&request.repository.id)); + let worktree_root = working_directory_root.join(CHECKOUT_DIR); if worktree_root.exists() { return Err(WorkingDirectoryDiagnostic::new( "working_directory_exists", @@ -455,8 +451,7 @@ impl WorkingDirectoryMaterializer for LocalGitWorktreeMaterializer { fn list_working_directories( &self, ) -> Result, WorkingDirectoryDiagnostic> { - let root = self.runtime_root.join(WORKING_DIRECTORIES_DIR); - let entries = match fs::read_dir(&root) { + let entries = match fs::read_dir(&self.runtime_root) { Ok(entries) => entries, Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(Vec::new()), Err(_) => { @@ -800,6 +795,17 @@ mod tests { .unwrap(); assert!(binding.root.starts_with(runtime_root.path())); + assert_eq!( + binding.working_directory_root(), + runtime_root + .path() + .join(&binding.working_directory.id) + .as_path() + ); + assert_eq!( + binding.root(), + binding.working_directory_root().join(CHECKOUT_DIR) + ); assert!(binding.root.join("README.md").exists()); let branch = git_stdout(binding.root(), ["branch", "--show-current"]).unwrap(); assert!( diff --git a/web/workspace/src/lib/workspace/console/model.test.ts b/web/workspace/src/lib/workspace/console/model.test.ts index 9b031f29..d1c5253c 100644 --- a/web/workspace/src/lib/workspace/console/model.test.ts +++ b/web/workspace/src/lib/workspace/console/model.test.ts @@ -323,7 +323,7 @@ Deno.test("projectConsole shows Grep query and caps result preview to five entri Deno.test("projectConsole keeps Grep error detail in the body", () => { const message = - "Tool execution failed: Invalid argument: path is outside allowed scope: /home/hare/.yoi/workdirs/working-directories/0019f5bce74f1000000/root/main/ghq.local/github/openai/codex"; + "Tool execution failed: Invalid argument: path is outside allowed scope: /home/hare/.yoi/workdirs/0019f5bce74f1000000/checkout/ghq.local/github/openai/codex"; const projection = projectConsole([ { eventId: "74",