refactor: eradicate deprecated tools (sticky_notes, pinned_files, context_workspaces, pr_checklist, preferences) and dead code
This commit is contained in:
1 parent
d80915635f
commit
79209da711
31 files changed
+1230
-3920
No files matched your search
@@ -8,6 +8,31 @@ pub static ACTIVE_SOCKET: LazyLock<Arc<tokio::sync::Mutex<Option<String>>>> =
|
||||
pub static HEADLESS_PROC: LazyLock<Arc<tokio::sync::Mutex<Option<tokio::process::Child>>>> =
|
||||
LazyLock::new(|| Arc::new(tokio::sync::Mutex::new(None)));
|
||||
|
||||
unsafe extern "C" {
|
||||
fn atexit(f: unsafe extern "C" fn()) -> i32;
|
||||
}
|
||||
|
||||
static HEADLESS_PID: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0);
|
||||
static ONCE_INIT: std::sync::Once = std::sync::Once::new();
|
||||
|
||||
unsafe extern "C" fn cleanup_on_exit() {
|
||||
let pid = HEADLESS_PID.swap(0, std::sync::atomic::Ordering::SeqCst);
|
||||
if pid != 0 {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let _ = std::process::Command::new("taskkill")
|
||||
.args(["/F", "/T", "/PID", &pid.to_string()])
|
||||
.output();
|
||||
}
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let _ = std::process::Command::new("kill")
|
||||
.args(["-9", &pid.to_string()])
|
||||
.output();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn spawn_headless_nvim() -> Result<String, String> {
|
||||
if std::process::Command::new("nvim")
|
||||
.arg("--version")
|
||||
@@ -17,6 +42,10 @@ pub async fn spawn_headless_nvim() -> Result<String, String> {
|
||||
return Err("Error: Neovim is not installed or not in PATH. Cannot execute nvim tool. Fallback to basic terminal tools.".to_string());
|
||||
}
|
||||
|
||||
ONCE_INIT.call_once(|| unsafe {
|
||||
atexit(cleanup_on_exit);
|
||||
});
|
||||
|
||||
#[cfg(windows)]
|
||||
let socket_name = format!(
|
||||
r"\\.\pipe\agy-headless-nvim-{}-{}",
|
||||
@@ -49,6 +78,10 @@ pub async fn spawn_headless_nvim() -> Result<String, String> {
|
||||
.spawn()
|
||||
.map_err(|e| format!("Failed to spawn headless Neovim: {}", e))?;
|
||||
|
||||
if let Some(id) = child.id() {
|
||||
HEADLESS_PID.store(id, std::sync::atomic::Ordering::SeqCst);
|
||||
}
|
||||
|
||||
if let Some(stdout) = child.stdout.take() {
|
||||
let mut reader = tokio::io::BufReader::new(stdout);
|
||||
let mut ready_line = String::new();
|
||||
@@ -60,6 +93,7 @@ pub async fn spawn_headless_nvim() -> Result<String, String> {
|
||||
{
|
||||
Ok(Ok(_)) => {
|
||||
if ready_line.trim() != "READY" {
|
||||
HEADLESS_PID.store(0, std::sync::atomic::Ordering::SeqCst);
|
||||
let _ = child.kill().await;
|
||||
return Err(format!(
|
||||
"Headless Neovim child output unexpected banner: {:?}",
|
||||
@@ -68,6 +102,7 @@ pub async fn spawn_headless_nvim() -> Result<String, String> {
|
||||
}
|
||||
}
|
||||
Ok(Err(e)) => {
|
||||
HEADLESS_PID.store(0, std::sync::atomic::Ordering::SeqCst);
|
||||
let _ = child.kill().await;
|
||||
return Err(format!(
|
||||
"Failed to read readiness from headless Neovim: {}",
|
||||
@@ -75,6 +110,7 @@ pub async fn spawn_headless_nvim() -> Result<String, String> {
|
||||
));
|
||||
}
|
||||
Err(_) => {
|
||||
HEADLESS_PID.store(0, std::sync::atomic::Ordering::SeqCst);
|
||||
let _ = child.kill().await;
|
||||
return Err("Timeout waiting for headless Neovim to become ready".to_string());
|
||||
}
|
||||
@@ -96,6 +132,7 @@ pub async fn spawn_headless_nvim() -> Result<String, String> {
|
||||
}
|
||||
|
||||
pub async fn kill_headless_nvim() {
|
||||
HEADLESS_PID.store(0, std::sync::atomic::Ordering::SeqCst);
|
||||
let child_to_kill = {
|
||||
let mut proc_lock = HEADLESS_PROC.lock().await;
|
||||
proc_lock.take()
|
||||
|
||||
Reference in new issue
Block a user