Skip to content

fix(branch-selector): show loading state instead of "No branches"#1967

Merged
jonathanlab merged 2 commits intomainfrom
fix/branch-selector-loading-state
May 1, 2026
Merged

fix(branch-selector): show loading state instead of "No branches"#1967
jonathanlab merged 2 commits intomainfrom
fix/branch-selector-loading-state

Conversation

@ryans-posthog
Copy link
Copy Markdown
Contributor

Summary

When the branch list in the branch selector is loading, the dropdown previously showed "No branches found." next to the trigger spinner — confusing UX implying the repo had no branches. This change surfaces a dedicated "Loading branches…" row while the fetch is in flight, so the empty state only appears once the query completes.

  • Captured the previously discarded isLoading flag from the local-mode getAllBranches query.
  • Combined local + cloud loading sources into a single branchListLoading flag.
  • Replaced the always-on <ComboboxEmpty> with a conditional that renders an inline spinner + "Loading branches…" row (mirroring the existing "Loading more (N)…" pattern) while loading and empty, falling back to "No branches found." otherwise so search filtering still works.

Test plan

  • Open branch selector on a fresh local repo — verify "Loading branches…" row appears, then list populates.
  • Open branch selector in cloud mode — verify same loading row, then branches populate.
  • Type a query that matches no branches after load — verify "No branches found." still shows.
  • Open branch selector when branches are already cached — verify no flash of loading row.

Generated-By: PostHog Code
Task-Id: 322fe270-1290-4c9d-b505-1eed6961381f

While the branch list is fetching, the dropdown previously rendered
"No branches found." alongside the trigger spinner. Surface a dedicated
"Loading branches…" row so the empty state only appears once the fetch
completes.

Generated-By: PostHog Code
Task-Id: 322fe270-1290-4c9d-b505-1eed6961381f
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 30, 2026

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/code/src/renderer/features/git-interaction/components/BranchSelector.tsx:258-261
**Duplicated loading-row markup (OnceAndOnlyOnce)**

The new "Loading branches…" row (lines 258–261) has identical structure to the existing "Loading more (N)…" row at lines 251–254 — same `div` className, same `Spinner` props, same layout. Since both are in the same file, extracting a tiny shared helper keeps the pattern in one place and makes future style changes (e.g. icon size, padding) trivially consistent.

Consider extracting:
```tsx
function LoadingRow({ label }: { label: string }): JSX.Element {
  return (
    <div className="flex items-center gap-1 px-2 py-1.5 text-muted-foreground text-xs">
      <Spinner size={12} className="animate-spin" />
      {label}
    </div>
  );
}
```
Then replace both occurrences with `<LoadingRow label="Loading branches…" />` and `<LoadingRow label={\`Loading more (${branches.length})…\`} />`.

Reviews (1): Last reviewed commit: "fix(branch-selector): show loading state..." | Re-trigger Greptile

Comment thread apps/code/src/renderer/features/git-interaction/components/BranchSelector.tsx Outdated
Greptile review feedback: the "Loading branches…" and "Loading more (N)…"
rows shared identical markup. Extract a small LoadingRow helper so future
style changes only need to happen in one place.

Generated-By: PostHog Code
Task-Id: 322fe270-1290-4c9d-b505-1eed6961381f
@jonathanlab jonathanlab merged commit 7980843 into main May 1, 2026
15 checks passed
@jonathanlab jonathanlab deleted the fix/branch-selector-loading-state branch May 1, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants