fix(webui): unblock earlier-history pagination and show retry states (#5934)

* fix(webui): show history pagination loading and retry states

* fix(webui): load earlier history on backward input at top

* fix(webui): use pull gestures and spinners for history loading

* fix(webui): shorten history loading failure messages

* refactor(webui): simplify history pagination guards and tests
This commit is contained in:
chengyongru authored and GitHub committed 2026-09-27 21:06:59 +08:00
1 parent db6ef4d674
commit 33dddaaa46
17 files changed
+533 -28

No files matched your search

+15 -3
View File
@@ -138,6 +138,7 @@ interface SessionHistoryState {
messages: UIMessage[];
loading: boolean;
loadingOlder: boolean;
olderError: string | null;
error: string | null;
hasPendingToolCalls: boolean;
completedTurnIds: string[];
@@ -157,6 +158,7 @@ function emptyHistoryState(key: string | null, loading = false): SessionHistoryS
messages: [],
loading,
loadingOlder: false,
olderError: null,
error: null,
hasPendingToolCalls: false,
completedTurnIds: [],
@@ -183,6 +185,7 @@ function cachedHistoryState(
messages,
loading: false,
loadingOlder: false,
olderError: null,
error: null,
hasPendingToolCalls: hasPendingToolCallsFromThread(body, messages),
completedTurnIds: completedTurnIdsFromThread(body),
@@ -384,6 +387,7 @@ export function useSessionHistory(key: string | null): {
messages: UIMessage[];
loading: boolean;
loadingOlder: boolean;
olderError: string | null;
error: string | null;
refresh: () => void;
loadOlder: () => Promise<void>;
@@ -492,6 +496,10 @@ export function useSessionHistory(key: string | null): {
messages: merged.messages,
loading: false,
loadingOlder: false,
olderError: merged.continuity === "overlap"
&& (retainedPrefix || prev.beforeCursor === body?.page?.before_cursor)
? prev.olderError
: null,
error: null,
hasPendingToolCalls: hasPending,
completedTurnIds,
@@ -532,6 +540,7 @@ export function useSessionHistory(key: string | null): {
messages: [],
loading: false,
loadingOlder: false,
olderError: null,
error: null,
hasPendingToolCalls: false,
completedTurnIds: [],
@@ -573,7 +582,7 @@ export function useSessionHistory(key: string | null): {
const controller = new AbortController();
olderRequestAbortRef.current = controller;
setState((prev) => matchesRequest(prev)
? { ...prev, loadingOlder: true, error: null }
? { ...prev, loadingOlder: true, olderError: null }
: prev);
try {
const body = await fetchWebuiThread(getToken(), requestKey, {
@@ -604,7 +613,7 @@ export function useSessionHistory(key: string | null): {
...prev,
messages: nextMessages,
loadingOlder: false,
error: null,
olderError: null,
forkBoundaryMessageCount: olderBoundary ?? shiftedBoundary,
beforeCursor: body.page?.before_cursor ?? null,
hasMoreBefore: body.page?.has_more_before === true,
@@ -617,7 +626,7 @@ export function useSessionHistory(key: string | null): {
? {
...prev,
loadingOlder: false,
error: (e as Error).message,
olderError: (e as Error).message || "Could not load earlier messages",
}
: prev);
} finally {
@@ -640,6 +649,7 @@ export function useSessionHistory(key: string | null): {
messages: EMPTY_MESSAGES,
loading: false,
loadingOlder: false,
olderError: null,
error: null,
refresh,
loadOlder,
@@ -662,6 +672,7 @@ export function useSessionHistory(key: string | null): {
messages: EMPTY_MESSAGES,
loading: true,
loadingOlder: false,
olderError: null,
error: null,
refresh,
loadOlder,
@@ -681,6 +692,7 @@ export function useSessionHistory(key: string | null): {
messages: state.messages,
loading: state.loading,
loadingOlder: state.loadingOlder,
olderError: state.olderError,
error: state.error,
refresh,
loadOlder,