Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Add git_provider and selected_branch to conversation response (#8795)

sp.wackfd5284184290
diff --git a/frontend/__tests__/components/features/conversation-panel/conversation-panel.test.tsx b/frontend/__tests__/components/features/conversation-panel/conversation-panel.test.tsx
index 79bfde6b5e..45cd05eaa9 100644
--- a/frontend/__tests__/components/features/conversation-panel/conversation-panel.test.tsx
+++ b/frontend/__tests__/components/features/conversation-panel/conversation-panel.test.tsx
@@ -7,6 +7,7 @@ import React from "react";
import { renderWithProviders } from "test-utils";
import { ConversationPanel } from "#/components/features/conversation-panel/conversation-panel";
import OpenHands from "#/api/open-hands";
+import { Conversation } from "#/api/open-hands.types";
describe("ConversationPanel", () => {
const onCloseMock = vi.fn();
@@ -37,11 +38,13 @@ describe("ConversationPanel", () => {
}));
});
- const mockConversations = [
+ const mockConversations: Conversation[] = [
{
conversation_id: "1",
title: "Conversation 1",
selected_repository: null,
+ git_provider: null,
+ selected_branch: null,
last_updated_at: "2021-10-01T12:00:00Z",
created_at: "2021-10-01T12:00:00Z",
status: "STOPPED" as const,
@@ -52,6 +55,8 @@ describe("ConversationPanel", () => {
conversation_id: "2",
title: "Conversation 2",
selected_repository: null,
+ git_provider: null,
+ selected_branch: null,
last_updated_at: "2021-10-02T12:00:00Z",
created_at: "2021-10-02T12:00:00Z",
status: "STOPPED" as const,
@@ -62,6 +67,8 @@ describe("ConversationPanel", () => {
conversation_id: "3",
title: "Conversation 3",
selected_repository: null,
+ git_provider: null,
+ selected_branch: null,
last_updated_at: "2021-10-03T12:00:00Z",
created_at: "2021-10-03T12:00:00Z",
status: "STOPPED" as const,
@@ -141,11 +148,13 @@ describe("ConversationPanel", () => {
it("should delete a conversation", async () => {
const user = userEvent.setup();
- const mockData = [
+ const mockData: Conversation[] = [
{
conversation_id: "1",
title: "Conversation 1",
selected_repository: null,
+ git_provider: null,
+ selected_branch: null,
last_updated_at: "2021-10-01T12:00:00Z",
created_at: "2021-10-01T12:00:00Z",
status: "STOPPED" as const,
@@ -156,6 +165,8 @@ describe("ConversationPanel", () => {
conversation_id: "2",
title: "Conversation 2",
selected_repository: null,
+ git_provider: null,
+ selected_branch: null,
last_updated_at: "2021-10-02T12:00:00Z",
created_at: "2021-10-02T12:00:00Z",
status: "STOPPED" as const,
@@ -166,6 +177,8 @@ describe("ConversationPanel", () => {
conversation_id: "3",
title: "Conversation 3",
selected_repository: null,
+ git_provider: null,
+ selected_branch: null,
last_updated_at: "2021-10-03T12:00:00Z",
created_at: "2021-10-03T12:00:00Z",
status: "STOPPED" as const,
diff --git a/frontend/src/api/open-hands.types.ts b/frontend/src/api/open-hands.types.ts
index 38bd52a40f..15c614b340 100644
--- a/frontend/src/api/open-hands.types.ts
+++ b/frontend/src/api/open-hands.types.ts
@@ -76,6 +76,8 @@ export interface Conversation {
conversation_id: string;
title: string;
selected_repository: string | null;
+ selected_branch: string | null;
+ git_provider: string | null;
last_updated_at: string;
created_at: string;
status: ProjectStatus;
diff --git a/frontend/src/i18n/declaration.ts b/frontend/src/i18n/declaration.ts
index 0d8a2e09e8..fcbcf04c92 100644
--- a/frontend/src/i18n/declaration.ts
+++ b/frontend/src/i18n/declaration.ts
@@ -1,5 +1,7 @@
// this file generate by script, don't modify it manually!!!
export enum I18nKey {
+ HOME$LAUNCH_FROM_SCRATCH = "HOME$LAUNCH_FROM_SCRATCH",
+ HOME$READ_THIS = "HOME$READ_THIS",
AUTH$LOGGING_BACK_IN = "AUTH$LOGGING_BACK_IN",
SECURITY$LOW_RISK = "SECURITY$LOW_RISK",
SECURITY$MEDIUM_RISK = "SECURITY$MEDIUM_RISK",
diff --git a/frontend/src/mocks/handlers.ts b/frontend/src/mocks/handlers.ts
index 489053330c..f9ff8bfe4a 100644
--- a/frontend/src/mocks/handlers.ts
+++ b/frontend/src/mocks/handlers.ts
@@ -52,6 +52,8 @@ const conversations: Conversation[] = [
conversation_id: "1",
title: "My New Project",
selected_repository: null,
+ git_provider: null,
+ selected_branch: null,
last_updated_at: new Date().toISOString(),
created_at: new Date().toISOString(),
status: "RUNNING",
@@ -62,6 +64,8 @@ const conversations: Conversation[] = [
conversation_id: "2",
title: "Repo Testing",
selected_repository: "octocat/hello-world",
+ git_provider: "github",
+ selected_branch: null,
// 2 days ago
last_updated_at: new Date(
Date.now() - 2 * 24 * 60 * 60 * 1000,
@@ -75,6 +79,8 @@ const conversations: Conversation[] = [
conversation_id: "3",
title: "Another Project",
selected_repository: "octocat/earth",
+ git_provider: null,
+ selected_branch: "main",
// 5 days ago
last_updated_at: new Date(
Date.now() - 5 * 24 * 60 * 60 * 1000,
@@ -271,6 +277,8 @@ export const handlers = [
conversation_id: (Math.random() * 100).toString(),
title: "New Conversation",
selected_repository: null,
+ git_provider: null,
+ selected_branch: null,
last_updated_at: new Date().toISOString(),
created_at: new Date().toISOString(),
status: "RUNNING",
diff --git a/openhands/server/data_models/conversation_info.py b/openhands/server/data_models/conversation_info.py
index c7f495fe88..24affd071d 100644
--- a/openhands/server/data_models/conversation_info.py
+++ b/openhands/server/data_models/conversation_info.py
@@ -1,6 +1,7 @@
from dataclasses import dataclass, field
from datetime import datetime, timezone
+from openhands.integrations.service_types import ProviderType
from openhands.storage.data_models.conversation_metadata import ConversationTrigger
from openhands.storage.data_models.conversation_status import ConversationStatus
@@ -17,6 +18,8 @@ class ConversationInfo:
last_updated_at: datetime | None = None
status: ConversationStatus = ConversationStatus.STOPPED
selected_repository: str | None = None
+ selected_branch: str | None = None
+ git_provider: ProviderType | None = None
trigger: ConversationTrigger | None = None
num_connections: int = 0
url: str | None = None
diff --git a/openhands/server/routes/manage_conversations.py b/openhands/server/routes/manage_conversations.py
index faa9c13b32..d0f62db3a3 100644
--- a/openhands/server/routes/manage_conversations.py
+++ b/openhands/server/routes/manage_conversations.py
@@ -264,6 +264,8 @@ async def _get_conversation_info(
last_updated_at=conversation.last_updated_at,
created_at=conversation.created_at,
selected_repository=conversation.selected_repository,
+ selected_branch=conversation.selected_branch,
+ git_provider=conversation.git_provider,
status=(
agent_loop_info.status if agent_loop_info else ConversationStatus.STOPPED
),
diff --git a/openhands/server/services/conversation.py b/openhands/server/services/conversation.py
index 7c079dbe7a..35601294fe 100644
--- a/openhands/server/services/conversation.py
+++ b/openhands/server/services/conversation.py
@@ -103,6 +103,7 @@ async def create_new_conversation(
user_id=user_id,
selected_repository=selected_repository,
selected_branch=selected_branch,
+ git_provider=git_provider,
)
)
diff --git a/openhands/storage/data_models/conversation_metadata.py b/openhands/storage/data_models/conversation_metadata.py
index 13ad34e333..d089811afa 100644
--- a/openhands/storage/data_models/conversation_metadata.py
+++ b/openhands/storage/data_models/conversation_metadata.py
@@ -2,6 +2,8 @@ from dataclasses import dataclass, field
from datetime import datetime, timezone
from enum import Enum
+from openhands.integrations.service_types import ProviderType
+
class ConversationTrigger(Enum):
RESOLVER = 'resolver'
@@ -17,10 +19,11 @@ class ConversationMetadata:
selected_repository: str | None
user_id: str | None = None
selected_branch: str | None = None
+ git_provider: ProviderType | None = None
title: str | None = None
last_updated_at: datetime | None = None
trigger: ConversationTrigger | None = None
- pr_number: list[int] = field(default_factory=list)
+ pr_number: list[int] = field(default_factory=list)
created_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
# Cost and token metrics
accumulated_cost: float = 0.0