@lobehub/chat 0.82.8 → 0.82.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/package.json +1 -1
  3. package/src/app/chat/{features/Header → (desktop)/features/ChatHeader}/Desktop.tsx +2 -2
  4. package/src/app/chat/{features/Header → (desktop)/features/ChatHeader}/index.tsx +1 -1
  5. package/src/app/chat/(desktop)/features/ChatInput/index.tsx +22 -0
  6. package/src/app/chat/{features/SessionList/Header → (desktop)/features/SessionHeader}/Desktop.tsx +1 -1
  7. package/src/app/chat/{features/SessionList/Header → (desktop)/features/SessionHeader}/index.tsx +1 -1
  8. package/src/app/chat/{features → (desktop)/features}/SessionList/Desktop.tsx +1 -1
  9. package/src/app/chat/(desktop)/features/SessionList/index.tsx +20 -0
  10. package/src/app/chat/{features/Sidebar → (desktop)/features/SideBar}/Desktop.tsx +4 -4
  11. package/src/app/chat/(desktop)/features/SideBar/index.tsx +20 -0
  12. package/src/app/chat/(desktop)/index.tsx +24 -0
  13. package/src/app/chat/{layout.desktop.tsx → (desktop)/layout/Desktop.tsx} +4 -4
  14. package/src/app/chat/(desktop)/layout/index.tsx +25 -0
  15. package/src/app/chat/(mobile)/features/ChatHeader.tsx +1 -0
  16. package/src/app/chat/(mobile)/features/ChatInput.tsx +14 -0
  17. package/src/app/chat/(mobile)/features/SessionList.tsx +12 -0
  18. package/src/app/chat/(mobile)/features/Topics.tsx +12 -0
  19. package/src/app/chat/(mobile)/index.tsx +20 -0
  20. package/src/app/chat/(mobile)/layout.tsx +15 -0
  21. package/src/app/chat/(mobile)/mobile/page.tsx +21 -0
  22. package/src/app/chat/{features/Header → components/ChatHeader}/Mobile.tsx +2 -1
  23. package/src/app/chat/{features/Header → components/ChatHeader}/ShareButton/Preview.tsx +3 -3
  24. package/src/app/chat/{features/Conversation/Input → components/ChatInput}/index.tsx +23 -21
  25. package/src/app/chat/components/Inspector/index.tsx +17 -0
  26. package/src/app/chat/{features → components}/SessionList/Mobile.tsx +1 -1
  27. package/src/app/chat/{features → components}/SessionList/index.tsx +3 -10
  28. package/src/app/chat/features/Conversation/index.tsx +8 -4
  29. package/src/app/chat/features/PageTitle.tsx +19 -0
  30. package/src/app/chat/layout.tsx +14 -0
  31. package/src/app/chat/page.tsx +9 -4
  32. package/src/app/chat/settings/(desktop)/Header/index.tsx +13 -0
  33. package/src/app/chat/settings/{layout.desktop.tsx → (desktop)/layout.desktop.tsx} +5 -4
  34. package/src/app/chat/settings/(mobile)/Header.tsx +12 -0
  35. package/src/app/chat/settings/{layout.mobile.tsx → (mobile)/layout.mobile.tsx} +3 -1
  36. package/src/app/chat/settings/{features → components}/Header/index.tsx +4 -13
  37. package/src/app/chat/settings/layout.tsx +14 -0
  38. package/src/app/chat/settings/page.tsx +36 -5
  39. package/src/app/metadata.ts +4 -1
  40. package/src/app/welcome/page.tsx +2 -6
  41. package/src/components/PageTitle.tsx +11 -0
  42. package/src/layout/AppMobileLayout.tsx +15 -24
  43. package/src/utils/responsive.ts +1 -0
  44. package/src/app/chat/features/Sidebar/index.tsx +0 -29
  45. package/src/app/chat/index.tsx +0 -54
  46. package/src/app/chat/layout.mobile.tsx +0 -20
  47. package/src/app/chat/mobile/index.tsx +0 -38
  48. package/src/app/chat/mobile/page.tsx +0 -7
  49. package/src/app/chat/settings/index.tsx +0 -51
  50. /package/src/app/chat/{features/Conversation/Input → (desktop)/features/ChatInput}/Desktop.tsx +0 -0
  51. /package/src/app/chat/{features/SessionList/Header/Mobile.tsx → (mobile)/features/SessionHeader.tsx} +0 -0
  52. /package/src/app/chat/{features/Header → components/ChatHeader}/PluginTag/PluginStatus.tsx +0 -0
  53. /package/src/app/chat/{features/Header → components/ChatHeader}/PluginTag/index.tsx +0 -0
  54. /package/src/app/chat/{features/Header → components/ChatHeader}/ShareButton/Inner.tsx +0 -0
  55. /package/src/app/chat/{features/Header → components/ChatHeader}/ShareButton/index.tsx +0 -0
  56. /package/src/app/chat/{features/Header → components/ChatHeader}/ShareButton/style.ts +0 -0
  57. /package/src/app/chat/{features/Conversation/Input → components/ChatInput}/ActionBar/ActionLeft.tsx +0 -0
  58. /package/src/app/chat/{features/Conversation/Input → components/ChatInput}/ActionBar/ActionRight.tsx +0 -0
  59. /package/src/app/chat/{features/Conversation/Input → components/ChatInput}/ActionBar/Token.tsx +0 -0
  60. /package/src/app/chat/{features/Conversation/Input → components/ChatInput}/Footer/SaveTopic.tsx +0 -0
  61. /package/src/app/chat/{features/Conversation/Input → components/ChatInput}/Footer/index.tsx +0 -0
  62. /package/src/app/chat/{features/Conversation/Input → components/ChatInput}/Mobile.tsx +0 -0
  63. /package/src/app/chat/{features/Sidebar → components/Inspector}/Mobile.tsx +0 -0
  64. /package/src/app/chat/{features/Sidebar → components/Inspector}/SystemRole/Header.tsx +0 -0
  65. /package/src/app/chat/{features/Sidebar → components/Inspector}/SystemRole/index.tsx +0 -0
  66. /package/src/app/chat/{features/Sidebar → components/Inspector}/SystemRole/style.ts +0 -0
  67. /package/src/app/chat/{features/Sidebar → components/Inspector}/Topic/DefaultContent.tsx +0 -0
  68. /package/src/app/chat/{features/Sidebar → components/Inspector}/Topic/SkeletonList.tsx +0 -0
  69. /package/src/app/chat/{features/Sidebar → components/Inspector}/Topic/TopicContent.tsx +0 -0
  70. /package/src/app/chat/{features/Sidebar → components/Inspector}/Topic/TopicItem.tsx +0 -0
  71. /package/src/app/chat/{features/Sidebar → components/Inspector}/Topic/index.tsx +0 -0
  72. /package/src/app/chat/{features/Sidebar → components/Inspector}/TopicSearchBar/index.tsx +0 -0
  73. /package/src/app/chat/{features → components}/SessionList/CollapseGroup/index.tsx +0 -0
  74. /package/src/app/chat/{features → components}/SessionList/Inbox/index.tsx +0 -0
  75. /package/src/app/chat/{features → components}/SessionList/List/AddButton.tsx +0 -0
  76. /package/src/app/chat/{features → components}/SessionList/List/Item/Actions.tsx +0 -0
  77. /package/src/app/chat/{features → components}/SessionList/List/Item/index.tsx +0 -0
  78. /package/src/app/chat/{features → components}/SessionList/List/SkeletonList.tsx +0 -0
  79. /package/src/app/chat/{features → components}/SessionList/List/index.tsx +0 -0
  80. /package/src/app/chat/settings/{features → (desktop)}/Header/Desktop.tsx +0 -0
  81. /package/src/app/chat/settings/{features → components}/Header/Mobile.tsx +0 -0
