fix: Fix exposing explicit search button in gh branch dropdown (#435)

* fix: Fix exposing explicit search button in gh branch dropdown

* cr
This commit is contained in:
Brace Sproul 2025-07-16 17:49:17 -07:00 • committed by GitHub
parent b128e4ae45
commit 0953468b5c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,6 +20,7 @@ import { GitBranch, Shield } from "lucide-react";
import { TargetRepository } from "@open-swe/shared/open-swe/types"; import { TargetRepository } from "@open-swe/shared/open-swe/types";
import { Branch } from "@/utils/github"; import { Branch } from "@/utils/github";
import { toast } from "sonner"; import { toast } from "sonner";
import { defaultFilter } from "cmdk";
interface BranchSelectorProps { interface BranchSelectorProps {
disabled?: boolean; disabled?: boolean;
@ -123,6 +124,14 @@ export function BranchSelector({
} }
}; };
// Whether or not to allow explicitly searching for a branch, even when there are results.
const allowExplicitSearchReqWithResults = !!(
searchQuery.trim() &&
branches.some(
(branch) => defaultFilter(branch.name, searchQuery.trim()) > 0,
)
);
if (!selectedRepository) { if (!selectedRepository) {
return ( return (
<Button <Button
@ -300,10 +309,7 @@ export function BranchSelector({
</CommandGroup> </CommandGroup>
{/* Show this search button if there is a search query, and there are some results. this is for {/* Show this search button if there is a search query, and there are some results. this is for
cases when some results do show, just not the exact result the user is looking for */} cases when some results do show, just not the exact result the user is looking for */}
{searchQuery.trim() && {allowExplicitSearchReqWithResults && (
branches.some((branch) =>
branch.name.toLowerCase().includes(searchQuery.toLowerCase()),
) && (
<div className="px-2 py-1"> <div className="px-2 py-1">
<Button <Button
variant="outline" variant="outline"
@ -318,7 +324,7 @@ export function BranchSelector({
</Button> </Button>
</div> </div>
)} )}
{branchesHasMore && ( {branchesHasMore && !allowExplicitSearchReqWithResults && (
<CommandGroup> <CommandGroup>
<CommandItem <CommandItem
onSelect={() => { onSelect={() => {