mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-05-20 00:56:41 +00:00
bug fix
This commit is contained in:
parent
c1aa4b19cd
commit
5995effa32
1 changed files with 10 additions and 3 deletions
|
|
@ -194,12 +194,16 @@ export const updateChatSession = internalMutation({
|
|||
memoriesRetrieved: v.array(v.string()),
|
||||
},
|
||||
handler: async (ctx, args) => {
|
||||
const MAX_MESSAGES = 500
|
||||
if (args.sessionId) {
|
||||
// Update existing session
|
||||
const session = await ctx.db.get(args.sessionId)
|
||||
if (session) {
|
||||
const messages = [...session.messages, args.newMessage].slice(
|
||||
-MAX_MESSAGES,
|
||||
)
|
||||
await ctx.db.patch(args.sessionId, {
|
||||
messages: [...session.messages, args.newMessage],
|
||||
messages,
|
||||
memoriesRetrieved: [
|
||||
...new Set([
|
||||
...session.memoriesRetrieved,
|
||||
|
|
@ -240,13 +244,16 @@ export const trackChatMessage = mutation({
|
|||
memoriesRetrieved: v.array(v.string()),
|
||||
},
|
||||
handler: async (ctx, args) => {
|
||||
// Inline the logic instead of calling another mutation
|
||||
const MAX_MESSAGES = 500
|
||||
if (args.sessionId) {
|
||||
// Update existing session
|
||||
const session = await ctx.db.get(args.sessionId)
|
||||
if (session) {
|
||||
const messages = [...session.messages, args.newMessage].slice(
|
||||
-MAX_MESSAGES,
|
||||
)
|
||||
await ctx.db.patch(args.sessionId, {
|
||||
messages: [...session.messages, args.newMessage],
|
||||
messages,
|
||||
memoriesRetrieved: [
|
||||
...new Set([
|
||||
...session.memoriesRetrieved,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue