Skip to content

Commit

Permalink
Move conv title
Browse files Browse the repository at this point in the history
  • Loading branch information
enricoros committed Oct 18, 2023
1 parent 42fe23a commit 2d0ec4d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/apps/chat/components/applayout/ConversationItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ import { SxProps } from '@mui/joy/styles/types';
import CloseIcon from '@mui/icons-material/Close';
import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline';

import { DConversation, useChatStore } from '~/common/state/store-chats';
import { SystemPurposes } from '../../../../data';

import { InlineTextarea } from '~/common/components/InlineTextarea';
import { conversationTitle, useChatStore } from '~/common/state/store-chats';
import { useUIPreferencesStore } from '~/common/state/store-ui';
import { SystemPurposes } from '../../../../data';


const DEBUG_CONVERSATION_IDs = false;


export const conversationTitle = (conversation: DConversation): string =>
conversation.userTitle || conversation.autoTitle || 'new conversation'; // 👋💬🗨️


export function ConversationItem(props: {
conversationId: string,
isActive: boolean, isSingle: boolean, showSymbols: boolean, maxChatMessages: number,
Expand All @@ -39,7 +36,7 @@ export function ConversationItem(props: {
messageCount: conversation.messages.length,
assistantTyping: !!conversation.abortController,
systemPurposeId: conversation.systemPurposeId,
title: conversationTitle(conversation),
title: conversationTitle(conversation, 'new conversation'),
setUserTitle: state.setUserTitle,
};
}, shallow);
Expand Down
4 changes: 4 additions & 0 deletions src/common/state/store-chats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ export const useChatStore = create<ChatState & ChatActions>()(devtools(
);


export const conversationTitle = (conversation: DConversation, fallback?: string): string =>
conversation.userTitle || conversation.autoTitle || fallback || ''; // 👋💬🗨️


/**
* Returns the chats stored in the localStorage, and rename the key for
* backup/data loss prevention purposes
Expand Down

0 comments on commit 2d0ec4d

Please sign in to comment.