@andespindola/brainlink 0.1.0-beta.69 → 0.1.0-beta.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1623,7 +1623,13 @@ const worldViewportBounds = () => {
1623
1623
  const rect = canvas.getBoundingClientRect()
1624
1624
  const width = Math.max(rect.width, 320)
1625
1625
  const height = Math.max(rect.height, 320)
1626
- const padding = viewportPaddingPx
1626
+ const paddingMultiplier =
1627
+ state.nodes.length > massiveGraphNodeThreshold
1628
+ ? (state.transform.scale >= 0.6 ? 2.8 : state.transform.scale >= 0.25 ? 2.35 : 1.9)
1629
+ : state.nodes.length > largeGraphNodeThreshold
1630
+ ? 1.45
1631
+ : 1
1632
+ const padding = viewportPaddingPx * paddingMultiplier
1627
1633
 
1628
1634
  return {
1629
1635
  minX: (-state.transform.x - padding) / state.transform.scale,
@@ -1639,6 +1645,13 @@ const isNodeInViewport = (node, viewport) =>
1639
1645
  node.y >= viewport.minY &&
1640
1646
  node.y <= viewport.maxY
1641
1647
 
1648
+ const expandViewportBounds = (viewport, worldMargin) => ({
1649
+ minX: viewport.minX - worldMargin,
1650
+ maxX: viewport.maxX + worldMargin,
1651
+ minY: viewport.minY - worldMargin,
1652
+ maxY: viewport.maxY + worldMargin
1653
+ })
1654
+
1642
1655
  const viewportNodeStride = () => {
1643
1656
  if (state.nodes.length <= largeGraphNodeThreshold) {
1644
1657
  return 1
@@ -1766,11 +1779,22 @@ const computeRenderVisibility = () => {
1766
1779
  const viewportNodes = viewportNodesFromSpatialIndex(viewport)
1767
1780
  const sourceNodes = viewportNodes.length > 0 ? viewportNodes : state.visibleNodes
1768
1781
  const sampleLimit = nodeBudgetForScale(state.transform.scale)
1769
- const layeredNodes = selectLayeredNodesForScale(sourceNodes, sampleLimit)
1782
+ const carryMargin = Math.max(240, Math.min(1200, 340 / Math.max(state.transform.scale, 0.0001)))
1783
+ const carryViewport = expandViewportBounds(viewport, carryMargin)
1784
+ const carryOverLimit = Math.max(180, Math.min(900, sampleLimit))
1785
+ const carryOverNodes = (state.renderNodes ?? [])
1786
+ .filter((node) => isNodeInViewport(node, carryViewport))
1787
+ .slice(0, carryOverLimit)
1788
+ const sourceWithCarry = mergeUniqueNodes(
1789
+ sourceNodes,
1790
+ carryOverNodes,
1791
+ Math.max(sampleLimit * 7, carryOverLimit)
1792
+ )
1793
+ const layeredNodes = selectLayeredNodesForScale(sourceWithCarry, sampleLimit)
1770
1794
  const bridgeLimit = Math.max(24, Math.min(180, Math.floor(sampleLimit * 0.26)))
1771
1795
  const bridgedNodes = mergeUniqueNodes(
1772
1796
  layeredNodes,
1773
- selectAccessBridgeNodes(sourceNodes, bridgeLimit),
1797
+ selectAccessBridgeNodes(sourceWithCarry, bridgeLimit),
1774
1798
  Math.min(renderNodeBudget, sampleLimit + bridgeLimit)
1775
1799
  )
1776
1800
  const sampled = selectStableSampleNodes(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andespindola/brainlink",
3
- "version": "0.1.0-beta.69",
3
+ "version": "0.1.0-beta.70",
4
4
  "description": "Local-first knowledge memory for agents with Markdown, backlinks, indexing and context retrieval.",
5
5
  "type": "module",
6
6
  "license": "MIT",