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:
1 parent
90d69e7a11
commit
6a24b17629
26 files changed
+283
-205
No files matched your search
@@ -20,7 +20,7 @@ for (const theme of ["light", "dark"]) {
|
||||
await expect(surface).toBeVisible();
|
||||
const input = page.getByRole("textbox", { name: "Message input" });
|
||||
await input.blur();
|
||||
await page.getByTestId("hero-greeting").click();
|
||||
await page.getByTestId("thread-empty-region").click();
|
||||
const rest = await surface.evaluate(element => getComputedStyle(element).boxShadow);
|
||||
const bounds = await surface.boundingBox();
|
||||
const footer = await page.locator(".thread-composer-footer").boundingBox();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useState } from "react";
|
||||
import { ThreadShell } from "@/components/thread/ThreadShell";
|
||||
import { PaneWorkbench } from "@/components/workbench/PaneWorkbench";
|
||||
import type { WorkspaceScopePayload } from "@/lib/types";
|
||||
import { StartupSkeleton } from "@/components/StartupSkeleton";
|
||||
import { settings } from "@/dev/gallery/settings";
|
||||
@@ -18,11 +19,19 @@ export function NewChatSkeletonFixture() {
|
||||
{params.has("loading") ? <StartupSkeleton sidebarExpanded={sidebarExpanded} sidebarWidth={sidebarWidth} /> : <>
|
||||
<aside className="hidden shrink-0 bg-sidebar lg:block" style={{ width: sidebarExpanded ? sidebarWidth : 56 }} />
|
||||
<main className="thread-workspace relative flex min-w-0 flex-1 flex-col overflow-hidden">
|
||||
<ThreadShell session={null} title="nanobot" onToggleSidebar={noop} theme={dark ? "dark" : "light"}
|
||||
{params.has("split") ? <PaneWorkbench
|
||||
panes={[{ key: "one", title: "One" }, { key: "two", title: "Two" }, { key: "three", title: "Three" }]}
|
||||
activePaneKey="one" layout="columns" showLayoutControl={false} onActivatePane={noop} onAddPane={noop}
|
||||
onLayoutChange={noop} onPaneOrderChange={noop}
|
||||
renderPane={(_pane, context) => <ThreadShell session={null} title="nanobot" onToggleSidebar={noop}
|
||||
headerPortalTarget={context.headerPortalTarget} headerActive={context.active}
|
||||
composerPortalTarget={context.composerPortalTarget} composerActive={context.active} settingsSnapshot={settings}
|
||||
navigationFrame={context.navigationFrame} multiplePanes={context.multiplePanes} emptyComposerVariant="thread" />}
|
||||
/> : <ThreadShell session={null} title="nanobot" onToggleSidebar={noop} theme={dark ? "dark" : "light"}
|
||||
hideSidebarToggleForHostChrome onTemporaryChatEnabledChange={noop} settingsSnapshot={settings}
|
||||
workspaceScope={workspaceScope}
|
||||
workspaceDefaultScope={{ project_path: "/workspace", access_mode: "full" }}
|
||||
workspaceControls={{ can_change_project: true, can_browse_directories: true }} onWorkspaceScopeChange={setWorkspaceScope} />
|
||||
workspaceControls={{ can_change_project: true, can_browse_directories: true }} onWorkspaceScopeChange={setWorkspaceScope} />}
|
||||
</main>
|
||||
</>}
|
||||
</div>;
|
||||
|
||||
@@ -25,9 +25,8 @@ function sameBox(actual: Awaited<ReturnType<typeof box>>, expected: typeof actua
|
||||
for (const c of cases) for (const locale of ["en", "zh-CN"]) {
|
||||
test.describe(`${c.name} ${locale} new chat`, () => {
|
||||
test.use({ viewport: { width: c.width, height: c.height }, hasTouch: c.touch, reducedMotion: "reduce" });
|
||||
test("aligns the document skeleton with the real welcome, composer and header", async ({ page }) => {
|
||||
test("aligns the document skeleton with the real composer and header", async ({ page }) => {
|
||||
await page.addInitScript((language) => {
|
||||
Math.random = () => 0;
|
||||
localStorage.setItem("nanobot.locale", language);
|
||||
}, locale);
|
||||
await page.route("**/api/commands", (route) => route.fulfill({ json: { commands: [] } }));
|
||||
@@ -42,12 +41,22 @@ for (const c of cases) for (const locale of ["en", "zh-CN"]) {
|
||||
return { x, y, width, height };
|
||||
})),
|
||||
composer: await box(page.locator(".thread-composer-surface")),
|
||||
mark: await box(page.getByTestId("thread-welcome-mark")),
|
||||
input: await box(page.locator(".thread-composer-input")),
|
||||
footer: await box(page.locator(".thread-composer-footer")),
|
||||
greeting: await box(page.getByTestId("hero-greeting")),
|
||||
workspaceRow: await box(page.locator(".thread-composer-meta")),
|
||||
workspaceControl: await box(page.locator(".thread-composer-workspace")),
|
||||
};
|
||||
await expect(page.getByTestId("thread-empty-region").getByRole("heading", {
|
||||
level: 1, name: locale === "en" ? "New topic" : "新建话题",
|
||||
})).toHaveClass("sr-only");
|
||||
await expect(page.getByTestId("thread-welcome-mark").locator(".thread-welcome-mark__focus")).toHaveCSS("mask-image", /nanobot_mark_outline\.svg/);
|
||||
await expect(page.getByTestId("thread-welcome-mark").locator(".thread-welcome-mark__fill")).toHaveCSS("background-image", /nanobot_mark\.svg/);
|
||||
await expect(page.getByTestId("thread-welcome-mark").locator(".thread-welcome-mark__fill")).toHaveCSS("filter", "grayscale(1)");
|
||||
expect(Math.abs(loaded.mark.x + loaded.mark.width / 2 - loaded.composer.x - loaded.composer.width / 2)).toBeLessThanOrEqual(1);
|
||||
expect(loaded.mark.y).toBeLessThan(loaded.composer.y);
|
||||
expect(loaded.mark.y + loaded.mark.height).toBeGreaterThan(loaded.composer.y);
|
||||
await expect(page.getByTestId("thread-welcome-mark")).toHaveCSS("pointer-events", "none");
|
||||
await page.goto(`${url}&loading`);
|
||||
sameBox(await box(page.locator(".startup-chat-header")), loaded.header);
|
||||
sameBox(await box(page.locator(".startup-composer-surface")), loaded.composer);
|
||||
@@ -58,11 +67,77 @@ for (const c of cases) for (const locale of ["en", "zh-CN"]) {
|
||||
const controls = page.locator(".startup-header-menu:visible, .startup-header-actions > div");
|
||||
await expect(controls).toHaveCount(loaded.controls.length);
|
||||
for (let i = 0; i < loaded.controls.length; i++) sameBox(await box(controls.nth(i)), loaded.controls[i]);
|
||||
const greeting = await box(page.locator(".startup-welcome-line"));
|
||||
if (c.width < 640) expect(Math.abs(greeting.y + greeting.height / 2 - loaded.greeting.y - loaded.greeting.height / 2)).toBeLessThanOrEqual(1);
|
||||
else expect(Math.abs(greeting.y + greeting.height - loaded.greeting.y - loaded.greeting.height)).toBeLessThanOrEqual(1);
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth)).toBe(false);
|
||||
await expect(page.getByRole("status")).toHaveText("Loading nanobot…");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
test("keeps the welcome marks proportional and inside split panes as the window resizes", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1100, height: 936 });
|
||||
await page.route("**/api/commands", (route) => route.fulfill({ json: { commands: [] } }));
|
||||
await page.goto("/browser/fixture.html?case=new-chat-skeleton&split");
|
||||
const panes = page.locator(".workbench-pane");
|
||||
await expect(panes).toHaveCount(3);
|
||||
|
||||
for (const width of [1100, 946]) {
|
||||
await page.setViewportSize({ width, height: 936 });
|
||||
for (const pane of await panes.all()) {
|
||||
const region = await box(pane.getByTestId("thread-empty-region"));
|
||||
const mark = await box(pane.getByTestId("thread-welcome-mark"));
|
||||
expect(mark.x).toBeGreaterThanOrEqual(region.x - 0.1);
|
||||
expect(mark.x + mark.width).toBeLessThanOrEqual(region.x + region.width + 0.1);
|
||||
expect(mark.width / mark.height).toBeCloseTo(783 / 742, 2);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("draws the nose bridge and the original cheek lines", async ({ page }) => {
|
||||
await page.route("**/api/commands", (route) => route.fulfill({ json: { commands: [] } }));
|
||||
await page.goto("/browser/fixture.html?case=new-chat-skeleton");
|
||||
await expect(page.getByTestId("thread-welcome-mark")).toBeVisible();
|
||||
const pixels = await page.evaluate(async () => {
|
||||
const image = new Image();
|
||||
image.src = "/brand/nanobot_mark_outline.svg";
|
||||
await image.decode();
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = 783;
|
||||
canvas.height = 742;
|
||||
const context = canvas.getContext("2d")!;
|
||||
context.drawImage(image, 0, 0);
|
||||
return [[379, 200], [379, 400], [379, 650], [80, 497], [680, 497]]
|
||||
.map(([x, y]) => context.getImageData(x + 12, y + 12, 1, 1).data[3]);
|
||||
});
|
||||
expect(pixels[0]).toBe(0);
|
||||
expect(pixels[1]).toBeGreaterThan(0);
|
||||
expect(pixels[2]).toBe(0);
|
||||
expect(pixels[3]).toBeGreaterThan(0);
|
||||
expect(pixels[4]).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
for (const reducedMotion of ["no-preference", "reduce"] as const) {
|
||||
test.describe(`welcome mark with ${reducedMotion} motion`, () => {
|
||||
test.use({ reducedMotion });
|
||||
test("reveals the outline near the pointer and hides the focus when the window loses focus", async ({ page }) => {
|
||||
await page.route("**/api/commands", (route) => route.fulfill({ json: { commands: [] } }));
|
||||
await page.goto("/browser/fixture.html?case=new-chat-skeleton");
|
||||
const mark = page.getByTestId("thread-welcome-mark");
|
||||
const bounds = await box(mark);
|
||||
const focus = mark.locator(".thread-welcome-mark__focus");
|
||||
const position = () => mark.evaluate((element) => ({
|
||||
x: Number.parseFloat(element.style.getPropertyValue("--mark-x")),
|
||||
y: Number.parseFloat(element.style.getPropertyValue("--mark-y")),
|
||||
}));
|
||||
|
||||
await page.mouse.move(bounds.x + 40, bounds.y + 50);
|
||||
await expect.poll(async () => Math.abs((await position()).x - 40)).toBeLessThan(1);
|
||||
await expect(focus).toHaveCSS("opacity", "1");
|
||||
await page.mouse.move(bounds.x + bounds.width - 40, bounds.y + 70);
|
||||
await expect.poll(async () => Math.abs((await position()).x - (bounds.width - 40))).toBeLessThan(1);
|
||||
expect(Math.abs((await position()).y - 70)).toBeLessThan(1);
|
||||
|
||||
await page.evaluate(() => window.dispatchEvent(new Event("blur")));
|
||||
await expect(focus).toHaveCSS("opacity", "0");
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -23,7 +23,7 @@ export function ThemeToggleFixture() {
|
||||
</div>
|
||||
<div className="workbench-body">
|
||||
<section data-theme-surface className="workbench-pane flex flex-col gap-8 bg-background">
|
||||
<h1 data-testid="hero-greeting" data-theme-ink className="text-center text-4xl text-foreground">Where should we start?</h1>
|
||||
<h1 data-theme-ink className="text-center text-4xl text-foreground">Theme preview</h1>
|
||||
<ThreadComposer variant="hero" onSend={() => {}} />
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@@ -70,7 +70,7 @@ test("pointer selection after keyboard entry does not restore keyboard focus", a
|
||||
test("pointer dismissal outside a keyboard-opened menu does not refocus the trigger", async ({ page }) => {
|
||||
const trigger = page.locator(".thread-composer-access");
|
||||
await openWithKeyboard(page, trigger);
|
||||
const greeting = (await page.getByTestId("hero-greeting").boundingBox())!;
|
||||
await page.mouse.click(greeting.x + 8, greeting.y + 8);
|
||||
const mark = (await page.getByTestId("thread-welcome-mark").boundingBox())!;
|
||||
await page.mouse.click(mark.x + 8, mark.y + 8);
|
||||
await expectPointerDismissal(page, trigger);
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-12 -12 783 742" fill="none" stroke="black" stroke-width="7" stroke-linecap="round" stroke-linejoin="round">
|
||||
<metadata>Outline adapted from nanobot_mark.svg, distributed under the repository MIT license.</metadata>
|
||||
<path d="M229.029 127.134C308.64 112.113 354.143 106.879 379.029 108.134M379.029 716.634L272.029 715.634C251.029 715.634 243.029 702.634 201.529 678.134L54.5291 581.634C30.0291 565.134 23.9802 560.075 13.0291 549.134C3.52914 537.634 -1.97086 526.634 3.52914 481.634L28.0291 340.634L29.5291 27.1337C31.0291 -2.36625 53.0291 -6.86625 77.0291 12.6337L229.029 127.134" />
|
||||
<path d="M529.842 126.817C450.231 111.796 404.728 106.562 379.842 107.817M379.842 716.317L486.842 715.317C509.342 714.317 570.342 661.817 611.842 637.317L704.342 581.317C728.842 564.817 734.891 559.759 745.842 548.817C755.342 537.317 760.842 526.317 755.342 481.317L730.842 340.317L729.342 26.817C727.842 -2.68287 705.842 -7.18287 681.842 12.3171L529.842 126.817" />
|
||||
<path d="M143.342 497.317H1.84164C-6.15857 550.317 22.8417 557.817 56.3419 582.817L143.342 497.317Z" />
|
||||
<path d="M615.342 496.817H757.001C765.002 549.817 735.842 557.317 702.342 582.317L615.342 496.817Z" />
|
||||
<path d="M379.342 517.817H288.342C239.842 517.817 243.342 531.817 144.842 640.817L233.342 698.817C245.302 707.847 260.342 717.317 275.342 715.817L379.342 716.317" />
|
||||
<path d="M566.842 382.817C561.842 348.817 509.842 341.317 501.342 382.817V439.317C509.842 477.317 559.342 478.317 566.842 439.317V382.817Z" />
|
||||
<path d="M379.342 517.817H470.342C518.842 517.817 513.342 528.317 611.842 637.317L522.842 698.817C510.881 707.847 495.342 715.817 483.342 715.817L379.342 716.317" />
|
||||
<path d="M258.842 383.199C253.842 349.199 201.842 341.699 193.342 383.199V439.699C201.842 477.699 251.342 478.699 258.842 439.699V383.199Z" />
|
||||
<path d="M439.342 517.817H318.342L379.842 583.317L439.342 517.817Z" />
|
||||
<path d="M367.842 304.817L339.842 109.817C369.864 107.082 387.219 106.437 420.842 109.817L391.342 304.817C382.555 322.184 376.628 321.255 367.842 304.817Z" />
|
||||
<path d="M446.412 112.822C473.271 116.662 491.893 119.703 529.928 126.325L530.604 126.442L530.284 127.05L529.842 126.817L530.283 127.051C530.283 127.051 530.282 127.054 530.281 127.055C530.279 127.059 530.276 127.064 530.273 127.071C530.265 127.085 530.254 127.107 530.239 127.135C530.209 127.193 530.164 127.279 530.105 127.391C529.986 127.617 529.81 127.951 529.581 128.387C529.122 129.261 528.449 130.543 527.59 132.177C525.872 135.444 523.413 140.12 520.448 145.753C514.519 157.018 506.565 172.113 498.471 187.426C490.377 202.738 482.142 218.27 475.65 230.412C469.165 242.538 464.401 251.316 463.262 253.088C460.97 256.653 457.712 259.067 454.529 259.067C451.263 259.067 448.386 256.547 446.859 250.949C446.467 249.511 446.169 246.271 445.938 241.776C445.705 237.256 445.537 231.406 445.42 224.701C445.186 211.289 445.154 194.441 445.217 177.94C445.279 161.438 445.436 145.281 445.576 133.249C445.647 127.233 445.713 122.248 445.762 118.767C445.786 117.027 445.806 115.662 445.82 114.733C445.827 114.268 445.832 113.912 445.836 113.673C445.838 113.553 445.839 113.462 445.84 113.401C445.84 113.371 445.841 113.348 445.841 113.333C445.841 113.325 445.842 113.319 445.842 113.315C445.842 113.313 445.842 113.311 445.842 113.31C445.845 113.31 445.882 113.31 446.342 113.317L445.842 113.309L445.851 112.742L446.412 112.822Z" />
|
||||
<path d="M311.842 251.317C314.842 240.317 313.842 112.817 313.842 112.817C281.05 117.181 262.657 120.321 229.842 126.817C229.842 126.817 291.842 246.317 296.342 253.317C300.842 260.317 308.842 262.317 311.842 251.317Z" />
|
||||
<path d="M562.842 166.317L686.842 67.8171V278.317L562.842 166.317Z" />
|
||||
<path d="M196.342 166.317L72.3416 67.8171V278.317L196.342 166.317Z" />
|
||||
<path d="M737.842 377.317L737.497 377.487M737.497 377.487L625.342 432.817L752.342 465.817L737.497 377.487Z" />
|
||||
<path d="M20.9558 376.817L21.3031 376.986M21.3031 376.986L134.342 432.004L6.34164 464.817L21.3031 376.986Z" />
|
||||
<path d="M379.342 317.775V517.817" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
@@ -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>
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -1841,12 +1841,6 @@
|
||||
},
|
||||
"loadingConversation": "会話を読み込み中…",
|
||||
"empty": {
|
||||
"greetings": {
|
||||
"workOn": "一緒に何に取り組みましょうか?",
|
||||
"start": "今日はどこから始めましょう?",
|
||||
"build": "今日は何を作りましょうか?",
|
||||
"tackle": "一緒に何を解決しましょう?"
|
||||
},
|
||||
"quickActions": {
|
||||
"plan": {
|
||||
"title": "計画を立てる",
|
||||
|
||||
@@ -1841,12 +1841,6 @@
|
||||
},
|
||||
"loadingConversation": "대화 불러오는 중…",
|
||||
"empty": {
|
||||
"greetings": {
|
||||
"workOn": "우리 무엇을 함께 해볼까요?",
|
||||
"start": "오늘은 어디서 시작할까요?",
|
||||
"build": "오늘은 무엇을 만들어볼까요?",
|
||||
"tackle": "함께 무엇을 해결할까요?"
|
||||
},
|
||||
"quickActions": {
|
||||
"plan": {
|
||||
"title": "계획 세우기",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -2023,12 +2023,6 @@
|
||||
},
|
||||
"loadingConversation": "正在加载话题…",
|
||||
"empty": {
|
||||
"greetings": {
|
||||
"workOn": "我们要一起做点什么?",
|
||||
"start": "今天从哪里开始?",
|
||||
"build": "今天一起构建什么?",
|
||||
"tackle": "我们要一起解决什么?"
|
||||
},
|
||||
"quickActions": {
|
||||
"plan": {
|
||||
"title": "制定计划",
|
||||
|
||||
@@ -1841,12 +1841,6 @@
|
||||
},
|
||||
"loadingConversation": "正在載入話題…",
|
||||
"empty": {
|
||||
"greetings": {
|
||||
"workOn": "我們要一起做點什麼?",
|
||||
"start": "今天從哪裡開始?",
|
||||
"build": "今天要一起打造什麼?",
|
||||
"tackle": "我們要一起解決什麼?"
|
||||
},
|
||||
"quickActions": {
|
||||
"plan": {
|
||||
"title": "制定計劃",
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in new issue
Block a user