From b0cad64b496a92b245d9c4640c7f8efab1afb438 Mon Sep 17 00:00:00 2001 From: Alessandro Pogliaghi Date: Tue, 24 Mar 2026 12:52:24 +0000 Subject: [PATCH] chore(cloud): branch pagination --- apps/code/src/renderer/api/posthogClient.ts | 7 +++++-- .../features/onboarding/components/TutorialStep.tsx | 5 ++++- .../features/task-detail/components/TaskInput.tsx | 8 ++++++-- apps/code/src/renderer/hooks/useIntegrations.ts | 3 ++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/apps/code/src/renderer/api/posthogClient.ts b/apps/code/src/renderer/api/posthogClient.ts index d35fb0d09..a17bd47b2 100644 --- a/apps/code/src/renderer/api/posthogClient.ts +++ b/apps/code/src/renderer/api/posthogClient.ts @@ -717,7 +717,7 @@ export class PostHogAPIClient { async getGithubBranches( integrationId: string | number, repo: string, - ): Promise { + ): Promise<{ branches: string[]; defaultBranch: string | null }> { const teamId = await this.getTeamId(); const url = new URL( `${this.api.baseUrl}/api/environments/${teamId}/integrations/${integrationId}/github_branches/`, @@ -736,7 +736,10 @@ export class PostHogAPIClient { } const data = await response.json(); - return data.branches ?? data.results ?? data ?? []; + return { + branches: data.branches ?? data.results ?? data ?? [], + defaultBranch: data.default_branch ?? null, + }; } async getGithubRepositories( diff --git a/apps/code/src/renderer/features/onboarding/components/TutorialStep.tsx b/apps/code/src/renderer/features/onboarding/components/TutorialStep.tsx index db55ac85e..02056aea4 100644 --- a/apps/code/src/renderer/features/onboarding/components/TutorialStep.tsx +++ b/apps/code/src/renderer/features/onboarding/components/TutorialStep.tsx @@ -97,8 +97,10 @@ export function TutorialStep({ onComplete, onBack }: TutorialStepProps) { >("local"); const [selectedModel, setSelectedModel] = useState(null); - const { data: cloudBranches, isPending: cloudBranchesLoading } = + const { data: cloudBranchData, isPending: cloudBranchesLoading } = useGithubBranches(githubIntegration?.id, selectedRepository); + const cloudBranches = cloudBranchData?.branches; + const cloudDefaultBranch = cloudBranchData?.defaultBranch ?? null; // Preview session for config options — always claude const { modeOption, thoughtOption, previewTaskId, isConnecting } = @@ -342,6 +344,7 @@ export function TutorialStep({ onComplete, onBack }: TutorialStepProps) { : selectedDirectory } currentBranch={null} + defaultBranch={cloudDefaultBranch} disabled={!isEnabled("branch-selector") || isCreatingTask} loading={cloudBranchesLoading} workspaceMode={workspaceMode} diff --git a/apps/code/src/renderer/features/task-detail/components/TaskInput.tsx b/apps/code/src/renderer/features/task-detail/components/TaskInput.tsx index fa443d497..7cdc05fa2 100644 --- a/apps/code/src/renderer/features/task-detail/components/TaskInput.tsx +++ b/apps/code/src/renderer/features/task-detail/components/TaskInput.tsx @@ -89,8 +89,10 @@ export function TaskInput() { const { currentBranch, branchLoading, defaultBranch } = useGitQueries(selectedDirectory); - const { data: cloudBranches, isPending: cloudBranchesLoading } = + const { data: cloudBranchData, isPending: cloudBranchesLoading } = useGithubBranches(githubIntegration?.id, selectedRepository); + const cloudBranches = cloudBranchData?.branches; + const cloudDefaultBranch = cloudBranchData?.defaultBranch ?? null; // Preview session provides adapter-specific config options const { @@ -342,7 +344,9 @@ export function TaskInput() { : selectedDirectory } currentBranch={currentBranch} - defaultBranch={defaultBranch} + defaultBranch={ + workspaceMode === "cloud" ? cloudDefaultBranch : defaultBranch + } disabled={ isCreatingTask || (workspaceMode === "cloud" && !selectedRepository) diff --git a/apps/code/src/renderer/hooks/useIntegrations.ts b/apps/code/src/renderer/hooks/useIntegrations.ts index e60d6fe40..f5890b18f 100644 --- a/apps/code/src/renderer/hooks/useIntegrations.ts +++ b/apps/code/src/renderer/hooks/useIntegrations.ts @@ -64,9 +64,10 @@ export function useGithubBranches( return useAuthenticatedQuery( integrationKeys.branches(integrationId, repo), async (client) => { - if (!integrationId || !repo) return []; + if (!integrationId || !repo) return { branches: [], defaultBranch: null }; return await client.getGithubBranches(integrationId, repo); }, + { staleTime: 0, refetchOnMount: "always" }, ); }