diff --git a/apps/ui/src/lib/workspace-config.ts b/apps/ui/src/lib/workspace-config.ts index d92bd671..e1d32837 100644 --- a/apps/ui/src/lib/workspace-config.ts +++ b/apps/ui/src/lib/workspace-config.ts @@ -5,7 +5,6 @@ import { createLogger } from '@automaker/utils/logger'; import { getHttpApiClient } from './http-api-client'; -import { getElectronAPI } from './electron'; import { useAppStore } from '@/store/app-store'; const logger = createLogger('WorkspaceConfig'); @@ -33,9 +32,17 @@ function joinPath(...parts: string[]): string { */ async function getDefaultDocumentsPath(): Promise { try { - const api = getElectronAPI(); - const documentsPath = await api.getPath('documents'); - return joinPath(documentsPath, 'Automaker'); + // In Electron mode, use the native getPath API directly from the preload script + // This returns the actual system Documents folder (e.g., C:\Users\\Documents on Windows) + // Note: The HTTP client's getPath returns incorrect Unix-style paths for 'documents' + if (typeof window !== 'undefined' && (window as any).electronAPI?.getPath) { + const documentsPath = await (window as any).electronAPI.getPath('documents'); + return joinPath(documentsPath, 'Automaker'); + } + + // In web mode (no Electron), we can't access the user's Documents folder + // Return null to let the caller use other fallback mechanisms (like server's DATA_DIR) + return null; } catch (error) { logger.error('Failed to get documents path:', error); return null; @@ -76,6 +83,7 @@ export async function getDefaultWorkspaceDirectory(): Promise { // Try to get Documents/Automaker const documentsPath = await getDefaultDocumentsPath(); + logger.info('Default documentsPath resolved to:', documentsPath); if (documentsPath) { return documentsPath; }