feat(webui): refresh the empty chat welcome (#6650)

* feat(webui): refresh the empty chat welcome

* fix(webui): keep empty chat accessible in split panes

* chore(webui): remove unused fixture test id
This commit is contained in:
chengyongru authored and GitHub committed 2026-11-13 17:12:18 +08:00
1 parent 90d69e7a11
commit 6a24b17629
26 files changed
+283 -205

No files matched your search

+1 -1
View File
@@ -72,7 +72,7 @@ export function StartupSkeleton({
<div className="startup-chat-viewport">
<div className="startup-chat-layout">
<div className="startup-messages"><Block /><Block /><Block /></div>
<div className="startup-welcome"><div className="startup-welcome-line"><Block /></div></div>
<div className="startup-chat-empty" />
<div className="startup-composer">
<div className="startup-composer-surface">
<div className="startup-composer-input"><Block /></div>
+2 -7
View File
@@ -99,9 +99,7 @@ html.dark .startup-shell { --startup-fill: hsl(0 0% 72% / .2); --startup-surface
.startup-messages .startup-block { width: 70%; margin-bottom: 20px; }
.startup-messages .startup-block:first-child { width: 40%; margin-left: auto; height: 40px; border-radius: 20px; }
.startup-messages .startup-block:last-child { width: 50%; }
.startup-welcome { display: flex; min-height: 0; align-items: center; justify-content: center; }
.startup-welcome-line { display: flex; width: 100%; max-width: 704px; height: 36.72px; align-items: center; justify-content: center; }
.startup-welcome-line .startup-block { width: 60%; height: 24px; }
.startup-chat-empty { min-height: 0; }
.startup-composer { container: startup-composer / inline-size; width: 100%; max-width: 928px; margin: 0 auto; --composer-footer-inset: 0.75rem; --composer-action-size: 2rem; --composer-action-margin: 0px; }
.startup-composer-surface { overflow: hidden; border-radius: 28px; background: hsl(0 0% 100%); box-shadow: inset 0 0 0 1px hsl(40 8% 90.5% / .75), 0 4px 18px -8px hsl(240 10% 16% / .12); }
html.dark .startup-composer-surface { background: hsl(0 0% 22%); box-shadow: inset 0 0 0 1px hsl(0 0% 28% / .75), 0 4px 18px -8px hsl(240 12% 3% / .12); }
@@ -126,12 +124,9 @@ html.dark .startup-composer-surface { background: hsl(0 0% 22%); box-shadow: ins
.startup-shell[data-existing-chat="true"] .startup-chat-layout { display: flex; flex-direction: column; }
.startup-shell[data-existing-chat="true"] .startup-messages { display: block; }
.startup-shell[data-existing-chat="true"] .startup-composer { max-width: 792px; margin-top: auto; }
.startup-shell[data-existing-chat="true"] :is(.startup-welcome, .startup-workspace-row) { display: none; }
.startup-shell[data-existing-chat="true"] :is(.startup-chat-empty, .startup-workspace-row) { display: none; }
@media (min-width: 640px) {
.startup-chat-layout { grid-template-rows: minmax(min-content, 1fr) auto 1fr; padding: 48px 16px; }
.startup-welcome { align-items: end; padding-bottom: 32px; }
.startup-welcome-line { height: 60px; }
.startup-welcome-line .startup-block { height: 36px; }
.startup-composer { --composer-footer-inset: 1rem; }
.startup-composer-input { padding-inline: 20px; }
.startup-composer-footer { padding-inline: 16px; }
+5 -95
View File
@@ -22,6 +22,7 @@ import { latestSubagentInputKey } from "@/lib/subagent-tasks";
import { SessionInfoPopover } from "@/components/thread/SessionInfoPopover";
import type { ComposerDraft, ComposerDraftStore } from "@/lib/composer-draft";
import { ThreadComposer } from "@/components/thread/ThreadComposer";
import { ThreadWelcomeMark } from "@/components/thread/ThreadWelcomeMark";
import {
ComposerUsagePopover,
type ComposerContextUsage,
@@ -260,89 +261,6 @@ interface ThreadShellProps {
skills?: SkillSummary[];
}
const HERO_GREETING_KEYS = [
"thread.empty.greetings.workOn",
"thread.empty.greetings.start",
"thread.empty.greetings.build",
"thread.empty.greetings.tackle",
] as const;
function HeroGreeting({ text }: { text: string }) {
const containerRef = useRef<HTMLDivElement>(null);
const headingRef = useRef<HTMLHeadingElement>(null);
useLayoutEffect(() => {
const container = containerRef.current;
const heading = headingRef.current;
if (!container || !heading) return;
const fitToWidth = () => {
heading.style.removeProperty("font-size");
const availableWidth = container.clientWidth;
if (availableWidth <= 0) return;
const naturalWidth = heading.scrollWidth;
const maximumFontSize = Number.parseFloat(window.getComputedStyle(heading).fontSize);
if (
naturalWidth <= availableWidth
|| !Number.isFinite(maximumFontSize)
|| maximumFontSize <= 0
) {
return;
}
const fittedFontSize = Math.max(
12,
Math.floor(maximumFontSize * ((availableWidth - 2) / naturalWidth) * 100) / 100,
);
heading.style.fontSize = `${fittedFontSize}px`;
};
fitToWidth();
let lastObservedWidth = container.clientWidth;
const resizeObserver = typeof ResizeObserver === "undefined"
? null
: new ResizeObserver(([entry]) => {
const nextWidth = entry?.contentRect.width ?? container.clientWidth;
if (nextWidth === lastObservedWidth) return;
lastObservedWidth = nextWidth;
fitToWidth();
});
resizeObserver?.observe(container);
window.addEventListener("resize", fitToWidth);
let cancelled = false;
void document.fonts?.ready.then(() => {
if (!cancelled) fitToWidth();
});
return () => {
cancelled = true;
resizeObserver?.disconnect();
window.removeEventListener("resize", fitToWidth);
};
}, [text]);
return (
<div ref={containerRef} className="min-w-0 w-full max-w-[44rem]">
<h1
ref={headingRef}
data-testid="hero-greeting"
data-theme-ink
className="select-none whitespace-nowrap text-[34px] font-normal leading-[1.08] tracking-normal text-foreground sm:text-[48px] sm:leading-tight"
>
{text}
</h1>
</div>
);
}
function randomHeroGreetingKey(): (typeof HERO_GREETING_KEYS)[number] {
const index = Math.floor(Math.random() * HERO_GREETING_KEYS.length);
return HERO_GREETING_KEYS[index] ?? HERO_GREETING_KEYS[0];
}
interface PendingFirstMessage {
finish?: (accepted: boolean) => void;
content: string;
@@ -550,7 +468,6 @@ export function ThreadShell({
dismissed: boolean;
} | null>(null);
const sandboxNotice = useSandboxNotice(client, chatId, webuiCapabilities.includes("webui.sandbox-settings.v1"));
const [heroGreetingKey, setHeroGreetingKey] = useState(randomHeroGreetingKey);
const [submittedViewportTurnId, setSubmittedViewportTurnId] = useState<string | null>(null);
const { state: previewState, openFile, resolveFile, selectTab, closeTab, close: closePreview, setWidth: setFilePreviewWidth } =
useFilePreviewState(previewSessionKey, filePreviewStore);
@@ -853,7 +770,6 @@ export function ThreadShell({
const composerVariant = showHeroComposer ? emptyComposerVariant : "thread";
// Only unpersisted drafts can choose a project; history pages do not own this state.
const projectLocked = !!session && session.projectLocked !== false;
const wasShowingHeroComposerRef = useRef(showHeroComposer);
const sessionModelPreset = session?.modelPreset?.trim() || null;
const [localModelPreset, setLocalModelPreset] = useState<string | null>(null);
useEffect(() => {
@@ -923,13 +839,6 @@ export function ThreadShell({
const modelBadgeLabel = modelBadge.needsSetup
? t("thread.composer.chooseAI", { defaultValue: "Choose your AI" })
: modelBadge.label;
useEffect(() => {
if (showHeroComposer && !wasShowingHeroComposerRef.current) {
setHeroGreetingKey(randomHeroGreetingKey());
}
wasShowingHeroComposerRef.current = showHeroComposer;
}, [showHeroComposer]);
const withWorkspaceScope = useCallback(
(options?: SendOptions): SendOptions | undefined => {
if (!workspaceScope) return options;
@@ -1494,9 +1403,10 @@ export function ThreadShell({
const emptyState = initialHistoryLoading ? (
<ThreadLoadingSkeleton />
) : (
<div className="flex w-full flex-col items-center text-center animate-in fade-in-0 slide-in-from-bottom-2 [animation-duration:220ms] motion-reduce:animate-none">
<HeroGreeting text={t(heroGreetingKey)} />
</div>
<>
<h1 className="sr-only">{session ? title : t(temporary || temporaryChatEnabled ? "temporaryChat.title" : "sidebar.newChat")}</h1>
<ThreadWelcomeMark />
</>
);
const sessionInfoAction = historyKey ? (
<SessionInfoPopover client={client} sessionKey={historyKey} token={token} />
@@ -1330,7 +1330,7 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
ref={emptyStateRef}
data-testid="thread-empty-region"
className={cn(
"row-start-1 min-h-0 min-w-0 w-full",
"relative row-start-1 min-h-0 min-w-0 w-full [container-type:inline-size]",
initialLoading
? "overflow-hidden"
: cn("flex items-center justify-center", hasComposer && "sm:items-end sm:pb-8"),
@@ -0,0 +1,89 @@
import { useEffect, useRef } from "react";
import "./thread-welcome-mark.css";
export function ThreadWelcomeMark() {
const markRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const mark = markRef.current;
if (!mark) return;
const motionPreference = window.matchMedia("(prefers-reduced-motion: reduce)");
let currentX = 0;
let currentY = 0;
let targetX = 0;
let targetY = 0;
let frame = 0;
let lastFrame: number | null = null;
let initialized = false;
const renderPosition = () => {
mark.style.setProperty("--mark-x", `${currentX}px`);
mark.style.setProperty("--mark-y", `${currentY}px`);
};
const followPointer = (timestamp: number) => {
const elapsed = lastFrame === null ? 0 : timestamp - lastFrame;
lastFrame = timestamp;
const step = 1 - Math.exp(-elapsed / 165);
currentX += (targetX - currentX) * step;
currentY += (targetY - currentY) * step;
if (Math.hypot(targetX - currentX, targetY - currentY) < 0.3) {
currentX = targetX;
currentY = targetY;
frame = 0;
lastFrame = null;
} else {
frame = window.requestAnimationFrame(followPointer);
}
renderPosition();
};
const onPointerMove = (event: PointerEvent) => {
if (event.pointerType === "touch") return;
const bounds = mark.getBoundingClientRect();
targetX = event.clientX - bounds.left;
targetY = event.clientY - bounds.top;
mark.style.setProperty("--mark-active", "1");
if (!initialized || motionPreference.matches) {
if (frame) window.cancelAnimationFrame(frame);
frame = 0;
lastFrame = null;
currentX = targetX;
currentY = targetY;
initialized = true;
renderPosition();
} else if (!frame) {
frame = window.requestAnimationFrame(followPointer);
}
};
const hideFocus = () => {
mark.style.setProperty("--mark-active", "0");
if (frame) window.cancelAnimationFrame(frame);
frame = 0;
lastFrame = null;
initialized = false;
};
const onPointerOut = (event: PointerEvent) => {
if (!event.relatedTarget) hideFocus();
};
window.addEventListener("pointermove", onPointerMove);
window.addEventListener("pointerout", onPointerOut);
window.addEventListener("blur", hideFocus);
return () => {
window.removeEventListener("pointermove", onPointerMove);
window.removeEventListener("pointerout", onPointerOut);
window.removeEventListener("blur", hideFocus);
if (frame) window.cancelAnimationFrame(frame);
};
}, []);
return (
<div ref={markRef} aria-hidden="true" data-testid="thread-welcome-mark" className="thread-welcome-mark">
<div className="thread-welcome-mark__fill" />
<div className="thread-welcome-mark__focus" />
</div>
);
}
@@ -0,0 +1,41 @@
.thread-welcome-mark {
position: absolute;
bottom: -3rem;
left: 50%;
/* 94.76cqw is the height of the 783:742 mark at its container's width. */
height: min(19.9rem, calc(100% + 3rem), 66.3vw, 94.76cqw);
aspect-ratio: 783 / 742;
pointer-events: none;
transform: translateX(-50%);
mask-image: linear-gradient(to bottom, #000 0%, rgb(0 0 0 / 0.8) 32%, rgb(0 0 0 / 0.28) 70%, transparent 100%);
-webkit-mask-image: linear-gradient(to bottom, #000 0%, rgb(0 0 0 / 0.8) 32%, rgb(0 0 0 / 0.28) 70%, transparent 100%);
}
.thread-welcome-mark__fill,
.thread-welcome-mark__focus {
position: absolute;
inset: 0;
}
.thread-welcome-mark__fill {
background: url('/brand/nanobot_mark.svg') center / calc(100% * 759 / 783) auto no-repeat;
filter: grayscale(1);
opacity: 0.06;
}
.thread-welcome-mark__focus {
mask: url('/brand/nanobot_mark_outline.svg') center / contain no-repeat;
-webkit-mask: url('/brand/nanobot_mark_outline.svg') center / contain no-repeat;
background: radial-gradient(circle 12rem at var(--mark-x, -200px) var(--mark-y, -200px), hsl(0 0% 25% / 0.06), hsl(0 0% 25% / 0.02) 50%, transparent 100%);
opacity: var(--mark-active, 0);
transition: opacity 600ms ease;
}
.dark .thread-welcome-mark__fill { opacity: 0.05; }
.dark .thread-welcome-mark__focus {
background: radial-gradient(circle 12rem at var(--mark-x, -200px) var(--mark-y, -200px), hsl(0 0% 100% / 0.05), hsl(0 0% 100% / 0.016) 50%, transparent 100%);
}
@media (prefers-reduced-motion: reduce) {
.thread-welcome-mark__focus { transition: none; }
}
-6
View File
@@ -2023,12 +2023,6 @@
},
"loadingConversation": "Loading conversation…",
"empty": {
"greetings": {
"workOn": "What should we work on?",
"start": "Where should we start?",
"build": "What are we building today?",
"tackle": "What should we tackle together?"
},
"quickActions": {
"plan": {
"title": "Make a plan",
-6
View File
@@ -1841,12 +1841,6 @@
},
"loadingConversation": "Cargando conversación…",
"empty": {
"greetings": {
"workOn": "¿En qué trabajamos juntos?",
"start": "¿Por dónde empezamos?",
"build": "¿Qué construimos hoy?",
"tackle": "¿Qué resolvemos juntos?"
},
"quickActions": {
"plan": {
"title": "Crear un plan",
-6
View File
@@ -1841,12 +1841,6 @@
},
"loadingConversation": "Chargement de la conversation…",
"empty": {
"greetings": {
"workOn": "Sur quoi travaillons-nous ensemble ?",
"start": "Par où commence-t-on ?",
"build": "Que construisons-nous aujourd'hui ?",
"tackle": "Que résout-on ensemble ?"
},
"quickActions": {
"plan": {
"title": "Créer un plan",
-6
View File
@@ -1841,12 +1841,6 @@
},
"loadingConversation": "Memuat percakapan…",
"empty": {
"greetings": {
"workOn": "Apa yang kita kerjakan bersama?",
"start": "Kita mulai dari mana?",
"build": "Apa yang kita bangun hari ini?",
"tackle": "Apa yang kita selesaikan bersama?"
},
"quickActions": {
"plan": {
"title": "Buat rencana",
-6
View File
@@ -1841,12 +1841,6 @@
},
"loadingConversation": "会話を読み込み中…",
"empty": {
"greetings": {
"workOn": "一緒に何に取り組みましょうか?",
"start": "今日はどこから始めましょう?",
"build": "今日は何を作りましょうか?",
"tackle": "一緒に何を解決しましょう?"
},
"quickActions": {
"plan": {
"title": "計画を立てる",
-6
View File
@@ -1841,12 +1841,6 @@
},
"loadingConversation": "대화 불러오는 중…",
"empty": {
"greetings": {
"workOn": "우리 무엇을 함께 해볼까요?",
"start": "오늘은 어디서 시작할까요?",
"build": "오늘은 무엇을 만들어볼까요?",
"tackle": "함께 무엇을 해결할까요?"
},
"quickActions": {
"plan": {
"title": "계획 세우기",
-6
View File
@@ -1843,12 +1843,6 @@
},
"loadingConversation": "Carregando conversa…",
"empty": {
"greetings": {
"workOn": "Em que vamos trabalhar?",
"start": "Por onde começamos?",
"build": "O que vamos construir hoje?",
"tackle": "O que vamos resolver juntos?"
},
"quickActions": {
"plan": {
"title": "Criar um plano",
-6
View File
@@ -1841,12 +1841,6 @@
},
"loadingConversation": "Đang tải cuộc trò chuyện…",
"empty": {
"greetings": {
"workOn": "Mình cùng làm gì tiếp?",
"start": "Hôm nay bắt đầu từ đâu?",
"build": "Hôm nay mình xây dựng gì?",
"tackle": "Mình cùng xử lý việc gì?"
},
"quickActions": {
"plan": {
"title": "Lập kế hoạch",
-6
View File
@@ -2023,12 +2023,6 @@
},
"loadingConversation": "正在加载话题…",
"empty": {
"greetings": {
"workOn": "我们要一起做点什么?",
"start": "今天从哪里开始?",
"build": "今天一起构建什么?",
"tackle": "我们要一起解决什么?"
},
"quickActions": {
"plan": {
"title": "制定计划",
-6
View File
@@ -1841,12 +1841,6 @@
},
"loadingConversation": "正在載入話題…",
"empty": {
"greetings": {
"workOn": "我們要一起做點什麼?",
"start": "今天從哪裡開始?",
"build": "今天要一起打造什麼?",
"tackle": "我們要一起解決什麼?"
},
"quickActions": {
"plan": {
"title": "制定計劃",
+4 -6
View File
@@ -48,8 +48,6 @@ const sidebarStateUpdateHandlers = new Set<(state: SidebarStatePayload) => void>
const pairingChangeHandlers = new Set<() => void>();
const readyHandlers = new Set<() => void>();
let mockSessions: ChatSummary[] = [];
const HERO_GREETING_PATTERN =
/What should we work on\?|Where should we start\?|What are we building today\?|What should we tackle together\?/;
function setNavigatorPlatform(platform: string): void {
Object.defineProperty(window.navigator, "platform", {
@@ -1368,7 +1366,7 @@ describe("App layout", () => {
});
fireEvent.click(screen.getByRole("button", { name: "Back to chat" }));
await waitFor(() => expect(window.location.hash).toBe("#/new"));
expect(await screen.findByText(HERO_GREETING_PATTERN, {}, { timeout: 10_000 })).toBeInTheDocument();
expect(await screen.findByTestId("thread-welcome-mark", {}, { timeout: 10_000 })).toBeInTheDocument();
}, 30_000);
it("opens Skills from the main sidebar", async () => {
@@ -1489,7 +1487,7 @@ describe("App layout", () => {
expect(document.title).toBe("Skills");
fireEvent.click(screen.getByRole("button", { name: "Back to chat" }));
expect(await screen.findByText(HERO_GREETING_PATTERN)).toBeInTheDocument();
expect(await screen.findByTestId("thread-welcome-mark")).toBeInTheDocument();
fireEvent.click(within(sidebar).getByRole("button", { name: "Skills" }));
expect(await screen.findByRole("heading", { name: "Skills" })).toBeInTheDocument();
@@ -3708,7 +3706,7 @@ describe("App layout", () => {
fireEvent.click(screen.getByRole("button", { name: "Back to chat" }));
await waitFor(() => expect(document.title).toBe("nanobot"));
expect(screen.getByText(HERO_GREETING_PATTERN)).toBeInTheDocument();
expect(screen.getByTestId("thread-welcome-mark")).toBeInTheDocument();
});
it("filters sessions in the centered search dialog", async () => {
@@ -4484,7 +4482,7 @@ describe("App layout", () => {
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
fireEvent.click(within(sidebar).getByRole("button", { name: "New topic" }));
expect(createChatSpy).not.toHaveBeenCalled();
expect(screen.getByText(HERO_GREETING_PATTERN)).toBeInTheDocument();
expect(screen.getByTestId("thread-welcome-mark")).toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Start a new topic" })).not.toBeInTheDocument();
expect(screen.getByRole("button", { name: "Toggle theme from header" })).toBeInTheDocument();
expect(within(sidebar).getByRole("button", { name: "Settings" })).toBeInTheDocument();
-4
View File
@@ -21,7 +21,6 @@ import {
const QUICK_ACTION_KEYS = ["plan", "analyze", "brainstorm", "code", "summarize", "more"];
const IMAGE_QUICK_ACTION_KEYS = ["icon", "sticker", "poster", "product", "portrait", "edit"];
const HERO_GREETING_KEYS = ["workOn", "start", "build", "tackle"];
const SLASH_COMMAND_KEYS = [
"new",
"compact",
@@ -586,9 +585,6 @@ describe("webui i18n", () => {
it("keeps empty landing resources localized for every registered locale", () => {
for (const resource of Object.values(resources)) {
const empty = resource.common.thread.empty;
for (const key of HERO_GREETING_KEYS) {
expect(empty.greetings[key as keyof typeof empty.greetings]).toBeTruthy();
}
for (const key of QUICK_ACTION_KEYS) {
const action = empty.quickActions[key as keyof typeof empty.quickActions];
expect(action.title).toBeTruthy();
@@ -386,7 +386,7 @@ describe("temporary chat navigation", () => {
expect(within(screen.getByTestId("thread-message-region")).getByText(
"Count from one to three",
)).toBeInTheDocument();
expect(screen.queryByTestId("hero-greeting")).not.toBeInTheDocument();
expect(screen.queryByTestId("thread-welcome-mark")).not.toBeInTheDocument();
});
it.each(["before leaving", "while away", "after returning"])(
@@ -520,7 +520,7 @@ describe("temporary chat navigation", () => {
expect(window.location.hash).toBe(`#/temporary/${secondChatId}`);
await selectTopic("Close temporary chat: List three colors");
expect(deleteCache).toHaveBeenCalledWith(secondChatId);
expect(await screen.findByTestId("hero-greeting")).toBeInTheDocument();
expect(await screen.findByTestId("thread-welcome-mark")).toBeInTheDocument();
for (const cache of deleteCache.mock.contexts) {
if (!(cache instanceof ThreadMessageCache)) throw new Error("Expected thread message cache");
expect(cache.get(firstChatId)).toBeUndefined();
+22 -17
View File
@@ -27,9 +27,6 @@ import type {
import { canonicalThreadPayload } from "./thread-test-payload";
import { createStreamClient } from "./stream-client";
const HERO_GREETING_PATTERN =
/What should we work on\?|Where should we start\?|What are we building today\?|What should we tackle together\?/;
async function openMessageActions(text: string): Promise<HTMLElement> {
const message = await screen.findByText(text);
const block = message.closest<HTMLElement>("[data-thread-display-unit]")!;
@@ -1491,10 +1488,11 @@ describe("ThreadShell", () => {
/>,
));
await waitFor(() => expect(screen.getByText("Important conversation")).toBeInTheDocument());
fireEvent.click(screen.getByText("Important conversation"));
const header = within(screen.getByTestId("thread-header"));
await waitFor(() => expect(header.getByText("Important conversation")).toBeInTheDocument());
fireEvent.click(header.getByText("Important conversation"));
expect(screen.getByText("Important conversation")).toBeVisible();
expect(header.getByText("Important conversation")).toBeVisible();
});
it.each([true, false])("waits for parent settings and retries only on failure (success: %s)", async (success) => {
@@ -1932,7 +1930,11 @@ describe("ThreadShell", () => {
"anthropic/claude-opus-4-5",
));
await screen.findByText(hasHistory ? "Previous message" : HERO_GREETING_PATTERN);
if (hasHistory) {
await screen.findByText("Previous message");
} else {
await waitFor(() => expect(screen.getByTestId("thread-welcome-layout")).toHaveAttribute("data-layout", "hero"));
}
const badge = screen.getByRole("button", { name: "Choose model" });
fireEvent.focus(badge);
expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
@@ -2555,7 +2557,7 @@ describe("ThreadShell", () => {
await waitFor(() =>
expect(screen.getByText("first message should stay")).toBeInTheDocument(),
);
expect(screen.queryByText(HERO_GREETING_PATTERN)).not.toBeInTheDocument();
expect(screen.getByTestId("thread-composer-motion").closest("[data-layout]")).toHaveAttribute("data-layout", "thread");
});
it("hides a live first /model turn when the initial history snapshot is stale", async () => {
@@ -2647,7 +2649,7 @@ describe("ThreadShell", () => {
});
});
it("keeps the empty thread landing focused on the composer", async () => {
it.each([false, true])("keeps the empty thread landing focused on the composer (temporary=%s)", async (temporary) => {
const client = makeClient();
render(
wrap(
@@ -2655,15 +2657,17 @@ describe("ThreadShell", () => {
<ThreadShell
session={null}
title="nanobot"
temporaryChatEnabled={temporary}
onToggleSidebar={() => {}}
/>,
),
);
await act(async () => {});
const greeting = screen.getByRole("heading", { level: 1, name: HERO_GREETING_PATTERN });
expect(greeting).toHaveAttribute("data-testid", "hero-greeting");
expect(greeting).toHaveClass("select-none", "whitespace-nowrap");
expect(within(screen.getByTestId("thread-empty-region")).getByRole("heading", {
level: 1, name: temporary ? "Temporary chat" : "New topic",
})).toHaveClass("sr-only");
expect(screen.getByTestId("thread-welcome-mark")).toHaveAttribute("aria-hidden", "true");
expect(screen.getByRole("textbox")).toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Write code" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Make a plan" })).not.toBeInTheDocument();
@@ -2903,7 +2907,7 @@ describe("ThreadShell", () => {
});
expect(screen.queryByText("live assistant reply")).not.toBeInTheDocument();
expect(screen.getByText(HERO_GREETING_PATTERN)).toBeInTheDocument();
expect(screen.getByTestId("thread-welcome-layout")).toHaveAttribute("data-layout", "hero");
await act(async () => {
rerender(
@@ -5357,7 +5361,7 @@ describe("ThreadShell", () => {
),
);
expect(screen.getByText(HERO_GREETING_PATTERN)).toBeInTheDocument();
expect(screen.getByTestId("thread-welcome-layout")).toHaveAttribute("data-layout", "hero");
const scroller = container.querySelector(".thread-viewport-scrollbar") as HTMLElement;
Object.defineProperties(scroller, {
scrollHeight: { configurable: true, value: 2400 },
@@ -5723,7 +5727,7 @@ describe("ThreadShell", () => {
expect(screen.getByTestId("thread-composer-motion")).toBe(composer);
});
it.each([false, true])("replaces the initial history skeleton with welcome when no visible history remains (systemOnly=%s)", async (systemOnly) => {
it.each([false, true])("replaces the initial history skeleton with the empty composer when no visible history remains (systemOnly=%s)", async (systemOnly) => {
let resolveHistory!: (response: Response) => void;
vi.mocked(fetch).mockImplementation((input) => String(input).includes("/webui-thread")
? new Promise<Response>((resolve) => { resolveHistory = resolve; })
@@ -5738,9 +5742,10 @@ describe("ThreadShell", () => {
: [])));
});
expect(await screen.findByText(HERO_GREETING_PATTERN)).toBeVisible();
await waitFor(() => expect(screen.getByTestId("thread-welcome-layout")).toHaveAttribute("data-layout", "hero"));
expect(screen.queryByRole("status", { name: "Loading conversation…" })).not.toBeInTheDocument();
expect(screen.getByTestId("thread-welcome-layout")).toHaveAttribute("data-layout", "hero");
expect(within(screen.getByTestId("thread-empty-region")).getByRole("heading", { level: 1, name: "Empty topic" })).toHaveClass("sr-only");
expect(screen.getByRole("textbox", { name: "Message input" })).toBeEnabled();
});
it("keeps cached messages visible while the first history revalidation is pending", async () => {