Skip to content

chore(code): github branch picker loading all branches#1592

Open
VojtechBartos wants to merge 5 commits intomainfrom
vojtab/paginated-branches
Open

chore(code): github branch picker loading all branches#1592
VojtechBartos wants to merge 5 commits intomainfrom
vojtab/paginated-branches

Conversation

@VojtechBartos
Copy link
Copy Markdown
Member

Problem

The branches API was capped at 2000 branches. Repositories with more than that were missing branches in the selector.

Changes

  • Paginate the branches API call with offset/limit, fetching all pages progressively
  • Show the first page of branches immediately while the rest load in the background
  • Display a "Loading more" indicator with running count in the branch dropdown
  • Show a spinner on the branch selector trigger while pages are still loading
  • Disable the branch selector until the first page arrives

Prerequisite

Posthog API changes PostHog/posthog#53931

Showcase

code-paginating.branches.mov

@VojtechBartos VojtechBartos requested a review from a team April 9, 2026 17:09
@VojtechBartos VojtechBartos self-assigned this Apr 9, 2026
Copy link
Copy Markdown
Contributor

adboio commented Apr 9, 2026

i don't think it's your fault haha i'm just curious - where is that latency coming from? looked like at least a few seconds before we got the first page of results - is that posthog api or github api taking so long?

can be a followup, but if there's no way around that, we should consider some local caching here so it's snappier most of the time

);

// Auto-fetch remaining pages in background once the first page arrives
useEffect(() => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we abort this query once the user selects a branch?

or if we keep this and fetch everything even after the user is done, we should at least be caching the results (see global comment)

@VojtechBartos
Copy link
Copy Markdown
Member Author

@adboio soooo :) ...

  • we can fetch max 100 GH branches per page :(
  • each page fetch takes ~400-500ms from my local, i hope it's going to be faster on prod, bud still
  • for each page we were fetching default branch, not efficient

the changes i have made

  • Posthog Code
    • we fetch first page with limit 100 so it's disabled fast and rest with limit 1000
    • we won't show spinner once collapsed
    • we will show only spinner when expanded
    • when you close/choose branch we pause fetching and resume when you open it again
    • changed query data stale time to default 5mins
  • Posthog Backend
    • added caching for the fetching default branch (we can add branches fetching at some point in future if it's really pain)

WDYT?

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