From 7ad24b56c8db3c8a5fadf28183c8b34ccc5836cf Mon Sep 17 00:00:00 2001 From: Lyon <88232613+pikasTech@users.noreply.github.com> Date: Wed, 24 Jun 2026 05:15:01 +0800 Subject: [PATCH] fix(workbench): return latest messages by default (#2015) --- internal/cloud/server-workbench-http.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/cloud/server-workbench-http.ts b/internal/cloud/server-workbench-http.ts index e4e50c58..0214304a 100644 --- a/internal/cloud/server-workbench-http.ts +++ b/internal/cloud/server-workbench-http.ts @@ -1446,7 +1446,9 @@ async function handleWorkbenchMessagePage(request, response, url, options, actor } const messages = factMessagesForSession(session, result.facts); const limit = boundedLimit(url.searchParams.get("limit")); - const offset = cursorOffset(url.searchParams.get("cursor") ?? url.searchParams.get("after")); + 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; const resolvedSessionId = factSessionId(session);