From da246c4c4e23c9ad976705f9a3fa80e0d75b4425 Mon Sep 17 00:00:00 2001 From: soryu Date: Wed, 21 Jan 2026 15:58:34 +0000 Subject: Update CLI to show repo suggestions --- makima/src/bin/makima.rs | 69 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) (limited to 'makima/src/bin') diff --git a/makima/src/bin/makima.rs b/makima/src/bin/makima.rs index f91ceef..29388e1 100644 --- a/makima/src/bin/makima.rs +++ b/makima/src/bin/makima.rs @@ -8,7 +8,7 @@ use makima::daemon::api::{ApiClient, CreateContractRequest}; use makima::daemon::cli::{ Cli, CliConfig, Commands, ConfigCommand, ContractCommand, SupervisorCommand, ViewArgs, }; -use makima::daemon::tui::{self, Action, App, ListItem, ViewType, TuiWsClient, WsEvent, OutputLine, OutputMessageType, WsConnectionState}; +use makima::daemon::tui::{self, Action, App, ListItem, ViewType, TuiWsClient, WsEvent, OutputLine, OutputMessageType, WsConnectionState, RepositorySuggestion}; use makima::daemon::config::{DaemonConfig, RepoEntry}; use makima::daemon::db::LocalDb; use makima::daemon::error::DaemonError; @@ -988,6 +988,73 @@ async fn run_tui_loop( } } } + Action::LoadRepoSuggestions => { + // Load repository suggestions for the create form + app.status_message = Some("Loading recent repositories...".to_string()); + // Force a redraw to show the status + terminal.draw(|f| tui::ui::render(f, app)).ok(); + + // Fetch all repository types (remote and local) + match client.get_repository_suggestions(None, Some(10)).await { + Ok(result) => { + // Parse suggestions from API response + let suggestions: Vec = result.0 + .get("entries") + .and_then(|v| v.as_array()) + .map(|arr| { + arr.iter().filter_map(|entry| { + let name = entry.get("name") + .and_then(|v| v.as_str()) + .unwrap_or("") + .to_string(); + let repository_url = entry.get("repositoryUrl") + .or_else(|| entry.get("repository_url")) + .and_then(|v| v.as_str()) + .map(|s| s.to_string()); + let local_path = entry.get("localPath") + .or_else(|| entry.get("local_path")) + .and_then(|v| v.as_str()) + .map(|s| s.to_string()); + let source_type = entry.get("sourceType") + .or_else(|| entry.get("source_type")) + .and_then(|v| v.as_str()) + .unwrap_or("remote") + .to_string(); + let use_count = entry.get("useCount") + .or_else(|| entry.get("use_count")) + .and_then(|v| v.as_i64()) + .unwrap_or(0) as i32; + + // Only include if we have a URL or path + if repository_url.is_some() || local_path.is_some() { + Some(RepositorySuggestion { + name, + repository_url, + local_path, + source_type, + use_count, + }) + } else { + None + } + }).collect() + }) + .unwrap_or_default(); + + let count = suggestions.len(); + app.create_state.set_suggestions(suggestions); + if count > 0 { + app.status_message = Some(format!("Found {} recent repositories", count)); + } else { + app.status_message = Some("No recent repositories found".to_string()); + } + } + Err(e) => { + app.status_message = Some(format!("Could not load suggestions: {}", e)); + app.create_state.suggestions_loaded = true; + } + } + } _ => {} } } -- cgit v1.2.3