feat: implement session deletion protection and enhance chat history management
This commit is contained in:
@@ -206,6 +206,7 @@ function ChatHistoryPanel({
|
||||
{bucket.sessions.map((session) => {
|
||||
const isActive = session.conversationId === selectedConversationId;
|
||||
const isMenuOpen = menuState?.conversationId === session.conversationId;
|
||||
const canDelete = Boolean(onDeleteConversation) && session.canDelete !== false;
|
||||
|
||||
return (
|
||||
<li key={session.conversationId}>
|
||||
@@ -273,19 +274,20 @@ function ChatHistoryPanel({
|
||||
<PencilLine className="h-4 w-4 text-[#94a3b8]" />
|
||||
{t('conversation.historyPanel.rename')}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="flex w-full items-center gap-2 border-t border-[#eef3f9] px-3 py-2.5 text-left text-sm text-[#ef4444] transition-colors hover:bg-[#fff5f5] disabled:cursor-not-allowed disabled:text-[#f5a2a2] dark:border-[#2f3136] dark:hover:bg-[#2a2a2d]"
|
||||
disabled={!onDeleteConversation}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
setMenuState(null);
|
||||
onDeleteConversation?.(session.conversationId);
|
||||
}}
|
||||
>
|
||||
<Trash2 className="h-4 w-4" />
|
||||
{t('conversation.historyPanel.delete')}
|
||||
</button>
|
||||
{canDelete ? (
|
||||
<button
|
||||
type="button"
|
||||
className="flex w-full items-center gap-2 border-t border-[#eef3f9] px-3 py-2.5 text-left text-sm text-[#ef4444] transition-colors hover:bg-[#fff5f5] disabled:cursor-not-allowed disabled:text-[#f5a2a2] dark:border-[#2f3136] dark:hover:bg-[#2a2a2d]"
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
setMenuState(null);
|
||||
onDeleteConversation?.(session.conversationId);
|
||||
}}
|
||||
>
|
||||
<Trash2 className="h-4 w-4" />
|
||||
{t('conversation.historyPanel.delete')}
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
@@ -101,8 +101,8 @@ function ChatMessageList({ messages, loading, showWelcomeState }: ChatMessageLis
|
||||
}, [loading, messages]);
|
||||
|
||||
return (
|
||||
<div className="flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-6 dark:bg-[#161618] sm:px-6">
|
||||
<div ref={containerRef} className="mx-auto flex min-h-0 w-full flex-1 flex-col gap-5 overflow-y-auto pr-1">
|
||||
<div className="flex min-h-0 flex-1 flex-col overflow-hidden p-4 dark:bg-[#161618] sm:px-6">
|
||||
<div ref={containerRef} className="mx-auto flex min-h-0 w-full flex-1 flex-col gap-5 overflow-y-auto pr-2">
|
||||
{loading ? (
|
||||
<div className="w-full rounded-[18px] border border-dashed border-[#DDD3C3] bg-[#EFE7D8] px-4 py-3 text-sm text-[#645C50] dark:border-white/10 dark:bg-white/5 dark:text-gray-400">
|
||||
{t('conversation.messageList.loading')}
|
||||
|
||||
@@ -9,6 +9,7 @@ export type ChatHistoryBucket = {
|
||||
conversationId: string;
|
||||
title: string;
|
||||
updatedAt: string;
|
||||
canDelete?: boolean;
|
||||
}>;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user