Skip to content

Commit 4ce0384

Browse files
committed
claude starts
1 parent f61aca9 commit 4ce0384

File tree

3 files changed

+40
-259
lines changed

3 files changed

+40
-259
lines changed

main.ts

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { app, BrowserWindow, ipcMain, dialog } from "electron";
22
import * as pty from "node-pty";
33
import * as os from "os";
44
import { simpleGit } from "simple-git";
5-
import Store from "electron-store";
65

76
interface SessionConfig {
87
projectDir: string;
@@ -12,7 +11,6 @@ interface SessionConfig {
1211

1312
let mainWindow: BrowserWindow;
1413
const sessions = new Map<string, pty.IPty>();
15-
const store = new Store();
1614

1715
// Open directory picker
1816
ipcMain.handle("select-directory", async () => {
@@ -54,8 +52,48 @@ ipcMain.on("create-session", (event, config: SessionConfig) => {
5452

5553
sessions.set(sessionId, ptyProcess);
5654

55+
let terminalReady = false;
56+
let dataBuffer = "";
57+
5758
ptyProcess.onData((data) => {
5859
mainWindow.webContents.send("session-output", sessionId, data);
60+
61+
// Detect when terminal is ready
62+
if (!terminalReady) {
63+
dataBuffer += data;
64+
65+
// Method 1: Look for bracketed paste mode enable sequence
66+
// This is sent by modern shells (zsh, bash) when ready for input
67+
if (dataBuffer.includes("\x1b[?2004h")) {
68+
terminalReady = true;
69+
70+
// Auto-run the selected coding agent
71+
if (config.codingAgent === "claude") {
72+
ptyProcess.write("claude\r");
73+
} else if (config.codingAgent === "codex") {
74+
ptyProcess.write("codex\r");
75+
}
76+
}
77+
78+
// Method 2: Fallback - look for common prompt indicators
79+
// In case bracketed paste mode is disabled
80+
else if (dataBuffer.includes("$ ") || dataBuffer.includes("% ") ||
81+
dataBuffer.includes("> ") || dataBuffer.includes("➜ ") ||
82+
dataBuffer.includes("➜ ") ||
83+
dataBuffer.includes("✗ ") || dataBuffer.includes("✓ ") ||
84+
dataBuffer.endsWith("$") || dataBuffer.endsWith("%") ||
85+
dataBuffer.endsWith(">") || dataBuffer.endsWith("➜") ||
86+
dataBuffer.endsWith("✗") || dataBuffer.endsWith("✓")) {
87+
terminalReady = true;
88+
89+
// Auto-run the selected coding agent
90+
if (config.codingAgent === "claude") {
91+
ptyProcess.write("claude\r");
92+
} else if (config.codingAgent === "codex") {
93+
ptyProcess.write("codex\r");
94+
}
95+
}
96+
}
5997
});
6098

6199
event.reply("session-created", sessionId, config);

0 commit comments

Comments
 (0)