fix(webui): stabilize earlier-history loading and reclaim space (#6349)
* fix(webui): retain smoothly revealed history loading headers * refactor(webui): simplify history loading feedback * fix(webui): keep retained history headers clear of preceding text * fix(webui): reclaim completed history loading space * refactor(webui): group history projection handoff with navigation * test(webui): synchronize history motion observations * fix(webui): collapse history completion geometry handoff
This commit is contained in:
1 parent
73a55e0b2f
commit
743c51e81f
24 files changed
+1658
-356
No files matched your search
@@ -55,6 +55,27 @@ it("loads the complete index without bodies, reads bounded windows and leaves li
|
||||
expect(latest).toHaveLength(1);
|
||||
});
|
||||
|
||||
it.each(["older", "newer"] as const)("keeps one pending %s page when boundary inputs arrive before the next render", async (operation) => {
|
||||
const { result } = renderHook(() => usePromptHistory("a", 1, latest), { wrapper: wrapper() });
|
||||
await waitFor(() => expect(result.current.prompts).toHaveLength(2000));
|
||||
await act(async () => result.current.jump("u10"));
|
||||
let finish!: (body: WebuiThreadPersistedPayload) => void;
|
||||
vi.mocked(api.fetchWebuiThread).mockImplementationOnce(() => new Promise((resolve) => { finish = resolve; }));
|
||||
const load = result.current[operation];
|
||||
act(() => {
|
||||
load();
|
||||
load();
|
||||
});
|
||||
expect(api.fetchWebuiThread).toHaveBeenCalledTimes(2);
|
||||
const options = vi.mocked(api.fetchWebuiThread).mock.lastCall?.[2];
|
||||
if (typeof options !== "object") throw new Error("expected page options");
|
||||
expect(options.signal?.aborted).toBe(false);
|
||||
expect(result.current.loading).toBe(true);
|
||||
await act(async () => finish(page(operation === "older" ? 9 : 11)));
|
||||
expect(result.current.loading).toBe(false);
|
||||
expect(result.current.window?.messages).toHaveLength(4);
|
||||
});
|
||||
|
||||
it("keeps the current page on failure and offers retry; superseded jumps and session reads cannot win", async () => {
|
||||
const { result, rerender } = renderHook(({ key }) => usePromptHistory(key, 1, latest), {
|
||||
wrapper: wrapper(), initialProps: { key: "a" },
|
||||
@@ -175,3 +196,28 @@ it("merges a live input by transport identity without adding an anchor or reorde
|
||||
expect(result.current.window).toBeNull();
|
||||
expect(result.current.target).toBeNull();
|
||||
});
|
||||
|
||||
|
||||
it("keeps the request operation with failures and retries", async () => {
|
||||
const { result } = renderHook(() => usePromptHistory("a", 1, latest), { wrapper: wrapper() });
|
||||
await waitFor(() => expect(result.current.prompts).toHaveLength(2000));
|
||||
let finish!: (body: WebuiThreadPersistedPayload) => void;
|
||||
vi.mocked(api.fetchWebuiThread).mockImplementationOnce(() => new Promise((resolve) => { finish = resolve; }));
|
||||
act(() => result.current.jump("u10"));
|
||||
expect(result.current.operation).toBe("jump");
|
||||
expect(result.current.loading).toBe(true);
|
||||
await act(async () => finish(page(10)));
|
||||
expect(result.current.operation).toBeNull();
|
||||
|
||||
for (const operation of ["older", "newer"] as const) {
|
||||
vi.mocked(api.fetchWebuiThread).mockRejectedValueOnce(new Error("offline"));
|
||||
await act(async () => result.current[operation]());
|
||||
expect(result.current.operation).toBe(operation);
|
||||
expect(result.current.error).toBe("offline");
|
||||
await act(async () => result.current.retry());
|
||||
expect(result.current.operation).toBeNull();
|
||||
expect(result.current.error).toBeNull();
|
||||
}
|
||||
act(() => result.current.cancel());
|
||||
expect(result.current.operation).toBeNull();
|
||||
});
|
||||
Reference in new issue
Block a user