diff --git a/main.js b/main.js index 6396f02..308f35f 100644 --- a/main.js +++ b/main.js @@ -231,6 +231,25 @@ function stopMonitoringWatcher(folderPath) { } } +// (1) Die Kernfunktion +async function addFolderByPath(newFolder) { + await initGitRepo(newFolder); + let folders = store.get('folders') || []; + let folderObj = folders.find(f => f.path === newFolder); + if (!folderObj) { + folderObj = { path: newFolder, monitoring: true, linesChanged: 0, llmCandidates: [] }; + folders.push(folderObj); + store.set('folders', folders); + } + store.set('selected', newFolder); + watchRepo(newFolder, win); + startMonitoringWatcher(newFolder, win); + return store.get('folders'); +} + + + + // ---- Rewrite Git Messages with LLM generated messages ---- // ---- 1. Commits & Diffs für LLM sammeln ---- @@ -775,6 +794,23 @@ function buildTrayMenu() { ipcMain.handle('get-folders', () => store.get('folders')); + + // (2) Die IPC-Handler anpassen: + ipcMain.handle('add-folder', async () => { + const { canceled, filePaths } = await dialog.showOpenDialog({ + properties: ['openDirectory'] + }); + if (canceled || !filePaths[0]) { + return store.get('folders'); + } + return await addFolderByPath(filePaths[0]); + }); + + ipcMain.handle('add-folder-by-path', async (_e, folderPath) => { + return await addFolderByPath(folderPath); + }); + + // Ordner hinzufügen: Open-Dialog, init, Store-Update, watchen, monitoren ipcMain.handle('add-folder', async () => { const { canceled, filePaths } = await dialog.showOpenDialog({ @@ -785,7 +821,7 @@ function buildTrayMenu() { } const newFolder = filePaths[0]; - + await initGitRepo(newFolder); // HEAD-Hash holen