mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 08:53:36 +00:00
fix: resolve data directory persistence between Electron and Web modes
This commit fixes bidirectional data synchronization between Electron and Web modes by addressing multiple interconnected issues: **Core Fixes:** 1. **Electron userData Path (main.ts)** - Explicitly set userData path in development using app.setPath() - Navigate from __dirname to project root instead of relying on process.cwd() - Ensures Electron reads from /data instead of ~/.config/Automaker 2. **Server DataDir Path (main.ts, start-automaker.sh)** - Fixed startServer() to use __dirname for reliable path calculation - Export DATA_DIR environment variable in start-automaker.sh - Server now consistently uses shared /data directory 3. **Settings Sync Protection (settings-service.ts)** - Modified wipe protection to distinguish legitimate removals from accidents - Allow empty projects array if trashedProjects has items - Prevent false-positive wipe detection when removing projects 4. **Diagnostics & Logging** - Enhanced cache loading logging in use-settings-migration.ts - Detailed migration decision logs for troubleshooting - Track project counts from both cache and server **Impact:** - Projects created in Electron now appear in Web mode after restart - Projects removed in Web mode stay removed in Electron after restart - Settings changes sync bidirectionally across mode switches - No more data loss or project duplication issues **Testing:** - Verified Electron uses /home/dhanush/Projects/automaker/data - Confirmed server startup logs show correct DATA_DIR - Tested project persistence across mode restarts - Validated no writes to ~/.config/Automaker in dev mode Fixes: Data persistence between Electron and Web modes Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1504,7 +1504,16 @@ export const useAppStore = create<AppState & AppActions>()((set, get) => ({
|
||||
|
||||
moveProjectToTrash: (projectId) => {
|
||||
const project = get().projects.find((p) => p.id === projectId);
|
||||
if (!project) return;
|
||||
if (!project) {
|
||||
console.warn('[MOVE_TO_TRASH] Project not found:', projectId);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[MOVE_TO_TRASH] Moving project to trash:', {
|
||||
projectId,
|
||||
projectName: project.name,
|
||||
currentProjectCount: get().projects.length,
|
||||
});
|
||||
|
||||
const remainingProjects = get().projects.filter((p) => p.id !== projectId);
|
||||
const existingTrash = get().trashedProjects.filter((p) => p.id !== projectId);
|
||||
@@ -1517,6 +1526,11 @@ export const useAppStore = create<AppState & AppActions>()((set, get) => ({
|
||||
const isCurrent = get().currentProject?.id === projectId;
|
||||
const nextCurrentProject = isCurrent ? null : get().currentProject;
|
||||
|
||||
console.log('[MOVE_TO_TRASH] Updating store with new state:', {
|
||||
newProjectCount: remainingProjects.length,
|
||||
newTrashedCount: [trashedProject, ...existingTrash].length,
|
||||
});
|
||||
|
||||
set({
|
||||
projects: remainingProjects,
|
||||
trashedProjects: [trashedProject, ...existingTrash],
|
||||
|
||||
Reference in New Issue
Block a user