Unverified 提交 e71ebbe7 authored 作者: Nour Zakhma's avatar Nour Zakhma 提交者: GitHub

Fixing non functional view plan button (#3073)

The "View Plan" button in the plan card was non-functional when: The preview panel was manually collapsed by the user Starting a new app session (preview panel is closed initially) The button only changed the preview mode to "plan" but didn't open the panel, making it invisible to users. Root Cause [isPreviewOpenAtom]was set to false when starting the app and only set back to true after streaming completes. The "View Plan" button only called [setPreviewMode("plan")] but didn't call [setIsPreviewOpen(true)], leaving the panel closed. Solution Added [setIsPreviewOpen(true)] to the "View Plan" button's onClick handler to ensure the preview panel opens when users click the button. Testing The fix can be verified by: Generating a plan in the chat Collapsing the preview panel (or having it closed on new app start) Clicking the "View Plan" button Confirm the panel opens and shows the plan view <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/3073" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> --------- Co-authored-by: 's avatarMohamed Aziz Mejri <mjrmohamedaziz@gmail.com>
上级 be878a5b
...@@ -201,3 +201,38 @@ testSkipIfWindows( ...@@ -201,3 +201,38 @@ testSkipIfWindows(
await po.snapshotServerDump("last-message"); await po.snapshotServerDump("last-message");
}, },
); );
testSkipIfWindows(
"plan mode - view plan button opens preview panel when collapsed",
async ({ po }) => {
// Set up app
await po.setUpDyadPro({ localAgent: true });
await po.importApp("minimal");
// Switch to plan mode
await po.chatActions.selectChatMode("plan");
// Generate a plan by sending a prompt that triggers plan generation
await po.sendPrompt("tc=local-agent/accept-plan");
// Wait for the "View Plan" button to appear
const viewPlanButton = po.page.getByRole("button", { name: "View Plan" });
await expect(viewPlanButton).toBeVisible({ timeout: Timeout.MEDIUM });
// Verify plan content is visible
const planContent = po.previewPanel.getPlanContent();
await expect(planContent).toBeVisible({ timeout: Timeout.MEDIUM });
// Collapse the preview panel
await po.previewPanel.clickTogglePreviewPanel();
// Verify the preview panel is actually closed (plan content should be hidden)
await expect(planContent).not.toBeVisible();
// Click the "View Plan" button
await viewPlanButton.click();
// Assert that the plan content is visible (button opened the panel and switched to plan mode)
await expect(planContent).toBeVisible({ timeout: Timeout.MEDIUM });
},
);
...@@ -2,6 +2,7 @@ import React, { useState } from "react"; ...@@ -2,6 +2,7 @@ import React, { useState } from "react";
import { FileText, Eye, ChevronDown, ChevronUp, Loader2 } from "lucide-react"; import { FileText, Eye, ChevronDown, ChevronUp, Loader2 } from "lucide-react";
import { useSetAtom } from "jotai"; import { useSetAtom } from "jotai";
import { previewModeAtom } from "@/atoms/appAtoms"; import { previewModeAtom } from "@/atoms/appAtoms";
import { isPreviewOpenAtom } from "@/atoms/viewAtoms";
import { CustomTagState } from "./stateTypes"; import { CustomTagState } from "./stateTypes";
import { usePlan } from "@/hooks/usePlan"; import { usePlan } from "@/hooks/usePlan";
...@@ -21,6 +22,7 @@ export const DyadWritePlan: React.FC<DyadWritePlanProps> = ({ node }) => { ...@@ -21,6 +22,7 @@ export const DyadWritePlan: React.FC<DyadWritePlanProps> = ({ node }) => {
const { title, summary, complete, state } = node.properties; const { title, summary, complete, state } = node.properties;
const [showSummary, setShowSummary] = useState(false); const [showSummary, setShowSummary] = useState(false);
const setPreviewMode = useSetAtom(previewModeAtom); const setPreviewMode = useSetAtom(previewModeAtom);
const setIsPreviewOpen = useSetAtom(isPreviewOpenAtom);
// Consider in progress if state is pending OR complete is explicitly "false" // Consider in progress if state is pending OR complete is explicitly "false"
const isInProgress = state === "pending" || complete === "false"; const isInProgress = state === "pending" || complete === "false";
...@@ -63,7 +65,10 @@ export const DyadWritePlan: React.FC<DyadWritePlanProps> = ({ node }) => { ...@@ -63,7 +65,10 @@ export const DyadWritePlan: React.FC<DyadWritePlanProps> = ({ node }) => {
{!isInProgress && hasPlan && ( {!isInProgress && hasPlan && (
<button <button
type="button" type="button"
onClick={() => setPreviewMode("plan")} onClick={() => {
setPreviewMode("plan");
setIsPreviewOpen(true);
}}
className="flex items-center gap-1.5 text-xs font-medium text-primary-foreground px-4 py-1.5 bg-primary rounded-md hover:bg-primary/90 transition-colors" className="flex items-center gap-1.5 text-xs font-medium text-primary-foreground px-4 py-1.5 bg-primary rounded-md hover:bg-primary/90 transition-colors"
> >
<Eye size={14} /> <Eye size={14} />
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论