kangfenmao / cherry-studio

🍒 Cherry Studio is a desktop client that supports for multiple LLM providers
https://cherry-ai.com
Other
1.36k stars 75 forks source link

mermaid图渲染有问题 #310

Closed huminglong closed 2 days ago

huminglong commented 4 days ago

mermaid显示有问题,生成的mermaid图代码,必须得手动切换一个话题再切换回来,mermaid图渲染才会成功,否则就只会显示代码,不显示渲染后的图

injurka commented 4 days ago

@kangfenmao Also, when generating code, it now throws an error, for some reason sometimes it gives undefined, its not clear how it gets there :)

image image

kangfenmao commented 4 days ago

Is it related to the mermaid? How to reproduce it @injurka

I'll see when I get home.

injurka commented 4 days ago

Is it related to the mermaid? How to reproduce it @injurka

I'll see when I get home.

Honestly, i cant say for sure, but now i think that this is exclusively related to shiki and the fact that it cant handle undefined. Its quite possible that this didnt work before, but react-syntax-highlighter was able to handle it. I think its enough to just add a check for the value)

And to reproduce this, its enough to generate a response in code format on the latest version of the application

kangfenmao commented 4 days ago

The app seems to start slower after using shiki. I don't know if it's my illusion

injurka commented 4 days ago

The app seems to start slower after using shiki. I don't know if it's my illusion

It is quite possible, after all, shiki supports many more language options, and it also has themes. Partly for this reason I mentioned whether it makes sense to use all the variations directly. And in the current implementation, it literally pulls everything into the bundle, although it has async chunks, but when importing all themes, I clearly noticed a slight decrease in the speed of the initial loading :) Mb can try to follow this advice and separate the variations a little https://shiki.style/guide/bundles#fine-grained-bundle, if the performance really does not improve, then perhaps I should give up altogether)

injurka commented 4 days ago

@kangfenmao Rolled back from the last commits to (73c93c558121e4db0342029b7f36f772ccfe8f0e) to see if shiki affected mermaid. Noticed some unusual behavior. When you first open a tab, mermaid is drawn correctly. But if you open another tab and return to the old one, everything breaks (

image

image

kangfenmao commented 2 days ago

已修复