Compare commits
1 commit
main
...
claude/fix
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb2040a227 |
1 changed files with 18 additions and 8 deletions
|
|
@ -238,6 +238,14 @@ async function renderGraph(): Promise<void> {
|
||||||
)
|
)
|
||||||
parentMap.value = computedParentMap
|
parentMap.value = computedParentMap
|
||||||
|
|
||||||
|
// Guard against dangling edges (source/target not in the node set). Both
|
||||||
|
// backends can emit them in edge cases — e.g. ON_PAGE edges whose page_no
|
||||||
|
// doesn't match any returned Page node, or DERIVED_FROM edges crossing
|
||||||
|
// document boundaries in Neo4j. Cytoscape-dagre auto-creates a skeleton
|
||||||
|
// graphlib entry for the missing endpoint with undefined data, then crashes
|
||||||
|
// in its ordering phase when it tries to set `.order` on that entry.
|
||||||
|
const nodeIds = new Set(payload.value.nodes.map((n) => n.id))
|
||||||
|
|
||||||
const elements = [
|
const elements = [
|
||||||
...payload.value.nodes.map((n) => ({
|
...payload.value.nodes.map((n) => ({
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -256,14 +264,16 @@ async function renderGraph(): Promise<void> {
|
||||||
raw: n,
|
raw: n,
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
...payload.value.edges.map((e) => ({
|
...payload.value.edges
|
||||||
data: {
|
.filter((e) => nodeIds.has(e.source) && nodeIds.has(e.target))
|
||||||
id: e.id,
|
.map((e) => ({
|
||||||
source: e.source,
|
data: {
|
||||||
target: e.target,
|
id: e.id,
|
||||||
type: e.type,
|
source: e.source,
|
||||||
},
|
target: e.target,
|
||||||
})),
|
type: e.type,
|
||||||
|
},
|
||||||
|
})),
|
||||||
]
|
]
|
||||||
|
|
||||||
cy.value = cytoscape({
|
cy.value = cytoscape({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue