From f1a50b80f3969d150bd1c31edde0aff05369157e Mon Sep 17 00:00:00 2001 From: soryu Date: Thu, 5 Feb 2026 11:10:23 +0000 Subject: Add repository selection to chain creation modal - Update CreateChainModal to include repository input fields - Add repository suggestions from history using getRepositorySuggestions - Support both remote (URL) and local (path) repositories - First repository added becomes primary automatically - Pass repositories to CreateChainRequest Also includes backend changes: - Copy chain repositories to contracts when created from definitions - Add created_at field to ChainContractDetail Co-Authored-By: Claude Opus 4.5 --- makima/src/db/models.rs | 2 ++ makima/src/db/repository.rs | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) (limited to 'makima/src/db') diff --git a/makima/src/db/models.rs b/makima/src/db/models.rs index 392d019..e861f1d 100644 --- a/makima/src/db/models.rs +++ b/makima/src/db/models.rs @@ -2825,6 +2825,8 @@ pub struct ChainContractDetail { /// Maximum evaluation retry attempts #[sqlx(default)] pub max_evaluation_retries: i32, + /// When the chain contract was created + pub created_at: DateTime, } /// DAG graph structure for visualization diff --git a/makima/src/db/repository.rs b/makima/src/db/repository.rs index 9cb653f..7be7bc8 100644 --- a/makima/src/db/repository.rs +++ b/makima/src/db/repository.rs @@ -5162,7 +5162,8 @@ pub async fn list_chain_contracts( cc.editor_y, cc.evaluation_status, cc.evaluation_retry_count, - cc.max_evaluation_retries + cc.max_evaluation_retries, + cc.created_at FROM chain_contracts cc JOIN contracts c ON c.id = cc.contract_id WHERE cc.chain_id = $1 @@ -6266,6 +6267,45 @@ async fn create_contract_from_definition( .execute(pool) .await?; + // Copy repositories from chain to contract + let chain_repos = list_chain_repositories(pool, chain_id).await.unwrap_or_default(); + for repo in chain_repos { + if let Some(url) = &repo.repository_url { + // Remote repository + if let Err(e) = add_remote_repository(pool, contract.id, &repo.name, url, repo.is_primary).await { + tracing::warn!( + contract_id = %contract.id, + repo_name = %repo.name, + error = %e, + "Failed to copy repository from chain to contract" + ); + } + } else if let Some(path) = &repo.local_path { + // Local repository + if let Err(e) = add_local_repository(pool, contract.id, &repo.name, path, repo.is_primary).await { + tracing::warn!( + contract_id = %contract.id, + repo_name = %repo.name, + error = %e, + "Failed to copy local repository from chain to contract" + ); + } + } + } + + // Activate the contract so it can start + sqlx::query("UPDATE contracts SET status = 'active' WHERE id = $1") + .bind(contract.id) + .execute(pool) + .await?; + + tracing::info!( + contract_id = %contract.id, + contract_name = %def.name, + chain_id = %chain_id, + "Contract created and activated from chain definition" + ); + Ok(contract.id) } -- cgit v1.2.3