diff --git a/src/renderer/src/components/right-sidebar/AiVaultSessionDetails.tsx b/src/renderer/src/components/right-sidebar/AiVaultSessionDetails.tsx index 438a50c3e..387bc877f 100644 --- a/src/renderer/src/components/right-sidebar/AiVaultSessionDetails.tsx +++ b/src/renderer/src/components/right-sidebar/AiVaultSessionDetails.tsx @@ -1,13 +1,12 @@ import type React from 'react' import { Copy, Play } from 'lucide-react' -import { toast } from 'sonner' import { Button } from '@/components/ui/button' -import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' import { AgentIcon } from '@/lib/agent-catalog' import { cn } from '@/lib/utils' import type { AiVaultSession } from '../../../../shared/ai-vault-types' import { agentLabel } from './ai-vault-session-filters' import { translate } from '@/i18n/i18n' +import { recentSessionConversationTurns } from './ai-vault-session-display' export function SessionInlineDetails({ id, @@ -23,26 +22,12 @@ export function SessionInlineDetails({ resumeDisabled: boolean }): React.JSX.Element { const updatedAt = session.updatedAt ?? session.modifiedAt - const usage = translate( - 'auto.components.right.sidebar.AiVaultSessionDetails.usageValue', - '{{value0}} msgs{{value1}}', - { - value0: session.messageCount, - value1: - session.totalTokens > 0 - ? translate( - 'auto.components.right.sidebar.AiVaultSessionDetails.tokenSuffix', - ' · {{value0}} tok', - { value0: formatTokenCount(session.totalTokens) } - ) - : '' - } - ) + const recentTurns = recentSessionConversationTurns(session, 3) return (
event.stopPropagation()} onClick={(event) => event.stopPropagation()} onDoubleClick={(event) => event.stopPropagation()} @@ -51,66 +36,62 @@ export function SessionInlineDetails({ event.stopPropagation() }} > -
- - - -
-
+
+ +
{session.title}
-
- {agentLabel(session.agent)} -
-
-
+ -
- - + {recentTurns.length > 0 ? ( +
+ {recentTurns.map((turn, index) => ( +
+ {conversationRoleLabel(turn.role)} + {turn.text} +
+ ))} +
+ ) : ( +
+ {translate( + 'auto.components.right.sidebar.AiVaultSessionDetails.noPreviewAvailable', + 'No conversation preview available' + )} +
)} - value={formatDateTime(session.createdAt)} - /> - {session.model ? ( - - ) : null} - {session.branch ? ( - + +
+ + + + {agentLabel(session.agent)} + · + + {translate( + 'auto.components.right.sidebar.AiVaultSessionDetails.messageCount', + '{{value0}} msgs', + { value0: session.messageCount } )} - value={session.branch} - /> - ) : null} - - + + · + +
@@ -154,71 +135,19 @@ export function SessionInlineDetails({ ) } -function SessionDetailCopyRow({ +function SessionReceiptSection({ label, - copyLabel = label, - value, - mono = false + children }: { label: string - copyLabel?: string - value: string - mono?: boolean + children: React.ReactNode }): React.JSX.Element { - const handleCopy = (event: React.MouseEvent): void => { - event.stopPropagation() - void window.api.ui - .writeClipboardText(value) - .then(() => { - toast.success( - translate('auto.components.right.sidebar.AiVaultPanel.valueCopied', '{{value0}} copied', { - value0: copyLabel - }) - ) - }) - .catch(() => { - toast.error( - translate( - 'auto.components.right.sidebar.AiVaultPanel.valueCopyFailed', - 'Unable to copy {{value0}}', - { value0: copyLabel } - ) - ) - }) - } - return ( -
- {label} - - {value} - - - - - - - {translate( - 'auto.components.right.sidebar.AiVaultSessionDetails.copyDetailValue', - 'Copy {{value0}}', - { value0: copyLabel } - )} - - +
+
+ {label} +
+ {children}
) } @@ -250,17 +179,6 @@ export function SessionTime({ ) } -function formatDateTime(value: string | null): string { - if (!value) { - return translate('auto.components.right.sidebar.AiVaultSessionDetails.unknown', 'Unknown') - } - const timestamp = Date.parse(value) - if (!Number.isFinite(timestamp)) { - return translate('auto.components.right.sidebar.AiVaultSessionDetails.unknown', 'Unknown') - } - return new Date(timestamp).toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' }) -} - function formatTimeAgo(timestamp: number): string { const diffMs = Date.now() - timestamp if (diffMs < 60_000) { @@ -305,12 +223,18 @@ function formatTimeAgo(timestamp: number): string { ) } -export function formatTokenCount(value: number): string { - if (value >= 1_000_000) { - return `${(value / 1_000_000).toFixed(1)}m` +function conversationRoleLabel(role: AiVaultSession['previewMessages'][number]['role']): string { + if (role === 'user') { + return translate('auto.components.right.sidebar.AiVaultSessionDetails.userRole', 'You') } - if (value >= 1_000) { - return `${(value / 1_000).toFixed(1)}k` + if (role === 'assistant') { + return translate('auto.components.right.sidebar.AiVaultSessionDetails.agentRole', 'Agent') } - return String(value) + if (role === 'tool') { + return translate('auto.components.right.sidebar.AiVaultSessionDetails.toolRole', 'Tool') + } + if (role === 'system') { + return translate('auto.components.right.sidebar.AiVaultSessionDetails.systemRole', 'System') + } + return translate('auto.components.right.sidebar.AiVaultSessionDetails.sessionRole', 'Session') } diff --git a/src/renderer/src/components/right-sidebar/AiVaultSessionRow.tsx b/src/renderer/src/components/right-sidebar/AiVaultSessionRow.tsx index 85e68bdde..567a48895 100644 --- a/src/renderer/src/components/right-sidebar/AiVaultSessionRow.tsx +++ b/src/renderer/src/components/right-sidebar/AiVaultSessionRow.tsx @@ -1,5 +1,13 @@ import type React from 'react' -import { ChevronDown, Copy, FileJson, FolderOpen, MoreHorizontal, Play } from 'lucide-react' +import { + ChevronDown, + Copy, + FileJson, + FolderOpen, + GripVertical, + MoreHorizontal, + Play +} from 'lucide-react' import { Button } from '@/components/ui/button' import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' import { @@ -27,6 +35,7 @@ import type { AiVaultSession } from '../../../../shared/ai-vault-types' import { agentLabel } from './ai-vault-session-filters' import { translate } from '@/i18n/i18n' import { SessionInlineDetails, SessionTime } from './AiVaultSessionDetails' +import { latestSessionConversationTurn } from './ai-vault-session-display' export function VaultSessionRow({ session, @@ -57,59 +66,102 @@ export function VaultSessionRow({ }): React.JSX.Element { const updatedAt = session.updatedAt ?? session.modifiedAt const detailsId = getSessionDetailsId(session.id) + const latestTurn = latestSessionConversationTurn(session) const detailsTooltip = detailsExpanded ? translate('auto.components.right.sidebar.AiVaultSessionRow.hideDetails', 'Hide Details') : translate('auto.components.right.sidebar.AiVaultSessionRow.showDetails', 'Show Details') + const startResumeDrag = (event: React.DragEvent): void => { + event.stopPropagation() + if (resumeDisabled) { + event.preventDefault() + return + } + writeAiVaultSessionDragData(event.dataTransfer, { + agent: session.agent, + sessionId: session.sessionId, + title: session.title, + command: resumeCommand + }) + window.dispatchEvent(new Event(AI_VAULT_SESSION_DRAG_START_EVENT)) + } return (
{ - if (resumeDisabled) { - event.preventDefault() - return - } - writeAiVaultSessionDragData(event.dataTransfer, { - agent: session.agent, - sessionId: session.sessionId, - title: session.title, - command: resumeCommand - }) - window.dispatchEvent(new Event(AI_VAULT_SESSION_DRAG_START_EVENT)) - }} - onDragEnd={() => { - window.dispatchEvent(new Event(AI_VAULT_SESSION_DRAG_END_EVENT)) - }} - onDoubleClick={() => { - if (!resumeDisabled) { - onResume() - } + className="group relative flex min-h-[82px] w-full cursor-pointer flex-col border-b border-sidebar-border px-3 py-2 text-left transition-colors hover:bg-sidebar-accent/55" + onClick={() => { + onToggleDetails() }} > -
-
-
+
+
+
{session.title}
-
- +
+ {latestTurn ? ( + <> + + {conversationRoleLabel(latestTurn.role)} + + : {latestTurn.text} + + ) : ( + translate( + 'auto.components.right.sidebar.AiVaultSessionRow.noPreviewAvailable', + 'No conversation preview available' + ) + )} +
+
event.stopPropagation()} onDoubleClick={(event) => event.stopPropagation()} - onDragStart={(event) => { - event.preventDefault() - event.stopPropagation() - }} > + + + + + + {translate( + 'auto.components.right.sidebar.AiVaultSessionRow.dragToResume', + 'Drag to resume in a new tab' + )} + +