diff --git a/apps/web/src/components/github/repo-branch-selectors/branch-selector.tsx b/apps/web/src/components/github/repo-branch-selectors/branch-selector.tsx index 8e3b1464..737cf61c 100644 --- a/apps/web/src/components/github/repo-branch-selectors/branch-selector.tsx +++ b/apps/web/src/components/github/repo-branch-selectors/branch-selector.tsx @@ -17,12 +17,14 @@ import { cn } from "@/lib/utils"; import { useState, useEffect } from "react"; import { useGitHubAppProvider } from "@/providers/GitHubApp"; import { GitBranch, Shield } from "lucide-react"; +import { TargetRepository } from "@open-swe/shared/open-swe/types"; interface BranchSelectorProps { disabled?: boolean; placeholder?: string; buttonClassName?: string; chatStarted?: boolean; + streamTargetRepository?: TargetRepository; } export function BranchSelector({ @@ -30,6 +32,7 @@ export function BranchSelector({ placeholder = "Select a branch...", buttonClassName, chatStarted = false, + streamTargetRepository, }: BranchSelectorProps) { const [open, setOpen] = useState(false); const { @@ -147,6 +150,12 @@ export function BranchSelector({ ); } + // Determine the display value - prioritize stream data when chatStarted and available + const displayValue = + chatStarted && streamTargetRepository?.branch + ? streamTargetRepository.branch + : selectedBranch; + if (chatStarted) { return ( diff --git a/apps/web/src/components/github/repo-branch-selectors/index.tsx b/apps/web/src/components/github/repo-branch-selectors/index.tsx index b5114547..79b83f2c 100644 --- a/apps/web/src/components/github/repo-branch-selectors/index.tsx +++ b/apps/web/src/components/github/repo-branch-selectors/index.tsx @@ -1,6 +1,7 @@ import { BranchSelector } from "./branch-selector"; import { RepositorySelector } from "./repository-selector"; import { useQueryState } from "nuqs"; +import { useStreamContext } from "@/providers/Stream"; export function RepositoryBranchSelectors() { const [threadId] = useQueryState("threadId"); @@ -10,6 +11,12 @@ export function RepositoryBranchSelectors() { const defaultStylesChatStarted = "hover:bg-inherit cursor-default hover:cursor-default hover:text-gray-500 hover:border-gray-300 hover:ring-inherit"; + // Access stream context when chat has started + const stream = useStreamContext(); + const streamTargetRepository = chatStarted + ? stream?.values?.targetRepository + : undefined; + return (