feat: implement session deletion protection and enhance chat history management

This commit is contained in:
duanshuwen
2026-04-22 22:53:22 +08:00
parent d915fcd61a
commit bbe32f7954
7 changed files with 44 additions and 16 deletions

View File

@@ -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>