Unverified 提交 d5a7b8b1 authored 作者: wwwillchen-bot's avatar wwwillchen-bot 提交者: GitHub

fix: hide Fix with AI button while streaming (#2771)

## Summary - Hides the "Fix with AI" button in the `DyadOutput` component while a response is being streamed - Prevents users from triggering conflicting AI fix requests during an ongoing stream - Uses the existing `isStreamingByIdAtom` to track streaming state per chat ## Test plan - Open the app and trigger an error/warning in the output - Start a streaming response - Verify the "Fix with AI" button is hidden during streaming - Verify the button reappears after streaming completes 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2771" 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 avatarWill Chen <willchen90@gmail.com> Co-authored-by: 's avatarClaude Opus 4.5 <noreply@anthropic.com>
上级 ccf97c0f
import React, { useState } from "react"; import React, { useState } from "react";
import { AlertTriangle, XCircle, Sparkles } from "lucide-react"; import { AlertTriangle, XCircle, Sparkles } from "lucide-react";
import { useAtomValue } from "jotai"; import { useAtomValue } from "jotai";
import { selectedChatIdAtom } from "@/atoms/chatAtoms"; import { selectedChatIdAtom, isStreamingByIdAtom } from "@/atoms/chatAtoms";
import { useStreamChat } from "@/hooks/useStreamChat"; import { useStreamChat } from "@/hooks/useStreamChat";
import { CopyErrorMessage } from "@/components/CopyErrorMessage"; import { CopyErrorMessage } from "@/components/CopyErrorMessage";
import { import {
...@@ -25,6 +25,10 @@ export const DyadOutput: React.FC<DyadOutputProps> = ({ ...@@ -25,6 +25,10 @@ export const DyadOutput: React.FC<DyadOutputProps> = ({
}) => { }) => {
const [isContentVisible, setIsContentVisible] = useState(false); const [isContentVisible, setIsContentVisible] = useState(false);
const selectedChatId = useAtomValue(selectedChatIdAtom); const selectedChatId = useAtomValue(selectedChatIdAtom);
const isStreamingById = useAtomValue(isStreamingByIdAtom);
const isStreaming = selectedChatId
? (isStreamingById.get(selectedChatId) ?? false)
: false;
const { streamMessage } = useStreamChat(); const { streamMessage } = useStreamChat();
// If the type is not warning, it is an error (in case LLM gives a weird "type") // If the type is not warning, it is an error (in case LLM gives a weird "type")
...@@ -76,6 +80,7 @@ export const DyadOutput: React.FC<DyadOutputProps> = ({ ...@@ -76,6 +80,7 @@ export const DyadOutput: React.FC<DyadOutputProps> = ({
<CopyErrorMessage <CopyErrorMessage
errorMessage={children ? `${message}\n${children}` : message} errorMessage={children ? `${message}\n${children}` : message}
/> />
{!isStreaming && (
<button <button
onClick={handleAIFix} onClick={handleAIFix}
className="cursor-pointer flex items-center justify-center bg-red-600 hover:bg-red-700 dark:bg-red-700 dark:hover:bg-red-800 text-white rounded-md text-xs px-2.5 py-1 h-6 transition-colors" className="cursor-pointer flex items-center justify-center bg-red-600 hover:bg-red-700 dark:bg-red-700 dark:hover:bg-red-800 text-white rounded-md text-xs px-2.5 py-1 h-6 transition-colors"
...@@ -83,6 +88,7 @@ export const DyadOutput: React.FC<DyadOutputProps> = ({ ...@@ -83,6 +88,7 @@ export const DyadOutput: React.FC<DyadOutputProps> = ({
<Sparkles size={13} className="mr-1" /> <Sparkles size={13} className="mr-1" />
<span>Fix with AI</span> <span>Fix with AI</span>
</button> </button>
)}
</div> </div>
)} )}
</DyadCard> </DyadCard>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论