diff --git a/web/chat/thread-list-provider.js b/web/chat/thread-list-provider.js --- a/web/chat/thread-list-provider.js +++ b/web/chat/thread-list-provider.js @@ -14,6 +14,7 @@ threadInChatList, getThreadListSearchResults, useThreadListSearch, + threadIsPending, } from 'lib/shared/thread-utils'; import { threadTypes } from 'lib/types/thread-types'; @@ -88,6 +89,25 @@ // eslint-disable-next-line react-hooks/exhaustive-deps }, [activeTopLevelThreadIsInChatList, activeThreadID]); + const makeSureActivePendingThreadIsIncluded = React.useCallback( + ( + threadListData: $ReadOnlyArray, + ): $ReadOnlyArray => { + if ( + activeChatThreadItem && + threadIsPending(activeThreadID) && + activeThreadInfo?.type !== threadTypes.SIDEBAR && + !threadListData + .map(thread => thread.threadInfo.id) + .includes(activeThreadID) + ) { + return [activeChatThreadItem, ...threadListData]; + } + return threadListData; + }, + [activeChatThreadItem, activeThreadID, activeThreadInfo], + ); + const makeSureActiveSidebarIsIncluded = React.useCallback( (threadListData: $ReadOnlyArray) => { if ( @@ -185,13 +205,17 @@ ...threadListWithTopLevelItem, ]; } - return makeSureActiveSidebarIsIncluded(threadListWithTopLevelItem); + const threadListWithCurrentPendingThread = makeSureActivePendingThreadIsIncluded( + threadListWithTopLevelItem, + ); + return makeSureActiveSidebarIsIncluded(threadListWithCurrentPendingThread); }, [ activeTab, activeThreadOriginalTab, activeTopLevelChatThreadItem, activeTopLevelThreadIsInChatList, chatListDataWithoutFilter, + makeSureActivePendingThreadIsIncluded, makeSureActiveSidebarIsIncluded, ]); const threadListContext = React.useMemo(