diff --git a/src/ui/Desktop/Apps/File Manager/components/FileWindow.tsx b/src/ui/Desktop/Apps/File Manager/components/FileWindow.tsx index 09e6d5e5..e2622feb 100644 --- a/src/ui/Desktop/Apps/File Manager/components/FileWindow.tsx +++ b/src/ui/Desktop/Apps/File Manager/components/FileWindow.tsx @@ -200,16 +200,23 @@ export function FileWindow({ // Check if file not found (common error messages from cat command) const errorMessage = errorData?.error || error.message || "Unknown error"; const isFileNotFound = + (error as any).isFileNotFound || errorData?.fileNotFound || error.response?.status === 404 || + errorMessage.includes("File not found") || errorMessage.includes("No such file or directory") || errorMessage.includes("cannot access") || - errorMessage.includes("not found"); + errorMessage.includes("not found") || + errorMessage.includes("Resource not found"); if (isFileNotFound && onFileNotFound) { // Notify parent component about the missing file for cleanup onFileNotFound(file); toast.error(t("fileManager.fileNotFoundAndRemoved", { name: file.name })); + + // Close this window since the file doesn't exist + closeWindow(windowId); + return; // Exit early to prevent showing empty editor } else { toast.error(t("fileManager.failedToLoadFile", { error: errorMessage.includes("Server error occurred") ? diff --git a/src/ui/main-axios.ts b/src/ui/main-axios.ts index 52486737..243ed8b7 100644 --- a/src/ui/main-axios.ts +++ b/src/ui/main-axios.ts @@ -1051,7 +1051,14 @@ export async function readSSHFile( params: { sessionId, path }, }); return response.data; - } catch (error) { + } catch (error: any) { + // Preserve fileNotFound information for 404 errors + if (error.response?.status === 404) { + const customError = new Error("File not found"); + (customError as any).response = error.response; + (customError as any).isFileNotFound = error.response.data?.fileNotFound || true; + throw customError; + } handleApiError(error, "read SSH file"); } }