Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: hide No conversations found when sidebar is collapsed (#295)

Hiep Le93e6ef911460
diff --git a/__tests__/components/features/conversation-panel/conversation-panel.test.tsx b/__tests__/components/features/conversation-panel/conversation-panel.test.tsx
index 0b39943e27..eeaecd30b7 100644
--- a/__tests__/components/features/conversation-panel/conversation-panel.test.tsx
+++ b/__tests__/components/features/conversation-panel/conversation-panel.test.tsx
@@ -1,4 +1,9 @@
-import { screen, waitFor, within } from "@testing-library/react";
+import {
+ screen,
+ waitFor,
+ waitForElementToBeRemoved,
+ within,
+} from "@testing-library/react";
import {
afterEach,
beforeAll,
@@ -135,6 +140,39 @@ describe("ConversationPanel", () => {
expect(emptyState).toBeInTheDocument();
});
+ it("should not display the empty state when there are no conversations and the panel is compact", async () => {
+ const searchConversationsSpy = vi.spyOn(
+ AgentServerConversationService,
+ "searchConversations",
+ );
+ searchConversationsSpy.mockResolvedValue({
+ items: [],
+ next_page_id: null,
+ });
+
+ const CompactRouterStub = createRoutesStub([
+ {
+ Component: () => <ConversationPanel compact />,
+ path: "/",
+ },
+ {
+ Component: () => null,
+ path: "/conversations/:conversationId",
+ },
+ ]);
+
+ renderWithProviders(<CompactRouterStub />);
+
+ const skeletons = await screen.findAllByTestId(
+ "conversation-card-skeleton",
+ );
+ await waitForElementToBeRemoved(skeletons);
+
+ expect(
+ screen.queryByText("CONVERSATION$NO_CONVERSATIONS"),
+ ).not.toBeInTheDocument();
+ });
+
it("should handle an error when fetching conversations", async () => {
const searchConversationsSpy = vi.spyOn(
AgentServerConversationService,
diff --git a/src/components/features/conversation-panel/conversation-panel.tsx b/src/components/features/conversation-panel/conversation-panel.tsx
index 8d848a9b5e..5e53bc5f0f 100644
--- a/src/components/features/conversation-panel/conversation-panel.tsx
+++ b/src/components/features/conversation-panel/conversation-panel.tsx
@@ -301,7 +301,7 @@ export function ConversationPanel({
</div>
)}
- {showEmptyState && (
+ {!compact && showEmptyState && (
<div className="flex flex-col items-center justify-center h-full">
<p className="text-neutral-400">
{t(I18nKey.CONVERSATION$NO_CONVERSATIONS)}