Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
TypeScript aiai-agentsai-memoryanthropicartificial-intelligencechromadbclaudeclaude-agent-sdkclaude-agentsclaude-codeclaude-code-pluginclaude-skillsembeddingslong-term-memorymem0memory-engineopenmemoryragsqlitesupermemory
import React, { useRef } from 'react';
import { useI18n, interpolate } from '../../i18n';
import { SessionCatalogEntry } from '../types';
import { formatCount, formatDate, formatShortTime, epochMs } from '../utils/formatters';
import { catalogEntryRef, SESSION_NAME_SOURCE_WORDS, sessionKey, sessionName, sessionNameText, shortSessionId } from '../utils/sessions';
import { sessionHash } from '../utils/memory-route';
import { isPlainClick } from '../utils/links';
import { useDeletes, type FeedItemDeletion } from '../hooks/useFeedItemDelete';
import { SessionCardMenu } from './SessionCardMenu';
import { DeleteConfirmation } from './DeleteButton';
import { ChevronRightIcon, MessagesSquareIcon } from './icons';
interface SessionCardProps {
session: SessionCatalogEntry;
onOpen: () => void;
/** Deletes the session; rejects with a user-facing reason when the worker refuses. `signal` stops waiting. */
onDelete: (signal?: AbortSignal) => Promise<void>;
/** The row's delete, when the list keeps it (so it outlives a recycled row); otherwise the card keeps its own. */
deletion?: FeedItemDeletion;
}
/**
* One row of the Sessions list (Codex's memory-sessions): a mark, the session's name (sessionName), and under it where
* the name came from, the tool, a short id and the start time; the memory count and a chevron at the end. The row is a
* link to the session's address; the "…" menu sits beside it, not inside it (F19), and a delete asks in the row how
* many memories will go (F20).
*/
export function SessionCard({ session, onOpen, onDelete, deletion: listDeletion }: SessionCardProps) {
const { t } = useI18n();
const rowRef = useRef<HTMLDivElement>(null);
const ref = catalogEntryRef(session);
const own = useDeletes();
const deletion = listDeletion ?? own.forKey(sessionKey(ref), signal => onDelete(signal));
const name = sessionName(session.content_session_id, session);
const title = sessionNameText(name, t);
const memories = interpolate(t(session.item_count === 1 ? '{count} memory' : '{count} memories'), { count: formatCount(session.item_count) });
const started = new Date(epochMs(session.started_at_epoch));
const startedKnown = Number.isFinite(started.getTime());
// The day is in the day heading above the row; the full stamp is in the time's title.
const time = startedKnown ? formatShortTime(session.started_at_epoch) : t('Unknown time');
return (
<div ref={rowRef} className={`mem-session-row${deletion.stage === 'deleting' ? ' mem-session-row--deleting' : ''}`}>
<div className="mem-session-row-main">
<a
className="mem-row mem-session-link"
href={sessionHash(ref)}
onClick={event => { if (isPlainClick(event)) { event.preventDefault(); onOpen(); } }}
>
<span className="mem-mark" data-tone="blue" aria-hidden="true"><MessagesSquareIcon size={20} /></span>
<span className="mem-row-body">
<span className="mem-row-title mem-session-name" data-source={name.source} title={title}>{title}</span>
<span className="mem-row-meta mem-session-meta">
<span className="mem-session-source">{SESSION_NAME_SOURCE_WORDS[name.source](t)}</span>
<span className="mem-sep" aria-hidden="true">·</span>
<span className="mem-session-tool">{session.platform_source}</span>
<span className="mem-sep" aria-hidden="true">·</span>
<span className="mem-session-id" title={session.content_session_id} data-session-id={session.content_session_id}
aria-label={interpolate(t('Session id {id}'), { id: session.content_session_id })}>
{shortSessionId(session.content_session_id)}
</span>
<span className="mem-sep" aria-hidden="true">·</span>
{startedKnown
? <time className="mem-session-time" dateTime={started.toISOString()} title={formatDate(session.started_at_epoch)}>{time}</time>
: <span className="mem-session-time">{time}</span>}
</span>
</span>
<span className="mem-row-end mem-session-count">{memories}</span>
<span className="mem-chev" aria-hidden="true"><ChevronRightIcon size={18} /></span>
</a>
<SessionCardMenu onOpen={onOpen} onDelete={deletion.ask} />
</div>
{deletion.stage !== 'idle' && (
<DeleteConfirmation
question={interpolate(t('Delete this session and everything captured in it ({count})? This cannot be undone.'), { count: memories })}
confirmLabel={interpolate(t('Delete {item}'), { item: t('session') })}
deletion={deletion}
returnFocus={() => rowRef.current?.querySelector<HTMLElement>('.mem-session-menu-trigger')?.focus()}
/>
)}
</div>
);
}