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.

🐛 fix(chat-input): keep input mounted while intervention panel is shown (#15283)

Innei84598524df68
diff --git a/src/features/ChatInput/Desktop/index.tsx b/src/features/ChatInput/Desktop/index.tsx
index c1589efca31..1115714533e 100644
--- a/src/features/ChatInput/Desktop/index.tsx
+++ b/src/features/ChatInput/Desktop/index.tsx
@@ -62,6 +62,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
interface DesktopChatInputProps extends ActionToolbarProps {
actionBarStyle?: React.CSSProperties;
extentHeaderContent?: ReactNode;
+ hidden?: boolean;
inputContainerProps?: ChatInputProps;
/**
* Swap the action bar and send area for skeleton placeholders while
@@ -94,6 +95,7 @@ const DesktopChatInput = memo<DesktopChatInputProps>(
borderRadius,
extraActionItems,
dropdownPlacement,
+ hidden,
isConfigLoading = false,
leftContent,
placeholder,
@@ -151,6 +153,7 @@ const DesktopChatInput = memo<DesktopChatInputProps>(
className={cx(styles.container, expand && styles.fullscreen)}
gap={8}
paddingBlock={expand ? 0 : showFootnote ? '0 12px' : '0 8px'}
+ style={{ display: hidden ? 'none' : undefined }}
onDragOver={skillDrop.onDragOver}
onDrop={skillDrop.onDrop}
>
@@ -224,4 +227,4 @@ const DesktopChatInput = memo<DesktopChatInputProps>(
DesktopChatInput.displayName = 'DesktopChatInput';
-export default DesktopChatInput;
+export default DesktopChatInput;
\ No newline at end of file
diff --git a/src/features/Conversation/ChatInput/index.tsx b/src/features/Conversation/ChatInput/index.tsx
index d2b89586ea6..928a1289b10 100644
--- a/src/features/Conversation/ChatInput/index.tsx
+++ b/src/features/Conversation/ChatInput/index.tsx
@@ -290,47 +290,47 @@ const ChatInput = memo<ChatInputProps>(
<WideScreenContainer
style={{ position: 'relative', ...(skipScrollMarginWithList ? { marginTop: -12 } : null) }}
>
- {hasPendingInterventions ? (
- <InterventionBar interventions={pendingInterventions} />
- ) : (
- <>
- {sendMessageErrorMsg && (
- <Flexbox paddingBlock={'0 6px'} paddingInline={12}>
- <Alert
- closable
- title={t('input.errorMsg', { errorMsg: sendMessageErrorMsg })}
- type={'secondary'}
- onClose={clearSendMessageError}
- />
- </Flexbox>
- )}
- <Flexbox
- paddingInline={12}
- ref={overlayRef}
- style={{
- bottom: '100%',
- left: 12,
- position: 'absolute',
- right: 12,
- zIndex: 10,
- }}
- >
- {!disableQueue && hasQueuedMessages && <QueueTray />}
- <TodoProgress topAttached={!disableQueue && hasQueuedMessages} />
+ {hasPendingInterventions && <InterventionBar interventions={pendingInterventions} />}
+ {/* Keep the chat input mounted while an intervention panel is showing —
+ unmounting would wipe the Lexical editor's in-memory document. */}
+ <div style={{ display: hasPendingInterventions ? 'none' : 'contents' }}>
+ {sendMessageErrorMsg && (
+ <Flexbox paddingBlock={'0 6px'} paddingInline={12}>
+ <Alert
+ closable
+ title={t('input.errorMsg', { errorMsg: sendMessageErrorMsg })}
+ type={'secondary'}
+ onClose={clearSendMessageError}
+ />
</Flexbox>
- <DesktopChatInput
- actionBarStyle={actionBarStyle}
- borderRadius={12}
- extraActionItems={extraActionItems}
- isConfigLoading={isConfigLoading}
- leftContent={leftContent}
- placeholderVariant={placeholderVariant}
- runtimeConfigSlot={runtimeConfigSlot}
- sendAreaPrefix={businessSendAreaPrefix}
- showRuntimeConfig={showRuntimeConfig}
- />
- </>
- )}
+ )}
+ <Flexbox
+ paddingInline={12}
+ ref={overlayRef}
+ style={{
+ bottom: '100%',
+ left: 12,
+ position: 'absolute',
+ right: 12,
+ zIndex: 10,
+ }}
+ >
+ {!disableQueue && hasQueuedMessages && <QueueTray />}
+ <TodoProgress topAttached={!disableQueue && hasQueuedMessages} />
+ </Flexbox>
+ <DesktopChatInput
+ actionBarStyle={actionBarStyle}
+ borderRadius={12}
+ extraActionItems={extraActionItems}
+ hidden={hasPendingInterventions}
+ isConfigLoading={isConfigLoading}
+ leftContent={leftContent}
+ placeholderVariant={placeholderVariant}
+ runtimeConfigSlot={runtimeConfigSlot}
+ sendAreaPrefix={businessSendAreaPrefix}
+ showRuntimeConfig={showRuntimeConfig}
+ />
+ </div>
</WideScreenContainer>
);
@@ -365,4 +365,4 @@ const ChatInput = memo<ChatInputProps>(
ChatInput.displayName = 'ConversationChatInput';
-export default ChatInput;
+export default ChatInput;
\ No newline at end of file