@@ -1,21 +1,22 @@
1
+ 'use client';
2
+
1
3
  import { PropsWithChildren, memo } from 'react';
2
4
  import { Flexbox } from 'react-layout-kit';
3
5
 
4
6
  import SafeSpacing from '@/components/SafeSpacing';
5
7
  import { HEADER_HEIGHT } from '@/const/layoutTokens';
6
8
 
7
- import ChatLayout from '../layout.desktop';
8
- import Header from './features/Header';
9
+ import Header from './Header';
9
10
 
10
11
  const DesktopLayout = memo<PropsWithChildren>(({ children }) => {
11
12
  return (
12
- <ChatLayout>
13
+ <>
13
14
  <Header />
14
15
  <Flexbox align={'center'} flex={1} gap={16} padding={24} style={{ overflow: 'auto' }}>
15
16
  <SafeSpacing height={HEADER_HEIGHT - 16} />
16
17
  {children}
17
18
  </Flexbox>
18
- </ChatLayout>
19
+ </>
19
20
  );
20
21
  });
21
22
 
@@ -0,0 +1,12 @@
1
+ import { memo } from 'react';
2
+
3
+ import { HeaderContent } from '@/app/chat/settings/components/Header';
4
+ import Layout from '@/app/chat/settings/components/Header/Mobile';
5
+
6
+ const Header = memo(() => (
7
+ <Layout>
8
+ <HeaderContent />
9
+ </Layout>
10
+ ));
11
+
12
+ export default Header;
@@ -1,8 +1,10 @@
1
+ 'use client';
2
+
1
3
  import { PropsWithChildren, memo } from 'react';
