File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
app/[variants]/(main)/chat/@session/features/SessionListContent/Inbox
store/chat/slices/message Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ import { DEFAULT_INBOX_AVATAR } from '@/const/meta';
66import { INBOX_SESSION_ID } from '@/const/session' ;
77import { SESSION_CHAT_URL } from '@/const/url' ;
88import { useSwitchSession } from '@/hooks/useSwitchSession' ;
9+ import { getChatStoreState , useChatStore } from '@/store/chat' ;
10+ import { chatSelectors } from '@/store/chat/selectors' ;
911import { useServerConfigStore } from '@/store/serverConfig' ;
1012import { useSessionStore } from '@/store/session' ;
1113
@@ -17,13 +19,24 @@ const Inbox = memo(() => {
1719 const activeId = useSessionStore ( ( s ) => s . activeId ) ;
1820 const switchSession = useSwitchSession ( ) ;
1921
22+ const openNewTopicOrSaveTopic = useChatStore ( ( s ) => s . openNewTopicOrSaveTopic ) ;
23+
2024 return (
2125 < Link
2226 aria-label = { t ( 'inbox.title' ) }
2327 href = { SESSION_CHAT_URL ( INBOX_SESSION_ID , mobile ) }
24- onClick = { ( e ) => {
28+ onClick = { async ( e ) => {
2529 e . preventDefault ( ) ;
26- switchSession ( INBOX_SESSION_ID ) ;
30+ if ( activeId === INBOX_SESSION_ID ) {
31+ // If user tap the inbox again, open a new topic
32+ const inboxMessages = chatSelectors . inboxActiveTopicMessages ( getChatStoreState ( ) ) ;
33+
34+ if ( inboxMessages . length > 0 ) {
35+ await openNewTopicOrSaveTopic ( ) ;
36+ }
37+ } else {
38+ switchSession ( INBOX_SESSION_ID ) ;
39+ }
2740 } }
2841 >
2942 < ListItem
Original file line number Diff line number Diff line change @@ -201,6 +201,11 @@ const isSendButtonDisabledByMessage = (s: ChatStoreState) =>
201201 // 4. when the message is in RAG flow
202202 isInRAGFlow ( s ) ;
203203
204+ const inboxActiveTopicMessages = ( state : ChatStoreState ) => {
205+ const activeTopicId = state . activeTopicId ;
206+ return state . messagesMap [ messageMapKey ( INBOX_SESSION_ID , activeTopicId ) ] || [ ] ;
207+ } ;
208+
204209export const chatSelectors = {
205210 activeBaseChats,
206211 activeBaseChatsWithoutTool,
@@ -213,6 +218,7 @@ export const chatSelectors = {
213218 getMessageById,
214219 getMessageByToolCallId,
215220 getTraceIdByMessageId,
221+ inboxActiveTopicMessages,
216222 isAIGenerating,
217223 isCreatingMessage,
218224 isCurrentChatLoaded,
You can’t perform that action at this time.
0 commit comments