From 94d0764243d4b01b4355ff2a4ce6a1ef42bb0a05 Mon Sep 17 00:00:00 2001 From: yaoweiprc <6896642+yaoweiprc@users.noreply.github.com> Date: Tue, 23 Dec 2025 15:30:16 +0800 Subject: [PATCH] Support fuzzy match when picking repo [INS-1460] (#9504) * tmp * Fuzzy match for selecting branch --- .../git-credentials/git-remote-branch-select.tsx | 6 +++++- .../git-credentials/github-repository-select.tsx | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/insomnia/src/ui/components/git-credentials/git-remote-branch-select.tsx b/packages/insomnia/src/ui/components/git-credentials/git-remote-branch-select.tsx index da223b6bc1..333d965d52 100644 --- a/packages/insomnia/src/ui/components/git-credentials/git-remote-branch-select.tsx +++ b/packages/insomnia/src/ui/components/git-credentials/git-remote-branch-select.tsx @@ -3,6 +3,7 @@ import { Button, ComboBox, Input, Label, ListBox, ListBoxItem, Popover } from 'r import * as reactUse from 'react-use'; import { z } from 'zod/v4'; +import { fuzzyMatch } from '~/common/misc'; import type { GitCredentials } from '~/models/git-repository'; import { useGitRemoteBranchesActionFetcher } from '~/routes/git.remote-branches'; @@ -66,11 +67,14 @@ export const GitRemoteBranchSelect = ({ className="w-full" defaultSelectedKey={remoteBranches[0]} isDisabled={isComboboxDisabled} - items={remoteBranches.map(branch => ({ + defaultItems={remoteBranches.map(branch => ({ id: branch, name: branch, }))} menuTrigger="focus" + defaultFilter={(branch: string, inputValue: string) => + Boolean(fuzzyMatch(inputValue, branch, { splitSpace: true, loose: false })?.indexes) + } >
diff --git a/packages/insomnia/src/ui/components/git-credentials/github-repository-select.tsx b/packages/insomnia/src/ui/components/git-credentials/github-repository-select.tsx index c03ecaf436..5fa901e708 100644 --- a/packages/insomnia/src/ui/components/git-credentials/github-repository-select.tsx +++ b/packages/insomnia/src/ui/components/git-credentials/github-repository-select.tsx @@ -1,6 +1,8 @@ import React, { useEffect, useState } from 'react'; import { Button, ComboBox, FieldError, Input, Label, ListBox, ListBoxItem, Popover } from 'react-aria-components'; +import { fuzzyMatch } from '~/common/misc'; + import { getAppWebsiteBaseURL } from '../../../common/constants'; import { isGitHubAppUserToken } from '../github-app-config-link'; import { Icon } from '../icon'; @@ -89,6 +91,9 @@ export const GitHubRepositorySelect = ({ }))} onSelectionChange={key => setSelectedRepository(repositories.find(r => r.clone_url === key) || null)} menuTrigger="focus" + defaultFilter={(repoName: string, inputValue: string) => + Boolean(fuzzyMatch(inputValue, repoName, { splitSpace: true, loose: false })?.indexes) + } >
@@ -141,7 +146,8 @@ export const GitHubRepositorySelect = ({ {isDisabled && } {item.name} {isDisabled && ( - + /* If you use hidden here, if the drop down is a long list and you scroll to the disabled item and hover on it, the scroll bar will scroll to the top. So we use invisible instead */ + Already connected to: {allConnectedRepoURIProjectNameMap[item.id]} )}