Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Improve conversation panel (#6087)

sp.wackcf0f6e5e3821
diff --git a/frontend/__tests__/components/features/conversation-panel/conversation-card.test.tsx b/frontend/__tests__/components/features/conversation-panel/conversation-card.test.tsx
index e07eb25a3d..431e6a4f9f 100644
--- a/frontend/__tests__/components/features/conversation-panel/conversation-card.test.tsx
+++ b/frontend/__tests__/components/features/conversation-panel/conversation-card.test.tsx
@@ -3,6 +3,7 @@ import { afterEach, describe, expect, it, test, vi } from "vitest";
import userEvent from "@testing-library/user-event";
import { formatTimeDelta } from "#/utils/format-time-delta";
import { ConversationCard } from "#/components/features/conversation-panel/conversation-card";
+import { clickOnEditButton } from "./utils";
describe("ConversationCard", () => {
const onClick = vi.fn();
@@ -144,7 +145,9 @@ describe("ConversationCard", () => {
/>,
);
- const selectedRepository = screen.getByTestId("conversation-card-selected-repository");
+ const selectedRepository = screen.getByTestId(
+ "conversation-card-selected-repository",
+ );
await user.click(selectedRepository);
expect(onClick).not.toHaveBeenCalled();
@@ -164,6 +167,14 @@ describe("ConversationCard", () => {
);
const title = screen.getByTestId("conversation-card-title");
+ expect(title).toBeDisabled();
+
+ await clickOnEditButton(user);
+
+ expect(title).toBeEnabled();
+ expect(screen.queryByTestId("context-menu")).not.toBeInTheDocument();
+ // expect to be focused
+ expect(document.activeElement).toBe(title);
await user.clear(title);
await user.type(title, "New Conversation Name ");
@@ -171,6 +182,7 @@ describe("ConversationCard", () => {
expect(onChangeTitle).toHaveBeenCalledWith("New Conversation Name");
expect(title).toHaveValue("New Conversation Name");
+ expect(title).toBeDisabled();
});
it("should reset title and not call onChangeTitle when the title is empty", async () => {
@@ -186,6 +198,8 @@ describe("ConversationCard", () => {
/>,
);
+ await clickOnEditButton(user);
+
const title = screen.getByTestId("conversation-card-title");
await user.clear(title);
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 262b2bd28e..da22450c99 100644
--- a/frontend/__tests__/components/features/conversation-panel/conversation-panel.test.tsx
+++ b/frontend/__tests__/components/features/conversation-panel/conversation-panel.test.tsx
@@ -9,6 +9,7 @@ import userEvent from "@testing-library/user-event";
import { ConversationPanel } from "#/components/features/conversation-panel/conversation-panel";
import OpenHands from "#/api/open-hands";
import { AuthProvider } from "#/context/auth-context";
+import { clickOnEditButton } from "./utils";
describe("ConversationPanel", () => {
const onCloseMock = vi.fn();
@@ -52,6 +53,8 @@ describe("ConversationPanel", () => {
renderConversationPanel();
const cards = await screen.findAllByTestId("conversation-card");
+ // NOTE that we filter out conversations that don't have a created_at property
+ // (mock data has 4 conversations, but only 3 have a created_at property)
expect(cards).toHaveLength(3);
});
@@ -169,6 +172,8 @@ describe("ConversationPanel", () => {
const cards = await screen.findAllByTestId("conversation-card");
const title = within(cards[0]).getByTestId("conversation-card-title");
+ await clickOnEditButton(user);
+
await user.clear(title);
await user.type(title, "Conversation 1 Renamed");
await user.tab();
@@ -196,6 +201,8 @@ describe("ConversationPanel", () => {
// Ensure the conversation is not renamed
expect(updateUserConversationSpy).not.toHaveBeenCalled();
+ await clickOnEditButton(user);
+
await user.type(title, "Conversation 1");
await user.click(title);
await user.tab();
@@ -217,51 +224,4 @@ describe("ConversationPanel", () => {
expect(onCloseMock).toHaveBeenCalledOnce();
});
-
- describe("New Conversation Button", () => {
- it("should display a confirmation modal when clicking", async () => {
- const user = userEvent.setup();
- renderConversationPanel();
-
- expect(
- screen.queryByTestId("confirm-new-conversation-modal"),
- ).not.toBeInTheDocument();
-
- const newProjectButton = screen.getByTestId("new-conversation-button");
- await user.click(newProjectButton);
-
- const modal = screen.getByTestId("confirm-new-conversation-modal");
- expect(modal).toBeInTheDocument();
- });
-
- it("should call endSession and close panel after confirming", async () => {
- const user = userEvent.setup();
- renderConversationPanel();
-
- const newProjectButton = screen.getByTestId("new-conversation-button");
- await user.click(newProjectButton);
-
- const confirmButton = screen.getByText("Confirm");
- await user.click(confirmButton);
-
- expect(endSessionMock).toHaveBeenCalledOnce();
- expect(onCloseMock).toHaveBeenCalledOnce();
- });
-
- it("should close the modal when cancelling", async () => {
- const user = userEvent.setup();
- renderConversationPanel();
-
- const newProjectButton = screen.getByTestId("new-conversation-button");
- await user.click(newProjectButton);
-
- const cancelButton = screen.getByText("Cancel");
- await user.click(cancelButton);
-
- expect(endSessionMock).not.toHaveBeenCalled();
- expect(
- screen.queryByTestId("confirm-new-conversation-modal"),
- ).not.toBeInTheDocument();
- });
- });
});
diff --git a/frontend/__tests__/components/features/conversation-panel/utils.ts b/frontend/__tests__/components/features/conversation-panel/utils.ts
new file mode 100644
index 0000000000..5963dc0a08
--- /dev/null
+++ b/frontend/__tests__/components/features/conversation-panel/utils.ts
@@ -0,0 +1,12 @@
+import { screen, within } from "@testing-library/react";
+import { UserEvent } from "@testing-library/user-event";
+
+export const clickOnEditButton = async (user: UserEvent) => {
+ const ellipsisButton = screen.getByTestId("ellipsis-button");
+ await user.click(ellipsisButton);
+
+ const menu = screen.getByTestId("context-menu");
+ const editButton = within(menu).getByTestId("edit-button");
+
+ await user.click(editButton);
+};
diff --git a/frontend/__tests__/routes/_oh.app.test.tsx b/frontend/__tests__/routes/_oh.app.test.tsx
index e034c74765..4fc96b25d3 100644
--- a/frontend/__tests__/routes/_oh.app.test.tsx
+++ b/frontend/__tests__/routes/_oh.app.test.tsx
@@ -60,6 +60,7 @@ describe("App", () => {
getConversationSpy.mockResolvedValue({
conversation_id: "9999",
last_updated_at: "",
+ created_at: "",
title: "",
selected_repository: "",
status: "STOPPED",
diff --git a/frontend/src/api/open-hands.types.ts b/frontend/src/api/open-hands.types.ts
index 263bfb7811..169de47afb 100644
--- a/frontend/src/api/open-hands.types.ts
+++ b/frontend/src/api/open-hands.types.ts
@@ -65,6 +65,7 @@ export interface Conversation {
title: string;
selected_repository: string | null;
last_updated_at: string;
+ created_at: string;
status: ProjectStatus;
}
diff --git a/frontend/src/components/features/conversation-panel/conversation-card-context-menu.tsx b/frontend/src/components/features/conversation-panel/conversation-card-context-menu.tsx
index d2b290e000..d22c74cbb1 100644
--- a/frontend/src/components/features/conversation-panel/conversation-card-context-menu.tsx
+++ b/frontend/src/components/features/conversation-panel/conversation-card-context-menu.tsx
@@ -5,11 +5,13 @@ import { ContextMenuListItem } from "../context-menu/context-menu-list-item";
interface ConversationCardContextMenuProps {
onClose: () => void;
onDelete: (event: React.MouseEvent<HTMLButtonElement>) => void;
+ onEdit: (event: React.MouseEvent<HTMLButtonElement>) => void;
}
export function ConversationCardContextMenu({
onClose,
onDelete,
+ onEdit,
}: ConversationCardContextMenuProps) {
const ref = useClickOutsideElement<HTMLUListElement>(onClose);
@@ -22,6 +24,9 @@ export function ConversationCardContextMenu({
<ContextMenuListItem testId="delete-button" onClick={onDelete}>
Delete
</ContextMenuListItem>
+ <ContextMenuListItem testId="edit-button" onClick={onEdit}>
+ Edit Title
+ </ContextMenuListItem>
</ContextMenu>
);
}
diff --git a/frontend/src/components/features/conversation-panel/conversation-card.tsx b/frontend/src/components/features/conversation-panel/conversation-card.tsx
index 5f44f5b527..ba53740f80 100644
--- a/frontend/src/components/features/conversation-panel/conversation-card.tsx
+++ b/frontend/src/components/features/conversation-panel/conversation-card.tsx
@@ -28,6 +28,7 @@ export function ConversationCard({
status = "STOPPED",
}: ConversationCardProps) {
const [contextMenuVisible, setContextMenuVisible] = React.useState(false);
+ const [titleMode, setTitleMode] = React.useState<"view" | "edit">("view");
const inputRef = React.useRef<HTMLInputElement>(null);
const handleBlur = () => {
@@ -39,6 +40,8 @@ export function ConversationCard({
// reset the value if it's empty
inputRef.current!.value = title;
}
+
+ setTitleMode("view");
};
const handleKeyUp = (event: React.KeyboardEvent<HTMLInputElement>) => {
@@ -56,6 +59,18 @@ export function ConversationCard({
onDelete();
};
+ const handleEdit = (event: React.MouseEvent<HTMLButtonElement>) => {
+ event.stopPropagation();
+ setTitleMode("edit");
+ setContextMenuVisible(false);
+ };
+
+ React.useEffect(() => {
+ if (titleMode === "edit") {
+ inputRef.current?.focus();
+ }
+ }, [titleMode]);
+
return (
<div
data-testid="conversation-card"
@@ -64,8 +79,9 @@ export function ConversationCard({
>
<div className="flex items-center justify-between space-x-1">
<input
- ref={inputRef}
data-testid="conversation-card-title"
+ ref={inputRef}
+ disabled={titleMode === "view"}
onClick={handleInputClick}
onBlur={handleBlur}
onKeyUp={handleKeyUp}
@@ -88,6 +104,7 @@ export function ConversationCard({
<ConversationCardContextMenu
onClose={() => setContextMenuVisible(false)}
onDelete={handleDelete}
+ onEdit={handleEdit}
/>
)}
{selectedRepository && (
diff --git a/frontend/src/components/features/conversation-panel/conversation-panel-wrapper.tsx b/frontend/src/components/features/conversation-panel/conversation-panel-wrapper.tsx
new file mode 100644
index 0000000000..0e11e6a325
--- /dev/null
+++ b/frontend/src/components/features/conversation-panel/conversation-panel-wrapper.tsx
@@ -0,0 +1,22 @@
+import ReactDOM from "react-dom";
+
+interface ConversationPanelWrapperProps {
+ isOpen: boolean;
+}
+
+export function ConversationPanelWrapper({
+ isOpen,
+ children,
+}: React.PropsWithChildren<ConversationPanelWrapperProps>) {
+ if (!isOpen) return null;
+
+ const portalTarget = document.getElementById("root-outlet");
+ if (!portalTarget) return null;
+
+ return ReactDOM.createPortal(
+ <div className="absolute h-full w-full left-0 top-0 z-20 bg-black/80 rounded-xl">
+ {children}
+ </div>,
+ portalTarget,
+ );
+}
diff --git a/frontend/src/components/features/conversation-panel/conversation-panel.tsx b/frontend/src/components/features/conversation-panel/conversation-panel.tsx
index fd22cb7439..3510388ca1 100644
--- a/frontend/src/components/features/conversation-panel/conversation-panel.tsx
+++ b/frontend/src/components/features/conversation-panel/conversation-panel.tsx
@@ -1,14 +1,14 @@
import React from "react";
-import { useLocation, useNavigate, useParams } from "react-router";
+import { useNavigate, useParams } from "react-router";
import { ConversationCard } from "./conversation-card";
import { useUserConversations } from "#/hooks/query/use-user-conversations";
import { useDeleteConversation } from "#/hooks/mutation/use-delete-conversation";
import { ConfirmDeleteModal } from "./confirm-delete-modal";
-import { NewConversationButton } from "./new-conversation-button";
import { LoadingSpinner } from "#/components/shared/loading-spinner";
import { useUpdateConversation } from "#/hooks/mutation/use-update-conversation";
import { useEndSession } from "#/hooks/use-end-session";
import { ExitConversationModal } from "./exit-conversation-modal";
+import { useClickOutsideElement } from "#/hooks/use-click-outside-element";
interface ConversationPanelProps {
onClose: () => void;
@@ -17,9 +17,8 @@ interface ConversationPanelProps {
export function ConversationPanel({ onClose }: ConversationPanelProps) {
const { conversationId: cid } = useParams();
const navigate = useNavigate();
- const location = useLocation();
-
const endSession = useEndSession();
+ const ref = useClickOutsideElement<HTMLDivElement>(onClose);
const [confirmDeleteModalVisible, setConfirmDeleteModalVisible] =
React.useState(false);
@@ -71,15 +70,11 @@ export function ConversationPanel({ onClose }: ConversationPanelProps) {
return (
<div
+ ref={ref}
data-testid="conversation-panel"
className="w-[350px] h-full border border-neutral-700 bg-neutral-800 rounded-xl overflow-y-auto"
>
<div className="pt-4 px-4 flex items-center justify-between">
- {location.pathname.startsWith("/conversation") && (
- <NewConversationButton
- onClick={() => setConfirmExitConversationModalVisible(true)}
- />
- )}
{isFetching && <LoadingSpinner size="small" />}
</div>
{error && (
diff --git a/frontend/src/components/features/sidebar/sidebar.tsx b/frontend/src/components/features/sidebar/sidebar.tsx
index 1123756504..6b7db21584 100644
--- a/frontend/src/components/features/sidebar/sidebar.tsx
+++ b/frontend/src/components/features/sidebar/sidebar.tsx
@@ -1,6 +1,6 @@
import React from "react";
-import { useLocation } from "react-router";
import { FaListUl } from "react-icons/fa";
+import { useDispatch } from "react-redux";
import { useAuth } from "#/context/auth-context";
import { useGitHubUser } from "#/hooks/query/use-github-user";
import { useIsAuthed } from "#/hooks/query/use-is-authed";
@@ -11,15 +11,20 @@ import { ExitProjectButton } from "#/components/shared/buttons/exit-project-butt
import { SettingsButton } from "#/components/shared/buttons/settings-button";
import { LoadingSpinner } from "#/components/shared/loading-spinner";
import { AccountSettingsModal } from "#/components/shared/modals/account-settings/account-settings-modal";
-import { ExitProjectConfirmationModal } from "#/components/shared/modals/exit-project-confirmation-modal";
import { SettingsModal } from "#/components/shared/modals/settings/settings-modal";
import { useSettingsUpToDate } from "#/context/settings-up-to-date-context";
import { useSettings } from "#/hooks/query/use-settings";
import { ConversationPanel } from "../conversation-panel/conversation-panel";
import { MULTI_CONVERSATION_UI } from "#/utils/feature-flags";
+import { useEndSession } from "#/hooks/use-end-session";
+import { setCurrentAgentState } from "#/state/agent-slice";
+import { AgentState } from "#/types/agent-state";
+import { TooltipButton } from "#/components/shared/buttons/tooltip-button";
+import { ConversationPanelWrapper } from "../conversation-panel/conversation-panel-wrapper";
export function Sidebar() {
- const location = useLocation();
+ const dispatch = useDispatch();
+ const endSession = useEndSession();
const user = useGitHubUser();
const { data: isAuthed } = useIsAuthed();
const { logout } = useAuth();
@@ -29,20 +34,9 @@ export function Sidebar() {
const [accountSettingsModalOpen, setAccountSettingsModalOpen] =
React.useState(false);
const [settingsModalIsOpen, setSettingsModalIsOpen] = React.useState(false);
- const [startNewProjectModalIsOpen, setStartNewProjectModalIsOpen] =
- React.useState(false);
+
const [conversationPanelIsOpen, setConversationPanelIsOpen] =
React.useState(false);
- const conversationPanelRef = React.useRef<HTMLDivElement | null>(null);
-
- const handleClick = (event: MouseEvent) => {
- const conversationPanel = conversationPanelRef.current;
- if (conversationPanelIsOpen && conversationPanel) {
- if (!conversationPanel.contains(event.target as Node)) {
- setConversationPanelIsOpen(false);
- }
- }
- };
React.useEffect(() => {
// If the github token is invalid, open the account settings modal again
@@ -51,12 +45,10 @@ export function Sidebar() {
}
}, [user.isError]);
- React.useEffect(() => {
- document.addEventListener("click", handleClick);
- return () => {
- document.removeEventListener("click", handleClick);
- };
- }, [conversationPanelIsOpen]);
+ const handleEndSession = () => {
+ dispatch(setCurrentAgentState(AgentState.LOADING));
+ endSession();
+ };
const handleAccountSettingsModalClose = () => {
// If the user closes the modal without connecting to GitHub,
@@ -66,22 +58,30 @@ export function Sidebar() {
setAccountSettingsModalOpen(false);
};
- const handleClickLogo = () => {
- if (location.pathname.startsWith("/conversations/"))
- setStartNewProjectModalIsOpen(true);
- };
-
const showSettingsModal =
isAuthed && (!settingsAreUpToDate || settingsModalIsOpen);
return (
<>
- <aside className="h-[40px] md:h-auto px-1 flex flex-row md:flex-col gap-1 relative">
+ <aside className="h-[40px] md:h-auto px-1 flex flex-row md:flex-col gap-1">
<nav className="flex flex-row md:flex-col items-center gap-[18px]">
- <div className="w-[34px] h-[34px] flex items-center justify-center">
- <AllHandsLogoButton onClick={handleClickLogo} />
+ <div className="w-[34px] h-[34px] flex items-center justify-center mb-7">
+ <AllHandsLogoButton onClick={handleEndSession} />
</div>
{user.isLoading && <LoadingSpinner size="small" />}
+ <ExitProjectButton onClick={handleEndSession} />
+ {MULTI_CONVERSATION_UI && (
+ <TooltipButton
+ data-testid="toggle-conversation-panel"
+ tooltip="Conversations"
+ ariaLabel="Conversations"
+ onClick={() => setConversationPanelIsOpen((prev) => !prev)}
+ >
+ <FaListUl size={22} />
+ </TooltipButton>
+ )}
+ <DocsButton />
+ <SettingsButton onClick={() => setSettingsModalIsOpen(true)} />
{!user.isLoading && (
<UserActions
user={
@@ -91,35 +91,14 @@ export function Sidebar() {
onClickAccountSettings={() => setAccountSettingsModalOpen(true)}
/>
)}
- <SettingsButton onClick={() => setSettingsModalIsOpen(true)} />
- {MULTI_CONVERSATION_UI && (
- <button
- data-testid="toggle-conversation-panel"
- type="button"
- onClick={() => setConversationPanelIsOpen((prev) => !prev)}
- >
- <FaListUl
- width={28}
- height={28}
- fill={conversationPanelIsOpen ? "#FFE165" : "#FFFFFF"}
- />
- </button>
- )}
- <DocsButton />
- <ExitProjectButton
- onClick={() => setStartNewProjectModalIsOpen(true)}
- />
</nav>
{conversationPanelIsOpen && (
- <div
- ref={conversationPanelRef}
- className="absolute h-full left-[calc(100%+12px)] top-0 z-20" // 12px padding (sidebar parent)
- >
+ <ConversationPanelWrapper isOpen={conversationPanelIsOpen}>
<ConversationPanel
onClose={() => setConversationPanelIsOpen(false)}
/>
- </div>
+ </ConversationPanelWrapper>
)}
</aside>
@@ -133,11 +112,6 @@ export function Sidebar() {
onClose={() => setSettingsModalIsOpen(false)}
/>
))}
- {startNewProjectModalIsOpen && (
- <ExitProjectConfirmationModal
- onClose={() => setStartNewProjectModalIsOpen(false)}
- />
- )}
</>
);
}
diff --git a/frontend/src/components/features/sidebar/user-avatar.tsx b/frontend/src/components/features/sidebar/user-avatar.tsx
index 12a18847d0..857f410e66 100644
--- a/frontend/src/components/features/sidebar/user-avatar.tsx
+++ b/frontend/src/components/features/sidebar/user-avatar.tsx
@@ -1,8 +1,8 @@
-import { Tooltip } from "@nextui-org/react";
import { LoadingSpinner } from "#/components/shared/loading-spinner";
import DefaultUserAvatar from "#/icons/default-user.svg?react";
import { cn } from "#/utils/utils";
import { Avatar } from "./avatar";
+import { TooltipButton } from "#/components/shared/buttons/tooltip-button";
interface UserAvatarProps {
onClick: () => void;
@@ -11,10 +11,11 @@ interface UserAvatarProps {
}
export function UserAvatar({ onClick, avatarUrl, isLoading }: UserAvatarProps) {
- const buttonContent = (
- <button
- data-testid="user-avatar"
- type="button"
+ return (
+ <TooltipButton
+ testId="user-avatar"
+ tooltip="Account settings"
+ ariaLabel="Account settings"
onClick={onClick}
className={cn(
"w-8 h-8 rounded-full flex items-center justify-center border-2 border-gray-200",
@@ -30,12 +31,6 @@ export function UserAvatar({ onClick, avatarUrl, isLoading }: UserAvatarProps) {
/>
)}
{isLoading && <LoadingSpinner size="small" />}
- </button>
- );
-
- return (
- <Tooltip content="Account settings" closeDelay={100}>
- {buttonContent}
- </Tooltip>
+ </TooltipButton>
);
}
diff --git a/frontend/src/components/shared/buttons/all-hands-logo-button.tsx b/frontend/src/components/shared/buttons/all-hands-logo-button.tsx
index e068f152af..f8af9ac476 100644
--- a/frontend/src/components/shared/buttons/all-hands-logo-button.tsx
+++ b/frontend/src/components/shared/buttons/all-hands-logo-button.tsx
@@ -12,7 +12,7 @@ export function AllHandsLogoButton({ onClick }: AllHandsLogoButtonProps) {
ariaLabel="All Hands Logo"
onClick={onClick}
>
- <AllHandsLogo width={34} height={23} />
+ <AllHandsLogo width={44} height={30} />
</TooltipButton>
);
}
diff --git a/frontend/src/components/shared/buttons/exit-project-button.tsx b/frontend/src/components/shared/buttons/exit-project-button.tsx
index 206d1660e2..b0c4bbd4df 100644
--- a/frontend/src/components/shared/buttons/exit-project-button.tsx
+++ b/frontend/src/components/shared/buttons/exit-project-button.tsx
@@ -13,7 +13,7 @@ export function ExitProjectButton({ onClick }: ExitProjectButtonProps) {
onClick={onClick}
testId="new-project-button"
>
- <NewProjectIcon width={28} height={28} />
+ <NewProjectIcon width={26} height={26} />
</TooltipButton>
);
}
diff --git a/frontend/src/components/shared/buttons/settings-button.tsx b/frontend/src/components/shared/buttons/settings-button.tsx
index 59ed58ed27..8abae964cd 100644
--- a/frontend/src/components/shared/buttons/settings-button.tsx
+++ b/frontend/src/components/shared/buttons/settings-button.tsx
@@ -1,4 +1,4 @@
-import CogTooth from "#/assets/cog-tooth";
+import { FaCog } from "react-icons/fa";
import { TooltipButton } from "./tooltip-button";
interface SettingsButtonProps {
@@ -13,7 +13,7 @@ export function SettingsButton({ onClick }: SettingsButtonProps) {
ariaLabel="Settings"
onClick={onClick}
>
- <CogTooth />
+ <FaCog size={24} />
</TooltipButton>
);
}
diff --git a/frontend/src/components/shared/buttons/tooltip-button.tsx b/frontend/src/components/shared/buttons/tooltip-button.tsx
index 00ddddbc5c..efe053c39e 100644
--- a/frontend/src/components/shared/buttons/tooltip-button.tsx
+++ b/frontend/src/components/shared/buttons/tooltip-button.tsx
@@ -1,5 +1,6 @@
import { Tooltip } from "@nextui-org/react";
-import { ReactNode } from "react";
+import React, { ReactNode } from "react";
+import { cn } from "#/utils/utils";
interface TooltipButtonProps {
children: ReactNode;
@@ -8,6 +9,7 @@ interface TooltipButtonProps {
href?: string;
ariaLabel: string;
testId?: string;
+ className?: React.HTMLAttributes<HTMLButtonElement>["className"];
}
export function TooltipButton({
@@ -17,6 +19,7 @@ export function TooltipButton({
href,
ariaLabel,
testId,
+ className,
}: TooltipButtonProps) {
const buttonContent = (
<button
@@ -24,7 +27,7 @@ export function TooltipButton({
aria-label={ariaLabel}
data-testid={testId}
onClick={onClick}
- className="w-8 h-8 rounded-full hover:opacity-80 flex items-center justify-center"
+ className={cn("hover:opacity-80", className)}
>
{children}
</button>
@@ -35,7 +38,7 @@ export function TooltipButton({
href={href}
target="_blank"
rel="noreferrer noopener"
- className="w-8 h-8 rounded-full hover:opacity-80 flex items-center justify-center"
+ className={cn("hover:opacity-80", className)}
aria-label={ariaLabel}
>
{children}
@@ -45,7 +48,7 @@ export function TooltipButton({
);
return (
- <Tooltip content={tooltip} closeDelay={100}>
+ <Tooltip content={tooltip} closeDelay={100} placement="right">
{content}
</Tooltip>
);
diff --git a/frontend/src/mocks/handlers.ts b/frontend/src/mocks/handlers.ts
index 37894e2da3..f24c4a55dd 100644
--- a/frontend/src/mocks/handlers.ts
+++ b/frontend/src/mocks/handlers.ts
@@ -1,5 +1,9 @@
import { delay, http, HttpResponse } from "msw";
-import { GetConfigResponse, Conversation } from "#/api/open-hands.types";
+import {
+ GetConfigResponse,
+ Conversation,
+ ResultSet,
+} from "#/api/open-hands.types";
import { DEFAULT_SETTINGS } from "#/services/settings";
const userPreferences = {
@@ -20,6 +24,7 @@ const conversations: Conversation[] = [
title: "My New Project",
selected_repository: null,
last_updated_at: new Date().toISOString(),
+ created_at: new Date().toISOString(),
status: "RUNNING",
},
{
@@ -30,6 +35,7 @@ const conversations: Conversation[] = [
last_updated_at: new Date(
Date.now() - 2 * 24 * 60 * 60 * 1000,
).toISOString(),
+ created_at: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000).toISOString(),
status: "STOPPED",
},
{
@@ -40,6 +46,7 @@ const conversations: Conversation[] = [
last_updated_at: new Date(
Date.now() - 5 * 24 * 60 * 60 * 1000,
).toISOString(),
+ created_at: new Date(Date.now() - 5 * 24 * 60 * 60 * 1000).toISOString(),
status: "STOPPED",
},
];
@@ -186,12 +193,15 @@ export const handlers = [
http.get("/api/options/config", () => HttpResponse.json({ APP_MODE: "oss" })),
- http.get("/api/conversations?limit=9", async () =>
- HttpResponse.json({
- results: Array.from(CONVERSATIONS.values()),
+ http.get("/api/conversations", async () => {
+ const values = Array.from(CONVERSATIONS.values());
+ const results: ResultSet<Conversation> = {
+ results: values,
next_page_id: null,
- }),
- ),
+ };
+
+ return HttpResponse.json(results, { status: 200 });
+ }),
http.delete("/api/conversations/:conversationId", async ({ params }) => {
const { conversationId } = params;
@@ -234,6 +244,7 @@ export const handlers = [
title: "New Conversation",
selected_repository: null,
last_updated_at: new Date().toISOString(),
+ created_at: new Date().toISOString(),
status: "RUNNING",
};
diff --git a/frontend/src/routes/_oh._index/route.tsx b/frontend/src/routes/_oh._index/route.tsx
index cd24784038..463922d215 100644
--- a/frontend/src/routes/_oh._index/route.tsx
+++ b/frontend/src/routes/_oh._index/route.tsx
@@ -29,10 +29,7 @@ function Home() {
const latestConversation = localStorage.getItem("latest_conversation_id");
return (
- <div
- data-testid="root-index"
- className="bg-root-secondary h-full rounded-xl flex flex-col items-center justify-center relative overflow-y-auto px-2"
- >
+ <div className="bg-root-secondary h-full rounded-xl flex flex-col items-center justify-center relative overflow-y-auto px-2">
<HeroHeading />
<div className="flex flex-col gap-8 w-full md:w-[600px] items-center">
<div className="flex flex-col gap-2 w-full">
diff --git a/frontend/src/routes/_oh/route.tsx b/frontend/src/routes/_oh/route.tsx
index 47e5ffe52e..16492b5333 100644
--- a/frontend/src/routes/_oh/route.tsx
+++ b/frontend/src/routes/_oh/route.tsx
@@ -78,7 +78,10 @@ export default function MainApp() {
>
<Sidebar />
- <div className="h-[calc(100%-50px)] md:h-full w-full relative">
+ <div
+ id="root-outlet"
+ className="h-[calc(100%-50px)] md:h-full w-full relative"
+ >
<Outlet />
</div>
diff --git a/openhands/server/routes/manage_conversations.py b/openhands/server/routes/manage_conversations.py
index 6d23ae0169..178fbefe66 100644
--- a/openhands/server/routes/manage_conversations.py
+++ b/openhands/server/routes/manage_conversations.py
@@ -66,10 +66,15 @@ async def new_conversation(request: Request, data: InitSessionRequest):
conversation_id = uuid.uuid4().hex
logger.info(f'New conversation ID: {conversation_id}')
+ conversation_title = (
+ data.selected_repository or f'Conversation {conversation_id[:5]}'
+ )
+
logger.info(f'Saving metadata for conversation {conversation_id}')
await conversation_store.save_metadata(
ConversationMetadata(
conversation_id=conversation_id,
+ title=conversation_title,
github_user_id=get_user_id(request),
selected_repository=data.selected_repository,
)
@@ -104,6 +109,7 @@ async def search_conversations(
conversation_ids = set(
conversation.conversation_id
for conversation in conversation_metadata_result_set.results
+ if hasattr(conversation, 'created_at')
)
running_conversations = await session_manager.get_agent_loop_running(
set(conversation_ids)