Skip to content

Commit

Permalink
Enhance window management
Browse files Browse the repository at this point in the history
- Added command-line argument handling for '--run' to execute workflows directly from the command line.
  • Loading branch information
georgi committed Jan 14, 2025
1 parent beb02d1 commit afb63e4
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ const {
dialog,
shell,
systemPreferences,
Tray,
Menu,
BrowserWindow,
} = require("electron");
const { createWindow, forceQuit, handleActivation } = require("./window");
Expand Down Expand Up @@ -38,6 +36,8 @@ let isAppQuitting = false;
let tray = null;
/** @type {import('electron').Menu} */
let contextMenu = null;
/** @type {import('electron').BrowserWindow|null} */
let mainWindow = null;

/**
* Checks and sets up the Python Conda environment
Expand Down Expand Up @@ -75,10 +75,8 @@ async function initialize() {
return;
}

createWindow();
setupAutoUpdater();

// Check if Conda environment exists, but don't update packages
await checkPythonEnvironment();

emitBootMessage("Starting NodeTool server...");
Expand Down Expand Up @@ -148,6 +146,20 @@ app.on("ready", async () => {
await checkMediaPermissions();
await initialize();
await createTray();

// Check for --run argument
const runIndex = process.argv.indexOf("--run");
if (runIndex > -1 && process.argv[runIndex + 1]) {
const workflowId = process.argv[runIndex + 1];
logMessage(`Running workflow from command line: ${workflowId}`);
runWorkflow(workflowId);
return;
}

// Only create main window if --tray flag is not present
if (!process.argv.includes("--tray")) {
mainWindow = createWindow();
}
});

/**
Expand Down Expand Up @@ -287,3 +299,15 @@ ipcMain.on("MAXIMIZE-APP", (event) => {
}
}
});

/**
* IPC handler to show the window when needed
* @returns {void}
*/
ipcMain.handle("show-main-window", () => {
if (!mainWindow) {
mainWindow = createWindow();
} else {
mainWindow.show();
}
});

0 comments on commit afb63e4

Please sign in to comment.