Title: perf(mothership): restore static markdown parse for settled chat messages by waleedlatif1 · Pull Request #5751 · simstudioai/sim · GitHub
Open Graph Title: perf(mothership): restore static markdown parse for settled chat messages by waleedlatif1 · Pull Request #5751 · simstudioai/sim
X Title: perf(mothership): restore static markdown parse for settled chat messages by waleedlatif1 · Pull Request #5751 · simstudioai/sim
Description: Summary Chat scroll got laggy after the mothership v0.8 merge (#5410), which removed mode='static' from the chat markdown renderer. Every message then rendered through Streamdown's streaming parser — remend + incomplete-markdown repair + per-block re-parse, running the rehype raw/sanitize/harden chain once per block. Because chat rows are virtualized, every up/down scroll remounts the messages crossing the overscan boundary and re-pays that N-block cost. That's the lag. Restore mode='static' for never-streamed mounts (reloaded history, or an in-session message scrolled out of the virtualized window and back): one whole-document parse instead of streaming's per-block re-parse. A completed message needs no incomplete-markdown repair, so static is the correct — and much cheaper — mode. In-session streaming is unchanged: it keeps the streaming parser for its mount life, so there's no drain re-parse flash. Cache Prism highlight output in a module-level bounded LRU (512, LRU eviction) so a code block re-highlights at most once across the unmount/remount virtualization does on scroll — a component useMemo would not survive the unmount. Root cause Verified by commit archaeology + reading streamdown@2.5.0's compiled parser: mode: 'static' renders the whole message in one ReactMarkdown pass and skips parseIncompleteMarkdown; mode: 'streaming' splits into N blocks and renders each as its own ReactMarkdown subtree, running the expensive rehype-raw chain per block. Type of Change Bug fix (performance regression) Testing tsc clean (0 errors), biome clean, 108/108 message-content tests pass. /cleanup (8 parallel quality passes: effects, state, memo, callback, react-query, url-state, emcn, comments) returned zero findings. Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
Open Graph Description: Summary Chat scroll got laggy after the mothership v0.8 merge (#5410), which removed mode='static' from the chat markdown renderer. Every message then rendered through Streamdown's str...
X Description: Summary Chat scroll got laggy after the mothership v0.8 merge (#5410), which removed mode='static' from the chat markdown renderer. Every message then rendered through Streamdown&a...
Opengraph URL: https://github.com/simstudioai/sim/pull/5751
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:55009ca2-bd30-135e-9a16-9a30eb7f7861 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C9B2:38B0A0:BDDDE6:10CF075:6A63868B |
| html-safe-nonce | 35fa19bb3be0ff97c8a3907d47eacfb8432ab01ba087a94a91b135712141320b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOUIyOjM4QjBBMDpCRERERTY6MTBDRjA3NTo2QTYzODY4QiIsInZpc2l0b3JfaWQiOiI0NjYxOTMwOTg3MTgyMzI3NDM1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 391a3526cd4fa9b361e01aa638c380bdcfc58b87411b018892b36a3109de5d75 |
| hovercard-subject-tag | pull_request:4080105851 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/5751/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary Chat scroll got laggy after the mothership v0.8 merge (#5410), which removed mode='static' from the chat markdown renderer. Every message then rendered through Streamdown's str... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | e4fb64aef87da454ec25b158147f7f5f14aef29216e5ca1612c2e48faa599d1f |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e839936ba5faffb9c836dda1cf4729d50c88a32e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width