-
Notifications
You must be signed in to change notification settings - Fork 4.9k
fix(github): search repositories by name #8340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d7a485d
91ad373
2a4c55e
6cf30bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,7 @@ import { | |||||||||||||||||||||||||||||||||||
| getCloneDestinationPath, | ||||||||||||||||||||||||||||||||||||
| getCloneDirectoryName, | ||||||||||||||||||||||||||||||||||||
| getDefaultCloneUrl, | ||||||||||||||||||||||||||||||||||||
| isGitHubRepositoryShorthand, | ||||||||||||||||||||||||||||||||||||
| normalizePastedCloneUrl, | ||||||||||||||||||||||||||||||||||||
| resolveAddProjectPath, | ||||||||||||||||||||||||||||||||||||
| sortAddProjectProviderSources, | ||||||||||||||||||||||||||||||||||||
|
|
@@ -31,7 +32,12 @@ import { | |||||||||||||||||||||||||||||||||||
| inferProjectTitleFromPath, | ||||||||||||||||||||||||||||||||||||
| isWindowsPlatform, | ||||||||||||||||||||||||||||||||||||
| } from "@t3tools/client-runtime/state/projects"; | ||||||||||||||||||||||||||||||||||||
| import { CommandId, type EnvironmentId, ProjectId } from "@t3tools/contracts"; | ||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||
| CommandId, | ||||||||||||||||||||||||||||||||||||
| type EnvironmentId, | ||||||||||||||||||||||||||||||||||||
| ProjectId, | ||||||||||||||||||||||||||||||||||||
| type SourceControlRepositoryInfo, | ||||||||||||||||||||||||||||||||||||
| } from "@t3tools/contracts"; | ||||||||||||||||||||||||||||||||||||
| import { CommonActions, StackActions, useNavigation } from "@react-navigation/native"; | ||||||||||||||||||||||||||||||||||||
| import { SymbolView } from "../../components/AppSymbol"; | ||||||||||||||||||||||||||||||||||||
| import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react"; | ||||||||||||||||||||||||||||||||||||
|
|
@@ -55,6 +61,7 @@ import { useThemeColor } from "../../lib/useThemeColor"; | |||||||||||||||||||||||||||||||||||
| import { uuidv4 } from "../../lib/uuid"; | ||||||||||||||||||||||||||||||||||||
| import { useAtomCommand } from "../../state/use-atom-command"; | ||||||||||||||||||||||||||||||||||||
| import { useAtomQueryRunner } from "../../state/use-atom-query-runner"; | ||||||||||||||||||||||||||||||||||||
| import { useDebouncedValue } from "../../state/queries"; | ||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||
| useRemoteConnectionStatus, | ||||||||||||||||||||||||||||||||||||
| useRemoteEnvironmentRuntime, | ||||||||||||||||||||||||||||||||||||
|
|
@@ -72,6 +79,8 @@ interface EnvironmentOption { | |||||||||||||||||||||||||||||||||||
| readonly connectionErrorTraceId: string | null; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const REPOSITORY_SEARCH_DEBOUNCE_MS = 100; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const environmentOptionOrder = Order.mapInput( | ||||||||||||||||||||||||||||||||||||
| Order.Struct({ | ||||||||||||||||||||||||||||||||||||
| label: Order.String, | ||||||||||||||||||||||||||||||||||||
|
|
@@ -652,11 +661,55 @@ export function AddProjectRepositoryScreen(props: { | |||||||||||||||||||||||||||||||||||
| reportFailure: false, | ||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||
| const navigation = useNavigation(); | ||||||||||||||||||||||||||||||||||||
| const iconColor = useThemeColor("--color-icon"); | ||||||||||||||||||||||||||||||||||||
| const environment = useEnvironmentFromParam(props.environmentId); | ||||||||||||||||||||||||||||||||||||
| const source = sourceFromParam(props.source); | ||||||||||||||||||||||||||||||||||||
| const [repositoryInput, setRepositoryInput] = useState(""); | ||||||||||||||||||||||||||||||||||||
| const [isSubmitting, setIsSubmitting] = useState(false); | ||||||||||||||||||||||||||||||||||||
| const [error, setError] = useState<string | null>(null); | ||||||||||||||||||||||||||||||||||||
| const normalizedRepositoryInput = repositoryInput.trim(); | ||||||||||||||||||||||||||||||||||||
| const debouncedRepositoryInput = useDebouncedValue( | ||||||||||||||||||||||||||||||||||||
| normalizedRepositoryInput, | ||||||||||||||||||||||||||||||||||||
| REPOSITORY_SEARCH_DEBOUNCE_MS, | ||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||
| const githubRepositorySearchEnvironmentId = | ||||||||||||||||||||||||||||||||||||
| source === "github" ? (environment?.environmentId ?? null) : null; | ||||||||||||||||||||||||||||||||||||
| const settledRepositoryInput = | ||||||||||||||||||||||||||||||||||||
| normalizedRepositoryInput.length > 0 && normalizedRepositoryInput === debouncedRepositoryInput | ||||||||||||||||||||||||||||||||||||
| ? debouncedRepositoryInput | ||||||||||||||||||||||||||||||||||||
| : null; | ||||||||||||||||||||||||||||||||||||
| const repositorySearch = useEnvironmentQuery( | ||||||||||||||||||||||||||||||||||||
| githubRepositorySearchEnvironmentId !== null && settledRepositoryInput !== null | ||||||||||||||||||||||||||||||||||||
| ? sourceControlEnvironment.repositorySearch({ | ||||||||||||||||||||||||||||||||||||
| environmentId: githubRepositorySearchEnvironmentId, | ||||||||||||||||||||||||||||||||||||
| input: { | ||||||||||||||||||||||||||||||||||||
| provider: "github", | ||||||||||||||||||||||||||||||||||||
| query: settledRepositoryInput, | ||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||
| : null, | ||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||
| const repositories = repositorySearch.data; | ||||||||||||||||||||||||||||||||||||
| const isRepositorySearchPending = | ||||||||||||||||||||||||||||||||||||
| normalizedRepositoryInput.length > 0 && | ||||||||||||||||||||||||||||||||||||
| (normalizedRepositoryInput !== debouncedRepositoryInput || repositorySearch.isPending); | ||||||||||||||||||||||||||||||||||||
| const visibleError = error ?? repositorySearch.error; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const selectRepository = useCallback( | ||||||||||||||||||||||||||||||||||||
| (repository: SourceControlRepositoryInfo) => { | ||||||||||||||||||||||||||||||||||||
| if (!environment) return; | ||||||||||||||||||||||||||||||||||||
| navigation.dispatch( | ||||||||||||||||||||||||||||||||||||
| StackActions.push("AddProjectDestination", { | ||||||||||||||||||||||||||||||||||||
| environmentId: environment.environmentId, | ||||||||||||||||||||||||||||||||||||
| source, | ||||||||||||||||||||||||||||||||||||
| remoteUrl: getDefaultCloneUrl(repository), | ||||||||||||||||||||||||||||||||||||
| repositoryTitle: repository.nameWithOwner, | ||||||||||||||||||||||||||||||||||||
| repositoryName: getCloneDirectoryName(repository.nameWithOwner), | ||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||
| [environment, navigation, source], | ||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const lookupRepository = useCallback(async () => { | ||||||||||||||||||||||||||||||||||||
| if (!environment || repositoryInput.trim().length === 0 || isSubmitting) return; | ||||||||||||||||||||||||||||||||||||
|
|
@@ -678,6 +731,11 @@ export function AddProjectRepositoryScreen(props: { | |||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if (provider === "github" && !isGitHubRepositoryShorthand(repositoryInput)) { | ||||||||||||||||||||||||||||||||||||
| setIsSubmitting(false); | ||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const result = await lookupRepositoryQuery({ | ||||||||||||||||||||||||||||||||||||
| environmentId: environment.environmentId, | ||||||||||||||||||||||||||||||||||||
| input: { | ||||||||||||||||||||||||||||||||||||
|
|
@@ -704,29 +762,64 @@ export function AddProjectRepositoryScreen(props: { | |||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||
| <AddProjectShell> | ||||||||||||||||||||||||||||||||||||
| {error ? <ErrorBanner message={error} /> : null} | ||||||||||||||||||||||||||||||||||||
| {visibleError ? <ErrorBanner message={visibleError} /> : null} | ||||||||||||||||||||||||||||||||||||
| {environment ? ( | ||||||||||||||||||||||||||||||||||||
| <> | ||||||||||||||||||||||||||||||||||||
| <TextInput | ||||||||||||||||||||||||||||||||||||
| className="h-12 min-h-12 rounded-[24px] px-4 py-0 text-base leading-snug" | ||||||||||||||||||||||||||||||||||||
| value={repositoryInput} | ||||||||||||||||||||||||||||||||||||
| onChangeText={setRepositoryInput} | ||||||||||||||||||||||||||||||||||||
| onChangeText={(value) => { | ||||||||||||||||||||||||||||||||||||
| if (value.trim() !== normalizedRepositoryInput) { | ||||||||||||||||||||||||||||||||||||
| setError(null); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| setRepositoryInput(value); | ||||||||||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||||||||||
| autoCapitalize="none" | ||||||||||||||||||||||||||||||||||||
| autoCorrect={false} | ||||||||||||||||||||||||||||||||||||
| placeholder={ | ||||||||||||||||||||||||||||||||||||
| source === "url" | ||||||||||||||||||||||||||||||||||||
| ? "https://github.com/org/repo.git" | ||||||||||||||||||||||||||||||||||||
| : addProjectRemoteSourcePathHint(source) | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| returnKeyType="next" | ||||||||||||||||||||||||||||||||||||
| returnKeyType={source === "github" ? "done" : "next"} | ||||||||||||||||||||||||||||||||||||
| onSubmitEditing={() => void lookupRepository()} | ||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||
| <PrimaryActionButton | ||||||||||||||||||||||||||||||||||||
| label={source === "url" ? "Continue" : "Lookup repository"} | ||||||||||||||||||||||||||||||||||||
| disabled={isSubmitting || repositoryInput.trim().length === 0} | ||||||||||||||||||||||||||||||||||||
| onPress={() => void lookupRepository()} | ||||||||||||||||||||||||||||||||||||
| loading={isSubmitting} | ||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||
| {source === "github" ? null : ( | ||||||||||||||||||||||||||||||||||||
| <PrimaryActionButton | ||||||||||||||||||||||||||||||||||||
| label={source === "url" ? "Continue" : "Lookup repository"} | ||||||||||||||||||||||||||||||||||||
| disabled={isSubmitting || repositoryInput.trim().length === 0} | ||||||||||||||||||||||||||||||||||||
| onPress={() => void lookupRepository()} | ||||||||||||||||||||||||||||||||||||
| loading={isSubmitting} | ||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||
| {source === "github" && isRepositorySearchPending ? ( | ||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GitHub lookup shows no loading stateMedium Severity The GitHub spinner now follows Additional Locations (1)Reviewed by Cursor Bugbot for commit 91ad373. Configure here. |
||||||||||||||||||||||||||||||||||||
| <View className="items-center py-3"> | ||||||||||||||||||||||||||||||||||||
| <ActivityIndicator /> | ||||||||||||||||||||||||||||||||||||
| </View> | ||||||||||||||||||||||||||||||||||||
| ) : null} | ||||||||||||||||||||||||||||||||||||
| {repositories ? ( | ||||||||||||||||||||||||||||||||||||
| <> | ||||||||||||||||||||||||||||||||||||
| <SectionTitle>Repositories</SectionTitle> | ||||||||||||||||||||||||||||||||||||
| <ListSection> | ||||||||||||||||||||||||||||||||||||
| {repositories.length === 0 ? ( | ||||||||||||||||||||||||||||||||||||
| <View className="items-center px-4 py-5"> | ||||||||||||||||||||||||||||||||||||
| <Text className="text-sm text-foreground-muted">No repositories found.</Text> | ||||||||||||||||||||||||||||||||||||
| </View> | ||||||||||||||||||||||||||||||||||||
| ) : ( | ||||||||||||||||||||||||||||||||||||
| repositories.map((repository, index) => ( | ||||||||||||||||||||||||||||||||||||
| <ListRow | ||||||||||||||||||||||||||||||||||||
| key={repository.nameWithOwner} | ||||||||||||||||||||||||||||||||||||
| title={repository.nameWithOwner} | ||||||||||||||||||||||||||||||||||||
| subtitle={repository.url} | ||||||||||||||||||||||||||||||||||||
| icon={<SourceControlIcon kind="github" size={18} color={String(iconColor)} />} | ||||||||||||||||||||||||||||||||||||
| isFirst={index === 0} | ||||||||||||||||||||||||||||||||||||
| onPress={() => selectRepository(repository)} | ||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+810
to
+817
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 High Repository rows remain tappable while
Suggested change
🤖 Copy this AI Prompt to have your agent fix this: |
||||||||||||||||||||||||||||||||||||
| )) | ||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||
| </ListSection> | ||||||||||||||||||||||||||||||||||||
| </> | ||||||||||||||||||||||||||||||||||||
| ) : null} | ||||||||||||||||||||||||||||||||||||
| </> | ||||||||||||||||||||||||||||||||||||
| ) : ( | ||||||||||||||||||||||||||||||||||||
| <EmptyEnvironmentState /> | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||


Uh oh!
There was an error while loading. Please reload this page.