diff --git a/Frontend/src/scripts/features/branches.ts b/Frontend/src/scripts/features/branches.ts index 936b802..63c4a2e 100644 --- a/Frontend/src/scripts/features/branches.ts +++ b/Frontend/src/scripts/features/branches.ts @@ -18,7 +18,8 @@ import type { ConflictDetails, FileStatus } from '../types'; import { openConflictsSummary } from './conflicts'; import { getPluginContextMenuItems, runHook, runPluginAction } from '../plugins'; -type Branch = { name: string; full_ref?: string; current?: boolean; kind?: { type?: string; remote?: string } }; +type BranchKind = { type?: string; remote?: string }; +type Branch = { name: string; full_ref?: string; current?: boolean; kind?: BranchKind }; const branchBtn = qs('#branch-switch'); const branchName = qs('#branch-name'); @@ -85,10 +86,11 @@ function renderBranches() { const kindType = b.kind?.type || ''; const remoteFromName = b.name.includes('/') ? b.name.split('/')[0] : ''; const remote = b.kind?.remote || remoteFromName || ''; + const remoteLabel = remote || 'remote'; let kindLabel = ''; if (kindType.toLowerCase() === 'local') kindLabel = 'Local'; - else if (kindType.toLowerCase() === 'remote') kindLabel = `Remote:${remote || 'remote'}`; - else if (remote) kindLabel = `Remote:${remote || 'remote'}`; + else if (kindType.toLowerCase() === 'remote') kindLabel = `Remote:${remoteLabel}`; + else if (remote) kindLabel = `Remote:${remoteLabel}`; return `
  • @@ -125,7 +127,11 @@ async function openBranchPopover() { branchPop.style.top = `${r.bottom + 6}px`; branchPop.hidden = false; branchBtn.setAttribute('aria-expanded', 'true'); - try { refreshOverlayScrollbarsFor(branchPop); } catch {} + try { + refreshOverlayScrollbarsFor(branchPop); + } catch (err) { + console.debug('Failed to refresh scrollbars for branch popover:', err); + } setTimeout(() => branchFilter?.focus(), 0); } @@ -234,8 +240,8 @@ export function bindBranchUI() { items.push({ label: 'Set upstream…', action: async () => { await loadBranches(); const remoteBranches = (state.branches || []) - .filter((br: any) => (br?.kind?.type || '').toLowerCase() === 'remote') - .map((br: any) => String(br?.name || '').trim()) + .filter((br: Branch) => (br?.kind?.type || '').toLowerCase() === 'remote') + .map((br: Branch) => String(br?.name || '').trim()) .filter((s: string) => !!s); if (remoteBranches.length === 0) { @@ -285,7 +291,10 @@ export function bindBranchUI() { notify(`Force-deleted '${name}'`); await loadBranches(); await runHook('postBranchDelete', hookData); - } catch (e) { console.error('Force delete failed:', e); notify('Force delete failed'); } + } catch (e) { + console.error('Force delete failed:', e); + notify('Force delete failed'); + } } }}); }