25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(driver): prioritize running runtimes
t8y28f6a8b5b13d3
diff --git a/crates/dbx-core/src/driver_runtime.rs b/crates/dbx-core/src/driver_runtime.rsindex 4512afd3f0..89e017c6a3 100644--- a/crates/dbx-core/src/driver_runtime.rs+++ b/crates/dbx-core/src/driver_runtime.rs@@ -215,16 +215,32 @@ async fn collect_runtime_seeds(state: &AppState) -> Vec<RuntimeSeed> {}let mut output = seeds.into_values().collect::<Vec<_>>();- output.sort_by(|left, right| {- left.kind- .cmp(&right.kind)- .then(left.label.cmp(&right.label))- .then(left.source.cmp(&right.source))- .then(left.id.cmp(&right.id))- });+ sort_runtime_seeds(&mut output);output}+fn sort_runtime_seeds(runtimes: &mut [RuntimeSeed]) {+ runtimes.sort_by(|left, right| {+ // Active runtimes are the primary operational focus; preserve the+ // existing deterministic order within active and inactive groups.+ runtime_activity_rank(&left.status).cmp(&runtime_activity_rank(&right.status)).then(+ left.kind+ .cmp(&right.kind)+ .then(left.label.cmp(&right.label))+ .then(left.source.cmp(&right.source))+ .then(left.id.cmp(&right.id)),+ )+ });+}++fn runtime_activity_rank(status: &str) -> u8 {+ if status == "running" {+ 0+ } else {+ 1+ }+}+async fn collect_process_stats(pids: HashSet<u32>) -> HashMap<u32, ProcessStats> {if pids.is_empty() {return HashMap::new();@@ -309,7 +325,7 @@ fn non_empty(value: String) -> Option<String> {#[cfg(test)]mod tests {- use super::{build_summary, runtime_agent_key, ProcessStats, RuntimeSeed};+ use super::{build_summary, runtime_agent_key, sort_runtime_seeds, ProcessStats, RuntimeSeed};use std::collections::HashMap;fn seed(id: &str, status: &str, pid: Option<u32>) -> RuntimeSeed {@@ -350,4 +366,13 @@ mod tests {assert_eq!(runtime_agent_key("agent-runtime:oracle:123"), Some("oracle"));assert_eq!(runtime_agent_key("plugin-connection:test"), None);}++ #[test]+ fn running_runtimes_sort_before_stopped_runtimes() {+ let mut runtimes = vec![seed("h2", "stopped", None), seed("oracle", "running", Some(42))];++ sort_runtime_seeds(&mut runtimes);++ assert_eq!(runtimes.iter().map(|runtime| runtime.id.as_str()).collect::<Vec<_>>(), vec!["oracle", "h2"]);+ }}