diff options
| author | soryu <soryu@soryu.co> | 2026-02-05 11:10:23 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-02-05 11:10:23 +0000 |
| commit | f1a50b80f3969d150bd1c31edde0aff05369157e (patch) | |
| tree | eef4a1e8ba4012d5ee67cd5dd01d3a7380f215ec /makima/src/db/repository.rs | |
| parent | 5205db1f26cff0b59c567915966ed1dd892ab472 (diff) | |
| download | soryu-f1a50b80f3969d150bd1c31edde0aff05369157e.tar.gz soryu-f1a50b80f3969d150bd1c31edde0aff05369157e.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'makima/src/db/repository.rs')
| -rw-r--r-- | makima/src/db/repository.rs | 42 |
1 files changed, 41 insertions, 1 deletions
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) } |
