mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-18 14:08:21 +00:00
Some checks are pending
Backend Unit Tests / Build packages (push) Waiting to run
Backend Unit Tests / Codegraph select (push) Waiting to run
Backend Unit Tests / TypeScript type checks (push) Blocked by required conditions
Backend Unit Tests / Circular dependency checks (push) Waiting to run
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Vote Gate / Gate (push) Waiting to run
Codegraph E2E Votes / vote (shard 1/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 10/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 2/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 3/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 4/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 5/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 6/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 7/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 8/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 9/10) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/chat (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
* perf: Index Hot Lookups and Make Message Cursor Pagination Stable Add narrow indexes for session refresh-token deletes, user-only tool call deletes, queued-turn delivery and reconciliation claims, agent code environment references, and updatedAt message pages. Add a TTL index to the KeyvMongo collection. getMessagesByCursor now sorts and pages on a unique (sortField, _id) tiebreaker with a millisecond-precise cursor while still accepting legacy cursors, and GET /api/messages caps pageSize in a TypeScript helper. * fix: Keep the Message Id for the Cursor Under the Client Projection * fix: Declare select on the Message Cursor Method Type * feat: Make the Message Page Size Ceiling Configurable * fix: Clamp the Default Message Page Size to the Configured Ceiling * test: Cover Message Cursor Paging and Page Size Cap End to End * fix: Continue Message Cursors Whose Sort Value Is Empty * fix: Include Missing Sort Values When Paging Messages Descending * perf: Resolve the Message Page Ceiling Beside the Ownership Read * fix: Observe the Ownership Read While the Page Size Resolves * style: Sort Imports in the Message Page Module * refactor: Move Page Size Read Observation Into the API Package * fix: Keep Missing and Empty Sort Values Distinct in the Message Cursor * fix: Page Past Messages With a Missing Timestamp
89 lines
3.1 KiB
TypeScript
89 lines
3.1 KiB
TypeScript
import { randomUUID } from 'node:crypto';
|
|
import { expect, test } from '@playwright/test';
|
|
import { getE2EUser } from '../../../setup/user';
|
|
import {
|
|
deleteConversations,
|
|
deleteMessagesByConversation,
|
|
seedConversations,
|
|
withMongo,
|
|
} from '../db';
|
|
import { NEW_CHAT_PATH, getAccessToken, requestJson } from '../helpers';
|
|
|
|
type Page = { messages: { messageId: string; _id?: string }[]; nextCursor: string | null };
|
|
|
|
async function seedTied(conversationId: string, count: number): Promise<string[]> {
|
|
const at = new Date('2026-01-01T00:00:00.123Z');
|
|
await seedConversations(getE2EUser().email, [{ conversationId, title: 'cursor', updatedAt: at }]);
|
|
return withMongo(async (db) => {
|
|
const user = await db.collection('users').findOne({ email: getE2EUser().email });
|
|
const rows = Array.from({ length: count }, (_, index) => ({
|
|
messageId: `cursor-${index}-${randomUUID()}`,
|
|
conversationId,
|
|
user: String(user?._id),
|
|
text: `message ${index}`,
|
|
sender: 'User',
|
|
isCreatedByUser: false,
|
|
createdAt: at,
|
|
updatedAt: at,
|
|
__v: 0,
|
|
}));
|
|
await db.collection('messages').insertMany(rows);
|
|
return rows.map((row) => row.messageId);
|
|
});
|
|
}
|
|
|
|
test.describe('message cursor and page size', () => {
|
|
const conversationIds: string[] = [];
|
|
test.afterEach(async () => {
|
|
await deleteMessagesByConversation(conversationIds);
|
|
await deleteConversations(conversationIds);
|
|
conversationIds.length = 0;
|
|
});
|
|
|
|
test('@scenario:message-pages-share-timestamp-without-skips messages sharing one timestamp are all returned across pages', async ({
|
|
page,
|
|
}) => {
|
|
const conversationId = randomUUID();
|
|
conversationIds.push(conversationId);
|
|
const seeded = await seedTied(conversationId, 7);
|
|
await page.goto(NEW_CHAT_PATH);
|
|
const token = await getAccessToken(page);
|
|
|
|
const seen: string[] = [];
|
|
let cursor: string | null = null;
|
|
for (let index = 0; index < 10; index++) {
|
|
const query = new URLSearchParams({ conversationId, pageSize: '3' });
|
|
if (cursor) {
|
|
query.set('cursor', cursor);
|
|
}
|
|
const result: Page = await requestJson<Page>(page, {
|
|
path: `/api/messages?${query.toString()}`,
|
|
token,
|
|
});
|
|
expect(result.messages.every((message) => message._id === undefined)).toBe(true);
|
|
seen.push(...result.messages.map((message) => message.messageId));
|
|
cursor = result.nextCursor;
|
|
if (!cursor) {
|
|
break;
|
|
}
|
|
}
|
|
expect(seen).toHaveLength(7);
|
|
expect(new Set(seen)).toEqual(new Set(seeded));
|
|
});
|
|
|
|
test('@scenario:message-page-size-capped an oversized pageSize returns a bounded page', async ({
|
|
page,
|
|
}) => {
|
|
const conversationId = randomUUID();
|
|
conversationIds.push(conversationId);
|
|
await seedTied(conversationId, 4);
|
|
await page.goto(NEW_CHAT_PATH);
|
|
const token = await getAccessToken(page);
|
|
const result = await requestJson<Page>(page, {
|
|
path: `/api/messages?conversationId=${conversationId}&pageSize=999999999`,
|
|
token,
|
|
});
|
|
expect(result.messages).toHaveLength(4);
|
|
expect(result.nextCursor).toBeNull();
|
|
});
|
|
});
|