fix(webui): hide exhausted history hints at rest
Refs NAN-300
This commit is contained in:
1 parent
e44ebb164d
commit
f80956966b
5 files changed
+145
-28
No files matched your search
@@ -30,6 +30,21 @@ async function installHistory(page: Page) {
|
|||||||
return { reads, complete: (outcome: "success" | "error" = "success") => pending.shift()?.(outcome) };
|
return { reads, complete: (outcome: "success" | "error" = "success") => pending.shift()?.(outcome) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function installShortHistory(page: Page) {
|
||||||
|
let reads = 0;
|
||||||
|
await page.route("**/api/sessions/**", async (route) => {
|
||||||
|
const pathname = new URL(route.request().url()).pathname;
|
||||||
|
if (pathname.endsWith("/prompts")) return route.fulfill({ json: { prompts: [] } });
|
||||||
|
if (!pathname.endsWith("/webui-thread")) return route.fulfill({ json: {} });
|
||||||
|
reads++;
|
||||||
|
const history = historyPage(0, 1, false);
|
||||||
|
return route.fulfill({ json: { ...history, events: history.events.map((event) => ({
|
||||||
|
...event, text: event.event === "message" ? "Short answer." : event.text,
|
||||||
|
})) } });
|
||||||
|
});
|
||||||
|
return () => reads;
|
||||||
|
}
|
||||||
|
|
||||||
// Positioning is synthetic; gesture assertions below use browser wheel / CDP touch input.
|
// Positioning is synthetic; gesture assertions below use browser wheel / CDP touch input.
|
||||||
async function positionAtTop(body: Locator) {
|
async function positionAtTop(body: Locator) {
|
||||||
return body.evaluate((node) => {
|
return body.evaluate((node) => {
|
||||||
@@ -208,14 +223,81 @@ test("failure stays actionable away from the top; retry, fast completion and exh
|
|||||||
await expect(body.getByText(`Question ${start}`, { exact: true })).toBeAttached();
|
await expect(body.getByText(`Question ${start}`, { exact: true })).toBeAttached();
|
||||||
}
|
}
|
||||||
await positionAtTop(body);
|
await positionAtTop(body);
|
||||||
await expect(page.locator('.thread-history-status[data-state="exhausted"]')).toBeInViewport();
|
const exhausted = page.locator('.thread-history-status[data-state="exhausted"]');
|
||||||
|
await expect(exhausted).toHaveCount(0);
|
||||||
await body.hover();
|
await body.hover();
|
||||||
await page.mouse.wheel(0, -120);
|
await page.mouse.wheel(0, -120);
|
||||||
|
await expect(exhausted).toBeInViewport();
|
||||||
expect(await displacement(body)).toBe(0);
|
expect(await displacement(body)).toBe(0);
|
||||||
expect(history.reads).toHaveLength(5);
|
expect(history.reads).toHaveLength(5);
|
||||||
await page.screenshot({ path: "test-results/history-boundary-exhausted-dark.png" });
|
await page.screenshot({ path: "test-results/history-boundary-exhausted-dark.png" });
|
||||||
|
await expect(exhausted).toHaveCount(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for (const reducedMotion of ["no-preference", "reduce"] as const) {
|
||||||
|
test(`exhausted hints follow wheel and touch feedback, including settlement (${reducedMotion})`, async ({ page, browser, baseURL }) => {
|
||||||
|
await page.emulateMedia({ reducedMotion });
|
||||||
|
const reads = await installShortHistory(page);
|
||||||
|
await page.goto("/browser/fixture.html?case=history-boundary");
|
||||||
|
const body = page.getByTestId("thread-message-region");
|
||||||
|
const hint = page.getByText("No earlier messages", { exact: true });
|
||||||
|
await expect(body.getByText("Short answer.", { exact: true })).toBeVisible();
|
||||||
|
await stableLayout(body);
|
||||||
|
expect(await body.evaluate((node) => node.scrollHeight <= node.clientHeight)).toBe(true);
|
||||||
|
await expect(hint).toHaveCount(0);
|
||||||
|
await page.screenshot({ path: test.info().outputPath("exhausted-at-rest.png") });
|
||||||
|
await body.hover();
|
||||||
|
await page.mouse.wheel(80, 0);
|
||||||
|
await expect(hint).toHaveCount(0);
|
||||||
|
for (let attempt = 0; attempt < 2; attempt++) {
|
||||||
|
await page.mouse.wheel(0, -120);
|
||||||
|
await expect(hint).toBeVisible();
|
||||||
|
if (reducedMotion === "reduce") expect(await displacement(body)).toBe(0);
|
||||||
|
else await expect.poll(() => displacement(body)).toBeGreaterThan(0);
|
||||||
|
if (attempt === 0) await page.screenshot({ path: test.info().outputPath("exhausted-wheel.png") });
|
||||||
|
await expect(hint).toHaveCount(0);
|
||||||
|
expect(await displacement(body)).toBe(0);
|
||||||
|
expect(await body.evaluate((node) => node.scrollTop)).toBe(0);
|
||||||
|
}
|
||||||
|
expect(reads()).toBe(1);
|
||||||
|
await page.reload();
|
||||||
|
await expect(body.getByText("Short answer.", { exact: true })).toBeVisible();
|
||||||
|
await expect(hint).toHaveCount(0);
|
||||||
|
await body.hover();
|
||||||
|
await page.mouse.wheel(0, -120);
|
||||||
|
await expect(hint).toBeVisible();
|
||||||
|
await page.getByRole("button", { name: "Switch conversation" }).click();
|
||||||
|
await expect(hint).toHaveCount(0);
|
||||||
|
expect(await displacement(body)).toBe(0);
|
||||||
|
|
||||||
|
const context = await browser.newContext({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true, reducedMotion, baseURL });
|
||||||
|
try {
|
||||||
|
const touchPage = await context.newPage();
|
||||||
|
const touchReads = await installShortHistory(touchPage);
|
||||||
|
await touchPage.goto("/browser/fixture.html?case=history-boundary");
|
||||||
|
const touchBody = touchPage.getByTestId("thread-message-region");
|
||||||
|
const touchHint = touchPage.getByText("No earlier messages", { exact: true });
|
||||||
|
await expect(touchBody.getByText("Short answer.", { exact: true })).toBeVisible();
|
||||||
|
await stableLayout(touchBody);
|
||||||
|
await expect(touchHint).toHaveCount(0);
|
||||||
|
const cdp = await context.newCDPSession(touchPage);
|
||||||
|
const touch = (type: "touchStart" | "touchMove" | "touchEnd", y = 200) => cdp.send("Input.dispatchTouchEvent", {
|
||||||
|
type, touchPoints: type === "touchEnd" ? [] : [{ x: 180, y, id: 1 }],
|
||||||
|
});
|
||||||
|
await touch("touchStart");
|
||||||
|
await touch("touchMove", 300);
|
||||||
|
await expect(touchHint).toBeVisible();
|
||||||
|
if (reducedMotion === "reduce") expect(await displacement(touchBody)).toBe(0);
|
||||||
|
else expect(await displacement(touchBody)).toBeGreaterThan(0);
|
||||||
|
await touchPage.screenshot({ path: test.info().outputPath("exhausted-touch.png") });
|
||||||
|
await touch("touchEnd");
|
||||||
|
await expect(touchHint).toHaveCount(0);
|
||||||
|
expect(await displacement(touchBody)).toBe(0);
|
||||||
|
expect(touchReads()).toBe(1);
|
||||||
|
} finally { await context.close(); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
test("local cached windows expand without network loading and only the complete beginning is exhausted", async ({ page }) => {
|
test("local cached windows expand without network loading and only the complete beginning is exhausted", async ({ page }) => {
|
||||||
const history = await installHistory(page);
|
const history = await installHistory(page);
|
||||||
await page.goto("/browser/fixture.html?case=history-boundary&local=1");
|
await page.goto("/browser/fixture.html?case=history-boundary&local=1");
|
||||||
@@ -232,7 +314,12 @@ test("local cached windows expand without network loading and only the complete
|
|||||||
await positionAtTop(body);
|
await positionAtTop(body);
|
||||||
await expect(body.getByText("Cached message 0", { exact: true })).toBeAttached();
|
await expect(body.getByText("Cached message 0", { exact: true })).toBeAttached();
|
||||||
await positionAtTop(body);
|
await positionAtTop(body);
|
||||||
await expect(page.locator('.thread-history-status[data-state="exhausted"]')).toBeInViewport();
|
const exhausted = page.locator('.thread-history-status[data-state="exhausted"]');
|
||||||
|
await expect(exhausted).toHaveCount(0);
|
||||||
|
await body.hover();
|
||||||
|
await page.mouse.wheel(0, -120);
|
||||||
|
await expect(exhausted).toBeInViewport();
|
||||||
|
await expect(exhausted).toHaveCount(0);
|
||||||
expect(history.reads).toHaveLength(0);
|
expect(history.reads).toHaveLength(0);
|
||||||
await expect(page.locator('.thread-history-status[data-state="loading"]')).toHaveCount(0);
|
await expect(page.locator('.thread-history-status[data-state="loading"]')).toHaveCount(0);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -301,6 +301,7 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
|
|||||||
const composerDockHeightRef = useRef(0);
|
const composerDockHeightRef = useRef(0);
|
||||||
const [atBottom, setAtBottom] = useState(true);
|
const [atBottom, setAtBottom] = useState(true);
|
||||||
const [atHistoryTop, setAtHistoryTop] = useState(false);
|
const [atHistoryTop, setAtHistoryTop] = useState(false);
|
||||||
|
const [historyFeedbackActive, setHistoryFeedbackActive] = useState(false);
|
||||||
const historyInputRef = useRef<"touch" | "other">("other");
|
const historyInputRef = useRef<"touch" | "other">("other");
|
||||||
const historyTouchRef = useRef<{
|
const historyTouchRef = useRef<{
|
||||||
lastY: number; startX: number; startY: number; pulling: boolean; horizontal: boolean;
|
lastY: number; startX: number; startY: number; pulling: boolean; horizontal: boolean;
|
||||||
@@ -310,6 +311,7 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
|
|||||||
const historySpringRef = useRef<ThreadHistorySpring | null>(null);
|
const historySpringRef = useRef<ThreadHistorySpring | null>(null);
|
||||||
if (historySpringRef.current === null) {
|
if (historySpringRef.current === null) {
|
||||||
historySpringRef.current = new ThreadHistorySpring({
|
historySpringRef.current = new ThreadHistorySpring({
|
||||||
|
onFeedbackChange: setHistoryFeedbackActive,
|
||||||
onUpdate: (distance) => {
|
onUpdate: (distance) => {
|
||||||
// Presentation travel never becomes a scrollTop destination or an anchor correction.
|
// Presentation travel never becomes a scrollTop destination or an anchor correction.
|
||||||
historyDistanceRef.current = distance;
|
historyDistanceRef.current = distance;
|
||||||
@@ -396,6 +398,7 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
|
|||||||
[messages, visibleMessageCount],
|
[messages, visibleMessageCount],
|
||||||
);
|
);
|
||||||
const hiddenMessageCount = messages.length - visibleMessages.length;
|
const hiddenMessageCount = messages.length - visibleMessages.length;
|
||||||
|
const historyExhausted = !hasMoreBefore && hiddenMessageCount === 0;
|
||||||
const hiddenUserMessageCount =
|
const hiddenUserMessageCount =
|
||||||
userMessageOffset
|
userMessageOffset
|
||||||
+ (hiddenMessageCount > 0
|
+ (hiddenMessageCount > 0
|
||||||
@@ -1156,11 +1159,11 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
|
|||||||
</div>
|
</div>
|
||||||
{navigation && (navigation.loading || navigation.error) ? (
|
{navigation && (navigation.loading || navigation.error) ? (
|
||||||
<ThreadHistoryStatus ref={setHistoryStatus} loading={navigation.loading} error={navigation.error} onRetry={navigation.retry} />
|
<ThreadHistoryStatus ref={setHistoryStatus} loading={navigation.loading} error={navigation.error} onRetry={navigation.retry} />
|
||||||
) : messages.length > 0 && conversationReady && (atHistoryTop || loadingOlder || olderError) ? (
|
) : messages.length > 0 && conversationReady && ((atHistoryTop && (!historyExhausted || historyFeedbackActive)) || loadingOlder || olderError) ? (
|
||||||
<ThreadHistoryStatus
|
<ThreadHistoryStatus
|
||||||
ref={setHistoryStatus}
|
ref={setHistoryStatus}
|
||||||
loading={loadingOlder}
|
loading={loadingOlder}
|
||||||
exhausted={!hasMoreBefore && hiddenMessageCount === 0}
|
exhausted={historyExhausted}
|
||||||
error={olderError}
|
error={olderError}
|
||||||
onRetry={loadEarlierMessages}
|
onRetry={loadEarlierMessages}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const DAMPING_RATIO = 0.78;
|
|||||||
|
|
||||||
interface HistorySpringOptions {
|
interface HistorySpringOptions {
|
||||||
onUpdate: (distance: number) => void;
|
onUpdate: (distance: number) => void;
|
||||||
|
onFeedbackChange: (active: boolean) => void;
|
||||||
scheduler?: ThreadCameraScheduler;
|
scheduler?: ThreadCameraScheduler;
|
||||||
prefersReducedMotion?: () => boolean;
|
prefersReducedMotion?: () => boolean;
|
||||||
}
|
}
|
||||||
@@ -26,6 +27,7 @@ export class ThreadHistorySpring {
|
|||||||
private dragging = false;
|
private dragging = false;
|
||||||
private travel = 0;
|
private travel = 0;
|
||||||
private wheelLatched = false;
|
private wheelLatched = false;
|
||||||
|
private feedbackActive = false;
|
||||||
|
|
||||||
constructor(options: HistorySpringOptions) {
|
constructor(options: HistorySpringOptions) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
@@ -49,6 +51,7 @@ export class ThreadHistorySpring {
|
|||||||
if (this.dragging) return false;
|
if (this.dragging) return false;
|
||||||
const first = !this.wheelLatched && travel > 0;
|
const first = !this.wheelLatched && travel > 0;
|
||||||
this.wheelLatched = true;
|
this.wheelLatched = true;
|
||||||
|
if (travel > 0) this.setFeedbackActive(true);
|
||||||
// Wheel packets add pressure to one live spring, without a position jump.
|
// Wheel packets add pressure to one live spring, without a position jump.
|
||||||
const speed = FREQUENCY * (travel > 0
|
const speed = FREQUENCY * (travel > 0
|
||||||
? HISTORY_PULL_LIMIT_PX - Math.max(0, this.distance)
|
? HISTORY_PULL_LIMIT_PX - Math.max(0, this.distance)
|
||||||
@@ -61,6 +64,7 @@ export class ThreadHistorySpring {
|
|||||||
startTouch(): void {
|
startTouch(): void {
|
||||||
this.stopFrame();
|
this.stopFrame();
|
||||||
this.dragging = true;
|
this.dragging = true;
|
||||||
|
this.setFeedbackActive(true);
|
||||||
this.velocity = 0;
|
this.velocity = 0;
|
||||||
this.travel = -RESISTANCE_LENGTH_PX
|
this.travel = -RESISTANCE_LENGTH_PX
|
||||||
* Math.log(Math.max(Number.EPSILON, 1 - Math.max(0, this.distance) / HISTORY_PULL_LIMIT_PX));
|
* Math.log(Math.max(Number.EPSILON, 1 - Math.max(0, this.distance) / HISTORY_PULL_LIMIT_PX));
|
||||||
@@ -85,6 +89,7 @@ export class ThreadHistorySpring {
|
|||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.dragging = false;
|
this.dragging = false;
|
||||||
this.wheelLatched = false;
|
this.wheelLatched = false;
|
||||||
|
this.setFeedbackActive(false);
|
||||||
this.animate();
|
this.animate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,10 +101,18 @@ export class ThreadHistorySpring {
|
|||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.dragging = false;
|
this.dragging = false;
|
||||||
this.wheelLatched = false;
|
this.wheelLatched = false;
|
||||||
|
this.setFeedbackActive(false);
|
||||||
this.publish();
|
this.publish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private setFeedbackActive(active: boolean): void {
|
||||||
|
if (this.feedbackActive === active) return;
|
||||||
|
this.feedbackActive = active;
|
||||||
|
this.options.onFeedbackChange(active);
|
||||||
|
}
|
||||||
|
|
||||||
private publish(): void {
|
private publish(): void {
|
||||||
|
// Reduced motion suppresses travel, not the input/settlement lifecycle.
|
||||||
this.options.onUpdate(this.reducedMotion() ? 0 : Math.max(0, this.distance));
|
this.options.onUpdate(this.reducedMotion() ? 0 : Math.max(0, this.distance));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,16 +123,12 @@ export class ThreadHistorySpring {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private animate(): void {
|
private animate(): void {
|
||||||
if (this.reducedMotion()) {
|
|
||||||
this.distance = 0;
|
|
||||||
this.velocity = 0;
|
|
||||||
this.stopFrame();
|
|
||||||
this.publish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.frame !== null) return;
|
if (this.frame !== null) return;
|
||||||
if (this.distance === (this.loading ? LOADING_POCKET_PX : 0) && this.velocity === 0) {
|
if (this.distance === (this.loading ? LOADING_POCKET_PX : 0) && this.velocity === 0) {
|
||||||
if (!this.loading) this.wheelLatched = false;
|
if (!this.loading) {
|
||||||
|
this.wheelLatched = false;
|
||||||
|
this.setFeedbackActive(false);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.timestamp = this.scheduler.now();
|
this.timestamp = this.scheduler.now();
|
||||||
@@ -128,13 +137,6 @@ export class ThreadHistorySpring {
|
|||||||
|
|
||||||
private readonly advance = (timestamp: number): void => {
|
private readonly advance = (timestamp: number): void => {
|
||||||
this.frame = null;
|
this.frame = null;
|
||||||
if (this.reducedMotion()) {
|
|
||||||
this.distance = 0;
|
|
||||||
this.velocity = 0;
|
|
||||||
this.timestamp = null;
|
|
||||||
this.publish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const seconds = Math.max(0, timestamp - (this.timestamp ?? timestamp)) / 1000;
|
const seconds = Math.max(0, timestamp - (this.timestamp ?? timestamp)) / 1000;
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
const target = this.loading ? LOADING_POCKET_PX : 0;
|
const target = this.loading ? LOADING_POCKET_PX : 0;
|
||||||
@@ -155,7 +157,10 @@ export class ThreadHistorySpring {
|
|||||||
this.distance = target;
|
this.distance = target;
|
||||||
this.velocity = 0;
|
this.velocity = 0;
|
||||||
this.timestamp = null;
|
this.timestamp = null;
|
||||||
if (!this.loading) this.wheelLatched = false;
|
if (!this.loading) {
|
||||||
|
this.wheelLatched = false;
|
||||||
|
this.setFeedbackActive(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.publish();
|
this.publish();
|
||||||
if (!settled) this.frame = this.scheduler.request(this.advance);
|
if (!settled) this.frame = this.scheduler.request(this.advance);
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ function harness(reduced = false) {
|
|||||||
request: vi.fn((callback: FrameRequestCallback) => { frames.set(++nextId, callback); return nextId; }),
|
request: vi.fn((callback: FrameRequestCallback) => { frames.set(++nextId, callback); return nextId; }),
|
||||||
cancel: (id: number) => { frames.delete(id); },
|
cancel: (id: number) => { frames.delete(id); },
|
||||||
};
|
};
|
||||||
|
const feedback = vi.fn();
|
||||||
const spring = new ThreadHistorySpring({ scheduler, prefersReducedMotion: () => reduced,
|
const spring = new ThreadHistorySpring({ scheduler, prefersReducedMotion: () => reduced,
|
||||||
onUpdate: (next) => { distance = next; } });
|
onFeedbackChange: feedback, onUpdate: (next) => { distance = next; } });
|
||||||
const advance = (milliseconds = 16) => {
|
const advance = (milliseconds = 16) => {
|
||||||
now += milliseconds;
|
now += milliseconds;
|
||||||
const callbacks = [...frames.values()];
|
const callbacks = [...frames.values()];
|
||||||
@@ -21,7 +22,7 @@ function harness(reduced = false) {
|
|||||||
return distance;
|
return distance;
|
||||||
};
|
};
|
||||||
const settle = () => { for (let i = 0; i < 100 && frames.size; i++) advance(); };
|
const settle = () => { for (let i = 0; i < 100 && frames.size; i++) advance(); };
|
||||||
return { spring, scheduler, advance, settle, frames, distance: () => distance };
|
return { spring, scheduler, advance, settle, frames, feedback, distance: () => distance };
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("history boundary spring", () => {
|
describe("history boundary spring", () => {
|
||||||
@@ -70,9 +71,11 @@ describe("history boundary spring", () => {
|
|||||||
h.advance();
|
h.advance();
|
||||||
}
|
}
|
||||||
expect(requests).toBe(1);
|
expect(requests).toBe(1);
|
||||||
|
expect(h.feedback.mock.calls).toEqual([[true]]);
|
||||||
expect(h.distance()).toBeLessThan(HISTORY_PULL_LIMIT_PX);
|
expect(h.distance()).toBeLessThan(HISTORY_PULL_LIMIT_PX);
|
||||||
h.settle();
|
h.settle();
|
||||||
expect(h.distance()).toBe(0);
|
expect(h.distance()).toBe(0);
|
||||||
|
expect(h.feedback.mock.calls).toEqual([[true], [false]]);
|
||||||
expect(h.spring.wheel(100)).toBe(true);
|
expect(h.spring.wheel(100)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -93,7 +96,16 @@ describe("history boundary spring", () => {
|
|||||||
expect(h.distance()).toBe(0);
|
expect(h.distance()).toBe(0);
|
||||||
expect(h.spring.endTouch()).toBe(true);
|
expect(h.spring.endTouch()).toBe(true);
|
||||||
h.spring.setLoading(true);
|
h.spring.setLoading(true);
|
||||||
expect(h.frames.size).toBe(0);
|
|
||||||
expect(h.distance()).toBe(0);
|
expect(h.distance()).toBe(0);
|
||||||
|
h.settle();
|
||||||
|
expect(h.frames.size).toBe(0);
|
||||||
|
h.spring.setLoading(false);
|
||||||
|
h.settle();
|
||||||
|
expect(h.feedback.mock.calls).toEqual([[true], [false]]);
|
||||||
|
h.spring.wheel(100);
|
||||||
|
expect(h.feedback).toHaveBeenLastCalledWith(true);
|
||||||
|
h.settle();
|
||||||
|
expect(h.distance()).toBe(0);
|
||||||
|
expect(h.feedback).toHaveBeenLastCalledWith(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1857,14 +1857,24 @@ describe("ThreadViewport", () => {
|
|||||||
expect(onRender).not.toHaveBeenCalled();
|
expect(onRender).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows the confirmed start of conversation with boundary feedback", async () => {
|
it("shows the confirmed start only during boundary feedback and clears it on conversation changes", async () => {
|
||||||
const onLoadOlder = vi.fn();
|
const onLoadOlder = vi.fn();
|
||||||
const { container } = render(<ThreadViewport messages={messages} isStreaming={false}
|
const props = { messages, isStreaming: false, onLoadOlder };
|
||||||
onLoadOlder={onLoadOlder} />);
|
const { container, rerender } = render(<ThreadViewport {...props} conversationKey="a" />);
|
||||||
fireEvent.wheel(getScroller(container), { deltaY: -100 });
|
const scroller = getScroller(container);
|
||||||
|
expect(screen.queryByText("No earlier messages")).not.toBeInTheDocument();
|
||||||
|
fireEvent.wheel(scroller, { deltaY: -100 });
|
||||||
expect(screen.getByText("hello")).toBeVisible();
|
expect(screen.getByText("hello")).toBeVisible();
|
||||||
expect(screen.getByText("No earlier messages")).toBeVisible();
|
expect(screen.getByText("No earlier messages")).toBeVisible();
|
||||||
await waitFor(() => expect(historyPull(getScroller(container))).toBeGreaterThan(0));
|
await waitFor(() => expect(historyPull(scroller)).toBeGreaterThan(0));
|
||||||
|
await waitFor(() => expect(screen.queryByText("No earlier messages")).not.toBeInTheDocument());
|
||||||
|
expect(historyPull(scroller)).toBe(0);
|
||||||
|
expect(scroller.scrollTop).toBe(0);
|
||||||
|
fireEvent.wheel(scroller, { deltaY: -100 });
|
||||||
|
expect(screen.getByText("No earlier messages")).toBeVisible();
|
||||||
|
rerender(<ThreadViewport {...props} conversationKey="b" />);
|
||||||
|
expect(screen.queryByText("No earlier messages")).not.toBeInTheDocument();
|
||||||
|
expect(historyPull(scroller)).toBe(0);
|
||||||
expect(onLoadOlder).not.toHaveBeenCalled();
|
expect(onLoadOlder).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user