summaryrefslogtreecommitdiff
path: root/makima/src/bin/makima.rs
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-21 15:58:34 +0000
committersoryu <soryu@soryu.co>2026-01-21 15:58:34 +0000
commitda246c4c4e23c9ad976705f9a3fa80e0d75b4425 (patch)
treeddc3b93ed269e60dac1aa9113000daeac4a1b6e6 /makima/src/bin/makima.rs
parent7155e6cd7ddf25a5a4d4f6d6abecd49f0cf519dc (diff)
downloadsoryu-da246c4c4e23c9ad976705f9a3fa80e0d75b4425.tar.gz
soryu-da246c4c4e23c9ad976705f9a3fa80e0d75b4425.zip
Update CLI to show repo suggestions
Diffstat (limited to 'makima/src/bin/makima.rs')
-rw-r--r--makima/src/bin/makima.rs69
1 files changed, 68 insertions, 1 deletions
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<RepositorySuggestion> = 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;
+ }
+ }
+ }
_ => {}
}
}