Skip to content
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

fix: performance issue with atom storage persistence #4281

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

louis-jan
Copy link
Contributor

@louis-jan louis-jan commented Dec 17, 2024

Describe Your Changes

This PR fixes the message rendering issue when caching it with jotai local storage, using composed atom of cache and storage

Summary of Code Changes

The Git diff shows the following changes to the ChatMessage.atom.ts file:

  1. Import Statement: The import statement for createJSONStorage is removed.
  2. Type Annotation: A type annotation for chatMessagesStorage is added.
  3. Atom Creation:
    • chatMessagesStorage is created using atomWithStorage.
    • cachedMessages is defined as an atom to store cached chat messages.
    • chatMessages is modified to first read from cachedMessages. If cachedMessages has no value, it reads from chatMessagesStorage.
    • The setter for chatMessages now sets both cachedMessages and chatMessagesStorage.

The overall goal seems to be improving the efficiency of accessing chat messages by caching them locally in addition to storing them persistently.

@louis-jan louis-jan requested a review from urmauur December 17, 2024 08:46
@github-actions github-actions bot added the type: bug Something isn't working label Dec 17, 2024
Copy link
Contributor

Barecheck - Code coverage report

Total: 69.24%

Your code coverage diff: -0.03% ▾

Uncovered files and lines
FileLines
web/helpers/atoms/ChatMessage.atom.ts31, 33-34, 57, 81-82, 84-85, 87, 90-91, 98-99, 101, 104-105, 108-109, 120, 123-124, 129, 132-133, 137, 140-141, 143-144, 147, 163-168, 170, 173-174, 176-177

@louis-jan louis-jan merged commit 14b1e61 into dev Dec 17, 2024
9 checks passed
@louis-jan louis-jan deleted the fix/performance-issue-with-atom-storage branch December 17, 2024 11:03
@github-actions github-actions bot added this to the v0.5.12 milestone Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants