CI / Check (push) Has been skipped
CI / Detect Changes (push) Successful in 3s
CI / Deploy Agent (push) Successful in 8m20s
CI / Deploy Dashboard (push) Successful in 3m13s
CI / Deploy Docs (push) Has been skipped
CI / Deploy MCP (push) Successful in 2m7s
93 lines
4.4 KiB
Rust
93 lines
4.4 KiB
Rust
use dioxus::prelude::*;
|
|
|
|
use crate::app::Route;
|
|
use crate::components::page_header::PageHeader;
|
|
use crate::infrastructure::onboarding::fetch_targets;
|
|
|
|
#[component]
|
|
pub fn ChatIndexPage() -> Element {
|
|
let repos = use_resource(|| async { fetch_targets().await.ok() });
|
|
|
|
rsx! {
|
|
PageHeader {
|
|
title: "AI Chat",
|
|
description: "Ask questions about your codebase using RAG-augmented AI",
|
|
}
|
|
|
|
match &*repos.read() {
|
|
Some(Some(data)) => {
|
|
let repo_list = &data.data;
|
|
if repo_list.is_empty() {
|
|
rsx! {
|
|
div { class: "card",
|
|
p { "No repositories found. Add a repository first." }
|
|
}
|
|
}
|
|
} else {
|
|
rsx! {
|
|
div { class: "graph-index-grid",
|
|
for repo in repo_list {
|
|
{
|
|
let repo_id = repo.get("_id").and_then(|o| o.get("$oid")).and_then(|s| s.as_str()).unwrap_or_default().to_string();
|
|
let name = repo.get("name").and_then(|n| n.as_str()).unwrap_or_default().to_string();
|
|
let url = repo
|
|
.get("artifacts")
|
|
.and_then(|a| a.as_array())
|
|
.and_then(|arr| {
|
|
arr.iter().find(|a| {
|
|
a.get("kind").and_then(|k| k.as_str()) == Some("git_repo")
|
|
})
|
|
})
|
|
.and_then(|a| a.get("source_ref"))
|
|
.and_then(|s| s.as_str())
|
|
.unwrap_or_default()
|
|
.to_string();
|
|
let branch = repo
|
|
.get("artifacts")
|
|
.and_then(|a| a.as_array())
|
|
.and_then(|arr| {
|
|
arr.iter().find_map(|a| {
|
|
a.get("git")
|
|
.and_then(|g| g.get("default_branch"))
|
|
.and_then(|b| b.as_str())
|
|
})
|
|
})
|
|
.unwrap_or("main")
|
|
.to_string();
|
|
rsx! {
|
|
Link {
|
|
to: Route::ChatPage { repo_id },
|
|
class: "graph-repo-card",
|
|
div { class: "graph-repo-card-header",
|
|
div { class: "graph-repo-card-icon", "\u{1F4AC}" }
|
|
h3 { class: "graph-repo-card-name", "{name}" }
|
|
}
|
|
if !url.is_empty() {
|
|
p { class: "graph-repo-card-url", "{url}" }
|
|
}
|
|
div { class: "graph-repo-card-meta",
|
|
span { class: "graph-repo-card-tag",
|
|
"\u{E0A0} {branch}"
|
|
}
|
|
span { class: "graph-repo-card-tag",
|
|
"AI Chat"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
Some(None) => rsx! {
|
|
div { class: "card", p { "Failed to load repositories." } }
|
|
},
|
|
None => rsx! {
|
|
div { class: "loading", "Loading repositories..." }
|
|
},
|
|
}
|
|
}
|
|
}
|