mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 08:03:15 +00:00
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:
parent
b128e4ae45
commit
0953468b5c
1 changed files with 25 additions and 19 deletions
|
|
@ -20,6 +20,7 @@ import { GitBranch, Shield } from "lucide-react";
|
|||
import { TargetRepository } from "@open-swe/shared/open-swe/types";
|
||||
import { Branch } from "@/utils/github";
|
||||
import { toast } from "sonner";
|
||||
import { defaultFilter } from "cmdk";
|
||||
|
||||
interface BranchSelectorProps {
|
||||
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) {
|
||||
return (
|
||||
<Button
|
||||
|
|
@ -300,25 +309,22 @@ export function BranchSelector({
|
|||
</CommandGroup>
|
||||
{/* 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 */}
|
||||
{searchQuery.trim() &&
|
||||
branches.some((branch) =>
|
||||
branch.name.toLowerCase().includes(searchQuery.toLowerCase()),
|
||||
) && (
|
||||
<div className="px-2 py-1">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleSearchForBranch}
|
||||
disabled={isSearching}
|
||||
className="w-full text-xs"
|
||||
>
|
||||
{isSearching
|
||||
? "Searching..."
|
||||
: `Search for "${searchQuery.trim()}"`}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{branchesHasMore && (
|
||||
{allowExplicitSearchReqWithResults && (
|
||||
<div className="px-2 py-1">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleSearchForBranch}
|
||||
disabled={isSearching}
|
||||
className="w-full text-xs"
|
||||
>
|
||||
{isSearching
|
||||
? "Searching..."
|
||||
: `Search for "${searchQuery.trim()}"`}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{branchesHasMore && !allowExplicitSearchReqWithResults && (
|
||||
<CommandGroup>
|
||||
<CommandItem
|
||||
onSelect={() => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue