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): show the running state once in the conversation composer (#23587)

AmAzing-009305e0217c
diff --git a/src/features/ChatInput/SendArea/RunningIndicator.tsx b/src/features/ChatInput/SendArea/RunningIndicator.tsx
index 8e3df5d0746..a52e381baa4 100644
--- a/src/features/ChatInput/SendArea/RunningIndicator.tsx
+++ b/src/features/ChatInput/SendArea/RunningIndicator.tsx
@@ -8,12 +8,15 @@ import { useChatInputStore } from '../store';
/**
* A small spinner at the head of the send area while the agent runs, so it sits
* beside the model selector that qualifies the run. Stop itself stays static.
+ * Hosts that already show the run elsewhere turn it off with `hideRunningIndicator`.
*/
const RunningIndicator = memo(() => {
const { t } = useTranslation('chat');
- const generating = useChatInputStore((s) => !!s.sendButtonProps?.generating);
+ const visible = useChatInputStore(
+ (s) => !!s.sendButtonProps?.generating && !s.sendButtonProps.hideRunningIndicator,
+ );
- if (!generating) return null;
+ if (!visible) return null;
return (
<Tooltip title={t('input.running')}>
diff --git a/src/features/ChatInput/SendArea/SendButton.tsx b/src/features/ChatInput/SendArea/SendButton.tsx
index 316477a86de..08a8a68a01f 100644
--- a/src/features/ChatInput/SendArea/SendButton.tsx
+++ b/src/features/ChatInput/SendArea/SendButton.tsx
@@ -39,7 +39,7 @@ const SendButton = memo(() => {
const canSend = canCreate && !viewOnly;
// Only a pending send spins, inside Send itself. A running turn shows a static
- // Stop; the run is indicated once, by RunningIndicator beside the model selector.
+ // Stop; the run is indicated once, by the host's status or RunningIndicator.
// Send sits beside Stop for the follow-up the user typed (Enter sends too).
const renderSend = (pending: boolean) =>
pending ? (
diff --git a/src/features/ChatInput/SendArea/StateButton.tsx b/src/features/ChatInput/SendArea/StateButton.tsx
index 57a009eb02d..67403ff985d 100644
--- a/src/features/ChatInput/SendArea/StateButton.tsx
+++ b/src/features/ChatInput/SendArea/StateButton.tsx
@@ -22,7 +22,7 @@ const buttonStyle = (size: number) => ({
/**
* Stops the running turn. A plain square, still: the run itself is indicated once,
- * by `RunningIndicator` beside the model selector.
+ * by the host's status or `RunningIndicator`.
*/
export const StopButton = memo<StateButtonProps & { onStop: () => void }>(
({ onStop, shape, size = 32 }) => {
diff --git a/src/features/ChatInput/store/initialState.ts b/src/features/ChatInput/store/initialState.ts
index b4f0c41f5d6..0f47d23d7bb 100644
--- a/src/features/ChatInput/store/initialState.ts
+++ b/src/features/ChatInput/store/initialState.ts
@@ -21,6 +21,11 @@ export type VoiceMessageSendHandler = (recording: VoiceMessageRecording) => bool
export interface SendButtonProps {
disabled?: boolean;
generating: boolean;
+ /**
+ * The host already shows the run elsewhere (e.g. the conversation status tray),
+ * so the send area skips its own running spinner.
+ */
+ hideRunningIndicator?: boolean;
/**
* A send was committed but has not reached the agent yet (the message and its
* topic are still being created). Send shows as loading instead of Stop: there
diff --git a/src/features/Conversation/ChatInput/OpStatusTray.tsx b/src/features/Conversation/ChatInput/OpStatusTray.tsx
index ecf7b6f9fd4..70bf5857a9f 100644
--- a/src/features/Conversation/ChatInput/OpStatusTray.tsx
+++ b/src/features/Conversation/ChatInput/OpStatusTray.tsx
@@ -12,7 +12,6 @@ import { useTranslation } from 'react-i18next';
import { useChatStore } from '@/store/chat';
import { operationSelectors } from '@/store/chat/selectors';
-import { AI_RUNTIME_OPERATION_TYPES } from '@/store/chat/slices/operation/types';
import { shinyTextStyles } from '@/styles';
import { calculateOperationUsageMetrics } from '@/utils/operationUsageMetrics';
@@ -20,6 +19,7 @@ import { contextSelectors, dataSelectors, useConversationStore } from '../store'
import { type ActivityKey, resolveOperationActivity } from '../utils/operationActivity';
import AnimatedCount from './OpStatusTray/AnimatedCount';
import { parseStatusPhrases, pickRotatingStatusPhrase } from './OpStatusTray/logic';
+import { isOpStatusRuntimeOperation } from './OpStatusTray/visibility';
// Cycle the generating phrase like a carousel so a long-running task doesn't
// stare back with the same line the whole time.
@@ -227,10 +227,7 @@ const OpStatusTray = memo<OpStatusTrayProps>(({ seamless, topAttached }) => {
activity = mapped;
}
- const isSteeredSend = op.type === 'sendMessage' && op.metadata.turnStartTime !== undefined;
- if (!AI_RUNTIME_OPERATION_TYPES.includes(op.type) && !isSteeredSend) {
- continue;
- }
+ if (!isOpStatusRuntimeOperation(op)) continue;
runtimeOperationIds.push(op.id);
// Prefer the explicit LLM-call total; older servers only sent the
diff --git a/src/features/Conversation/ChatInput/OpStatusTray/visibility.ts b/src/features/Conversation/ChatInput/OpStatusTray/visibility.ts
new file mode 100644
index 00000000000..9b8f89005ba
--- /dev/null
+++ b/src/features/Conversation/ChatInput/OpStatusTray/visibility.ts
@@ -0,0 +1,40 @@
+import type { ChatStoreState } from '@/store/chat';
+import { operationSelectors } from '@/store/chat/selectors';
+import type { Operation } from '@/store/chat/slices/operation/types';
+import { AI_RUNTIME_OPERATION_TYPES } from '@/store/chat/slices/operation/types';
+import type { MessageMapKeyInput } from '@/store/chat/utils/messageMapKey';
+
+/**
+ * Whether an operation drives the tray's timer. Child operations inherit
+ * `turnStartTime`, so only a steered `sendMessage` counts beyond runtime types.
+ */
+export const isOpStatusRuntimeOperation = (op: Operation): boolean =>
+ AI_RUNTIME_OPERATION_TYPES.includes(op.type) ||
+ (op.type === 'sendMessage' && op.metadata.turnStartTime !== undefined);
+
+/**
+ * Whether `OpStatusTray` renders for a conversation context.
+ *
+ * Use when:
+ * - A sibling surface has to adapt to the tray, such as squaring its corners or
+ * dropping a running indicator the tray already covers.
+ */
+export const isOpStatusVisible =
+ (context: MessageMapKeyInput) =>
+ (s: ChatStoreState): boolean => {
+ const hasVisibleRun = operationSelectors
+ .getOperationsByContext(context)(s)
+ .some(
+ (op) =>
+ op.status === 'running' &&
+ !op.metadata.isAborting &&
+ !op.metadata.visibleLoadingDone &&
+ isOpStatusRuntimeOperation(op),
+ );
+ if (hasVisibleRun) return true;
+
+ return (
+ operationSelectors.isSteerHandoffPending(context)(s) &&
+ !!operationSelectors.getLatestAgentRuntimeTurnStartTime(context)(s)
+ );
+ };
diff --git a/src/features/Conversation/ChatInput/index.tsx b/src/features/Conversation/ChatInput/index.tsx
index 5fced87d237..b2bd500ead7 100644
--- a/src/features/Conversation/ChatInput/index.tsx
+++ b/src/features/Conversation/ChatInput/index.tsx
@@ -51,6 +51,7 @@ import TodoProgress from '../TodoProgress';
import InputCompletionErrorAlert from './InputCompletionErrorAlert';
import LinkedGoalTray from './LinkedGoalTray';
import OpStatusTray from './OpStatusTray';
+import { isOpStatusVisible } from './OpStatusTray/visibility';
import QueueTray from './QueueTray';
import SendErrorAlert from './SendErrorAlert';
import { sendVoiceMessage } from './sendVoiceMessage';
@@ -305,12 +306,10 @@ const ChatInput = memo<ChatInputProps>(
// can square the top corners of OpStatusTray when it sits flush below.
const hasTodos = (selectCurrentTurnTodosFromMessages(dbMessages)?.items.length ?? 0) > 0;
- // Detect whether OpStatusTray will render (mirrors its own `!startTime`
- // gate) so LinkedGoalTray β€” which sits flush below it β€” can square its top corners
- // and merge with the status strip instead of showing a seam.
- const hasOpStatus = useChatStore(
- (s) => operationSelectors.getVisibleAgentRuntimeStartTimeByContext(context)(s) !== undefined,
- );
+ // Detect whether OpStatusTray will render so LinkedGoalTray β€” which sits flush
+ // below it β€” can square its top corners and merge with the status strip instead
+ // of showing a seam, and the send area can drop its duplicate running spinner.
+ const hasOpStatus = useChatStore(isOpStatusVisible(context));
// Computed state
const isInputEmpty = !inputMessage.trim() && fileList.length === 0 && contextList.length === 0;
@@ -502,6 +501,8 @@ const ChatInput = memo<ChatInputProps>(
// While the message is still being created there is no run to stop yet:
// Send shows as loading, and Stop takes over once the run starts.
generating: showStopButton && !isSendDispatchPending,
+ // Custom `children` replace the layout that mounts OpStatusTray.
+ hideRunningIndicator: !children && hasOpStatus,
loading: isSendDispatchPending,
onStop: stopGenerating,
showSendWhileGenerating: showSendWhileGenerating && !isSendDispatchPending,