Enhance AI Vault session rows with conversation previews (#5896)
Revamp the session display in the AI Vault to prioritize visible conversation history (user and assistant turns) over raw metadata. - Display the latest conversation turn directly on collapsed rows - Redesign expanded details to show the "Original ask" and latest turns - Integrate visible preview text into session search filters - Add a dedicated drag handle for resuming sessions to prevent accidental drags on the row card - Update row height and virtual scroll metrics to accommodate previews
This commit is contained in:
@@ -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 (
|
||||
<div
|
||||
id={id}
|
||||
className="mt-2 rounded-md border border-sidebar-border bg-sidebar-accent/25 p-2"
|
||||
className="mt-2 rounded-md border border-sidebar-border bg-sidebar-accent/25 p-2.5"
|
||||
onPointerDown={(event) => event.stopPropagation()}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
onDoubleClick={(event) => event.stopPropagation()}
|
||||
@@ -51,66 +36,62 @@ export function SessionInlineDetails({
|
||||
event.stopPropagation()
|
||||
}}
|
||||
>
|
||||
<div className="flex min-w-0 items-start gap-2">
|
||||
<span className="mt-0.5 flex size-5 shrink-0 items-center justify-center text-muted-foreground">
|
||||
<AgentIcon agent={session.agent} size={16} />
|
||||
</span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="line-clamp-2 text-[12px] font-medium leading-4 text-foreground">
|
||||
<div className="space-y-2.5">
|
||||
<SessionReceiptSection
|
||||
label={translate(
|
||||
'auto.components.right.sidebar.AiVaultSessionDetails.originalAsk',
|
||||
'Original ask'
|
||||
)}
|
||||
>
|
||||
<div className="min-w-0 break-words text-[12px] font-medium leading-4 text-foreground [overflow-wrap:anywhere]">
|
||||
{session.title}
|
||||
</div>
|
||||
<div className="mt-0.5 truncate text-[11px] text-muted-foreground">
|
||||
{agentLabel(session.agent)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</SessionReceiptSection>
|
||||
|
||||
<div className="mt-2 grid gap-1 text-[11px] leading-4">
|
||||
<SessionDetailCopyRow
|
||||
<SessionReceiptSection
|
||||
label={translate(
|
||||
'auto.components.right.sidebar.AiVaultSessionDetails.updated',
|
||||
'Updated'
|
||||
'auto.components.right.sidebar.AiVaultSessionDetails.latestTurns',
|
||||
'Latest turns'
|
||||
)}
|
||||
value={formatDateTime(updatedAt)}
|
||||
/>
|
||||
<SessionDetailCopyRow
|
||||
label={translate(
|
||||
'auto.components.right.sidebar.AiVaultSessionDetails.created',
|
||||
'Created'
|
||||
>
|
||||
{recentTurns.length > 0 ? (
|
||||
<div className="grid gap-1.5">
|
||||
{recentTurns.map((turn, index) => (
|
||||
<div
|
||||
key={`${turn.timestamp ?? 'turn'}-${index}`}
|
||||
className="grid min-w-0 grid-cols-[3.25rem_minmax(0,1fr)] gap-2 text-[11px] leading-4"
|
||||
>
|
||||
<span className="text-muted-foreground">{conversationRoleLabel(turn.role)}</span>
|
||||
<span className="line-clamp-3 text-foreground/90">{turn.text}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-[11px] leading-4 text-muted-foreground">
|
||||
{translate(
|
||||
'auto.components.right.sidebar.AiVaultSessionDetails.noPreviewAvailable',
|
||||
'No conversation preview available'
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
value={formatDateTime(session.createdAt)}
|
||||
/>
|
||||
{session.model ? (
|
||||
<SessionDetailCopyRow
|
||||
label={translate('auto.components.right.sidebar.AiVaultSessionDetails.model', 'Model')}
|
||||
value={session.model}
|
||||
/>
|
||||
) : null}
|
||||
{session.branch ? (
|
||||
<SessionDetailCopyRow
|
||||
label={translate(
|
||||
'auto.components.right.sidebar.AiVaultSessionDetails.branch',
|
||||
'Branch'
|
||||
</SessionReceiptSection>
|
||||
|
||||
<div className="flex min-w-0 items-center gap-1.5 text-[11px] leading-4 text-muted-foreground">
|
||||
<span className="flex size-4 shrink-0 items-center justify-center text-muted-foreground">
|
||||
<AgentIcon agent={session.agent} size={14} />
|
||||
</span>
|
||||
<span className="min-w-0 truncate">{agentLabel(session.agent)}</span>
|
||||
<span className="shrink-0 text-muted-foreground/55">·</span>
|
||||
<span className="shrink-0">
|
||||
{translate(
|
||||
'auto.components.right.sidebar.AiVaultSessionDetails.messageCount',
|
||||
'{{value0}} msgs',
|
||||
{ value0: session.messageCount }
|
||||
)}
|
||||
value={session.branch}
|
||||
/>
|
||||
) : null}
|
||||
<SessionDetailCopyRow
|
||||
label={translate('auto.components.right.sidebar.AiVaultSessionDetails.usage', 'Usage')}
|
||||
value={usage}
|
||||
/>
|
||||
<SessionDetailCopyRow
|
||||
label={translate(
|
||||
'auto.components.right.sidebar.AiVaultSessionDetails.session',
|
||||
'Session'
|
||||
)}
|
||||
copyLabel={translate(
|
||||
'auto.components.right.sidebar.AiVaultSessionDetails.sessionId',
|
||||
'Session ID'
|
||||
)}
|
||||
value={session.sessionId}
|
||||
mono
|
||||
/>
|
||||
</span>
|
||||
<span className="shrink-0 text-muted-foreground/55">·</span>
|
||||
<SessionTime value={updatedAt} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-2 grid gap-1">
|
||||
@@ -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<HTMLButtonElement>): 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 (
|
||||
<div className="grid min-w-0 grid-cols-[4.5rem_minmax(0,1fr)_1.5rem] items-center gap-2 rounded-sm px-1 py-0.5">
|
||||
<span className="text-muted-foreground">{label}</span>
|
||||
<span className={cn('min-w-0 truncate text-foreground/90', mono && 'font-mono')}>
|
||||
{value}
|
||||
</span>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
draggable={false}
|
||||
onClick={handleCopy}
|
||||
aria-label={translate(
|
||||
'auto.components.right.sidebar.AiVaultSessionDetails.copyDetailValue',
|
||||
'Copy {{value0}}',
|
||||
{ value0: copyLabel }
|
||||
)}
|
||||
className="size-5 text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
<Copy className="size-3" />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top" sideOffset={4}>
|
||||
{translate(
|
||||
'auto.components.right.sidebar.AiVaultSessionDetails.copyDetailValue',
|
||||
'Copy {{value0}}',
|
||||
{ value0: copyLabel }
|
||||
)}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<div className="grid gap-1">
|
||||
<div className="text-[10px] font-semibold uppercase leading-3 text-muted-foreground">
|
||||
{label}
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -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')
|
||||
}
|
||||
|
||||
@@ -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<HTMLButtonElement>): 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 (
|
||||
<ContextMenu>
|
||||
<ContextMenuTrigger asChild>
|
||||
<div
|
||||
draggable={!resumeDisabled}
|
||||
className={cn(
|
||||
'group relative flex min-h-[64px] w-full flex-col border-b border-sidebar-border px-3 py-2 text-left transition-colors hover:bg-sidebar-accent/55',
|
||||
!resumeDisabled && 'cursor-grab active:cursor-grabbing'
|
||||
)}
|
||||
onDragStart={(event) => {
|
||||
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()
|
||||
}}
|
||||
>
|
||||
<div className="min-w-0 flex-1 pr-24">
|
||||
<div className="flex min-w-0 items-start gap-1.5">
|
||||
<div className="min-w-0 flex-1 truncate text-[13px] font-medium leading-5 text-foreground">
|
||||
<div className="min-w-0 flex-1 pr-32">
|
||||
<div className="min-w-0">
|
||||
<div
|
||||
className={cn(
|
||||
'text-[13px] font-medium leading-5 text-foreground',
|
||||
detailsExpanded
|
||||
? 'min-w-0 break-words [overflow-wrap:anywhere]'
|
||||
: 'line-clamp-1'
|
||||
)}
|
||||
>
|
||||
{session.title}
|
||||
</div>
|
||||
<SessionTime value={updatedAt} className="mt-0.5 @max-[300px]/ai-vault:hidden" />
|
||||
</div>
|
||||
<SessionMetadata session={session} />
|
||||
<div className="mt-0.5 line-clamp-2 text-[12px] leading-4 text-muted-foreground">
|
||||
{latestTurn ? (
|
||||
<>
|
||||
<span className="font-medium text-foreground/80">
|
||||
{conversationRoleLabel(latestTurn.role)}
|
||||
</span>
|
||||
<span>: {latestTurn.text}</span>
|
||||
</>
|
||||
) : (
|
||||
translate(
|
||||
'auto.components.right.sidebar.AiVaultSessionRow.noPreviewAvailable',
|
||||
'No conversation preview available'
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
<SessionMetadata session={session} updatedAt={updatedAt} />
|
||||
</div>
|
||||
<div
|
||||
className="pointer-events-none absolute right-2 top-1.5 flex items-center gap-1 rounded-md bg-sidebar/95"
|
||||
onPointerDown={(event) => event.stopPropagation()}
|
||||
onDoubleClick={(event) => event.stopPropagation()}
|
||||
onDragStart={(event) => {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
}}
|
||||
>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
aria-label={translate(
|
||||
'auto.components.right.sidebar.AiVaultSessionRow.dragToResume',
|
||||
'Drag to resume in a new tab'
|
||||
)}
|
||||
disabled={resumeDisabled}
|
||||
draggable={!resumeDisabled}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation()
|
||||
}}
|
||||
onDragStart={startResumeDrag}
|
||||
onDragEnd={() => {
|
||||
window.dispatchEvent(new Event(AI_VAULT_SESSION_DRAG_END_EVENT))
|
||||
}}
|
||||
// Why: the card is for inspection. Drag-to-resume lives on a
|
||||
// quiet handle so the row does not look movable by default.
|
||||
className="pointer-events-auto cursor-grab can-hover:pointer-events-none can-hover:opacity-0 transition-opacity active:cursor-grabbing group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100"
|
||||
>
|
||||
<GripVertical className="size-3.5" />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top" sideOffset={4}>
|
||||
{translate(
|
||||
'auto.components.right.sidebar.AiVaultSessionRow.dragToResume',
|
||||
'Drag to resume in a new tab'
|
||||
)}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
@@ -318,9 +370,15 @@ function getSessionDetailsId(sessionId: string): string {
|
||||
return `ai-vault-session-details-${sessionId.replace(/[^A-Za-z0-9_-]/g, '-')}`
|
||||
}
|
||||
|
||||
function SessionMetadata({ session }: { session: AiVaultSession }): React.JSX.Element {
|
||||
function SessionMetadata({
|
||||
session,
|
||||
updatedAt
|
||||
}: {
|
||||
session: AiVaultSession
|
||||
updatedAt: string
|
||||
}): React.JSX.Element {
|
||||
return (
|
||||
<div className="mt-0.5 flex min-w-0 items-center gap-1.5 text-[11px] leading-4 text-muted-foreground">
|
||||
<div className="mt-1 flex min-w-0 items-center gap-1.5 text-[11px] leading-4 text-muted-foreground">
|
||||
<span className="flex size-4 shrink-0 items-center justify-center text-muted-foreground">
|
||||
<AgentIcon agent={session.agent} size={14} />
|
||||
</span>
|
||||
@@ -332,6 +390,24 @@ function SessionMetadata({ session }: { session: AiVaultSession }): React.JSX.El
|
||||
{ value0: session.messageCount }
|
||||
)}
|
||||
</span>
|
||||
<span className="shrink-0 text-muted-foreground/55">·</span>
|
||||
<SessionTime value={updatedAt} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function conversationRoleLabel(role: AiVaultSession['previewMessages'][number]['role']): string {
|
||||
if (role === 'user') {
|
||||
return translate('auto.components.right.sidebar.AiVaultSessionRow.userRole', 'You')
|
||||
}
|
||||
if (role === 'assistant') {
|
||||
return translate('auto.components.right.sidebar.AiVaultSessionRow.agentRole', 'Agent')
|
||||
}
|
||||
if (role === 'tool') {
|
||||
return translate('auto.components.right.sidebar.AiVaultSessionRow.toolRole', 'Tool')
|
||||
}
|
||||
if (role === 'system') {
|
||||
return translate('auto.components.right.sidebar.AiVaultSessionRow.systemRole', 'System')
|
||||
}
|
||||
return translate('auto.components.right.sidebar.AiVaultSessionRow.sessionRole', 'Session')
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { AiVaultSession } from '../../../../shared/ai-vault-types'
|
||||
import {
|
||||
latestSessionConversationTurn,
|
||||
recentSessionConversationTurns,
|
||||
sessionPreviewSearchText
|
||||
} from './ai-vault-session-display'
|
||||
|
||||
const baseSession: AiVaultSession = {
|
||||
id: 'codex:1',
|
||||
agent: 'codex',
|
||||
sessionId: 'session-1',
|
||||
title: 'Fix the flaky golden tests',
|
||||
cwd: '/Users/ada/repo/app',
|
||||
branch: 'fix/golden',
|
||||
model: 'gpt-5.5',
|
||||
filePath: '/Users/ada/.codex/sessions/session-1.jsonl',
|
||||
codexHome: null,
|
||||
createdAt: '2026-05-01T10:00:00.000Z',
|
||||
updatedAt: '2026-05-01T10:10:00.000Z',
|
||||
modifiedAt: '2026-05-01T10:10:00.000Z',
|
||||
messageCount: 4,
|
||||
totalTokens: 1200,
|
||||
previewMessages: [
|
||||
{ role: 'user', text: 'Please fix the flaky golden tests', timestamp: null },
|
||||
{ role: 'tool', text: 'pnpm test failed', timestamp: null },
|
||||
{ role: 'assistant', text: 'I updated the fixture ordering', timestamp: null },
|
||||
{ role: 'system', text: 'hidden runtime bookkeeping', timestamp: null }
|
||||
],
|
||||
resumeCommand: "cd '/Users/ada/repo/app' && codex resume 'session-1'"
|
||||
}
|
||||
|
||||
describe('ai vault session display', () => {
|
||||
it('uses the latest user or assistant turn for the collapsed row preview', () => {
|
||||
expect(latestSessionConversationTurn(baseSession)).toEqual({
|
||||
role: 'assistant',
|
||||
text: 'I updated the fixture ordering',
|
||||
timestamp: null
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps recent turns conversation-first and falls back when no conversation turns exist', () => {
|
||||
expect(recentSessionConversationTurns(baseSession, 2).map((turn) => turn.text)).toEqual([
|
||||
'Please fix the flaky golden tests',
|
||||
'I updated the fixture ordering'
|
||||
])
|
||||
|
||||
expect(
|
||||
recentSessionConversationTurns(
|
||||
{
|
||||
...baseSession,
|
||||
previewMessages: [{ role: 'tool', text: 'tool-only transcript', timestamp: null }]
|
||||
},
|
||||
1
|
||||
)
|
||||
).toEqual([{ role: 'tool', text: 'tool-only transcript', timestamp: null }])
|
||||
})
|
||||
|
||||
it('builds search text from displayed preview messages', () => {
|
||||
expect(sessionPreviewSearchText(baseSession)).toContain('fixture ordering')
|
||||
expect(sessionPreviewSearchText(baseSession)).not.toContain('pnpm test failed')
|
||||
expect(sessionPreviewSearchText(baseSession)).not.toContain('hidden runtime bookkeeping')
|
||||
})
|
||||
|
||||
it('searches fallback tool text when no conversation turns exist', () => {
|
||||
expect(
|
||||
sessionPreviewSearchText({
|
||||
...baseSession,
|
||||
previewMessages: [{ role: 'tool', text: 'tool-only transcript', timestamp: null }]
|
||||
})
|
||||
).toBe('tool-only transcript')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,55 @@
|
||||
import type {
|
||||
AiVaultSession,
|
||||
AiVaultSessionPreviewMessage
|
||||
} from '../../../../shared/ai-vault-types'
|
||||
|
||||
const CONVERSATION_ROLES = new Set<AiVaultSessionPreviewMessage['role']>(['user', 'assistant'])
|
||||
|
||||
export type AiVaultSessionDisplayTurn = {
|
||||
role: AiVaultSessionPreviewMessage['role']
|
||||
text: string
|
||||
timestamp: string | null
|
||||
}
|
||||
|
||||
export function latestSessionConversationTurn(
|
||||
session: AiVaultSession
|
||||
): AiVaultSessionDisplayTurn | null {
|
||||
return recentSessionConversationTurns(session, 1)[0] ?? null
|
||||
}
|
||||
|
||||
export function recentSessionConversationTurns(
|
||||
session: AiVaultSession,
|
||||
limit: number
|
||||
): AiVaultSessionDisplayTurn[] {
|
||||
if (limit <= 0) {
|
||||
return []
|
||||
}
|
||||
|
||||
return displayableSessionPreviewMessages(session).slice(-limit).map(toDisplayTurn)
|
||||
}
|
||||
|
||||
export function sessionPreviewSearchText(session: AiVaultSession): string {
|
||||
return displayableSessionPreviewMessages(session)
|
||||
.map((message) => message.text)
|
||||
.join(' ')
|
||||
}
|
||||
|
||||
function displayableSessionPreviewMessages(
|
||||
session: AiVaultSession
|
||||
): AiVaultSessionPreviewMessage[] {
|
||||
const conversationTurns = session.previewMessages.filter((message) =>
|
||||
CONVERSATION_ROLES.has(message.role)
|
||||
)
|
||||
|
||||
// Why: search hits should be explainable by the preview UI; tool/system text is
|
||||
// only searchable when it is the fallback preview shown for the session.
|
||||
return conversationTurns.length > 0 ? conversationTurns : session.previewMessages
|
||||
}
|
||||
|
||||
function toDisplayTurn(message: AiVaultSessionPreviewMessage): AiVaultSessionDisplayTurn {
|
||||
return {
|
||||
role: message.role,
|
||||
text: message.text,
|
||||
timestamp: message.timestamp
|
||||
}
|
||||
}
|
||||
@@ -88,6 +88,65 @@ describe('filterAiVaultSessions', () => {
|
||||
expect(new Set(shownWhenAllowed)).toEqual(new Set(['claude:1', 'claude:empty']))
|
||||
})
|
||||
|
||||
it('matches visible preview message text', () => {
|
||||
expect(
|
||||
filterAiVaultSessions(
|
||||
[
|
||||
{
|
||||
...baseSession,
|
||||
previewMessages: [
|
||||
{
|
||||
role: 'assistant',
|
||||
text: 'The fixture ordering now matches the golden output.',
|
||||
timestamp: null
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
{
|
||||
query: 'fixture ordering',
|
||||
agents: ['claude'],
|
||||
scope: 'all',
|
||||
sort: 'updated',
|
||||
activeWorktreePath: null,
|
||||
hideEmptySessions: true
|
||||
}
|
||||
).map((session) => session.id)
|
||||
).toEqual(['claude:1'])
|
||||
})
|
||||
|
||||
it('does not match hidden preview text when conversation turns are visible', () => {
|
||||
expect(
|
||||
filterAiVaultSessions(
|
||||
[
|
||||
{
|
||||
...baseSession,
|
||||
previewMessages: [
|
||||
{
|
||||
role: 'user',
|
||||
text: 'Please repair the screenshot comparison.',
|
||||
timestamp: null
|
||||
},
|
||||
{
|
||||
role: 'tool',
|
||||
text: 'internal-build-cache-token',
|
||||
timestamp: null
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
{
|
||||
query: 'internal-build-cache-token',
|
||||
agents: ['claude'],
|
||||
scope: 'all',
|
||||
sort: 'updated',
|
||||
activeWorktreePath: null,
|
||||
hideEmptySessions: true
|
||||
}
|
||||
)
|
||||
).toEqual([])
|
||||
})
|
||||
|
||||
it('matches Windows workspace paths case-insensitively', () => {
|
||||
expect(
|
||||
filterAiVaultSessions(
|
||||
|
||||
@@ -11,6 +11,7 @@ import type {
|
||||
AiVaultSort
|
||||
} from '../../../../shared/ai-vault-types'
|
||||
import { aiVaultAgentLabel } from '../../../../shared/ai-vault-types'
|
||||
import { sessionPreviewSearchText } from './ai-vault-session-display'
|
||||
|
||||
export type AiVaultSessionFilterState = {
|
||||
query: string
|
||||
@@ -143,7 +144,8 @@ function matchesQuery(session: AiVaultSession, parsed: ParsedQuery): boolean {
|
||||
session.branch,
|
||||
session.model,
|
||||
session.cwd,
|
||||
session.filePath
|
||||
session.filePath,
|
||||
sessionPreviewSearchText(session)
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from '../sidebar/worktree-list-virtual-rows'
|
||||
|
||||
export const VAULT_GROUP_HEADER_ROW_HEIGHT = 32
|
||||
export const VAULT_SESSION_ROW_HEIGHT = 64
|
||||
export const VAULT_SESSION_ROW_HEIGHT = 82
|
||||
|
||||
export type VaultVirtualRow = { type: 'group' | 'session' }
|
||||
|
||||
|
||||
@@ -9067,6 +9067,10 @@
|
||||
"globalScope": "Global"
|
||||
},
|
||||
"AiVaultSessionDetails": {
|
||||
"originalAsk": "Original ask",
|
||||
"latestTurns": "Latest turns",
|
||||
"noPreviewAvailable": "No conversation preview available",
|
||||
"messageCount": "{{value0}} msgs",
|
||||
"updated": "Updated",
|
||||
"created": "Created",
|
||||
"workingDir": "Working dir",
|
||||
@@ -9102,9 +9106,16 @@
|
||||
"hoursAgo": "{{value0}}h ago",
|
||||
"daysAgo": "{{value0}}d ago",
|
||||
"monthsAgo": "{{value0}}mo ago",
|
||||
"yearsAgo": "{{value0}}y ago"
|
||||
"yearsAgo": "{{value0}}y ago",
|
||||
"userRole": "You",
|
||||
"agentRole": "Agent",
|
||||
"toolRole": "Tool",
|
||||
"systemRole": "System",
|
||||
"sessionRole": "Session"
|
||||
},
|
||||
"AiVaultSessionRow": {
|
||||
"noPreviewAvailable": "No conversation preview available",
|
||||
"dragToResume": "Drag to resume in a new tab",
|
||||
"resumeAgentSession": "Resume {{value0}} session",
|
||||
"resumeInNewTab": "Resume in New Tab",
|
||||
"toggleSessionDetails": "{{value0}} session details",
|
||||
@@ -9119,7 +9130,12 @@
|
||||
"hideDetails": "Hide Details",
|
||||
"showDetails": "Show Details",
|
||||
"moreSessionActions": "More Session Actions",
|
||||
"moreActions": "More Actions"
|
||||
"moreActions": "More Actions",
|
||||
"userRole": "You",
|
||||
"agentRole": "Agent",
|
||||
"toolRole": "Tool",
|
||||
"systemRole": "System",
|
||||
"sessionRole": "Session"
|
||||
},
|
||||
"FileExplorerNameFilter": {
|
||||
"26fb73c6e3": "Find files",
|
||||
|
||||
Reference in New Issue
Block a user