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: react-markdown crash on code highlighting - threads switching do not take effect sometime #4216

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

louis-jan
Copy link
Contributor

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

Describe Your Changes

This PR addresses an issue where ReactMarkdown could crash due to unsupported languages in code highlighting. This has been resolved in the newer version of the dependency.

Also fixed the issue where switching between new threads (very shorts) would not take effect

CleanShot 2024-12-04 at 16 51 53

CleanShot 2024-12-04 at 16 52 23

Fixes Issues

Changes made

The changes in the git diff are as follows:

  1. package.json Update:

    • The version of the rehype-highlight package was updated from ^6.0.0 to ^7.0.1 in the project's dependencies.
  2. index.tsx Code Modifications:

    • Import Changes:

      • Added a new import: import { activeThreadAtom } from '@/helpers/atoms/Thread.atom'.
    • State and Effect Hook Adjustments:

      • Introduced a new state variable currentThread using useAtomValue to get the value of activeThreadAtom.
      • Updated the useEffect dependency and logic to include currentThread. This ensures that setCurrent is called if any message's thread_id does not match currentThread?.id.
    • Virtual Row Key Adjustment:

      • Changed the key for each virtualRow from virtualRow.key to messages[virtualRow.index]?.id. This provides a more consistent and relevant key based on the message ID.

These changes aim to improve thread handling and ensure correct rendering of chat messages in the component.

@louis-jan louis-jan requested a review from a team December 4, 2024 09:48
@github-actions github-actions bot added the type: bug Something isn't working label Dec 4, 2024
@louis-jan louis-jan merged commit 38ff118 into dev Dec 4, 2024
11 checks passed
@louis-jan louis-jan deleted the fix/react-markdown-crash-on-code-highlighting branch December 4, 2024 09:55
Copy link
Contributor

github-actions bot commented Dec 4, 2024

Barecheck - Code coverage report

Total: 69.26%

Your code coverage diff: -0.03% ▾

Uncovered files and lines
FileLines
web/screens/Thread/ThreadCenterPanel/ChatBody/index.tsx20-21, 23-24, 26, 30-31, 34-35, 37, 39, 43, 60, 62-63, 68, 70-71, 74-76, 80-81, 86, 123

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