Skip to content

Commit f61aca9

Browse files
committed
session config
1 parent 66e0c96 commit f61aca9

File tree

6 files changed

+494
-11
lines changed

6 files changed

+494
-11
lines changed

index.html

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,41 @@ <h1 class="sidebar-title">FleetCode</h1>
4545
</div>
4646
</div>
4747

48+
<!-- Session Configuration Modal -->
49+
<div id="config-modal" class="modal-overlay hidden">
50+
<div class="modal">
51+
<h2 class="modal-title">New Session Configuration</h2>
52+
53+
<div class="form-group">
54+
<label class="form-label">Project Directory</label>
55+
<div class="directory-input-group">
56+
<input type="text" id="project-dir" class="form-input" readonly placeholder="Select a directory..." />
57+
<button id="browse-dir" class="btn-icon">Browse</button>
58+
</div>
59+
</div>
60+
61+
<div class="form-group">
62+
<label class="form-label">Parent Branch</label>
63+
<select id="parent-branch" class="form-select">
64+
<option value="">Loading branches...</option>
65+
</select>
66+
</div>
67+
68+
<div class="form-group">
69+
<label class="form-label">Coding Agent</label>
70+
<select id="coding-agent" class="form-select">
71+
<option value="claude">Claude</option>
72+
<option value="codex">Codex</option>
73+
</select>
74+
</div>
75+
76+
<div class="btn-group">
77+
<button id="cancel-session" class="btn-secondary">Cancel</button>
78+
<button id="create-session" class="btn-primary">Create Session</button>
79+
</div>
80+
</div>
81+
</div>
82+
4883
<script>
4984
require('./dist/renderer.js');
5085
</script>

main.ts

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,54 @@
1-
import { app, BrowserWindow, ipcMain } from "electron";
1+
import { app, BrowserWindow, ipcMain, dialog } from "electron";
22
import * as pty from "node-pty";
33
import * as os from "os";
4+
import { simpleGit } from "simple-git";
5+
import Store from "electron-store";
6+
7+
interface SessionConfig {
8+
projectDir: string;
9+
parentBranch: string;
10+
codingAgent: string;
11+
}
412

513
let mainWindow: BrowserWindow;
614
const sessions = new Map<string, pty.IPty>();
15+
const store = new Store();
16+
17+
// Open directory picker
18+
ipcMain.handle("select-directory", async () => {
19+
const result = await dialog.showOpenDialog(mainWindow, {
20+
properties: ["openDirectory"],
21+
});
22+
23+
if (result.canceled || result.filePaths.length === 0) {
24+
return null;
25+
}
26+
27+
return result.filePaths[0];
28+
});
29+
30+
// Get git branches from directory
31+
ipcMain.handle("get-branches", async (_event, dirPath: string) => {
32+
try {
33+
const git = simpleGit(dirPath);
34+
const branchSummary = await git.branch();
35+
return branchSummary.all;
36+
} catch (error) {
37+
console.error("Error getting branches:", error);
38+
return [];
39+
}
40+
});
741

842
// Create new session
9-
ipcMain.on("create-session", (event) => {
43+
ipcMain.on("create-session", (event, config: SessionConfig) => {
1044
const sessionId = `session-${Date.now()}`;
1145
const shell = os.platform() === "darwin" ? "zsh" : "bash";
1246

1347
const ptyProcess = pty.spawn(shell, [], {
1448
name: "xterm-color",
1549
cols: 80,
1650
rows: 30,
17-
cwd: process.env.HOME,
51+
cwd: config.projectDir || process.env.HOME,
1852
env: process.env,
1953
});
2054

@@ -24,7 +58,7 @@ ipcMain.on("create-session", (event) => {
2458
mainWindow.webContents.send("session-output", sessionId, data);
2559
});
2660

27-
event.reply("session-created", sessionId);
61+
event.reply("session-created", sessionId, config);
2862
});
2963

3064
// Handle session input

0 commit comments

Comments
 (0)