Skip to content

Offer a node's own menu on right-click, to add a pin - #76

Merged
matt-edmondson merged 2 commits into
mainfrom
claude/issue-36-node-context-menu
Sep 22, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
claude/issue-36-node-context-menu

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #36

What changed

Right-clicking a node opened the create-node palette — the same menu empty canvas offers — so the only way to grow a variadic slot was to select the node and press the inspector's +. The gesture now decides which menu it means: over a node it opens that node's own menu, over empty canvas it opens the palette exactly as before.

The node menu offers one entry per slot that can hold another child (Add Parameters, Add Body, …), and picking one makes the same undoable edit AddChild already makes for the inspector. A node whose every slot holds one child says so rather than opening empty, the way the dropped-link menu does.

  • AstSchema.GrowableSlotsOf — which slots a child can be added to, answered where the rest of the node's shape is, so the draw call holds no rule of its own
  • AstGraphEditor.RequestNodeMenu(nodeId) — offers the menu without the gesture, mirroring RequestCreateFrom, so a host can bind it to a key and a test can drive it
  • AstGraphEditor.DrawNodeMenu — the popup itself, following the dropped-link menu's shape

Removing a pin is deliberately not here: the slot is an ordered sequence, so which child the user means is a question a node-level menu cannot ask, and disconnecting the child already says it. That is #35's half.

Tests

  • AstSchemaTests — three headless tests over GrowableSlotsOf: the variadic slots kept in pin order, a node whose slots all hold one child, and a leaf
  • AstGraphEditorNodeMenuTests — six rendered-frame tests through ImGuiAppHarness: the entry per growable slot, picking one adding and undoing, the "nothing to add" case, dismissal changing nothing, the refusal for a node outside the graph, and a real right-click on the node opening its menu rather than the palette

Each was proved to fail without the change, by three mutations run separately: reverting the right-click routing fails the gesture test alone (1 of 9), drawing no menu entries fails 4 of 6 menu tests, and dropping the cardinality filter fails the schema test and the "nothing to add" case.

Full suite on the branch: 894 passed, 0 failed. Release build clean, 0 warnings.

🤖 Generated with Claude Code

https://claude.ai/code/session_011gZgXrkFA4Fy13yuxgmqKz


Generated by Claude Code

…nor]

Right-clicking a node opened the create-node palette, the same menu empty
canvas offers, so the only way to grow a variadic slot was to select the node
and press the inspector's +. The gesture now decides which menu it means: over
a node it opens that node's own menu, over empty canvas the palette as before.

The menu offers one entry per slot that can hold another child, which is the
same undoable edit the inspector's + makes, and says so rather than opening
empty when the node has no such slot. Which slots those are is a fact about the
node's shape, so AstSchema.GrowableSlotsOf answers it and the draw call holds no
rule of its own.

Removing a pin is deliberately left out: the slot is an ordered sequence, so
which child the user means is a question a node-level menu cannot ask.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011gZgXrkFA4Fy13yuxgmqKz
MSTEST0068 on the test this PR adds: Assert.AreSequenceEqual rather than
CollectionAssert.AreEqual. The rest of the file keeps CollectionAssert, since
Sonar reads only new code and rewriting the file is not this PR's business.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011gZgXrkFA4Fy13yuxgmqKz
matt-edmondson pushed a commit that referenced this pull request Sep 22, 2026
The same MSTEST0068 family Sonar raised on #76: Assert.Contains rather than
CollectionAssert.Contains, on the line this PR adds. The two pre-existing uses
in AstGraphTests keep theirs, since Sonar reads only new code and rewriting
them is not this PR's business.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011gZgXrkFA4Fy13yuxgmqKz
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit d26cbd7 into main Sep 22, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the claude/issue-36-node-context-menu branch September 22, 2026 07:47
matt-edmondson pushed a commit that referenced this pull request Sep 22, 2026
#76 landed the node's own menu on the same gesture this branch gives the pin,
so both rewrote the one right-click handler. Settled as the PR said it would
be: pin first, then node, then the palette — a pin sits inside a node, so a
click over both is about the pin, the narrower target being the one it took aim
to hit. The three-way choice is now OfferOwnMenu, so DrawPalette still reads as
one decision rather than a chain.

One behaviour follows from the order rather than from either side: a node's
output pin has no menu of its own, so a right-click on one now falls through to
the node's menu where before it opened the palette. That is whose actions they
are. The remark on RequestPinMenu and the gesture test both say so now — the
test asserting the node's menu answers a click on the title bar is what tells
the two menus apart rather than one shadowing the other.

905 tests pass on the merge.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011gZgXrkFA4Fy13yuxgmqKz
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.

Right clicking on a node should give a context menu to add pins where supported by the node type

2 participants