💄 style: Open new topic by tap Just Chat again (#8426)

This commit is contained in:
René Wang
2025-07-29 20:05:29 +08:00
committed by GitHub
parent 6bfba72dce
commit 018ca7598c
2 changed files with 23 additions and 2 deletions
@@ -6,6 +6,8 @@ import { DEFAULT_INBOX_AVATAR } from '@/const/meta';
import { INBOX_SESSION_ID } from '@/const/session';
import { SESSION_CHAT_URL } from '@/const/url';
import { useSwitchSession } from '@/hooks/useSwitchSession';
import { getChatStoreState, useChatStore } from '@/store/chat';
import { chatSelectors } from '@/store/chat/selectors';
import { useServerConfigStore } from '@/store/serverConfig';
import { useSessionStore } from '@/store/session';
@@ -17,13 +19,26 @@ const Inbox = memo(() => {
const activeId = useSessionStore((s) => s.activeId);
const switchSession = useSwitchSession();
const openNewTopicOrSaveTopic = useChatStore((s) => s.openNewTopicOrSaveTopic);
return (
<Link
aria-label={t('inbox.title')}
href={SESSION_CHAT_URL(INBOX_SESSION_ID, mobile)}
onClick={(e) => {
onClick={async (e) => {
e.preventDefault();
switchSession(INBOX_SESSION_ID);
if (activeId === INBOX_SESSION_ID && !mobile) {
// If user tap the inbox again, open a new topic.
// Only for desktop.
const inboxMessages = chatSelectors.inboxActiveTopicMessages(getChatStoreState());
if (inboxMessages.length > 0) {
await openNewTopicOrSaveTopic();
}
} else {
switchSession(INBOX_SESSION_ID);
}
}}
>
<ListItem
@@ -201,6 +201,11 @@ const isSendButtonDisabledByMessage = (s: ChatStoreState) =>
// 4. when the message is in RAG flow
isInRAGFlow(s);
const inboxActiveTopicMessages = (state: ChatStoreState) => {
const activeTopicId = state.activeTopicId;
return state.messagesMap[messageMapKey(INBOX_SESSION_ID, activeTopicId)] || [];
};
export const chatSelectors = {
activeBaseChats,
activeBaseChatsWithoutTool,
@@ -213,6 +218,7 @@ export const chatSelectors = {
getMessageById,
getMessageByToolCallId,
getTraceIdByMessageId,
inboxActiveTopicMessages,
isAIGenerating,
isCreatingMessage,
isCurrentChatLoaded,