diff --git a/index.html b/index.html index 8a7cb8e..7a83fbd 100644 --- a/index.html +++ b/index.html @@ -19,6 +19,7 @@
+ + + diff --git a/main.ts b/main.ts index aff9140..30bbe84 100644 --- a/main.ts +++ b/main.ts @@ -212,7 +212,10 @@ ipcMain.on("create-session", async (event, config: SessionConfig) => { let dataBuffer = ""; ptyProcess.onData((data) => { - mainWindow.webContents.send("session-output", sessionId, data); + // Only send data if window still exists and is not destroyed + if (mainWindow && !mainWindow.isDestroyed()) { + mainWindow.webContents.send("session-output", sessionId, data); + } // Detect when terminal is ready if (!terminalReady) { @@ -309,7 +312,10 @@ ipcMain.on("reopen-session", (event, sessionId: string) => { let dataBuffer = ""; ptyProcess.onData((data) => { - mainWindow.webContents.send("session-output", sessionId, data); + // Only send data if window still exists and is not destroyed + if (mainWindow && !mainWindow.isDestroyed()) { + mainWindow.webContents.send("session-output", sessionId, data); + } // Detect when terminal is ready and auto-run agent if (!terminalReady) { @@ -389,6 +395,15 @@ ipcMain.on("rename-session", (_event, sessionId: string, newName: string) => { } }); +// Terminal settings handlers +ipcMain.handle("get-terminal-settings", () => { + return (store as any).get("terminalSettings"); +}); + +ipcMain.handle("save-terminal-settings", (_event, settings: any) => { + (store as any).set("terminalSettings", settings); +}); + // MCP Server management functions async function listMcpServers() { try { @@ -529,6 +544,19 @@ const createWindow = () => { const sessions = getPersistedSessions(); mainWindow.webContents.send("load-persisted-sessions", sessions); }); + + // Clean up PTY processes when window is closed + mainWindow.on("closed", () => { + // Kill all active PTY processes + activePtyProcesses.forEach((ptyProcess, sessionId) => { + try { + ptyProcess.kill(); + } catch (error) { + console.error(`Error killing PTY for session ${sessionId}:`, error); + } + }); + activePtyProcesses.clear(); + }); }; app.whenReady().then(() => { diff --git a/renderer.ts b/renderer.ts index a391659..701094f 100644 --- a/renderer.ts +++ b/renderer.ts @@ -40,19 +40,199 @@ interface McpServer { type?: "stdio" | "sse"; } +interface TerminalSettings { + fontFamily: string; + fontSize: number; + theme: string; // Theme preset name + cursorBlink: boolean; +} + +interface ThemeColors { + background: string; + foreground: string; + cursor?: string; + cursorAccent?: string; + selection?: string; + black?: string; + red?: string; + green?: string; + yellow?: string; + blue?: string; + magenta?: string; + cyan?: string; + white?: string; + brightBlack?: string; + brightRed?: string; + brightGreen?: string; + brightYellow?: string; + brightBlue?: string; + brightMagenta?: string; + brightCyan?: string; + brightWhite?: string; +} + +// Theme presets +const THEME_PRESETS: Record