FIX: Automatically cleanup deleted files from recent/pinned lists

File Cleanup Implementation:
- Detect file-not-found errors when opening files from recent/pinned lists
- Automatically remove missing files from both recent and pinned file lists
- Refresh sidebar to reflect updated lists immediately after cleanup
- Prevent error dialogs from appearing when files are successfully cleaned up

Backend Improvements:
- Enhanced SSH file manager to return proper 404 status for missing files
- Added fileNotFound flag in error responses for better error detection
- Improved error categorization for file access failures

Frontend Error Handling:
- Added onFileNotFound callback prop to FileWindow component
- Implemented handleFileNotFound function in FileManagerModern
- Enhanced error detection logic to catch various "file not found" scenarios
- Better error messages with internationalization support

Translation Additions:
- fileNotFoundAndRemoved: Notify user when file is cleaned up
- failedToLoadFile: Generic file loading error message
- serverErrorOccurred: Server error fallback message
- Chinese translations for all new error messages

Technical Details:
- Uses existing removeRecentFile and removePinnedFile API calls
- Triggers sidebar refresh via setSidebarRefreshTrigger
- Maintains backward compatibility with existing error handling
- Preserves error logging for debugging purposes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ZacharyZcR
2025-09-25 07:49:48 +08:00
parent c780ad2f18
commit fdd1218b03
5 changed files with 65 additions and 5 deletions

View File

@@ -860,6 +860,9 @@
"modified": "Modified",
"largeFileWarning": "Large File Warning",
"largeFileWarningDesc": "This file is {{size}} in size, which may cause performance issues when opened as text.",
"fileNotFoundAndRemoved": "File \"{{name}}\" not found and has been removed from recent/pinned files",
"failedToLoadFile": "Failed to load file: {{error}}",
"serverErrorOccurred": "Server error occurred. Please try again later.",
"fileSavedSuccessfully": "File saved successfully",
"autoSaveFailed": "Auto-save failed",
"fileAutoSaved": "File auto-saved",