π OpenHands: AI-Driven Development
feat: always render Workspaces tab regardless of Git PAT (#125)
Hiep Le6b4fb427e92f
diff --git a/__tests__/components/features/home/repo-selection-form.test.tsx b/__tests__/components/features/home/repo-selection-form.test.tsxindex 7dfe98b8be..594c43206b 100644--- a/__tests__/components/features/home/repo-selection-form.test.tsx+++ b/__tests__/components/features/home/repo-selection-form.test.tsx@@ -5,6 +5,8 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { RepositorySelectionForm } from "../../../../src/components/features/home/repo-selection-form";import { LaunchTabs } from "../../../../src/components/features/home/launch-tabs";import GitService from "#/api/git-service/git-service.api";+import SettingsService from "#/api/settings-service/settings-service.api";+import { DEFAULT_SETTINGS } from "#/services/settings";import { GitRepository } from "#/types/git";import { useHomeStore } from "#/stores/home-store";import { useWorkspacesStore } from "#/stores/workspaces-store";@@ -361,4 +363,57 @@ describe("RepositorySelectionForm", () => {).toBeInTheDocument();expect(screen.queryByTestId("git-repo-dropdown")).not.toBeInTheDocument();});++ it("keeps the Workspaces tab reachable when no provider is configured", async () => {+ mockUseUserProviders.mockReturnValue({ providers: [] });+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(+ DEFAULT_SETTINGS,+ );+ useWorkspacesStore.setState({ workspaces: [] });++ render(<LaunchTabs onRepoSelection={mockOnRepoSelection} />, {+ wrapper: ({ children }) => (+ <QueryClientProvider+ client={+ new QueryClient({+ defaultOptions: { queries: { retry: false } },+ })+ }+ >+ {children}+ </QueryClientProvider>+ ),+ });++ await userEvent.click(screen.getByTestId("workspaces-tab"));++ expect(+ await screen.findByTestId("workspace-launch-button"),+ ).toBeInTheDocument();+ });++ it("shows the connect-provider empty state in the Repositories tab when no provider is configured", async () => {+ mockUseUserProviders.mockReturnValue({ providers: [] });+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(+ DEFAULT_SETTINGS,+ );++ render(<LaunchTabs onRepoSelection={mockOnRepoSelection} />, {+ wrapper: ({ children }) => (+ <QueryClientProvider+ client={+ new QueryClient({+ defaultOptions: { queries: { retry: false } },+ })+ }+ >+ {children}+ </QueryClientProvider>+ ),+ });++ expect(+ await screen.findByTestId("navigate-to-settings-button"),+ ).toBeInTheDocument();+ });});diff --git a/src/components/features/home/launch-tabs.tsx b/src/components/features/home/launch-tabs.tsxindex 6465a25365..cbb2f2fb75 100644--- a/src/components/features/home/launch-tabs.tsx+++ b/src/components/features/home/launch-tabs.tsx@@ -4,9 +4,11 @@ import { useTranslation } from "react-i18next";import { cn } from "#/utils/utils";import { I18nKey } from "#/i18n/declaration";import { GitRepository } from "#/types/git";+import { useUserProviders } from "#/hooks/use-user-providers";import { RepositorySelectionForm } from "./repo-selection-form";import { WorkspaceSelectionForm } from "./workspace-selection-form";+import { ConnectToProviderMessage } from "./connect-to-provider-message";type LaunchTab = "repositories" | "workspaces";@@ -47,6 +49,8 @@ export function LaunchTabs({isLoadingSettings = false,}: LaunchTabsProps) {const { t } = useTranslation("openhands");+ const { providers } = useUserProviders();+ const providersAreSet = providers.length > 0;const [activeTab, setActiveTab] = React.useState<LaunchTab>("repositories");return (@@ -73,7 +77,10 @@ export function LaunchTabs({</div><div className="min-h-[240px]">- {activeTab === "repositories" && (+ {activeTab === "repositories" && !providersAreSet && (+ <ConnectToProviderMessage />+ )}+ {activeTab === "repositories" && providersAreSet && (<RepositorySelectionFormonRepoSelection={onRepoSelection}isLoadingSettings={isLoadingSettings}diff --git a/src/components/features/home/repo-connector.tsx b/src/components/features/home/repo-connector.tsxindex b09984c625..713445b637 100644--- a/src/components/features/home/repo-connector.tsx+++ b/src/components/features/home/repo-connector.tsx@@ -1,4 +1,3 @@-import { ConnectToProviderMessage } from "./connect-to-provider-message";import { LaunchTabs } from "./launch-tabs";import { useUserProviders } from "#/hooks/use-user-providers";import { GitRepository } from "#/types/git";@@ -8,22 +7,17 @@ interface RepoConnectorProps {}export function RepoConnector({ onRepoSelection }: RepoConnectorProps) {- const { providers, isLoadingSettings } = useUserProviders();-- const providersAreSet = providers.length > 0;+ const { isLoadingSettings } = useUserProviders();return (<sectiondata-testid="repo-connector"className="w-full flex flex-col gap-6 rounded-[12px] p-[20px] border border-[#727987] bg-[#26282D] min-h-[263.5px] relative">- {!providersAreSet && <ConnectToProviderMessage />}- {providersAreSet && (- <LaunchTabs- onRepoSelection={onRepoSelection}- isLoadingSettings={isLoadingSettings}- />- )}+ <LaunchTabs+ onRepoSelection={onRepoSelection}+ isLoadingSettings={isLoadingSettings}+ /></section>);}