From b4f4ee58e5b883343cd2b0d9c38d0a00655c628c Mon Sep 17 00:00:00 2001 From: Bohdan Triapitsyn Date: Sun, 8 Feb 2026 14:28:27 +0200 Subject: [PATCH] feat: infer remotes when none configured in GitView --- packages/ui/src/components/views/GitView.tsx | 35 ++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/views/GitView.tsx b/packages/ui/src/components/views/GitView.tsx index 44e3f5db..1840155f 100644 --- a/packages/ui/src/components/views/GitView.tsx +++ b/packages/ui/src/components/views/GitView.tsx @@ -925,6 +925,35 @@ export const GitView: React.FC = () => { .sort(); }, [branches]); + const effectiveRemotes = React.useMemo(() => { + if (remotes.length > 0) { + return remotes; + } + + const inferredNames = new Set(); + const tracking = status?.tracking?.trim(); + if (tracking && tracking.includes('/')) { + inferredNames.add(tracking.split('/')[0]); + } + + for (const branchName of remoteBranches) { + const slashIndex = branchName.indexOf('/'); + if (slashIndex > 0) { + inferredNames.add(branchName.slice(0, slashIndex)); + } + } + + if (inferredNames.size === 0 && remoteUrl) { + inferredNames.add('origin'); + } + + return Array.from(inferredNames).map((name) => ({ + name, + fetchUrl: remoteUrl ?? '', + pushUrl: remoteUrl ?? '', + })); + }, [remotes, remoteBranches, remoteUrl, status?.tracking]); + const baseBranch = React.useMemo(() => { const fromMeta = typeof worktreeMetadata?.createdFromBranch === 'string' ? worktreeMetadata.createdFromBranch.trim() @@ -1520,7 +1549,7 @@ export const GitView: React.FC = () => { remoteBranches={remoteBranches} branchInfo={branches?.branches} syncAction={syncAction} - remotes={remotes} + remotes={effectiveRemotes} onFetch={(remote) => handleSyncAction('fetch', remote)} onPull={(remote) => handleSyncAction('pull', remote)} onPush={(remote) => handleSyncAction('push', remote)} @@ -1573,8 +1602,8 @@ export const GitView: React.FC = () => { { - if (remotes.length > 0) { - handleSyncAction('pull', remotes[0]); + if (effectiveRemotes.length > 0) { + handleSyncAction('pull', effectiveRemotes[0]); } else { toast.error('No remotes configured'); }