Run setup script in parallel with coding agent (vibe-kanban) (#1446)

* The implementation is complete. Here's a summary of all the changes made:

## Summary

### Files Created
- `crates/db/migrations/20251206000000_add_parallel_setup_script_to_projects.sql` - Database migration

### Files Modified

**Backend (Rust):**
- `crates/db/src/models/project.rs` - Added `parallel_setup_script: bool` field to `Project`, `Option<bool>` to `CreateProject`/`UpdateProject`, updated all SQL queries
- `crates/services/src/services/container.rs` - Modified `start_attempt()` to support parallel execution when `parallel_setup_script` is true
- `crates/server/src/routes/projects.rs` - Updated create/update handlers to include new field
- `crates/deployment/src/lib.rs` - Added field to auto-created projects

**Frontend (TypeScript/React):**
- `frontend/src/pages/settings/ProjectSettings.tsx` - Added checkbox UI for parallel setup script setting
- `frontend/src/components/dialogs/projects/ProjectFormDialog.tsx` - Added field to create data
- `frontend/src/components/tasks/TaskDetails/preview/NoServerContent.tsx` - Added field to update data

**i18n:**
- `frontend/src/i18n/locales/en/settings.json` - Added translation strings
- `frontend/src/i18n/locales/es/settings.json` - Added Spanish translations
- `frontend/src/i18n/locales/ja/settings.json` - Added Japanese translations
- `frontend/src/i18n/locales/ko/settings.json` - Added Korean translations

**SQLx Cache:**
- `crates/db/.sqlx/` - Updated query cache files

### Behavior
- When `parallel_setup_script` is `false` (default): Sequential execution (setup → coding agent → cleanup)
- When `parallel_setup_script` is `true`: Setup script and coding agent start simultaneously, setup script failure does not stop the coding agent

* update useConversationHistory to display multiple running conversation threads at once

* The bug fix is complete. Here's a summary of the changes:

## Bug Fix Summary

**Problem:** When running in parallel mode, if the setup script finishes before the coding agent, the task incorrectly moves to "InReview" status while the coding agent is still running.

**Root Cause:** The `should_finalize()` method returned `true` when `next_action.is_none()`, which is the case for setup scripts in parallel mode. This caused premature task finalization.

**Solution:** Modified `should_finalize()` to check if there are other running non-DevServer processes for the same task attempt before finalizing.

### Files Modified

1. **`crates/db/src/models/execution_process.rs`**
   - Added `has_running_non_dev_server_processes_excluding()` method that accepts an optional `exclude_id` parameter
   - Refactored existing `has_running_non_dev_server_processes()` to delegate to the new method

2. **`crates/services/src/services/container.rs`**
   - Changed `should_finalize()` from sync to async
   - Added check for other running processes before allowing finalization

3. **`crates/local-deployment/src/container.rs`**
   - Updated call site to use `.await` on the now-async `should_finalize()`

* The bug fix is complete. Here's a summary of the changes:

**Fixed files:**

1. **`crates/services/src/services/container.rs`** - Simplified `should_finalize()`:
   - Changed from `async fn` back to `fn` (non-async)
   - Removed the complex database check for other running processes
   - Added a simple check: if the run_reason is `SetupScript` AND `next_action.is_none()` (parallel mode), return `false` (don't finalize)

2. **`crates/local-deployment/src/container.rs`** - Removed `.await` from the `should_finalize()` call

3. **`crates/db/src/models/execution_process.rs`** - Cleaned up by removing the unused `has_running_non_dev_server_processes_excluding()` function and simplifying `has_running_non_dev_server_processes()` back to its original form

**How the fix works:**

- In **parallel mode**: Setup scripts have `next_action: None`, so the new check catches this case and prevents finalization
- In **sequential mode**: Setup scripts have `next_action: Some(coding_agent)`, so they pass this check but won't finalize anyway because `next_action.is_none()` returns `false`
This commit is contained in:
Louis Knight-Webb
2025-12-07 15:25:13 +00:00
committed by GitHub
parent 7da884bc3a
commit 76877ea631
23 changed files with 275 additions and 107 deletions

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "SELECT id as \"id!: Uuid\",\n name,\n git_repo_path,\n setup_script,\n dev_script,\n cleanup_script,\n copy_files,\n remote_project_id as \"remote_project_id: Uuid\",\n created_at as \"created_at!: DateTime<Utc>\",\n updated_at as \"updated_at!: DateTime<Utc>\"\n FROM projects\n WHERE git_repo_path = $1 AND id != $2",
"query": "SELECT id as \"id!: Uuid\",\n name,\n git_repo_path,\n setup_script,\n dev_script,\n cleanup_script,\n copy_files,\n parallel_setup_script as \"parallel_setup_script!: bool\",\n remote_project_id as \"remote_project_id: Uuid\",\n created_at as \"created_at!: DateTime<Utc>\",\n updated_at as \"updated_at!: DateTime<Utc>\"\n FROM projects\n WHERE git_repo_path = $1 AND id != $2",
"describe": {
"columns": [
{
@@ -39,18 +39,23 @@
"type_info": "Text"
},
{
"name": "remote_project_id: Uuid",
"name": "parallel_setup_script!: bool",
"ordinal": 7,
"type_info": "Integer"
},
{
"name": "remote_project_id: Uuid",
"ordinal": 8,
"type_info": "Blob"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 8,
"ordinal": 9,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 9,
"ordinal": 10,
"type_info": "Text"
}
],
@@ -65,10 +70,11 @@
true,
true,
true,
false,
true,
false,
false
]
},
"hash": "3c370bbd5b58c1e5de1ca4799c7fe2b3202173a9211c2d1493d79d93493754a3"
"hash": "1394d6317296aa95af82b78e038e40a929ad163d4986208bfebb243ed7372199"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "SELECT id as \"id!: Uuid\",\n name,\n git_repo_path,\n setup_script,\n dev_script,\n cleanup_script,\n copy_files,\n remote_project_id as \"remote_project_id: Uuid\",\n created_at as \"created_at!: DateTime<Utc>\",\n updated_at as \"updated_at!: DateTime<Utc>\"\n FROM projects\n WHERE id = $1",
"query": "SELECT id as \"id!: Uuid\",\n name,\n git_repo_path,\n setup_script,\n dev_script,\n cleanup_script,\n copy_files,\n parallel_setup_script as \"parallel_setup_script!: bool\",\n remote_project_id as \"remote_project_id: Uuid\",\n created_at as \"created_at!: DateTime<Utc>\",\n updated_at as \"updated_at!: DateTime<Utc>\"\n FROM projects\n WHERE remote_project_id = $1\n LIMIT 1",
"describe": {
"columns": [
{
@@ -39,18 +39,23 @@
"type_info": "Text"
},
{
"name": "remote_project_id: Uuid",
"name": "parallel_setup_script!: bool",
"ordinal": 7,
"type_info": "Integer"
},
{
"name": "remote_project_id: Uuid",
"ordinal": 8,
"type_info": "Blob"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 8,
"ordinal": 9,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 9,
"ordinal": 10,
"type_info": "Text"
}
],
@@ -65,10 +70,11 @@
true,
true,
true,
false,
true,
false,
false
]
},
"hash": "a6ee0cb1535be5f414429a26c1534afa3f859f87c291b33769049b922ab8ff86"
"hash": "46139a0b9debe5889e7d35b3cf9b20edec27573bb555a66fbb27cd78161392af"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "UPDATE projects\n SET name = $2,\n git_repo_path = $3,\n setup_script = $4,\n dev_script = $5,\n cleanup_script = $6,\n copy_files = $7\n WHERE id = $1\n RETURNING id as \"id!: Uuid\",\n name,\n git_repo_path,\n setup_script,\n dev_script,\n cleanup_script,\n copy_files,\n remote_project_id as \"remote_project_id: Uuid\",\n created_at as \"created_at!: DateTime<Utc>\",\n updated_at as \"updated_at!: DateTime<Utc>\"",
"query": "UPDATE projects\n SET name = $2,\n git_repo_path = $3,\n setup_script = $4,\n dev_script = $5,\n cleanup_script = $6,\n copy_files = $7,\n parallel_setup_script = $8\n WHERE id = $1\n RETURNING id as \"id!: Uuid\",\n name,\n git_repo_path,\n setup_script,\n dev_script,\n cleanup_script,\n copy_files,\n parallel_setup_script as \"parallel_setup_script!: bool\",\n remote_project_id as \"remote_project_id: Uuid\",\n created_at as \"created_at!: DateTime<Utc>\",\n updated_at as \"updated_at!: DateTime<Utc>\"",
"describe": {
"columns": [
{
@@ -39,23 +39,28 @@
"type_info": "Text"
},
{
"name": "remote_project_id: Uuid",
"name": "parallel_setup_script!: bool",
"ordinal": 7,
"type_info": "Integer"
},
{
"name": "remote_project_id: Uuid",
"ordinal": 8,
"type_info": "Blob"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 8,
"ordinal": 9,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 9,
"ordinal": 10,
"type_info": "Text"
}
],
"parameters": {
"Right": 7
"Right": 8
},
"nullable": [
true,
@@ -65,10 +70,11 @@
true,
true,
true,
false,
true,
false,
false
]
},
"hash": "2d49b016e3d5872a71d07525a9d15637c9799e8918f125058413028ecb931a5c"
"hash": "59f5b5a5d4ec2a614c039fb84ecf5081e7ec23ef0fef7cfe2b60ec9fc9d69d18"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "SELECT id as \"id!: Uuid\",\n name,\n git_repo_path,\n setup_script,\n dev_script,\n cleanup_script,\n copy_files,\n remote_project_id as \"remote_project_id: Uuid\",\n created_at as \"created_at!: DateTime<Utc>\",\n updated_at as \"updated_at!: DateTime<Utc>\"\n FROM projects\n WHERE remote_project_id = $1\n LIMIT 1",
"query": "SELECT id as \"id!: Uuid\",\n name,\n git_repo_path,\n setup_script,\n dev_script,\n cleanup_script,\n copy_files,\n parallel_setup_script as \"parallel_setup_script!: bool\",\n remote_project_id as \"remote_project_id: Uuid\",\n created_at as \"created_at!: DateTime<Utc>\",\n updated_at as \"updated_at!: DateTime<Utc>\"\n FROM projects\n WHERE git_repo_path = $1",
"describe": {
"columns": [
{
@@ -39,18 +39,23 @@
"type_info": "Text"
},
{
"name": "remote_project_id: Uuid",
"name": "parallel_setup_script!: bool",
"ordinal": 7,
"type_info": "Integer"
},
{
"name": "remote_project_id: Uuid",
"ordinal": 8,
"type_info": "Blob"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 8,
"ordinal": 9,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 9,
"ordinal": 10,
"type_info": "Text"
}
],
@@ -65,10 +70,11 @@
true,
true,
true,
false,
true,
false,
false
]
},
"hash": "2330097afa4816aaf7d98e083eac80558ecb9a355384e5076aa744fab27d2f7e"
"hash": "5ab2baf9bee3fb408b31e8ce408220b741ca5e6fac93e71f93a14fb345c6c704"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "SELECT id as \"id!: Uuid\",\n name,\n git_repo_path,\n setup_script,\n dev_script,\n cleanup_script,\n copy_files,\n remote_project_id as \"remote_project_id: Uuid\",\n created_at as \"created_at!: DateTime<Utc>\",\n updated_at as \"updated_at!: DateTime<Utc>\"\n FROM projects\n ORDER BY created_at DESC",
"query": "SELECT id as \"id!: Uuid\",\n name,\n git_repo_path,\n setup_script,\n dev_script,\n cleanup_script,\n copy_files,\n parallel_setup_script as \"parallel_setup_script!: bool\",\n remote_project_id as \"remote_project_id: Uuid\",\n created_at as \"created_at!: DateTime<Utc>\",\n updated_at as \"updated_at!: DateTime<Utc>\"\n FROM projects\n ORDER BY created_at DESC",
"describe": {
"columns": [
{
@@ -39,18 +39,23 @@
"type_info": "Text"
},
{
"name": "remote_project_id: Uuid",
"name": "parallel_setup_script!: bool",
"ordinal": 7,
"type_info": "Integer"
},
{
"name": "remote_project_id: Uuid",
"ordinal": 8,
"type_info": "Blob"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 8,
"ordinal": 9,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 9,
"ordinal": 10,
"type_info": "Text"
}
],
@@ -65,10 +70,11 @@
true,
true,
true,
false,
true,
false,
false
]
},
"hash": "24fc0f4f51e4080aebf6131c47eb241ef5c35440b23cfa712311692143be53f3"
"hash": "5ae74dcee62a835018743862b2beceb7231696a0775ba2f144a0b1ecc8bfd56d"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "INSERT INTO projects (\n id,\n name,\n git_repo_path,\n setup_script,\n dev_script,\n cleanup_script,\n copy_files\n ) VALUES (\n $1, $2, $3, $4, $5, $6, $7\n )\n RETURNING id as \"id!: Uuid\",\n name,\n git_repo_path,\n setup_script,\n dev_script,\n cleanup_script,\n copy_files,\n remote_project_id as \"remote_project_id: Uuid\",\n created_at as \"created_at!: DateTime<Utc>\",\n updated_at as \"updated_at!: DateTime<Utc>\"",
"query": "INSERT INTO projects (\n id,\n name,\n git_repo_path,\n setup_script,\n dev_script,\n cleanup_script,\n copy_files,\n parallel_setup_script\n ) VALUES (\n $1, $2, $3, $4, $5, $6, $7, $8\n )\n RETURNING id as \"id!: Uuid\",\n name,\n git_repo_path,\n setup_script,\n dev_script,\n cleanup_script,\n copy_files,\n parallel_setup_script as \"parallel_setup_script!: bool\",\n remote_project_id as \"remote_project_id: Uuid\",\n created_at as \"created_at!: DateTime<Utc>\",\n updated_at as \"updated_at!: DateTime<Utc>\"",
"describe": {
"columns": [
{
@@ -39,23 +39,28 @@
"type_info": "Text"
},
{
"name": "remote_project_id: Uuid",
"name": "parallel_setup_script!: bool",
"ordinal": 7,
"type_info": "Integer"
},
{
"name": "remote_project_id: Uuid",
"ordinal": 8,
"type_info": "Blob"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 8,
"ordinal": 9,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 9,
"ordinal": 10,
"type_info": "Text"
}
],
"parameters": {
"Right": 7
"Right": 8
},
"nullable": [
true,
@@ -65,10 +70,11 @@
true,
true,
true,
false,
true,
false,
false
]
},
"hash": "18a4eb409f5d5ea419c98fabcfaa024126074d3b29202195c6e3b12a75c32338"
"hash": "921d5710f2e19167d69b60da029246dfce714f1fc57d6625dd752b7aa644b497"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "SELECT id as \"id!: Uuid\",\n name,\n git_repo_path,\n setup_script,\n dev_script,\n cleanup_script,\n copy_files,\n remote_project_id as \"remote_project_id: Uuid\",\n created_at as \"created_at!: DateTime<Utc>\",\n updated_at as \"updated_at!: DateTime<Utc>\"\n FROM projects\n WHERE git_repo_path = $1",
"query": "SELECT id as \"id!: Uuid\",\n name,\n git_repo_path,\n setup_script,\n dev_script,\n cleanup_script,\n copy_files,\n parallel_setup_script as \"parallel_setup_script!: bool\",\n remote_project_id as \"remote_project_id: Uuid\",\n created_at as \"created_at!: DateTime<Utc>\",\n updated_at as \"updated_at!: DateTime<Utc>\"\n FROM projects\n WHERE id = $1",
"describe": {
"columns": [
{
@@ -39,18 +39,23 @@
"type_info": "Text"
},
{
"name": "remote_project_id: Uuid",
"name": "parallel_setup_script!: bool",
"ordinal": 7,
"type_info": "Integer"
},
{
"name": "remote_project_id: Uuid",
"ordinal": 8,
"type_info": "Blob"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 8,
"ordinal": 9,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 9,
"ordinal": 10,
"type_info": "Text"
}
],
@@ -65,10 +70,11 @@
true,
true,
true,
false,
true,
false,
false
]
},
"hash": "c53e0af00938e45ba437e81cdb6c3e3d5d0ccaf7122c3830d9935dd10111ea70"
"hash": "cff3d8c29c20cb7ddf3c9ba4c7f8a1191a60dacd760f5c711a947b3454735945"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "\n SELECT p.id as \"id!: Uuid\", p.name, p.git_repo_path, p.setup_script, p.dev_script, p.cleanup_script, p.copy_files, \n p.remote_project_id as \"remote_project_id: Uuid\",\n p.created_at as \"created_at!: DateTime<Utc>\", p.updated_at as \"updated_at!: DateTime<Utc>\"\n FROM projects p\n WHERE p.id IN (\n SELECT DISTINCT t.project_id\n FROM tasks t\n INNER JOIN task_attempts ta ON ta.task_id = t.id\n ORDER BY ta.updated_at DESC\n )\n LIMIT $1\n ",
"query": "\n SELECT p.id as \"id!: Uuid\", p.name, p.git_repo_path, p.setup_script, p.dev_script, p.cleanup_script, p.copy_files,\n p.parallel_setup_script as \"parallel_setup_script!: bool\",\n p.remote_project_id as \"remote_project_id: Uuid\",\n p.created_at as \"created_at!: DateTime<Utc>\", p.updated_at as \"updated_at!: DateTime<Utc>\"\n FROM projects p\n WHERE p.id IN (\n SELECT DISTINCT t.project_id\n FROM tasks t\n INNER JOIN task_attempts ta ON ta.task_id = t.id\n ORDER BY ta.updated_at DESC\n )\n LIMIT $1\n ",
"describe": {
"columns": [
{
@@ -39,18 +39,23 @@
"type_info": "Text"
},
{
"name": "remote_project_id: Uuid",
"name": "parallel_setup_script!: bool",
"ordinal": 7,
"type_info": "Integer"
},
{
"name": "remote_project_id: Uuid",
"ordinal": 8,
"type_info": "Blob"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 8,
"ordinal": 9,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 9,
"ordinal": 10,
"type_info": "Text"
}
],
@@ -65,10 +70,11 @@
true,
true,
true,
false,
true,
false,
false
]
},
"hash": "4c8cc854d7f9ff93fb86a5a1a99cb99c86c50e062281bf3e52e2ebc6537192f0"
"hash": "e82f7fc1672ff56df544cc59fec2dba6d739d11567965be2cf3a1ca99beccae2"
}

