mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-11 09:25:35 +08:00
Memory management: - Vendor mimalloc v2.1.9 as global allocator (MI_OVERRIDE=1 in prod) - New mem.h/mem.c: RSS-based budget tracking via mi_process_info() - Remove vmem.c/vmem.h (mmap-based budget tracking) - Remove slab tier2 bump allocator (~300 LOC); >64B goes to mimalloc - Slab tier1 pages from malloc (= mimalloc) instead of vmem - Arena blocks from malloc instead of vmem - Budget raised from 35% to 50% RAM (no more untracked C++ heap) Extraction-phase prescan (eliminates disk re-reads): - HTTP call sites: keyword check + URL extraction during extraction - HTTP routes: decorator + source-based extraction during extraction - Config file refs: regex scan during extraction - httplinks: 41.8s → 13ms on Linux kernel (3,212x faster) - configlink: 41.4s → 0.8s on Linux kernel (54x faster) - Linux kernel fast-mode total: 2m38s → 1m18s Bug fixes: - __init__.py Module QN no longer collides with Folder QN - index.ts same fix for JS/TS packages - 13 regression tests for QN collision at FQN + extraction layers - search_graph/search_code default limit raised from 10 to 500k - Resolve all clang-tidy, cppcheck, and clang-format warnings Repo cleanup: - tree-sitter-form, tree-sitter-magma moved to tools/ - .gitignore: build/, node_modules/, graph-ui/dist/, TEST_PLAN.md
64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
import { useCallback, useState } from "react";
|
|
import type { GraphData } from "../lib/types";
|
|
|
|
interface UseGraphDataResult {
|
|
data: GraphData | null;
|
|
loading: boolean;
|
|
error: string | null;
|
|
fetchOverview: (project: string) => void;
|
|
fetchDetail: (project: string, centerNode: string) => void;
|
|
}
|
|
|
|
async function fetchLayout(
|
|
project: string,
|
|
maxNodes = 50000,
|
|
): Promise<GraphData> {
|
|
const params = new URLSearchParams({ project, max_nodes: String(maxNodes) });
|
|
const res = await fetch(`/api/layout?${params}`);
|
|
|
|
if (!res.ok) {
|
|
const body = await res.json().catch(() => ({ error: res.statusText }));
|
|
throw new Error(body.error ?? `HTTP ${res.status}`);
|
|
}
|
|
|
|
return res.json();
|
|
}
|
|
|
|
export function useGraphData(): UseGraphDataResult {
|
|
const [data, setData] = useState<GraphData | null>(null);
|
|
const [loading, setLoading] = useState(false);
|
|
const [error, setError] = useState<string | null>(null);
|
|
|
|
const fetchOverview = useCallback(async (project: string) => {
|
|
setLoading(true);
|
|
setError(null);
|
|
try {
|
|
const result = await fetchLayout(project, 50000);
|
|
setData(result);
|
|
} catch (e) {
|
|
setError(e instanceof Error ? e.message : "Failed to fetch layout");
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
}, []);
|
|
|
|
const fetchDetail = useCallback(
|
|
async (project: string, _centerNode: string) => {
|
|
setLoading(true);
|
|
setError(null);
|
|
try {
|
|
/* TODO: detail level with center_node filtering */
|
|
const result = await fetchLayout(project, 50000);
|
|
setData(result);
|
|
} catch (e) {
|
|
setError(e instanceof Error ? e.message : "Failed to fetch layout");
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
},
|
|
[],
|
|
);
|
|
|
|
return { data, loading, error, fetchOverview, fetchDetail };
|
|
}
|