import { useState } from "react"
import { cn } from "@lib/utils"
import { Tabs, TabsList, TabsTrigger } from "@ui/components/tabs"
export interface MemoryEntry {
id: string
memory: string
title?: string
url?: string
version: number
isForgotten: boolean
forgetAfter: string | null
isLatest: boolean
isStatic: boolean
}
function VersionStatus({
status,
}: {
status: "latest" | "static" | "expiring" | "forgotten"
}) {
return (
<>
{
{
latest: (
),
static: (
Static
),
expiring: (
),
forgotten: (
),
}[status]
}
>
)
}
export function GraphListMemories({
memoryEntries,
}: {
memoryEntries: MemoryEntry[]
}) {
const [expandedMemories, setExpandedMemories] = useState>(
new Set(),
)
const toggleMemory = (memoryId: string) => {
setExpandedMemories((prev) => {
const next = new Set(prev)
if (next.has(memoryId)) {
next.delete(memoryId)
} else {
next.add(memoryId)
}
return next
})
}
return (
Graph
List
{memoryEntries.map((memory, idx) => {
const isClickable =
memory.url &&
(memory.url.startsWith("http://") ||
memory.url.startsWith("https://"))
const status = memory.isForgotten
? "forgotten"
: memory.forgetAfter
? "expiring"
: memory.isStatic
? "static"
: "latest"
const content = (
{memory.title && (
{memory.title}
)}
{memory.memory && (
)}
{memory.url && (
{memory.url}
)}
)
if (isClickable) {
return (
{content}
)
}
return (
{content}
)
})}
)
}