[PR #4793] [CLOSED] Refactor workspace/pfp images #4774

Closed
opened 2026-02-22 18:36:30 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/4793
Author: @shatfield4
Created: 12/16/2025
Status: Closed

Base: masterHead: 4792-feat-refactor-workspacepfp-image


📝 Commits (4)

  • a6ad59c use svgr vite plugin to inline svgs
  • 2463ee6 fix rerendering of all messages when typing in prompt input
  • b4ccd6e Merge branch 'master' into 4792-feat-refactor-workspacepfp-image
  • 0338081 Merge branch 'master' into 4792-feat-refactor-workspacepfp-image

📊 Changes

5 files changed (+237 additions, -64 deletions)

View changed files

📝 frontend/package.json (+2 -1)
📝 frontend/src/components/UserIcon/index.jsx (+4 -15)
📝 frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/index.jsx (+1 -7)
📝 frontend/vite.config.js (+2 -0)
📝 frontend/yarn.lock (+228 -41)

📄 Description

Pull Request Type

  • feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • 📝 docs

Relevant Issues

resolves #4792

What is in this change?

  • Uses vite-plugin-svgr vite plugin to inline SVGs for workspace and user image
  • Prevent entire message history rerendering when typing into the prompt input box by removing regenerateAssistantMessage, saveEditedMessage, and forkThread from compiledHistory function and adding getMessageAlignment
  • Previously any time a user entered any key into the prompt input, it would cause the entire message history to rerender and rebuild the messages. This is because the parent component would rerender on input change, which would recreate the functions for saveEditedMessage and forkThread (defined in ChatHistory), causing useMemo to trigger the rebuild of messages

Additional Information

  • Discovered that any time you render an SVG in an <img> it will cause a network request to be made regardless of if the component is properly memoized or not
  • Also discovered that base64 encoding the image and inlining it in the react component prevents the network requests from happening since they are included in the js bundle (very messy)
  • vite-plugin-svgr allows us to import SVGs as react components using ?react in the import which inlines them in the js bundle without the base64 encoding and prevents the network requests
  • Added logging to all chat/streaming related components when testing to check for unnecessary rerenders (now removed)

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality
  • Docker build succeeds locally

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/4793 **Author:** [@shatfield4](https://github.com/shatfield4) **Created:** 12/16/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `4792-feat-refactor-workspacepfp-image` --- ### 📝 Commits (4) - [`a6ad59c`](https://github.com/Mintplex-Labs/anything-llm/commit/a6ad59ca6b1e7a87dc6da77425e01f562a5cd507) use svgr vite plugin to inline svgs - [`2463ee6`](https://github.com/Mintplex-Labs/anything-llm/commit/2463ee628fadef7b396c71c774d7ac411c4f04f9) fix rerendering of all messages when typing in prompt input - [`b4ccd6e`](https://github.com/Mintplex-Labs/anything-llm/commit/b4ccd6e9eb3ee3ad7930773e7ce6d9efcdefbf97) Merge branch 'master' into 4792-feat-refactor-workspacepfp-image - [`0338081`](https://github.com/Mintplex-Labs/anything-llm/commit/0338081208f62a4f1b438bff15b750f463618f37) Merge branch 'master' into 4792-feat-refactor-workspacepfp-image ### 📊 Changes **5 files changed** (+237 additions, -64 deletions) <details> <summary>View changed files</summary> 📝 `frontend/package.json` (+2 -1) 📝 `frontend/src/components/UserIcon/index.jsx` (+4 -15) 📝 `frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/index.jsx` (+1 -7) 📝 `frontend/vite.config.js` (+2 -0) 📝 `frontend/yarn.lock` (+228 -41) </details> ### 📄 Description ### Pull Request Type <!-- For change type, change [ ] to [x]. --> - [ ] ✨ feat - [ ] 🐛 fix - [x] ♻️ refactor - [ ] 💄 style - [ ] 🔨 chore - [ ] 📝 docs ### Relevant Issues <!-- Use "resolves #xxx" to auto resolve on merge. Otherwise, please use "connect #xxx" --> resolves #4792 ### What is in this change? <!-- Describe the changes in this PR that are impactful to the repo. --> - Uses `vite-plugin-svgr` vite plugin to inline SVGs for workspace and user image - Prevent entire message history rerendering when typing into the prompt input box by removing `regenerateAssistantMessage`, `saveEditedMessage`, and `forkThread` from `compiledHistory` function and adding `getMessageAlignment` - Previously any time a user entered any key into the prompt input, it would cause the entire message history to rerender and rebuild the messages. This is because the parent component would rerender on input change, which would recreate the functions for `saveEditedMessage` and `forkThread` (defined in ChatHistory), causing useMemo to trigger the rebuild of messages ### Additional Information <!-- Add any other context about the Pull Request here that was not captured above. --> - Discovered that any time you render an SVG in an `<img>` it will cause a network request to be made regardless of if the component is properly memoized or not - Also discovered that base64 encoding the image and inlining it in the react component prevents the network requests from happening since they are included in the js bundle (very messy) - `vite-plugin-svgr` allows us to import SVGs as react components using `?react` in the import which inlines them in the js bundle without the base64 encoding and prevents the network requests - Added logging to all chat/streaming related components when testing to check for unnecessary rerenders (now removed) ### Developer Validations <!-- All of the applicable items should be checked. --> - [x] I ran `yarn lint` from the root of the repo & committed changes - [x] Relevant documentation has been updated - [x] I have tested my code functionality - [x] Docker build succeeds locally --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-22 18:36:30 -05:00
yindo closed this issue 2026-02-22 18:36:30 -05:00
yindo changed title from [PR #4793] Refactor workspace/pfp images to [PR #4793] [CLOSED] Refactor workspace/pfp images 2026-06-05 15:20:19 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#4774