fix: add shutdown_port_forwards command for app cleanup
Some checks failed
PR Review Automation / review (pull_request) Successful in 5m32s
Test / rust-clippy (pull_request) Has been cancelled
Test / rust-tests (pull_request) Has been cancelled
Test / frontend-typecheck (pull_request) Has been cancelled
Test / rust-fmt-check (pull_request) Has been cancelled
Test / frontend-tests (pull_request) Has been cancelled

- Add shutdown_port_forwards() to kill all child processes on app exit
- Update lib.rs to register the new command
- PortForwardSession::close() handles both child kill and temp file cleanup
This commit is contained in:
Shaun Arman 2026-06-06 18:46:13 -05:00
parent 2134b880b9
commit c53cfdd84f
2 changed files with 17 additions and 0 deletions

View File

@ -694,3 +694,19 @@ mod tests {
assert!(validate_resource_name(&long_name, "pod").is_err());
}
}
#[tauri::command]
pub async fn shutdown_port_forwards(state: State<'_, AppState>) -> Result<(), String> {
let mut port_forwards = state.port_forwards.lock().await;
// Close all active port forward sessions
let session_ids: Vec<String> = port_forwards.keys().cloned().collect();
for session_id in session_ids {
if let Some(mut session) = port_forwards.remove(&session_id) {
session.close().await;
}
}
Ok(())
}

View File

@ -182,6 +182,7 @@ pub fn run() {
commands::kube::stop_port_forward,
commands::kube::list_port_forwards,
commands::kube::delete_port_forward,
commands::kube::shutdown_port_forwards,
])
.run(tauri::generate_context!())
.expect("Error running Troubleshooting and RCA Assistant application");