From 0785dd7b7b31e190ef58a812ad195fb3cfcfff0e Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Wed, 25 Mar 2026 22:16:11 -0700 Subject: [PATCH] fix: fetch latest remote before worktree creation & improve settings spacing (#105) Co-authored-by: Claude Opus 4.6 --- src/main/ipc/worktrees.ts | 13 ++ .../components/settings/RepositoryPane.tsx | 147 +++++++++--------- 2 files changed, 84 insertions(+), 76 deletions(-) diff --git a/src/main/ipc/worktrees.ts b/src/main/ipc/worktrees.ts index 3c4017678..51a0d6648 100644 --- a/src/main/ipc/worktrees.ts +++ b/src/main/ipc/worktrees.ts @@ -1,5 +1,6 @@ import type { BrowserWindow } from 'electron' import { ipcMain } from 'electron' +import { execFileSync } from 'child_process' import { join, basename, resolve, relative, isAbsolute } from 'path' import type { Store } from '../persistence' import type { Worktree, WorktreeMeta } from '../../shared/types' @@ -86,6 +87,18 @@ export function registerWorktreeHandlers(mainWindow: BrowserWindow, store: Store // Determine base branch const baseBranch = args.baseBranch || repo.worktreeBaseRef || getDefaultBaseRef(repo.path) + // Fetch latest from remote so the worktree starts with up-to-date content + const remote = baseBranch.includes('/') ? baseBranch.split('/')[0] : 'origin' + try { + execFileSync('git', ['fetch', remote], { + cwd: repo.path, + encoding: 'utf-8', + stdio: ['pipe', 'pipe', 'pipe'] + }) + } catch { + // Fetch is best-effort — don't block worktree creation if offline + } + addWorktree(repo.path, worktreePath, branchName, baseBranch) // Re-list to get the freshly created worktree info diff --git a/src/renderer/src/components/settings/RepositoryPane.tsx b/src/renderer/src/components/settings/RepositoryPane.tsx index f24b3fd57..b6fa7418a 100644 --- a/src/renderer/src/components/settings/RepositoryPane.tsx +++ b/src/renderer/src/components/settings/RepositoryPane.tsx @@ -133,7 +133,7 @@ export function RepositoryPane({ return (
-
+

Identity

@@ -186,84 +186,79 @@ export function RepositoryPane({
-
+
-
-
-
-
{effectiveBaseRef}
-

- {repo.worktreeBaseRef - ? 'Pinned for this repo' - : `Following primary branch (${defaultBaseRef})`} -

-
- +
+
+
{effectiveBaseRef}
+

+ {repo.worktreeBaseRef + ? 'Pinned for this repo' + : `Following primary branch (${defaultBaseRef})`} +

- -
- setBaseRefQuery(e.target.value)} - placeholder="Search branches by name..." - className="max-w-md" - /> -

Type at least 2 characters.

-
- - {isSearchingBaseRefs ? ( -

Searching branches...

- ) : null} - - {!isSearchingBaseRefs && baseRefQuery.trim().length >= 2 ? ( - baseRefResults.length > 0 ? ( - -
- {baseRefResults.map((ref) => ( - - ))} -
-
- ) : ( -

No matching branches found.

- ) - ) : null} +
-

- New worktrees default to the repo primary branch unless you pin a different base here. -

+ +
+ setBaseRefQuery(e.target.value)} + placeholder="Search branches by name..." + className="max-w-md" + /> +

Type at least 2 characters.

+
+ + {isSearchingBaseRefs ? ( +

Searching branches...

+ ) : null} + + {!isSearchingBaseRefs && baseRefQuery.trim().length >= 2 ? ( + baseRefResults.length > 0 ? ( + +
+ {baseRefResults.map((ref) => ( + + ))} +
+
+ ) : ( +

No matching branches found.

+ ) + ) : null}