Skip to content

🤯 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.

💄 style(chat-input): show skeleton in action bar while config is loading (#14656)

Arvin Xudb22573a885a
diff --git a/locales/en-US/home.json b/locales/en-US/home.json
index 18dc07eee17..522891768fa 100644
--- a/locales/en-US/home.json
+++ b/locales/en-US/home.json
@@ -6,7 +6,7 @@
"brief.action.acknowledge": "Acknowledge",
"brief.action.approve": "Approve",
"brief.action.confirm": "Confirm",
- "brief.action.confirmDone": "Confirm",
+ "brief.action.confirmDone": "Confirm complete",
"brief.action.feedback": "Feedback",
"brief.action.retry": "Retry",
"brief.addFeedback": "Share feedback",
diff --git a/locales/zh-CN/home.json b/locales/zh-CN/home.json
index c2e97d1bbc5..3b6d16e2ac6 100644
--- a/locales/zh-CN/home.json
+++ b/locales/zh-CN/home.json
@@ -5,8 +5,8 @@
"agentSelection.search": "未找到匹配的助理",
"brief.action.acknowledge": "确认",
"brief.action.approve": "批准",
- "brief.action.confirm": "确认",
- "brief.action.confirmDone": "确认",
+ "brief.action.confirm": "已阅",
+ "brief.action.confirmDone": "确认完成",
"brief.action.feedback": "反馈",
"brief.action.retry": "重试",
"brief.addFeedback": "分享反馈",
diff --git a/src/features/ChatInput/Desktop/index.tsx b/src/features/ChatInput/Desktop/index.tsx
index 40288345ac3..51a5f8a160e 100644
--- a/src/features/ChatInput/Desktop/index.tsx
+++ b/src/features/ChatInput/Desktop/index.tsx
@@ -2,7 +2,7 @@
import { type ChatInputProps } from '@lobehub/editor/react';
import { ChatInput, ChatInputActionBar } from '@lobehub/editor/react';
-import { Center, Flexbox, Text } from '@lobehub/ui';
+import { Center, Flexbox, Skeleton, Text } from '@lobehub/ui';
import { createStaticStyles, cx } from 'antd-style';
import { type ReactNode, use } from 'react';
import { memo, useEffect } from 'react';
@@ -62,9 +62,16 @@ interface DesktopChatInputProps extends ActionToolbarProps {
actionBarStyle?: React.CSSProperties;
extentHeaderContent?: ReactNode;
inputContainerProps?: ChatInputProps;
+ /**
+ * Swap the action bar and send area for skeleton placeholders while
+ * the underlying agent / group / session config is still hydrating.
+ * The editor itself stays usable. Wins over `leftContent` / `rightContent`.
+ */
+ isConfigLoading?: boolean;
leftContent?: ReactNode;
placeholder?: ReactNode;
placeholderVariant?: PlaceholderVariant;
+ rightContent?: ReactNode;
/**
* Custom node to render in place of the default RuntimeConfig bar.
* When provided, used instead of `<RuntimeConfig />` (ignores `showRuntimeConfig`).
@@ -86,9 +93,11 @@ const DesktopChatInput = memo<DesktopChatInputProps>(
borderRadius,
extraActionItems,
dropdownPlacement,
+ isConfigLoading = false,
leftContent,
placeholder,
placeholderVariant,
+ rightContent,
sendAreaPrefix,
}) => {
const { t } = useTranslation('chat');
@@ -120,6 +129,21 @@ const DesktopChatInput = memo<DesktopChatInputProps>(
leftActions.flat().includes('fileUpload') || hasContextSelections || hasFiles;
const contextContainerNode = shouldShowContextContainer && <ContextContainer />;
+ const loadingLeftSlot = isConfigLoading ? (
+ <Flexbox horizontal align="center" gap={6} paddingInline={4}>
+ <Skeleton.Button active shape="circle" size="small" style={{ height: 28, width: 28 }} />
+ <Skeleton.Button active shape="circle" size="small" style={{ height: 28, width: 28 }} />
+ </Flexbox>
+ ) : null;
+ const loadingRightSlot = isConfigLoading ? (
+ <Skeleton.Button
+ active
+ shape="round"
+ size="small"
+ style={{ height: 32, minWidth: 64, width: 64 }}
+ />
+ ) : null;
+
const content = (
<Flexbox
className={cx(styles.container, expand && styles.fullscreen)}
@@ -138,6 +162,7 @@ const DesktopChatInput = memo<DesktopChatInputProps>(
<ChatInputActionBar
style={actionBarStyle ?? { paddingRight: 8 }}
left={
+ loadingLeftSlot ??
leftContent ?? (
<ActionBar
borderRadius={borderRadius}
@@ -147,14 +172,16 @@ const DesktopChatInput = memo<DesktopChatInputProps>(
)
}
right={
- sendAreaPrefix ? (
+ loadingRightSlot ??
+ rightContent ??
+ (sendAreaPrefix ? (
<Flexbox horizontal align={'center'} gap={6}>
{sendAreaPrefix}
<SendArea />
</Flexbox>
) : (
<SendArea />
- )
+ ))
}
/>
}
diff --git a/src/features/Conversation/ChatInput/index.tsx b/src/features/Conversation/ChatInput/index.tsx
index 61eff7716cd..a8c78eba48e 100644
--- a/src/features/Conversation/ChatInput/index.tsx
+++ b/src/features/Conversation/ChatInput/index.tsx
@@ -85,6 +85,12 @@ export interface ChatInputProps {
* Extra action items to append to the ActionBar
*/
extraActionItems?: ChatInputActionsProps['items'];
+ /**
+ * Swap the action bar and send area for skeleton placeholders while
+ * the underlying agent/session config is still hydrating. The editor
+ * itself stays usable.
+ */
+ isConfigLoading?: boolean;
/**
* Left action buttons configuration
*/
@@ -151,6 +157,7 @@ const ChatInput = memo<ChatInputProps>(
rightActions = [],
children,
extraActionItems,
+ isConfigLoading = false,
mentionItems,
runtimeConfigSlot,
sendMenu,
@@ -324,6 +331,7 @@ const ChatInput = memo<ChatInputProps>(
actionBarStyle={actionBarStyle}
borderRadius={12}
extraActionItems={extraActionItems}
+ isConfigLoading={isConfigLoading}
leftContent={leftContent}
placeholderVariant={placeholderVariant}
runtimeConfigSlot={runtimeConfigSlot}
diff --git a/src/locales/default/home.ts b/src/locales/default/home.ts
index fea1b7582af..723b7fc9ac9 100644
--- a/src/locales/default/home.ts
+++ b/src/locales/default/home.ts
@@ -7,7 +7,7 @@ export default {
'brief.action.acknowledge': 'Acknowledge',
'brief.action.approve': 'Approve',
'brief.action.confirm': 'Confirm',
- 'brief.action.confirmDone': 'Confirm',
+ 'brief.action.confirmDone': 'Confirm complete',
'brief.action.feedback': 'Feedback',
'brief.action.retry': 'Retry',
'brief.collapse': 'Show less',
diff --git a/src/routes/(main)/agent/features/Conversation/MainChatInput/index.tsx b/src/routes/(main)/agent/features/Conversation/MainChatInput/index.tsx
index eab37d43bf2..1dfa4ce6981 100644
--- a/src/routes/(main)/agent/features/Conversation/MainChatInput/index.tsx
+++ b/src/routes/(main)/agent/features/Conversation/MainChatInput/index.tsx
@@ -30,6 +30,7 @@ const MainChatInput = memo(() => {
const model = useAgentStore(agentSelectors.currentAgentModel);
const provider = useAgentStore(agentSelectors.currentAgentModelProvider);
+ const isAgentConfigLoading = useAgentStore(agentSelectors.isAgentConfigLoading);
const supportsImageOutput = useModelSupportImageOutput(model, provider);
const rightActions = supportsImageOutput ? promptTransformRightActions : emptyRightActions;
@@ -50,6 +51,7 @@ const MainChatInput = memo(() => {
return (
<ChatInput
skipScrollMarginWithList
+ isConfigLoading={isAgentConfigLoading}
leftActions={leftActions}
rightActions={rightActions}
{...(isDevMode
diff --git a/src/routes/(main)/group/features/Conversation/MainChatInput/GroupChat.tsx b/src/routes/(main)/group/features/Conversation/MainChatInput/GroupChat.tsx
index 407d46fd05a..d1662a0b124 100644
--- a/src/routes/(main)/group/features/Conversation/MainChatInput/GroupChat.tsx
+++ b/src/routes/(main)/group/features/Conversation/MainChatInput/GroupChat.tsx
@@ -39,6 +39,7 @@ const Desktop = memo((props: { targetMemberId?: string }) => {
const isDMPortal = !!props.targetMemberId;
const currentGroupMembers = useAgentGroupStore(agentGroupSelectors.currentGroupAgents, isEqual);
+ const isGroupConfigLoading = useAgentGroupStore(agentGroupSelectors.isGroupsInit);
const [mainInputSendErrorMsg, clearSendMessageError] = useChatStore((s) => [
aiChatSelectors.isCurrentSendMessageError(s),
@@ -108,7 +109,7 @@ const Desktop = memo((props: { targetMemberId?: string }) => {
/>
</Flexbox>
)}
- <DesktopChatInput />
+ <DesktopChatInput isConfigLoading={isGroupConfigLoading} />
</WideScreenContainer>
<Suspense>
<MessageFromUrl />