Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion app/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import url from 'url';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import i18n from './i18next.config';
import ElectronMCPClient from './mcp-client';
import {
addToPath,
ArtifactHubHeadlampPkg,
Expand Down Expand Up @@ -134,6 +135,7 @@ const buildManifest = fs.existsSync(manifestFile) ? require(manifestFile) : {};

// make it global so that it doesn't get garbage collected
let mainWindow: BrowserWindow | null;
let mcpClient: ElectronMCPClient;

/**
* `Action` is an interface for an action to be performed by the plugin manager.
Expand Down Expand Up @@ -1108,7 +1110,7 @@ function adjustZoom(delta: number) {

function startElecron() {
console.info('App starting...');

mcpClient = new ElectronMCPClient();
let appVersion: string;
if (isDev && process.env.HEADLAMP_APP_VERSION) {
appVersion = process.env.HEADLAMP_APP_VERSION;
Expand Down Expand Up @@ -1222,6 +1224,9 @@ function startElecron() {
},
});

// Set the main window reference in the MCP client for dialogs
mcpClient.setMainWindow(mainWindow);

// Load the frontend
mainWindow.loadURL(startUrl);

Expand Down Expand Up @@ -1434,6 +1439,14 @@ function startElecron() {
if (mainWindow) {
mainWindow.removeAllListeners('close');
}
// Cleanup MCP client
if (mcpClient) {
mcpClient.cleanup().catch(console.error);
}
// Cleanup MCP client
if (mcpClient) {
mcpClient.cleanup().catch(console.error);
}
});
}

Expand Down
Loading
Loading