summaryrefslogtreecommitdiff
path: root/makima/src/db
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-02-05 11:10:23 +0000
committersoryu <soryu@soryu.co>2026-02-05 11:10:23 +0000
commitf1a50b80f3969d150bd1c31edde0aff05369157e (patch)
treeeef4a1e8ba4012d5ee67cd5dd01d3a7380f215ec /makima/src/db
parent5205db1f26cff0b59c567915966ed1dd892ab472 (diff)
downloadsoryu-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')
-rw-r--r--makima/src/db/models.rs2
-rw-r--r--makima/src/db/repository.rs42
2 files changed, 43 insertions, 1 deletions
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<Utc>,
}
/// 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)
}