feat(tui): instance launching, tabs, profiles overhaul

This commit is contained in:
objz committed 2025-11-01 14:22:18 +01:00
1 parent 09d548272b
commit 46087c47a8
15 files changed
+813 -71

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
use once_cell::sync::Lazy;
use std::collections::{HashMap, VecDeque};
use std::sync::{Arc, Mutex};
const MAX_LINES: usize = 2000;
pub static LOGS: Lazy<Arc<Mutex<HashMap<String, VecDeque<String>>>>> =
Lazy::new(|| Arc::new(Mutex::new(HashMap::new())));
pub fn push(name: &str, line: impl Into<String>) {
if let Ok(mut logs) = LOGS.lock() {
let buf = logs.entry(name.to_string()).or_insert_with(VecDeque::new);
buf.push_back(line.into());
while buf.len() > MAX_LINES {
buf.pop_front();
}
}
}
pub fn get_all(name: &str) -> Vec<String> {
LOGS.lock()
.ok()
.and_then(|logs| logs.get(name).map(|buf| buf.iter().cloned().collect()))
.unwrap_or_default()
}
pub fn clear(name: &str) {
if let Ok(mut logs) = LOGS.lock() {
logs.remove(name);
}
}