2
4
 
3
5
  import AppMobileLayout from '@/layout/AppMobileLayout';
4
6
 
5
- import Header from './features/Header';
7
+ import Header from './Header';
6
8
 
7
9
  const MobileLayout = memo<PropsWithChildren>(({ children }) => {
8
10
  return <AppMobileLayout navBar={<Header />}>{children}</AppMobileLayout>;
@@ -9,16 +9,11 @@ import { MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
9
9
  import { exportSingleAgent, exportSingleSession } from '@/helpers/export';
10
10
  import { useSessionStore } from '@/store/session';
11
11
 
12
- import Desktop from './Desktop';
13
- import Mobile from './Mobile';
14
-
15
- const Header = memo<{ mobile?: boolean }>(() => {
12
+ export const HeaderContent = memo<{ mobile?: boolean }>(() => {
16
13
  const { t } = useTranslation('setting');
17
14
  const id = useSessionStore((s) => s.activeId);
18
15
  const { mobile } = useResponsive();
19
16
 
20
- const Render = mobile ? Mobile : Desktop;
21
-
22
17
  const items = useMemo<MenuProps['items']>(
23
18
  () => [
24
19
  {
@@ -46,12 +41,8 @@ const Header = memo<{ mobile?: boolean }>(() => {
46
41
  const size = mobile ? MOBILE_HEADER_ICON_SIZE : { fontSize: 24 };
47
42
 
48
43
  return (
49
- <Render>
50
- <Dropdown arrow={false} menu={{ items }} trigger={['click']}>
51
- <ActionIcon icon={HardDriveDownload} size={size} title={t('export', { ns: 'common' })} />
52
- </Dropdown>
53
- </Render>
44
+ <Dropdown arrow={false} menu={{ items }} trigger={['click']}>
45
+ <ActionIcon icon={HardDriveDownload} size={size} title={t('export', { ns: 'common' })} />
46
+ </Dropdown>
54
47
  );
55
48
  });
56
-
57
- export default Header;
@@ -0,0 +1,14 @@
1
+ import { PropsWithChildren } from 'react';
2
+
3
+ import { isMobileDevice } from '@/utils/responsive';
4
+
5
+ import Desktop from './(desktop)/layout.desktop';
6
+ import Mobile from './(mobile)/layout.mobile';
7
+
8
+ const Layout = ({ children }: PropsWithChildren) => {
9
+ const mobile = isMobileDevice();
10
+
11
+ return mobile ? <Mobile>{children}</Mobile> : <Desktop>{children}</Desktop>;
12
+ };
13
+
14
+ export default Layout;
@@ -1,7 +1,38 @@
1
- import Page from './index';
1
+ 'use client';
2
2
 
3
- const Index = () => {
4
- return <Page />;
5
- };
3
+ import isEqual from 'fast-deep-equal';
4
+ import { memo } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
6
 
7
- export default Index;
7
+ import PageTitle from '@/components/PageTitle';
8
+ import AgentSetting from '@/features/AgentSetting';
9
+ import { useSessionStore } from '@/store/session';
10
+ import { agentSelectors } from '@/store/session/selectors';
11
+ import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
12
+
13
+ const EditPage = memo(() => {
14
+ const { t } = useTranslation('setting');
15
+ const config = useSessionStore(agentSelectors.currentAgentConfig, isEqual);
16
+ const meta = useSessionStore(agentSelectors.currentAgentMeta, isEqual);
17
+ const [updateAgentConfig, updateAgentMeta, title] = useSessionStore((s) => [
18
+ s.updateAgentConfig,
19
+ s.updateAgentMeta,
20
+ agentSelectors.currentAgentTitle(s),
21
+ ]);
22
+
23
+ const pageTitle = genSiteHeadTitle(t('header.sessionWithName', { name: title }));
24
+
25
+ return (
26
+ <>
27
+ <PageTitle title={pageTitle} />
28
+ <AgentSetting
29
+ config={config}
30
+ meta={meta}
31
+ onConfigChange={updateAgentConfig}
32
+ onMetaChange={updateAgentMeta}
33
+ />
34
+ </>
35
+ );
36
+ });
37
+
38
+ export default EditPage;
@@ -46,7 +46,10 @@ const metadata: Metadata = {
46
46
  { color: '#f8f8f8', media: '(prefers-color-scheme: light)' },
47
47
  { color: '#000', media: '(prefers-color-scheme: dark)' },
48
48
  ],
49
- title: title,
49
+ title: {
50
+ default: title,
51
+ template: '%s · LobeChat',
52
+ },
50
53
  viewport: {
51
54
  initialScale: 1,
52
55
  maximumScale: 1,
@@ -1,16 +1,12 @@
1
1
  import { t } from 'i18next';
2
2
  import { Metadata } from 'next';
3
3
 
4
- import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
5
-
6
4
  import Banner from './features/Banner';
7
5
 
8
6
  export const generateMetadata = (): Metadata => ({
9
- title: genSiteHeadTitle(t('header', { ns: 'welcome' })),
7
+ title: t('header', { ns: 'welcome' }),
10
8
  });
11
9
 
12
- const Page = () => {
13
- return <Banner />;
14
- };
10
+ const Page = () => <Banner />;
15
11
 
16
12
  export default Page;
@@ -0,0 +1,11 @@
1
+ import { memo, useEffect } from 'react';
2
+
3
+ const PageTitle = memo<{ title: string }>(({ title }) => {
4
+ useEffect(() => {
5
+ document.title = title;
6
+ }, [title]);
7
+
8
+ return null;
9
+ });
10
+
11
+ export default PageTitle;
@@ -1,6 +1,5 @@
1
1
  import { type MobileNavBarTitleProps } from '@lobehub/ui';
2
2
  import { createStyles } from 'antd-style';
3
- import Head from 'next/head';
4
3
  import { CSSProperties, PropsWithChildren, ReactNode, memo } from 'react';
5
4
  import { Flexbox } from 'react-layout-kit';
6
5
 
@@ -49,29 +48,21 @@ const AppMobileLayout = memo<AppMobileLayoutProps>(
49
48
  const { styles, cx } = useStyles();
50
49
 
51
50
  return (
52
- <>
53
- <Head>
54
- <meta
55
- content="width=device-width, initial-scale=1.0, viewport-fit=cover"
56
- name="viewport"
57
- />
58
- </Head>
59
- <Flexbox className={cx(styles.container, className)} style={style}>
60
- {navBar && (
61
- <>
62
- <div className={styles.mobileNavBar}>{navBar}</div>
63
- <SafeSpacing mobile position={'top'} />
64
- </>
65
- )}
66
- {children}
67
- {showTabBar && (
68
- <>
69
- <SafeSpacing mobile position={'bottom'} />
70
- <MobileTabBar className={styles.mobileTabBar} />
71
- </>
72
- )}
73
- </Flexbox>
74
- </>
51
+ <Flexbox className={cx(styles.container, className)} style={style}>
52
+ {navBar && (
53
+ <>
54
+ <div className={styles.mobileNavBar}>{navBar}</div>
55
+ <SafeSpacing mobile position={'top'} />
56
+ </>
57
+ )}
58
+ {children}
59
+ {showTabBar && (
60
+ <>
61
+ <SafeSpacing mobile position={'bottom'} />
62
+ <MobileTabBar className={styles.mobileTabBar} />
63
+ </>
64
+ )}
65
+ </Flexbox>
75
66
  );
76
67
  },
77
68
  );
@@ -12,6 +12,7 @@ export const isMobileDevice = () => {
12
12
  const { get } = headers();
13
13
  const ua = get('user-agent');
14
14
 
15
+ console.log(ua);
15
16
  const device = new UAParser(ua || '').getDevice();
16
17
 
17
18
  return device.type === 'mobile';
@@ -1,29 +0,0 @@
1
- import { useResponsive } from 'antd-style';
2
- import { memo } from 'react';
3
- import { Flexbox } from 'react-layout-kit';
4
-
5
- import Desktop from './Desktop';
6
- import Mobile from './Mobile';
7
- import { Topic } from './Topic';
8
- import TopicSearchBar from './TopicSearchBar';
9
-
10
- const SideBar = memo(() => {
11
- const { mobile } = useResponsive();
12
-
13
- const Render = mobile ? Mobile : Desktop;
14
-
15
- return (
16
- <Render>
17
- <Flexbox height={'100%'} style={{ overflow: 'hidden' }}>
18
- <Flexbox padding={16}>
19
- <TopicSearchBar />
20
- </Flexbox>
21
- <Flexbox gap={16} paddingInline={16} style={{ overflowY: 'auto', position: 'relative' }}>
22
- <Topic />
23
- </Flexbox>
24
- </Flexbox>
25
- </Render>
26
- );
27
- });
28
-
29
- export default SideBar;
@@ -1,54 +0,0 @@
1
- 'use client';
2
-
3
- import { useResponsive } from 'antd-style';
4
- import Head from 'next/head';
5
- import { memo } from 'react';
6
- import { Flexbox } from 'react-layout-kit';
7
-
8
- import { useSessionStore } from '@/store/session';
9
- import { useEffectAfterSessionHydrated } from '@/store/session/hooks';
10
- import { agentSelectors } from '@/store/session/selectors';
11
- import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
12
-
13
- import Conversation from './features/Conversation';
14
- import Header from './features/Header';
15
- import SideBar from './features/Sidebar';
16
- import DesktopLayout from './layout.desktop';
17
- import MobileLayout from './layout.mobile';
18
-
19
- const Chat = memo(() => {
20
- const { mobile } = useResponsive();
21
- const [avatar, title] = useSessionStore((s) => [
22
- agentSelectors.currentAgentAvatar(s),
23
- agentSelectors.currentAgentTitle(s),
24
- ]);
25
- const pageTitle = genSiteHeadTitle([avatar, title].filter(Boolean).join(' '));
26
- const RenderLayout = mobile ? MobileLayout : DesktopLayout;
27
-
28
- useEffectAfterSessionHydrated(
29
- (store) => {
30
- store.setState({ isMobile: mobile });
31
- },
32
- [mobile],
33
- );
34
-
35
- return (
36
- <>
37
- <Head>
38
- <title>{pageTitle}</title>
39
- </Head>
40
- <RenderLayout>
41
- {!mobile && (
42
- <>
43
- <Header />
44
- <Flexbox flex={1} height={'calc(100vh - 64px)'} horizontal>
45
- <Conversation />
46
- <SideBar />
47
- </Flexbox>
48
- </>
49
- )}
50
- </RenderLayout>
51
- </>
52
- );
53
- });
54
- export default Chat;
@@ -1,20 +0,0 @@
1
- import { memo } from 'react';
2
-
3
- import AppMobileLayout from '@/layout/AppMobileLayout';
4
- import { useSwitchSideBarOnInit } from '@/store/global';
5
- import { SidebarTabKey } from '@/store/global/initialState';
6
-
7
- import { Sessions } from './features/SessionList';
8
- import Header from './features/SessionList/Header';
9
-
10
- const ChatMobileLayout = memo(() => {
11
- useSwitchSideBarOnInit(SidebarTabKey.Chat);
12
-
13
- return (
14
- <AppMobileLayout navBar={<Header />} showTabBar>
15
- <Sessions />
16
- </AppMobileLayout>
17
- );
18
- });
19
-
20
- export default ChatMobileLayout;
@@ -1,38 +0,0 @@
1
- 'use client';
2
-
3
- import Head from 'next/head';
4
- import { memo } from 'react';
5
- import { Flexbox } from 'react-layout-kit';
6
-
7
- import AppMobileLayout from '@/layout/AppMobileLayout';
8
- import { useSessionStore } from '@/store/session';
9
- import { agentSelectors } from '@/store/session/selectors';
10
- import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
11
-
12
- import Conversation from '../features/Conversation';
13
- import Header from '../features/Header';
14
- import SideBar from '../features/Sidebar';
15
-
16
- const Chat = memo(() => {
17
- const [avatar, title] = useSessionStore((s) => [
18
- agentSelectors.currentAgentAvatar(s),
19
- agentSelectors.currentAgentTitle(s),
20
- ]);
21
-
22
- const pageTitle = genSiteHeadTitle([avatar, title].filter(Boolean).join(' '));
23
-
24
- return (
25
- <>
26
- <Head>
27
- <title>{pageTitle}</title>
28
- </Head>
29
- <AppMobileLayout navBar={<Header />}>
30
- <Flexbox height={'calc(100vh - 44px)'} horizontal>
31
- <Conversation mobile />
32
- <SideBar />
33
- </Flexbox>
34
- </AppMobileLayout>
35
- </>
36
- );
37
- });
38
- export default Chat;
@@ -1,7 +0,0 @@
1
- import Page from './index';
2
-
3
- const Index = () => {
4
- return <Page />;
5
- };
6
-
7
- export default Index;
@@ -1,51 +0,0 @@
1
- 'use client';
2
-
3
- import { useResponsive } from 'antd-style';
4
- import isEqual from 'fast-deep-equal';
5
- import Head from 'next/head';
6
- import { memo } from 'react';
7
- import { useTranslation } from 'react-i18next';
8
-
9
- import AgentSetting from '@/features/AgentSetting';
10
- import { useSessionStore } from '@/store/session';
11
- import { agentSelectors } from '@/store/session/selectors';
12
- import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
13
-
14
- import DesktopLayout from './layout.desktop';
15
- import MobileLayout from './layout.mobile';
16
-
17
- const EditPage = memo(() => {
18
- const { mobile } = useResponsive();
19
- const { t } = useTranslation('setting');
20
- const config = useSessionStore(agentSelectors.currentAgentConfig, isEqual);
21
- const meta = useSessionStore(agentSelectors.currentAgentMeta, isEqual);
22
- const [updateAgentConfig, updateAgentMeta, title] = useSessionStore((s) => [
23
- s.updateAgentConfig,
24
- s.updateAgentMeta,
25
- agentSelectors.currentAgentTitle(s),
26
- ]);
27
-
28
- const pageTitle = genSiteHeadTitle(t('header.sessionWithName', { name: title }));
29
-
30
- const settings = (
31
- <AgentSetting
32
- config={config}
33
- meta={meta}
34
- onConfigChange={updateAgentConfig}
35
- onMetaChange={updateAgentMeta}
36
- />
37
- );
38
-
39
- const RenderLayout = mobile ? MobileLayout : DesktopLayout;
40
-
41
- return (
42
- <>
43
- <Head>
44
- <title>{pageTitle}</title>
45
- </Head>
46
- <RenderLayout>{settings}</RenderLayout>
47
- </>
48
- );
49
- });
50
-
51
- export default EditPage;