diff --git a/.automaker/agents-context/feature-1765326577290-x65tvg9n0.md b/.automaker/agents-context/feature-1765326577290-x65tvg9n0.md deleted file mode 100644 index d537d922..00000000 --- a/.automaker/agents-context/feature-1765326577290-x65tvg9n0.md +++ /dev/null @@ -1,117 +0,0 @@ -šŸ“‹ Planning implementation for: switch the order inside the add new feature panel so descriptino comes first followed by an optional category, also update the edit feature panel. -⚔ Executing implementation for: switch the order inside the add new feature panel so descriptino comes first followed by an optional category, also update the edit feature panel. -Starting code implementation... - -šŸ”§ Tool: Task - -šŸ”§ Tool: Bash - -šŸ”§ Tool: Glob - -šŸ”§ Tool: Glob - -šŸ”§ Tool: Grep - -šŸ”§ Tool: Grep - -šŸ”§ Tool: Glob - -šŸ”§ Tool: Glob - -šŸ”§ Tool: Bash - -šŸ”§ Tool: Read - -šŸ”§ Tool: Bash - -šŸ”§ Tool: Bash - -šŸ”§ Tool: Bash - -šŸ”§ Tool: Bash - -šŸ”§ Tool: Read - -šŸ”§ Tool: Read - -šŸ”§ Tool: Grep - -šŸ”§ Tool: Read - -šŸ”§ Tool: Grep - -šŸ”§ Tool: Read - -šŸ”§ Tool: Bash - -šŸ”§ Tool: Read - -šŸ”§ Tool: Bash - -šŸ”§ Tool: Read - -šŸ”§ Tool: Read - -šŸ”§ Tool: Read - -šŸ”§ Tool: Bash - -šŸ”§ Tool: Bash - -šŸ”§ Tool: Read - -šŸ”§ Tool: Bash - -šŸ”§ Tool: Bash - -šŸ”§ Tool: Read - -šŸ”§ Tool: Bash - -šŸ”§ Tool: Read -Now I have a good understanding of the codebase. Let me read the specific files to see the exact structure of the add and edit feature dialogs: -šŸ”§ Tool: Read -Now I have a clear understanding of both dialogs. I need to: - -1. In the **Add Feature Dialog** (lines 1342-1419): Move the Description field before the Category field -2. In the **Edit Feature Dialog** (lines 1452-1536): Move the Description field before the Category field - -Let me make these edits: -šŸ”§ Tool: Edit -Now let me update the Edit Feature Dialog similarly: -šŸ”§ Tool: Edit -Both dialogs have been updated. Now let me verify the changes are correct by reading the updated sections: -šŸ”§ Tool: Read -Now let me verify the edit dialog changes: -šŸ”§ Tool: Read -Both dialogs have been successfully updated. The changes are: - -1. **Add New Feature Dialog**: - - Description field now comes first - - Category field now comes second with label "Category (optional)" - -2. **Edit Feature Dialog**: - - Description field now comes first - - Category field now comes second with label "Category (optional)" - -Now let me mark this feature as verified using the UpdateFeatureStatus tool: -šŸ”§ Tool: mcp__automaker-tools__UpdateFeatureStatus -I've completed the feature implementation. Here's a summary of what was done: - -## Changes Made - -**File Modified:** `app/src/components/views/board-view.tsx` - -### Add New Feature Dialog (lines 1342-1368) -- Moved **Description** field to the first position (was second) -- Moved **Category** field to the second position (was first) -- Updated Category label from "Category" to "Category (optional)" - -### Edit Feature Dialog (lines 1452-1482) -- Moved **Description** field to the first position (was second) -- Moved **Category** field to the second position (was first) -- Updated Category label from "Category" to "Category (optional)" - -The feature has been marked as `waiting_approval` (automatically converted from `verified` because `skipTests=true`). Please manually verify the changes and commit when ready.āœ… Verifying implementation for: switch the order inside the add new feature panel so descriptino comes first followed by an optional category, also update the edit feature panel. -Verifying implementation and checking test results... -āœ“ Verification successful: All tests passed diff --git a/.automaker/agents-context/feature-1765326669854-gcjsh15zz.md b/.automaker/agents-context/feature-1765326669854-gcjsh15zz.md deleted file mode 100644 index 2c2cce77..00000000 --- a/.automaker/agents-context/feature-1765326669854-gcjsh15zz.md +++ /dev/null @@ -1,139 +0,0 @@ -šŸ“‹ Planning implementation for: remember the users choice for skip testing and add a setting toggle in settings page to let them change their default when making new tasks. if it's enabled, show the steps to allow user to add manual testing steps. change label from steps to Verification Steps -⚔ Executing implementation for: remember the users choice for skip testing and add a setting toggle in settings page to let them change their default when making new tasks. if it's enabled, show the steps to allow user to add manual testing steps. change label from steps to Verification Steps -Starting code implementation... - -šŸ”§ Tool: Glob -Let me look at the project structure more specifically: -šŸ”§ Tool: Glob - -šŸ”§ Tool: Read - -šŸ”§ Tool: Read - -šŸ”§ Tool: Read -Now I have a good understanding of the codebase. Let me implement the feature: - -1. Add a `defaultSkipTests` setting to the app store (persisted) -2. Add a toggle in the settings page -3. Update the "Add Feature" dialog to: - - Default skipTests based on user preference - - Show "Verification Steps" label instead of "Steps" when skipTests is enabled -4. Also update the edit dialog label -šŸ”§ Tool: TodoWrite - -šŸ”§ Tool: Edit -Input: { - "file_path": "/Users/webdevcody/Workspace/automaker/app/src/store/app-store.ts", - "old_string": " // Kanban Card Display Settings\n kanbanCardDetailLevel: KanbanCardDetailLevel; // Level of detail shown on kanban cards\n}", - "new_string": " // Kanban Card Display Settings\n kanbanCardDetailLevel: KanbanCardDetailLevel; // Level of detail shown on kanban cards\n\n // Feature Default Settings\n defaultSkipTests: boolean; // Default value for skip tests when creating new features\n}" -} -šŸ”§ Tool: Edit - -šŸ”§ Tool: Edit -Input: { - "file_path": "/Users/webdevcody/Workspace/automaker/app/src/store/app-store.ts", - "old_string": " maxConcurrency: 3, // Default to 3 concurrent agents\n kanbanCardDetailLevel: \"standard\", // Default to standard detail level\n};", - "new_string": " maxConcurrency: 3, // Default to 3 concurrent agents\n kanbanCardDetailLevel: \"standard\", // Default to standard detail level\n defaultSkipTests: false, // Default to TDD mode (tests enabled)\n};" -} -šŸ”§ Tool: Edit -Now I need to add `defaultSkipTests` to the persisted state: -šŸ”§ Tool: Edit - -šŸ”§ Tool: TodoWrite -Now let me add the toggle in the settings page. I'll add a new section for Feature Defaults: -šŸ”§ Tool: Read - -šŸ”§ Tool: Edit - -šŸ”§ Tool: Edit -Now let me find where I can add the new section. Let me read more of the settings view to find where to add the feature defaults section: -šŸ”§ Tool: Read -Now let me add the Feature Defaults section after the Kanban Card Display section: -šŸ”§ Tool: Edit - -šŸ”§ Tool: TodoWrite -Now let me update the board-view.tsx to: -1. Use `defaultSkipTests` as the default value for new features -2. Change the label from "Steps" to "Verification Steps" when skipTests is enabled -šŸ”§ Tool: Read - -šŸ”§ Tool: Edit -Now I need to update the newFeature state initialization to use defaultSkipTests. Since it's initialized with a static value, I need to use an effect to sync it when the dialog opens or when defaultSkipTests changes: -šŸ”§ Tool: Read -I need to update the handleAddFeature to reset skipTests to the default value: -šŸ”§ Tool: Edit -Now I also need to make sure the initial state and when dialog opens uses the default. Let me add an effect that resets the form when the dialog opens: -šŸ”§ Tool: Read -I need to add an effect to reset the skipTests when the dialog opens. Let me find a good place to add it: -šŸ”§ Tool: Edit -Now let me update the label from "Steps" to "Verification Steps" when skipTests is enabled. Let me find the Add Feature dialog: -šŸ”§ Tool: Read -I'll now update the label to change dynamically based on skipTests. I also need to: -1. Change the "Steps" label to "Verification Steps" when skipTests is enabled -2. Only show the steps section when skipTests is enabled (based on the requirement "if it's enabled, show the steps to allow user to add manual testing steps") - -Let me update the add feature dialog: -šŸ”§ Tool: Edit - -šŸ”§ Tool: TodoWrite -Now let me find and update the Edit Feature dialog to also show "Verification Steps" when skipTests is enabled: -šŸ”§ Tool: Read - -šŸ”§ Tool: Edit - -šŸ”§ Tool: TodoWrite -Now let me verify the implementation is correct by checking that everything compiles. Let me run a quick type check: -šŸ”§ Tool: Bash -The errors are from an example file and API routes, not from the files I modified. The core application code I changed compiles correctly. Let me verify specifically that the files I modified don't have errors: -šŸ”§ Tool: Bash -The errors are in a different file (analysis-view.tsx) that imports from the store but has missing types - not related to my changes. The store, board-view, and settings-view themselves have no type errors. - -Let me now mark the feature as verified using the UpdateFeatureStatus tool: -šŸ”§ Tool: mcp__automaker-tools__UpdateFeatureStatus -Let me check if the feature exists in the feature list: -šŸ”§ Tool: Bash - -šŸ”§ Tool: Read -The feature list is empty. This could be because the feature is being tracked elsewhere or the file was cleared. Let me clear my todo list and provide a summary of what was implemented: -šŸ”§ Tool: TodoWrite -## Feature Implementation Complete - -I have successfully implemented the feature to remember the user's choice for skip testing and added a settings toggle. Here's a summary of the changes made: - -### Files Modified: - -1. **`app/src/store/app-store.ts`** - - Added `defaultSkipTests: boolean` to the AppState interface - - Added `setDefaultSkipTests: (skip: boolean) => void` action - - Set initial state to `false` (TDD mode by default) - - Added `defaultSkipTests` to the persisted state so it's remembered across sessions - -2. **`app/src/components/views/settings-view.tsx`** - - Added `FlaskConical` icon import and `Checkbox` component import - - Added `defaultSkipTests` and `setDefaultSkipTests` from the store - - Added a new "Feature Defaults" section with a toggle for "Skip automated testing by default" - - The toggle is displayed with helpful description text - -3. **`app/src/components/views/board-view.tsx`** - - Added `defaultSkipTests` from the store - - Added an effect to sync `skipTests` default when the Add Feature dialog opens - - **Add Feature Dialog**: - - Moved the skip tests checkbox above the steps section - - Steps section now only shows when `skipTests` is enabled - - Changed label from "Steps" to "Verification Steps" - - Changed button from "Add Step" to "Add Verification Step" - - Changed placeholder from "Step X" to "Verification step X" - - **Edit Feature Dialog**: - - Applied the same changes - steps only show when `skipTests` is enabled - - Changed label to "Verification Steps" and button to "Add Verification Step" - - Reset form uses `defaultSkipTests` value after adding a feature - -### Behavior: -- Users can set their default preference in Settings → Feature Defaults -- When creating a new feature, the "Skip automated testing" checkbox will be pre-checked based on their preference -- When skip tests is enabled, the "Verification Steps" input section appears, allowing users to add manual testing/verification steps -- The setting persists across browser sessions via localStorage - -**Note:** The feature could not be marked as verified via the UpdateFeatureStatus tool because the feature list appears to be empty. Since this is a `skipTests` feature, the user should manually review and commit the changes.āœ… Verifying implementation for: remember the users choice for skip testing and add a setting toggle in settings page to let them change their default when making new tasks. if it's enabled, show the steps to allow user to add manual testing steps. change label from steps to Verification Steps -Verifying implementation and checking test results... -āœ— Verification: Tests need attention diff --git a/.automaker/feature_list.json b/.automaker/feature_list.json index 47bb3620..a4d0a19d 100644 --- a/.automaker/feature_list.json +++ b/.automaker/feature_list.json @@ -187,6 +187,24 @@ "model": "opus", "thinkingLevel": "none" }, + { + "id": "feature-1765335919754-r010d1fw5", + "category": "Uncategorized", + "description": "what does the text in the button say?\n", + "steps": [], + "status": "waiting_approval", + "startedAt": "2025-12-10T03:05:34.894Z", + "imagePaths": [ + { + "id": "img-1765335919132-0x3t37l1r", + "path": "/Users/webdevcody/Library/Application Support/automaker/images/1765335919131-g4qvs053g_Screenshot_2025-12-09_at_10.05.17_PM.png", + "filename": "Screenshot 2025-12-09 at 10.05.17 PM.png", + "mimeType": "image/png" + } + ], + "skipTests": true, + "summary": "Investigated button text in the app. Main buttons found in welcome-view.tsx: \"Create Project\" (primary action), \"Browse Folder\" (secondary action), \"Browse\" (directory selector), \"Cancel\", \"Get Started\". No code changes made - this was an investigative question." + }, { "id": "feature-1765336835703-4xona4xy9", "category": "Uncategorized", diff --git a/app/electron/auto-mode-service.js b/app/electron/auto-mode-service.js index 10b314fb..6277f7c8 100644 --- a/app/electron/auto-mode-service.js +++ b/app/electron/auto-mode-service.js @@ -181,6 +181,31 @@ class AutoModeService { return { success: true, passes: result.passes }; } catch (error) { console.error("[AutoMode] Error running feature:", error); + + // Write error to context file + try { + await contextManager.writeToContextFile( + projectPath, + featureId, + `\n\nāŒ ERROR: ${error.message}\n\n${error.stack || ''}\n` + ); + } catch (contextError) { + console.error("[AutoMode] Failed to write error to context:", contextError); + } + + // Update feature status to waiting_approval so user can review the error + try { + await featureLoader.updateFeatureStatus( + featureId, + "waiting_approval", + projectPath, + null, // no summary + error.message // pass error message + ); + } catch (statusError) { + console.error("[AutoMode] Failed to update feature status after error:", statusError); + } + sendToRenderer({ type: "auto_mode_error", error: error.message, @@ -260,6 +285,31 @@ class AutoModeService { return { success: true, passes: result.passes }; } catch (error) { console.error("[AutoMode] Error verifying feature:", error); + + // Write error to context file + try { + await contextManager.writeToContextFile( + projectPath, + featureId, + `\n\nāŒ ERROR: ${error.message}\n\n${error.stack || ''}\n` + ); + } catch (contextError) { + console.error("[AutoMode] Failed to write error to context:", contextError); + } + + // Update feature status to waiting_approval so user can review the error + try { + await featureLoader.updateFeatureStatus( + featureId, + "waiting_approval", + projectPath, + null, // no summary + error.message // pass error message + ); + } catch (statusError) { + console.error("[AutoMode] Failed to update feature status after error:", statusError); + } + sendToRenderer({ type: "auto_mode_error", error: error.message, @@ -400,6 +450,31 @@ class AutoModeService { return { success: true, passes: finalResult.passes }; } catch (error) { console.error("[AutoMode] Error resuming feature:", error); + + // Write error to context file + try { + await contextManager.writeToContextFile( + projectPath, + featureId, + `\n\nāŒ ERROR: ${error.message}\n\n${error.stack || ''}\n` + ); + } catch (contextError) { + console.error("[AutoMode] Failed to write error to context:", contextError); + } + + // Update feature status to waiting_approval so user can review the error + try { + await featureLoader.updateFeatureStatus( + featureId, + "waiting_approval", + projectPath, + null, // no summary + error.message // pass error message + ); + } catch (statusError) { + console.error("[AutoMode] Failed to update feature status after error:", statusError); + } + sendToRenderer({ type: "auto_mode_error", error: error.message, @@ -544,6 +619,31 @@ class AutoModeService { }); } catch (error) { console.error(`[AutoMode] Error running feature ${featureId}:`, error); + + // Write error to context file + try { + await contextManager.writeToContextFile( + projectPath, + featureId, + `\n\nāŒ ERROR: ${error.message}\n\n${error.stack || ''}\n` + ); + } catch (contextError) { + console.error("[AutoMode] Failed to write error to context:", contextError); + } + + // Update feature status to waiting_approval so user can review the error + try { + await featureLoader.updateFeatureStatus( + featureId, + "waiting_approval", + projectPath, + null, // no summary + error.message // pass error message + ); + } catch (statusError) { + console.error("[AutoMode] Failed to update feature status after error:", statusError); + } + sendToRenderer({ type: "auto_mode_error", error: error.message, @@ -761,6 +861,31 @@ class AutoModeService { }); } catch (error) { console.error("[AutoMode] Error in follow-up:", error); + + // Write error to context file + try { + await contextManager.writeToContextFile( + projectPath, + featureId, + `\n\nāŒ ERROR: ${error.message}\n\n${error.stack || ''}\n` + ); + } catch (contextError) { + console.error("[AutoMode] Failed to write error to context:", contextError); + } + + // Update feature status to waiting_approval so user can review the error + try { + await featureLoader.updateFeatureStatus( + featureId, + "waiting_approval", + projectPath, + null, // no summary + error.message // pass error message + ); + } catch (statusError) { + console.error("[AutoMode] Failed to update feature status after error:", statusError); + } + sendToRenderer({ type: "auto_mode_error", error: error.message, diff --git a/app/electron/main.js b/app/electron/main.js index abba3d31..805fd5de 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -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"); @@ -12,11 +12,11 @@ let mainWindow = null; // Get icon path - works in both dev and production function getIconPath() { - // In dev: __dirname is electron/, so ../public/icon_gold.png + // In dev: __dirname is electron/, so ../public/logo.png // In production: public folder is included in the app bundle return app.isPackaged - ? path.join(process.resourcesPath, "app", "public", "icon_gold.png") - : path.join(__dirname, "../public/icon_gold.png"); + ? path.join(process.resourcesPath, "app", "public", "logo.png") + : path.join(__dirname, "../public/logo.png"); } function createWindow() { @@ -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}`); diff --git a/app/electron/preload.js b/app/electron/preload.js index 162b13b6..d9348281 100644 --- a/app/electron/preload.js +++ b/app/electron/preload.js @@ -19,6 +19,7 @@ contextBridge.exposeInMainWorld("electronAPI", { exists: (filePath) => ipcRenderer.invoke("fs:exists", filePath), stat: (filePath) => ipcRenderer.invoke("fs:stat", filePath), deleteFile: (filePath) => ipcRenderer.invoke("fs:deleteFile", filePath), + trashItem: (filePath) => ipcRenderer.invoke("fs:trashItem", filePath), // App APIs getPath: (name) => ipcRenderer.invoke("app:getPath", name), diff --git a/app/electron/services/feature-executor.js b/app/electron/services/feature-executor.js index 98f508e1..7a3cd30b 100644 --- a/app/electron/services/feature-executor.js +++ b/app/electron/services/feature-executor.js @@ -699,7 +699,8 @@ class FeatureExecutor { const path = require("path"); for (const imagePathObj of imagePaths) { try { - const imagePath = imagePathObj.path; + // Handle both string paths and FeatureImagePath objects + const imagePath = typeof imagePathObj === 'string' ? imagePathObj : imagePathObj.path; const imageBuffer = fs.readFileSync(imagePath); const base64Data = imageBuffer.toString("base64"); const ext = path.extname(imagePath).toLowerCase(); @@ -710,7 +711,9 @@ class FeatureExecutor { ".gif": "image/gif", ".webp": "image/webp", }; - const mediaType = mimeTypeMap[ext] || imagePathObj.mimeType || "image/png"; + const mediaType = typeof imagePathObj === 'string' + ? (mimeTypeMap[ext] || "image/png") + : (mimeTypeMap[ext] || imagePathObj.mimeType || "image/png"); contentBlocks.push({ type: "image", @@ -723,8 +726,9 @@ class FeatureExecutor { console.log(`[FeatureExecutor] Added image to resume prompt: ${imagePath}`); } catch (error) { + const errorPath = typeof imagePathObj === 'string' ? imagePathObj : imagePathObj.path; console.error( - `[FeatureExecutor] Failed to load image ${imagePathObj.path}:`, + `[FeatureExecutor] Failed to load image ${errorPath}:`, error ); } diff --git a/app/electron/services/feature-loader.js b/app/electron/services/feature-loader.js index 79da4cbc..7394c34e 100644 --- a/app/electron/services/feature-loader.js +++ b/app/electron/services/feature-loader.js @@ -36,8 +36,9 @@ class FeatureLoader { * @param {string} status - The new status * @param {string} projectPath - Path to the project * @param {string} [summary] - Optional summary of what was done + * @param {string} [error] - Optional error message if feature errored */ - async updateFeatureStatus(featureId, status, projectPath, summary) { + async updateFeatureStatus(featureId, status, projectPath, summary, error) { const featuresPath = path.join( projectPath, ".automaker", @@ -98,6 +99,14 @@ class FeatureLoader { feature.summary = summary; } + // Update the error field (set or clear) + if (error) { + feature.error = error; + } else { + // Clear any previous error when status changes without error + delete feature.error; + } + // Save back to file const toSave = features.map((f) => { const featureData = { @@ -129,6 +138,9 @@ class FeatureLoader { if (f.thinkingLevel !== undefined) { featureData.thinkingLevel = f.thinkingLevel; } + if (f.error !== undefined) { + featureData.error = f.error; + } return featureData; }); diff --git a/app/electron/services/prompt-builder.js b/app/electron/services/prompt-builder.js index 7a4c9f81..f5ece767 100644 --- a/app/electron/services/prompt-builder.js +++ b/app/electron/services/prompt-builder.js @@ -10,9 +10,18 @@ class PromptBuilder { ? `\n**āš ļø IMPORTANT - Manual Testing Mode:**\nThis feature has skipTests=true, which means:\n- DO NOT commit changes automatically\n- DO NOT mark as verified - it will automatically go to "waiting_approval" status\n- The user will manually review and commit the changes\n- Just implement the feature and mark it as verified (it will be converted to waiting_approval)\n` : ""; - const imagesNote = feature.imagePaths && feature.imagePaths.length > 0 - ? `\n**šŸ“Ž Context Images Attached:**\nThe user has attached ${feature.imagePaths.length} image(s) for context. These images will be provided to you visually to help understand the requirements. Review them carefully before implementing.\n` - : ""; + let imagesNote = ""; + if (feature.imagePaths && feature.imagePaths.length > 0) { + const imagesList = feature.imagePaths.map((img, idx) => + ` ${idx + 1}. ${img.filename} (${img.mimeType})\n Path: ${img.path}` + ).join("\n"); + + imagesNote = `\n**šŸ“Ž Context Images Attached:**\nThe user has attached ${feature.imagePaths.length} image(s) for context. These images are provided both visually (in the initial message) and as files you can read: + +${imagesList} + +You can use the Read tool to view these images at any time during implementation. Review them carefully before implementing.\n`; + } return `You are working on a feature implementation task. @@ -121,9 +130,18 @@ Begin by reading the project structure and then implementing the feature.`; ? `\n**āš ļø IMPORTANT - Manual Testing Mode:**\nThis feature has skipTests=true, which means:\n- DO NOT commit changes automatically\n- DO NOT mark as verified - it will automatically go to "waiting_approval" status\n- The user will manually review and commit the changes\n- Just implement the feature and mark it as verified (it will be converted to waiting_approval)\n` : ""; - const imagesNote = feature.imagePaths && feature.imagePaths.length > 0 - ? `\n**šŸ“Ž Context Images Attached:**\nThe user has attached ${feature.imagePaths.length} image(s) for context. These images will be provided to you visually to help understand the requirements. Review them carefully before implementing.\n` - : ""; + let imagesNote = ""; + if (feature.imagePaths && feature.imagePaths.length > 0) { + const imagesList = feature.imagePaths.map((img, idx) => + ` ${idx + 1}. ${img.filename} (${img.mimeType})\n Path: ${img.path}` + ).join("\n"); + + imagesNote = `\n**šŸ“Ž Context Images Attached:**\nThe user has attached ${feature.imagePaths.length} image(s) for context. These images are provided both visually (in the initial message) and as files you can read: + +${imagesList} + +You can use the Read tool to view these images at any time during implementation. Review them carefully before implementing.\n`; + } return `You are implementing and verifying a feature until it is complete and working correctly. @@ -224,9 +242,24 @@ Begin by reading the project structure and understanding what needs to be implem ? `\n**āš ļø IMPORTANT - Manual Testing Mode:**\nThis feature has skipTests=true, which means:\n- DO NOT commit changes automatically\n- DO NOT mark as verified - it will automatically go to "waiting_approval" status\n- The user will manually review and commit the changes\n- Just implement the feature and mark it as verified (it will be converted to waiting_approval)\n` : ""; - const imagesNote = feature.imagePaths && feature.imagePaths.length > 0 - ? `\n**šŸ“Ž Context Images Attached:**\nThe user has attached ${feature.imagePaths.length} image(s) for context. These images will be provided to you visually to help understand the requirements. Review them carefully.\n` - : ""; + // For resume, check both followUpImages and imagePaths + const imagePaths = feature.followUpImages || feature.imagePaths; + let imagesNote = ""; + if (imagePaths && imagePaths.length > 0) { + const imagesList = imagePaths.map((img, idx) => { + // Handle both FeatureImagePath objects and simple path strings + const path = typeof img === 'string' ? img : img.path; + const filename = typeof img === 'string' ? path.split('/').pop() : img.filename; + const mimeType = typeof img === 'string' ? 'image/*' : img.mimeType; + return ` ${idx + 1}. ${filename} (${mimeType})\n Path: ${path}`; + }).join("\n"); + + imagesNote = `\n**šŸ“Ž Context Images Attached:**\nThe user has attached ${imagePaths.length} image(s) for context. These images are provided both visually (in the initial message) and as files you can read: + +${imagesList} + +You can use the Read tool to view these images at any time. Review them carefully.\n`; + } return `You are resuming work on a feature implementation that was previously started. diff --git a/app/package.json b/app/package.json index b72dc6dc..38725950 100644 --- a/app/package.json +++ b/app/package.json @@ -87,7 +87,7 @@ "arch": ["x64", "arm64"] } ], - "icon": "public/icon_gold.png" + "icon": "public/logo.png" }, "win": { "target": [ @@ -96,7 +96,7 @@ "arch": ["x64"] } ], - "icon": "public/icon_gold.png" + "icon": "public/logo.png" }, "linux": { "target": [ @@ -110,7 +110,7 @@ } ], "category": "Development", - "icon": "public/icon_gold.png" + "icon": "public/logo.png" }, "nsis": { "oneClick": false, diff --git a/app/public/logo.png b/app/public/logo.png new file mode 100644 index 00000000..3f0aaa10 Binary files /dev/null and b/app/public/logo.png differ diff --git a/app/src/components/layout/sidebar.tsx b/app/src/components/layout/sidebar.tsx index bab8ca63..43021508 100644 --- a/app/src/components/layout/sidebar.tsx +++ b/app/src/components/layout/sidebar.tsx @@ -3,7 +3,6 @@ import { useState, useMemo, useEffect, useCallback } from "react"; import { cn } from "@/lib/utils"; import { useAppStore } from "@/store/app-store"; -import Link from "next/link"; import { FolderOpen, Plus, @@ -11,25 +10,32 @@ import { FileText, LayoutGrid, Bot, - ChevronLeft, - ChevronRight, Folder, X, Wrench, PanelLeft, PanelLeftClose, - Sparkles, ChevronDown, Check, BookOpen, GripVertical, + Trash2, + Undo2, } from "lucide-react"; import { DropdownMenu, DropdownMenuContent, - DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog"; +import { Button } from "@/components/ui/button"; import { useKeyboardShortcuts, NAV_SHORTCUTS, @@ -37,7 +43,7 @@ import { ACTION_SHORTCUTS, KeyboardShortcut, } from "@/hooks/use-keyboard-shortcuts"; -import { getElectronAPI, Project } from "@/lib/electron"; +import { getElectronAPI, Project, TrashedProject } from "@/lib/electron"; import { initializeProject } from "@/lib/project-init"; import { toast } from "sonner"; import { @@ -145,6 +151,7 @@ function SortableProjectItem({ export function Sidebar() { const { projects, + trashedProjects, currentProject, currentView, sidebarOpen, @@ -152,12 +159,17 @@ export function Sidebar() { setCurrentProject, setCurrentView, toggleSidebar, - removeProject, + restoreTrashedProject, + deleteTrashedProject, + emptyTrash, reorderProjects, } = useAppStore(); // State for project picker dropdown const [isProjectPickerOpen, setIsProjectPickerOpen] = useState(false); + const [showTrashDialog, setShowTrashDialog] = useState(false); + const [activeTrashId, setActiveTrashId] = useState(null); + const [isEmptyingTrash, setIsEmptyingTrash] = useState(false); // Sensors for drag-and-drop const sensors = useSensors( @@ -239,6 +251,73 @@ export function Sidebar() { } }, [addProject, setCurrentProject]); + const handleRestoreProject = useCallback( + (projectId: string) => { + restoreTrashedProject(projectId); + toast.success("Project restored", { + description: "Added back to your project list.", + }); + setShowTrashDialog(false); + }, + [restoreTrashedProject] + ); + + const handleDeleteProjectFromDisk = useCallback( + async (trashedProject: TrashedProject) => { + const confirmed = window.confirm( + `Delete "${trashedProject.name}" from disk?\nThis sends the folder to your system Trash.` + ); + if (!confirmed) return; + + setActiveTrashId(trashedProject.id); + try { + const api = getElectronAPI(); + if (!api.trashItem) { + throw new Error("System Trash is not available in this build."); + } + + const result = await api.trashItem(trashedProject.path); + if (!result.success) { + throw new Error(result.error || "Failed to delete project folder"); + } + + deleteTrashedProject(trashedProject.id); + toast.success("Project folder sent to system Trash", { + description: trashedProject.path, + }); + } catch (error) { + console.error("[Sidebar] Failed to delete project from disk:", error); + toast.error("Failed to delete project folder", { + description: error instanceof Error ? error.message : "Unknown error", + }); + } finally { + setActiveTrashId(null); + } + }, + [deleteTrashedProject] + ); + + const handleEmptyTrash = useCallback(() => { + if (trashedProjects.length === 0) { + setShowTrashDialog(false); + return; + } + + const confirmed = window.confirm( + "Clear all trashed projects from Automaker? This does not delete folders from disk." + ); + if (!confirmed) return; + + setIsEmptyingTrash(true); + try { + emptyTrash(); + toast.success("Trash cleared"); + setShowTrashDialog(false); + } finally { + setIsEmptyingTrash(false); + } + }, [emptyTrash, trashedProjects.length]); + const navSections: NavSection[] = [ { label: "Project", @@ -428,16 +507,16 @@ export function Sidebar() { onClick={() => setCurrentView("welcome")} data-testid="logo-button" > -
+
Automaker Logo
@@ -455,7 +534,7 @@ export function Sidebar() { title="New Project" data-testid="new-project-button" > - + New @@ -467,13 +546,23 @@ export function Sidebar() { data-testid="open-project-button" > - - Open - {ACTION_SHORTCUTS.openProject} +
)} @@ -581,7 +670,7 @@ export function Sidebar() { isActive ? "bg-sidebar-accent/50 text-foreground border border-sidebar-border" : "text-muted-foreground hover:text-foreground hover:bg-sidebar-accent/50", - !sidebarOpen && "justify-center" + sidebarOpen ? "justify-start" : "justify-center" )} title={!sidebarOpen ? item.label : undefined} data-testid={`nav-${item.id}`} @@ -599,7 +688,7 @@ export function Sidebar() { /> @@ -665,7 +754,7 @@ export function Sidebar() { /> @@ -691,6 +780,91 @@ export function Sidebar() { + + + + Trash + + Restore projects to the sidebar or delete their folders using your + system Trash. + + + + {trashedProjects.length === 0 ? ( +

Trash is empty.

+ ) : ( +
+ {trashedProjects.map((project) => ( +
+
+

+ {project.name} +

+

+ {project.path} +

+

+ Trashed {new Date(project.trashedAt).toLocaleString()} +

+
+
+ + + +
+
+ ))} +
+ )} + + + + {trashedProjects.length > 0 && ( + + )} + +
+
); } diff --git a/app/src/components/views/agent-output-modal.tsx b/app/src/components/views/agent-output-modal.tsx index 7e839df0..ed7bef29 100644 --- a/app/src/components/views/agent-output-modal.tsx +++ b/app/src/components/views/agent-output-modal.tsx @@ -237,7 +237,7 @@ export function AgentOutputModal({ return ( diff --git a/app/src/components/views/board-view.tsx b/app/src/components/views/board-view.tsx index 241e1e07..f1d14f1c 100644 --- a/app/src/components/views/board-view.tsx +++ b/app/src/components/views/board-view.tsx @@ -416,17 +416,35 @@ export function BoardView() { } }, [showAddDialog, defaultSkipTests]); - - // Listen for auto mode feature completion and reload features + // Listen for auto mode feature completion and errors to reload features useEffect(() => { const api = getElectronAPI(); if (!api?.autoMode) return; + const { removeRunningTask } = useAppStore.getState(); + const unsubscribe = api.autoMode.onEvent((event) => { if (event.type === "auto_mode_feature_complete") { // Reload features when a feature is completed console.log("[Board] Feature completed, reloading features..."); loadFeatures(); + } else if (event.type === "auto_mode_error") { + // Reload features when an error occurs (feature moved to waiting_approval) + console.log( + "[Board] Feature error, reloading features...", + event.error + ); + + // Remove from running tasks so it moves to the correct column + if (event.featureId) { + removeRunningTask(event.featureId); + } + + loadFeatures(); + // Show error toast + toast.error("Agent encountered an error", { + description: event.error || "Check the logs for details", + }); } }); @@ -478,7 +496,10 @@ export function BoardView() { const checkAllContexts = async () => { // Check context for in_progress, waiting_approval, and verified features const featuresWithPotentialContext = features.filter( - (f) => f.status === "in_progress" || f.status === "waiting_approval" || f.status === "verified" + (f) => + f.status === "in_progress" || + f.status === "waiting_approval" || + f.status === "verified" ); const contextChecks = await Promise.all( featuresWithPotentialContext.map(async (f) => ({ @@ -520,6 +541,7 @@ export function BoardView() { summary: f.summary, model: f.model, thinkingLevel: f.thinkingLevel, + error: f.error, })); await api.writeFile( `${currentProject.path}/.automaker/feature_list.json`, @@ -754,7 +776,9 @@ export function BoardView() { console.log(`[Board] Deleted agent context for feature ${featureId}`); } catch (error) { // Context file might not exist, which is fine - console.log(`[Board] Context file not found or already deleted for feature ${featureId}`); + console.log( + `[Board] Context file not found or already deleted for feature ${featureId}` + ); } } @@ -767,11 +791,17 @@ export function BoardView() { await api.deleteFile(imagePathObj.path); console.log(`[Board] Deleted image: ${imagePathObj.path}`); } catch (error) { - console.error(`[Board] Failed to delete image ${imagePathObj.path}:`, error); + console.error( + `[Board] Failed to delete image ${imagePathObj.path}:`, + error + ); } } } catch (error) { - console.error(`[Board] Error deleting images for feature ${featureId}:`, error); + console.error( + `[Board] Error deleting images for feature ${featureId}:`, + error + ); } } @@ -2009,10 +2039,15 @@ export function BoardView() { try { const contextPath = `${currentProject.path}/.automaker/agents-context/${feature.id}.md`; await api.deleteFile(contextPath); - console.log(`[Board] Deleted agent context for feature ${feature.id}`); + console.log( + `[Board] Deleted agent context for feature ${feature.id}` + ); } catch (error) { // Context file might not exist, which is fine - console.debug("[Board] No context file to delete for feature:", feature.id); + console.debug( + "[Board] No context file to delete for feature:", + feature.id + ); } // Remove the feature diff --git a/app/src/components/views/kanban-card.tsx b/app/src/components/views/kanban-card.tsx index 829ff1be..28c813b8 100644 --- a/app/src/components/views/kanban-card.tsx +++ b/app/src/components/views/kanban-card.tsx @@ -39,7 +39,6 @@ import { RotateCcw, StopCircle, Hand, - ArrowLeft, MessageSquare, GitCommit, Cpu, @@ -49,6 +48,7 @@ import { Expand, FileText, MoreVertical, + AlertCircle, } from "lucide-react"; import { CountUpTimer } from "@/components/ui/count-up-timer"; import { getElectronAPI } from "@/lib/electron"; @@ -199,7 +199,10 @@ export function KanbanCard({ "cursor-grab active:cursor-grabbing transition-all backdrop-blur-sm border-border relative kanban-card-content", isDragging && "opacity-50 scale-105 shadow-lg", isCurrentAutoTask && - "border-running-indicator border-2 shadow-running-indicator/50 shadow-lg animate-pulse" + "border-running-indicator border-2 shadow-running-indicator/50 shadow-lg animate-pulse", + feature.error && + !isCurrentAutoTask && + "border-red-500 border-2 shadow-red-500/30 shadow-lg" )} data-testid={`kanban-card-${feature.id}`} {...attributes} @@ -214,7 +217,7 @@ export function KanbanCard({ )} {/* Skip Tests indicator badge */} - {feature.skipTests && ( + {feature.skipTests && !feature.error && (
Manual
)} + {/* Error indicator badge */} + {feature.error && ( +
+ + Errored +
+ )} {isCurrentAutoTask && (
@@ -255,6 +273,28 @@ export function KanbanCard({ + { + e.stopPropagation(); + onEdit(); + }} + data-testid={`edit-feature-${feature.id}`} + > + + Edit + + {onViewOutput && ( + { + e.stopPropagation(); + onViewOutput(); + }} + data-testid={`view-logs-${feature.id}`} + > + + Logs + + )} { @@ -565,55 +605,10 @@ export function KanbanCard({ Logs )} - {/* Move back button for skipTests verified features */} - {feature.skipTests && onMoveBackToInProgress && ( - - )} - )} {!isCurrentAutoTask && feature.status === "waiting_approval" && ( <> - {/* Logs button if context exists */} - {hasContext && onViewOutput && ( - - )} {/* Follow-up prompt button */} {onFollowUp && ( )}
diff --git a/app/src/components/views/settings-view.tsx b/app/src/components/views/settings-view.tsx index 2749ed10..ae5277a8 100644 --- a/app/src/components/views/settings-view.tsx +++ b/app/src/components/views/settings-view.tsx @@ -1,10 +1,11 @@ "use client"; -import { useState, useEffect } from "react"; +import { useState, useEffect, useRef, useCallback } from "react"; import { useAppStore } from "@/store/app-store"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; +import { cn } from "@/lib/utils"; import { Settings, Key, @@ -32,9 +33,28 @@ import { Square, Maximize2, FlaskConical, + Trash2, + Folder, } from "lucide-react"; import { getElectronAPI } from "@/lib/electron"; import { Checkbox } from "@/components/ui/checkbox"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog"; + +// Navigation items for the side panel +const NAV_ITEMS = [ + { id: "api-keys", label: "API Keys", icon: Key }, + { id: "appearance", label: "Appearance", icon: Palette }, + { id: "kanban", label: "Kanban Display", icon: LayoutGrid }, + { id: "defaults", label: "Feature Defaults", icon: FlaskConical }, + { id: "danger", label: "Danger Zone", icon: Trash2 }, +]; export function SettingsView() { const { @@ -47,6 +67,8 @@ export function SettingsView() { setKanbanCardDetailLevel, defaultSkipTests, setDefaultSkipTests, + currentProject, + moveProjectToTrash, } = useAppStore(); const [anthropicKey, setAnthropicKey] = useState(apiKeys.anthropic); const [googleKey, setGoogleKey] = useState(apiKeys.google); @@ -101,6 +123,9 @@ export function SettingsView() { success: boolean; message: string; } | null>(null); + const [activeSection, setActiveSection] = useState("api-keys"); + const [showDeleteDialog, setShowDeleteDialog] = useState(false); + const scrollContainerRef = useRef(null); useEffect(() => { setAnthropicKey(apiKeys.anthropic); @@ -131,6 +156,52 @@ export function SettingsView() { checkCliStatus(); }, []); + // Track scroll position to highlight active nav item + useEffect(() => { + const container = scrollContainerRef.current; + if (!container) return; + + const handleScroll = () => { + const sections = NAV_ITEMS.map((item) => ({ + id: item.id, + element: document.getElementById(item.id), + })).filter((s) => s.element); + + const containerRect = container.getBoundingClientRect(); + const scrollTop = container.scrollTop; + + for (let i = sections.length - 1; i >= 0; i--) { + const section = sections[i]; + if (section.element) { + const rect = section.element.getBoundingClientRect(); + const relativeTop = rect.top - containerRect.top + scrollTop; + if (scrollTop >= relativeTop - 100) { + setActiveSection(section.id); + break; + } + } + } + }; + + container.addEventListener("scroll", handleScroll); + return () => container.removeEventListener("scroll", handleScroll); + }, []); + + const scrollToSection = useCallback((sectionId: string) => { + const element = document.getElementById(sectionId); + if (element && scrollContainerRef.current) { + const container = scrollContainerRef.current; + const containerRect = container.getBoundingClientRect(); + const elementRect = element.getBoundingClientRect(); + const relativeTop = elementRect.top - containerRect.top + container.scrollTop; + + container.scrollTo({ + top: relativeTop - 24, + behavior: "smooth", + }); + } + }, []); + const handleTestConnection = async () => { setTestingConnection(true); setTestResult(null); @@ -157,7 +228,7 @@ export function SettingsView() { message: data.error || "Failed to connect to Claude API.", }); } - } catch (error) { + } catch { setTestResult({ success: false, message: "Network error. Please check your connection.", @@ -193,7 +264,7 @@ export function SettingsView() { message: data.error || "Failed to connect to Gemini API.", }); } - } catch (error) { + } catch { setGeminiTestResult({ success: false, message: "Network error. Please check your connection.", @@ -246,7 +317,7 @@ export function SettingsView() { }); } } - } catch (error) { + } catch { setOpenaiTestResult({ success: false, message: "Network error. Please check your connection.", @@ -288,23 +359,60 @@ export function SettingsView() { - {/* Content Area */} -
-
- {/* API Keys Section */} -
-
-
- -

- API Keys -

+ {/* Content Area with Sidebar */} +
+ {/* Sticky Side Navigation */} + + + {/* Scrollable Content */} +
+
+ {/* API Keys Section */} +
+
+
+ +

+ API Keys +

+
+

+ Configure your AI provider API keys. Keys are stored locally in + your browser. +

-

- Configure your AI provider API keys. Keys are stored locally in - your browser. -

-
{/* Claude/Anthropic API Key */}
@@ -592,7 +700,7 @@ export function SettingsView() {

Security Notice

- API keys are stored in your browser's local storage. Never + API keys are stored in your browser's local storage. Never share your API keys or commit them to version control.

@@ -780,7 +888,10 @@ export function SettingsView() { )} {/* Appearance Section */} -
+
@@ -958,7 +1069,10 @@ export function SettingsView() {
{/* Kanban Card Display Section */} -
+
@@ -1036,7 +1150,10 @@ export function SettingsView() {
{/* Feature Defaults Section */} -
+
@@ -1078,6 +1195,51 @@ export function SettingsView() {
+ {/* Delete Project Section - Only show when a project is selected */} + {currentProject && ( +
+
+
+ +

+ Danger Zone +

+
+

+ Permanently remove this project from Automaker. +

+
+
+
+
+
+ +
+
+

+ {currentProject.name} +

+

+ {currentProject.path} +

+
+
+ +
+
+
+ )} + {/* Save Button */}
+
+ + {/* Delete Project Confirmation Dialog */} + + + + + + Delete Project + + + Are you sure you want to move this project to Trash? + + + + {currentProject && ( +
+
+ +
+
+

+ {currentProject.name} +

+

+ {currentProject.path} +

+
+
+ )} + +

+ The folder will remain on disk until you permanently delete it from Trash. +

+ + + + + +
+
); } diff --git a/app/src/components/views/welcome-view.tsx b/app/src/components/views/welcome-view.tsx index 5c690543..901e0fa7 100644 --- a/app/src/components/views/welcome-view.tsx +++ b/app/src/components/views/welcome-view.tsx @@ -284,11 +284,7 @@ export function WelcomeView() {
- Automaker Logo + Automaker Logo

diff --git a/app/src/lib/electron.ts b/app/src/lib/electron.ts index 3b794cd1..b7904f1d 100644 --- a/app/src/lib/electron.ts +++ b/app/src/lib/electron.ts @@ -76,6 +76,7 @@ export interface ElectronAPI { exists: (filePath: string) => Promise; stat: (filePath: string) => Promise; deleteFile: (filePath: string) => Promise; + trashItem?: (filePath: string) => Promise; getPath: (name: string) => Promise; saveImageToTemp?: (data: string, filename: string, mimeType: string) => Promise; autoMode?: AutoModeAPI; @@ -150,6 +151,7 @@ const mockFeatures = [ const STORAGE_KEYS = { PROJECTS: "automaker_projects", CURRENT_PROJECT: "automaker_current_project", + TRASHED_PROJECTS: "automaker_trashed_projects", } as const; // Mock file system using localStorage @@ -370,6 +372,10 @@ export const getElectronAPI = (): ElectronAPI => { return { success: true }; }, + trashItem: async () => { + return { success: true }; + }, + getPath: async (name: string) => { if (name === "userData") { return "/mock/userData"; @@ -828,6 +834,11 @@ export interface Project { lastOpened?: string; } +export interface TrashedProject extends Project { + trashedAt: string; + deletedFromDisk?: boolean; +} + export const getStoredProjects = (): Project[] => { if (typeof window === "undefined") return []; const stored = localStorage.getItem(STORAGE_KEYS.PROJECTS); @@ -869,3 +880,14 @@ export const removeProject = (projectId: string): void => { const projects = getStoredProjects().filter((p) => p.id !== projectId); saveProjects(projects); }; + +export const getStoredTrashedProjects = (): TrashedProject[] => { + if (typeof window === "undefined") return []; + const stored = localStorage.getItem(STORAGE_KEYS.TRASHED_PROJECTS); + return stored ? JSON.parse(stored) : []; +}; + +export const saveTrashedProjects = (projects: TrashedProject[]): void => { + if (typeof window === "undefined") return; + localStorage.setItem(STORAGE_KEYS.TRASHED_PROJECTS, JSON.stringify(projects)); +}; diff --git a/app/src/store/app-store.ts b/app/src/store/app-store.ts index 32db36b4..f581410f 100644 --- a/app/src/store/app-store.ts +++ b/app/src/store/app-store.ts @@ -1,6 +1,6 @@ import { create } from "zustand"; import { persist } from "zustand/middleware"; -import type { Project } from "@/lib/electron"; +import type { Project, TrashedProject } from "@/lib/electron"; export type ViewMode = | "welcome" @@ -107,12 +107,14 @@ export interface Feature { summary?: string; // Summary of what was done/modified by the agent model?: AgentModel; // Model to use for this feature (defaults to opus) thinkingLevel?: ThinkingLevel; // Thinking level for extended thinking (defaults to none) + error?: string; // Error message if the agent errored during processing } export interface AppState { // Project state projects: Project[]; currentProject: Project | null; + trashedProjects: TrashedProject[]; // View state currentView: ViewMode; @@ -175,6 +177,10 @@ export interface AppActions { setProjects: (projects: Project[]) => void; addProject: (project: Project) => void; removeProject: (projectId: string) => void; + moveProjectToTrash: (projectId: string) => void; + restoreTrashedProject: (projectId: string) => void; + deleteTrashedProject: (projectId: string) => void; + emptyTrash: () => void; setCurrentProject: (project: Project | null) => void; reorderProjects: (oldIndex: number, newIndex: number) => void; @@ -237,6 +243,7 @@ export interface AppActions { const initialState: AppState = { projects: [], currentProject: null, + trashedProjects: [], currentView: "welcome", sidebarOpen: true, theme: "dark", @@ -291,6 +298,82 @@ export const useAppStore = create()( set({ projects: get().projects.filter((p) => p.id !== projectId) }); }, + moveProjectToTrash: (projectId) => { + const project = get().projects.find((p) => p.id === projectId); + if (!project) return; + + const remainingProjects = get().projects.filter( + (p) => p.id !== projectId + ); + const existingTrash = get().trashedProjects.filter( + (p) => p.id !== projectId + ); + const trashedProject: TrashedProject = { + ...project, + trashedAt: new Date().toISOString(), + deletedFromDisk: false, + }; + + const isCurrent = get().currentProject?.id === projectId; + + set({ + projects: remainingProjects, + trashedProjects: [trashedProject, ...existingTrash], + currentProject: isCurrent ? null : get().currentProject, + currentView: isCurrent ? "welcome" : get().currentView, + }); + }, + + restoreTrashedProject: (projectId) => { + const trashed = get().trashedProjects.find((p) => p.id === projectId); + if (!trashed) return; + + const remainingTrash = get().trashedProjects.filter( + (p) => p.id !== projectId + ); + const existingProjects = get().projects; + const samePathProject = existingProjects.find( + (p) => p.path === trashed.path + ); + const projectsWithoutId = existingProjects.filter( + (p) => p.id !== projectId + ); + + // If a project with the same path already exists, keep it and just remove from trash + if (samePathProject) { + set({ + trashedProjects: remainingTrash, + currentProject: samePathProject, + currentView: "board", + }); + return; + } + + const restoredProject: Project = { + id: trashed.id, + name: trashed.name, + path: trashed.path, + lastOpened: new Date().toISOString(), + }; + + set({ + trashedProjects: remainingTrash, + projects: [...projectsWithoutId, restoredProject], + currentProject: restoredProject, + currentView: "board", + }); + }, + + deleteTrashedProject: (projectId) => { + set({ + trashedProjects: get().trashedProjects.filter( + (p) => p.id !== projectId + ), + }); + }, + + emptyTrash: () => set({ trashedProjects: [] }), + reorderProjects: (oldIndex, newIndex) => { const projects = [...get().projects]; const [movedProject] = projects.splice(oldIndex, 1); @@ -517,6 +600,7 @@ export const useAppStore = create()( partialize: (state) => ({ projects: state.projects, currentProject: state.currentProject, + trashedProjects: state.trashedProjects, currentView: state.currentView, theme: state.theme, sidebarOpen: state.sidebarOpen,