mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-24 08:55:59 +00:00
Fix invalid HTML nesting in reasoning trigger during complex task rendering (#2382)
* Initial plan * fix(frontend): avoid invalid paragraph nesting in reasoning trigger Agent-Logs-Url: https://github.com/bytedance/deer-flow/sessions/4c9eb0c2-ff29-4629-a61c-4e33d736d918 Co-authored-by: WillemJiang <219644+WillemJiang@users.noreply.github.com> * test(frontend): strengthen reasoning trigger DOM nesting assertion Agent-Logs-Url: https://github.com/bytedance/deer-flow/sessions/4c9eb0c2-ff29-4629-a61c-4e33d736d918 Co-authored-by: WillemJiang <219644+WillemJiang@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: WillemJiang <219644+WillemJiang@users.noreply.github.com>
This commit is contained in:
@@ -123,9 +123,9 @@ const defaultGetThinkingMessage = (isStreaming: boolean, duration?: number) => {
|
|||||||
return <Shimmer duration={1}>Thinking...</Shimmer>;
|
return <Shimmer duration={1}>Thinking...</Shimmer>;
|
||||||
}
|
}
|
||||||
if (duration === undefined) {
|
if (duration === undefined) {
|
||||||
return <p>Thought for a few seconds</p>;
|
return <span>Thought for a few seconds</span>;
|
||||||
}
|
}
|
||||||
return <p>Thought for {duration} seconds</p>;
|
return <span>Thought for {duration} seconds</span>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ReasoningTrigger = memo(
|
export const ReasoningTrigger = memo(
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { createElement } from "react";
|
||||||
|
import { renderToStaticMarkup } from "react-dom/server";
|
||||||
|
import { expect, test, vi } from "vitest";
|
||||||
|
|
||||||
|
vi.mock("streamdown", () => ({
|
||||||
|
Streamdown: ({ children }: { children: string }) =>
|
||||||
|
createElement("div", null, children),
|
||||||
|
}));
|
||||||
|
|
||||||
|
import {
|
||||||
|
Reasoning,
|
||||||
|
ReasoningContent,
|
||||||
|
ReasoningTrigger,
|
||||||
|
} from "@/components/ai-elements/reasoning";
|
||||||
|
|
||||||
|
test("ReasoningTrigger default message uses phrasing content", () => {
|
||||||
|
const html = renderToStaticMarkup(
|
||||||
|
createElement(
|
||||||
|
Reasoning,
|
||||||
|
{ isStreaming: false, defaultOpen: false },
|
||||||
|
createElement(ReasoningTrigger, null),
|
||||||
|
createElement(ReasoningContent, null, "test"),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(html).toContain("Thought for a few seconds");
|
||||||
|
expect(html).not.toMatch(/<button\b[^>]*>[\s\S]*?<p\b/i);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user