fix(webui): restore full-project typechecking
This commit is contained in:
1 parent
f869212e7d
commit
a1bca7dc50
56 files changed
+622
-583
No files matched your search
@@ -19,16 +19,6 @@ vi.mock("@/lib/api", async (importOriginal) => {
|
||||
};
|
||||
});
|
||||
|
||||
const fetchThreadMock = vi.mocked(api.fetchWebuiThread);
|
||||
const rawMockResolvedValue = fetchThreadMock.mockResolvedValue.bind(fetchThreadMock);
|
||||
const rawMockResolvedValueOnce = fetchThreadMock.mockResolvedValueOnce.bind(fetchThreadMock);
|
||||
fetchThreadMock.mockResolvedValue = ((value) => rawMockResolvedValue(
|
||||
canonicalThreadPayload(value as never),
|
||||
)) as typeof fetchThreadMock.mockResolvedValue;
|
||||
fetchThreadMock.mockResolvedValueOnce = ((value) => rawMockResolvedValueOnce(
|
||||
canonicalThreadPayload(value as never),
|
||||
)) as typeof fetchThreadMock.mockResolvedValueOnce;
|
||||
|
||||
function fakeClient() {
|
||||
const sessionUpdateHandlers = new Set<(chatId: string, scope?: string) => void>();
|
||||
return {
|
||||
@@ -466,7 +456,7 @@ describe("useSessions", () => {
|
||||
});
|
||||
|
||||
it("passes through WebUI transcript user media as images and media", async () => {
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue({
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{
|
||||
@@ -486,7 +476,7 @@ describe("useSessions", () => {
|
||||
{ id: "a1", role: "assistant", content: "it's a cat", createdAt: 2 },
|
||||
{ id: "u2", role: "user", content: "follow-up without images", createdAt: 3 },
|
||||
],
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(() => useSessionHistory("websocket:chat-media"), {
|
||||
wrapper: wrap(fakeClient()),
|
||||
@@ -510,7 +500,7 @@ describe("useSessions", () => {
|
||||
});
|
||||
|
||||
it("passes through assistant video media from transcript replay", async () => {
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue({
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{
|
||||
@@ -521,7 +511,7 @@ describe("useSessions", () => {
|
||||
media: [{ kind: "video", url: "/api/media/sig-v/payload-v", name: "clip.mp4" }],
|
||||
},
|
||||
],
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(() => useSessionHistory("websocket:chat-video"), {
|
||||
wrapper: wrap(fakeClient()),
|
||||
@@ -537,7 +527,7 @@ describe("useSessions", () => {
|
||||
});
|
||||
|
||||
it("passes through assistant reasoning from transcript replay", async () => {
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue({
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{
|
||||
@@ -548,7 +538,7 @@ describe("useSessions", () => {
|
||||
reasoning: "hidden but persisted reasoning",
|
||||
},
|
||||
],
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(() => useSessionHistory("websocket:chat-reasoning"), {
|
||||
wrapper: wrap(fakeClient()),
|
||||
@@ -563,7 +553,7 @@ describe("useSessions", () => {
|
||||
});
|
||||
|
||||
it("accepts transcript rows produced by the server replay reducer", async () => {
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue({
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{ id: "u1", role: "user", content: "research this", createdAt: 1 },
|
||||
@@ -577,7 +567,7 @@ describe("useSessions", () => {
|
||||
},
|
||||
{ id: "a1", role: "assistant", content: "summary", createdAt: 3 },
|
||||
],
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(() => useSessionHistory("websocket:chat-tools"), {
|
||||
wrapper: wrap(fakeClient()),
|
||||
@@ -596,7 +586,7 @@ describe("useSessions", () => {
|
||||
});
|
||||
|
||||
it("projects canonical transcript events with the live event reducer", async () => {
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue({
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue(api.parseWebuiThreadPayload({
|
||||
schemaVersion: 3,
|
||||
projection: "events",
|
||||
events: [
|
||||
@@ -646,7 +636,7 @@ describe("useSessions", () => {
|
||||
turn_seq: 5,
|
||||
},
|
||||
],
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(() => useSessionHistory("websocket:chat-event-history"), {
|
||||
wrapper: wrap(fakeClient()),
|
||||
@@ -665,13 +655,13 @@ describe("useSessions", () => {
|
||||
});
|
||||
|
||||
it("shows a cached transcript immediately while revalidating it", async () => {
|
||||
const cached = {
|
||||
const cached = canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
revision: "rev-cached",
|
||||
messages: [
|
||||
{ id: "a1", role: "assistant" as const, content: "cached answer", createdAt: 1 },
|
||||
{ id: "a1", role: "assistant", content: "cached answer", createdAt: 1 },
|
||||
],
|
||||
};
|
||||
});
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValueOnce(cached);
|
||||
|
||||
const first = renderHook(() => useSessionHistory("websocket:cached"), {
|
||||
@@ -731,7 +721,8 @@ describe("useSessions", () => {
|
||||
resolve: (body: Awaited<ReturnType<typeof api.fetchWebuiThread>>) => void;
|
||||
signal: AbortSignal | undefined;
|
||||
}> = [];
|
||||
vi.mocked(api.fetchWebuiThread).mockImplementation((_token, _key, options) => new Promise((resolve) => {
|
||||
vi.mocked(api.fetchWebuiThread).mockImplementation((_token, _key, optionsOrBase) => new Promise((resolve) => {
|
||||
const options = typeof optionsOrBase === "string" ? undefined : optionsOrBase;
|
||||
requests.push({ resolve, signal: options?.signal });
|
||||
}));
|
||||
const first = renderHook(() => useSessionHistory("websocket:shared-reconnect"), {
|
||||
@@ -773,13 +764,13 @@ describe("useSessions", () => {
|
||||
});
|
||||
|
||||
it("keeps rendered history visible when its LRU entry was evicted before refresh", async () => {
|
||||
const loaded = {
|
||||
const loaded = canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
revision: "rev-loaded",
|
||||
messages: [
|
||||
{ id: "a1", role: "assistant" as const, content: "still visible", createdAt: 1 },
|
||||
{ id: "a1", role: "assistant", content: "still visible", createdAt: 1 },
|
||||
],
|
||||
};
|
||||
});
|
||||
vi.mocked(api.fetchWebuiThread)
|
||||
.mockResolvedValueOnce(loaded)
|
||||
.mockImplementationOnce(() => new Promise(() => {}));
|
||||
@@ -801,7 +792,7 @@ describe("useSessions", () => {
|
||||
});
|
||||
|
||||
it("flags transcript ending with a trace row as pending", async () => {
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue({
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{
|
||||
@@ -813,7 +804,7 @@ describe("useSessions", () => {
|
||||
createdAt: 1,
|
||||
},
|
||||
],
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(() => useSessionHistory("websocket:chat-pending"), {
|
||||
wrapper: wrap(fakeClient()),
|
||||
@@ -825,7 +816,7 @@ describe("useSessions", () => {
|
||||
});
|
||||
|
||||
it("uses the server pending flag for completed tails that still end with trace rows", async () => {
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue({
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
has_pending_tool_calls: false,
|
||||
messages: [
|
||||
@@ -846,7 +837,7 @@ describe("useSessions", () => {
|
||||
createdAt: 2,
|
||||
},
|
||||
],
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(() => useSessionHistory("websocket:chat-cron-done"), {
|
||||
wrapper: wrap(fakeClient()),
|
||||
@@ -891,7 +882,7 @@ describe("useSessions", () => {
|
||||
active_turn_id: "incomplete-turn",
|
||||
completed_turn_ids: [],
|
||||
events: [
|
||||
{ event: "user_message", chat_id: "incomplete", text: "question", turn_id: "incomplete-turn" },
|
||||
{ event: "user_message", chat_id: "incomplete", text: "question", turn_id: "incomplete-turn", starts_turn: true },
|
||||
{ event: "turn_end", chat_id: "incomplete", turn_id: "incomplete-turn" },
|
||||
],
|
||||
});
|
||||
@@ -905,12 +896,12 @@ describe("useSessions", () => {
|
||||
});
|
||||
|
||||
it("does not flag transcript as pending when last row is not a trace", async () => {
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue({
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{ id: "a1", role: "assistant", content: "All done", createdAt: 1 },
|
||||
],
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(() => useSessionHistory("websocket:chat-done"), {
|
||||
wrapper: wrap(fakeClient()),
|
||||
@@ -936,12 +927,12 @@ describe("useSessions", () => {
|
||||
|
||||
it("does not reload history when only the auth token rotates", async () => {
|
||||
const tokenSource = { current: "tok-old" };
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue({
|
||||
vi.mocked(api.fetchWebuiThread).mockResolvedValue(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{ id: "a1", role: "assistant", content: "stable", createdAt: 1 },
|
||||
],
|
||||
});
|
||||
}));
|
||||
|
||||
const { result, rerender } = renderHook(
|
||||
() => useSessionHistory("websocket:token-rotation"),
|
||||
@@ -979,12 +970,12 @@ describe("useSessions", () => {
|
||||
reject(new DOMException("Aborted", "AbortError"));
|
||||
});
|
||||
}))
|
||||
.mockResolvedValueOnce({
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{ id: "a2", role: "assistant", content: "latest", createdAt: 2 },
|
||||
],
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(
|
||||
() => useSessionHistory("websocket:superseded"),
|
||||
@@ -1003,7 +994,7 @@ describe("useSessions", () => {
|
||||
|
||||
it("loads older transcript pages before the current history", async () => {
|
||||
vi.mocked(api.fetchWebuiThread)
|
||||
.mockResolvedValueOnce({
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{ id: "u2", role: "user", content: "new question", createdAt: 2 },
|
||||
@@ -1012,11 +1003,11 @@ describe("useSessions", () => {
|
||||
page: {
|
||||
before_cursor: "cursor-2",
|
||||
has_more_before: true,
|
||||
loaded_message_count: 2,
|
||||
loaded_event_count: 2,
|
||||
user_message_offset: 1,
|
||||
},
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
}))
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{ id: "u1", role: "user", content: "old question", createdAt: 0 },
|
||||
@@ -1025,10 +1016,10 @@ describe("useSessions", () => {
|
||||
page: {
|
||||
before_cursor: null,
|
||||
has_more_before: false,
|
||||
loaded_message_count: 2,
|
||||
loaded_event_count: 2,
|
||||
user_message_offset: 0,
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(() => useSessionHistory("websocket:paged"), {
|
||||
wrapper: wrap(fakeClient()),
|
||||
@@ -1078,7 +1069,7 @@ describe("useSessions", () => {
|
||||
|
||||
it("keeps older-history failures separate and retries them explicitly", async () => {
|
||||
vi.mocked(api.fetchWebuiThread)
|
||||
.mockResolvedValueOnce({
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{ id: "u2", role: "user", content: "latest question", createdAt: 2 },
|
||||
@@ -1086,12 +1077,12 @@ describe("useSessions", () => {
|
||||
page: {
|
||||
before_cursor: "cursor-2",
|
||||
has_more_before: true,
|
||||
loaded_message_count: 1,
|
||||
loaded_event_count: 1,
|
||||
user_message_offset: 1,
|
||||
},
|
||||
})
|
||||
}))
|
||||
.mockRejectedValueOnce(new Error("offline"))
|
||||
.mockResolvedValueOnce({
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{ id: "u1", role: "user", content: "earliest question", createdAt: 1 },
|
||||
@@ -1099,10 +1090,10 @@ describe("useSessions", () => {
|
||||
page: {
|
||||
before_cursor: null,
|
||||
has_more_before: false,
|
||||
loaded_message_count: 1,
|
||||
loaded_event_count: 1,
|
||||
user_message_offset: 0,
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(() => useSessionHistory("websocket:retry-older"), {
|
||||
wrapper: wrap(fakeClient()),
|
||||
@@ -1125,19 +1116,19 @@ describe("useSessions", () => {
|
||||
});
|
||||
|
||||
it("preserves a failed history cursor on refresh but clears it for another session", async () => {
|
||||
const latest = {
|
||||
schemaVersion: 3 as const,
|
||||
messages: [{ id: "u2", role: "user" as const, content: "question", createdAt: 2 }],
|
||||
const latest = canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [{ id: "u2", role: "user", content: "question", createdAt: 2 }],
|
||||
page: {
|
||||
before_cursor: "cursor-2", has_more_before: true,
|
||||
loaded_message_count: 1, user_message_offset: 1,
|
||||
loaded_event_count: 1, user_message_offset: 1,
|
||||
},
|
||||
};
|
||||
});
|
||||
vi.mocked(api.fetchWebuiThread)
|
||||
.mockResolvedValueOnce(latest)
|
||||
.mockRejectedValueOnce(new Error("offline"))
|
||||
.mockResolvedValueOnce({ ...latest })
|
||||
.mockResolvedValueOnce({ schemaVersion: 3, messages: [] });
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({ schemaVersion: 3, messages: [] }));
|
||||
const { result, rerender } = renderHook(({ sessionKey }) => useSessionHistory(sessionKey), {
|
||||
initialProps: { sessionKey: "websocket:failed-prefix" },
|
||||
wrapper: wrap(fakeClient()),
|
||||
@@ -1161,7 +1152,7 @@ describe("useSessions", () => {
|
||||
it("aborts an older-history request when the consumer unmounts", async () => {
|
||||
let olderSignal: AbortSignal | undefined;
|
||||
vi.mocked(api.fetchWebuiThread)
|
||||
.mockResolvedValueOnce({
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{ id: "u2", role: "user", content: "latest question", createdAt: 2 },
|
||||
@@ -1169,10 +1160,10 @@ describe("useSessions", () => {
|
||||
page: {
|
||||
before_cursor: "cursor-2",
|
||||
has_more_before: true,
|
||||
loaded_message_count: 1,
|
||||
loaded_event_count: 1,
|
||||
user_message_offset: 1,
|
||||
},
|
||||
})
|
||||
}))
|
||||
.mockImplementationOnce((_token, _key, optionsOrBase) => new Promise((_resolve, reject) => {
|
||||
if (typeof optionsOrBase !== "string") olderSignal = optionsOrBase?.signal;
|
||||
olderSignal?.addEventListener("abort", () => {
|
||||
@@ -1200,7 +1191,7 @@ describe("useSessions", () => {
|
||||
|
||||
it("preserves a loaded prefix when a canonical latest window overlaps its tail", async () => {
|
||||
vi.mocked(api.fetchWebuiThread)
|
||||
.mockResolvedValueOnce({
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
has_pending_tool_calls: true,
|
||||
messages: [
|
||||
@@ -1210,11 +1201,11 @@ describe("useSessions", () => {
|
||||
page: {
|
||||
before_cursor: "cursor-middle",
|
||||
has_more_before: true,
|
||||
loaded_message_count: 2,
|
||||
loaded_event_count: 2,
|
||||
user_message_offset: 1,
|
||||
},
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
}))
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{ id: "u1", role: "user", content: "old question", createdAt: 0 },
|
||||
@@ -1223,11 +1214,11 @@ describe("useSessions", () => {
|
||||
page: {
|
||||
before_cursor: null,
|
||||
has_more_before: false,
|
||||
loaded_message_count: 2,
|
||||
loaded_event_count: 2,
|
||||
user_message_offset: 0,
|
||||
},
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
}))
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
has_pending_tool_calls: false,
|
||||
completed_turn_ids: ["turn-3"],
|
||||
@@ -1251,10 +1242,10 @@ describe("useSessions", () => {
|
||||
page: {
|
||||
before_cursor: "cursor-shifted",
|
||||
has_more_before: true,
|
||||
loaded_message_count: 3,
|
||||
loaded_event_count: 3,
|
||||
user_message_offset: 1,
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(() => useSessionHistory("websocket:paged-refresh"), {
|
||||
wrapper: wrap(fakeClient()),
|
||||
@@ -1302,22 +1293,22 @@ describe("useSessions", () => {
|
||||
createdAt: 1_000 + index,
|
||||
}));
|
||||
vi.mocked(api.fetchWebuiThread)
|
||||
.mockResolvedValueOnce({
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: oldWindow,
|
||||
page: {
|
||||
before_cursor: "old-window-cursor",
|
||||
has_more_before: true,
|
||||
},
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
}))
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: newWindow,
|
||||
page: {
|
||||
before_cursor: "new-window-cursor",
|
||||
has_more_before: true,
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(() => useSessionHistory("websocket:window-reset"), {
|
||||
wrapper: wrap(fakeClient()),
|
||||
@@ -1339,7 +1330,7 @@ describe("useSessions", () => {
|
||||
|
||||
it("uses the longest consecutive semantic overlap for legacy unstable replay metadata", async () => {
|
||||
vi.mocked(api.fetchWebuiThread)
|
||||
.mockResolvedValueOnce({
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{ id: "repeat-1-old", role: "user", content: "repeat", createdAt: 10 },
|
||||
@@ -1351,8 +1342,8 @@ describe("useSessions", () => {
|
||||
before_cursor: "legacy-cursor",
|
||||
has_more_before: true,
|
||||
},
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
}))
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{ id: "old-prefix", role: "user", content: "old prefix", createdAt: 1 },
|
||||
@@ -1361,8 +1352,8 @@ describe("useSessions", () => {
|
||||
before_cursor: null,
|
||||
has_more_before: false,
|
||||
},
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
}))
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{ id: "repeat-2-new", role: "user", content: "repeat", createdAt: 9_012 },
|
||||
@@ -1373,7 +1364,7 @@ describe("useSessions", () => {
|
||||
before_cursor: "shifted-legacy-cursor",
|
||||
has_more_before: true,
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(() => useSessionHistory("websocket:legacy-overlap"), {
|
||||
wrapper: wrap(fakeClient()),
|
||||
@@ -1405,7 +1396,7 @@ describe("useSessions", () => {
|
||||
| ((value: Awaited<ReturnType<typeof api.fetchWebuiThread>>) => void)
|
||||
| null = null;
|
||||
vi.mocked(api.fetchWebuiThread)
|
||||
.mockResolvedValueOnce({
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{ id: "old-latest", role: "assistant", content: "old latest", createdAt: 10 },
|
||||
@@ -1414,11 +1405,11 @@ describe("useSessions", () => {
|
||||
before_cursor: "cursor-old-lineage",
|
||||
has_more_before: true,
|
||||
},
|
||||
})
|
||||
}))
|
||||
.mockImplementationOnce(() => new Promise((resolve) => {
|
||||
resolveOlder = resolve;
|
||||
}))
|
||||
.mockResolvedValueOnce({
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{ id: "new-latest", role: "assistant", content: "new latest", createdAt: 20 },
|
||||
@@ -1427,7 +1418,7 @@ describe("useSessions", () => {
|
||||
before_cursor: "cursor-new-lineage",
|
||||
has_more_before: true,
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(() => useSessionHistory("websocket:paged-race"), {
|
||||
wrapper: wrap(fakeClient()),
|
||||
@@ -1466,7 +1457,7 @@ describe("useSessions", () => {
|
||||
|
||||
it("preserves authoritative active state while prepending older history", async () => {
|
||||
vi.mocked(api.fetchWebuiThread)
|
||||
.mockResolvedValueOnce({
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
has_pending_tool_calls: true,
|
||||
messages: [
|
||||
@@ -1476,11 +1467,11 @@ describe("useSessions", () => {
|
||||
page: {
|
||||
before_cursor: "cursor-active",
|
||||
has_more_before: true,
|
||||
loaded_message_count: 2,
|
||||
loaded_event_count: 2,
|
||||
user_message_offset: 1,
|
||||
},
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
}))
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
has_pending_tool_calls: false,
|
||||
messages: [
|
||||
@@ -1490,10 +1481,10 @@ describe("useSessions", () => {
|
||||
page: {
|
||||
before_cursor: null,
|
||||
has_more_before: false,
|
||||
loaded_message_count: 2,
|
||||
loaded_event_count: 2,
|
||||
user_message_offset: 0,
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(() => useSessionHistory("websocket:paged-active"), {
|
||||
wrapper: wrap(fakeClient()),
|
||||
@@ -1513,7 +1504,7 @@ describe("useSessions", () => {
|
||||
|
||||
it("preserves authoritative completed state while prepending trace history", async () => {
|
||||
vi.mocked(api.fetchWebuiThread)
|
||||
.mockResolvedValueOnce({
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
has_pending_tool_calls: false,
|
||||
messages: [
|
||||
@@ -1529,11 +1520,11 @@ describe("useSessions", () => {
|
||||
page: {
|
||||
before_cursor: "cursor-complete",
|
||||
has_more_before: true,
|
||||
loaded_message_count: 1,
|
||||
loaded_event_count: 1,
|
||||
user_message_offset: 1,
|
||||
},
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
}))
|
||||
.mockResolvedValueOnce(canonicalThreadPayload({
|
||||
schemaVersion: 3,
|
||||
messages: [
|
||||
{ id: "u1", role: "user", content: "old question", createdAt: 0 },
|
||||
@@ -1542,10 +1533,10 @@ describe("useSessions", () => {
|
||||
page: {
|
||||
before_cursor: null,
|
||||
has_more_before: false,
|
||||
loaded_message_count: 2,
|
||||
loaded_event_count: 2,
|
||||
user_message_offset: 0,
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
const { result } = renderHook(() => useSessionHistory("websocket:paged-complete"), {
|
||||
wrapper: wrap(fakeClient()),
|
||||
|
||||
Reference in new issue
Block a user