Skip to content

Commit

Permalink
refactor: organize components in AieraChat
Browse files Browse the repository at this point in the history
  • Loading branch information
getnashty committed Dec 9, 2024
1 parent 25fc32b commit 89657b3
Show file tree
Hide file tree
Showing 42 changed files with 45 additions and 45 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { MicroSearch } from '@aiera/client-sdk/components/Svg/MicroSearch';
import { VirtuosoMessageListMethods } from '@virtuoso.dev/message-list';
import classNames from 'classnames';
import React, { ChangeEvent, KeyboardEvent, RefObject, useCallback, useEffect, useState } from 'react';
import { useChatStore } from '../../store';
import { useChatStore } from '../../../store';
import { IconButton } from '../../IconButton';
import { ChatMessage, ChatMessageType } from '../../services/messages';
import { ChatMessage, ChatMessageType } from '../../../services/messages';
import { CitableContent, ContentBlock } from '../../Messages/MessageFactory/Block';
import { ListItemContent } from '../../Messages/MessageFactory/Block/List';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { RefObject } from 'react';
import { Search } from './Search';
import { VirtuosoMessageListMethods } from '@virtuoso.dev/message-list';
import { IconButton } from '../IconButton';
import { ChatMessage } from '../services/messages';
import { ChatMessage } from '../../services/messages';

