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:
chengyongru authored and GitHub committed 2026-10-21 13:10:05 +08:00
1 parent 73a55e0b2f
commit 743c51e81f
24 files changed
+1658 -356

No files matched your search

+60 -2
View File
@@ -1,5 +1,6 @@
import { describe, expect, it, vi } from "vitest";
import { type ThreadCameraFollowResult } from "@/components/thread/thread-camera";
import {
ThreadMotionCoordinator,
type ThreadMotionGeometry,
@@ -9,6 +10,7 @@ import {
function motionHarness(initial?: Partial<ThreadMotionGeometry>) {
let nextFrameId = 1;
let cameraFollowing = false;
let nextNavigationResult: ThreadCameraFollowResult = "started";
const frames = new Map<number, FrameRequestCallback>();
let geometry: ThreadMotionGeometry = {
scrollTop: 400,
@@ -39,8 +41,8 @@ function motionHarness(initial?: Partial<ThreadMotionGeometry>) {
followTo: vi.fn(() => "settled" as const),
isFollowing: vi.fn(() => cameraFollowing),
navigateTo: vi.fn(() => {
cameraFollowing = true;
return "started" as const;
cameraFollowing = nextNavigationResult === "started";
return nextNavigationResult;
}),
};
const onGeometry = vi.fn();
@@ -69,6 +71,9 @@ function motionHarness(initial?: Partial<ThreadMotionGeometry>) {
const setCameraFollowing = (following: boolean) => {
cameraFollowing = following;
};
const setNextNavigationResult = (result: ThreadCameraFollowResult) => {
nextNavigationResult = result;
};
return {
camera,
@@ -81,6 +86,7 @@ function motionHarness(initial?: Partial<ThreadMotionGeometry>) {
advanceFrame,
setCameraFollowing,
setGeometry,
setNextNavigationResult,
};
}
@@ -708,4 +714,56 @@ describe("ThreadMotionCoordinator", () => {
expect(camera.jumpTo.mock.calls).toEqual([[430], [458], [490]]);
});
it("retargets a prompt navigation from authoritative geometry without restarting the camera", () => {
const { camera, coordinator, measure, setGeometry } = motionHarness();
coordinator.navigateHistoryToPrompt("prompt-46");
expect(measure).toHaveBeenCalledWith("prompt-46");
expect(camera.navigateTo).toHaveBeenLastCalledWith(404);
expect(coordinator.snapshot().mode).toBe("navigating-history");
camera.cancel.mockClear();
setGeometry({ promptTop: 520 });
coordinator.reconcileObservedGeometry();
expect(camera.navigateTo).toHaveBeenLastCalledWith(520);
expect(camera.cancel).not.toHaveBeenCalled();
expect(coordinator.snapshot().mode).toBe("navigating-history");
});
it("releases prompt retarget ownership on composer input and user takeover", () => {
const { camera, coordinator, setGeometry } = motionHarness();
coordinator.navigateHistoryToPrompt("prompt-46");
camera.cancel.mockClear();
coordinator.handleComposerInput();
expect(camera.cancel).toHaveBeenCalledTimes(1);
expect(coordinator.snapshot().mode).toBe("browsing-history");
const callsAfterComposer = camera.navigateTo.mock.calls.length;
setGeometry({ promptTop: 600 });
coordinator.reconcileObservedGeometry();
expect(camera.navigateTo).toHaveBeenCalledTimes(callsAfterComposer);
coordinator.navigateHistoryToPrompt("prompt-47");
camera.cancel.mockClear();
coordinator.handleUserScrollIntent(true);
expect(camera.cancel).toHaveBeenCalledTimes(1);
expect(coordinator.snapshot().mode).toBe("browsing-history");
const callsAfterTouch = camera.navigateTo.mock.calls.length;
setGeometry({ promptTop: 700 });
coordinator.reconcileObservedGeometry();
expect(camera.navigateTo).toHaveBeenCalledTimes(callsAfterTouch);
});
it("drops prompt identity when an aligned navigation settles immediately", () => {
const { camera, coordinator, measure, setGeometry, setNextNavigationResult } = motionHarness();
setNextNavigationResult("settled");
expect(coordinator.navigateHistoryToPrompt("prompt-46")).toBe("settled");
expect(measure).toHaveBeenCalledWith("prompt-46");
expect(coordinator.snapshot().mode).toBe("browsing-history");
const callsAfterSettle = camera.navigateTo.mock.calls.length;
setGeometry({ promptTop: 720 });
coordinator.reconcileObservedGeometry();
expect(camera.navigateTo).toHaveBeenCalledTimes(callsAfterSettle);
expect(coordinator.snapshot().mode).toBe("browsing-history");
});
});