🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
'use client';
import { BRANDING_NAME } from '@lobechat/business-const';
import { DEFAULT_INBOX_TITLE } from '@lobechat/const';
import { type IconProps } from '@lobehub/ui';
import {
Block,
Button,
createStaticStyles,
cssVar,
Flexbox,
Icon,
Steps,
Switch,
Text,
} from '@lobehub/ui';
import { TypewriterEffect } from '@lobehub/ui/awesome';
import { LoadingDots } from '@lobehub/ui/chat';
import { BrainIcon, HeartHandshakeIcon, PencilRulerIcon, ShieldCheck } from 'lucide-react';
import { memo, useCallback, useRef, useState } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import { ProductLogo } from '@/components/Branding';
import { PRIVACY_URL, TERMS_URL } from '@/const/url';
import { useUserStore } from '@/store/user';
// `&&` outranks base-ui's own vertical connector rule so the rail centres under the 32px icons.
const styles = createStaticStyles(({ css }) => ({
steps: css`
&& > li > span[aria-hidden] {
inset-block-start: 36px;
inset-inline-start: 16px;
}
`,
}));
interface TelemetryStepProps {
onNext: () => void;
}
const TelemetryStep = memo<TelemetryStepProps>(({ onNext }) => {
const { t, i18n } = useTranslation('onboarding');
const locale = i18n.language;
const [check, setCheck] = useState(true);
const [isNavigating, setIsNavigating] = useState(false);
const isNavigatingRef = useRef(false);
const updateGeneralConfig = useUserStore((s) => s.updateGeneralConfig);
const handleChoice = useCallback(
(enabled: boolean) => {
if (isNavigatingRef.current) return;
isNavigatingRef.current = true;
setIsNavigating(true);
updateGeneralConfig({ telemetry: enabled });
onNext();
},
[updateGeneralConfig, onNext],
);
// eslint-disable-next-line @eslint-react/no-nested-component-definitions
const IconAvatar = useCallback(({ icon }: { icon: IconProps['icon'] }) => {
return (
<Block
shadow
align="center"
height={32}
justify="center"
padding={4}
variant="outlined"
width={32}
>
<Icon color={cssVar.colorTextDescription} icon={icon} size={16} />
</Block>
);
}, []);
return (
<Flexbox gap={16}>
<ProductLogo size={64} />
<Flexbox style={{ marginBottom: 16 }}>
<Text as={'h1'} fontSize={28} weight={'bold'}>
<TypewriterEffect
cursorCharacter={<LoadingDots size={28} variant={'pulse'} />}
cursorFade={false}
deletePauseDuration={1000}
deletingSpeed={32}
hideCursorWhileTyping={'afterTyping'}
key={locale}
pauseDuration={16_000}
typingSpeed={64}
sentences={[
t('telemetry.title', { name: DEFAULT_INBOX_TITLE }),
t('telemetry.title2'),
t('telemetry.title3'),
]}
/>
</Text>
<Text as={'p'}>{t('telemetry.desc')}</Text>
</Flexbox>
<Steps
className={styles.steps}
orientation={'vertical'}
styles={{ indicator: { border: 'none', height: 32, width: 32 } }}
items={[
{
description: (
<Text as={'p'} color={cssVar.colorTextSecondary} style={{ marginBottom: 16 }}>
{t('telemetry.rows.create.desc')}
</Text>
),
icon: <IconAvatar icon={PencilRulerIcon} />,
title: (
<Text as={'h2'} fontSize={16}>
{t('telemetry.rows.create.title')}
</Text>
),
},
{
description: (
<Text as={'p'} color={cssVar.colorTextSecondary} style={{ marginBottom: 16 }}>
{t('telemetry.rows.collaborate.desc')}
</Text>
),
icon: <IconAvatar icon={HeartHandshakeIcon} />,
title: (
<Text as={'h2'} fontSize={16}>
{t('telemetry.rows.collaborate.title')}
</Text>
),
},
{
description: (
<Text as={'p'} color={cssVar.colorTextSecondary}>
{t('telemetry.rows.evolve.desc')}
</Text>
),
icon: <IconAvatar icon={BrainIcon} />,
title: (
<Text as={'h2'} fontSize={16}>
{t('telemetry.rows.evolve.title')}
</Text>
),
},
]}
/>
<Flexbox gap={8}>
<Text as={'p'} color={cssVar.colorTextSecondary}>
{t('telemetry.rows.privacy.desc', { appName: BRANDING_NAME })}
</Text>
<Flexbox horizontal align="center" gap={8}>
<Switch checked={check} size={'small'} onChange={(v) => setCheck(v)} />
<Text fontSize={12} type={check ? undefined : 'secondary'}>
{t('telemetry.rows.privacy.title', { appName: BRANDING_NAME })}
</Text>
</Flexbox>
</Flexbox>
<Button
disabled={isNavigating}
size={'large'}
type="primary"
style={{
marginBlock: 8,
maxWidth: 240,
}}
onClick={() => handleChoice(check)}
>
{t('telemetry.next')}
</Button>
{check && (
<Block horizontal align="flex-start" gap={8} variant={'borderless'}>
<Icon
icon={ShieldCheck}
size={16}
style={{ color: cssVar.colorSuccess, flexShrink: 0 }}
/>
<Text fontSize={12} type="secondary">
{/* New window: Desktop hands it to the system browser, Web keeps onboarding progress */}
<Trans
i18nKey={'telemetry.agreement'}
ns={'onboarding'}
components={{
privacy: (
<a
href={PRIVACY_URL}
rel="noopener noreferrer"
style={{ color: 'inherit', cursor: 'pointer', textDecoration: 'underline' }}
target="_blank"
>
{t('telemetry.terms')}
</a>
),
terms: (
<a
href={TERMS_URL}
rel="noopener noreferrer"
style={{ color: 'inherit', cursor: 'pointer', textDecoration: 'underline' }}
target="_blank"
>
{t('telemetry.privacy')}
</a>
),
}}
/>
</Text>
</Block>
)}
</Flexbox>
);
});
TelemetryStep.displayName = 'TelemetryStep';
export default TelemetryStep;