Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

fix(ui): render the Projects page immediately; fetch schemas lazily

Martin Vogel71a80ed15165
diff --git a/graph-ui/src/components/StatsTab.tsx b/graph-ui/src/components/StatsTab.tsx
index 644805812..fd32d39eb 100644
--- a/graph-ui/src/components/StatsTab.tsx
+++ b/graph-ui/src/components/StatsTab.tsx
@@ -506,8 +506,10 @@ export function StatsTab({ onSelectProject }: StatsTabProps) {
const aggregate = useMemo(() => {
let totalNodes = 0, totalEdges = 0;
for (const p of projects) {
- totalNodes += p.schema?.node_labels?.reduce((s, l) => s + l.count, 0) ?? 0;
- totalEdges += p.schema?.edge_types?.reduce((s, t) => s + t.count, 0) ?? 0;
+ totalNodes +=
+ p.project.nodes ?? p.schema?.node_labels?.reduce((s, l) => s + l.count, 0) ?? 0;
+ totalEdges +=
+ p.project.edges ?? p.schema?.edge_types?.reduce((s, t) => s + t.count, 0) ?? 0;
}
return { projects: projects.length, nodes: totalNodes, edges: totalEdges };
}, [projects]);
@@ -556,8 +558,10 @@ export function StatsTab({ onSelectProject }: StatsTabProps) {
<div className="space-y-3">
{projects.map((p) => {
- const totalNodes = p.schema?.node_labels?.reduce((s, l) => s + l.count, 0) ?? 0;
- const totalEdges = p.schema?.edge_types?.reduce((s, t) => s + t.count, 0) ?? 0;
+ const totalNodes =
+ p.project.nodes ?? p.schema?.node_labels?.reduce((s, l) => s + l.count, 0) ?? 0;
+ const totalEdges =
+ p.project.edges ?? p.schema?.edge_types?.reduce((s, t) => s + t.count, 0) ?? 0;
return (
<div key={p.project.name} className="rounded-xl border border-border/30 bg-white/[0.02] hover:bg-white/[0.035] transition-all p-5">
<div className="flex items-start justify-between gap-3 mb-3">
diff --git a/graph-ui/src/hooks/useProjects.ts b/graph-ui/src/hooks/useProjects.ts
index 5deff5215..12767a036 100644
--- a/graph-ui/src/hooks/useProjects.ts
+++ b/graph-ui/src/hooks/useProjects.ts
@@ -19,6 +19,11 @@ export function useProjects(): UseProjectsResult {
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
+ /* Schemas above this size are not fetched: get_graph_schema scans every
+ * node and edge, which on a multi-million-node index takes ~30 s. The card
+ * still shows totals from list_projects; only the label chips are absent. */
+ const SCHEMA_LAZY_MAX_NODES = 1_000_000;
+
const fetchProjects = useCallback(async () => {
setLoading(true);
setError(null);
@@ -26,24 +31,30 @@ export function useProjects(): UseProjectsResult {
const result = await callTool<{ projects: Project[] }>("list_projects");
const list = result.projects ?? [];
- /* Fetch schema for each project */
- const infos: ProjectInfo[] = await Promise.all(
- list.map(async (p) => {
- try {
- const schema = await callTool<SchemaInfo>("get_graph_schema", {
- project: p.name,
- });
- return { project: p, schema };
- } catch {
- return { project: p, schema: null };
- }
- }),
- );
-
- setProjects(infos);
+ /* Render immediately from list_projects' own totals… */
+ setProjects(list.map((p) => ({ project: p, schema: null })));
+ setLoading(false);
+
+ /* …then enrich with per-label schemas one at a time, patching each
+ * card as its schema lands. Sequential on purpose: N parallel schema
+ * scans would serialize behind the store lock anyway. */
+ for (const p of list) {
+ if ((p.nodes ?? 0) > SCHEMA_LAZY_MAX_NODES) continue;
+ try {
+ const schema = await callTool<SchemaInfo>("get_graph_schema", {
+ project: p.name,
+ });
+ setProjects((prev) =>
+ prev.map((info) =>
+ info.project.name === p.name ? { ...info, schema } : info,
+ ),
+ );
+ } catch {
+ /* card keeps its totals; chips stay absent */
+ }
+ }
} catch (e) {
setError(e instanceof Error ? e.message : "Failed to fetch projects");
- } finally {
setLoading(false);
}
}, []);
diff --git a/graph-ui/src/lib/types.ts b/graph-ui/src/lib/types.ts
index 76df89c33..c3c74743b 100644
--- a/graph-ui/src/lib/types.ts
+++ b/graph-ui/src/lib/types.ts
@@ -104,6 +104,10 @@ export interface Project {
name: string;
root_path: string;
indexed_at: string;
+ /* Totals reported by list_projects — render these immediately; the
+ * per-label schema arrives lazily (a 13 GB index takes ~30 s to scan). */
+ nodes?: number;
+ edges?: number;
}
export interface SchemaInfo {