fix(workbench): query latest message facts by default (#2016)
This commit is contained in:
@@ -1436,7 +1436,13 @@ async function handleWorkbenchSessionDetail(request, response, options, actor, s
|
||||
|
||||
async function handleWorkbenchMessagePage(request, response, url, options, actor, sessionId) {
|
||||
const readModel = workbenchRuntimeFactsReadModel(request, options, actor);
|
||||
const result = await queryFactsByRouteId(readModel, sessionId, { families: WORKBENCH_SESSION_MESSAGE_PAGE_FAMILIES });
|
||||
const limit = boundedLimit(url.searchParams.get("limit"));
|
||||
const cursorParam = url.searchParams.get("cursor") ?? url.searchParams.get("after");
|
||||
const hasCursor = Boolean(textValue(cursorParam));
|
||||
const result = await queryFactsByRouteId(readModel, sessionId, {
|
||||
families: WORKBENCH_SESSION_MESSAGE_PAGE_FAMILIES,
|
||||
...(hasCursor ? {} : { limit, messagesOrder: "updated_desc", partsOrder: "updated_desc", turnsOrder: "updated_desc", checkpointsOrder: "updated_desc" })
|
||||
});
|
||||
if (result.error) return sendJson(response, 503, workbenchProjectionStoreError(result.error));
|
||||
const session = visibleFactSessions(result.facts, actor)[0] ?? null;
|
||||
if (!session) {
|
||||
@@ -1445,9 +1451,6 @@ async function handleWorkbenchMessagePage(request, response, url, options, actor
|
||||
return sendJson(response, 404, body);
|
||||
}
|
||||
const messages = factMessagesForSession(session, result.facts);
|
||||
const limit = boundedLimit(url.searchParams.get("limit"));
|
||||
const cursorParam = url.searchParams.get("cursor") ?? url.searchParams.get("after");
|
||||
const hasCursor = Boolean(textValue(cursorParam));
|
||||
const offset = hasCursor ? cursorOffset(cursorParam) : Math.max(0, messages.length - limit);
|
||||
const page = messages.slice(offset, offset + limit);
|
||||
const nextOffset = offset + page.length;
|
||||
|
||||
Reference in New Issue
Block a user