From 50391ecdf306bcb15faaa47f755665acc664ba4d Mon Sep 17 00:00:00 2001 From: Hiep Le <69354317+hieptl@users.noreply.github.com> Date: Wed, 27 Aug 2025 16:02:48 +0700 Subject: [PATCH] feat(frontend): update learning repo flow (microagent management) (#10597) Co-authored-by: amanape <83104063+amanape@users.noreply.github.com> Co-authored-by: openhands --- .../microagent-management-content.tsx | 7 +++++ ...agent-management-learn-this-repo-modal.tsx | 21 +++++++------- frontend/src/utils/utils.ts | 28 +++++++++++++++++++ 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/features/microagent-management/microagent-management-content.tsx b/frontend/src/components/features/microagent-management/microagent-management-content.tsx index 530d906f3b..7be9a9df05 100644 --- a/frontend/src/components/features/microagent-management/microagent-management-content.tsx +++ b/frontend/src/components/features/microagent-management/microagent-management-content.tsx @@ -277,6 +277,12 @@ export function MicroagentManagementContent() { const repositoryName = repository.full_name; const gitProvider = repository.git_provider; + const createMicroagent = { + repo: repositoryName, + git_provider: gitProvider, + title: formData.query, + }; + // Launch a new conversation to help the user understand the repo createConversationAndSubscribe({ query: formData.query, @@ -286,6 +292,7 @@ export function MicroagentManagementContent() { branch: formData.selectedBranch, gitProvider, }, + createMicroagent, onSuccessCallback: () => { hideLearnThisRepoModal(); }, diff --git a/frontend/src/components/features/microagent-management/microagent-management-learn-this-repo-modal.tsx b/frontend/src/components/features/microagent-management/microagent-management-learn-this-repo-modal.tsx index 9c5829ef5b..afa5ac0ac6 100644 --- a/frontend/src/components/features/microagent-management/microagent-management-learn-this-repo-modal.tsx +++ b/frontend/src/components/features/microagent-management/microagent-management-learn-this-repo-modal.tsx @@ -8,7 +8,7 @@ import { BrandButton } from "../settings/brand-button"; import { I18nKey } from "#/i18n/declaration"; import { RootState } from "#/store"; import XIcon from "#/icons/x.svg?react"; -import { cn } from "#/utils/utils"; +import { cn, getRepoMdCreatePrompt } from "#/utils/utils"; import { LearnThisRepoFormData } from "#/types/microagent-management"; import { Branch } from "#/types/git"; import { useRepositoryBranches } from "#/hooks/query/use-repository-branches"; @@ -76,23 +76,25 @@ export function MicroagentManagementLearnThisRepoModal({ const onSubmit = (event: React.FormEvent) => { event.preventDefault(); - if (!query.trim()) { - return; - } + const finalQuery = getRepoMdCreatePrompt( + selectedRepository?.git_provider || "github", + query.trim(), + ); onConfirm({ - query: query.trim(), + query: finalQuery, selectedBranch: selectedBranch?.name || "", }); }; const handleConfirm = () => { - if (!query.trim()) { - return; - } + const finalQuery = getRepoMdCreatePrompt( + selectedRepository?.git_provider || "github", + query.trim(), + ); onConfirm({ - query: query.trim(), + query: finalQuery, selectedBranch: selectedBranch?.name || "", }); }; @@ -244,7 +246,6 @@ export function MicroagentManagementLearnThisRepoModal({ onClick={handleConfirm} testId="confirm-button" isDisabled={ - !query.trim() || isLoading || isLoadingBranches || !selectedBranch || diff --git a/frontend/src/utils/utils.ts b/frontend/src/utils/utils.ts index 2c7c1027ce..d2dfc13184 100644 --- a/frontend/src/utils/utils.ts +++ b/frontend/src/utils/utils.ts @@ -244,3 +244,31 @@ export const extractRepositoryInfo = ( return { owner, repo, filePath }; }; + +/** + * Get the repository markdown creation prompt with additional PR creation instructions + * @param gitProvider The git provider to use for generating provider-specific text + * @param query Optional custom query to use instead of the default prompt + * @returns The complete prompt for creating repository markdown and PR instructions + */ +export const getRepoMdCreatePrompt = ( + gitProvider: Provider, + query?: string, +): string => { + const providerName = getProviderName(gitProvider); + const pr = getPR(gitProvider === "gitlab"); + const prShort = getPRShort(gitProvider === "gitlab"); + + return `Please explore this repository. Create the file .openhands/microagents/repo.md with: + ${ + query + ? `- ${query}` + : `- A description of the project + - An overview of the file structure + - Any information on how to run tests or other relevant commands + - Any other information that would be helpful to a brand new developer + Keep it short--just a few paragraphs will do.` + } + +Please push the changes to your branch on ${providerName} and create a ${pr}. Please create a meaningful branch name that describes the changes. If a ${pr} template exists in the repository, please follow it when creating the ${prShort} description.`; +};