Skip to content

Commit c45ac9e

Browse files
committed
set up commands before claude
1 parent 020d8ba commit c45ac9e

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ <h2 class="modal-title">New Session Configuration</h2>
8686
</label>
8787
</div>
8888

89+
<div class="form-group">
90+
<label class="form-label">Setup Commands (optional)</label>
91+
<textarea id="setup-commands" class="form-input" rows="3" placeholder="Commands to run before starting coding agent (one per line)&#10;e.g., export API_KEY=...&#10;source .env"></textarea>
92+
<span class="text-xs text-gray-400 mt-1 block">These commands will be executed in order before the coding agent starts</span>
93+
</div>
94+
8995
<div class="btn-group">
9096
<button id="cancel-session" class="btn-secondary">Cancel</button>
9197
<button id="create-session" class="btn-primary">Create Session</button>

main.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ interface SessionConfig {
1515
parentBranch: string;
1616
codingAgent: string;
1717
skipPermissions: boolean;
18+
setupCommands?: string[];
1819
}
1920

2021
interface PersistedSession {
@@ -225,6 +226,13 @@ ipcMain.on("create-session", async (event, config: SessionConfig) => {
225226
if (dataBuffer.includes("\x1b[?2004h")) {
226227
terminalReady = true;
227228

229+
// Run setup commands if provided
230+
if (config.setupCommands && config.setupCommands.length > 0) {
231+
config.setupCommands.forEach(cmd => {
232+
ptyProcess.write(cmd + "\r");
233+
});
234+
}
235+
228236
// Auto-run the selected coding agent
229237
if (config.codingAgent === "claude") {
230238
const claudeCmd = config.skipPermissions ? "claude --dangerously-skip-permissions\r" : "claude\r";
@@ -244,6 +252,13 @@ ipcMain.on("create-session", async (event, config: SessionConfig) => {
244252
dataBuffer.endsWith("✗") || dataBuffer.endsWith("✓")) {
245253
terminalReady = true;
246254

255+
// Run setup commands if provided
256+
if (config.setupCommands && config.setupCommands.length > 0) {
257+
config.setupCommands.forEach(cmd => {
258+
ptyProcess.write(cmd + "\r");
259+
});
260+
}
261+
247262
// Auto-run the selected coding agent
248263
if (config.codingAgent === "claude") {
249264
const claudeCmd = config.skipPermissions ? "claude --dangerously-skip-permissions\r" : "claude\r";
@@ -327,6 +342,13 @@ ipcMain.on("reopen-session", (event, sessionId: string) => {
327342
dataBuffer.includes("✓ ")) {
328343
terminalReady = true;
329344

345+
// Run setup commands if provided
346+
if (session.config.setupCommands && session.config.setupCommands.length > 0) {
347+
session.config.setupCommands.forEach(cmd => {
348+
ptyProcess.write(cmd + "\r");
349+
});
350+
}
351+
330352
if (session.config.codingAgent === "claude") {
331353
const claudeCmd = session.config.skipPermissions ? "claude --dangerously-skip-permissions\r" : "claude\r";
332354
ptyProcess.write(claudeCmd);

renderer.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ interface SessionConfig {
77
parentBranch: string;
88
codingAgent: string;
99
skipPermissions: boolean;
10+
setupCommands?: string[];
1011
}
1112

1213
interface PersistedSession {
@@ -806,6 +807,12 @@ document.getElementById("new-session")?.addEventListener("click", async () => {
806807
skipPermissionsCheckbox.checked = lastSettings.skipPermissions;
807808
}
808809

810+
// Set last used setup commands
811+
const setupCommandsTextarea = document.getElementById("setup-commands") as HTMLTextAreaElement;
812+
if (lastSettings.setupCommands && setupCommandsTextarea) {
813+
setupCommandsTextarea.value = lastSettings.setupCommands.join("\n");
814+
}
815+
809816
// Show/hide skip permissions based on coding agent
810817
if (lastSettings.codingAgent === "codex") {
811818
skipPermissionsGroup?.classList.add("hidden");
@@ -853,11 +860,18 @@ createBtn?.addEventListener("click", () => {
853860
return;
854861
}
855862

863+
const setupCommandsTextarea = document.getElementById("setup-commands") as HTMLTextAreaElement;
864+
const setupCommandsText = setupCommandsTextarea?.value.trim();
865+
const setupCommands = setupCommandsText
866+
? setupCommandsText.split("\n").filter(cmd => cmd.trim())
867+
: undefined;
868+
856869
const config: SessionConfig = {
857870
projectDir: selectedDirectory,
858871
parentBranch: parentBranchSelect.value,
859872
codingAgent: codingAgentSelect.value,
860873
skipPermissions: codingAgentSelect.value === "claude" ? skipPermissionsCheckbox.checked : false,
874+
setupCommands,
861875
};
862876

863877
// Save settings for next time
@@ -872,6 +886,9 @@ createBtn?.addEventListener("click", () => {
872886
selectedDirectory = "";
873887
parentBranchSelect.innerHTML = '<option value="">Loading branches...</option>';
874888
codingAgentSelect.value = "claude";
889+
if (setupCommandsTextarea) {
890+
setupCommandsTextarea.value = "";
891+
}
875892
});
876893

877894
// MCP Server management functions

0 commit comments

Comments
 (0)