diff --git a/dist-electron/main/main.js b/dist-electron/main/main.js index 2400e83..d8adec3 100644 --- a/dist-electron/main/main.js +++ b/dist-electron/main/main.js @@ -1,6 +1,6 @@ "use strict"; require("electron"); -require("./main-DfEXs_ww.js"); +require("./main-CDQKuYIF.js"); require("electron-squirrel-startup"); require("electron-log"); require("bytenode"); diff --git a/electron/gateway/manager.ts b/electron/gateway/manager.ts index 582bc38..8bfe015 100644 --- a/electron/gateway/manager.ts +++ b/electron/gateway/manager.ts @@ -798,6 +798,10 @@ class GatewayManager { } case 'session.delete': { const request = params as GatewayRpcParams['session.delete']; + if (normalizeAgentSessionKey(request.sessionKey).endsWith(':main')) { + return { success: false }; + } + await this.rpcGateway('sessions.delete', { key: normalizeAgentSessionKey(request.sessionKey), deleteTranscript: true, diff --git a/src/components/chat/ChatHistoryPanel.tsx b/src/components/chat/ChatHistoryPanel.tsx index 7ca5680..22033d0 100644 --- a/src/components/chat/ChatHistoryPanel.tsx +++ b/src/components/chat/ChatHistoryPanel.tsx @@ -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 (
  • @@ -273,19 +274,20 @@ function ChatHistoryPanel({ {t('conversation.historyPanel.rename')} - + {canDelete ? ( + + ) : null} ) : null} diff --git a/src/components/chat/ChatMessageList.tsx b/src/components/chat/ChatMessageList.tsx index a2fffd9..cfb60b1 100644 --- a/src/components/chat/ChatMessageList.tsx +++ b/src/components/chat/ChatMessageList.tsx @@ -101,8 +101,8 @@ function ChatMessageList({ messages, loading, showWelcomeState }: ChatMessageLis }, [loading, messages]); return ( -
    -
    +
    +
    {loading ? (
    {t('conversation.messageList.loading')} diff --git a/src/components/chat/types.ts b/src/components/chat/types.ts index 4d629be..6351ca6 100644 --- a/src/components/chat/types.ts +++ b/src/components/chat/types.ts @@ -9,6 +9,7 @@ export type ChatHistoryBucket = { conversationId: string; title: string; updatedAt: string; + canDelete?: boolean; }>; }; diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx index 768eccb..7a2f00e 100644 --- a/src/pages/Home/index.tsx +++ b/src/pages/Home/index.tsx @@ -120,6 +120,10 @@ function getTaskRoomTypeLabel(task: { roomType: string; roomList: Array<{ id?: s return matchedRoom?.pmsName || task.roomType; } +function isProtectedMainSession(sessionKey: string): boolean { + return sessionKey.endsWith(':main'); +} + function mapMessages( messages: RawMessage[], streamingMessage: RawMessage | null, @@ -281,6 +285,7 @@ export default function HomePage() { conversationId: session.key, title: chatSessionLabels[session.key] || session.displayName || session.key, updatedAt: formatHistoryTime(locale, t, activityMs, currentMs), + canDelete: !isProtectedMainSession(session.key), }); } @@ -421,6 +426,10 @@ export default function HomePage() { } function handleDeleteConversation(conversationId: string): void { + if (isProtectedMainSession(conversationId)) { + return; + } + const nextTitle = chatSessionLabels[conversationId] || chatSessions.find((session) => session.key === conversationId)?.displayName || t('conversation.untitledConversation'); @@ -433,6 +442,10 @@ export default function HomePage() { async function handleConfirmDeleteConversation(): Promise { if (!deleteConversationTarget) return; + if (isProtectedMainSession(deleteConversationTarget.conversationId)) { + setDeleteConversationTarget(null); + return; + } setDeletingConversation(true); try { diff --git a/src/stores/chat.ts b/src/stores/chat.ts index 6c6d6b2..bea909c 100644 --- a/src/stores/chat.ts +++ b/src/stores/chat.ts @@ -197,6 +197,10 @@ function buildNewSessionKey(agentId: string | null | undefined): string { return buildAgentSessionKey(agentId || getDefaultAgentId(), `session-${Date.now()}`); } +function isProtectedMainSession(sessionKey: string): boolean { + return normalizeAgentSessionKey(sessionKey).endsWith(':main'); +} + function clearSessionEntryFromMap>(entries: T, sessionKey: string): T { return Object.fromEntries(Object.entries(entries).filter(([key]) => key !== sessionKey)) as T; } @@ -671,6 +675,10 @@ function selectAgent(agentId: string): void { } async function deleteSession(sessionKey: string): Promise { + if (isProtectedMainSession(sessionKey)) { + return; + } + const currentState = state; const isDeletingCurrentSession = sessionKey === currentState.currentSessionKey;