[PR #122] [MERGED] feat: add pagination support for GitHub repositories and branches #431

Closed
opened 2026-02-16 07:19:36 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/open-swe/pull/122
Author: @bracesproul
Created: 6/11/2025
Status: Merged
Merged: 6/11/2025
Merged by: @bracesproul

Base: mainHead: open-swe/e21b097e-d6c5-4388-a8cd-c98a9d438834


📝 Commits (10+)

📊 Changes

11 files changed (+367 additions, -152 deletions)

View changed files

📝 apps/web/src/app/api/github/proxy/[..._path]/route.ts (+5 -0)
📝 apps/web/src/app/api/github/repositories/route.ts (+34 -5)
📝 apps/web/src/app/page.tsx (+10 -7)
📝 apps/web/src/components/github/repo-branch-selectors/branch-selector.tsx (+20 -2)
📝 apps/web/src/components/github/repo-branch-selectors/repository-selector.tsx (+20 -2)
📝 apps/web/src/components/github/repository-list.tsx (+2 -2)
📝 apps/web/src/components/tasks/use-task-plan.tsx (+0 -15)
📝 apps/web/src/components/thread/index.tsx (+4 -6)
📝 apps/web/src/hooks/useGitHubApp.ts (+172 -62)
apps/web/src/providers/GitHubApp.tsx (+27 -0)
📝 apps/web/src/utils/github.ts (+73 -51)

📄 Description

fixes #121
fixes #104

Summary

This PR implements pagination for GitHub repositories and branches to improve performance and reduce API calls for repositories with large numbers of branches.

Changes Made

API Layer

  • Modified GitHub repositories API route (apps/web/src/app/api/github/repositories/route.ts) to support pagination with a 'page' query parameter, returning 100 repositories per page with pagination metadata
  • Updated getInstallationRepositories function (utils/github.ts) to accept pagination parameters and return structured response with hasMore and totalCount
  • Enhanced getRepositoryBranches function (utils/github.ts) to limit fetching to first 100 branches instead of all branches

Hook Layer

  • Enhanced useGitHubApp hook (hooks/useGitHubApp.ts) with comprehensive pagination state management:
    • Added pagination state for both repositories and branches (page, hasMore, loadingMore)
    • Implemented loadMoreRepositories() and loadMoreBranches() functions
    • Added proper state management for appending paginated results
    • Reset pagination state when repository selection changes

UI Components

  • Updated RepositorySelector component to display "Load more" button when additional repositories are available
  • Updated BranchSelector component to display "Load more" button when additional branches are available
  • Both components include loading states and prevent duplicate requests during loading

Key Features

  • Efficient Loading: Repositories and branches are loaded in batches of 100
  • Progressive Loading: "Load more" buttons appear only when additional items are available
  • Loading States: Visual feedback during loading operations with disabled buttons
  • State Management: Proper pagination state reset when switching repositories
  • Performance: Significantly reduces API calls for repositories with many branches

Testing

The implementation maintains backward compatibility while adding pagination functionality. The initial load behavior remains the same, with pagination controls appearing only when needed.

Impact

  • Reduces initial API calls for repositories with many branches
  • Improves page load performance
  • Provides better user experience with progressive loading
  • Maintains existing functionality while adding scalability

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/open-swe/pull/122 **Author:** [@bracesproul](https://github.com/bracesproul) **Created:** 6/11/2025 **Status:** ✅ Merged **Merged:** 6/11/2025 **Merged by:** [@bracesproul](https://github.com/bracesproul) **Base:** `main` ← **Head:** `open-swe/e21b097e-d6c5-4388-a8cd-c98a9d438834` --- ### 📝 Commits (10+) - [`9be5305`](https://github.com/langchain-ai/open-swe/commit/9be5305bf75c234dd256441a1acfb5f99cd87a1b) Apply patch - [`2beb05e`](https://github.com/langchain-ai/open-swe/commit/2beb05e92329aab0133f1de78499c3f5a5d21dda) Apply patch - [`bc1589b`](https://github.com/langchain-ai/open-swe/commit/bc1589bb47804c16781827f9e5b9c51e624a9825) Apply patch - [`6061ae2`](https://github.com/langchain-ai/open-swe/commit/6061ae2c90c536306face1db9499d176d7a21f3c) Apply patch - [`39de8f0`](https://github.com/langchain-ai/open-swe/commit/39de8f0c19ac0bff2711a3691b0ee90fdc443136) Apply patch - [`dfd8130`](https://github.com/langchain-ai/open-swe/commit/dfd81302ced0e175d41b09809aea0d8c53984b07) Apply patch - [`e8c1ae5`](https://github.com/langchain-ai/open-swe/commit/e8c1ae5ddd741d0b44c396d1a69fdb33357a5c08) Apply patch - [`bf58995`](https://github.com/langchain-ai/open-swe/commit/bf5899528f75adc28adfe8705f911a612bb57659) Apply patch - [`349fe92`](https://github.com/langchain-ai/open-swe/commit/349fe926ce72d99bc36a28092cbb7aace7d8b0af) Apply patch - [`74cc304`](https://github.com/langchain-ai/open-swe/commit/74cc3049dbeeccfe5602f6393bca8e80b570c8ce) Apply patch ### 📊 Changes **11 files changed** (+367 additions, -152 deletions) <details> <summary>View changed files</summary> 📝 `apps/web/src/app/api/github/proxy/[..._path]/route.ts` (+5 -0) 📝 `apps/web/src/app/api/github/repositories/route.ts` (+34 -5) 📝 `apps/web/src/app/page.tsx` (+10 -7) 📝 `apps/web/src/components/github/repo-branch-selectors/branch-selector.tsx` (+20 -2) 📝 `apps/web/src/components/github/repo-branch-selectors/repository-selector.tsx` (+20 -2) 📝 `apps/web/src/components/github/repository-list.tsx` (+2 -2) 📝 `apps/web/src/components/tasks/use-task-plan.tsx` (+0 -15) 📝 `apps/web/src/components/thread/index.tsx` (+4 -6) 📝 `apps/web/src/hooks/useGitHubApp.ts` (+172 -62) ➕ `apps/web/src/providers/GitHubApp.tsx` (+27 -0) 📝 `apps/web/src/utils/github.ts` (+73 -51) </details> ### 📄 Description fixes #121 fixes #104 ## Summary This PR implements pagination for GitHub repositories and branches to improve performance and reduce API calls for repositories with large numbers of branches. ## Changes Made ### API Layer - **Modified GitHub repositories API route** (`apps/web/src/app/api/github/repositories/route.ts`) to support pagination with a 'page' query parameter, returning 100 repositories per page with pagination metadata - **Updated `getInstallationRepositories` function** (`utils/github.ts`) to accept pagination parameters and return structured response with hasMore and totalCount - **Enhanced `getRepositoryBranches` function** (`utils/github.ts`) to limit fetching to first 100 branches instead of all branches ### Hook Layer - **Enhanced `useGitHubApp` hook** (`hooks/useGitHubApp.ts`) with comprehensive pagination state management: - Added pagination state for both repositories and branches (page, hasMore, loadingMore) - Implemented `loadMoreRepositories()` and `loadMoreBranches()` functions - Added proper state management for appending paginated results - Reset pagination state when repository selection changes ### UI Components - **Updated `RepositorySelector` component** to display "Load more" button when additional repositories are available - **Updated `BranchSelector` component** to display "Load more" button when additional branches are available - Both components include loading states and prevent duplicate requests during loading ## Key Features - **Efficient Loading**: Repositories and branches are loaded in batches of 100 - **Progressive Loading**: "Load more" buttons appear only when additional items are available - **Loading States**: Visual feedback during loading operations with disabled buttons - **State Management**: Proper pagination state reset when switching repositories - **Performance**: Significantly reduces API calls for repositories with many branches ## Testing The implementation maintains backward compatibility while adding pagination functionality. The initial load behavior remains the same, with pagination controls appearing only when needed. ## Impact - Reduces initial API calls for repositories with many branches - Improves page load performance - Provides better user experience with progressive loading - Maintains existing functionality while adding scalability --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 07:19:36 -05:00
yindo closed this issue 2026-02-16 07:19:36 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/open-swe#431