Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(ui): correct memory insight display for empty state

Steven Enamakel3dac35f3ce6f
diff --git a/app/src/components/intelligence/MemoryInsights.tsx b/app/src/components/intelligence/MemoryInsights.tsx
index a430d3a9b9..1813dd2b53 100644
--- a/app/src/components/intelligence/MemoryInsights.tsx
+++ b/app/src/components/intelligence/MemoryInsights.tsx
@@ -224,22 +224,36 @@ export function MemoryInsights({ relations, loading }: MemoryInsightsProps) {
</div>
</div>
- <div className="grid grid-cols-2 lg:grid-cols-3 gap-3">
+ {/*
+ * Category cards are exclusive — expanding one collapses whatever else
+ * was open — so this is Accordion `type="single" collapsible`, not a
+ * plain grid of buttons. The first 3 items per category are always
+ * visible (a preview, not a disclosure), so only the *extra* items
+ * beyond that live inside `AccordionContent` and unmount when the card
+ * is collapsed; the preview + "+N more" hint stay outside it.
+ */}
+ <AccordionRoot
+ type="single"
+ collapsible
+ value={expandedCategory ?? ''}
+ onValueChange={value => setExpandedCategory((value || null) as InsightCategory | null)}
+ variant="card"
+ className="grid grid-cols-2 lg:grid-cols-3 gap-3">
{groups.map(group => {
const isExpanded = expandedCategory === group.category;
- const displayItems = isExpanded ? group.items.slice(0, 20) : group.items.slice(0, 3);
+ const previewItems = group.items.slice(0, 3);
+ const extraItems = group.items.slice(3, 20);
return (
- <div
+ <AccordionItem
key={group.category}
+ value={group.category}
className={`rounded-lg border ${group.borderColor} ${group.bgColor} p-3 transition-all ${
isExpanded ? 'col-span-2 lg:col-span-3' : ''
}`}>
- <Button
- variant="tertiary"
- onClick={() => setExpandedCategory(isExpanded ? null : group.category)}
- aria-expanded={isExpanded}
- className="h-auto w-full justify-start gap-2 p-0 text-left font-normal mb-2 hover:bg-transparent">
+ <AccordionTrigger
+ showChevron={false}
+ className="h-auto gap-2 p-0 font-normal mb-2 hover:bg-transparent">
<div
className={`w-7 h-7 rounded-md ${group.bgColor} flex items-center justify-center flex-shrink-0`}>
<svg
@@ -273,41 +287,58 @@ export function MemoryInsights({ relations, loading }: MemoryInsightsProps) {
d="M19 9l-7 7-7-7"
/>
</svg>
- </Button>
+ </AccordionTrigger>
<div className={`space-y-1.5 ${isExpanded ? 'max-h-80 overflow-y-auto pr-1' : ''}`}>
- {displayItems.map((item, idx) => (
- <div
- key={`${item.subject}-${item.predicate}-${item.object}-${idx}`}
- className="flex items-start gap-1.5 text-[11px] leading-relaxed">
- <span
- className="text-content font-medium shrink-0 max-w-[30%] truncate"
- title={item.subject}>
- {item.subject}
- {item.subjectType && <EntityTypeBadge type={item.subjectType} />}
- </span>
- <span className="text-content-muted shrink-0 italic">{item.predicate}</span>
- <span className="text-content-secondary truncate" title={item.object}>
- {item.object}
- {item.objectType && <EntityTypeBadge type={item.objectType} />}
- </span>
- {item.evidenceCount > 1 && (
- <span className="ml-auto text-[9px] text-content-secondary shrink-0 tabular-nums">
- x{item.evidenceCount}
- </span>
- )}
- </div>
+ {previewItems.map((item, idx) => (
+ <InsightItemRow key={`${item.subject}-${item.predicate}-${item.object}-${idx}`}
+ item={item}
+ />
))}
{!isExpanded && group.items.length > 3 && (
<div className="text-[10px] text-content-muted pt-0.5">
+{group.items.length - 3} {t('insights.more')}
</div>
)}
+ {extraItems.length > 0 && (
+ <AccordionContent className="p-0">
+ <div className="space-y-1.5">
+ {extraItems.map((item, idx) => (
+ <InsightItemRow
+ key={`${item.subject}-${item.predicate}-${item.object}-${idx + 3}`}
+ item={item}
+ />
+ ))}
+ </div>
+ </AccordionContent>
+ )}
</div>
- </div>
+ </AccordionItem>
);
})}
- </div>
+ </AccordionRoot>
+ </div>
+ );
+}
+
+/** One subject/predicate/object row, shared between the always-visible preview and the expanded extra items. */
+function InsightItemRow({ item }: { item: InsightItem }) {
+ return (
+ <div className="flex items-start gap-1.5 text-[11px] leading-relaxed">
+ <span className="text-content font-medium shrink-0 max-w-[30%] truncate" title={item.subject}>
+ {item.subject}
+ {item.subjectType && <EntityTypeBadge type={item.subjectType} />}
+ </span>
+ <span className="text-content-muted shrink-0 italic">{item.predicate}</span>
+ <span className="text-content-secondary truncate" title={item.object}>
+ {item.object}
+ {item.objectType && <EntityTypeBadge type={item.objectType} />}
+ </span>
+ {item.evidenceCount > 1 && (
+ <span className="ml-auto text-[9px] text-content-secondary shrink-0 tabular-nums">
+ x{item.evidenceCount}
+ </span>
+ )}
</div>
);
}