Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions Frontend/src/scripts/features/branches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLButtonElement>('#branch-switch');
const branchName = qs<HTMLElement>('#branch-name');
Expand Down Expand Up @@ -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 = '<span class="badge kind">Local</span>';
else if (kindType.toLowerCase() === 'remote') kindLabel = `<span class="badge kind">Remote:${remote || 'remote'}</span>`;
else if (remote) kindLabel = `<span class="badge kind">Remote:${remote || 'remote'}</span>`;
else if (kindType.toLowerCase() === 'remote') kindLabel = `<span class="badge kind">Remote:${remoteLabel}</span>`;
else if (remote) kindLabel = `<span class="badge kind">Remote:${remoteLabel}</span>`;
return `
<li role="option" data-branch="${b.name}" aria-selected="${b.current ? 'true' : 'false'}">
<span class="label">
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
}
}
}});
}
Expand Down
Loading