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.

✨ feat(conversation): show a fetching hint while cached messages revalidate (#20355)

Arvin Xu3c5e91c5da0c
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 79c7df6afa7..ef1418a1511 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -101,6 +101,7 @@
"chatList.expandMessage": "Expand Message",
"chatList.longMessageDetail": "View Details",
"chatList.refreshError": "Couldn't refresh messages",
+ "chatList.refreshing": "Fetching latest messages…",
"chatMode.agent": "Agent",
"chatMode.agentCap.env": "Runtime env",
"chatMode.agentCap.files": "File access",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 1da772abd02..bc435b1b8fe 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -101,6 +101,7 @@
"chatList.expandMessage": "展开消息",
"chatList.longMessageDetail": "查看详情",
"chatList.refreshError": "未能刷新消息",
+ "chatList.refreshing": "正在拉取最新消息…",
"chatMode.agent": "智能",
"chatMode.agentCap.env": "运行环境",
"chatMode.agentCap.files": "文件访问",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index e3f11c013f7..1554db15919 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -170,6 +170,7 @@ export default {
'chatList.expandMessage': 'Expand Message',
'chatList.longMessageDetail': 'View Details',
'chatList.refreshError': "Couldn't refresh messages",
+ 'chatList.refreshing': 'Fetching latest messages…',
'clearCurrentMessages': 'Clear current conversation messages',
'compressedHistory': 'Compressed History',
'compression.cancel': 'Uncompress',
diff --git a/src/features/Conversation/ChatList/hooks/useInitialRevalidation.test.ts b/src/features/Conversation/ChatList/hooks/useInitialRevalidation.test.ts
new file mode 100644
index 00000000000..a73bc3243ae
--- /dev/null
+++ b/src/features/Conversation/ChatList/hooks/useInitialRevalidation.test.ts
@@ -0,0 +1,77 @@
+import { renderHook } from '@testing-library/react';
+import { describe, expect, it } from 'vitest';
+
+import { useInitialRevalidation } from './useInitialRevalidation';
+
+const verified = () => true;
+const unverified = () => false;
+
+describe('useInitialRevalidation', () => {
+ it('reports the first revalidation of a conversation only', () => {
+ const { rerender, result } = renderHook((props) => useInitialRevalidation(props), {
+ initialProps: { identity: 'topic-a', isServerVerified: unverified, isValidating: true },
+ });
+ expect(result.current).toBe(true);
+
+ rerender({ identity: 'topic-a', isServerVerified: unverified, isValidating: false });
+ expect(result.current).toBe(false);
+
+ // A later focus / polling revalidation of the same conversation stays silent.
+ rerender({ identity: 'topic-a', isServerVerified: unverified, isValidating: true });
+ expect(result.current).toBe(false);
+ });
+
+ it('reports again after switching to another conversation', () => {
+ const { rerender, result } = renderHook((props) => useInitialRevalidation(props), {
+ initialProps: { identity: 'topic-a', isServerVerified: unverified, isValidating: true },
+ });
+ rerender({ identity: 'topic-a', isServerVerified: unverified, isValidating: false });
+
+ rerender({ identity: 'topic-b', isServerVerified: unverified, isValidating: true });
+ expect(result.current).toBe(true);
+ });
+
+ it('reports again when reopening a settled conversation through one that never validated', () => {
+ const { rerender, result } = renderHook((props) => useInitialRevalidation(props), {
+ initialProps: { identity: 'topic-a', isServerVerified: unverified, isValidating: true },
+ });
+ rerender({ identity: 'topic-a', isServerVerified: unverified, isValidating: false });
+
+ // B renders from a still-verified cache and never starts a fetch.
+ rerender({ identity: 'topic-b', isServerVerified: verified, isValidating: false });
+
+ // Back on A after its verification window lapsed: a new first fetch.
+ rerender({ identity: 'topic-a', isServerVerified: unverified, isValidating: true });
+ expect(result.current).toBe(true);
+ });
+
+ it('treats a later refresh as non-initial when the opening started from verified cache', () => {
+ const { rerender, result } = renderHook((props) => useInitialRevalidation(props), {
+ initialProps: { identity: 'topic-b', isServerVerified: verified, isValidating: false },
+ });
+
+ // Verification window lapses; a focus / polling refresh starts.
+ rerender({ identity: 'topic-b', isServerVerified: unverified, isValidating: true });
+ expect(result.current).toBe(false);
+ });
+
+ it('reports the switch-time fetch even before SWR flags it', () => {
+ const { rerender, result } = renderHook((props) => useInitialRevalidation(props), {
+ initialProps: { identity: 'topic-a', isServerVerified: unverified, isValidating: false },
+ });
+ // The switch render reports isValidating=false; the fetch starts right after.
+ rerender({ identity: 'topic-a', isServerVerified: unverified, isValidating: true });
+ expect(result.current).toBe(true);
+ });
+
+ it('stays hidden while no fetch is in flight', () => {
+ const { result } = renderHook(() =>
+ useInitialRevalidation({
+ identity: 'topic-a',
+ isServerVerified: unverified,
+ isValidating: false,
+ }),
+ );
+ expect(result.current).toBe(false);
+ });
+});
diff --git a/src/features/Conversation/ChatList/hooks/useInitialRevalidation.ts b/src/features/Conversation/ChatList/hooks/useInitialRevalidation.ts
new file mode 100644
index 00000000000..3e4da7c80df
--- /dev/null
+++ b/src/features/Conversation/ChatList/hooks/useInitialRevalidation.ts
@@ -0,0 +1,45 @@
+import { useEffect, useRef, useState } from 'react';
+
+interface UseInitialRevalidationOptions {
+ identity: string;
+ /**
+ * Whether this conversation's cached list is still inside its server
+ * verification window, i.e. opening it starts no fetch. Read once per opening.
+ */
+ isServerVerified: () => boolean;
+ isValidating: boolean;
+}
+
+/**
+ * Whether the list is still waiting on the first server fetch since this
+ * conversation was opened — i.e. it is painting cached rows that may be stale.
+ * Later focus or polling revalidations share SWR's `isValidating` flag, but
+ * the list is already fresh by then, so they are not surfaced.
+ */
+export const useInitialRevalidation = ({
+ identity,
+ isServerVerified,
+ isValidating,
+}: UseInitialRevalidationOptions) => {
+ const [settledIdentity, setSettledIdentity] = useState<string>();
+ const previousRef = useRef<{ identity: string; isValidating: boolean } | undefined>(undefined);
+ const isServerVerifiedRef = useRef(isServerVerified);
+ isServerVerifiedRef.current = isServerVerified;
+
+ useEffect(() => {
+ const previous = previousRef.current;
+ if (previous?.identity !== identity) {
+ // A new opening. The hook and its provider outlive context switches, so a
+ // settlement never carries over. An opening served from a still-verified
+ // cache starts no first fetch, so it is settled right away and a later
+ // focus or polling refresh is not mistaken for one. `isValidating` cannot
+ // decide this: SWR has not reported the switch-time revalidation yet.
+ setSettledIdentity(isServerVerifiedRef.current() ? identity : undefined);
+ } else if (previous.isValidating && !isValidating) {
+ setSettledIdentity(identity);
+ }
+ previousRef.current = { identity, isValidating };
+ }, [identity, isValidating]);
+
+ return isValidating && settledIdentity !== identity;
+};
diff --git a/src/features/Conversation/ChatList/index.tsx b/src/features/Conversation/ChatList/index.tsx
index 4cfc7a24628..ba99f6f2701 100644
--- a/src/features/Conversation/ChatList/index.tsx
+++ b/src/features/Conversation/ChatList/index.tsx
@@ -3,12 +3,12 @@
import type { UIChatMessage } from '@lobechat/types';
import { Flexbox } from '@lobehub/ui';
import type { ReactNode } from 'react';
-import { memo, useCallback, useMemo } from 'react';
+import { memo, useCallback, useEffect, useMemo } from 'react';
import AsyncError from '@/components/AsyncError';
import { useFetchTopicMemories } from '@/hooks/useFetchMemoryForTopic';
import { useFetchNotebookDocuments } from '@/hooks/useFetchNotebookDocuments';
-import { getMessageListCacheIdentity } from '@/services/message/cache';
+import { getMessageListCacheIdentity, isMessageListServerVerified } from '@/services/message/cache';
import { useAgentStore } from '@/store/agent';
import { useChatStore } from '@/store/chat';
import { operationSelectors } from '@/store/chat/selectors';
@@ -26,16 +26,23 @@ import MessageItem from '../Messages';
import type { WorkflowExpandLevelDefault } from '../Messages/AssistantGroup/components/WorkflowCollapse';
import { BackgroundRunHintContext } from '../Messages/Contexts/BackgroundRunHintContext';
import { MessageActionProvider } from '../Messages/Contexts/MessageActionProvider';
-import { dataSelectors, inputSelectors, useConversationStore } from '../store';
+import {
+ dataSelectors,
+ inputSelectors,
+ useConversationStore,
+ useConversationStoreApi,
+} from '../store';
import AgentSignalReceiptList from './components/AgentSignalReceiptList';
import { RefreshError } from './components/RefreshError';
import VirtualizedList from './components/VirtualizedList';
import { useAgentSignalReceipts } from './hooks/useAgentSignalReceipts';
+import { useInitialRevalidation } from './hooks/useInitialRevalidation';
import { useMessageRefreshError } from './hooks/useMessageRefreshError';
import { resolveMessageListFeedback } from './resolveMessageListFeedback';
import { buildChatRows } from './utils/chatRows';
import type { MessageDeepLink } from './utils/messageDeepLink';
import { resolveMessageDeepLink } from './utils/messageDeepLink';
+import { resolveRefreshingRowId } from './utils/refreshingRow';
const MessageAuthorConfigLoader = memo<{ agentId: string; isLogin: boolean | undefined }>(
({ agentId, isLogin }) => {
@@ -146,12 +153,19 @@ const ChatList = memo<ChatListProps>(
skipFetch: skipFetch || isCreatingTopic,
syncInterventions: true,
});
+ const messageListIdentity = getMessageListCacheIdentity(context);
const refreshError = useMessageRefreshError({
error: messagesSWR.error,
- identity: getMessageListCacheIdentity(context),
+ identity: messageListIdentity,
isValidating: messagesSWR.isValidating,
mutate: messagesSWR.mutate,
});
+ const isServerVerified = useCallback(() => isMessageListServerVerified(context), [context]);
+ const isInitialRevalidation = useInitialRevalidation({
+ identity: messageListIdentity,
+ isServerVerified,
+ isValidating: messagesSWR.isValidating,
+ });
const allDisplayMessages = useConversationStore(dataSelectors.displayMessages);
const displayMessages = useMemo(
() => (filterItem ? allDisplayMessages.filter(filterItem) : allDisplayMessages),
@@ -253,11 +267,26 @@ const ChatList = memo<ChatListProps>(
const isNewConversation = !context.topicId;
const feedback = resolveMessageListFeedback({
error: refreshError.error,
+ isInitialRevalidation,
isNewConversation,
isStreaming,
messagesInit,
});
+ // The hint renders inside the latest assistant row, which subscribes to the
+ // store itself (virtua would not repaint a cached row from a prop change).
+ // Resolved against the rows actually rendered: folded steer chains in the
+ // default list, flat (and possibly filtered) messages for custom renderers.
+ const refreshingRowId = useMemo(
+ () =>
+ feedback.showRefreshing ? resolveRefreshingRowId(displayMessages, !itemContent) : undefined,
+ [displayMessages, feedback.showRefreshing, itemContent],
+ );
+ const storeApi = useConversationStoreApi();
+ useEffect(() => {
+ storeApi.setState({ refreshingRowId });
+ }, [refreshingRowId, storeApi]);
+
// `messagesInit` is the settled-data signal: [] is a valid loaded result.
// A first-load failure owns the whole surface, while a background failure
// must preserve either the messages or the welcome state below.
diff --git a/src/features/Conversation/ChatList/resolveMessageListFeedback.test.ts b/src/features/Conversation/ChatList/resolveMessageListFeedback.test.ts
index 648ef076666..64fdd90a980 100644
--- a/src/features/Conversation/ChatList/resolveMessageListFeedback.test.ts
+++ b/src/features/Conversation/ChatList/resolveMessageListFeedback.test.ts
@@ -7,6 +7,7 @@ describe('resolveMessageListFeedback', () => {
{
expected: {
showBackgroundError: false,
+ showRefreshing: false,
showFirstLoadError: false,
showSkeleton: true,
},
@@ -21,6 +22,7 @@ describe('resolveMessageListFeedback', () => {
{
expected: {
showBackgroundError: false,
+ showRefreshing: false,
showFirstLoadError: true,
showSkeleton: false,
},
@@ -35,15 +37,49 @@ describe('resolveMessageListFeedback', () => {
{
expected: {
showBackgroundError: false,
+ showRefreshing: false,
showFirstLoadError: false,
showSkeleton: false,
},
name: 'settled list validating silently',
state: { error: undefined, isNewConversation: false, isStreaming: false, messagesInit: true },
},
+ {
+ expected: {
+ showBackgroundError: false,
+ showRefreshing: true,
+ showFirstLoadError: false,
+ showSkeleton: false,
+ },
+ name: 'cached list waiting on its first server fetch',
+ state: {
+ error: undefined,
+ isInitialRevalidation: true,
+ isNewConversation: false,
+ isStreaming: false,
+ messagesInit: true,
+ },
+ },
+ {
+ expected: {
+ showBackgroundError: false,
+ showRefreshing: false,
+ showFirstLoadError: false,
+ showSkeleton: true,
+ },
+ name: 'first load keeps the skeleton instead of the refreshing hint',
+ state: {
+ error: undefined,
+ isInitialRevalidation: true,
+ isNewConversation: false,
+ isStreaming: false,
+ messagesInit: false,
+ },
+ },
{
expected: {
showBackgroundError: true,
+ showRefreshing: false,
showFirstLoadError: false,
showSkeleton: false,
},
@@ -58,6 +94,7 @@ describe('resolveMessageListFeedback', () => {
{
expected: {
showBackgroundError: false,
+ showRefreshing: false,
showFirstLoadError: false,
showSkeleton: false,
},
@@ -72,6 +109,7 @@ describe('resolveMessageListFeedback', () => {
{
expected: {
showBackgroundError: false,
+ showRefreshing: false,
showFirstLoadError: false,
showSkeleton: false,
},
diff --git a/src/features/Conversation/ChatList/resolveMessageListFeedback.ts b/src/features/Conversation/ChatList/resolveMessageListFeedback.ts
index c960e681af4..a3225620238 100644
--- a/src/features/Conversation/ChatList/resolveMessageListFeedback.ts
+++ b/src/features/Conversation/ChatList/resolveMessageListFeedback.ts
@@ -1,5 +1,7 @@
interface ResolveMessageListFeedbackOptions {
error?: unknown;
+ /** Cached rows are on screen while the first server fetch is in flight. */
+ isInitialRevalidation?: boolean;
isNewConversation: boolean;
isStreaming: boolean;
messagesInit: boolean;
@@ -7,6 +9,7 @@ interface ResolveMessageListFeedbackOptions {
export const resolveMessageListFeedback = ({
error,
+ isInitialRevalidation = false,
isNewConversation,
isStreaming,
messagesInit,
@@ -15,6 +18,7 @@ export const resolveMessageListFeedback = ({
return {
showBackgroundError: messagesInit && hasError && !isStreaming,
+ showRefreshing: messagesInit && isInitialRevalidation && !hasError,
showFirstLoadError: !messagesInit && !isNewConversation && hasError,
showSkeleton: !messagesInit && !isNewConversation && !hasError,
};
diff --git a/src/features/Conversation/ChatList/utils/refreshingRow.test.ts b/src/features/Conversation/ChatList/utils/refreshingRow.test.ts
new file mode 100644
index 00000000000..73ef9e3e4bf
--- /dev/null
+++ b/src/features/Conversation/ChatList/utils/refreshingRow.test.ts
@@ -0,0 +1,38 @@
+import type { UIChatMessage } from '@lobechat/types';
+import { describe, expect, it } from 'vitest';
+
+import { resolveRefreshingRowId } from './refreshingRow';
+
+const messages = (list: unknown[]) => list as UIChatMessage[];
+
+describe('resolveRefreshingRowId', () => {
+ it('targets the latest assistant reply', () => {
+ const list = messages([
+ { id: 'u1', role: 'user' },
+ { id: 'a1', role: 'assistant' },
+ { id: 'u2', role: 'user' },
+ { id: 'g2', role: 'assistantGroup' },
+ { id: 'u3', role: 'user' },
+ ]);
+
+ expect(resolveRefreshingRowId(list, true)).toBe('g2');
+ });
+
+ const steered = messages([
+ { content: 'first draft', id: 'a1', role: 'assistant' },
+ { content: 'shorter please', id: 's1', metadata: { steer: true }, role: 'user' },
+ { children: [{ content: 'final answer', id: 'b1' }], id: 'g2', role: 'assistantGroup' },
+ ]);
+
+ it('targets the host row when the list folds steer chains', () => {
+ expect(resolveRefreshingRowId(steered, true)).toBe('a1');
+ });
+
+ it('targets the continuation itself in a flat custom-rendered list', () => {
+ expect(resolveRefreshingRowId(steered, false)).toBe('g2');
+ });
+
+ it('targets nothing without an assistant reply', () => {
+ expect(resolveRefreshingRowId(messages([{ id: 'u1', role: 'user' }]), true)).toBeUndefined();
+ });
+});
diff --git a/src/features/Conversation/ChatList/utils/refreshingRow.ts b/src/features/Conversation/ChatList/utils/refreshingRow.ts
new file mode 100644
index 00000000000..12a24159c95
--- /dev/null
+++ b/src/features/Conversation/ChatList/utils/refreshingRow.ts
@@ -0,0 +1,22 @@
+import type { UIChatMessage } from '@lobechat/types';
+
+import { collectSteerChains } from '../../store/slices/data/steerChains';
+
+const isAssistantMessage = (m: UIChatMessage) =>
+ m.role === 'assistant' || m.role === 'assistantGroup' || m.role === 'supervisor';
+
+/**
+ * The rendered row that carries the "fetching latest messages" hint: the one
+ * showing the latest assistant reply. The default list folds a steered
+ * continuation into its host row; custom renderers keep the list flat, so the
+ * continuation renders as its own row there.
+ */
+export const resolveRefreshingRowId = (
+ messages: UIChatMessage[],
+ foldsSteerChains: boolean,
+): string | undefined => {
+ const latestId = messages.findLast(isAssistantMessage)?.id;
+ if (!latestId || !foldsSteerChains) return latestId;
+
+ return collectSteerChains(messages).hostOf.get(latestId) ?? latestId;
+};
diff --git a/src/features/Conversation/Messages/Assistant/index.tsx b/src/features/Conversation/Messages/Assistant/index.tsx
index 282ffb023db..ff4ab01204c 100644
--- a/src/features/Conversation/Messages/Assistant/index.tsx
+++ b/src/features/Conversation/Messages/Assistant/index.tsx
@@ -20,6 +20,7 @@ import { useAgentMeta, useDoubleClickEdit } from '../../hooks';
import { dataSelectors, messageStateSelectors, useConversationStore } from '../../store';
import { normalizeThinkTags, processWithArtifact } from '../../utils/markdown';
import MessageBranch from '../components/MessageBranch';
+import RefreshingIndicator from '../components/RefreshingIndicator';
import {
useSetMessageItemActionElementPortialContext,
useSetMessageItemActionTypeContext,
@@ -142,6 +143,7 @@ const AssistantMessage = memo<AssistantMessageProps>(
message={message}
placement={'left'}
time={createdAt}
+ titleAddon={<RefreshingIndicator messageId={id} />}
actionAddon={
reactions.length > 0 || (commentCount > 0 && commentTopicId) ? (
<>
diff --git a/src/features/Conversation/Messages/AssistantGroup/index.tsx b/src/features/Conversation/Messages/AssistantGroup/index.tsx
index dbbc8cbcba3..15d28a1e74b 100644
--- a/src/features/Conversation/Messages/AssistantGroup/index.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/index.tsx
@@ -36,6 +36,7 @@ import { getOperationFinalRootId } from '../../store/slices/data/workSummaries';
import InterruptedHint from '../Assistant/components/InterruptedHint';
import Usage from '../components/Extras/Usage';
import MessageBranch from '../components/MessageBranch';
+import RefreshingIndicator from '../components/RefreshingIndicator';
import {
useSetMessageItemActionElementPortialContext,
useSetMessageItemActionTypeContext,
@@ -294,7 +295,6 @@ const GroupMessage = memo<GroupMessageProps>(
id={id}
placement={'left'}
time={createdAt}
- titleAddon={isSupervisor ? <Tag>{t('supervisor.label')}</Tag> : undefined}
actionAddon={
reactions.length > 0 || (commentCount > 0 && commentTopicId) ? (
<>
@@ -362,6 +362,12 @@ const GroupMessage = memo<GroupMessageProps>(
)
: undefined
}
+ titleAddon={
+ <>
+ {isSupervisor && <Tag>{t('supervisor.label')}</Tag>}
+ <RefreshingIndicator messageId={id} />
+ </>
+ }
onAvatarClick={onAvatarClick}
onMouseEnter={onMouseEnter}
>
diff --git a/src/features/Conversation/Messages/components/RefreshingIndicator.tsx b/src/features/Conversation/Messages/components/RefreshingIndicator.tsx
new file mode 100644
index 00000000000..79ece6f6cb7
--- /dev/null
+++ b/src/features/Conversation/Messages/components/RefreshingIndicator.tsx
@@ -0,0 +1,36 @@
+'use client';
+
+import { Flexbox } from '@lobehub/ui';
+import { Spin, Text } from '@lobehub/ui/base-ui';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { delayed } from '@/components/Skeleton/Delayed';
+
+import { dataSelectors, useConversationStore } from '../../store';
+
+/**
+ * "Fetching latest messages" hint beside the latest assistant reply's name,
+ * shown while the conversation paints cached rows and its first server fetch
+ * is still in flight. Held back like a route fallback so a fast fetch never
+ * flashes it.
+ */
+const RefreshingIndicator = memo<{ messageId: string }>(({ messageId }) => {
+ const { t } = useTranslation('chat');
+ const isRefreshing = useConversationStore(dataSelectors.isRefreshingAt(messageId));
+
+ if (!isRefreshing) return null;
+
+ return delayed(
+ <Flexbox horizontal align={'center'} aria-live={'polite'} gap={4} role={'status'}>
+ <Spin size={'small'} variant={'network'} />
+ <Text fontSize={12} type={'secondary'}>
+ {t('chatList.refreshing')}
+ </Text>
+ </Flexbox>,
+ );
+});
+
+RefreshingIndicator.displayName = 'ConversationRefreshingIndicator';
+
+export default RefreshingIndicator;
diff --git a/src/features/Conversation/store/initialState.ts b/src/features/Conversation/store/initialState.ts
index 04368efbefe..94691f617b0 100644
--- a/src/features/Conversation/store/initialState.ts
+++ b/src/features/Conversation/store/initialState.ts
@@ -92,6 +92,7 @@ export const createEphemeralResetState = (): Partial<State> => ({
heteroOverloadWaitOpIds: {},
inputMessage: '',
isLoadingEarlierMessages: false,
+ refreshingRowId: undefined,
isScrolling: false,
messageEditingIds: [],
messageLoadingIds: [],
diff --git a/src/features/Conversation/store/slices/data/initialState.ts b/src/features/Conversation/store/slices/data/initialState.ts
index 6dc85138a0d..1938b62dffb 100644
--- a/src/features/Conversation/store/slices/data/initialState.ts
+++ b/src/features/Conversation/store/slices/data/initialState.ts
@@ -31,6 +31,13 @@ export interface DataState {
*/
messagesInit: boolean;
+ /**
+ * While cached rows are on screen and the conversation's first server fetch
+ * is still in flight, the id of the rendered row that shows the "fetching
+ * latest messages" hint (the latest assistant reply's row).
+ */
+ refreshingRowId?: string;
+
/**
* Skip internal message fetching (when external messages are provided)
*/
diff --git a/src/features/Conversation/store/slices/data/selectors.test.ts b/src/features/Conversation/store/slices/data/selectors.test.ts
index e42c02fd2b9..b2ea77ce461 100644
--- a/src/features/Conversation/store/slices/data/selectors.test.ts
+++ b/src/features/Conversation/store/slices/data/selectors.test.ts
@@ -88,3 +88,16 @@ describe('getRowLatestMessageWithoutTools', () => {
});
});
});
+
+describe('isRefreshingAt', () => {
+ it('matches only the resolved refreshing row', () => {
+ const state = { refreshingRowId: 'g2' } as unknown as State;
+
+ expect(dataSelectors.isRefreshingAt('g2')(state)).toBe(true);
+ expect(dataSelectors.isRefreshingAt('a1')(state)).toBe(false);
+ });
+
+ it('matches nothing once the fetch settled', () => {
+ expect(dataSelectors.isRefreshingAt('g2')({} as State)).toBe(false);
+ });
+});
diff --git a/src/features/Conversation/store/slices/data/selectors.ts b/src/features/Conversation/store/slices/data/selectors.ts
index aca68ed90d7..e47e25daa9c 100644
--- a/src/features/Conversation/store/slices/data/selectors.ts
+++ b/src/features/Conversation/store/slices/data/selectors.ts
@@ -163,6 +163,8 @@ const pendingInterventions = (s: State) => getPendingInterventions(s.displayMess
const workSummariesByRootOperationId = (rootOperationId?: string | null) => (s: State) =>
getWorkSummariesByRootOperationId(s.dbMessages, rootOperationId);
+const isRefreshingAt = (id: string) => (s: State) => s.refreshingRowId === id;
+
const isSecondLastMessageFromUser = (s: State) => s.displayMessages.at(-2)?.role === 'user';
const rowMemberIds = (id: string) => (s: State) =>
@@ -315,6 +317,7 @@ const getVerifyOrdinal = (id: string) => (s: State) => {
};
export const dataSelectors = {
+ isRefreshingAt,
currentTopicSummary,
dbMessages,
deletableRowMessageIds,