Skip to content

fix(memory-graph): popover fallback now picks the side with the most space#1264

Open
abhay-codes07 wants to merge 1 commit into
supermemoryai:mainfrom
abhay-codes07:fix/graph-popover-quadrant-fallback
Open

fix(memory-graph): popover fallback now picks the side with the most space#1264
abhay-codes07 wants to merge 1 commit into
supermemoryai:mainfrom
abhay-codes07:fix/graph-popover-quadrant-fallback

Conversation

@abhay-codes07

Copy link
Copy Markdown
Contributor

What

pickBestQuadrant decides which side of a node the hover popover opens on. When no side fully fits the popover, it's supposed to fall back to the side with the most room — but the fit check flattened each side's measured space to -1 before the fallback sort ran:

const fits: [Quadrant, number][] = [
    ["right", spaceRight >= popoverWidth ? spaceRight : -1],
    ...
]
...
return fits.sort((a, b) => b[1] - a[1])[0]?.[0] ?? "right"

Once every entry is -1 the sort is meaningless and the fallback always answers "right" — even for a node hugging the right edge of a small container where the left side has ~45× more space. The clamping that follows then slides the popover over the node it's annotating.

Fix

Keep the raw space measurement alongside the required size for each side. The preference pass (right → left → below → above) still returns the first side that fully fits — behaviour there is unchanged, including exact-fit boundaries — but the fallback can now genuinely rank sides by available space.

The helper is exported so it can be unit-tested directly.

Testing

  • New tests in src/__tests__/popover-quadrant.test.ts cover the preference order, the exact-fit boundary, and three fallback scenarios (node hugging the right edge / top / bottom) that the old code all answered with "right"
  • bun run test in packages/memory-graph — 196 pass
  • bun run check-types — clean

…most space

pickBestQuadrant flattened each side's available space to -1 when the
popover did not fully fit, then sorted those values for the fallback.
Once every side was -1 the sort was meaningless and the fallback always
returned right, even for a node hugging the right edge of the
container where the left side has ~45x more room. The clamped popover
then slides over the node it is annotating.

Keep the raw space measurements alongside the required size so the
preference pass still checks fit, while the fallback can genuinely
rank sides by available space. Also export the helper and cover the
preference order, the exact-fit boundary, and the fallback ranking
with unit tests.
Copilot AI review requested due to automatic review settings July 12, 2026 18:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants