Skip to content

🙌 OpenHands: AI-Driven Development

feat: Support the “Learn this repo” Button for the Microagent Management Page. (#9873)

Hiep Lefa041537c387
diff --git a/frontend/__tests__/components/features/microagent-management/microagent-management.test.tsx b/frontend/__tests__/components/features/microagent-management/microagent-management.test.tsx
index 591795b54c..f9ac19043d 100644
--- a/frontend/__tests__/components/features/microagent-management/microagent-management.test.tsx
+++ b/frontend/__tests__/components/features/microagent-management/microagent-management.test.tsx
@@ -36,6 +36,7 @@ describe("MicroagentManagement", () => {
organizationRepositories: [],
repositories: [],
selectedMicroagentItem: null,
+ learnThisRepoModalVisible: false,
},
},
});
@@ -1297,6 +1298,7 @@ describe("MicroagentManagement", () => {
organizationRepositories: [],
repositories: [],
updateMicroagentModalVisible: false,
+ learnThisRepoModalVisible: false,
},
},
});
@@ -1554,6 +1556,7 @@ describe("MicroagentManagement", () => {
repositories: [],
selectedMicroagentItem,
updateMicroagentModalVisible: false,
+ learnThisRepoModalVisible: false,
},
},
});
@@ -1914,6 +1917,7 @@ describe("MicroagentManagement", () => {
personalRepositories: [],
organizationRepositories: [],
repositories: [],
+ learnThisRepoModalVisible: false,
},
},
});
@@ -1952,6 +1956,7 @@ describe("MicroagentManagement", () => {
personalRepositories: [],
organizationRepositories: [],
repositories: [],
+ learnThisRepoModalVisible: false,
},
},
});
@@ -1989,6 +1994,7 @@ describe("MicroagentManagement", () => {
personalRepositories: [],
organizationRepositories: [],
repositories: [],
+ learnThisRepoModalVisible: false,
},
},
});
@@ -2004,7 +2010,7 @@ describe("MicroagentManagement", () => {
const user = userEvent.setup();
// Render with update modal visible and selected microagent
- const { store } = renderWithProviders(<RouterStub />, {
+ renderWithProviders(<RouterStub />, {
preloadedState: {
metrics: {
cost: null,
@@ -2029,6 +2035,7 @@ describe("MicroagentManagement", () => {
personalRepositories: [],
organizationRepositories: [],
repositories: [],
+ learnThisRepoModalVisible: false,
},
},
});
@@ -2047,12 +2054,6 @@ describe("MicroagentManagement", () => {
const confirmButton = screen.getByTestId("confirm-button");
await user.click(confirmButton);
- // Directly update the Redux state to simulate modal closing
- store.dispatch({
- type: "microagentManagement/setUpdateMicroagentModalVisible",
- payload: false,
- });
-
// Wait for the modal to be removed after form submission
await waitFor(() => {
expect(
@@ -2090,6 +2091,7 @@ describe("MicroagentManagement", () => {
personalRepositories: [],
organizationRepositories: [],
repositories: [],
+ learnThisRepoModalVisible: false,
},
},
});
@@ -2140,6 +2142,7 @@ describe("MicroagentManagement", () => {
personalRepositories: [],
organizationRepositories: [],
repositories: [],
+ learnThisRepoModalVisible: false,
},
},
});
@@ -2190,6 +2193,7 @@ describe("MicroagentManagement", () => {
personalRepositories: [],
organizationRepositories: [],
repositories: [],
+ learnThisRepoModalVisible: false,
},
},
});
@@ -2234,6 +2238,7 @@ describe("MicroagentManagement", () => {
personalRepositories: [],
organizationRepositories: [],
repositories: [],
+ learnThisRepoModalVisible: false,
},
},
});
@@ -2276,6 +2281,7 @@ describe("MicroagentManagement", () => {
personalRepositories: [],
organizationRepositories: [],
repositories: [],
+ learnThisRepoModalVisible: false,
},
},
});
@@ -2288,6 +2294,194 @@ describe("MicroagentManagement", () => {
});
});
+ // Learn this repo functionality tests
+ describe("Learn this repo functionality", () => {
+ it("should display learn this repo trigger when no microagents exist", async () => {
+ const user = userEvent.setup();
+
+ // Setup mocks before rendering
+ const getRepositoryMicroagentsSpy = vi.spyOn(
+ OpenHands,
+ "getRepositoryMicroagents",
+ );
+ const searchConversationsSpy = vi.spyOn(OpenHands, "searchConversations");
+ getRepositoryMicroagentsSpy.mockResolvedValue([]);
+ searchConversationsSpy.mockResolvedValue([]);
+
+ renderMicroagentManagement();
+
+ // Wait for repositories to be loaded
+ await waitFor(() => {
+ expect(OpenHands.retrieveUserGitRepositories).toHaveBeenCalled();
+ });
+
+ // Find and click on the first repository accordion to expand it
+ const repoAccordion = screen.getByTestId("repository-name-tooltip");
+ await user.click(repoAccordion);
+
+ // Wait for microagents and conversations to be fetched
+ await waitFor(() => {
+ expect(getRepositoryMicroagentsSpy).toHaveBeenCalled();
+ expect(searchConversationsSpy).toHaveBeenCalled();
+ });
+
+ // Verify the learn this repo trigger is displayed when no microagents exist
+ await waitFor(() => {
+ expect(
+ screen.getByTestId("learn-this-repo-trigger"),
+ ).toBeInTheDocument();
+ });
+
+ // Verify trigger has correct text content
+ expect(screen.getByTestId("learn-this-repo-trigger")).toHaveTextContent(
+ "MICROAGENT_MANAGEMENT$LEARN_THIS_REPO",
+ );
+ });
+
+ it("should trigger learn this repo modal opening when trigger is clicked", async () => {
+ const user = userEvent.setup();
+
+ // Setup mocks
+ const getRepositoryMicroagentsSpy = vi.spyOn(
+ OpenHands,
+ "getRepositoryMicroagents",
+ );
+ const searchConversationsSpy = vi.spyOn(OpenHands, "searchConversations");
+ getRepositoryMicroagentsSpy.mockResolvedValue([]);
+ searchConversationsSpy.mockResolvedValue([]);
+
+ renderMicroagentManagement();
+
+ // Wait for repositories and expand accordion
+ await waitFor(() => {
+ expect(OpenHands.retrieveUserGitRepositories).toHaveBeenCalled();
+ });
+
+ const repoAccordion = screen.getByTestId("repository-name-tooltip");
+ await user.click(repoAccordion);
+
+ await waitFor(() => {
+ expect(
+ screen.getByTestId("learn-this-repo-trigger"),
+ ).toBeInTheDocument();
+ });
+
+ // Verify the trigger is clickable and has correct behavior
+ const learnThisRepoTrigger = screen.getByTestId(
+ "learn-this-repo-trigger",
+ );
+
+ // Verify the trigger has the expected text content
+ expect(learnThisRepoTrigger).toHaveTextContent(
+ "MICROAGENT_MANAGEMENT$LEARN_THIS_REPO",
+ );
+
+ // Click the trigger should not throw an error
+ await user.click(learnThisRepoTrigger);
+
+ // The trigger should still be present after click (testing that click is handled gracefully)
+ expect(learnThisRepoTrigger).toBeInTheDocument();
+ });
+
+ it("should show learn this repo trigger only when no microagents or conversations exist", async () => {
+ const user = userEvent.setup();
+
+ // Setup mocks with existing microagents (should NOT show trigger)
+ const getRepositoryMicroagentsSpy = vi.spyOn(
+ OpenHands,
+ "getRepositoryMicroagents",
+ );
+ const searchConversationsSpy = vi.spyOn(OpenHands, "searchConversations");
+
+ // Mock with existing microagent
+ getRepositoryMicroagentsSpy.mockResolvedValue([
+ {
+ name: "test-microagent",
+ type: "repo",
+ content: "Test content",
+ triggers: [],
+ inputs: [],
+ tools: [],
+ created_at: "2021-10-01",
+ git_provider: "github",
+ path: ".openhands/microagents/test",
+ },
+ ]);
+ searchConversationsSpy.mockResolvedValue([]);
+
+ renderMicroagentManagement();
+
+ await waitFor(() => {
+ expect(OpenHands.retrieveUserGitRepositories).toHaveBeenCalled();
+ });
+
+ const repoAccordion = screen.getByTestId("repository-name-tooltip");
+ await user.click(repoAccordion);
+
+ await waitFor(() => {
+ expect(getRepositoryMicroagentsSpy).toHaveBeenCalled();
+ expect(searchConversationsSpy).toHaveBeenCalled();
+ });
+
+ // Should NOT show the learn this repo trigger when microagents exist
+ expect(
+ screen.queryByTestId("learn-this-repo-trigger"),
+ ).not.toBeInTheDocument();
+ });
+
+ it("should handle API call for branches when learn this repo modal opens", async () => {
+ // Mock branch API
+ const branchesSpy = vi
+ .spyOn(OpenHands, "getRepositoryBranches")
+ .mockResolvedValue([
+ { name: "main", commit_sha: "abc123", protected: false },
+ { name: "develop", commit_sha: "def456", protected: false },
+ ]);
+
+ // Mock other APIs
+ const getRepositoryMicroagentsSpy = vi.spyOn(
+ OpenHands,
+ "getRepositoryMicroagents",
+ );
+ const searchConversationsSpy = vi.spyOn(OpenHands, "searchConversations");
+ getRepositoryMicroagentsSpy.mockResolvedValue([]);
+ searchConversationsSpy.mockResolvedValue([]);
+
+ // Test with direct Redux state that has modal visible
+ renderWithProviders(<RouterStub />, {
+ preloadedState: {
+ metrics: {
+ cost: null,
+ max_budget_per_task: null,
+ usage: null,
+ },
+ microagentManagement: {
+ selectedMicroagentItem: null,
+ addMicroagentModalVisible: false,
+ updateMicroagentModalVisible: false,
+ learnThisRepoModalVisible: true, // Modal should be visible
+ selectedRepository: {
+ id: "1",
+ full_name: "test-org/test-repo",
+ git_provider: "github",
+ is_public: true,
+ owner_type: "user",
+ pushed_at: "2021-10-01T12:00:00Z",
+ },
+ personalRepositories: [],
+ organizationRepositories: [],
+ repositories: [],
+ },
+ },
+ });
+
+ // The branches API should be called when the modal is visible
+ await waitFor(() => {
+ expect(branchesSpy).toHaveBeenCalledWith("test-org/test-repo");
+ });
+ });
+ });
+
// Learn something new button functionality tests
describe("Learn something new button functionality", () => {
const mockMicroagentForLearn: RepositoryMicroagent = {
@@ -2329,6 +2523,7 @@ describe("MicroagentManagement", () => {
personalRepositories: [],
organizationRepositories: [],
repositories: [],
+ learnThisRepoModalVisible: false,
},
},
});
@@ -2368,6 +2563,7 @@ describe("MicroagentManagement", () => {
personalRepositories: [],
organizationRepositories: [],
repositories: [],
+ learnThisRepoModalVisible: false,
},
},
});
@@ -2416,6 +2612,7 @@ describe("MicroagentManagement", () => {
personalRepositories: [],
organizationRepositories: [],
repositories: [],
+ learnThisRepoModalVisible: false,
},
},
});
@@ -2469,6 +2666,7 @@ describe("MicroagentManagement", () => {
personalRepositories: [],
organizationRepositories: [],
repositories: [],
+ learnThisRepoModalVisible: false,
},
},
});
@@ -2520,6 +2718,7 @@ describe("MicroagentManagement", () => {
personalRepositories: [],
organizationRepositories: [],
repositories: [],
+ learnThisRepoModalVisible: false,
},
},
});
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 5d042dfb1a..e43a72eeb1 100644
--- a/frontend/src/components/features/microagent-management/microagent-management-content.tsx
+++ b/frontend/src/components/features/microagent-management/microagent-management-content.tsx
@@ -7,9 +7,13 @@ import { RootState } from "#/store";
import {
setAddMicroagentModalVisible,
setUpdateMicroagentModalVisible,
+ setLearnThisRepoModalVisible,
} from "#/state/microagent-management-slice";
import { useCreateConversationAndSubscribeMultiple } from "#/hooks/use-create-conversation-and-subscribe-multiple";
-import { MicroagentFormData } from "#/types/microagent-management";
+import {
+ LearnThisRepoFormData,
+ MicroagentFormData,
+} from "#/types/microagent-management";
import { AgentState } from "#/types/agent-state";
import { getPR, getProviderName, getPRShort } from "#/utils/utils";
import {
@@ -20,6 +24,7 @@ import {
import { GitRepository } from "#/types/git";
import { queryClient } from "#/query-client-config";
import { Provider } from "#/types/settings";
+import { MicroagentManagementLearnThisRepoModal } from "./microagent-management-learn-this-repo-modal";
// Handle error events
const isErrorEvent = (evt: unknown): evt is { error: true; message: string } =>
@@ -104,6 +109,7 @@ export function MicroagentManagementContent() {
addMicroagentModalVisible,
updateMicroagentModalVisible,
selectedRepository,
+ learnThisRepoModalVisible,
} = useSelector((state: RootState) => state.microagentManagement);
const dispatch = useDispatch();
@@ -231,21 +237,57 @@ export function MicroagentManagementContent() {
});
};
- const renderModals = () => {
- if (addMicroagentModalVisible || updateMicroagentModalVisible) {
- return (
+ const hideLearnThisRepoModal = () => {
+ dispatch(setLearnThisRepoModalVisible(false));
+ };
+
+ const handleLearnThisRepoConfirm = (formData: LearnThisRepoFormData) => {
+ if (!selectedRepository || typeof selectedRepository !== "object") {
+ return;
+ }
+
+ const repository = selectedRepository as GitRepository;
+ const repositoryName = repository.full_name;
+ const gitProvider = repository.git_provider;
+
+ // Launch a new conversation to help the user understand the repo
+ createConversationAndSubscribe({
+ query: formData.query,
+ conversationInstructions: formData.query,
+ repository: {
+ name: repositoryName,
+ branch: formData.selectedBranch,
+ gitProvider,
+ },
+ onSuccessCallback: () => {
+ hideLearnThisRepoModal();
+ },
+ });
+ };
+
+ const renderModals = () => (
+ <>
+ {(addMicroagentModalVisible || updateMicroagentModalVisible) && (
<MicroagentManagementUpsertMicroagentModal
- onConfirm={(formData) => handleUpsertMicroagent(formData, false)}
+ onConfirm={(formData) =>
+ handleUpsertMicroagent(formData, updateMicroagentModalVisible)
+ }
onCancel={() =>
hideUpsertMicroagentModal(updateMicroagentModalVisible)
}
isLoading={isPending}
isUpdate={updateMicroagentModalVisible}
/>
- );
- }
- return null;
- };
+ )}
+ {learnThisRepoModalVisible && (
+ <MicroagentManagementLearnThisRepoModal
+ onCancel={hideLearnThisRepoModal}
+ onConfirm={handleLearnThisRepoConfirm}
+ isLoading={isPending}
+ />
+ )}
+ </>
+ );
if (width < 1024) {
return (
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
new file mode 100644
index 0000000000..9c5829ef5b
--- /dev/null
+++ b/frontend/src/components/features/microagent-management/microagent-management-learn-this-repo-modal.tsx
@@ -0,0 +1,262 @@
+import { useEffect, useRef, useState } from "react";
+import { useTranslation } from "react-i18next";
+import { useSelector } from "react-redux";
+import { FaCircleInfo } from "react-icons/fa6";
+import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";
+import { ModalBody } from "#/components/shared/modals/modal-body";
+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 { LearnThisRepoFormData } from "#/types/microagent-management";
+import { Branch } from "#/types/git";
+import { useRepositoryBranches } from "#/hooks/query/use-repository-branches";
+import {
+ BranchDropdown,
+ BranchLoadingState,
+ BranchErrorState,
+} from "../home/repository-selection";
+
+interface MicroagentManagementLearnThisRepoModalProps {
+ onConfirm: (formData: LearnThisRepoFormData) => void;
+ onCancel: () => void;
+ isLoading: boolean;
+}
+
+export function MicroagentManagementLearnThisRepoModal({
+ onConfirm,
+ onCancel,
+ isLoading = false,
+}: MicroagentManagementLearnThisRepoModalProps) {
+ const { t } = useTranslation();
+
+ const [query, setQuery] = useState<string>("");
+ const [selectedBranch, setSelectedBranch] = useState<Branch | null>(null);
+
+ const { selectedRepository } = useSelector(
+ (state: RootState) => state.microagentManagement,
+ );
+
+ // Add a ref to track if the branch was manually cleared by the user
+ const branchManuallyClearedRef = useRef<boolean>(false);
+
+ 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 onSubmit = (event: React.FormEvent<HTMLFormElement>) => {
+ event.preventDefault();
+
+ if (!query.trim()) {
+ return;
+ }
+
+ onConfirm({
+ query: query.trim(),
+ selectedBranch: selectedBranch?.name || "",
+ });
+ };
+
+ const handleConfirm = () => {
+ if (!query.trim()) {
+ return;
+ }
+
+ onConfirm({
+ query: query.trim(),
+ selectedBranch: selectedBranch?.name || "",
+ });
+ };
+
+ 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]"
+ data-testid="learn-this-repo-modal"
+ >
+ <div className="flex flex-col gap-2 w-full">
+ <div className="flex justify-between items-center">
+ <div className="flex items-center gap-2">
+ <h2
+ className="text-white text-xl font-medium"
+ data-testid="modal-title"
+ >
+ {t(I18nKey.MICROAGENT_MANAGEMENT$LEARN_THIS_REPO_MODAL_TITLE)}
+ </h2>
+ <a
+ href="https://docs.all-hands.dev/usage/prompting/microagents-overview#microagents-overview"
+ target="_blank"
+ rel="noopener noreferrer"
+ data-testid="modal-info-link"
+ >
+ <FaCircleInfo className="text-primary" />
+ </a>
+ </div>
+ <button
+ type="button"
+ onClick={onCancel}
+ className="cursor-pointer"
+ data-testid="modal-close-button"
+ >
+ <XIcon width={24} height={24} color="#F9FBFE" />
+ </button>
+ </div>
+ <span
+ className="text-white text-sm font-normal"
+ data-testid="modal-description"
+ >
+ {t(I18nKey.MICROAGENT_MANAGEMENT$LEARN_THIS_REPO_MODAL_DESCRIPTION)}
+ </span>
+ </div>
+ <form
+ data-testid="learn-this-repo-form"
+ onSubmit={onSubmit}
+ className="flex flex-col gap-6 w-full"
+ >
+ <div data-testid="branch-selector-container">
+ {renderBranchSelector()}
+ </div>
+ <label
+ htmlFor="query-input"
+ className="flex flex-col gap-2 w-full text-sm font-normal"
+ >
+ {t(
+ I18nKey.MICROAGENT_MANAGEMENT$WHAT_YOU_WOULD_LIKE_TO_KNOW_ABOUT_THIS_REPO,
+ )}
+ <textarea
+ required
+ data-testid="query-input"
+ name="query-input"
+ value={query}
+ onChange={(e) => setQuery(e.target.value)}
+ placeholder={t(
+ I18nKey.MICROAGENT_MANAGEMENT$DESCRIBE_WHAT_TO_KNOW_ABOUT_THIS_REPO,
+ )}
+ rows={6}
+ className={cn(
+ "bg-tertiary border border-[#717888] bg-[#454545] w-full rounded-sm p-2 placeholder:italic placeholder:text-tertiary-alt resize-none",
+ "disabled:bg-[#2D2F36] disabled:border-[#2D2F36] disabled:cursor-not-allowed",
+ )}
+ />
+ </label>
+ </form>
+ <div
+ className="flex items-center justify-end gap-2 w-full"
+ onClick={(event) => event.stopPropagation()}
+ data-testid="modal-actions"
+ >
+ <BrandButton
+ type="button"
+ variant="secondary"
+ onClick={onCancel}
+ testId="cancel-button"
+ >
+ {t(I18nKey.BUTTON$CANCEL)}
+ </BrandButton>
+ <BrandButton
+ type="button"
+ variant="primary"
+ onClick={handleConfirm}
+ testId="confirm-button"
+ isDisabled={
+ !query.trim() ||
+ isLoading ||
+ isLoadingBranches ||
+ !selectedBranch ||
+ isBranchesError
+ }
+ >
+ {isLoading || isLoadingBranches
+ ? t(I18nKey.HOME$LOADING)
+ : t(I18nKey.MICROAGENT$LAUNCH)}
+ </BrandButton>
+ </div>
+ </ModalBody>
+ </ModalBackdrop>
+ );
+}
diff --git a/frontend/src/components/features/microagent-management/microagent-management-learn-this-repo.tsx b/frontend/src/components/features/microagent-management/microagent-management-learn-this-repo.tsx
index cc54a5b0c6..2a526a26ef 100644
--- a/frontend/src/components/features/microagent-management/microagent-management-learn-this-repo.tsx
+++ b/frontend/src/components/features/microagent-management/microagent-management-learn-this-repo.tsx
@@ -1,25 +1,36 @@
+import { useDispatch } from "react-redux";
import { useTranslation } from "react-i18next";
import { I18nKey } from "#/i18n/declaration";
+import {
+ setLearnThisRepoModalVisible,
+ setSelectedRepository,
+} from "#/state/microagent-management-slice";
+import { GitRepository } from "#/types/git";
interface MicroagentManagementLearnThisRepoProps {
- repositoryUrl: string;
+ repository: GitRepository;
}
export function MicroagentManagementLearnThisRepo({
- repositoryUrl,
+ repository,
}: MicroagentManagementLearnThisRepoProps) {
+ const dispatch = useDispatch();
const { t } = useTranslation();
+ const handleClick = () => {
+ dispatch(setLearnThisRepoModalVisible(true));
+ dispatch(setSelectedRepository(repository));
+ };
+
return (
- <div className="flex items-center justify-center rounded-lg bg-[#ffffff0d] border border-dashed border-[#ffffff4d] p-4 hover:bg-[#ffffff33] hover:border-[#C9B974] transition-all duration-300 cursor-pointer">
- <a
- className="text-[16px] font-normal text-[#8480FF]"
- href={repositoryUrl}
- target="_blank"
- rel="noopener noreferrer"
- >
+ <div
+ className="flex items-center justify-center rounded-lg bg-[#ffffff0d] border border-dashed border-[#ffffff4d] p-4 hover:bg-[#ffffff33] hover:border-[#C9B974] transition-all duration-300 cursor-pointer"
+ onClick={handleClick}
+ data-testid="learn-this-repo-trigger"
+ >
+ <span className="text-[16px] font-normal text-[#8480FF]">
{t(I18nKey.MICROAGENT_MANAGEMENT$LEARN_THIS_REPO)}
- </a>
+ </span>
</div>
);
}
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.tsx
index 2af905f083..b6ac4bf5f7 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
@@ -6,7 +6,6 @@ import { MicroagentManagementLearnThisRepo } from "./microagent-management-learn
import { useRepositoryMicroagents } from "#/hooks/query/use-repository-microagents";
import { useSearchConversations } from "#/hooks/query/use-search-conversations";
import { GitRepository } from "#/types/git";
-import { getGitProviderBaseUrl } from "#/utils/utils";
import { RootState } from "#/store";
import { setSelectedMicroagentItem } from "#/state/microagent-management-slice";
@@ -23,13 +22,11 @@ export function MicroagentManagementRepoMicroagents({
const dispatch = useDispatch();
- const { full_name: repositoryName, git_provider: gitProvider } = repository;
+ const { full_name: repositoryName } = repository;
// Extract owner and repo from repositoryName (format: "owner/repo")
const [owner, repo] = repositoryName.split("/");
- const repositoryUrl = `${getGitProviderBaseUrl(gitProvider)}/${repositoryName}`;
-
const {
data: microagents,
isLoading: isLoadingMicroagents,
@@ -86,7 +83,7 @@ export function MicroagentManagementRepoMicroagents({
if (isError) {
return (
<div className="pb-4">
- <MicroagentManagementLearnThisRepo repositoryUrl={repositoryUrl} />
+ <MicroagentManagementLearnThisRepo repository={repository} />
</div>
);
}
@@ -98,7 +95,7 @@ export function MicroagentManagementRepoMicroagents({
return (
<div className="pb-4">
{totalItems === 0 && (
- <MicroagentManagementLearnThisRepo repositoryUrl={repositoryUrl} />
+ <MicroagentManagementLearnThisRepo repository={repository} />
)}
{/* Render microagents */}
diff --git a/frontend/src/i18n/declaration.ts b/frontend/src/i18n/declaration.ts
index a0f432077f..b2413b9ac4 100644
--- a/frontend/src/i18n/declaration.ts
+++ b/frontend/src/i18n/declaration.ts
@@ -728,5 +728,9 @@ export enum I18nKey {
COMMON$STARTING = "COMMON$STARTING",
MICROAGENT_MANAGEMENT$ERROR = "MICROAGENT_MANAGEMENT$ERROR",
MICROAGENT_MANAGEMENT$CONVERSATION_STOPPED = "MICROAGENT_MANAGEMENT$CONVERSATION_STOPPED",
+ MICROAGENT_MANAGEMENT$LEARN_THIS_REPO_MODAL_TITLE = "MICROAGENT_MANAGEMENT$LEARN_THIS_REPO_MODAL_TITLE",
+ MICROAGENT_MANAGEMENT$LEARN_THIS_REPO_MODAL_DESCRIPTION = "MICROAGENT_MANAGEMENT$LEARN_THIS_REPO_MODAL_DESCRIPTION",
+ MICROAGENT_MANAGEMENT$WHAT_YOU_WOULD_LIKE_TO_KNOW_ABOUT_THIS_REPO = "MICROAGENT_MANAGEMENT$WHAT_YOU_WOULD_LIKE_TO_KNOW_ABOUT_THIS_REPO",
+ MICROAGENT_MANAGEMENT$DESCRIBE_WHAT_TO_KNOW_ABOUT_THIS_REPO = "MICROAGENT_MANAGEMENT$DESCRIBE_WHAT_TO_KNOW_ABOUT_THIS_REPO",
MICROAGENT_MANAGEMENT$UPDATE_MICROAGENT_MODAL_DESCRIPTION = "MICROAGENT_MANAGEMENT$UPDATE_MICROAGENT_MODAL_DESCRIPTION",
}
diff --git a/frontend/src/i18n/translation.json b/frontend/src/i18n/translation.json
index e313c7c2a4..62fbe7a070 100644
--- a/frontend/src/i18n/translation.json
+++ b/frontend/src/i18n/translation.json
@@ -11647,6 +11647,70 @@
"de": "Das Gespräch wurde gestoppt.",
"uk": "Розмову зупинено."
},
+ "MICROAGENT_MANAGEMENT$LEARN_THIS_REPO_MODAL_TITLE": {
+ "en": "Learn this repository?",
+ "ja": "このリポジトリを学習しますか?",
+ "zh-CN": "要学习此存储库吗?",
+ "zh-TW": "要學習此存儲庫嗎?",
+ "ko-KR": "이 저장소를 학습하시겠습니까?",
+ "no": "Vil du lære dette depotet?",
+ "it": "Vuoi imparare questo repository?",
+ "pt": "Aprender este repositório?",
+ "es": "¿Aprender este repositorio?",
+ "ar": "هل تريد تعلم هذا المستودع؟",
+ "fr": "Apprendre ce dépôt ?",
+ "tr": "Bu depoyu öğrenmek ister misiniz?",
+ "de": "Dieses Repository lernen?",
+ "uk": "Вивчити цей репозиторій?"
+ },
+ "MICROAGENT_MANAGEMENT$LEARN_THIS_REPO_MODAL_DESCRIPTION": {
+ "en": "Do you want OpenHands to launch a new conversation to help you understand this repository?",
+ "ja": "OpenHandsがこのリポジトリを理解するための新しい会話を開始しますか?",
+ "zh-CN": "您想让OpenHands启动一个新对话来帮助您了解此存储库吗?",
+ "zh-TW": "您想讓OpenHands啟動一個新對話來幫助您了解此存儲庫嗎?",
+ "ko-KR": "OpenHands가 이 저장소를 이해하는 데 도움이 되는 새 대화를 시작하도록 하시겠습니까?",
+ "no": "Vil du at OpenHands skal starte en ny samtale for å hjelpe deg med å forstå dette depotet?",
+ "it": "Vuoi che OpenHands avvii una nuova conversazione per aiutarti a capire questo repository?",
+ "pt": "Você quer que o OpenHands inicie uma nova conversa para ajudá-lo a entender este repositório?",
+ "es": "¿Quieres que OpenHands inicie una nueva conversación para ayudarte a entender este repositorio?",
+ "ar": "هل تريد أن يبدأ OpenHands محادثة جديدة لمساعدتك على فهم هذا المستودع؟",
+ "fr": "Voulez-vous qu'OpenHands lance une nouvelle conversation pour vous aider à comprendre ce dépôt ?",
+ "tr": "OpenHands'in bu depoyu anlamanıza yardımcı olacak yeni bir konuşma başlatmasını ister misiniz?",
+ "de": "Möchten Sie, dass OpenHands eine neue Unterhaltung startet, um Ihnen dieses Repository zu erklären?",
+ "uk": "Бажаєте, щоб OpenHands розпочав нову розмову, щоб допомогти вам зрозуміти цей репозиторій?"
+ },
+ "MICROAGENT_MANAGEMENT$WHAT_YOU_WOULD_LIKE_TO_KNOW_ABOUT_THIS_REPO": {
+ "en": "What would you like to know about this repository?",
+ "ja": "このリポジトリについて何を知りたいですか?",
+ "zh-CN": "您想了解此存储库的哪些内容?",
+ "zh-TW": "您想了解此存儲庫的哪些內容?",
+ "ko-KR": "이 저장소에 대해 무엇을 알고 싶으신가요?",
+ "no": "Hva vil du vite om dette depotet?",
+ "it": "Cosa vorresti sapere su questo repository?",
+ "pt": "O que você gostaria de saber sobre este repositório?",
+ "es": "¿Qué te gustaría saber sobre este repositorio?",
+ "ar": "ماذا تريد أن تعرف عن هذا المستودع؟",
+ "fr": "Que souhaitez-vous savoir sur ce dépôt ?",
+ "tr": "Bu depo hakkında ne bilmek istersiniz?",
+ "de": "Was möchten Sie über dieses Repository wissen?",
+ "uk": "Що ви хотіли б дізнатися про цей репозиторій?"
+ },
+ "MICROAGENT_MANAGEMENT$DESCRIBE_WHAT_TO_KNOW_ABOUT_THIS_REPO": {
+ "en": "Describe what you would like to know about this repository.",
+ "ja": "このリポジトリについて知りたいことを説明してください。",
+ "zh-CN": "请描述您想了解此存储库的内容。",
+ "zh-TW": "請描述您想了解此存儲庫的內容。",
+ "ko-KR": "이 저장소에 대해 알고 싶은 내용을 설명하세요.",
+ "no": "Beskriv hva du vil vite om dette depotet.",
+ "it": "Descrivi cosa vorresti sapere su questo repository.",
+ "pt": "Descreva o que você gostaria de saber sobre este repositório.",
+ "es": "Describe lo que te gustaría saber sobre este repositorio.",
+ "ar": "صف ما ترغب في معرفته عن هذا المستودع.",
+ "fr": "Décrivez ce que vous souhaitez savoir sur ce dépôt.",
+ "tr": "Bu depo hakkında ne bilmek istediğinizi açıklayın.",
+ "de": "Beschreiben Sie, was Sie über dieses Repository wissen möchten.",
+ "uk": "Опишіть, що ви хотіли б дізнатися про цей репозиторій."
+ },
"MICROAGENT_MANAGEMENT$UPDATE_MICROAGENT_MODAL_DESCRIPTION": {
"en": "OpenHands will update the microagent based on your instructions.",
"ja": "OpenHandsはあなたの指示に基づいてマイクロエージェントを更新します。",
diff --git a/frontend/src/state/microagent-management-slice.tsx b/frontend/src/state/microagent-management-slice.tsx
index e6f332f3fd..1d8cf0b157 100644
--- a/frontend/src/state/microagent-management-slice.tsx
+++ b/frontend/src/state/microagent-management-slice.tsx
@@ -12,6 +12,7 @@ export const microagentManagementSlice = createSlice({
organizationRepositories: [] as GitRepository[],
repositories: [] as GitRepository[],
selectedMicroagentItem: null as IMicroagentItem | null,
+ learnThisRepoModalVisible: false,
},
reducers: {
setAddMicroagentModalVisible: (state, action) => {
@@ -35,6 +36,9 @@ export const microagentManagementSlice = createSlice({
setSelectedMicroagentItem: (state, action) => {
state.selectedMicroagentItem = action.payload;
},
+ setLearnThisRepoModalVisible: (state, action) => {
+ state.learnThisRepoModalVisible = action.payload;
+ },
},
});
@@ -46,6 +50,7 @@ export const {
setOrganizationRepositories,
setRepositories,
setSelectedMicroagentItem,
+ setLearnThisRepoModalVisible,
} = microagentManagementSlice.actions;
export default microagentManagementSlice.reducer;
diff --git a/frontend/src/types/microagent-management.tsx b/frontend/src/types/microagent-management.tsx
index 714ed0ff1a..6d7752728c 100644
--- a/frontend/src/types/microagent-management.tsx
+++ b/frontend/src/types/microagent-management.tsx
@@ -25,3 +25,8 @@ export interface MicroagentFormData {
selectedBranch: string;
microagentPath: string;
}
+
+export interface LearnThisRepoFormData {
+ query: string;
+ selectedBranch: string;
+}