feat: extract driver management into standalone tab page with registry cache

Move driver management (Agent + JDBC) out of the settings dialog into a
dedicated tab page accessible from the top toolbar. Agent drivers are shown
as a compact horizontal list; JDBC plugin/driver management is on a second
tab. Add 5-minute in-memory cache for the agent registry to avoid repeated
GitHub requests on install/uninstall/refresh operations.
This commit is contained in:
t8y2
2026-05-13 11:05:21 +08:00
parent 047e8fc2f1
commit 4d4c8f4224
7 changed files with 527 additions and 218 deletions
+15 -1
View File
@@ -1,12 +1,16 @@
use std::sync::Arc;
use tauri::{Emitter, State};
use tokio::sync::Mutex;
use dbx_core::agent_manager::{AgentDriverInfo, AgentManager, AgentRegistry, InstalledDriver};
use dbx_core::connection::AppState;
const REGISTRY_PATH: &str = "https://github.com/t8y2/dbx-agents/releases/latest/download/agent-registry.json";
static REGISTRY_CACHE: std::sync::LazyLock<Mutex<Option<(std::time::Instant, AgentRegistry)>>> =
std::sync::LazyLock::new(|| Mutex::new(None));
#[tauri::command]
pub async fn list_installed_agents(state: State<'_, Arc<AppState>>) -> Result<Vec<AgentDriverInfo>, String> {
let am = &state.agent_manager;
@@ -153,6 +157,14 @@ pub async fn reinstall_jre(app: tauri::AppHandle, state: State<'_, Arc<AppState>
}
async fn fetch_registry() -> Result<AgentRegistry, String> {
{
let cache = REGISTRY_CACHE.lock().await;
if let Some((ts, reg)) = cache.as_ref() {
if ts.elapsed() < std::time::Duration::from_secs(300) {
return Ok(reg.clone());
}
}
}
let client = reqwest::Client::builder()
.timeout(std::time::Duration::from_secs(10))
.build()
@@ -168,7 +180,9 @@ async fn fetch_registry() -> Result<AgentRegistry, String> {
.and_then(|r| r.error_for_status())
{
Ok(resp) => {
return resp.json().await.map_err(|e| format!("Failed to parse registry: {e}"));
let reg: AgentRegistry = resp.json().await.map_err(|e| format!("Failed to parse registry: {e}"))?;
*REGISTRY_CACHE.lock().await = Some((std::time::Instant::now(), reg.clone()));
return Ok(reg);
}
Err(e) => {
last_err = format!("{e}");