Show metadata sections in node panel and preserve them during merge
- Render metadata.sections as labeled blocks in NodePanel sidebar - Fix memory_merge to carry forward metadata from merged nodes
This commit is contained in:
@@ -90,6 +90,18 @@ export default function NodePanel({
|
|||||||
<Field label="Content" field="content" value={node.content} />
|
<Field label="Content" field="content" value={node.content} />
|
||||||
<Field label="Tags" field="tags" value={node.tags.join(', ')} />
|
<Field label="Tags" field="tags" value={node.tags.join(', ')} />
|
||||||
|
|
||||||
|
{node.metadata?.sections?.length > 0 && (
|
||||||
|
<div className="mb-3">
|
||||||
|
<label className="text-[10px] uppercase tracking-wide text-gray-500">Sections</label>
|
||||||
|
{node.metadata.sections.map((s: { label: string; body: string }, i: number) => (
|
||||||
|
<div key={i} className="mt-2 bg-gray-800/50 rounded p-2">
|
||||||
|
<div className="text-xs font-medium text-indigo-400">{s.label}</div>
|
||||||
|
<div className="text-sm text-gray-300 mt-0.5 whitespace-pre-wrap">{s.body}</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="mt-4">
|
<div className="mt-4">
|
||||||
<label className="text-[10px] uppercase tracking-wide text-gray-500">Connections</label>
|
<label className="text-[10px] uppercase tracking-wide text-gray-500">Connections</label>
|
||||||
{node.connections.outgoing.length === 0 && node.connections.incoming.length === 0 && (
|
{node.connections.outgoing.length === 0 && node.connections.incoming.length === 0 && (
|
||||||
|
|||||||
@@ -160,7 +160,9 @@ server.tool(
|
|||||||
const allTags = [...new Set(validNodes.flatMap(n => n.tags))];
|
const allTags = [...new Set(validNodes.flatMap(n => n.tags))];
|
||||||
const mergedKind = (kind as NodeKind) ?? validNodes[0].kind;
|
const mergedKind = (kind as NodeKind) ?? validNodes[0].kind;
|
||||||
|
|
||||||
const merged = await addNode({ kind: mergedKind, title, content, tags: allTags });
|
// Merge metadata from all nodes (last wins for conflicting keys)
|
||||||
|
const mergedMetadata = validNodes.reduce((acc, n) => ({ ...acc, ...n.metadata }), {} as Record<string, any>);
|
||||||
|
const merged = await addNode({ kind: mergedKind, title, content, tags: allTags, metadata: mergedMetadata });
|
||||||
const oldIds = new Set(validNodes.map(n => n.id));
|
const oldIds = new Set(validNodes.map(n => n.id));
|
||||||
|
|
||||||
// Relink edges from old nodes to merged node
|
// Relink edges from old nodes to merged node
|
||||||
|
|||||||
Reference in New Issue
Block a user