Skip to content

Commit

Permalink
refactor: utils
Browse files Browse the repository at this point in the history
  • Loading branch information
paulclindo committed May 14, 2024
1 parent ca03939 commit 2c648a7
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 47 deletions.
8 changes: 3 additions & 5 deletions apps/shinkai-app/src/components/ui/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { IonAvatar } from '@ionic/react';

import { cn } from '../../theme/lib/utils';

import { cn } from '@shinkai_network/shinkai-ui/utils';
export default function Avatar({
url,
className,
Expand All @@ -11,11 +9,11 @@ export default function Avatar({
}) {
return (
<IonAvatar
className={cn('bg-white w-8 h-8 [--border-radius:7777px]', className)}
className={cn('h-8 w-8 bg-white [--border-radius:7777px]', className)}
>
<img
alt=""
className="w-full h-full"
className="h-full w-full"
src={url ?? 'https://ionicframework.com/docs/img/demos/avatar.svg'}
/>
</IonAvatar>
Expand Down
7 changes: 3 additions & 4 deletions apps/shinkai-app/src/components/ui/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import './Button.css';

import { IonButton } from '@ionic/react';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import { Loader2 } from 'lucide-react';
import React from 'react';

import { cn } from '../../theme/lib/utils';

export default function Button({
onClick,
disabled,
Expand All @@ -28,14 +27,14 @@ export default function Button({
className={cn(
'ion-button-custom w-full',
'variant-' + variant,
className
className,
)}
disabled={disabled || isLoading}
onClick={onClick}
shape={'round'}
type={type}
>
{isLoading ? <Loader2 className="h-4 w-4 animate-spin mr-2" /> : null}
{isLoading ? <Loader2 className="mr-2 h-4 w-4 animate-spin" /> : null}
{children}
</IonButton>
);
Expand Down
7 changes: 3 additions & 4 deletions apps/shinkai-app/src/components/ui/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import './Input.css';

import { InputCustomEvent } from '@ionic/core/dist/types/components/input/input-interface';
import { InputChangeEventDetail, IonInput } from '@ionic/react';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import type { Ref } from 'react';
import React from 'react';

import { cn } from '../../theme/lib/utils';

type InputProps = {
onChange: (event: InputCustomEvent<InputChangeEventDetail>) => void;
value: string;
Expand All @@ -18,7 +17,7 @@ type InputProps = {
const Input = React.forwardRef(
(
{ onChange, value, label, className }: InputProps,
ref: Ref<HTMLIonInputElement>
ref: Ref<HTMLIonInputElement>,
) => {
return (
<IonInput
Expand All @@ -34,7 +33,7 @@ const Input = React.forwardRef(
value={value}
/>
);
}
},
);

Input.displayName = 'Input';
Expand Down
2 changes: 1 addition & 1 deletion apps/shinkai-app/src/pages/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useSendMessageWithFilesToInbox } from '@shinkai_network/shinkai-node-st
import { ChatConversationMessage } from '@shinkai_network/shinkai-node-state/lib/queries/getChatConversation/types';
import { useGetChatConversationWithPagination } from '@shinkai_network/shinkai-node-state/lib/queries/getChatConversation/useGetChatConversationWithPagination';
import { groupMessagesByDate } from '@shinkai_network/shinkai-node-state/lib/utils/date';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import MarkdownPreview from '@uiw/react-markdown-preview';
import { cameraOutline } from 'ionicons/icons';
import { send } from 'ionicons/icons';
Expand All @@ -34,7 +35,6 @@ import {
IonHeaderCustom,
} from '../components/ui/Layout';
import { useAuth } from '../store/auth';
import { cn } from '../theme/lib/utils';
import {
extractReceiverShinkaiName,
getOtherPersonIdentity,
Expand Down
2 changes: 1 addition & 1 deletion apps/shinkai-app/src/pages/JobChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { useSendMessageToJob } from '@shinkai_network/shinkai-node-state/lib/mut
import { useSendMessageWithFilesToInbox } from '@shinkai_network/shinkai-node-state/lib/mutations/sendMesssageWithFilesToInbox/useSendMessageWithFilesToInbox';
import { ChatConversationMessage } from '@shinkai_network/shinkai-node-state/lib/queries/getChatConversation/types';
import { useGetChatConversationWithPagination } from '@shinkai_network/shinkai-node-state/lib/queries/getChatConversation/useGetChatConversationWithPagination';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import MarkdownPreview from '@uiw/react-markdown-preview';
import { send } from 'ionicons/icons';
import { cameraOutline } from 'ionicons/icons';
Expand All @@ -39,7 +40,6 @@ import {
IonHeaderCustom,
} from '../components/ui/Layout';
import { useAuth } from '../store/auth';
import { cn } from '../theme/lib/utils';

const groupMessagesByDate = (messages: ChatConversationMessage[]) => {
const groupedMessages: Record<string, ChatConversationMessage[]> = {};
Expand Down
4 changes: 2 additions & 2 deletions apps/shinkai-desktop/src/components/chat/message.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ShinkaiMessage } from '@shinkai_network/shinkai-message-ts/models';
import { MessageSchemaType } from '@shinkai_network/shinkai-message-ts/models';
import { extractErrorPropertyOrContent } from '@shinkai_network/shinkai-message-ts/utils/shinkai_message_handler';
import { extractErrorPropertyOrContent } from '@shinkai_network/shinkai-message-ts/utils';
import { ChatConversationMessage } from '@shinkai_network/shinkai-node-state/lib/queries/getChatConversation/types';
import {
Avatar,
Expand All @@ -9,9 +9,9 @@ import {
CopyToClipboardIcon,
MarkdownPreview,
} from '@shinkai_network/shinkai-ui';
import { cn } from '@shinkai_network/shinkai-ui/utils';

import icon from '../../assets/icon.png';
import { cn } from '../../lib/utils';
import { FileList } from '../../pages/create-job';

export const getMessageFilesInbox = (
Expand Down
6 changes: 0 additions & 6 deletions apps/shinkai-desktop/src/lib/utils.ts

This file was deleted.

3 changes: 1 addition & 2 deletions apps/shinkai-desktop/src/pages/chat/chat-conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
DirectoryTypeIcon,
FileTypeIcon,
} from '@shinkai_network/shinkai-ui/assets';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import { Placeholder } from '@tiptap/extension-placeholder';
import { EditorContent, Extension, useEditor } from '@tiptap/react';
import { StarterKit } from '@tiptap/starter-kit';
Expand Down Expand Up @@ -72,10 +73,8 @@ import { z } from 'zod';

import Message from '../../components/chat/message';
import { useGetCurrentInbox } from '../../hooks/use-current-inbox';
import { cn } from '../../lib/utils';
import { useAuth } from '../../store/auth';
import { isImageOrPdf } from '../create-job';

const chatSchema = z.object({
message: z.string(),
file: z.any().optional(),
Expand Down
4 changes: 2 additions & 2 deletions apps/shinkai-desktop/src/pages/chat/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { zodResolver } from '@hookform/resolvers/zod';
// import { PlusCircledIcon } from '@radix-ui/react-icons';
import { SmartInbox } from '@shinkai_network/shinkai-message-ts/models/ShinkaiMessage';
import { SmartInbox } from '@shinkai_network/shinkai-message-ts/models';
import {
getMessageContent,
isJobInbox,
Expand Down Expand Up @@ -35,6 +35,7 @@ import {
ChatBubbleIcon,
JobBubbleIcon,
} from '@shinkai_network/shinkai-ui/assets';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import { Edit3, PlusIcon } from 'lucide-react';
import React, { useEffect, useMemo, useRef, useState } from 'react';
import { useForm } from 'react-hook-form';
Expand All @@ -43,7 +44,6 @@ import { toast } from 'sonner';
import { z } from 'zod';

import { handleSendNotification } from '../../lib/notifications';
import { cn } from '../../lib/utils';
import { useAuth } from '../../store/auth';

const updateInboxNameSchema = z.object({
Expand Down
2 changes: 1 addition & 1 deletion apps/shinkai-desktop/src/pages/create-agent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { zodResolver } from '@hookform/resolvers/zod';
import { AgentAPIModel } from '@shinkai_network/shinkai-message-ts/models/SchemaTypes';
import { AgentAPIModel } from '@shinkai_network/shinkai-message-ts/models';
import { useCreateAgent } from '@shinkai_network/shinkai-node-state/lib/mutations/createAgent/useCreateAgent';
import { useScanOllamaModels } from '@shinkai_network/shinkai-node-state/lib/queries/scanOllamaModels/useScanOllamaModels';
import {
Expand Down
2 changes: 1 addition & 1 deletion apps/shinkai-desktop/src/pages/create-job.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { zodResolver } from '@hookform/resolvers/zod';
import { buildInboxIdFromJobId } from '@shinkai_network/shinkai-message-ts/utils/inbox_name_handler';
import { buildInboxIdFromJobId } from '@shinkai_network/shinkai-message-ts/utils';
import { useCreateJob } from '@shinkai_network/shinkai-node-state/lib/mutations/createJob/useCreateJob';
import { useAgents } from '@shinkai_network/shinkai-node-state/lib/queries/getAgents/useGetAgents';
import {
Expand Down
2 changes: 1 addition & 1 deletion apps/shinkai-desktop/src/pages/restore-connection.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { zodResolver } from '@hookform/resolvers/zod';
import { decryptMessageWithPassphrase } from '@shinkai_network/shinkai-message-ts/cryptography/shinkai-encryption';
import { decryptMessageWithPassphrase } from '@shinkai_network/shinkai-message-ts/cryptography';
import {
Button,
buttonVariants,
Expand Down
16 changes: 8 additions & 8 deletions apps/shinkai-desktop/src/windows/toasts-utils.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cn } from '@shinkai_network/shinkai-ui/utils';
import { ExternalToast, toast } from 'sonner';

import { cn } from '../lib/utils';
import { openShinkaiNodeManagerWindow } from './utils';

const ShinkaiNodeLogsLabel = ({
Expand Down Expand Up @@ -78,8 +78,8 @@ export const stoppingShinkaiNodeToast = () => {
export const shinkaiNodeStopErrorToast = () => {
toast.error(
<div>
Error stopping your local Shinkai Node, see <ShinkaiNodeLogsLabel />
{' '} for more information
Error stopping your local Shinkai Node, see <ShinkaiNodeLogsLabel /> for
more information
</div>,
{
...defaultToastOptions,
Expand All @@ -100,8 +100,8 @@ export const stoppingOllamaToast = () => {
export const ollamaStopErrorToast = () => {
toast.error(
<div>
Error stopping your local Ollama, see <ShinkaiNodeLogsLabel />
{' '} for more information
Error stopping your local Ollama, see <ShinkaiNodeLogsLabel /> for more
information
</div>,
{
...defaultToastOptions,
Expand All @@ -124,7 +124,7 @@ export const errorRemovingShinkaiNodeStorageToast = () => {
return toast.error(
<div>
Error removing your local Shinkai Node storage, see{' '}
<ShinkaiNodeLogsLabel /> {' '} for more information
<ShinkaiNodeLogsLabel /> for more information
</div>,
{ ...defaultToastOptions },
);
Expand Down Expand Up @@ -173,8 +173,8 @@ export const pullingModelDoneToast = (model: string) => {
export const pullingModelErrorToast = (model: string) => {
return toast.error(
<div>
Error downloading AI model {model}, see <ShinkaiNodeLogsLabel />
{' '} for more information
Error downloading AI model {model}, see <ShinkaiNodeLogsLabel /> for more
information
</div>,
{
...defaultToastOptions,
Expand Down
20 changes: 19 additions & 1 deletion apps/shinkai-desktop/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,25 @@
"types": ["vite/client", "vitest"],
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"paths": {
"@shinkai_network/shinkai-ui": [
"libs/shinkai-ui/src/components/index.ts"
],
"@shinkai_network/shinkai-ui/hooks": [
"libs/shinkai-ui/src/hooks/index.ts"
],
"@shinkai_network/shinkai-ui/utils": ["libs/shinkai-ui/src/utils.ts"],
"@shinkai_network/shinkai-ui/assets": [
"libs/shinkai-ui/src/assets/index.ts"
],
"@shinkai_network/shinkai-message-ts/*": [
"dist/libs/shinkai-message-ts/*"
],
"@shinkai_network/shinkai-node-state/*": [
"libs/shinkai-node-state/src/*.ts"
]
}
},
"files": [],
"include": [],
Expand Down
2 changes: 1 addition & 1 deletion apps/shinkai-visor/src/components/node-files/all-files.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ import {
FileTypeIcon,
GenerateDocIcon,
} from '@shinkai_network/shinkai-ui/assets';
import { useDebounce } from '@shinkai_network/shinkai-ui/hooks';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import { motion } from 'framer-motion';
import { ChevronRight, PlusIcon, SearchIcon, X, XIcon } from 'lucide-react';
import React, { useEffect } from 'react';
import { useHistory, useLocation } from 'react-router-dom';

import { useDebounce } from '../../hooks/use-debounce';
import { useQuery } from '../../hooks/use-query';
import { useAuth } from '../../store/auth/auth';
import { useVectorFsStore, VectorFSLayout } from './node-file-context';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import {
ToggleGroupItem,
} from '@shinkai_network/shinkai-ui';
import { SharedFolderIcon } from '@shinkai_network/shinkai-ui/assets';
import { useDebounce } from '@shinkai_network/shinkai-ui/hooks';
import { useInView } from 'framer-motion';
import { Maximize2, Minimize2, SearchIcon, XIcon } from 'lucide-react';
import { Tree, TreeExpandedKeysType } from 'primereact/tree';
import { TreeNode as PrimeTreeNode } from 'primereact/treenode';
import React, { Fragment, useEffect, useRef, useState } from 'react';

import { useDebounce } from '../../hooks/use-debounce';
import { useAuth } from '../../store/auth/auth';
import { treeOptions } from '../create-job/constants';
import {
Expand Down
6 changes: 0 additions & 6 deletions apps/shinkai-visor/src/helpers/cn-utils.ts

This file was deleted.

0 comments on commit 2c648a7

Please sign in to comment.