Problem
backend/src/routes/chat.ts:141–166 — the GET /chat endpoint fetches every chat the user owns plus every chat in every project they own, with no limit:
const { data, error } = await db
.from("chats")
.select("*")
.or(filter)
.order("created_at", { ascending: false });
// no .limit()
For an active user with hundreds of chats (or an owner of a busy shared project), this is a large unbounded response on every page load, blocking the sidebar render.
Fix
Add limit / cursor-based pagination. A default of 50 chats per page is reasonable. The sidebar already renders a list — it can lazy-load older chats on scroll.
const limit = Math.min(Number(req.query.limit) || 50, 200);
const before = req.query.before as string | undefined; // ISO timestamp cursor
// ...
let q = db.from("chats").select("*").or(filter).order("created_at", { ascending: false }).limit(limit);
if (before) q = q.lt("created_at", before);
Problem
backend/src/routes/chat.ts:141–166— theGET /chatendpoint fetches every chat the user owns plus every chat in every project they own, with no limit:For an active user with hundreds of chats (or an owner of a busy shared project), this is a large unbounded response on every page load, blocking the sidebar render.
Fix
Add
limit/ cursor-based pagination. A default of 50 chats per page is reasonable. The sidebar already renders a list — it can lazy-load older chats on scroll.