Skip to content

fix(chat): check storage size for chat history #7958

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

julialeex
Copy link
Contributor

This PR implemented automatic chat history cleanup that removes oldest conversations when storage exceeds STORAGE_SIZE_BIG. Uses an optimized algorithm to identify and trim the oldest chats while preserving newer conversations. Added constants to make the threshold and number of chats to remove configurable.

Right now STORAGE_SIZE_BIG is set to 50k KB, and NUM_CHATS_TO_TRIM (the maximum number of chats to trim) is set to 5.

Test plan

Tested locally.
Have at least 6 conversations in the chat history. Change STORAGE_SIZE_BIG to a small number (ex: 5000) and check if the chat gets deleted once the storage size is too big.

Copy link
Contributor

@abeatrix abeatrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of removing the chat history automatically, should we show a banner and ask users to remove / export their chat history themselves?
#7953 (comment)

}
}

console.log(`Trimming ${oldestChats.length} old chat conversations to reduce storage size`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(`Trimming ${oldestChats.length} old chat conversations to reduce storage size`)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants