mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-30 06:12:03 +00:00
feat: add debug option for Electron development
- Introduced a new command `dev:electron:debug` in both package.json files to launch Electron with DevTools open. - Updated main.js to conditionally open DevTools based on the `OPEN_DEVTOOLS` environment variable. - Refactored some IPC handler code for better readability and consistency.
This commit is contained in:
@@ -42,7 +42,10 @@ function createWindow() {
|
|||||||
const isDev = !app.isPackaged;
|
const isDev = !app.isPackaged;
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
mainWindow.loadURL("http://localhost:3007");
|
mainWindow.loadURL("http://localhost:3007");
|
||||||
// mainWindow.webContents.openDevTools();
|
// Open DevTools if OPEN_DEVTOOLS environment variable is set
|
||||||
|
if (process.env.OPEN_DEVTOOLS === "true") {
|
||||||
|
mainWindow.webContents.openDevTools();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mainWindow.loadFile(path.join(__dirname, "../.next/server/app/index.html"));
|
mainWindow.loadFile(path.join(__dirname, "../.next/server/app/index.html"));
|
||||||
}
|
}
|
||||||
@@ -894,12 +897,9 @@ ipcMain.handle(
|
|||||||
async (_, { featureId, status, projectPath, summary }) => {
|
async (_, { featureId, status, projectPath, summary }) => {
|
||||||
try {
|
try {
|
||||||
const featureLoader = require("./services/feature-loader");
|
const featureLoader = require("./services/feature-loader");
|
||||||
await featureLoader.updateFeatureStatus(
|
await featureLoader.updateFeatureStatus(featureId, status, projectPath, {
|
||||||
featureId,
|
summary,
|
||||||
status,
|
});
|
||||||
projectPath,
|
|
||||||
{ summary }
|
|
||||||
);
|
|
||||||
|
|
||||||
// Notify renderer if window is available
|
// Notify renderer if window is available
|
||||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||||
@@ -931,51 +931,59 @@ let suggestionsExecution = null;
|
|||||||
* @param {string} projectPath - The path to the project
|
* @param {string} projectPath - The path to the project
|
||||||
* @param {string} suggestionType - Type of suggestions: "features", "refactoring", "security", "performance"
|
* @param {string} suggestionType - Type of suggestions: "features", "refactoring", "security", "performance"
|
||||||
*/
|
*/
|
||||||
ipcMain.handle("suggestions:generate", async (_, { projectPath, suggestionType = "features" }) => {
|
ipcMain.handle(
|
||||||
try {
|
"suggestions:generate",
|
||||||
// Check if already running
|
async (_, { projectPath, suggestionType = "features" }) => {
|
||||||
if (suggestionsExecution && suggestionsExecution.isActive()) {
|
try {
|
||||||
return {
|
// Check if already running
|
||||||
success: false,
|
if (suggestionsExecution && suggestionsExecution.isActive()) {
|
||||||
error: "Suggestions generation is already running",
|
return {
|
||||||
};
|
success: false,
|
||||||
}
|
error: "Suggestions generation is already running",
|
||||||
|
};
|
||||||
// Create execution context
|
|
||||||
suggestionsExecution = {
|
|
||||||
abortController: null,
|
|
||||||
query: null,
|
|
||||||
isActive: () => suggestionsExecution !== null,
|
|
||||||
};
|
|
||||||
|
|
||||||
const sendToRenderer = (data) => {
|
|
||||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
|
||||||
mainWindow.webContents.send("suggestions:event", data);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// Start generating suggestions (runs in background)
|
// Create execution context
|
||||||
featureSuggestionsService
|
suggestionsExecution = {
|
||||||
.generateSuggestions(projectPath, sendToRenderer, suggestionsExecution, suggestionType)
|
abortController: null,
|
||||||
.catch((error) => {
|
query: null,
|
||||||
console.error("[IPC] suggestions:generate background error:", error);
|
isActive: () => suggestionsExecution !== null,
|
||||||
sendToRenderer({
|
};
|
||||||
type: "suggestions_error",
|
|
||||||
error: error.message,
|
const sendToRenderer = (data) => {
|
||||||
|
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||||
|
mainWindow.webContents.send("suggestions:event", data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Start generating suggestions (runs in background)
|
||||||
|
featureSuggestionsService
|
||||||
|
.generateSuggestions(
|
||||||
|
projectPath,
|
||||||
|
sendToRenderer,
|
||||||
|
suggestionsExecution,
|
||||||
|
suggestionType
|
||||||
|
)
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("[IPC] suggestions:generate background error:", error);
|
||||||
|
sendToRenderer({
|
||||||
|
type: "suggestions_error",
|
||||||
|
error: error.message,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
suggestionsExecution = null;
|
||||||
});
|
});
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
suggestionsExecution = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Return immediately
|
// Return immediately
|
||||||
return { success: true };
|
return { success: true };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[IPC] suggestions:generate error:", error);
|
console.error("[IPC] suggestions:generate error:", error);
|
||||||
suggestionsExecution = null;
|
suggestionsExecution = null;
|
||||||
return { success: false, error: error.message };
|
return { success: false, error: error.message };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop the current suggestions generation
|
* Stop the current suggestions generation
|
||||||
@@ -1248,7 +1256,10 @@ ipcMain.handle(
|
|||||||
|
|
||||||
// Check if already running
|
// Check if already running
|
||||||
if (specRegenerationExecution && specRegenerationExecution.isActive()) {
|
if (specRegenerationExecution && specRegenerationExecution.isActive()) {
|
||||||
return { success: false, error: "Spec regeneration is already running" };
|
return {
|
||||||
|
success: false,
|
||||||
|
error: "Spec regeneration is already running",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create execution context
|
// Create execution context
|
||||||
@@ -1266,7 +1277,11 @@ ipcMain.handle(
|
|||||||
|
|
||||||
// Start generating features (runs in background)
|
// Start generating features (runs in background)
|
||||||
specRegenerationService
|
specRegenerationService
|
||||||
.generateFeaturesOnly(projectPath, sendToRenderer, specRegenerationExecution)
|
.generateFeaturesOnly(
|
||||||
|
projectPath,
|
||||||
|
sendToRenderer,
|
||||||
|
specRegenerationExecution
|
||||||
|
)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(
|
console.error(
|
||||||
"[IPC] spec-regeneration:generate-features background error:",
|
"[IPC] spec-regeneration:generate-features background error:",
|
||||||
@@ -1788,7 +1803,10 @@ ipcMain.handle(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const featureLoader = require("./services/feature-loader");
|
const featureLoader = require("./services/feature-loader");
|
||||||
const content = await featureLoader.getAgentOutput(projectPath, featureId);
|
const content = await featureLoader.getAgentOutput(
|
||||||
|
projectPath,
|
||||||
|
featureId
|
||||||
|
);
|
||||||
return { success: true, content };
|
return { success: true, content };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[IPC] features:getAgentOutput error:", error);
|
console.error("[IPC] features:getAgentOutput error:", error);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
"dev": "next dev -p 3007",
|
"dev": "next dev -p 3007",
|
||||||
"dev:web": "next dev -p 3007",
|
"dev:web": "next dev -p 3007",
|
||||||
"dev:electron": "concurrently \"next dev -p 3007\" \"wait-on http://localhost:3007 && electron .\"",
|
"dev:electron": "concurrently \"next dev -p 3007\" \"wait-on http://localhost:3007 && electron .\"",
|
||||||
|
"dev:electron:debug": "concurrently \"next dev -p 3007\" \"wait-on http://localhost:3007 && OPEN_DEVTOOLS=true electron .\"",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"build:electron": "next build && electron-builder",
|
"build:electron": "next build && electron-builder",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"dev": "npm run dev --workspace=apps/app",
|
"dev": "npm run dev --workspace=apps/app",
|
||||||
"dev:web": "npm run dev:web --workspace=apps/app",
|
"dev:web": "npm run dev:web --workspace=apps/app",
|
||||||
"dev:electron": "npm run dev:electron --workspace=apps/app",
|
"dev:electron": "npm run dev:electron --workspace=apps/app",
|
||||||
|
"dev:electron:debug": "npm run dev:electron:debug --workspace=apps/app",
|
||||||
"dev:electron:wsl": "npm run dev:electron:wsl --workspace=apps/app",
|
"dev:electron:wsl": "npm run dev:electron:wsl --workspace=apps/app",
|
||||||
"dev:electron:wsl:gpu": "npm run dev:electron:wsl:gpu --workspace=apps/app",
|
"dev:electron:wsl:gpu": "npm run dev:electron:wsl:gpu --workspace=apps/app",
|
||||||
"build": "npm run build --workspace=apps/app",
|
"build": "npm run build --workspace=apps/app",
|
||||||
|
|||||||
Reference in New Issue
Block a user