🙌 OpenHands: AI-Driven Development
refactor: remove branch dropdown, update title, fix pr_number issue (microagent management) (#10691)
Hiep Le5b35203253bb
diff --git a/frontend/src/components/features/microagent-management/microagent-management-content.tsx b/frontend/src/components/features/microagent-management/microagent-management-content.tsxindex 7be9a9df05..315e7b9e67 100644--- a/frontend/src/components/features/microagent-management/microagent-management-content.tsx+++ b/frontend/src/components/features/microagent-management/microagent-management-content.tsx@@ -240,7 +240,6 @@ export function MicroagentManagementContent() {conversationInstructions,repository: {name: repositoryName,- branch: formData.selectedBranch,gitProvider,},createMicroagent,diff --git a/frontend/src/components/features/microagent-management/microagent-management-repo-microagents.tsx b/frontend/src/components/features/microagent-management/microagent-management-repo-microagents.tsxindex 939eb288fe..7466314512 100644--- a/frontend/src/components/features/microagent-management/microagent-management-repo-microagents.tsx+++ b/frontend/src/components/features/microagent-management/microagent-management-repo-microagents.tsx@@ -137,7 +137,7 @@ export function MicroagentManagementRepoMicroagents({{hasConversations && (<div className={cn("flex flex-col", hasMicroagents && "mt-4")}><span className="text-md text-white font-medium leading-5 mb-4">- {t(I18nKey.MICROAGENT_MANAGEMENT$OPEN_MICROAGENT_PULL_REQUESTS)}+ {t(I18nKey.COMMON$IN_PROGRESS)}</span>{conversations?.map((conversation) => (<div key={conversation.conversation_id} className="pb-4 last:pb-0">diff --git a/frontend/src/components/features/microagent-management/microagent-management-upsert-microagent-modal.tsx b/frontend/src/components/features/microagent-management/microagent-management-upsert-microagent-modal.tsxindex 0f9f9494cc..0351b387db 100644--- a/frontend/src/components/features/microagent-management/microagent-management-upsert-microagent-modal.tsx+++ b/frontend/src/components/features/microagent-management/microagent-management-upsert-microagent-modal.tsx@@ -1,4 +1,4 @@-import { useEffect, useRef, useState, useMemo } from "react";+import { useEffect, useState, useMemo } from "react";import { useTranslation } from "react-i18next";import { useSelector } from "react-redux";import { FaCircleInfo } from "react-icons/fa6";@@ -11,14 +11,8 @@ import XIcon from "#/icons/x.svg?react";import { cn, extractRepositoryInfo } from "#/utils/utils";import { BadgeInput } from "#/components/shared/inputs/badge-input";import { MicroagentFormData } from "#/types/microagent-management";-import { Branch, GitRepository } from "#/types/git";-import { useRepositoryBranches } from "#/hooks/query/use-repository-branches";+import { GitRepository } from "#/types/git";import { useRepositoryMicroagentContent } from "#/hooks/query/use-repository-microagent-content";-import {- BranchDropdown,- BranchLoadingState,- BranchErrorState,-} from "../home/repository-selection";interface MicroagentManagementUpsertMicroagentModalProps {onConfirm: (formData: MicroagentFormData) => void;@@ -37,7 +31,6 @@ export function MicroagentManagementUpsertMicroagentModal({const [triggers, setTriggers] = useState<string[]>([]);const [query, setQuery] = useState<string>("");- const [selectedBranch, setSelectedBranch] = useState<Branch | null>(null);const { selectedRepository } = useSelector((state: RootState) => state.microagentManagement,@@ -49,9 +42,6 @@ export function MicroagentManagementUpsertMicroagentModal({const { microagent } = selectedMicroagentItem ?? {};- // Add a ref to track if the branch was manually cleared by the user- const branchManuallyClearedRef = useRef<boolean>(false);-// Extract owner and repo from full_name for content APIconst { owner, repo, filePath } = extractRepositoryInfo(selectedRepository,@@ -70,38 +60,6 @@ export function MicroagentManagementUpsertMicroagentModal({}}, [isUpdate, microagentContentData]);- const {- data: branches,- isLoading: isLoadingBranches,- isError: isBranchesError,- } = useRepositoryBranches(selectedRepository?.full_name || null);-- const branchesItems = branches?.map((branch) => ({- key: branch.name,- label: branch.name,- }));-- // Auto-select main or master branch if it exists.- useEffect(() => {- if (- branches &&- branches.length > 0 &&- !selectedBranch &&- !isLoadingBranches- ) {- // Look for main or master branch- const mainBranch = branches.find((branch) => branch.name === "main");- const masterBranch = branches.find((branch) => branch.name === "master");-- // Select main if it exists, otherwise select master if it exists- if (mainBranch) {- setSelectedBranch(mainBranch);- } else if (masterBranch) {- setSelectedBranch(masterBranch);- }- }- }, [branches, isLoadingBranches, selectedBranch]);-const modalTitle = useMemo(() => {if (isUpdate) {return t(I18nKey.MICROAGENT_MANAGEMENT$UPDATE_MICROAGENT);@@ -134,7 +92,6 @@ export function MicroagentManagementUpsertMicroagentModal({onConfirm({query: query.trim(),triggers,- selectedBranch: selectedBranch?.name || "",microagentPath: microagent?.path || "",});};@@ -147,67 +104,10 @@ export function MicroagentManagementUpsertMicroagentModal({onConfirm({query: query.trim(),triggers,- selectedBranch: selectedBranch?.name || "",microagentPath: microagent?.path || "",});};- const handleBranchSelection = (key: React.Key | null) => {- const selectedBranchObj = branches?.find((branch) => branch.name === key);- setSelectedBranch(selectedBranchObj || null);- // Reset the manually cleared flag when a branch is explicitly selected- branchManuallyClearedRef.current = false;- };-- const handleBranchInputChange = (value: string) => {- // Clear the selected branch if the input is empty or contains only whitespace- // This fixes the issue where users can't delete the entire default branch name- if (value === "" || value.trim() === "") {- setSelectedBranch(null);- // Set the flag to indicate that the branch was manually cleared- branchManuallyClearedRef.current = true;- } else {- // Reset the flag when the user starts typing again- branchManuallyClearedRef.current = false;- }- };-- // Render the appropriate UI for branch selector based on the loading/error state- const renderBranchSelector = () => {- if (!selectedRepository) {- return (- <BranchDropdown- items={[]}- onSelectionChange={() => {}}- onInputChange={() => {}}- isDisabled- wrapperClassName="max-w-full w-full"- label={t(I18nKey.REPOSITORY$SELECT_BRANCH)}- />- );- }-- if (isLoadingBranches) {- return <BranchLoadingState wrapperClassName="max-w-full w-full" />;- }-- if (isBranchesError) {- return <BranchErrorState wrapperClassName="max-w-full w-full" />;- }-- return (- <BranchDropdown- items={branchesItems || []}- onSelectionChange={handleBranchSelection}- onInputChange={handleBranchInputChange}- isDisabled={false}- selectedKey={selectedBranch?.name}- wrapperClassName="max-w-full w-full"- label={t(I18nKey.REPOSITORY$SELECT_BRANCH)}- />- );- };-return (<ModalBackdrop onClose={onCancel}><ModalBody className="items-start rounded-[12px] p-6 min-w-[611px]">@@ -236,7 +136,6 @@ export function MicroagentManagementUpsertMicroagentModal({onSubmit={onSubmit}className="flex flex-col gap-6 w-full">- {renderBranchSelector()}<labelhtmlFor="query-input"className="flex flex-col gap-2 w-full text-sm font-normal"@@ -301,15 +200,10 @@ export function MicroagentManagementUpsertMicroagentModal({onClick={handleConfirm}testId="confirm-button"isDisabled={- !query.trim() ||- isLoading ||- isLoadingBranches ||- !selectedBranch ||- isBranchesError ||- (isUpdate && isLoadingContent) // Disable while loading content for updates+ !query.trim() || isLoading || (isUpdate && isLoadingContent) // Disable while loading content for updates}>- {isLoading || isLoadingBranches || (isUpdate && isLoadingContent)+ {isLoading || (isUpdate && isLoadingContent)? t(I18nKey.HOME$LOADING): t(I18nKey.MICROAGENT$LAUNCH)}</BrandButton>diff --git a/frontend/src/hooks/use-create-conversation-and-subscribe-multiple.ts b/frontend/src/hooks/use-create-conversation-and-subscribe-multiple.tsindex ebd5b37995..017e3bbdb7 100644--- a/frontend/src/hooks/use-create-conversation-and-subscribe-multiple.ts+++ b/frontend/src/hooks/use-create-conversation-and-subscribe-multiple.ts@@ -128,7 +128,7 @@ export const useCreateConversationAndSubscribeMultiple = () => {conversationInstructions: string;repository: {name: string;- branch: string;+ branch?: string;gitProvider: Provider;};createMicroagent?: CreateMicroagent;diff --git a/frontend/src/i18n/declaration.ts b/frontend/src/i18n/declaration.tsindex 23a3ea6273..115c2ab226 100644--- a/frontend/src/i18n/declaration.ts+++ b/frontend/src/i18n/declaration.ts@@ -818,11 +818,11 @@ export enum I18nKey {MICROAGENT$UNKNOWN_ERROR = "MICROAGENT$UNKNOWN_ERROR",MICROAGENT$CONVERSATION_STARTING = "MICROAGENT$CONVERSATION_STARTING",MICROAGENT_MANAGEMENT$EXISTING_MICROAGENTS = "MICROAGENT_MANAGEMENT$EXISTING_MICROAGENTS",- MICROAGENT_MANAGEMENT$OPEN_MICROAGENT_PULL_REQUESTS = "MICROAGENT_MANAGEMENT$OPEN_MICROAGENT_PULL_REQUESTS",SETTINGS$SECURITY_ANALYZER_LLM_DEFAULT = "SETTINGS$SECURITY_ANALYZER_LLM_DEFAULT",SETTINGS$SECURITY_ANALYZER_NONE = "SETTINGS$SECURITY_ANALYZER_NONE",SETTINGS$SECURITY_ANALYZER_INVARIANT = "SETTINGS$SECURITY_ANALYZER_INVARIANT",COMMON$HIGH_RISK = "COMMON$HIGH_RISK",MICROAGENT$DEFINITION = "MICROAGENT$DEFINITION",MICROAGENT$ADD_TO_MEMORY = "MICROAGENT$ADD_TO_MEMORY",+ COMMON$IN_PROGRESS = "COMMON$IN_PROGRESS",}diff --git a/frontend/src/i18n/translation.json b/frontend/src/i18n/translation.jsonindex 8aae5b0243..d91f02320a 100644--- a/frontend/src/i18n/translation.json+++ b/frontend/src/i18n/translation.json@@ -13087,22 +13087,6 @@"de": "Vorhandene Mikroagenten","uk": "Існуючі мікроагенти"},- "MICROAGENT_MANAGEMENT$OPEN_MICROAGENT_PULL_REQUESTS": {- "en": "Open Microagent Pull Requests",- "ja": "未解決のマイクロエージェントのプルリクエスト",- "zh-CN": "未合并的微代理拉取请求",- "zh-TW": "未合併的微代理拉取請求",- "ko-KR": "오픈된 마이크로에이전트 풀 리퀘스트",- "no": "Åpne mikroagent-pull requests",- "it": "Pull request di microagent aperte",- "pt": "Pull requests de microagentes abertas",- "es": "Pull requests de microagentes abiertas",- "ar": "طلبات السحب المفتوحة للوكلاء الدقيقين",- "fr": "Pull requests de microagents ouvertes",- "tr": "Açık Mikroajan Pull İstekleri",- "de": "Offene Microagent-Pull-Requests",- "uk": "Відкриті pull-запити мікроагентів"- },"SETTINGS$SECURITY_ANALYZER_LLM_DEFAULT": {"en": "LLM Analyzer (Default)","ja": "LLMアナライザー(デフォルト)",@@ -13198,5 +13182,21 @@"tr": "Mikroajan Hafızasına Ekle","de": "Zur Microagent-Speicher hinzufügen","uk": "Додати до пам'яті мікроагента"+ },+ "COMMON$IN_PROGRESS": {+ "en": "In Progress",+ "ja": "進行中",+ "zh-CN": "进行中",+ "zh-TW": "進行中",+ "ko-KR": "진행 중",+ "no": "Pågår",+ "it": "In corso",+ "pt": "Em andamento",+ "es": "En progreso",+ "ar": "قيد التنفيذ",+ "fr": "En cours",+ "tr": "Devam Ediyor",+ "de": "In Bearbeitung",+ "uk": "В процесі"}}diff --git a/frontend/src/types/microagent-management.tsx b/frontend/src/types/microagent-management.tsxindex d26ba5fe62..1d68b7416f 100644--- a/frontend/src/types/microagent-management.tsx+++ b/frontend/src/types/microagent-management.tsx@@ -17,7 +17,6 @@ export interface IMicroagentItem {export interface MicroagentFormData {query: string;triggers: string[];- selectedBranch: string;microagentPath: string;}diff --git a/openhands/server/routes/mcp.py b/openhands/server/routes/mcp.pyindex 1f33eab9c1..f5a7b17be7 100644--- a/openhands/server/routes/mcp.py+++ b/openhands/server/routes/mcp.py@@ -206,7 +206,7 @@ async def create_mr(labels=labels,)- if conversation_id and user_id:+ if conversation_id:await save_pr_metadata(user_id, conversation_id, response)except Exception as e:@@ -272,7 +272,7 @@ async def create_bitbucket_pr(body=description,)- if conversation_id and user_id:+ if conversation_id:await save_pr_metadata(user_id, conversation_id, response)except Exception as e: