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
@@ -11,8 +11,9 @@ function harness(reduced = false) {
|
||||
request: vi.fn((callback: FrameRequestCallback) => { frames.set(++nextId, callback); return nextId; }),
|
||||
cancel: (id: number) => { frames.delete(id); },
|
||||
};
|
||||
const feedback = vi.fn();
|
||||
const spring = new ThreadHistorySpring({ scheduler, prefersReducedMotion: () => reduced,
|
||||
onUpdate: (next) => { distance = next; } });
|
||||
onFeedbackChange: feedback, onUpdate: (next) => { distance = next; } });
|
||||
const advance = (milliseconds = 16) => {
|
||||
now += milliseconds;
|
||||
const callbacks = [...frames.values()];
|
||||
@@ -21,7 +22,7 @@ function harness(reduced = false) {
|
||||
return distance;
|
||||
};
|
||||
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", () => {
|
||||
@@ -70,9 +71,11 @@ describe("history boundary spring", () => {
|
||||
h.advance();
|
||||
}
|
||||
expect(requests).toBe(1);
|
||||
expect(h.feedback.mock.calls).toEqual([[true]]);
|
||||
expect(h.distance()).toBeLessThan(HISTORY_PULL_LIMIT_PX);
|
||||
h.settle();
|
||||
expect(h.distance()).toBe(0);
|
||||
expect(h.feedback.mock.calls).toEqual([[true], [false]]);
|
||||
expect(h.spring.wheel(100)).toBe(true);
|
||||
});
|
||||
|
||||
@@ -93,7 +96,16 @@ describe("history boundary spring", () => {
|
||||
expect(h.distance()).toBe(0);
|
||||
expect(h.spring.endTouch()).toBe(true);
|
||||
h.spring.setLoading(true);
|
||||
expect(h.frames.size).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();
|
||||
});
|
||||
|
||||
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 { container } = render(<ThreadViewport messages={messages} isStreaming={false}
|
||||
onLoadOlder={onLoadOlder} />);
|
||||
fireEvent.wheel(getScroller(container), { deltaY: -100 });
|
||||
const props = { messages, isStreaming: false, onLoadOlder };
|
||||
const { container, rerender } = render(<ThreadViewport {...props} conversationKey="a" />);
|
||||
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("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();
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user