-
Notifications
You must be signed in to change notification settings - Fork 0
feat: launch Claude session as git worktree (⌘+Shift+Enter) #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
7dc2e63
160a159
1f3323b
5545f31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2149,6 +2149,16 @@ ipcMain.on('launch-new-claude-session', async (_event, projectPath: string) => { | |
| launchNewClaudeSession(projectPath, terminalApp, terminalMode); | ||
| }); | ||
|
|
||
| ipcMain.on('launch-new-claude-session-worktree', async (_event, projectPath: string, worktreeName: string) => { | ||
| if (!existsSync(projectPath)) { | ||
| console.log('[launch-new-claude-session-worktree] path does not exist:', projectPath); | ||
| return; | ||
| } | ||
| const terminalApp = ((await settings.get('session-terminal-app')) || 'iterm2') as string; | ||
| const terminalMode = ((await settings.get('session-terminal-mode')) || 'tab') as string; | ||
| launchNewClaudeSession(projectPath, terminalApp, terminalMode, worktreeName); | ||
|
grimmerk marked this conversation as resolved.
Comment on lines
+2153
to
+2165
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reject non-directory targets before starting a worktree session. This handler only checks Suggested hardening-import { existsSync, readdirSync } from 'fs';
+import { existsSync, readdirSync, statSync } from 'fs';
...
ipcMain.on('launch-new-claude-session-worktree', async (_event, projectPath: string, worktreeName: string) => {
if (!existsSync(projectPath)) {
console.log('[launch-new-claude-session-worktree] path does not exist:', projectPath);
return;
}
+ if (!statSync(projectPath).isDirectory()) {
+ console.error('[launch-new-claude-session-worktree] projectPath is not a directory:', projectPath);
+ return;
+ }
// Validate at IPC boundary (defense in depth) — the renderer also validates.
if (!isValidWorktreeName(worktreeName)) {
console.error('[launch-new-claude-session-worktree] invalid worktreeName:', JSON.stringify(worktreeName));
return;
}🤖 Prompt for AI Agents |
||
| }); | ||
|
|
||
| ipcMain.on('launch-new-claude-session-in-codev', (_event, projectPath: string) => { | ||
| if (!existsSync(projectPath)) { | ||
| console.log('[launch-new-claude-session-in-codev] path does not exist:', projectPath); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parseWorktreePath()breaks on slash-delimited worktree names.isValidWorktreeName()explicitly allows names likefix/login-bug, but this regex only captures a single segment after/.claude/worktrees/. For a path like/repo/.claude/worktrees/fix/login-bug, it misidentifies the parent repo as/repo/.claude/worktrees/fix, so the newprojectName/isWorktreemetadata is wrong across history reads and active-session detection.Suggested fix
export const parseWorktreePath = ( p: string, ): { parentRepo: string; worktreeName: string } | null => { if (!p) return null; - const match = p.match(/^(.+)\/\.claude\/worktrees\/([^/]+)\/?$/); - return match ? { parentRepo: match[1], worktreeName: match[2] } : null; + const marker = `${path.sep}.claude${path.sep}worktrees${path.sep}`; + const idx = p.indexOf(marker); + if (idx === -1) return null; + const parentRepo = p.slice(0, idx); + const worktreeName = p.slice(idx + marker.length).replace(/\/$/, ''); + if (!parentRepo || !worktreeName) return null; + return { parentRepo, worktreeName }; };🤖 Prompt for AI Agents