sync: Idea Genealogy + Quick Capture Overhaul

From private repo:

Idea Genealogy:
- Required edge explanations across UI/tools/API/MCP
- Inferred edge schema (category/type/confidence)
- Added part_of relationship type
- Connection UI chips (Made by / Part of / Came from / Related)

Quick Capture Overhaul:
- Jina.ai fallback for JS-rendered sites (Twitter, SPAs)
- Simplified UI: removed mode buttons, auto-detect input type
- Renamed to "Add Stuff", moved to top-right
- Auto-edge creation from description entities
- Increased content summary length (500→1500 chars)

Description Generation Fix:
- Simplified prompt to "what is this"
- Added link/dimensions context
- Better creator attribution

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
“BeeRad”
2026-01-14 17:08:26 +11:00
co-authored by Claude Opus 4.5
parent f7b8b2058c
commit 2cbc950fd4
21 changed files with 1296 additions and 389 deletions
+21 -4
View File
@@ -27,10 +27,10 @@ export async function POST(request: NextRequest) {
const body = await request.json();
// Validate required fields
if (!body.from_node_id || !body.to_node_id) {
if (!body.from_node_id || !body.to_node_id || typeof body.explanation !== 'string') {
return NextResponse.json({
success: false,
error: 'Missing required fields: from_node_id and to_node_id are required'
error: 'Missing required fields: from_node_id, to_node_id, and explanation are required'
}, { status: 400 });
}
@@ -57,6 +57,21 @@ export async function POST(request: NextRequest) {
const fromId = parseInt(body.from_node_id);
const toId = parseInt(body.to_node_id);
const explanation = String(body.explanation || '').trim();
if (!explanation) {
return NextResponse.json({
success: false,
error: 'explanation is required and cannot be empty'
}, { status: 400 });
}
const skipInference = Boolean(body.skip_inference);
const createdVia = (() => {
const raw = typeof body.created_via === 'string' ? body.created_via : '';
if (['ui', 'agent', 'mcp', 'workflow', 'quicklink'].includes(raw)) return raw as any;
return 'ui' as const;
})();
// Idempotency: prevent duplicate edges between same pair
try {
@@ -76,8 +91,10 @@ export async function POST(request: NextRequest) {
const edge = await edgeService.createEdge({
from_node_id: fromId,
to_node_id: toId,
context: body.context || {},
source: body.source
explanation,
created_via: createdVia,
source: body.source,
skip_inference: skipInference
});
return NextResponse.json({
@@ -4,6 +4,55 @@ import { generateDescription } from '@/services/database/descriptionService';
export const runtime = 'nodejs';
type NodeMetadata = { source?: string; channel_name?: string; author?: string; site_name?: string; type?: string } & Record<string, unknown>;
function parseMetadata(raw: unknown): NodeMetadata | undefined {
if (!raw) return undefined;
if (typeof raw === 'string') {
try {
return JSON.parse(raw) as NodeMetadata;
} catch {
return undefined;
}
}
if (typeof raw === 'object') {
return raw as NodeMetadata;
}
return undefined;
}
async function enrichYoutubeMetadataIfMissing(link: string, metadata: NodeMetadata | undefined): Promise<NodeMetadata | undefined> {
const url = link.trim();
if (!url) return metadata;
if (!url.includes('youtube.com') && !url.includes('youtu.be')) return metadata;
const existing = metadata || {};
const hasCreatorHint = Boolean(
(typeof existing.author === 'string' && existing.author.trim()) ||
(typeof existing.channel_name === 'string' && existing.channel_name.trim())
);
if (hasCreatorHint) return existing;
try {
const oembedUrl = `https://www.youtube.com/oembed?url=${encodeURIComponent(url)}&format=json`;
const response = await fetch(oembedUrl, { signal: AbortSignal.timeout(6000) });
if (!response.ok) return existing;
const data = await response.json();
const authorName = typeof data.author_name === 'string' ? data.author_name.trim() : '';
const providerName = typeof data.provider_name === 'string' ? data.provider_name.trim() : '';
if (!authorName) return existing;
return {
...existing,
source: typeof existing.source === 'string' && existing.source.trim().length > 0 ? existing.source : 'youtube',
channel_name: typeof existing.channel_name === 'string' && existing.channel_name.trim().length > 0 ? existing.channel_name : authorName,
site_name: typeof existing.site_name === 'string' && existing.site_name.trim().length > 0 ? existing.site_name : (providerName || 'YouTube'),
};
} catch {
return existing;
}
}
export async function POST(
request: NextRequest,
{ params }: { params: Promise<{ id: string }> }
@@ -28,19 +77,25 @@ export async function POST(
}, { status: 404 });
}
const parsedMetadata = parseMetadata(node.metadata);
const enrichedMetadata = node.link
? await enrichYoutubeMetadataIfMissing(node.link, parsedMetadata)
: parsedMetadata;
// Generate new description using the description service
const newDescription = await generateDescription({
title: node.title,
content: node.content || undefined,
link: node.link || undefined,
metadata: node.metadata as { source?: string; channel_name?: string; author?: string; site_name?: string } | undefined,
type: (node.metadata as { type?: string } | null)?.type,
metadata: enrichedMetadata,
type: enrichedMetadata?.type,
dimensions: node.dimensions || []
});
// Update the node with the new description
const updatedNode = await nodeService.updateNode(nodeId, {
description: newDescription
description: newDescription,
metadata: enrichedMetadata ?? parsedMetadata ?? node.metadata
});
return NextResponse.json({
+6
View File
@@ -5,6 +5,7 @@ import { autoEmbedQueue } from '@/services/embedding/autoEmbedQueue';
import { hasSufficientContent } from '@/services/embedding/constants';
import { DimensionService } from '@/services/database/dimensionService';
import { generateDescription } from '@/services/database/descriptionService';
import { scheduleAutoEdgeCreation } from '@/services/agents/autoEdge';
export const runtime = 'nodejs';
@@ -126,6 +127,11 @@ export async function POST(request: NextRequest) {
autoEmbedQueue.enqueue(node.id, { reason: 'node_created' });
}
// Schedule auto-edge creation (fire-and-forget, non-blocking)
if (node.id) {
scheduleAutoEdgeCreation(node.id);
}
return NextResponse.json({
success: true,
data: node,