Open-source SEO, GEO, and marketing skills for AI agents.
fix(chat): compact streaming response status
Yuting Zhongaab14fb1f1a4
diff --git a/notfair/src/components/chat/messages.test.tsx b/notfair/src/components/chat/messages.test.tsxindex 7b00a6d1..97d4b33e 100644--- a/notfair/src/components/chat/messages.test.tsx+++ b/notfair/src/components/chat/messages.test.tsx@@ -2,7 +2,7 @@import { fireEvent, render, within } from "@testing-library/react";import { describe, expect, it } from "vitest";-import { RenderItem, ToolGroup } from "./messages";+import { AssistantText, RenderItem, ToolGroup } from "./messages";import type { RenderedItem, ToolEntry } from "./transcript-model";const runningTool: ToolEntry = {@@ -14,6 +14,18 @@ const runningTool: ToolEntry = {done: false,};+describe("AssistantText", () => {+ it("does not add a standalone streaming cursor below the message", () => {+ const { container } = render(+ <AssistantText body="The answer is still streaming." />,+ );++ expect(container).toHaveTextContent("The answer is still streaming.");+ expect(container.querySelector(".animate-pulse")).toBeNull();+ expect(container.querySelector('span[aria-hidden="true"]')).toBeNull();+ });+});+describe("ToolGroup", () => {it("stays collapsed by default and preserves a user's expansion when the tool finishes", () => {const { container, rerender } = render(diff --git a/notfair/src/components/chat/messages.tsx b/notfair/src/components/chat/messages.tsxindex 52a69ada..bb1f0e6c 100644--- a/notfair/src/components/chat/messages.tsx+++ b/notfair/src/components/chat/messages.tsx@@ -123,21 +123,13 @@ export function UserBubble({ body }: { body: string }) {export function AssistantText({body,- streaming = false,}: {body: string;- streaming?: boolean;}) {if (body.trim() === "") return null;return (<div className="text-[15px] leading-[1.75] text-foreground/95"><Markdown>{body}</Markdown>- {streaming && (- <span- aria-hidden- className="ml-1 inline-block h-[15px] w-[3px] translate-y-[2px] animate-pulse rounded-full bg-foreground/60"- />- )}</div>);}diff --git a/notfair/src/components/live-transcript.test.tsx b/notfair/src/components/live-transcript.test.tsxnew file mode 100644index 00000000..4c320db4--- /dev/null+++ b/notfair/src/components/live-transcript.test.tsx@@ -0,0 +1,53 @@+// @vitest-environment jsdom+import { render, screen } from "@testing-library/react";+import { describe, expect, it, vi } from "vitest";++const stream = vi.hoisted(() => ({+ events: [],+ sendingChat: true,+ remoteTurnActive: false,+ openTurn: null,+ turnStartedAt: 1_800_000_000_000,+ pendingUserMsg: null,+ pendingAssistant: "The answer is still streaming.",+ pendingTools: [],+ pendingError: null,+ pendingLifecycle: null,+ send: vi.fn(),+ stopTurn: vi.fn(),+ clearLocal: vi.fn(),+}));++vi.mock("@/components/chat/use-chat-stream", () => ({+ useChatStream: () => stream,+}));++import { LiveTranscript } from "@/components/live-transcript";++describe("LiveTranscript streaming layout", () => {+ it("keeps the writing status close to the streamed answer", () => {+ render(+ <LiveTranscript+ projectSlug="project"+ agentSlug="goal-1"+ agentDisplayName="Growth goal"+ threadId="main"+ initialEvents={[]}+ initialCursor={0}+ />,+ );++ const answerItem = screen+ .getByText("The answer is still streaming.")+ .closest("li");+ const statusItem = screen+ .getByRole("status", {+ name: "Growth goal Writing the response",+ })+ .closest("li");++ expect(answerItem?.nextElementSibling).toBe(statusItem);+ expect(statusItem).toHaveAttribute("data-live-working-status");+ expect(statusItem).toHaveClass("!mt-2");+ });+});diff --git a/notfair/src/components/live-transcript.tsx b/notfair/src/components/live-transcript.tsxindex 53089c46..12f3545c 100644--- a/notfair/src/components/live-transcript.tsx+++ b/notfair/src/components/live-transcript.tsx@@ -279,7 +279,7 @@ export function LiveTranscript({)}{pendingAssistant && (<li>- <AssistantText body={pendingAssistant} streaming />+ <AssistantText body={pendingAssistant} /></li>)}{pendingError && (@@ -291,7 +291,10 @@ export function LiveTranscript({</li>)}{showThinking && (- <li>+ <li+ data-live-working-status+ className={pendingAssistant ? "!mt-2" : undefined}+ >{blockedReason ? (<BlockedStatus reason={blockedReason} />) : (