Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions apps/code/src/renderer/api/posthogClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ export class PostHogAPIClient {
async getGithubBranches(
integrationId: string | number,
repo: string,
): Promise<string[]> {
): 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/`,
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ export function TutorialStep({ onComplete, onBack }: TutorialStepProps) {
>("local");
const [selectedModel, setSelectedModel] = useState<string | null>(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 } =
Expand Down Expand Up @@ -342,6 +344,7 @@ export function TutorialStep({ onComplete, onBack }: TutorialStepProps) {
: selectedDirectory
}
currentBranch={null}
defaultBranch={cloudDefaultBranch}
disabled={!isEnabled("branch-selector") || isCreatingTask}
loading={cloudBranchesLoading}
workspaceMode={workspaceMode}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -342,7 +344,9 @@ export function TaskInput() {
: selectedDirectory
}
currentBranch={currentBranch}
defaultBranch={defaultBranch}
defaultBranch={
workspaceMode === "cloud" ? cloudDefaultBranch : defaultBranch
}
disabled={
isCreatingTask ||
(workspaceMode === "cloud" && !selectedRepository)
Expand Down
3 changes: 2 additions & 1 deletion apps/code/src/renderer/hooks/useIntegrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
);
}

Expand Down
Loading