From 8b7112abe8bd0da7ccecb277b5f7a32dceae6f99 Mon Sep 17 00:00:00 2001
From: Hiep Le <69354317+hieptl@users.noreply.github.com>
Date: Mon, 16 Feb 2026 18:35:20 +0700
Subject: [PATCH] refactor(frontend): hide planning preview component when plan
content is empty (#12879)
---
.../features/chat/plan-preview.test.tsx | 18 ++++++++++--------
.../components/features/chat/plan-preview.tsx | 2 +-
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/frontend/__tests__/components/features/chat/plan-preview.test.tsx b/frontend/__tests__/components/features/chat/plan-preview.test.tsx
index 00d0466919..3e53ae7b09 100644
--- a/frontend/__tests__/components/features/chat/plan-preview.test.tsx
+++ b/frontend/__tests__/components/features/chat/plan-preview.test.tsx
@@ -92,19 +92,21 @@ describe("PlanPreview", () => {
});
it("should render nothing when planContent is null", () => {
- renderPlanPreview();
+ // Arrange & Act
+ const { container } = renderPlanPreview();
- const contentDiv = screen.getByTestId("plan-preview-content");
- expect(contentDiv).toBeInTheDocument();
- expect(contentDiv.textContent?.trim() || "").toBe("");
+ // Assert
+ expect(container.firstChild).toBeNull();
});
it("should render nothing when planContent is undefined", () => {
- renderPlanPreview();
+ // Arrange & Act
+ const { container } = renderPlanPreview(
+ ,
+ );
- const contentDiv = screen.getByTestId("plan-preview-content");
- expect(contentDiv).toBeInTheDocument();
- expect(contentDiv.textContent?.trim() || "").toBe("");
+ // Assert
+ expect(container.firstChild).toBeNull();
});
it("should render markdown content when planContent is provided", () => {
diff --git a/frontend/src/components/features/chat/plan-preview.tsx b/frontend/src/components/features/chat/plan-preview.tsx
index 44cbedace3..9a69d8ad64 100644
--- a/frontend/src/components/features/chat/plan-preview.tsx
+++ b/frontend/src/components/features/chat/plan-preview.tsx
@@ -65,7 +65,7 @@ export function PlanPreview({
return `${planContent.slice(0, MAX_CONTENT_LENGTH)}...`;
}, [planContent]);
- if (!shouldUsePlanningAgent) {
+ if (!shouldUsePlanningAgent || !planContent) {
return null;
}