export function Header({
onOpenMenu,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import classNames from 'classnames';
import React from 'react';
import { useChatStore } from '../../../store';
import { useChatStore } from '../../../../store';

export const Citation = () => {
const { onSelectSource } = useChatStore();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { MicroQuestionMark } from '@aiera/client-sdk/components/Svg/MicroQuestionMark';
import classNames from 'classnames';
import React from 'react';
import { ChatMessagePrompt } from '../../../services/messages';
import { useChatStore } from '../../../store';
import { ChatMessagePrompt } from '../../../../services/messages';
import { useChatStore } from '../../../../store';

export const MessagePrompt = ({
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { MicroFolder } from '@aiera/client-sdk/components/Svg/MicroFolder';
import { MicroRefresh } from '@aiera/client-sdk/components/Svg/MicroRefresh';
import { MicroThumbDown } from '@aiera/client-sdk/components/Svg/MicroThumbDown';
import { MicroThumbUp } from '@aiera/client-sdk/components/Svg/MicroThumbUp';
import { AddSourceDialog } from '@aiera/client-sdk/modules/AieraChat/AddSourceDialog';
import { IconButton } from '@aiera/client-sdk/modules/AieraChat/IconButton';
import { AddSourceDialog } from '@aiera/client-sdk/modules/AieraChat/modals/AddSourceDialog';
import { IconButton } from '@aiera/client-sdk/modules/AieraChat/components/IconButton';
import { ChatMessage } from '@aiera/client-sdk/modules/AieraChat/services/messages';
import { Source } from '@aiera/client-sdk/modules/AieraChat/store';
import classNames from 'classnames';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { ChatMessageResponse, ChatMessageStatus } from '../../../services/messages';
import { ChatMessageResponse, ChatMessageStatus } from '../../../../services/messages';
import { Block } from '../Block';
import { Loading } from '../Loading';
import { Footer } from './Footer';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { useChatStore } from '../../../store';
import { useChatStore } from '../../../../store';

export function SearchableText({ text }: { text: string }) {
const { searchTerm } = useChatStore();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Button } from '@aiera/client-sdk/components/Button';
import { MicroTrash } from '@aiera/client-sdk/components/Svg/MicroTrash';
import classNames from 'classnames';
import React, { useCallback, useState } from 'react';
import { AddSourceDialog } from '../../../AddSourceDialog';
import { ChatMessageSources, ChatMessageStatus } from '../../../services/messages';
import { Source, useChatStore } from '../../../store';
import { AddSourceDialog } from '../../../../modals/AddSourceDialog';
import { ChatMessageSources, ChatMessageStatus } from '../../../../services/messages';
import { Source, useChatStore } from '../../../../store';
import { Loading } from '../Loading';

export const SourcesResponse = ({ data, onConfirm }: { onConfirm: (k: string) => void; data: ChatMessageSources }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { VirtuosoMessageListProps } from '@virtuoso.dev/message-list';
import React from 'react';
import { match } from 'ts-pattern';
import { MessageListContext } from '..';
import { ChatMessage, ChatMessageType } from '../../services/messages';
import { ChatMessage, ChatMessageType } from '../../../services/messages';
import { MessagePrompt } from './MessagePrompt';
import { MessageResponse } from './MessageResponse';
import { SourcesResponse } from './SourcesResponse';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { MicroArrowUp } from '@aiera/client-sdk/components/Svg/MicroArrowUp';
import { MicroFolder } from '@aiera/client-sdk/components/Svg/MicroFolder';
import classNames from 'classnames';
import React, { KeyboardEvent, useCallback, useEffect, useRef, useState } from 'react';
import { MicroFolderOpen } from '../../../components/Svg/MicroFolderOpen';
import { useChatStore } from '../store';
import { Hint } from '../Hint';
import { MicroFolderOpen } from '../../../../../components/Svg/MicroFolderOpen';
import { useChatStore } from '../../../store';
import { Hint } from '../../Hint';
import './styles.css';

interface PromptProps {
onOpenSources: () => void;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useCallback, useState } from 'react';
import { VirtuosoMessageListProps } from '@virtuoso.dev/message-list';
import { useSuggestedPrompts } from '../../services/suggestedPrompts';
import { useSuggestedPrompts } from '../../../services/suggestedPrompts';
import { LoadingSpinner } from '@aiera/client-sdk/components/LoadingSpinner';
import { Chevron } from '@aiera/client-sdk/components/Svg/Chevron';
import { MessageListContext } from '..';
import { ChatMessage } from '../../services/messages';
import { ChatMessage } from '../../../services/messages';

export const SuggestedPrompts: VirtuosoMessageListProps<ChatMessage, MessageListContext>['EmptyPlaceholder'] = ({
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@virtuoso.dev/message-list';
import classNames from 'classnames';
import React, { Fragment, RefObject, useCallback, useEffect, useMemo } from 'react';
import { Prompt } from '../Prompt';
import { Prompt } from './Prompt';
import {
ChatMessage,
ChatMessagePrompt,
Expand All @@ -18,8 +18,8 @@ import {
ChatMessageStatus,
ChatMessageType,
useChatMessages,
} from '../services/messages';
import { useChatStore } from '../store';
} from '../../services/messages';
import { useChatStore } from '../../store';
import { MessageFactory } from './MessageFactory';
import './styles.css';
import { SuggestedPrompts } from './SuggestedPrompts';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MicroCloseCircle } from '@aiera/client-sdk/components/Svg/MicroCloseCir
import classNames from 'classnames';
import React from 'react';

export function PanelSearchInput({
export function SearchInput({
autoFocus,
value,
onChange,
Expand Down
11 changes: 5 additions & 6 deletions src/modules/AieraChat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import { VirtuosoMessageListMethods } from '@virtuoso.dev/message-list';
import classNames from 'classnames';
import React, { ReactElement, useCallback, useRef, useState } from 'react';
import { Transcript } from '../Transcript';
import { ConfirmDialog } from './ConfirmDialog';
import { Header } from './Header';
import { Menu } from './Menu';
import { Messages } from './Messages';
import { Sources } from './Sources';
import { ConfirmDialog } from './modals/ConfirmDialog';
import { Header } from './components/Header';
import { Menu } from './panels/Menu';
import { Messages } from './components/Messages';
import { Sources } from './panels/Sources';
import { useChatStore } from './store';
import './styles.css';
import { ChatMessage } from './services/messages';

export function AieraChat(): ReactElement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { MicroFolderOpen } from '@aiera/client-sdk/components/Svg/MicroFolderOpe
import debounce from 'lodash.debounce';
import React, { ReactElement, useCallback, useEffect, useState } from 'react';
import { match } from 'ts-pattern';
import { ContentRow } from '../ContentRow';
import { ContentRow } from '../../components/ContentRow';
import { Modal } from '../Modal';
import { PanelSearchInput } from '../PanelSearchInput';
import { useEvents } from '../services/events';
import { Source, useChatStore } from '../store';
import { SearchInput } from '../../components/SearchInput';
import { useEvents } from '../../services/events';
import { Source, useChatStore } from '../../store';

/**
* Checks if a given source exists in an array of sources
Expand Down Expand Up @@ -65,7 +65,7 @@ export function AddSourceDialog({
return (
<Modal onClose={onClose} title="Manage Sources" className="h-60 -mb-5" Icon={MicroFolderOpen}>
<div className="flex flex-col flex-1">
<PanelSearchInput
<SearchInput
autoFocus
onChange={(newValue) => {
if (newValue) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { MicroTrash } from '@aiera/client-sdk/components/Svg/MicroTrash';
import classNames from 'classnames';
import React, { useState } from 'react';
import { Panel } from '../Panel';
import { PanelSearchInput } from '../PanelSearchInput';
import { useChatSessions } from '../services/chats';
import { useChatStore } from '../store';
import { ContentRow } from '../ContentRow';
import { SearchInput } from '../../components/SearchInput';
import { useChatSessions } from '../../services/chats';
import { useChatStore } from '../../store';
import { ContentRow } from '../../components/ContentRow';

export function Menu({ onClose, onOpenConfirm }: { onOpenConfirm: () => void; onClose: () => void }) {
const { chatId, onSelectChat, onNewChat } = useChatStore();
Expand All @@ -22,7 +22,7 @@ export function Menu({ onClose, onOpenConfirm }: { onOpenConfirm: () => void; on
<Panel Icon={MicroBars} className="mt-4 flex flex-col flex-1" onClose={onClose} title="All Chats" side="left">
{({ onStartExit }) => (
<div className="flex flex-col flex-1 pb-6">
<PanelSearchInput
<SearchInput
onChange={setSearchTerm}
value={searchTerm}
name="search_chats"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import debounce from 'lodash.debounce';
import React, { useCallback, useEffect, useState } from 'react';
import { match } from 'ts-pattern';
import { Panel } from '../Panel';
import { PanelSearchInput } from '../PanelSearchInput';
import { useEvents } from '../services/events';
import { Source, useChatStore } from '../store';
import { ContentRow } from '../ContentRow';
import { SearchInput } from '../../components/SearchInput';
import { useEvents } from '../../services/events';
import { Source, useChatStore } from '../../store';
import { ContentRow } from '../../components/ContentRow';

/**
* Checks if a given source exists in an array of sources
Expand Down Expand Up @@ -60,7 +60,7 @@ export function Sources({ onClose }: { onClose: () => void }) {
side="right"
>
<div className="flex flex-col flex-1">
<PanelSearchInput
<SearchInput
autoFocus
onChange={(newValue) => {
if (newValue) {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/AieraChat/services/messages.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useEffect, useCallback } from 'react';
import { ContentBlock } from '../Messages/MessageFactory/Block';
import { ContentBlock } from '../components/Messages/MessageFactory/Block';

export enum ChatMessageType {
prompt = 'prompt',
Expand Down

0 comments on commit 89657b3

Please sign in to comment.