Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR reduces over-fetching in the /souls browse listing by adding and using an index that targets active (non-soft-deleted) souls directly, and adds a focused regression test to ensure the optimized query shape is preserved.
Changes:
- Add
souls.by_active_updatedcompound index (softDeletedAt,updatedAt) to support efficient active-only browsing. - Update
souls.listbrowse mode to use the new index andtake(limit)instead oftake(limit * 5)with JS-side filtering/slicing. - Add a regression test asserting the browse query uses the active index and respects the requested limit; rename a shadowed local in the CLI auth route.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/routes/cli/auth.tsx | Renames a shadowed local variable used for redirect URL construction to satisfy linting. |
| convex/souls.ts | Switches browse listing to an active-only indexed query and removes JS-side overfetch filtering. |
| convex/souls.test.ts | Adds regression coverage to assert browse listing uses the active index and only takes limit. |
| convex/schema.ts | Adds the missing by_active_updated index to the souls table schema. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Greptile SummaryThis PR fixes the
Confidence Score: 4/5Safe to merge once the sort-order change is acknowledged or corrected — no data loss or security risk, but browsing order changes silently. One P1 finding: the browse listing's sort order silently changes from _creationTime to updatedAt. This is a real behavioural difference that the PR description claims doesn't exist. If the change is intentional (aligning with listPublicPage), confirming that and documenting it would make this ready to merge at 5/5. convex/souls.ts — browse path ordering and owner-path over-fetch
|
| const entries = await ctx.db | ||
| .query("souls") | ||
| .withIndex("by_active_updated", (q) => q.eq("softDeletedAt", undefined)) | ||
| .order("desc") | ||
| .take(limit * 5); | ||
| .take(limit); |
There was a problem hiding this comment.
Silent sort-order change:
_creationTime → updatedAt
The old scan (no index, .order("desc")) sorted by _creationTime — Convex's default ordering. The new by_active_updated index is ["softDeletedAt", "updatedAt"], so after the equality constraint on softDeletedAt the remaining sort key is updatedAt. The browse listing will now return souls ordered by most-recently-updated rather than most-recently-created, which is a silent behavioral change. The PR description says "keeps the behavior the same," but the sort order is different. If this is intentional (aligning with listPublicPage's by_updated ordering), please call it out explicitly in the description.
Prompt To Fix With AI
This is a comment left during a code review.
Path: convex/souls.ts
Line: 139-143
Comment:
**Silent sort-order change: `_creationTime` → `updatedAt`**
The old scan (no index, `.order("desc")`) sorted by `_creationTime` — Convex's default ordering. The new `by_active_updated` index is `["softDeletedAt", "updatedAt"]`, so after the equality constraint on `softDeletedAt` the remaining sort key is `updatedAt`. The browse listing will now return souls ordered by most-recently-*updated* rather than most-recently-*created*, which is a silent behavioral change. The PR description says "keeps the behavior the same," but the sort order is different. If this is intentional (aligning with `listPublicPage`'s `by_updated` ordering), please call it out explicitly in the description.
How can I resolve this? If you propose a fix, please make it concise.|
Thanks. I checked the ordering concern before merging. For I’m treating the owner-branch overfetch as follow-up scope, not a blocker for this patch. |
Summary
souls.by_active_updatedindex so browse queries can target active souls directlysouls.listbrowse mode to readlimitactive rows instead oflimit * 5rows filtered in JSsrc/routes/cli/auth.tsxso lint passes cleanlyWhy
The previous browse listing path over-read soul documents and then filtered soft-deleted rows in application code. That meant requests like
/soulswithlimit=500could read up to 2500 rows to return 500 visible items.This patch keeps the behavior the same while making the browse path ask Convex for active rows directly.
Verification
bun run lintbun x vitest run convex/souls.test.ts src/routes/cli/-auth.test.tsbun run buildNotes
bunx convex codegenis blocked in this shell because noCONVEX_DEPLOYMENTis configured here.