* Gets the default Documents/Automaker directory path * @returns Promise resolving to Documents/Automaker path, or null if unavailable
()
| 31 | * @returns Promise resolving to Documents/Automaker path, or null if unavailable |
| 32 | */ |
| 33 | async function getDefaultDocumentsPath(): Promise<string | null> { |
| 34 | try { |
| 35 | // In Electron mode, use the native getPath API directly from the preload script |
| 36 | // This returns the actual system Documents folder (e.g., C:\Users\<user>\Documents on Windows) |
| 37 | // Note: The HTTP client's getPath returns incorrect Unix-style paths for 'documents' |
| 38 | if (typeof window !== 'undefined' && window.electronAPI?.getPath) { |
| 39 | const documentsPath = await window.electronAPI.getPath('documents'); |
| 40 | return joinPath(documentsPath, 'Automaker'); |
| 41 | } |
| 42 | |
| 43 | // In web mode (no Electron), we can't access the user's Documents folder |
| 44 | // Return null to let the caller use other fallback mechanisms (like server's DATA_DIR) |
| 45 | return null; |
| 46 | } catch (error) { |
| 47 | logger.error('Failed to get documents path:', error); |
| 48 | return null; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Determines the default directory for project creation/opening |
no test coverage detected