diff --git a/kinode/packages/app_store/app_store/src/http_api.rs b/kinode/packages/app_store/app_store/src/http_api.rs index 98ea77a30..d41489154 100644 --- a/kinode/packages/app_store/app_store/src/http_api.rs +++ b/kinode/packages/app_store/app_store/src/http_api.rs @@ -8,9 +8,8 @@ use crate::{ use kinode_process_lib::{ http::{self, server, Method, StatusCode}, - Address, LazyLoadBlob, PackageId, Request, + println, Address, LazyLoadBlob, PackageId, Request, SendError, SendErrorKind, }; -use kinode_process_lib::{SendError, SendErrorKind}; use serde_json::json; use std::{collections::HashMap, str::FromStr}; @@ -266,7 +265,7 @@ fn serve_paths( } } // GET detail about a specific app - // update a downloaded app: PUT + // DELETE uninstall an app "/apps/:id" => { let Ok(package_id) = get_package_id(url_params) else { return Ok(( @@ -294,6 +293,7 @@ fn serve_paths( Method::DELETE => { // uninstall an app crate::utils::uninstall(state, &package_id)?; + println!("successfully uninstalled {:?}", package_id); Ok(( StatusCode::NO_CONTENT, None, @@ -474,7 +474,10 @@ fn serve_paths( state, &our.node().to_string(), ) { - Ok(_) => Ok((StatusCode::CREATED, None, vec![])), + Ok(_) => { + println!("successfully installed package: {:?}", process_package_id); + Ok((StatusCode::CREATED, None, vec![])) + } Err(e) => Ok(( StatusCode::SERVICE_UNAVAILABLE, None, diff --git a/kinode/packages/app_store/ui/src/pages/DownloadPage.tsx b/kinode/packages/app_store/ui/src/pages/DownloadPage.tsx index 45a4d5dcb..e98a19c4c 100644 --- a/kinode/packages/app_store/ui/src/pages/DownloadPage.tsx +++ b/kinode/packages/app_store/ui/src/pages/DownloadPage.tsx @@ -36,7 +36,7 @@ export default function DownloadPage() { fetchData(id); clearAllActiveDownloads(); } - }, [id, fetchData, clearAllActiveDownloads]); + }, [id, fetchData, clearAllActiveDownloads, installedApp]); const handleMirrorSelect = useCallback((mirror: string, status: boolean | null | 'http') => { setSelectedMirror(mirror); @@ -75,19 +75,22 @@ export default function DownloadPage() { if (!app || !selectedVersion) return false; const versionData = sortedVersions.find(v => v.version === selectedVersion); if (!versionData) return false; - const downloadKey = `${app.package_id.package_name}:${selectedMirror}:${versionData.hash}`; - return !!activeDownloads[downloadKey]; - }, [app, selectedVersion, sortedVersions, selectedMirror, activeDownloads]); - + // Check for any active download for this app, not just the selected version + return Object.keys(activeDownloads).some(key => key.startsWith(`${app.package_id.package_name}:`)); + }, [app, selectedVersion, sortedVersions, activeDownloads]); const downloadProgress = useMemo(() => { if (!isDownloading || !app || !selectedVersion) return null; const versionData = sortedVersions.find(v => v.version === selectedVersion); if (!versionData) return null; - const downloadKey = `${app.package_id.package_name}:${selectedMirror}:${versionData.hash}`; - const progress = activeDownloads[downloadKey]; + // Find the active download for this app + const activeDownloadKey = Object.keys(activeDownloads).find(key => + key.startsWith(`${app.package_id.package_name}:`) + ); + if (!activeDownloadKey) return null; + const progress = activeDownloads[activeDownloadKey]; return progress ? Math.round((progress.downloaded / progress.total) * 100) : 0; - }, [isDownloading, app, selectedVersion, sortedVersions, selectedMirror, activeDownloads]); + }, [isDownloading, app, selectedVersion, sortedVersions, activeDownloads]); const isCurrentVersionInstalled = useMemo(() => { if (!app || !selectedVersion || !installedApp) return false; @@ -170,6 +173,7 @@ export default function DownloadPage() { {sortedVersions.map(({ version }, index) => ( ))}