-
Notifications
You must be signed in to change notification settings - Fork 51
Daily branch 2026 01 19 #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Replace O(n) query that fetched all user files and filtered in JS with O(1) direct index lookup by storage_id. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughReplace scan-based user file lookup with a direct Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant Convex as Convex Function
participant DB as Database (files table)
participant S3 as S3 / Storage Service
Client->>Convex: request getFileDownloadUrl(storage_id)
Convex->>DB: query files by_storage_id index (storage_id)
DB-->>Convex: file record or null
alt file found and owner matches
Convex->>S3: generate signed URL for `s3_key`
S3-->>Convex: signed URL
Convex-->>Client: return signed URL
else not found or ownership mismatch
Convex-->>Client: throw FILE_NOT_FOUND
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
package.json (1)
46-109: Address breaking changes in Stripe v20 and AWS SDK v3 upgrades.The upgrades introduce breaking changes that require code updates:
Stripe Node.js v20: API version pinned to 2025-12-15.clover; resource namespaces (V2.Core, Account/AccountPerson/AccountToken) restructured; method and field names changed. Update import statements and type signatures; audit all Stripe API call sites and ensure call signatures match the v20 schema.
AWS SDK v3 (
@aws-sdk/client-s3,@aws-sdk/s3-request-presigner): Modular package structure changed; presigner moved to separate package with new Command/Client pattern (getSignedUrl signature changed); PutObject parameter handling differs (signature mismatches possible with ContentDisposition, ServerSideEncryption, ACL, StorageClass); Node.js 16.x support dropped in newer v3 versions. Verify S3 upload flow end-to-end, ensure client upload headers match those in presigned URL generation, and confirm Node.js runtime meets SDK engine requirements.Next.js 16.1.3 and PostHog-js v1.329.0 contain only bug fixes and no breaking changes.
- getUserChats: batch fetch branched chat titles using Promise.all and Map lookup instead of N+1 individual queries per branched chat - deleteAllChats: batch fetch messages, files, and summaries in parallel instead of nested sequential loops, reducing ~10k queries to ~200 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Batch fetch branched chat titles using Promise.all and Map lookup instead of N+1 individual queries per branched chat in paginated results. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@convex/chats.ts`:
- Around line 741-767: The current code batches all chats with userChats ->
Promise.all(... .collect()) and then does Promise.all(fileIds.map(id =>
ctx.db.get(id))), which can exceed Convex read/memory and per-mutation call
limits; replace unbounded .collect() and Promise.all usage by streaming queries
with for await (const row of query) or using query.paginate() per chat to
accumulate messages without loading everything into memory, and limit concurrent
db.get calls (e.g., batch fileIds or use a bounded concurrency worker) when
building fileMap; update the blocks around allMessagesPerChat, the .collect()
call on ctx.db.query("messages").withIndex("by_chat_id", ...) and the files =
await Promise.all(fileIds.map(... ctx.db.get ...)) to use streaming/pagination
and bounded batching to avoid hitting Convex limits.
Process chats in chunks of 5 to stay under Convex's 16MB single-function read limit. Still batches file/message fetches within each chunk for efficiency. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The optimized versions caused errors. Reverting to the stable original implementation that processes chats sequentially. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
convex/chats.ts (1)
452-519: Add areturnsvalidator forgetUserChats.The
getUserChatsquery function (line 452) omits areturnsvalidator, which is required for all Convex functions per coding guidelines. Add the return schema to match the paginated chat shape with the enrichedbranched_from_titlefield.Suggested fix
export const getUserChats = query({ args: { paginationOpts: paginationOptsValidator, }, + returns: v.object({ + page: v.array( + v.object({ + _id: v.id("chats"), + _creationTime: v.number(), + id: v.string(), + title: v.string(), + user_id: v.string(), + finish_reason: v.optional(v.string()), + active_stream_id: v.optional(v.string()), + canceled_at: v.optional(v.number()), + default_model_slug: v.optional( + v.union(v.literal("ask"), v.literal("agent")), + ), + todos: v.optional( + v.array( + v.object({ + id: v.string(), + content: v.string(), + status: v.union( + v.literal("pending"), + v.literal("in_progress"), + v.literal("completed"), + v.literal("cancelled"), + ), + sourceMessageId: v.optional(v.string()), + }), + ), + ), + branched_from_chat_id: v.optional(v.string()), + branched_from_title: v.optional(v.string()), + latest_summary_id: v.optional(v.id("chat_summaries")), + share_id: v.optional(v.string()), + share_date: v.optional(v.number()), + update_time: v.number(), + }), + ), + isDone: v.boolean(), + continueCursor: v.string(), + }), handler: async (ctx, args) => {
Summary by CodeRabbit
New Features
Performance Improvements
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.