🙌 OpenHands: AI-Driven Development
fix(frontend): The suggested tasks section only filters the tasks by the repository’s title. (#9606)
Hiep Le2a833325e1c3
diff --git a/frontend/__tests__/components/features/home/repo-selection-form.test.tsx b/frontend/__tests__/components/features/home/repo-selection-form.test.tsxindex e164a48e45..563f0d3c16 100644--- a/frontend/__tests__/components/features/home/repo-selection-form.test.tsx+++ b/frontend/__tests__/components/features/home/repo-selection-form.test.tsx@@ -252,8 +252,6 @@ describe("RepositorySelectionForm", () => {expect(searchedRepo).toBeInTheDocument();await userEvent.click(searchedRepo);- expect(mockOnRepoSelection).toHaveBeenCalledWith(- MOCK_SEARCH_REPOS[0].full_name,- );+ expect(mockOnRepoSelection).toHaveBeenCalledWith(MOCK_SEARCH_REPOS[0]);});});diff --git a/frontend/src/components/features/home/repo-connector.tsx b/frontend/src/components/features/home/repo-connector.tsxindex 92426e6eea..8dbbf0e4f6 100644--- a/frontend/src/components/features/home/repo-connector.tsx+++ b/frontend/src/components/features/home/repo-connector.tsx@@ -4,9 +4,10 @@ import { RepositorySelectionForm } from "./repo-selection-form";import { useConfig } from "#/hooks/query/use-config";import { RepoProviderLinks } from "./repo-provider-links";import { useUserProviders } from "#/hooks/use-user-providers";+import { GitRepository } from "#/types/git";interface RepoConnectorProps {- onRepoSelection: (repoTitle: string | null) => void;+ onRepoSelection: (repo: GitRepository | null) => void;}export function RepoConnector({ onRepoSelection }: RepoConnectorProps) {diff --git a/frontend/src/components/features/home/repo-selection-form.tsx b/frontend/src/components/features/home/repo-selection-form.tsxindex 3c4107e4b6..45b219fdf9 100644--- a/frontend/src/components/features/home/repo-selection-form.tsx+++ b/frontend/src/components/features/home/repo-selection-form.tsx@@ -19,7 +19,7 @@ import {} from "./repository-selection";interface RepositorySelectionFormProps {- onRepoSelection: (repoTitle: string | null) => void;+ onRepoSelection: (repo: GitRepository | null) => void;}export function RepositorySelectionForm({@@ -94,8 +94,7 @@ export function RepositorySelectionForm({const handleRepoSelection = (key: React.Key | null) => {const selectedRepo = allRepositories?.find((repo) => repo.id === key);-- if (selectedRepo) onRepoSelection(selectedRepo.full_name);+ if (selectedRepo) onRepoSelection(selectedRepo);setSelectedRepository(selectedRepo || null);setSelectedBranch(null); // Reset branch selection when repo changesbranchManuallyClearedRef.current = false; // Reset the flag when repo changesdiff --git a/frontend/src/components/features/home/tasks/task-suggestions.tsx b/frontend/src/components/features/home/tasks/task-suggestions.tsxindex cfef06a7b1..14e0b15b91 100644--- a/frontend/src/components/features/home/tasks/task-suggestions.tsx+++ b/frontend/src/components/features/home/tasks/task-suggestions.tsx@@ -6,16 +6,24 @@ import { TaskSuggestionsSkeleton } from "./task-suggestions-skeleton";import { cn } from "#/utils/utils";import { I18nKey } from "#/i18n/declaration";import { TooltipButton } from "#/components/shared/buttons/tooltip-button";+import { GitRepository } from "#/types/git";interface TaskSuggestionsProps {- filterFor?: string | null;+ filterFor?: GitRepository | null;}export function TaskSuggestions({ filterFor }: TaskSuggestionsProps) {const { t } = useTranslation();const { data: tasks, isLoading } = useSuggestedTasks();+const suggestedTasks = filterFor- ? tasks?.filter((task) => task.title === filterFor)+ ? tasks?.filter(+ (element) =>+ element.title === filterFor.full_name &&+ !!element.tasks.find(+ (task) => task.git_provider === filterFor.git_provider,+ ),+ ): tasks;const hasSuggestedTasks = suggestedTasks && suggestedTasks.length > 0;diff --git a/frontend/src/routes/home.tsx b/frontend/src/routes/home.tsxindex 258e03fe95..62ec424893 100644--- a/frontend/src/routes/home.tsx+++ b/frontend/src/routes/home.tsx@@ -4,14 +4,15 @@ import { HomeHeader } from "#/components/features/home/home-header";import { RepoConnector } from "#/components/features/home/repo-connector";import { TaskSuggestions } from "#/components/features/home/tasks/task-suggestions";import { useUserProviders } from "#/hooks/use-user-providers";+import { GitRepository } from "#/types/git";<PrefetchPageLinks page="/conversations/:conversationId" />;function HomeScreen() {const { providers } = useUserProviders();- const [selectedRepoTitle, setSelectedRepoTitle] = React.useState<- string | null- >(null);+ const [selectedRepo, setSelectedRepo] = React.useState<GitRepository | null>(+ null,+ );const providersAreSet = providers.length > 0;@@ -25,11 +26,9 @@ function HomeScreen() {<hr className="border-[#717888]" /><main className="flex flex-col lg:flex-row justify-between gap-8">- <RepoConnector- onRepoSelection={(title) => setSelectedRepoTitle(title)}- />+ <RepoConnector onRepoSelection={(repo) => setSelectedRepo(repo)} /><hr className="md:hidden border-[#717888]" />- {providersAreSet && <TaskSuggestions filterFor={selectedRepoTitle} />}+ {providersAreSet && <TaskSuggestions filterFor={selectedRepo} />}</main></div>);