feat(sidebar): implement trash functionality for project management

- Added a new `trashItem` method in the Electron API to move projects to the system trash.
- Enhanced the sidebar component to include a trash button and manage trashed projects.
- Implemented functionality to restore and permanently delete projects from the trash.
- Updated the application state to track trashed projects and provide user feedback through toast notifications.

This update significantly improves project management by allowing users to easily manage deleted projects without permanent loss.
This commit is contained in:
SuperComboGamer
2025-12-09 22:37:04 -05:00
parent 7b760090e4
commit d014a0ba4f
5 changed files with 368 additions and 7 deletions

View File

@@ -3,7 +3,7 @@ const path = require("path");
// Load environment variables from .env file
require("dotenv").config({ path: path.join(__dirname, "../.env") });
const { app, BrowserWindow, ipcMain, dialog } = require("electron");
const { app, BrowserWindow, ipcMain, dialog, shell } = require("electron");
const fs = require("fs/promises");
const agentService = require("./agent-service");
const autoModeService = require("./auto-mode-service");
@@ -169,6 +169,15 @@ ipcMain.handle("fs:deleteFile", async (_, filePath) => {
}
});
ipcMain.handle("fs:trashItem", async (_, targetPath) => {
try {
await shell.trashItem(targetPath);
return { success: true };
} catch (error) {
return { success: false, error: error.message };
}
});
// App data path
ipcMain.handle("app:getPath", (_, name) => {
return app.getPath(name);
@@ -193,7 +202,9 @@ ipcMain.handle(
await fs.mkdir(imagesDir, { recursive: true });
// Generate unique filename with unique ID
const uniqueId = `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
const uniqueId = `${Date.now()}-${Math.random()
.toString(36)
.substring(2, 11)}`;
const safeName = filename.replace(/[^a-zA-Z0-9.-]/g, "_");
const imageFilePath = path.join(imagesDir, `${uniqueId}_${safeName}`);