diff --git a/backend/src/graph/store.ts b/backend/src/graph/store.ts index a8fe7a7..3348202 100644 --- a/backend/src/graph/store.ts +++ b/backend/src/graph/store.ts @@ -70,7 +70,7 @@ export async function reachFrom(podId: string, startNodeId: string): Promise('graph_edges') - .aggregate<{ reaches: GraphEdgeDoc[] }>([ + .aggregate([ { $match: { podId, source: startNodeId } }, { $graphLookup: { @@ -80,9 +80,25 @@ export async function reachFrom(podId: string, startNodeId: string): Promise r.reaches) }; + + // Include the direct outbound edges (the $match rows) plus everything reachable + // from them, de-duped by edge id. Without the direct rows, edges straight off + // the start node go missing unless a cycle happens to re-discover them. + const seen = new Set(); + const reaches: GraphEdgeDoc[] = []; + for (const row of rows) { + const { reaches: recursive, ...direct } = row; + for (const edge of [direct as GraphEdgeDoc, ...(recursive ?? [])]) { + if (edge?.id && !seen.has(edge.id)) { + seen.add(edge.id); + reaches.push(edge); + } + } + } + return { start: startNodeId, reaches }; } diff --git a/frontend/src/components/GraphView.tsx b/frontend/src/components/GraphView.tsx index 66254fc..ad2b58b 100644 --- a/frontend/src/components/GraphView.tsx +++ b/frontend/src/components/GraphView.tsx @@ -245,7 +245,16 @@ export function GraphView({ podId, onClose }: { podId: string; onClose: () => vo setSelected((cur) => (cur === n.id ? null : n.id))} + onKeyDown={(ev) => { + if (ev.key === 'Enter' || ev.key === ' ') { + ev.preventDefault(); + setSelected((cur) => (cur === n.id ? null : n.id)); + } + }} >