π OpenHands: AI-Driven Development
fix(chat): enable git PR/push/pull on local without provider_tokens_set (#722)
Neha Prasadf4d45e46fe44
diff --git a/src/components/features/chat/git-control-bar-pr-button.tsx b/src/components/features/chat/git-control-bar-pr-button.tsxindex 063e47c92e..d553aaa9d5 100644--- a/src/components/features/chat/git-control-bar-pr-button.tsx+++ b/src/components/features/chat/git-control-bar-pr-button.tsx@@ -1,7 +1,6 @@import { useTranslation } from "react-i18next";import PRIcon from "#/icons/u-pr.svg?react";import { cn, getCreatePRPrompt } from "#/utils/utils";-import { useUserProviders } from "#/hooks/use-user-providers";import { I18nKey } from "#/i18n/declaration";import { Provider } from "#/types/settings";import { useTracking } from "#/hooks/use-tracking";@@ -9,6 +8,7 @@ import { useTracking } from "#/hooks/use-tracking";interface GitControlBarPrButtonProps {onSuggestionsClick: (value: string) => void;hasRepository: boolean;+ providerTokensReady: boolean;currentGitProvider: Provider;isConversationReady?: boolean;}@@ -16,17 +16,15 @@ interface GitControlBarPrButtonProps {export function GitControlBarPrButton({onSuggestionsClick,hasRepository,+ providerTokensReady,currentGitProvider,isConversationReady = true,}: GitControlBarPrButtonProps) {const { t } = useTranslation("openhands");const { trackCreatePrButtonClick } = useTracking();- const { providers } = useUserProviders();-- const providersAreSet = providers.length > 0;const isButtonEnabled =- providersAreSet && hasRepository && isConversationReady;+ providerTokensReady && hasRepository && isConversationReady;const handlePrClick = () => {trackCreatePrButtonClick();diff --git a/src/components/features/chat/git-control-bar-pull-button.tsx b/src/components/features/chat/git-control-bar-pull-button.tsxindex 0a9be811d7..c896c8c65d 100644--- a/src/components/features/chat/git-control-bar-pull-button.tsx+++ b/src/components/features/chat/git-control-bar-pull-button.tsx@@ -1,30 +1,27 @@import { useTranslation } from "react-i18next";import ArrowDownIcon from "#/icons/u-arrow-down.svg?react";import { cn, getGitPullPrompt } from "#/utils/utils";-import { useActiveConversation } from "#/hooks/query/use-active-conversation";-import { useUserProviders } from "#/hooks/use-user-providers";import { I18nKey } from "#/i18n/declaration";import { useTracking } from "#/hooks/use-tracking";interface GitControlBarPullButtonProps {onSuggestionsClick: (value: string) => void;+ hasRepository: boolean;+ providerTokensReady: boolean;isConversationReady?: boolean;}export function GitControlBarPullButton({onSuggestionsClick,+ hasRepository,+ providerTokensReady,isConversationReady = true,}: GitControlBarPullButtonProps) {const { t } = useTranslation("openhands");const { trackPullButtonClick } = useTracking();- const { data: conversation } = useActiveConversation();- const { providers } = useUserProviders();-- const providersAreSet = providers.length > 0;- const hasRepository = conversation?.selected_repository;const isButtonEnabled =- providersAreSet && hasRepository && isConversationReady;+ providerTokensReady && hasRepository && isConversationReady;const handlePullClick = () => {trackPullButtonClick();diff --git a/src/components/features/chat/git-control-bar-push-button.tsx b/src/components/features/chat/git-control-bar-push-button.tsxindex fb48d43eb2..779c444ac5 100644--- a/src/components/features/chat/git-control-bar-push-button.tsx+++ b/src/components/features/chat/git-control-bar-push-button.tsx@@ -1,7 +1,6 @@import { useTranslation } from "react-i18next";import ArrowUpIcon from "#/icons/u-arrow-up.svg?react";import { cn, getGitPushPrompt } from "#/utils/utils";-import { useUserProviders } from "#/hooks/use-user-providers";import { I18nKey } from "#/i18n/declaration";import { Provider } from "#/types/settings";import { useTracking } from "#/hooks/use-tracking";@@ -9,6 +8,7 @@ import { useTracking } from "#/hooks/use-tracking";interface GitControlBarPushButtonProps {onSuggestionsClick: (value: string) => void;hasRepository: boolean;+ providerTokensReady: boolean;currentGitProvider: Provider;isConversationReady?: boolean;}@@ -16,17 +16,15 @@ interface GitControlBarPushButtonProps {export function GitControlBarPushButton({onSuggestionsClick,hasRepository,+ providerTokensReady,currentGitProvider,isConversationReady = true,}: GitControlBarPushButtonProps) {const { t } = useTranslation("openhands");const { trackPushButtonClick } = useTracking();- const { providers } = useUserProviders();-- const providersAreSet = providers.length > 0;const isButtonEnabled =- providersAreSet && hasRepository && isConversationReady;+ providerTokensReady && hasRepository && isConversationReady;const handlePushClick = () => {trackPushButtonClick();diff --git a/src/components/features/chat/git-control-bar.tsx b/src/components/features/chat/git-control-bar.tsxindex dc2f442461..1d69eab323 100644--- a/src/components/features/chat/git-control-bar.tsx+++ b/src/components/features/chat/git-control-bar.tsx@@ -23,6 +23,7 @@ import { useHomeStore } from "#/stores/home-store";import { useOptimisticUserMessageStore } from "#/stores/optimistic-user-message-store";import { getStoredConversationMetadata } from "#/api/conversation-metadata-store";import { useActiveBackend } from "#/contexts/active-backend-context";+import { useUserProviders } from "#/hooks/use-user-providers";interface GitControlBarProps {onSuggestionsClick: (value: string) => void;@@ -43,6 +44,8 @@ export function GitControlBar({ onSuggestionsClick }: GitControlBarProps) {);const { backend } = useActiveBackend();const isLocalBackend = backend.kind === "local";+ const { providers } = useUserProviders();+ const providerTokensReady = isLocalBackend || providers.length > 0;const { data: conversation } = useActiveConversation();const { repositoryInfo } = useTaskPolling();@@ -237,6 +240,8 @@ export function GitControlBar({ onSuggestionsClick }: GitControlBarProps) {><GitControlBarPullButtononSuggestionsClick={onSuggestionsClick}+ hasRepository={hasRepository}+ providerTokensReady={providerTokensReady}isConversationReady={isConversationReady}/></GitControlBarTooltipWrapper>@@ -249,6 +254,7 @@ export function GitControlBar({ onSuggestionsClick }: GitControlBarProps) {<GitControlBarPushButtononSuggestionsClick={onSuggestionsClick}hasRepository={hasRepository}+ providerTokensReady={providerTokensReady}currentGitProvider={gitProvider}isConversationReady={isConversationReady}/>@@ -262,6 +268,7 @@ export function GitControlBar({ onSuggestionsClick }: GitControlBarProps) {<GitControlBarPrButtononSuggestionsClick={onSuggestionsClick}hasRepository={hasRepository}+ providerTokensReady={providerTokensReady}currentGitProvider={gitProvider}isConversationReady={isConversationReady}/>