Refactor ClientChatStore into separate stores for modularity and improve maintainability.

This commit is contained in:
geoffsee
2025-05-30 22:27:01 -04:00
committed by Geoff Seemueller
parent ebbfd4d31a
commit df6e18bbdf
9 changed files with 228 additions and 227 deletions

View File

@@ -25,8 +25,8 @@ const Chat = observer(({ height, width }) => {
width={width}
gap={0}
>
<GridItem alignSelf="center" hidden={!(chatStore.messages.length < 1)}>
<WelcomeHome visible={chatStore.messages.length < 1} />
<GridItem alignSelf="center" hidden={!(chatStore.items.length < 1)}>
<WelcomeHome visible={chatStore.items.length < 1} />
</GridItem>
<GridItem

View File

@@ -71,7 +71,7 @@ const InputMenu: React.FC<{ isDisabled?: boolean }> = observer(
const handleCopyConversation = useCallback(() => {
navigator.clipboard
.writeText(formatConversationMarkdown(ClientChatStore.messages))
.writeText(formatConversationMarkdown(ClientchatStore.items))
.then(() => {
window.alert(
"Conversation copied to clipboard. \n\nPaste it somewhere safe!",

View File

@@ -27,8 +27,8 @@ const ChatMessages: React.FC<ChatMessagesProps> = observer(({ scrollRef }) => {
boxShadow="md"
whiteSpace="pre-wrap"
>
{chatStore.messages.map((msg, index) => {
if (index < chatStore.messages.length - 1) {
{chatStore.items.map((msg, index) => {
if (index < chatStore.items.length - 1) {
return (
<GridItem key={index}>
<MessageBubble x scrollRef={scrollRef} msg={msg} />

View File

@@ -63,12 +63,12 @@ const MessageBubble = observer(({ msg, scrollRef }) => {
useEffect(() => {
if (
clientChatStore.messages.length > 0 &&
clientChatStore.items.length > 0 &&
clientChatStore.isLoading &&
UserOptionsStore.followModeEnabled
) {
console.log(
`${clientChatStore.messages.length}/${clientChatStore.isLoading}/${UserOptionsStore.followModeEnabled}`,
`${clientChatStore.items.length}/${clientChatStore.isLoading}/${UserOptionsStore.followModeEnabled}`,
);
scrollRef.current?.scrollTo({
top: scrollRef.current.scrollHeight,