This document outlines the plan to decouple the llm-streaming-ui library from the VZCode client codebase, making it a standalone, reusable component library.
The primary goal is to remove the dependency on VZCodeContext from src/llm-streaming-ui. Components should receive data and callbacks via props.
Goal: Create a bridge between VZCode's context and the UI library.
- Create
src/client/VZSidebar/AIChatWrapper.tsx. - This component will consume
VZCodeContext. - It will render
AIChatfromllm-streaming-ui, passing all necessary context values as props. - Update
src/client/VZSidebar/index.tsxto useAIChatWrapperinstead ofAIChat.
Goal: Remove useContext(VZCodeContext) from src/llm-streaming-ui/components/index.tsx.
- Update
AIChatprops interface to include all values currently destructured fromVZCodeContext. - Remove the context import.
- Pass these props down to child components (
MessageList,ChatInput) which also currently consume context.
Goal: Remove context usage from MessageList, Message, and ChatInput.
- MessageList: Update to accept
additionalWidgetsandhandleSendMessageas props. - Message: Update to accept
additionalWidgetsandhandleSendMessageas props. - ChatInput: Ensure it receives all necessary callbacks (it seems it already receives most via props from AIChat, but check for any hidden context usage).
The library currently imports utilities and hooks from the client folder.
Goal: Move or duplicate necessary hooks into the library.
- useAutoScroll: This hook is used in
AIChat. Movesrc/client/hooks/useAutoScroll.tstosrc/llm-streaming-ui/hooks/useAutoScroll.ts(or shared location). - Update imports in
AIChat.
Goal: Decouple file diffing and formatting utilities.
- fileDiff:
src/utils/fileDiff.tsis imported byDiffViewandIndividualFileDiff. Move relevant diffing logic tosrc/llm-streaming-ui/utils/or ensure it's passed as a prop/utility function if it depends on specific data structures not owned by the UI. - featureFlags:
enableDiffView,enableAskMode,enableMinimalEditFloware imported from../../client/featureFlags. These should be passed as props (booleans) toAIChat.
The library depends on specific icons and bootstrap components.
Goal: Remove hard dependency on src/client/Icons.
- Define an
Iconsinterface inllm-streaming-ui. - Accept an
iconsprop inAIChat(or use a Context within the library for theming). - Pass VZCode icons from the wrapper.
Goal: Remove hard dependency on src/client/bootstrap.
- The library uses
Form,Button, etc. - Either bundle these styles/components with the library or define a slot/render prop API for them.
- For now, copying the necessary styles or components into
llm-streaming-uimight be the easiest path to standalone usage.
Goal: Clean up src/client/VZSidebar/AIChat.
- Once
llm-streaming-uiis fully working and decoupled, verify thatsrc/client/VZSidebar/AIChat(the old implementation) is no longer used. - Delete
src/client/VZSidebar/AIChat.