fix(webui): navigate complete prompt history with bounded pages

This commit is contained in:
Xubin Ren committed 2026-10-18 17:13:18 +08:00
1 parent 5f6e8a6baa
commit bf1eada575
20 files changed
+949 -401

No files matched your search

+21
View File
@@ -21,6 +21,7 @@ import type {
ModelConfigurationUpdate,
NetworkSafetySettingsUpdate,
PairingPayload,
PromptSummary,
ProviderCreationUpdate,
ProviderModelsPayload,
ProviderOAuthCompletionResult,
@@ -235,6 +236,7 @@ export interface FetchWebuiThreadOptions {
limit?: number;
direction?: "latest";
before?: string | null;
after?: string | null;
signal?: AbortSignal;
revision?: string;
cached?: WebuiThreadPersistedPayload;
@@ -418,6 +420,7 @@ export async function fetchWebuiThread(
if (options?.limit !== undefined) params.set("limit", String(options.limit));
if (options?.direction) params.set("direction", options.direction);
if (options?.before) params.set("before", options.before);
if (options?.after) params.set("after", options.after);
const query = params.toString();
const suffix = query ? `?${query}` : "";
const url = `${resolvedBase}/api/sessions/${encodeURIComponent(key)}/webui-thread${suffix}`;
@@ -435,6 +438,24 @@ export async function fetchWebuiThread(
return parseWebuiThreadPayload(await res.json());
}
export async function fetchPromptIndex(token: string, key: string, signal: AbortSignal): Promise<PromptSummary[]> {
const res = await fetchWithTimeout(`/api/sessions/${encodeURIComponent(key)}/webui-thread/prompts`, {
headers: { Authorization: `Bearer ${token}` }, credentials: "same-origin", cache: "no-store", signal,
});
if (!res.ok) throw new ApiError(res.status, `HTTP ${res.status}`);
const body: unknown = await res.json();
if (!isRecord(body) || !Array.isArray(body.prompts)) throw new Error("Invalid prompt index");
return body.prompts.map((item: unknown) => {
if (!isRecord(item) || typeof item.id !== "string" || typeof item.preview !== "string"
|| typeof item.answerPreview !== "string" || typeof item.cursor !== "string" || typeof item.turnId !== "string"
|| typeof item.createdAt !== "number" || !Number.isFinite(item.createdAt)) {
throw new Error("Invalid prompt summary");
}
return { id: item.id, preview: item.preview, answerPreview: item.answerPreview,
cursor: item.cursor, createdAt: item.createdAt, turnId: item.turnId };
});
}
export async function fetchWebuiThreadTraceDetail(
token: string,
key: string,
+11
View File
@@ -1690,10 +1690,21 @@ export interface OutboundMcpPresetMention {
interface WebuiThreadPagePayload {
before_cursor?: string | null;
has_more_before?: boolean;
after_cursor?: string | null;
has_more_after?: boolean;
user_message_offset?: number;
loaded_event_count?: number;
}
export interface PromptSummary {
id: string;
preview: string;
answerPreview: string;
createdAt: number;
cursor: string;
turnId: string;
}
export interface WebuiThreadPersistedPayload {
schemaVersion: number;
sessionKey?: string;