View File

@@ -0,0 +1,3 @@
-- Add parallel_setup_script column to projects table
-- When true, setup script runs in parallel with coding agent instead of sequentially
ALTER TABLE projects ADD COLUMN parallel_setup_script INTEGER NOT NULL DEFAULT 0;

View File

@@ -30,6 +30,7 @@ pub struct Project {
pub dev_script: Option<String>,
pub cleanup_script: Option<String>,
pub copy_files: Option<String>,
pub parallel_setup_script: bool,
pub remote_project_id: Option<Uuid>,
#[ts(type = "Date")]
pub created_at: DateTime<Utc>,
@@ -46,6 +47,7 @@ pub struct CreateProject {
pub dev_script: Option<String>,
pub cleanup_script: Option<String>,
pub copy_files: Option<String>,
pub parallel_setup_script: Option<bool>,
}
#[derive(Debug, Deserialize, TS)]
@@ -56,6 +58,7 @@ pub struct UpdateProject {
pub dev_script: Option<String>,
pub cleanup_script: Option<String>,
pub copy_files: Option<String>,
pub parallel_setup_script: Option<bool>,
}
#[derive(Debug, Serialize, TS)]
@@ -89,6 +92,7 @@ impl Project {
dev_script,
cleanup_script,
copy_files,
parallel_setup_script as "parallel_setup_script!: bool",
remote_project_id as "remote_project_id: Uuid",
created_at as "created_at!: DateTime<Utc>",
updated_at as "updated_at!: DateTime<Utc>"
@@ -104,7 +108,8 @@ impl Project {
sqlx::query_as!(
Project,
r#"
SELECT p.id as "id!: Uuid", p.name, p.git_repo_path, p.setup_script, p.dev_script, p.cleanup_script, p.copy_files,
SELECT p.id as "id!: Uuid", p.name, p.git_repo_path, p.setup_script, p.dev_script, p.cleanup_script, p.copy_files,
p.parallel_setup_script as "parallel_setup_script!: bool",
p.remote_project_id as "remote_project_id: Uuid",
p.created_at as "created_at!: DateTime<Utc>", p.updated_at as "updated_at!: DateTime<Utc>"
FROM projects p
@@ -132,6 +137,7 @@ impl Project {
dev_script,
cleanup_script,
copy_files,
parallel_setup_script as "parallel_setup_script!: bool",
remote_project_id as "remote_project_id: Uuid",
created_at as "created_at!: DateTime<Utc>",
updated_at as "updated_at!: DateTime<Utc>"
@@ -156,6 +162,7 @@ impl Project {
dev_script,
cleanup_script,
copy_files,
parallel_setup_script as "parallel_setup_script!: bool",
remote_project_id as "remote_project_id: Uuid",
created_at as "created_at!: DateTime<Utc>",
updated_at as "updated_at!: DateTime<Utc>"
@@ -181,6 +188,7 @@ impl Project {
dev_script,
cleanup_script,
copy_files,
parallel_setup_script as "parallel_setup_script!: bool",
remote_project_id as "remote_project_id: Uuid",
created_at as "created_at!: DateTime<Utc>",
updated_at as "updated_at!: DateTime<Utc>"
@@ -206,6 +214,7 @@ impl Project {
dev_script,
cleanup_script,
copy_files,
parallel_setup_script as "parallel_setup_script!: bool",
remote_project_id as "remote_project_id: Uuid",
created_at as "created_at!: DateTime<Utc>",
updated_at as "updated_at!: DateTime<Utc>"
@@ -223,6 +232,7 @@ impl Project {
data: &CreateProject,
project_id: Uuid,
) -> Result<Self, sqlx::Error> {
let parallel_setup_script = data.parallel_setup_script.unwrap_or(false);
sqlx::query_as!(
Project,
r#"INSERT INTO projects (
@@ -232,9 +242,10 @@ impl Project {
setup_script,
dev_script,
cleanup_script,
copy_files
copy_files,
parallel_setup_script
) VALUES (
$1, $2, $3, $4, $5, $6, $7
$1, $2, $3, $4, $5, $6, $7, $8
)
RETURNING id as "id!: Uuid",
name,
@@ -243,6 +254,7 @@ impl Project {
dev_script,
cleanup_script,
copy_files,
parallel_setup_script as "parallel_setup_script!: bool",
remote_project_id as "remote_project_id: Uuid",
created_at as "created_at!: DateTime<Utc>",
updated_at as "updated_at!: DateTime<Utc>""#,
@@ -253,6 +265,7 @@ impl Project {
data.dev_script,
data.cleanup_script,
data.copy_files,
parallel_setup_script,
)
.fetch_one(pool)
.await
@@ -268,6 +281,7 @@ impl Project {
dev_script: Option<String>,
cleanup_script: Option<String>,
copy_files: Option<String>,
parallel_setup_script: bool,
) -> Result<Self, sqlx::Error> {
sqlx::query_as!(
Project,
@@ -277,7 +291,8 @@ impl Project {
setup_script = $4,
dev_script = $5,
cleanup_script = $6,
copy_files = $7
copy_files = $7,
parallel_setup_script = $8
WHERE id = $1
RETURNING id as "id!: Uuid",
name,
@@ -286,6 +301,7 @@ impl Project {
dev_script,
cleanup_script,
copy_files,
parallel_setup_script as "parallel_setup_script!: bool",
remote_project_id as "remote_project_id: Uuid",
created_at as "created_at!: DateTime<Utc>",
updated_at as "updated_at!: DateTime<Utc>""#,
@@ -296,6 +312,7 @@ impl Project {
dev_script,
cleanup_script,
copy_files,
parallel_setup_script,
)
.fetch_one(pool)
.await

View File

@@ -166,6 +166,7 @@ pub trait Deployment: Clone + Send + Sync + 'static {
dev_script: None,
cleanup_script: None,
copy_files: None,
parallel_setup_script: None,
};
// Ensure existing repo has a main branch if it's empty
if let Err(e) = self.git().ensure_main_branch_exists(&repo.path) {

View File

@@ -205,6 +205,7 @@ pub async fn create_project(
dev_script,
cleanup_script,
copy_files,
parallel_setup_script,
use_existing_repo,
} = payload;
tracing::debug!("Creating project '{}'", name);
@@ -292,6 +293,7 @@ pub async fn create_project(
dev_script,
cleanup_script,
copy_files,
parallel_setup_script,
},
id,
)
@@ -333,6 +335,7 @@ pub async fn update_project(
dev_script,
cleanup_script,
copy_files,
parallel_setup_script,
} = payload;
// If git_repo_path is being changed, check if the new path is already used by another project
let git_repo_path = if let Some(new_git_repo_path) = git_repo_path.map(|s| expand_tilde(&s))
@@ -369,6 +372,7 @@ pub async fn update_project(
dev_script,
cleanup_script,
copy_files,
parallel_setup_script.unwrap_or(existing_project.parallel_setup_script),
)
.await
{

View File

@@ -123,14 +123,29 @@ pub trait ContainerService {
/// A context is finalized when
/// - Always when the execution process has failed or been killed
/// - Never when the run reason is DevServer
/// - Never when a setup script has no next_action (parallel mode)
/// - The next action is None (no follow-up actions)
fn should_finalize(&self, ctx: &ExecutionContext) -> bool {
// Never finalize DevServer processes
if matches!(
ctx.execution_process.run_reason,
ExecutionProcessRunReason::DevServer
) {
return false;
}
// Never finalize setup scripts without a next_action (parallel mode).
// In sequential mode, setup scripts have next_action pointing to coding agent,
// so they won't finalize anyway (handled by next_action.is_none() check below).
let action = ctx.execution_process.executor_action().unwrap();
if matches!(
ctx.execution_process.run_reason,
ExecutionProcessRunReason::SetupScript
) && action.next_action.is_none()
{
return false;
}
// Always finalize failed or killed executions, regardless of next action
if matches!(
ctx.execution_process.status,
@@ -138,12 +153,9 @@ pub trait ContainerService {
) {
return true;
}
// Otherwise, finalize only if no next action
ctx.execution_process
.executor_action()
.unwrap()
.next_action
.is_none()
action.next_action.is_none()
}
/// Finalize task execution by updating status to InReview and sending notifications
@@ -670,32 +682,74 @@ pub trait ContainerService {
let prompt = task.to_prompt();
let cleanup_action = self.cleanup_action(project.cleanup_script);
let cleanup_action = self.cleanup_action(project.cleanup_script.clone());
// Choose whether to execute the setup_script or coding agent first
let execution_process = if let Some(setup_script) = project.setup_script {
let executor_action = ExecutorAction::new(
ExecutorActionType::ScriptRequest(ScriptRequest {
script: setup_script,
language: ScriptRequestLanguage::Bash,
context: ScriptContext::SetupScript,
}),
// once the setup script is done, run the initial coding agent request
Some(Box::new(ExecutorAction::new(
if project.parallel_setup_script {
// PARALLEL EXECUTION: Start setup script and coding agent independently
// Setup script runs without next_action (it completes on its own)
let setup_action = ExecutorAction::new(
ExecutorActionType::ScriptRequest(ScriptRequest {
script: setup_script,
language: ScriptRequestLanguage::Bash,
context: ScriptContext::SetupScript,
}),
None, // No chaining - runs independently
);
// Start setup script (ignore errors - coding agent will start regardless)
if let Err(e) = self
.start_execution(
&task_attempt,
&setup_action,
&ExecutionProcessRunReason::SetupScript,
)
.await
{
tracing::warn!(?e, "Failed to start setup script in parallel mode");
}
// Start coding agent independently with cleanup as next_action
let coding_action = ExecutorAction::new(
ExecutorActionType::CodingAgentInitialRequest(CodingAgentInitialRequest {
prompt,
executor_profile_id: executor_profile_id.clone(),
}),
cleanup_action,
))),
);
);
self.start_execution(
&task_attempt,
&executor_action,
&ExecutionProcessRunReason::SetupScript,
)
.await?
self.start_execution(
&task_attempt,
&coding_action,
&ExecutionProcessRunReason::CodingAgent,
)
.await?
} else {
// SEQUENTIAL EXECUTION: Setup script runs first, then coding agent
let executor_action = ExecutorAction::new(
ExecutorActionType::ScriptRequest(ScriptRequest {
script: setup_script,
language: ScriptRequestLanguage::Bash,
context: ScriptContext::SetupScript,
}),
// once the setup script is done, run the initial coding agent request
Some(Box::new(ExecutorAction::new(
ExecutorActionType::CodingAgentInitialRequest(CodingAgentInitialRequest {
prompt,
executor_profile_id: executor_profile_id.clone(),
}),
cleanup_action,
))),
);
self.start_execution(
&task_attempt,
&executor_action,
&ExecutionProcessRunReason::SetupScript,
)
.await?
}
} else {
let executor_action = ExecutorAction::new(
ExecutorActionType::CodingAgentInitialRequest(CodingAgentInitialRequest {