Skip to content

Commit

Permalink
Merge pull request #129 from lobehub/chore/remove-panel
Browse files Browse the repository at this point in the history
Chore/remove panel
  • Loading branch information
rdmclin2 authored Aug 25, 2024
2 parents 9585bd2 + 0e1bfcf commit 2c75aec
Show file tree
Hide file tree
Showing 80 changed files with 1,087 additions and 1,096 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@
"@ant-design/icons": "^5.3.7",
"@aws-sdk/client-s3": "^3.600.0",
"@aws-sdk/s3-request-presigner": "^3.600.0",
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/utilities": "^3.2.2",
"@gltf-transform/core": "^4.0.2",
"@icons-pack/react-simple-icons": "^9.6.0",
"@lobehub/i18n-cli": "^1.18.1",
Expand Down
13 changes: 0 additions & 13 deletions scripts/mixamo/Posture/Female/Crouch/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,5 @@
"motion_id": "e3543986-d43d-4ec1-bac8-5cf7f5ec003b",
"motions": null,
"source": "system"
},
{
"id": "8c95cac8-2068-410f-9564-d0a2a04ea0a5",
"type": "Motion",
"description": "Sliding",
"category": "",
"character_type": "human",
"name": "Female Action Pose",
"thumbnail": "https://d99n9xvb9513w.cloudfront.net/thumbnails/motions/140000902/static.png",
"thumbnail_animated": "https://d99n9xvb9513w.cloudfront.net/thumbnails/motions/140000902/animated.gif",
"motion_id": "8c95cac8-2068-410f-9564-d0a2a04ea0a5",
"motions": null,
"source": "system"
}
]
13 changes: 0 additions & 13 deletions scripts/mixamo/Posture/Male/Locomotion/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,5 @@
"motion_id": "b414a4b5-236d-46e3-a2bd-efd45612ec42",
"motions": null,
"source": "system"
},
{
"id": "1189d701-e683-4281-a13d-3a48fce4797f",
"type": "Motion",
"description": "Crawling Forward Reaching With Left Hand",
"category": "",
"character_type": "human",
"name": "Male Action Pose",
"thumbnail": "https://d99n9xvb9513w.cloudfront.net/thumbnails/motions/150000903/static.png",
"thumbnail_animated": "https://d99n9xvb9513w.cloudfront.net/thumbnails/motions/150000903/animated.gif",
"motion_id": "1189d701-e683-4281-a13d-3a48fce4797f",
"motions": null,
"source": "system"
}
]
20 changes: 0 additions & 20 deletions src/animations/Posture/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,6 @@
"url": "https://r2.vidol.chat/animations/b414a4b5-236d-46e3-a2bd-efd45612ec42.fbx",
"avatar": "https://d99n9xvb9513w.cloudfront.net/thumbnails/motions/150500904/animated.gif"
},
{
"id": "1189d701-e683-4281-a13d-3a48fce4797f",
"name": "Male Action Pose",
"type": "Posture",
"gender": "Male",
"category": "Locomotion",
"description": "Crawling Forward Reaching With Left Hand",
"url": "https://r2.vidol.chat/animations/1189d701-e683-4281-a13d-3a48fce4797f.fbx",
"avatar": "https://d99n9xvb9513w.cloudfront.net/thumbnails/motions/150000903/animated.gif"
},
{
"id": "fec5edc4-5789-4583-8ae7-605f01ffe227",
"name": "Male Sitting Pose",
Expand Down Expand Up @@ -649,16 +639,6 @@
"url": "https://r2.vidol.chat/animations/27fe7228-487a-4951-af65-30cef1a9183d.fbx",
"avatar": "https://d99n9xvb9513w.cloudfront.net/thumbnails/motions/140000905/animated.gif"
},
{
"id": "8c95cac8-2068-410f-9564-d0a2a04ea0a5",
"name": "Female Action Pose",
"type": "Posture",
"gender": "Female",
"category": "Action",
"description": "Sliding",
"url": "https://r2.vidol.chat/animations/8c95cac8-2068-410f-9564-d0a2a04ea0a5.fbx",
"avatar": "https://d99n9xvb9513w.cloudfront.net/thumbnails/motions/140000902/animated.gif"
},
{
"id": "eaf51ff4-0fb7-4759-aadf-edb8fd3ae6a0",
"name": "Female Action Pose",
Expand Down
36 changes: 0 additions & 36 deletions src/app/chat/Apps.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/chat/ChatHeader/actions/ShareButton/ShareModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';

import { FORM_STYLE } from '@/constants/token';
import { useScreenshot } from '@/hooks/useScreenshot';
import { useSessionStore } from '@/store/session';

import { useScreenshot } from '../../../../../hooks/useScreenshot';
import Preview from './Preview';
import { FieldType, ImageType } from './type';

Expand Down
2 changes: 1 addition & 1 deletion src/app/chat/ChatHeader/actions/ShareButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useTranslation } from 'react-i18next';
import { DESKTOP_HEADER_ICON_SIZE } from '@/constants/token';
import { useSessionStore } from '@/store/session';

const ShareModal = dynamic(() => import('./ShareModal'));
const ShareModal = dynamic(() => import('./ShareModal'), { ssr: false });
interface ShareButtonProps {
className?: string;
// open?: boolean;
Expand Down
29 changes: 22 additions & 7 deletions src/app/chat/ChatHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Space } from 'antd';
'use client';

import { Skeleton, Space } from 'antd';
import classNames from 'classnames';
import React from 'react';
import React, { Suspense } from 'react';
import { Flexbox } from 'react-layout-kit';

