diff options
| author | soryu <soryu@soryu.co> | 2026-02-13 00:57:34 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-02-13 00:57:34 +0000 |
| commit | 639b4c6bc3b3964c00cdfc64c4f262c61ee22fc7 (patch) | |
| tree | 6ba4c1cd323f728453b95e19b9215e40974d1377 /makima/src/db | |
| parent | 39df770ea4ae37f3f9e30c5be5274b741e7ecf7b (diff) | |
| download | soryu-639b4c6bc3b3964c00cdfc64c4f262c61ee22fc7.tar.gz soryu-639b4c6bc3b3964c00cdfc64c4f262c61ee22fc7.zip | |
Make sure directive tasks inherit worktrees
Diffstat (limited to 'makima/src/db')
| -rw-r--r-- | makima/src/db/repository.rs | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/makima/src/db/repository.rs b/makima/src/db/repository.rs index a79818f..51f49cd 100644 --- a/makima/src/db/repository.rs +++ b/makima/src/db/repository.rs @@ -5298,6 +5298,30 @@ pub async fn get_completed_step_tasks( .await } +/// Get the task ID of the most recently completed step for a directive. +/// Used as a fallback `continue_from_task_id` when dispatching new-generation steps +/// that have no explicit dependencies and no PR branch to continue from. +pub async fn get_last_completed_step_task_id( + pool: &PgPool, + directive_id: Uuid, +) -> Result<Option<Uuid>, sqlx::Error> { + let row: Option<(Uuid,)> = sqlx::query_as( + r#" + SELECT ds.task_id + FROM directive_steps ds + WHERE ds.directive_id = $1 + AND ds.status = 'completed' + AND ds.task_id IS NOT NULL + ORDER BY ds.updated_at DESC + LIMIT 1 + "#, + ) + .bind(directive_id) + .fetch_optional(pool) + .await?; + Ok(row.map(|r| r.0)) +} + // ============================================================================= // Directive Step CRUD // ============================================================================= @@ -5586,6 +5610,8 @@ pub struct StepForDispatch { pub repository_url: Option<String>, pub base_branch: Option<String>, pub memory_enabled: bool, + /// The directive's PR branch (if a PR has already been created from previous steps). + pub pr_branch: Option<String>, } /// Get ready steps that need task dispatch. @@ -5607,7 +5633,8 @@ pub async fn get_ready_steps_for_dispatch( d.title AS directive_title, d.repository_url, d.base_branch, - d.memory_enabled + d.memory_enabled, + d.pr_branch FROM directive_steps ds JOIN directives d ON d.id = ds.directive_id WHERE ds.status = 'ready' |