import AgentMeta from '@/components/agent/AgentMeta';
Expand All @@ -14,9 +16,10 @@ import { useStyles } from './style';

interface Props {
className?: string;
style?: React.CSSProperties;
}
export default (props: Props) => {
const { className } = props;
const { className, style } = props;
const { styles } = useStyles();
const [currentAgent] = useSessionStore((s) => [sessionSelectors.currentAgent(s)]);

Expand All @@ -25,12 +28,24 @@ export default (props: Props) => {
justify={'space-between'}
horizontal
align={'center'}
style={style}
className={classNames(styles.header, className)}
>
<Space>
<ToggleSessionList />
<AgentMeta meta={currentAgent?.meta} />
</Space>
<Suspense
fallback={
<Skeleton
active
avatar={{ shape: 'circle', size: 'default' }}
paragraph={false}
title={{ style: { margin: 0, marginTop: 8 }, width: 200 }}
/>
}
>
<Space>
<ToggleSessionList />
<AgentMeta meta={currentAgent?.meta} />
</Space>
</Suspense>
<Space>
<Voice key={'voice'} />
<ShareButton key={'share'} />
Expand Down
51 changes: 51 additions & 0 deletions src/app/chat/ChatInfo/ChatList/SkeletonList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use client';

import { Skeleton } from 'antd';
import { createStyles } from 'antd-style';
import { memo } from 'react';
import { Flexbox } from 'react-layout-kit';

const useStyles = createStyles(({ css, prefixCls }) => ({
message: css`
display: flex;
gap: 12px;
.${prefixCls}-skeleton-header {
padding: 0;
}
`,
user: css`
flex-direction: row-reverse;
.${prefixCls}-skeleton-paragraph {
display: flex;
flex-direction: column;
align-items: flex-end;
}
`,
}));
interface SkeletonListProps {
mobile?: boolean;
}
const SkeletonList = memo<SkeletonListProps>(({ mobile }) => {
const { cx, styles } = useStyles();

return (
<Flexbox gap={24} padding={mobile ? 8 : 12} style={{ marginTop: 24 + (mobile ? 0 : 64) }}>
<Skeleton
active
avatar={{ size: mobile ? 32 : 40 }}
className={cx(styles.message, styles.user)}
paragraph={{ width: mobile ? ['80%', '40%'] : ['50%', '30%'] }}
title={false}
/>
<Skeleton
active
avatar={{ size: mobile ? 32 : 40 }}
className={styles.message}
paragraph={{ width: mobile ? ['80%', '40%'] : ['50%', '30%'] }}
title={false}
/>
</Flexbox>
);
});
export default SkeletonList;
96 changes: 96 additions & 0 deletions src/app/chat/ChatInfo/ChatList/VirtualizedList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { Space } from 'antd';
import classNames from 'classnames';
import isEqual from 'fast-deep-equal';
import React, { memo, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';
import { Virtuoso, VirtuosoHandle } from 'react-virtuoso';

import Header from '@/components/Header';
import Item from '@/features/ChatItem';
import { sessionSelectors, useSessionStore } from '@/store/session';

import History from './Actions/History';
import TokenMini from './Actions/TokenMini';
import AutoScroll from './AutoScroll';
import { useStyles } from './style';

const itemContent = (index: number, id: string) => {
return index === 0 ? (
<div style={{ height: 24 }} />
) : (
<Item id={id} index={index - 1} showTitle />
);
};

interface VirtualizedListProps {
className?: string;
mobile?: boolean;
style?: React.CSSProperties;
}
const VirtualizedList = memo<VirtualizedListProps>(({ mobile, className, style }) => {
const virtuosoRef = useRef<VirtuosoHandle>(null);
const [atBottom, setAtBottom] = useState(true);
const { styles } = useStyles();
const { t } = useTranslation('chat');

const data = useSessionStore(
(s) => ['empty', ...sessionSelectors.currentChatIDsWithGreetingMessage(s)],
isEqual,
);
const [id, chatLoading] = useSessionStore((s) => [s.activeId, !!s.chatLoadingId]);

useEffect(() => {
if (virtuosoRef.current) {
virtuosoRef.current.scrollToIndex({ align: 'end', behavior: 'auto', index: 'LAST' });
}
}, [id]);

// overscan should be 1.5 times the height of the window
const overscan = typeof window !== 'undefined' ? window.innerHeight * 1.5 : 0;

// @ts-ignore
return chatLoading && data.length === 2 ? null : (
<Flexbox style={style} className={classNames(className, styles.list)}>
<Header
title={t('history.title')}
className={styles.header}
extra={
<Space>
<TokenMini />
<History key={'history'} />
</Space>
}
/>
<Virtuoso
atBottomStateChange={setAtBottom}
atBottomThreshold={60 * (mobile ? 2 : 1)}
computeItemKey={(_, item) => item}
data={data}
followOutput={'auto'}
initialTopMostItemIndex={data?.length - 1}
itemContent={itemContent}
overscan={overscan}
ref={virtuosoRef}
/>
<AutoScroll
atBottom={atBottom}
onScrollToBottom={(type) => {
const virtuoso = virtuosoRef.current;
switch (type) {
case 'auto': {
virtuoso?.scrollToIndex({ align: 'end', behavior: 'auto', index: 'LAST' });
break;
}
case 'click': {
virtuoso?.scrollToIndex({ align: 'end', behavior: 'smooth', index: 'LAST' });
break;
}
}
}}
/>
</Flexbox>
);
});

export default VirtualizedList;
Loading

0 comments on commit 2c75aec

Please sign in to comment.